diff options
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/global_history.c | 21 | ||||
-rw-r--r-- | desktop/global_history.h | 9 | ||||
-rw-r--r-- | desktop/hotlist.c | 21 | ||||
-rw-r--r-- | desktop/hotlist.h | 9 | ||||
-rw-r--r-- | desktop/treeview.c | 9 | ||||
-rw-r--r-- | desktop/treeview.h | 8 |
6 files changed, 77 insertions, 0 deletions
diff --git a/desktop/global_history.c b/desktop/global_history.c index 191ff1966..94521e7c3 100644 --- a/desktop/global_history.c +++ b/desktop/global_history.c @@ -950,6 +950,27 @@ bool global_history_has_selection(void) /* Exported interface, documented in global_history.h */ +bool global_history_get_selection(nsurl **url, const char **title) +{ + struct global_history_entry *e; + void *v; + + treeview_get_selection(gh_ctx.tree, &v); + if (v == NULL) { + *url = NULL; + *title = NULL; + return false; + } + + e = (struct global_history_entry *)v; + + *url = e->url; + *title = e->data[GH_TITLE].value; + return true; +} + + +/* Exported interface, documented in global_history.h */ nserror global_history_expand(bool only_folders) { return treeview_expand(gh_ctx.tree, only_folders); diff --git a/desktop/global_history.h b/desktop/global_history.h index 4ebe13980..7c49cfcb7 100644 --- a/desktop/global_history.h +++ b/desktop/global_history.h @@ -110,6 +110,15 @@ void global_history_keypress(uint32_t key); bool global_history_has_selection(void); /** + * Get the first selected node + * + * \param url Updated to the selected entry's address, or NULL + * \param title Updated to the selected entry's title, or NULL + * \return true iff global history has a selection + */ +bool global_history_get_selection(nsurl **url, const char **title); + +/** * Expand the treeview's nodes * * \param only_folders Iff true, only folders are expanded. diff --git a/desktop/hotlist.c b/desktop/hotlist.c index fde4c33cf..bedb09535 100644 --- a/desktop/hotlist.c +++ b/desktop/hotlist.c @@ -1483,6 +1483,27 @@ bool hotlist_has_selection(void) /* Exported interface, documented in hotlist.h */ +bool hotlist_get_selection(nsurl **url, const char **title) +{ + struct hotlist_entry *e; + void *v; + + treeview_get_selection(hl_ctx.tree, &v); + if (v == NULL) { + *url = NULL; + *title = NULL; + return false; + } + + e = (struct hotlist_entry *)v; + + *url = e->url; + *title = e->data[HL_TITLE].value; + return true; +} + + +/* Exported interface, documented in hotlist.h */ void hotlist_edit_selection(void) { treeview_edit_selection(hl_ctx.tree); diff --git a/desktop/hotlist.h b/desktop/hotlist.h index c6e74f2cc..e5ae83499 100644 --- a/desktop/hotlist.h +++ b/desktop/hotlist.h @@ -201,6 +201,15 @@ void hotlist_keypress(uint32_t key); bool hotlist_has_selection(void); /** + * Get the first selected node + * + * \param url Updated to the selected entry's address, or NULL + * \param title Updated to the selected entry's title, or NULL + * \return true iff hotlist has a selection + */ +bool hotlist_get_selection(nsurl **url, const char **title); + +/** * Edit the first selected node */ void hotlist_edit_selection(void); diff --git a/desktop/treeview.c b/desktop/treeview.c index 6b74c9033..d1eae4030 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -2075,6 +2075,15 @@ static treeview_node * treeview_get_first_selected(treeview *tree) } +/* Exported interface, documented in treeview.h */ +void treeview_get_selection(treeview *tree, void **node_data) +{ + assert(tree != NULL); + + *node_data = treeview_get_first_selected(tree); +} + + /** * Clear any selection in a treeview * diff --git a/desktop/treeview.h b/desktop/treeview.h index 6fe6521dc..8f5c44ebd 100644 --- a/desktop/treeview.h +++ b/desktop/treeview.h @@ -376,6 +376,14 @@ void treeview_mouse_action(treeview *tree, bool treeview_has_selection(treeview *tree); /** + * Get the first selected node + * + * \param tree Treeview object to get selected node in + * \param node_data Client data for the selected treeview node, or NULL + */ +void treeview_get_selection(treeview *tree, void **node_data); + +/** * Edit the first selected node * * \param tree Treeview object to edit selected node in |