Add function to remove any entries with given URL.
This commit is contained in:
parent
184650c7d8
commit
44e33001d7
|
@ -1064,7 +1064,7 @@ nserror hotlist_fini(const char *path)
|
|||
|
||||
|
||||
/* Exported interface, documented in hotlist.h */
|
||||
nserror hotlist_add(nsurl *url)
|
||||
nserror hotlist_add_url(nsurl *url)
|
||||
{
|
||||
treeview_node *entry;
|
||||
nserror err;
|
||||
|
@ -1125,6 +1125,46 @@ bool hotlist_has_url(nsurl *url)
|
|||
}
|
||||
|
||||
|
||||
struct treeview_remove_url_walk_ctx {
|
||||
nsurl *url;
|
||||
};
|
||||
/** Callback for treeview_walk */
|
||||
static nserror hotlist_remove_url_walk_cb(void *ctx, void *node_data,
|
||||
enum treeview_node_type type, bool *abort)
|
||||
{
|
||||
struct treeview_remove_url_walk_ctx *tw = ctx;
|
||||
|
||||
if (type == TREE_NODE_ENTRY) {
|
||||
struct hotlist_entry *e = node_data;
|
||||
|
||||
if (nsurl_compare(e->url, tw->url, NSURL_COMPLETE) == true) {
|
||||
/* Found what we're looking for: delete it */
|
||||
treeview_delete_node(hl_ctx.tree, e->entry);
|
||||
}
|
||||
}
|
||||
|
||||
return NSERROR_OK;
|
||||
}
|
||||
/* Exported interface, documented in hotlist.h */
|
||||
void hotlist_remove_url(nsurl *url)
|
||||
{
|
||||
nserror err;
|
||||
struct treeview_remove_url_walk_ctx tw = {
|
||||
.url = url
|
||||
};
|
||||
|
||||
if (hl_ctx.built == false)
|
||||
return;
|
||||
|
||||
err = treeview_walk(hl_ctx.tree, NULL, NULL, hotlist_remove_url_walk_cb,
|
||||
&tw, TREE_NODE_ENTRY);
|
||||
if (err != NSERROR_OK)
|
||||
return;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Exported interface, documented in hotlist.h */
|
||||
void hotlist_redraw(int x, int y, struct rect *clip,
|
||||
const struct redraw_context *ctx)
|
||||
|
|
|
@ -54,12 +54,12 @@ nserror hotlist_init(struct core_window_callback_table *cw_t,
|
|||
nserror hotlist_fini(const char *path);
|
||||
|
||||
/**
|
||||
* Add an entry to the hotlist.
|
||||
* Add an entry to the hotlist for given URL.
|
||||
*
|
||||
* \param url URL for node being added
|
||||
* \return NSERROR_OK on success, appropriate error otherwise
|
||||
*/
|
||||
nserror hotlist_add(nsurl *url);
|
||||
nserror hotlist_add_url(nsurl *url);
|
||||
|
||||
/**
|
||||
* Check whether given URL is present in hotlist
|
||||
|
@ -69,6 +69,13 @@ nserror hotlist_add(nsurl *url);
|
|||
*/
|
||||
bool hotlist_has_url(nsurl *url);
|
||||
|
||||
/**
|
||||
* Remove any entries matching the given URL from the hotlist
|
||||
*
|
||||
* \param url Address to look for in hotlist
|
||||
*/
|
||||
void hotlist_remove_url(nsurl *url);
|
||||
|
||||
/**
|
||||
* Redraw the hotlist.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue