Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/32d2dda01c097be6a214499afa91d99bd198559e
...commit
http://git.netsurf-browser.org/netsurf.git/commit/32d2dda01c097be6a214499afa91d99bd198559e
...tree
http://git.netsurf-browser.org/netsurf.git/tree/32d2dda01c097be6a214499afa91d99bd198559e
The branch, master has been updated
via 32d2dda01c097be6a214499afa91d99bd198559e (commit)
via c60ab801f3cdd4cb7519245a9084fa7c6d4f66a8 (commit)
via 512a4335dae3fc27675cc6ba4ccfd219f20bfdba (commit)
via 354656b442cb9583fe8f690e9aa3e58ff50b6dce (commit)
via 4e5e9f1f5af2e526a87f38936aed0c4c100b5051 (commit)
via b6be869f19994070ec522d19455ea7eb47965be4 (commit)
via ded1979fa1b77ea6261df7a7f6f9177bde433f2d (commit)
via 7750d926adf3740448ec2fada2e207a4b5bd5851 (commit)
via 93fdbcc6de0d82323a67bc4c2d560f90a1f396cd (commit)
via b93ae2c28f2e1d3d4e0d20c5a5d09c930c49fb88 (commit)
via fb0cdfed79e5d55cf25a4e7866f0b084fde4ed2b (commit)
from 5f32f9ddd61ebd873ebb825c6e32d82e8965d840 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=32d2dda01c097be6a214499afa91d99bd198559e
commit 32d2dda01c097be6a214499afa91d99bd198559e
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
Old tree code compat layer: Update so it still builds.
diff --git a/desktop/tree.c b/desktop/tree.c
index 6acf179..b5f444d 100644
--- a/desktop/tree.c
+++ b/desktop/tree.c
@@ -139,10 +139,12 @@ static bool treeview_test_init(struct tree *tree)
guit->misc->warning("Couldn't init new global
history.", 0);
break;
case TREE_HOTLIST:
- err = hotlist_init(&cw_t, (struct core_window *)tree,
- tree_hotlist_path);
+ err = hotlist_init(tree_hotlist_path);
if (err != NSERROR_OK)
guit->misc->warning("Couldn't init new hotlist.", 0);
+ err = hotlist_manager_init(&cw_t, (struct core_window *)tree);
+ if (err != NSERROR_OK)
+ guit->misc->warning("Couldn't init hotlist manager.",
0);
break;
case TREE_SSLCERT:
assert(ssl_current_session == NULL &&
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=c60ab801f3cdd4cb7519245a9084fa7c6d4f66a8
commit c60ab801f3cdd4cb7519245a9084fa7c6d4f66a8
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
Windows: Update for new hotlist API.
This allows the hotlist backend to work before the hotlist window opens.
diff --git a/frontends/windows/hotlist.c b/frontends/windows/hotlist.c
index 88a802f..c184619 100644
--- a/frontends/windows/hotlist.c
+++ b/frontends/windows/hotlist.c
@@ -41,8 +41,6 @@
*/
struct nsw32_hotlist_window {
struct nsw32_corewindow core;
-
- const char *path; /**< path to users bookmarks */
};
/** hotlist window singleton */
@@ -147,11 +145,8 @@ static nserror nsw32_hotlist_init(HINSTANCE hInstance)
return res;
}
- ncwin->path = nsoption_charp(hotlist_path);
-
- res = hotlist_init(ncwin->core.cb_table,
- (struct core_window *)ncwin,
- ncwin->path);
+ res = hotlist_manager_init(ncwin->core.cb_table,
+ (struct core_window *)ncwin);
if (res != NSERROR_OK) {
free(ncwin);
return res;
@@ -187,7 +182,7 @@ nserror nsw32_hotlist_finalise(void)
return NSERROR_OK;
}
- res = hotlist_fini(hotlist_window->path);
+ res = hotlist_fini(nsoption_charp(hotlist_path));
if (res == NSERROR_OK) {
res = nsw32_corewindow_fini(&hotlist_window->core);
DestroyWindow(hotlist_window->core.hWnd);
diff --git a/frontends/windows/main.c b/frontends/windows/main.c
index da0fcc1..442c71b 100644
--- a/frontends/windows/main.c
+++ b/frontends/windows/main.c
@@ -38,6 +38,7 @@
#include "netsurf/fetch.h"
#include "netsurf/misc.h"
#include "netsurf/netsurf.h"
+#include "desktop/hotlist.h"
#include "windows/findfile.h"
#include "windows/file.h"
@@ -370,6 +371,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR
lpcli, int ncmd)
urldb_load(nsoption_charp(url_file));
urldb_load_cookies(nsoption_charp(cookie_file));
+ hotlist_init(nsoption_charp(hotlist_path));
ret = nsws_create_main_class(hInstance);
ret = nsws_create_drawable_class(hInstance);
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=512a4335dae3fc27675cc6ba4ccfd219f20bfdba
commit 512a4335dae3fc27675cc6ba4ccfd219f20bfdba
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
Atari: Update for new hotlist API.
diff --git a/frontends/atari/hotlist.c b/frontends/atari/hotlist.c
index 655b623..0f4a5c2 100644
--- a/frontends/atari/hotlist.c
+++ b/frontends/atari/hotlist.c
@@ -73,7 +73,7 @@ static nserror atari_hotlist_init_phase2(struct core_window
*cw,
struct core_window_callback_table
*cb_t)
{
LOG("cw:%p", cw);
- return(hotlist_init(cb_t, cw, hl.path));
+ return(hotlist_manager_init(cb_t, cw);
}
static void atari_hotlist_finish(struct core_window *cw)
@@ -199,6 +199,7 @@ void atari_hotlist_init(void)
}
LOG("Hotlist: %s", (char *)&hl.path);
+ hotlist_init(hl.path);
if( hl.window == NULL ){
int flags = ATARI_TREEVIEW_WIDGETS;
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=354656b442cb9583fe8f690e9aa3e58ff50b6dce
commit 354656b442cb9583fe8f690e9aa3e58ff50b6dce
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
RISC OS: Update for new hotlist API.
This allows the hotlist backend to work before the hotlist window opens.
diff --git a/frontends/riscos/gui.c b/frontends/riscos/gui.c
index 3ac9d4a..27b81d9 100644
--- a/frontends/riscos/gui.c
+++ b/frontends/riscos/gui.c
@@ -55,6 +55,7 @@
#include "netsurf/cookie_db.h"
#include "netsurf/url_db.h"
#include "desktop/save_complete.h"
+#include "desktop/hotlist.h"
#include "content/backing_store.h"
#include "riscos/gui.h"
@@ -1178,9 +1179,10 @@ static nserror gui_init(int argc, char** argv)
/* Initialise save complete functionality */
save_complete_init();
- /* Load in visited URLs and Cookies */
+ /* Load in visited URLs, Cookies, and hostlist */
urldb_load(nsoption_charp(url_path));
urldb_load_cookies(nsoption_charp(cookie_file));
+ hotlist_init(nsoption_charp(hotlist_path));
/* Initialise with the wimp */
error = xwimp_initialise(wimp_VERSION_RO38, task_name,
diff --git a/frontends/riscos/hotlist.c b/frontends/riscos/hotlist.c
index 24ced69..5eb3026 100644
--- a/frontends/riscos/hotlist.c
+++ b/frontends/riscos/hotlist.c
@@ -496,9 +496,8 @@ static nserror ro_hotlist_init(void)
return res;
}
- res = hotlist_init(ncwin->core.cb_table,
- (struct core_window *)ncwin,
- nsoption_charp(hotlist_path));
+ res = hotlist_manager_init(ncwin->core.cb_table,
+ (struct core_window *)ncwin);
if (res != NSERROR_OK) {
free(ncwin);
return res;
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=4e5e9f1f5af2e526a87f38936aed0c4c100b5051
commit 4e5e9f1f5af2e526a87f38936aed0c4c100b5051
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
gtk: Update for new hotlist API.
This allows the hotlist backend to work before the hotlist window opens.
diff --git a/frontends/gtk/gui.c b/frontends/gtk/gui.c
index d128dc2..c08ab0a 100644
--- a/frontends/gtk/gui.c
+++ b/frontends/gtk/gui.c
@@ -49,6 +49,7 @@
#include "desktop/save_complete.h"
#include "desktop/save_pdf.h"
#include "desktop/searchweb.h"
+#include "desktop/hotlist.h"
#include "gtk/compat.h"
#include "gtk/warn.h"
@@ -290,6 +291,7 @@ static nserror nsgtk_init(int argc, char** argv, char
**respath)
urldb_load(nsoption_charp(url_file));
urldb_load_cookies(nsoption_charp(cookie_file));
+ hotlist_init(nsoption_charp(hotlist_path));
/* The tree view system needs to know the screen's DPI, so we
* find that out here, rather than when we create a first browser
diff --git a/frontends/gtk/hotlist.c b/frontends/gtk/hotlist.c
index f64600a..6ce9060 100644
--- a/frontends/gtk/hotlist.c
+++ b/frontends/gtk/hotlist.c
@@ -45,7 +45,6 @@ struct nsgtk_hotlist_window {
struct nsgtk_corewindow core;
GtkBuilder *builder;
GtkWindow *wnd;
- const char *path; /**< path to users bookmarks */
};
static struct nsgtk_hotlist_window *hotlist_window = NULL;
@@ -361,11 +360,8 @@ static nserror nsgtk_hotlist_init(void)
return res;
}
- ncwin->path = nsoption_charp(hotlist_path);
-
- res = hotlist_init(ncwin->core.cb_table,
- (struct core_window *)ncwin,
- ncwin->path);
+ res = hotlist_manager_init(ncwin->core.cb_table,
+ (struct core_window *)ncwin);
if (res != NSERROR_OK) {
free(ncwin);
return res;
@@ -402,7 +398,7 @@ nserror nsgtk_hotlist_destroy(void)
return NSERROR_OK;
}
- res = hotlist_fini(hotlist_window->path);
+ res = hotlist_fini(nsoption_charp(hotlist_path));
if (res == NSERROR_OK) {
res = nsgtk_corewindow_fini(&hotlist_window->core);
gtk_widget_destroy(GTK_WIDGET(hotlist_window->wnd));
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=b6be869f19994070ec522d19455ea7eb47965be4
commit b6be869f19994070ec522d19455ea7eb47965be4
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
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.
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index e344b3b..78473c7 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 31aa030..c77ac92 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.
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=ded1979fa1b77ea6261df7a7f6f9177bde433f2d
commit ded1979fa1b77ea6261df7a7f6f9177bde433f2d
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
Treeview: Add API for attaching and detaching from corewindows.
diff --git a/desktop/treeview.c b/desktop/treeview.c
index c348146..1d0ac52 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -1422,6 +1422,35 @@ nserror treeview_create(treeview **tree,
/* Exported interface, documented in treeview.h */
+nserror treeview_cw_attach(treeview *tree,
+ const struct core_window_callback_table *cw_t,
+ struct core_window *cw)
+{
+ assert(cw_t != NULL);
+ assert(cw != NULL);
+
+ if (tree->cw_t != NULL || tree->cw_h != NULL) {
+ LOG("Treeview already attached.");
+ return NSERROR_UNKNOWN;
+ }
+ tree->cw_t = cw_t;
+ tree->cw_h = cw;
+
+ return NSERROR_OK;
+}
+
+
+/* Exported interface, documented in treeview.h */
+nserror treeview_cw_detach(treeview *tree)
+{
+ tree->cw_t = NULL;
+ tree->cw_h = NULL;
+
+ return NSERROR_OK;
+}
+
+
+/* Exported interface, documented in treeview.h */
nserror treeview_destroy(treeview *tree)
{
int f;
diff --git a/desktop/treeview.h b/desktop/treeview.h
index abe0e56..518f045 100644
--- a/desktop/treeview.h
+++ b/desktop/treeview.h
@@ -150,6 +150,28 @@ nserror treeview_create(treeview **tree,
struct core_window *cw, treeview_flags flags);
/**
+ * Attach a treeview to a corewindow.
+ *
+ * Treeview must be detached.
+ *
+ * \param tree Treeview object
+ * \param cw_t Callback table for core_window containing the treeview
+ * \param cw The core_window in which the treeview is shown
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror treeview_cw_attach(treeview *tree,
+ const struct core_window_callback_table *cw_t,
+ struct core_window *cw);
+
+/**
+ * Detach a treeview from a corewindow
+ *
+ * \param tree Treeview object
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror treeview_cw_detach(treeview *tree);
+
+/**
* Destroy a treeview object
*
* \param tree Treeview object to destroy
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=7750d926adf3740448ec2fada2e207a4b5bd5851
commit 7750d926adf3740448ec2fada2e207a4b5bd5851
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
Treeview: Allow treeview to be created "detached".
This allows treeviews to be constructed before their corewindow.
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 4c405ba..c348146 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -1346,8 +1346,7 @@ nserror treeview_create(treeview **tree,
nserror error;
int i;
- assert(cw_t != NULL);
- assert(cw != NULL);
+ assert((cw_t == NULL && cw == NULL) || (cw_t != NULL && cw != NULL));
assert(callbacks != NULL);
assert(fields != NULL);
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=93fdbcc6de0d82323a67bc4c2d560f90a1f396cd
commit 93fdbcc6de0d82323a67bc4c2d560f90a1f396cd
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
Treeview: Don't call corewindow callbacks if not attached to a corewindow.
diff --git a/desktop/treeview.c b/desktop/treeview.c
index fa8abc9..4c405ba 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -229,7 +229,9 @@ static inline void treeview__cw_redraw_request(
const struct treeview *tree,
const struct rect *r)
{
- tree->cw_t->redraw_request(tree->cw_h, r);
+ if (tree->cw_t != NULL) {
+ tree->cw_t->redraw_request(tree->cw_h, r);
+ }
}
@@ -244,7 +246,9 @@ static inline void treeview__cw_update_size(
const struct treeview *tree,
int width, int height)
{
- tree->cw_t->update_size(tree->cw_h, width, height);
+ if (tree->cw_t != NULL) {
+ tree->cw_t->update_size(tree->cw_h, width, height);
+ }
}
@@ -259,7 +263,9 @@ static inline void treeview__cw_get_window_dimensions(
const struct treeview *tree,
int *width, int *height)
{
- tree->cw_t->get_window_dimensions(tree->cw_h, width, height);
+ if (tree->cw_t != NULL) {
+ tree->cw_t->get_window_dimensions(tree->cw_h, width, height);
+ }
}
@@ -273,7 +279,9 @@ static inline void treeview__cw_drag_status(
const struct treeview *tree,
core_window_drag_status ds)
{
- tree->cw_t->drag_status(tree->cw_h, ds);
+ if (tree->cw_t != NULL) {
+ tree->cw_t->drag_status(tree->cw_h, ds);
+ }
}
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=b93ae2c28f2e1d3d4e0d20c5a5d09c930c49fb88
commit b93ae2c28f2e1d3d4e0d20c5a5d09c930c49fb88
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
Treeview: Convert to using corewindow callback wrappers.
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 38a6062..fa8abc9 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -663,7 +663,7 @@ nserror treeview_create_node_folder(treeview *tree,
if (n->parent->flags & TV_NFLAGS_EXPANDED) {
/* Inform front end of change in dimensions */
if (!(flags & TREE_OPTION_SUPPRESS_RESIZE))
- tree->cw_t->update_size(tree->cw_h, -1,
+ treeview__cw_update_size(tree, -1,
tree->root->height);
/* Redraw */
@@ -673,7 +673,7 @@ nserror treeview_create_node_folder(treeview *tree,
r.y0 = treeview_node_y(tree, n);
r.x1 = REDRAW_MAX;
r.y1 = tree->root->height;
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
}
}
@@ -723,7 +723,7 @@ nserror treeview_update_node_folder(treeview *tree,
r.y0 = treeview_node_y(tree, folder);
r.x1 = REDRAW_MAX;
r.y1 = r.y0 + tree_g.line_height;
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
}
return NSERROR_OK;
@@ -794,7 +794,7 @@ nserror treeview_update_node_entry(treeview *tree,
r.y0 = treeview_node_y(tree, entry);
r.x1 = REDRAW_MAX;
r.y1 = r.y0 + entry->height;
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
}
return NSERROR_OK;
@@ -869,7 +869,7 @@ nserror treeview_create_node_entry(treeview *tree,
if (n->parent->flags & TV_NFLAGS_EXPANDED) {
/* Inform front end of change in dimensions */
if (!(flags & TREE_OPTION_SUPPRESS_RESIZE))
- tree->cw_t->update_size(tree->cw_h, -1,
+ treeview__cw_update_size(tree, -1,
tree->root->height);
/* Redraw */
@@ -879,7 +879,7 @@ nserror treeview_create_node_entry(treeview *tree,
r.y0 = treeview_node_y(tree, n);
r.x1 = REDRAW_MAX;
r.y1 = tree->root->height;
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
}
}
@@ -1000,7 +1000,7 @@ static void treeview_edit_cancel(treeview *tree, bool
redraw)
r.y0 = tree->edit.y;
r.x1 = tree->edit.x + tree->edit.w;
r.y1 = tree->edit.y + tree->edit.h;
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
}
}
@@ -1168,7 +1168,7 @@ static nserror treeview_delete_node_internal(treeview
*tree, treeview_node *n,
if (tree->root != NULL && p != NULL && p->flags & TV_NFLAGS_EXPANDED &&
nd.h_reduction > 0 &&
!(flags & TREE_OPTION_SUPPRESS_RESIZE)) {
- tree->cw_t->update_size(tree->cw_h, -1,
+ treeview__cw_update_size(tree, -1,
tree->root->height);
}
@@ -1311,7 +1311,7 @@ nserror treeview_delete_node(treeview *tree,
treeview_node *n,
if (tree->root->height != h) {
r.y0 = 0;
if (!(flags & TREE_OPTION_SUPPRESS_RESIZE)) {
- tree->cw_t->update_size(tree->cw_h, -1,
+ treeview__cw_update_size(tree, -1,
tree->root->height);
}
}
@@ -1321,7 +1321,7 @@ nserror treeview_delete_node(treeview *tree,
treeview_node *n,
if (visible && !(flags & TREE_OPTION_SUPPRESS_REDRAW)) {
r.x0 = 0;
r.x1 = REDRAW_MAX;
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
}
return NSERROR_OK;
@@ -1527,7 +1527,7 @@ static nserror treeview_node_expand_internal(treeview
*tree,
/* Inform front end of change in dimensions */
if (additional_height != 0)
- tree->cw_t->update_size(tree->cw_h, -1, tree->root->height);
+ treeview__cw_update_size(tree, -1, tree->root->height);
return NSERROR_OK;
}
@@ -1549,7 +1549,7 @@ nserror treeview_node_expand(treeview *tree,
treeview_node *node)
r.y1 = tree->root->height;
/* Redraw */
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
return NSERROR_OK;
}
@@ -1621,7 +1621,7 @@ static nserror treeview_node_contract_internal(treeview
*tree,
node->flags |= TV_NFLAGS_SELECTED;
/* Inform front end of change in dimensions */
- tree->cw_t->update_size(tree->cw_h, -1, tree->root->height);
+ treeview__cw_update_size(tree, -1, tree->root->height);
return NSERROR_OK;
}
@@ -1645,7 +1645,7 @@ nserror treeview_node_contract(treeview *tree,
treeview_node *node)
return err;
/* Redraw */
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
return NSERROR_OK;
}
@@ -1688,10 +1688,10 @@ nserror treeview_contract(treeview *tree, bool all)
}
/* Inform front end of change in dimensions */
- tree->cw_t->update_size(tree->cw_h, -1, tree->root->height);
+ treeview__cw_update_size(tree, -1, tree->root->height);
/* Redraw */
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
return NSERROR_OK;
}
@@ -1745,7 +1745,7 @@ nserror treeview_expand(treeview *tree, bool only_folders)
r.y1 = tree->root->height;
/* Redraw */
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
return NSERROR_OK;
}
@@ -2532,7 +2532,7 @@ static nserror treeview_move_selection(treeview *tree,
struct rect *rect)
/* Tell window, if height has changed */
if (height != tree->root->height)
- tree->cw_t->update_size(tree->cw_h, -1, tree->root->height);
+ treeview__cw_update_size(tree, -1, tree->root->height);
/* TODO: Deal with redraw area properly */
rect->x0 = 0;
@@ -2840,7 +2840,7 @@ bool treeview_keypress(treeview *tree, uint32_t key)
/* Inform front end of change in dimensions */
if (tree->root->height != h) {
r.y0 = 0;
- tree->cw_t->update_size(tree->cw_h, -1,
+ treeview__cw_update_size(tree, -1,
tree->root->height);
}
}
@@ -2864,7 +2864,7 @@ bool treeview_keypress(treeview *tree, uint32_t key)
}
if (redraw) {
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
}
return true;
@@ -3021,7 +3021,7 @@ static void treeview_textarea_callback(void *data, struct
textarea_msg *msg)
/* Textarea drag started */
tree->drag.type = TV_DRAG_TEXTAREA;
}
- tree->cw_t->drag_status(tree->cw_h, tree->drag.type);
+ treeview__cw_drag_status(tree, tree->drag.type);
break;
case TEXTAREA_MSG_REDRAW_REQUEST:
@@ -3032,7 +3032,7 @@ static void treeview_textarea_callback(void *data, struct
textarea_msg *msg)
r->y1 += tree->edit.y;
/* Redraw the textarea */
- tree->cw_t->redraw_request(tree->cw_h, r);
+ treeview__cw_redraw_request(tree, r);
break;
default:
@@ -3102,7 +3102,7 @@ static bool treeview_edit_node_at_point(treeview *tree,
treeview_node *n,
}
/* Get window width/height */
- tree->cw_t->get_window_dimensions(tree->cw_h, &width, &height);
+ treeview__cw_get_window_dimensions(tree, &width, &height);
/* Anow textarea width/height */
field_x = n->inset + tree_g.step_width + tree_g.icon_step - 3;
@@ -3205,7 +3205,7 @@ void treeview_edit_selection(treeview *tree)
rect.y0 = y;
rect.x1 = REDRAW_MAX;
rect.y1 = y + tree_g.line_height;
- tree->cw_t->redraw_request(tree->cw_h, &rect);
+ treeview__cw_redraw_request(tree, &rect);
}
@@ -3324,7 +3324,7 @@ static nserror
treeview_node_mouse_action_cb(treeview_node *node, void *ctx,
ma->tree->drag.selected == false &&
ma->tree->drag.part == TV_NODE_PART_NONE) {
ma->tree->drag.type = TV_DRAG_SELECTION;
- ma->tree->cw_t->drag_status(ma->tree->cw_h,
+ treeview__cw_drag_status(ma->tree,
CORE_WINDOW_DRAG_SELECTION);
} else if (!(ma->tree->flags & TREEVIEW_NO_MOVES) &&
@@ -3332,13 +3332,13 @@ static nserror
treeview_node_mouse_action_cb(treeview_node *node, void *ctx,
(ma->tree->drag.selected == true ||
ma->tree->drag.part == TV_NODE_PART_ON_NODE)) {
ma->tree->drag.type = TV_DRAG_MOVE;
- ma->tree->cw_t->drag_status(ma->tree->cw_h,
+ treeview__cw_drag_status(ma->tree,
CORE_WINDOW_DRAG_MOVE);
redraw |= treeview_propagate_selection(ma->tree, &r);
} else if (ma->mouse & BROWSER_MOUSE_DRAG_2) {
ma->tree->drag.type = TV_DRAG_SELECTION;
- ma->tree->cw_t->drag_status(ma->tree->cw_h,
+ treeview__cw_drag_status(ma->tree,
CORE_WINDOW_DRAG_SELECTION);
}
@@ -3465,7 +3465,7 @@ static nserror
treeview_node_mouse_action_cb(treeview_node *node, void *ctx,
}
if (redraw) {
- ma->tree->cw_t->redraw_request(ma->tree->cw_h, &r);
+ treeview__cw_redraw_request(ma->tree, &r);
}
*end = true; /* Reached line with click; stop walking tree */
@@ -3514,8 +3514,7 @@ void treeview_mouse_action(treeview *tree,
tree->drag.type = TV_DRAG_NONE;
tree->drag.start_node = NULL;
- tree->cw_t->drag_status(tree->cw_h,
- CORE_WINDOW_DRAG_NONE);
+ treeview__cw_drag_status(tree, CORE_WINDOW_DRAG_NONE);
return;
case TV_DRAG_MOVE:
treeview_move_selection(tree, &r);
@@ -3525,9 +3524,8 @@ void treeview_mouse_action(treeview *tree,
tree->move.target = NULL;
tree->move.target_pos = TV_TARGET_NONE;
- tree->cw_t->drag_status(tree->cw_h,
- CORE_WINDOW_DRAG_NONE);
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_drag_status(tree, CORE_WINDOW_DRAG_NONE);
+ treeview__cw_redraw_request(tree, &r);
return;
default:
/* No drag to end */
@@ -3564,11 +3562,11 @@ void treeview_mouse_action(treeview *tree,
tree->drag.selected == false &&
tree->drag.part == TV_NODE_PART_NONE) {
tree->drag.type = TV_DRAG_SELECTION;
- tree->cw_t->drag_status(tree->cw_h,
+ treeview__cw_drag_status(tree,
CORE_WINDOW_DRAG_SELECTION);
} else if (mouse & BROWSER_MOUSE_DRAG_2) {
tree->drag.type = TV_DRAG_SELECTION;
- tree->cw_t->drag_status(tree->cw_h,
+ treeview__cw_drag_status(tree,
CORE_WINDOW_DRAG_SELECTION);
}
@@ -3602,7 +3600,7 @@ void treeview_mouse_action(treeview *tree,
}
if (redraw) {
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
}
} else {
@@ -3627,7 +3625,7 @@ int treeview_get_height(treeview *tree)
assert(tree != NULL);
assert(tree->root != NULL);
- tree->cw_t->update_size(tree->cw_h, -1, tree->root->height);
+ treeview__cw_update_size(tree, -1, tree->root->height);
return tree->root->height;
}
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=fb0cdfed79e5d55cf25a4e7866f0b084fde4ed2b
commit fb0cdfed79e5d55cf25a4e7866f0b084fde4ed2b
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
Treeview: Add wrappers for corewindow callbacks.
Currently unused.
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 34e524d..38a6062 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -219,6 +219,64 @@ static struct treeview_resource
treeview_res[TREE_RES_LAST] = {
}; /**< Treeview content resources */
+/**
+ * Corewindow callback wrapper: Request a redraw of the window
+ *
+ * \param[in] cw the core window object
+ * \param[in] r rectangle to redraw
+ */
+static inline void treeview__cw_redraw_request(
+ const struct treeview *tree,
+ const struct rect *r)
+{
+ tree->cw_t->redraw_request(tree->cw_h, r);
+}
+
+
+/**
+ * Corewindow callback wrapper: Update the limits of the window
+ *
+ * \param[in] cw the core window object
+ * \param[in] width the width in px, or negative if don't care
+ * \param[in] height the height in px, or negative if don't care
+ */
+static inline void treeview__cw_update_size(
+ const struct treeview *tree,
+ int width, int height)
+{
+ tree->cw_t->update_size(tree->cw_h, width, height);
+}
+
+
+/**
+ * Corewindow callback wrapper: Get window viewport dimensions
+ *
+ * \param[in] cw the core window object
+ * \param[out] width to be set to viewport width in px
+ * \param[out] height to be set to viewport height in px
+ */
+static inline void treeview__cw_get_window_dimensions(
+ const struct treeview *tree,
+ int *width, int *height)
+{
+ tree->cw_t->get_window_dimensions(tree->cw_h, width, height);
+}
+
+
+/**
+ * Corewindow callback wrapper: Inform corewindow owner of drag status
+ *
+ * \param[in] cw the core window object
+ * \param[in] ds the current drag status
+ */
+static inline void treeview__cw_drag_status(
+ const struct treeview *tree,
+ core_window_drag_status ds)
+{
+ tree->cw_t->drag_status(tree->cw_h, ds);
+}
+
+
/* Helper function to access the given field of a node
*
* \param tree Treeview that node belongs to
-----------------------------------------------------------------------
Summary of changes:
desktop/hotlist.c | 39 ++++++++--
desktop/hotlist.h | 36 +++++++--
desktop/tree.c | 6 +-
desktop/treeview.c | 170 +++++++++++++++++++++++++++++++++----------
desktop/treeview.h | 22 ++++++
frontends/atari/hotlist.c | 3 +-
frontends/gtk/gui.c | 2 +
frontends/gtk/hotlist.c | 10 +--
frontends/riscos/gui.c | 4 +-
frontends/riscos/hotlist.c | 5 +-
frontends/windows/hotlist.c | 11 +--
frontends/windows/main.c | 2 +
12 files changed, 239 insertions(+), 71 deletions(-)
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index e344b3b..78473c7 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 31aa030..c77ac92 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.
diff --git a/desktop/tree.c b/desktop/tree.c
index 6acf179..b5f444d 100644
--- a/desktop/tree.c
+++ b/desktop/tree.c
@@ -139,10 +139,12 @@ static bool treeview_test_init(struct tree *tree)
guit->misc->warning("Couldn't init new global
history.", 0);
break;
case TREE_HOTLIST:
- err = hotlist_init(&cw_t, (struct core_window *)tree,
- tree_hotlist_path);
+ err = hotlist_init(tree_hotlist_path);
if (err != NSERROR_OK)
guit->misc->warning("Couldn't init new hotlist.", 0);
+ err = hotlist_manager_init(&cw_t, (struct core_window *)tree);
+ if (err != NSERROR_OK)
+ guit->misc->warning("Couldn't init hotlist manager.",
0);
break;
case TREE_SSLCERT:
assert(ssl_current_session == NULL &&
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 34e524d..1d0ac52 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -219,6 +219,72 @@ static struct treeview_resource
treeview_res[TREE_RES_LAST] = {
}; /**< Treeview content resources */
+/**
+ * Corewindow callback wrapper: Request a redraw of the window
+ *
+ * \param[in] cw the core window object
+ * \param[in] r rectangle to redraw
+ */
+static inline void treeview__cw_redraw_request(
+ const struct treeview *tree,
+ const struct rect *r)
+{
+ if (tree->cw_t != NULL) {
+ tree->cw_t->redraw_request(tree->cw_h, r);
+ }
+}
+
+
+/**
+ * Corewindow callback wrapper: Update the limits of the window
+ *
+ * \param[in] cw the core window object
+ * \param[in] width the width in px, or negative if don't care
+ * \param[in] height the height in px, or negative if don't care
+ */
+static inline void treeview__cw_update_size(
+ const struct treeview *tree,
+ int width, int height)
+{
+ if (tree->cw_t != NULL) {
+ tree->cw_t->update_size(tree->cw_h, width, height);
+ }
+}
+
+
+/**
+ * Corewindow callback wrapper: Get window viewport dimensions
+ *
+ * \param[in] cw the core window object
+ * \param[out] width to be set to viewport width in px
+ * \param[out] height to be set to viewport height in px
+ */
+static inline void treeview__cw_get_window_dimensions(
+ const struct treeview *tree,
+ int *width, int *height)
+{
+ if (tree->cw_t != NULL) {
+ tree->cw_t->get_window_dimensions(tree->cw_h, width, height);
+ }
+}
+
+
+/**
+ * Corewindow callback wrapper: Inform corewindow owner of drag status
+ *
+ * \param[in] cw the core window object
+ * \param[in] ds the current drag status
+ */
+static inline void treeview__cw_drag_status(
+ const struct treeview *tree,
+ core_window_drag_status ds)
+{
+ if (tree->cw_t != NULL) {
+ tree->cw_t->drag_status(tree->cw_h, ds);
+ }
+}
+
+
/* Helper function to access the given field of a node
*
* \param tree Treeview that node belongs to
@@ -605,7 +671,7 @@ nserror treeview_create_node_folder(treeview *tree,
if (n->parent->flags & TV_NFLAGS_EXPANDED) {
/* Inform front end of change in dimensions */
if (!(flags & TREE_OPTION_SUPPRESS_RESIZE))
- tree->cw_t->update_size(tree->cw_h, -1,
+ treeview__cw_update_size(tree, -1,
tree->root->height);
/* Redraw */
@@ -615,7 +681,7 @@ nserror treeview_create_node_folder(treeview *tree,
r.y0 = treeview_node_y(tree, n);
r.x1 = REDRAW_MAX;
r.y1 = tree->root->height;
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
}
}
@@ -665,7 +731,7 @@ nserror treeview_update_node_folder(treeview *tree,
r.y0 = treeview_node_y(tree, folder);
r.x1 = REDRAW_MAX;
r.y1 = r.y0 + tree_g.line_height;
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
}
return NSERROR_OK;
@@ -736,7 +802,7 @@ nserror treeview_update_node_entry(treeview *tree,
r.y0 = treeview_node_y(tree, entry);
r.x1 = REDRAW_MAX;
r.y1 = r.y0 + entry->height;
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
}
return NSERROR_OK;
@@ -811,7 +877,7 @@ nserror treeview_create_node_entry(treeview *tree,
if (n->parent->flags & TV_NFLAGS_EXPANDED) {
/* Inform front end of change in dimensions */
if (!(flags & TREE_OPTION_SUPPRESS_RESIZE))
- tree->cw_t->update_size(tree->cw_h, -1,
+ treeview__cw_update_size(tree, -1,
tree->root->height);
/* Redraw */
@@ -821,7 +887,7 @@ nserror treeview_create_node_entry(treeview *tree,
r.y0 = treeview_node_y(tree, n);
r.x1 = REDRAW_MAX;
r.y1 = tree->root->height;
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
}
}
@@ -942,7 +1008,7 @@ static void treeview_edit_cancel(treeview *tree, bool
redraw)
r.y0 = tree->edit.y;
r.x1 = tree->edit.x + tree->edit.w;
r.y1 = tree->edit.y + tree->edit.h;
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
}
}
@@ -1110,7 +1176,7 @@ static nserror treeview_delete_node_internal(treeview
*tree, treeview_node *n,
if (tree->root != NULL && p != NULL && p->flags & TV_NFLAGS_EXPANDED &&
nd.h_reduction > 0 &&
!(flags & TREE_OPTION_SUPPRESS_RESIZE)) {
- tree->cw_t->update_size(tree->cw_h, -1,
+ treeview__cw_update_size(tree, -1,
tree->root->height);
}
@@ -1253,7 +1319,7 @@ nserror treeview_delete_node(treeview *tree,
treeview_node *n,
if (tree->root->height != h) {
r.y0 = 0;
if (!(flags & TREE_OPTION_SUPPRESS_RESIZE)) {
- tree->cw_t->update_size(tree->cw_h, -1,
+ treeview__cw_update_size(tree, -1,
tree->root->height);
}
}
@@ -1263,7 +1329,7 @@ nserror treeview_delete_node(treeview *tree,
treeview_node *n,
if (visible && !(flags & TREE_OPTION_SUPPRESS_REDRAW)) {
r.x0 = 0;
r.x1 = REDRAW_MAX;
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
}
return NSERROR_OK;
@@ -1280,8 +1346,7 @@ nserror treeview_create(treeview **tree,
nserror error;
int i;
- assert(cw_t != NULL);
- assert(cw != NULL);
+ assert((cw_t == NULL && cw == NULL) || (cw_t != NULL && cw != NULL));
assert(callbacks != NULL);
assert(fields != NULL);
@@ -1357,6 +1422,35 @@ nserror treeview_create(treeview **tree,
/* Exported interface, documented in treeview.h */
+nserror treeview_cw_attach(treeview *tree,
+ const struct core_window_callback_table *cw_t,
+ struct core_window *cw)
+{
+ assert(cw_t != NULL);
+ assert(cw != NULL);
+
+ if (tree->cw_t != NULL || tree->cw_h != NULL) {
+ LOG("Treeview already attached.");
+ return NSERROR_UNKNOWN;
+ }
+ tree->cw_t = cw_t;
+ tree->cw_h = cw;
+
+ return NSERROR_OK;
+}
+
+
+/* Exported interface, documented in treeview.h */
+nserror treeview_cw_detach(treeview *tree)
+{
+ tree->cw_t = NULL;
+ tree->cw_h = NULL;
+
+ return NSERROR_OK;
+}
+
+
+/* Exported interface, documented in treeview.h */
nserror treeview_destroy(treeview *tree)
{
int f;
@@ -1469,7 +1563,7 @@ static nserror treeview_node_expand_internal(treeview
*tree,
/* Inform front end of change in dimensions */
if (additional_height != 0)
- tree->cw_t->update_size(tree->cw_h, -1, tree->root->height);
+ treeview__cw_update_size(tree, -1, tree->root->height);
return NSERROR_OK;
}
@@ -1491,7 +1585,7 @@ nserror treeview_node_expand(treeview *tree,
treeview_node *node)
r.y1 = tree->root->height;
/* Redraw */
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
return NSERROR_OK;
}
@@ -1563,7 +1657,7 @@ static nserror treeview_node_contract_internal(treeview
*tree,
node->flags |= TV_NFLAGS_SELECTED;
/* Inform front end of change in dimensions */
- tree->cw_t->update_size(tree->cw_h, -1, tree->root->height);
+ treeview__cw_update_size(tree, -1, tree->root->height);
return NSERROR_OK;
}
@@ -1587,7 +1681,7 @@ nserror treeview_node_contract(treeview *tree,
treeview_node *node)
return err;
/* Redraw */
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
return NSERROR_OK;
}
@@ -1630,10 +1724,10 @@ nserror treeview_contract(treeview *tree, bool all)
}
/* Inform front end of change in dimensions */
- tree->cw_t->update_size(tree->cw_h, -1, tree->root->height);
+ treeview__cw_update_size(tree, -1, tree->root->height);
/* Redraw */
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
return NSERROR_OK;
}
@@ -1687,7 +1781,7 @@ nserror treeview_expand(treeview *tree, bool only_folders)
r.y1 = tree->root->height;
/* Redraw */
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
return NSERROR_OK;
}
@@ -2474,7 +2568,7 @@ static nserror treeview_move_selection(treeview *tree,
struct rect *rect)
/* Tell window, if height has changed */
if (height != tree->root->height)
- tree->cw_t->update_size(tree->cw_h, -1, tree->root->height);
+ treeview__cw_update_size(tree, -1, tree->root->height);
/* TODO: Deal with redraw area properly */
rect->x0 = 0;
@@ -2782,7 +2876,7 @@ bool treeview_keypress(treeview *tree, uint32_t key)
/* Inform front end of change in dimensions */
if (tree->root->height != h) {
r.y0 = 0;
- tree->cw_t->update_size(tree->cw_h, -1,
+ treeview__cw_update_size(tree, -1,
tree->root->height);
}
}
@@ -2806,7 +2900,7 @@ bool treeview_keypress(treeview *tree, uint32_t key)
}
if (redraw) {
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
}
return true;
@@ -2963,7 +3057,7 @@ static void treeview_textarea_callback(void *data, struct
textarea_msg *msg)
/* Textarea drag started */
tree->drag.type = TV_DRAG_TEXTAREA;
}
- tree->cw_t->drag_status(tree->cw_h, tree->drag.type);
+ treeview__cw_drag_status(tree, tree->drag.type);
break;
case TEXTAREA_MSG_REDRAW_REQUEST:
@@ -2974,7 +3068,7 @@ static void treeview_textarea_callback(void *data, struct
textarea_msg *msg)
r->y1 += tree->edit.y;
/* Redraw the textarea */
- tree->cw_t->redraw_request(tree->cw_h, r);
+ treeview__cw_redraw_request(tree, r);
break;
default:
@@ -3044,7 +3138,7 @@ static bool treeview_edit_node_at_point(treeview *tree,
treeview_node *n,
}
/* Get window width/height */
- tree->cw_t->get_window_dimensions(tree->cw_h, &width, &height);
+ treeview__cw_get_window_dimensions(tree, &width, &height);
/* Anow textarea width/height */
field_x = n->inset + tree_g.step_width + tree_g.icon_step - 3;
@@ -3147,7 +3241,7 @@ void treeview_edit_selection(treeview *tree)
rect.y0 = y;
rect.x1 = REDRAW_MAX;
rect.y1 = y + tree_g.line_height;
- tree->cw_t->redraw_request(tree->cw_h, &rect);
+ treeview__cw_redraw_request(tree, &rect);
}
@@ -3266,7 +3360,7 @@ static nserror
treeview_node_mouse_action_cb(treeview_node *node, void *ctx,
ma->tree->drag.selected == false &&
ma->tree->drag.part == TV_NODE_PART_NONE) {
ma->tree->drag.type = TV_DRAG_SELECTION;
- ma->tree->cw_t->drag_status(ma->tree->cw_h,
+ treeview__cw_drag_status(ma->tree,
CORE_WINDOW_DRAG_SELECTION);
} else if (!(ma->tree->flags & TREEVIEW_NO_MOVES) &&
@@ -3274,13 +3368,13 @@ static nserror
treeview_node_mouse_action_cb(treeview_node *node, void *ctx,
(ma->tree->drag.selected == true ||
ma->tree->drag.part == TV_NODE_PART_ON_NODE)) {
ma->tree->drag.type = TV_DRAG_MOVE;
- ma->tree->cw_t->drag_status(ma->tree->cw_h,
+ treeview__cw_drag_status(ma->tree,
CORE_WINDOW_DRAG_MOVE);
redraw |= treeview_propagate_selection(ma->tree, &r);
} else if (ma->mouse & BROWSER_MOUSE_DRAG_2) {
ma->tree->drag.type = TV_DRAG_SELECTION;
- ma->tree->cw_t->drag_status(ma->tree->cw_h,
+ treeview__cw_drag_status(ma->tree,
CORE_WINDOW_DRAG_SELECTION);
}
@@ -3407,7 +3501,7 @@ static nserror
treeview_node_mouse_action_cb(treeview_node *node, void *ctx,
}
if (redraw) {
- ma->tree->cw_t->redraw_request(ma->tree->cw_h, &r);
+ treeview__cw_redraw_request(ma->tree, &r);
}
*end = true; /* Reached line with click; stop walking tree */
@@ -3456,8 +3550,7 @@ void treeview_mouse_action(treeview *tree,
tree->drag.type = TV_DRAG_NONE;
tree->drag.start_node = NULL;
- tree->cw_t->drag_status(tree->cw_h,
- CORE_WINDOW_DRAG_NONE);
+ treeview__cw_drag_status(tree, CORE_WINDOW_DRAG_NONE);
return;
case TV_DRAG_MOVE:
treeview_move_selection(tree, &r);
@@ -3467,9 +3560,8 @@ void treeview_mouse_action(treeview *tree,
tree->move.target = NULL;
tree->move.target_pos = TV_TARGET_NONE;
- tree->cw_t->drag_status(tree->cw_h,
- CORE_WINDOW_DRAG_NONE);
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_drag_status(tree, CORE_WINDOW_DRAG_NONE);
+ treeview__cw_redraw_request(tree, &r);
return;
default:
/* No drag to end */
@@ -3506,11 +3598,11 @@ void treeview_mouse_action(treeview *tree,
tree->drag.selected == false &&
tree->drag.part == TV_NODE_PART_NONE) {
tree->drag.type = TV_DRAG_SELECTION;
- tree->cw_t->drag_status(tree->cw_h,
+ treeview__cw_drag_status(tree,
CORE_WINDOW_DRAG_SELECTION);
} else if (mouse & BROWSER_MOUSE_DRAG_2) {
tree->drag.type = TV_DRAG_SELECTION;
- tree->cw_t->drag_status(tree->cw_h,
+ treeview__cw_drag_status(tree,
CORE_WINDOW_DRAG_SELECTION);
}
@@ -3544,7 +3636,7 @@ void treeview_mouse_action(treeview *tree,
}
if (redraw) {
- tree->cw_t->redraw_request(tree->cw_h, &r);
+ treeview__cw_redraw_request(tree, &r);
}
} else {
@@ -3569,7 +3661,7 @@ int treeview_get_height(treeview *tree)
assert(tree != NULL);
assert(tree->root != NULL);
- tree->cw_t->update_size(tree->cw_h, -1, tree->root->height);
+ treeview__cw_update_size(tree, -1, tree->root->height);
return tree->root->height;
}
diff --git a/desktop/treeview.h b/desktop/treeview.h
index abe0e56..518f045 100644
--- a/desktop/treeview.h
+++ b/desktop/treeview.h
@@ -150,6 +150,28 @@ nserror treeview_create(treeview **tree,
struct core_window *cw, treeview_flags flags);
/**
+ * Attach a treeview to a corewindow.
+ *
+ * Treeview must be detached.
+ *
+ * \param tree Treeview object
+ * \param cw_t Callback table for core_window containing the treeview
+ * \param cw The core_window in which the treeview is shown
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror treeview_cw_attach(treeview *tree,
+ const struct core_window_callback_table *cw_t,
+ struct core_window *cw);
+
+/**
+ * Detach a treeview from a corewindow
+ *
+ * \param tree Treeview object
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror treeview_cw_detach(treeview *tree);
+
+/**
* Destroy a treeview object
*
* \param tree Treeview object to destroy
diff --git a/frontends/atari/hotlist.c b/frontends/atari/hotlist.c
index 655b623..0f4a5c2 100644
--- a/frontends/atari/hotlist.c
+++ b/frontends/atari/hotlist.c
@@ -73,7 +73,7 @@ static nserror atari_hotlist_init_phase2(struct core_window
*cw,
struct core_window_callback_table
*cb_t)
{
LOG("cw:%p", cw);
- return(hotlist_init(cb_t, cw, hl.path));
+ return(hotlist_manager_init(cb_t, cw);
}
static void atari_hotlist_finish(struct core_window *cw)
@@ -199,6 +199,7 @@ void atari_hotlist_init(void)
}
LOG("Hotlist: %s", (char *)&hl.path);
+ hotlist_init(hl.path);
if( hl.window == NULL ){
int flags = ATARI_TREEVIEW_WIDGETS;
diff --git a/frontends/gtk/gui.c b/frontends/gtk/gui.c
index d128dc2..c08ab0a 100644
--- a/frontends/gtk/gui.c
+++ b/frontends/gtk/gui.c
@@ -49,6 +49,7 @@
#include "desktop/save_complete.h"
#include "desktop/save_pdf.h"
#include "desktop/searchweb.h"
+#include "desktop/hotlist.h"
#include "gtk/compat.h"
#include "gtk/warn.h"
@@ -290,6 +291,7 @@ static nserror nsgtk_init(int argc, char** argv, char
**respath)
urldb_load(nsoption_charp(url_file));
urldb_load_cookies(nsoption_charp(cookie_file));
+ hotlist_init(nsoption_charp(hotlist_path));
/* The tree view system needs to know the screen's DPI, so we
* find that out here, rather than when we create a first browser
diff --git a/frontends/gtk/hotlist.c b/frontends/gtk/hotlist.c
index f64600a..6ce9060 100644
--- a/frontends/gtk/hotlist.c
+++ b/frontends/gtk/hotlist.c
@@ -45,7 +45,6 @@ struct nsgtk_hotlist_window {
struct nsgtk_corewindow core;
GtkBuilder *builder;
GtkWindow *wnd;
- const char *path; /**< path to users bookmarks */
};
static struct nsgtk_hotlist_window *hotlist_window = NULL;
@@ -361,11 +360,8 @@ static nserror nsgtk_hotlist_init(void)
return res;
}
- ncwin->path = nsoption_charp(hotlist_path);
-
- res = hotlist_init(ncwin->core.cb_table,
- (struct core_window *)ncwin,
- ncwin->path);
+ res = hotlist_manager_init(ncwin->core.cb_table,
+ (struct core_window *)ncwin);
if (res != NSERROR_OK) {
free(ncwin);
return res;
@@ -402,7 +398,7 @@ nserror nsgtk_hotlist_destroy(void)
return NSERROR_OK;
}
- res = hotlist_fini(hotlist_window->path);
+ res = hotlist_fini(nsoption_charp(hotlist_path));
if (res == NSERROR_OK) {
res = nsgtk_corewindow_fini(&hotlist_window->core);
gtk_widget_destroy(GTK_WIDGET(hotlist_window->wnd));
diff --git a/frontends/riscos/gui.c b/frontends/riscos/gui.c
index 3ac9d4a..27b81d9 100644
--- a/frontends/riscos/gui.c
+++ b/frontends/riscos/gui.c
@@ -55,6 +55,7 @@
#include "netsurf/cookie_db.h"
#include "netsurf/url_db.h"
#include "desktop/save_complete.h"
+#include "desktop/hotlist.h"
#include "content/backing_store.h"
#include "riscos/gui.h"
@@ -1178,9 +1179,10 @@ static nserror gui_init(int argc, char** argv)
/* Initialise save complete functionality */
save_complete_init();
- /* Load in visited URLs and Cookies */
+ /* Load in visited URLs, Cookies, and hostlist */
urldb_load(nsoption_charp(url_path));
urldb_load_cookies(nsoption_charp(cookie_file));
+ hotlist_init(nsoption_charp(hotlist_path));
/* Initialise with the wimp */
error = xwimp_initialise(wimp_VERSION_RO38, task_name,
diff --git a/frontends/riscos/hotlist.c b/frontends/riscos/hotlist.c
index 24ced69..5eb3026 100644
--- a/frontends/riscos/hotlist.c
+++ b/frontends/riscos/hotlist.c
@@ -496,9 +496,8 @@ static nserror ro_hotlist_init(void)
return res;
}
- res = hotlist_init(ncwin->core.cb_table,
- (struct core_window *)ncwin,
- nsoption_charp(hotlist_path));
+ res = hotlist_manager_init(ncwin->core.cb_table,
+ (struct core_window *)ncwin);
if (res != NSERROR_OK) {
free(ncwin);
return res;
diff --git a/frontends/windows/hotlist.c b/frontends/windows/hotlist.c
index 88a802f..c184619 100644
--- a/frontends/windows/hotlist.c
+++ b/frontends/windows/hotlist.c
@@ -41,8 +41,6 @@
*/
struct nsw32_hotlist_window {
struct nsw32_corewindow core;
-
- const char *path; /**< path to users bookmarks */
};
/** hotlist window singleton */
@@ -147,11 +145,8 @@ static nserror nsw32_hotlist_init(HINSTANCE hInstance)
return res;
}
- ncwin->path = nsoption_charp(hotlist_path);
-
- res = hotlist_init(ncwin->core.cb_table,
- (struct core_window *)ncwin,
- ncwin->path);
+ res = hotlist_manager_init(ncwin->core.cb_table,
+ (struct core_window *)ncwin);
if (res != NSERROR_OK) {
free(ncwin);
return res;
@@ -187,7 +182,7 @@ nserror nsw32_hotlist_finalise(void)
return NSERROR_OK;
}
- res = hotlist_fini(hotlist_window->path);
+ res = hotlist_fini(nsoption_charp(hotlist_path));
if (res == NSERROR_OK) {
res = nsw32_corewindow_fini(&hotlist_window->core);
DestroyWindow(hotlist_window->core.hWnd);
diff --git a/frontends/windows/main.c b/frontends/windows/main.c
index da0fcc1..442c71b 100644
--- a/frontends/windows/main.c
+++ b/frontends/windows/main.c
@@ -38,6 +38,7 @@
#include "netsurf/fetch.h"
#include "netsurf/misc.h"
#include "netsurf/netsurf.h"
+#include "desktop/hotlist.h"
#include "windows/findfile.h"
#include "windows/file.h"
@@ -370,6 +371,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR
lpcli, int ncmd)
urldb_load(nsoption_charp(url_file));
urldb_load_cookies(nsoption_charp(cookie_file));
+ hotlist_init(nsoption_charp(hotlist_path));
ret = nsws_create_main_class(hInstance);
ret = nsws_create_drawable_class(hInstance);
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org