summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2016-12-29 14:44:48 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2016-12-29 14:44:48 +0000
commitb6be869f19994070ec522d19455ea7eb47965be4 (patch)
tree24ca43ab57a53321fa52a50e2b18bd993ff76399 /desktop
parentded1979fa1b77ea6261df7a7f6f9177bde433f2d (diff)
downloadnetsurf-b6be869f19994070ec522d19455ea7eb47965be4.tar.gz
netsurf-b6be869f19994070ec522d19455ea7eb47965be4.tar.bz2
Hotlist: Allow hotlist initilialisation without hotlist corewindow.
Now, hotlist_init can be called without a corewindow. This allows the hotlist backend to be up and running, before any hostlist manager is opened. Calling hotlist_manager_init attaches the hotlist to a corewindow.
Diffstat (limited to 'desktop')
-rw-r--r--desktop/hotlist.c39
-rw-r--r--desktop/hotlist.h36
2 files changed, 65 insertions, 10 deletions
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index e344b3b57..78473c744 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -1227,8 +1227,7 @@ static nserror hotlist_populate(const char *path)
/* Exported interface, documented in hotlist.h */
-nserror hotlist_init(struct core_window_callback_table *cw_t,
- void *core_window_handle, const char *path)
+nserror hotlist_init(const char *path)
{
nserror err;
@@ -1252,8 +1251,7 @@ nserror hotlist_init(struct core_window_callback_table *cw_t,
/* Create the hotlist treeview */
err = treeview_create(&hl_ctx.tree, &hl_tree_cb_t,
- HL_N_FIELDS, hl_ctx.fields,
- cw_t, core_window_handle,
+ HL_N_FIELDS, hl_ctx.fields, NULL, NULL,
TREEVIEW_NO_FLAGS);
if (err != NSERROR_OK) {
hl_ctx.tree = NULL;
@@ -1271,10 +1269,41 @@ nserror hotlist_init(struct core_window_callback_table *cw_t,
* the treeview is built. */
hl_ctx.built = true;
+ LOG("Loaded hotlist");
+
+ return NSERROR_OK;
+}
+
+
+/* Exported interface, documented in hotlist.h */
+nserror hotlist_manager_init(struct core_window_callback_table *cw_t,
+ void *core_window_handle)
+{
+ nserror err;
+
+ /* Create the hotlist treeview */
+ err = treeview_cw_attach(hl_ctx.tree, cw_t, core_window_handle);
+ if (err != NSERROR_OK) {
+ return err;
+ }
+
/* Inform client of window height */
treeview_get_height(hl_ctx.tree);
- LOG("Loaded hotlist");
+ return NSERROR_OK;
+}
+
+
+/* Exported interface, documented in hotlist.h */
+nserror hotlist_manager_fini(void)
+{
+ nserror err;
+
+ /* Create the hotlist treeview */
+ err = treeview_cw_detach(hl_ctx.tree);
+ if (err != NSERROR_OK) {
+ return err;
+ }
return NSERROR_OK;
}
diff --git a/desktop/hotlist.h b/desktop/hotlist.h
index 31aa0307c..c77ac92d2 100644
--- a/desktop/hotlist.h
+++ b/desktop/hotlist.h
@@ -33,18 +33,44 @@ struct rect;
/**
* Initialise the hotlist.
*
- * This opens the hotlist file, generating the hotlist data, and creates a
+ * This opens the hotlist file, construct the hostlist, and creates a
* treeview. If there's no hotlist file, it generates a default hotlist.
*
- * This must be called before any other hotlist_* function.
+ * This must be called before any other hotlist_* function. It must
+ * be called before URLs can be added to the hotlist, and before the
+ * hotlist can be queried to ask if URLs are present in the hotlist.
+ *
+ * \param path The path to hotlist file to load
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror hotlist_init(const char *path);
+
+/**
+ * Initialise the hotlist manager.
+ *
+ * This connects the underlying hotlist treeview to a corewindow for display.
+ *
+ * The provided core window handle must be valid until hotlist_fini is called.
*
* \param cw_t Callback table for core_window containing the treeview
* \param core_window_handle The handle in which the treeview is shown
- * \param path The path to hotlist file to load
* \return NSERROR_OK on success, appropriate error otherwise
*/
-nserror hotlist_init(struct core_window_callback_table *cw_t,
- void *core_window_handle, const char *path);
+nserror hotlist_manager_init(struct core_window_callback_table *cw_t,
+ void *core_window_handle);
+
+
+/**
+ * Finalise the hotlist manager.
+ *
+ * This simply disconnects the underlying treeview from its corewindow,
+ * allowing destruction of a GUI hotlist window, without finalising the
+ * hotlist module.
+ *
+ * \param path The path to save hotlist to
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror hotlist_manager_fini(void);
/**
* Finalise the hotlist.