netsurf: branch master updated. release/3.0-517-ge8071e6
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/e8071e676c03320ee6371...
...commit http://git.netsurf-browser.org/netsurf.git/commit/e8071e676c03320ee637197...
...tree http://git.netsurf-browser.org/netsurf.git/tree/e8071e676c03320ee63719769...
The branch, master has been updated
via e8071e676c03320ee63719769987eb81980ab5c8 (commit)
via 393dee4fd784ec0f0a32f83b91cfabf034d2a2a6 (commit)
from 541724fb0dc4ba82bce76ad779770d37266c1818 (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=e8071e676c03320ee63...
commit e8071e676c03320ee63719769987eb81980ab5c8
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Remove some redundancy.
diff --git a/desktop/global_history.c b/desktop/global_history.c
index e0c8e39..191ff19 100644
--- a/desktop/global_history.c
+++ b/desktop/global_history.c
@@ -123,61 +123,47 @@ static struct global_history_entry *global_history_find(nsurl *url)
static nserror global_history_create_dir(enum global_history_folders f)
{
nserror err;
- time_t t = gh_ctx.today;
treeview_node *relation = NULL;
enum treeview_relationship rel = TREE_REL_FIRST_CHILD;
const char *label;
- int age;
int i;
switch (f) {
case GH_TODAY:
label = "DateToday";
- age = 0;
break;
case GH_YESTERDAY:
label = "DateYesterday";
- age = 1;
break;
case GH_2_DAYS_AGO:
label = "Date2Days";
- age = 2;
break;
case GH_3_DAYS_AGO:
label = "Date3Days";
- age = 3;
break;
case GH_4_DAYS_AGO:
label = "Date4Days";
- age = 4;
break;
case GH_5_DAYS_AGO:
label = "Date5Days";
- age = 5;
break;
case GH_6_DAYS_AGO:
label = "Date6Days";
- age = 6;
break;
case GH_LAST_WEEK:
label = "Date1Week";
- age = 7;
break;
case GH_2_WEEKS_AGO:
label = "Date2Week";
- age = 14;
break;
case GH_3_WEEKS_AGO:
label = "Date3Week";
- age = 21;
break;
default:
assert(0);
break;
}
- t -= age * N_SEC_PER_DAY;
-
label = messages_get(label);
for (i = f - 1; i >= 0; i--) {
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=393dee4fd784ec0f0a3...
commit 393dee4fd784ec0f0a32f83b91cfabf034d2a2a6
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Squash leak in error case.
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index 68caa20..a25d3f0 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -831,6 +831,7 @@ static nserror hotlist_generate(void)
nsurl_unref(url);
if (err != NSERROR_OK) {
+ free(title);
return NSERROR_NOMEM;
}
}
-----------------------------------------------------------------------
Summary of changes:
desktop/global_history.c | 14 --------------
desktop/hotlist.c | 1 +
2 files changed, 1 insertions(+), 14 deletions(-)
diff --git a/desktop/global_history.c b/desktop/global_history.c
index e0c8e39..191ff19 100644
--- a/desktop/global_history.c
+++ b/desktop/global_history.c
@@ -123,61 +123,47 @@ static struct global_history_entry *global_history_find(nsurl *url)
static nserror global_history_create_dir(enum global_history_folders f)
{
nserror err;
- time_t t = gh_ctx.today;
treeview_node *relation = NULL;
enum treeview_relationship rel = TREE_REL_FIRST_CHILD;
const char *label;
- int age;
int i;
switch (f) {
case GH_TODAY:
label = "DateToday";
- age = 0;
break;
case GH_YESTERDAY:
label = "DateYesterday";
- age = 1;
break;
case GH_2_DAYS_AGO:
label = "Date2Days";
- age = 2;
break;
case GH_3_DAYS_AGO:
label = "Date3Days";
- age = 3;
break;
case GH_4_DAYS_AGO:
label = "Date4Days";
- age = 4;
break;
case GH_5_DAYS_AGO:
label = "Date5Days";
- age = 5;
break;
case GH_6_DAYS_AGO:
label = "Date6Days";
- age = 6;
break;
case GH_LAST_WEEK:
label = "Date1Week";
- age = 7;
break;
case GH_2_WEEKS_AGO:
label = "Date2Week";
- age = 14;
break;
case GH_3_WEEKS_AGO:
label = "Date3Week";
- age = 21;
break;
default:
assert(0);
break;
}
- t -= age * N_SEC_PER_DAY;
-
label = messages_get(label);
for (i = f - 1; i >= 0; i--) {
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index 68caa20..a25d3f0 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -831,6 +831,7 @@ static nserror hotlist_generate(void)
nsurl_unref(url);
if (err != NSERROR_OK) {
+ free(title);
return NSERROR_NOMEM;
}
}
--
NetSurf Browser
9 years, 8 months
netsurf: branch master updated. release/3.0-515-g541724f
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/541724fb0dc4ba82bce76...
...commit http://git.netsurf-browser.org/netsurf.git/commit/541724fb0dc4ba82bce76ad...
...tree http://git.netsurf-browser.org/netsurf.git/tree/541724fb0dc4ba82bce76ad77...
The branch, master has been updated
via 541724fb0dc4ba82bce76ad779770d37266c1818 (commit)
from 1658554437f651a144311c18f21eb2bf449250c1 (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=541724fb0dc4ba82bce...
commit 541724fb0dc4ba82bce76ad779770d37266c1818
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Add hotlist iteration function.
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index 9f98138..68caa20 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -948,6 +948,67 @@ nserror hotlist_export(const char *path, const char *title)
}
+struct hotlist_iterate_ctx {
+ hotlist_folder_enter_cb enter_cb;
+ hotlist_address_cb address_cb;
+ hotlist_folder_leave_cb leave_cb;
+ void *ctx;
+};
+/** Callback for hotlist_iterate node entering */
+static nserror hotlist_iterate_enter_cb(void *ctx, void *node_data,
+ enum treeview_node_type type, bool *abort)
+{
+ struct hotlist_iterate_ctx *data = ctx;
+
+ if (type == TREE_NODE_ENTRY && data->address_cb != NULL) {
+ struct hotlist_entry *e = node_data;
+ data->address_cb(data->ctx, e->url,
+ e->data[HL_TITLE].value);
+
+ } else if (type == TREE_NODE_FOLDER && data->enter_cb != NULL) {
+ struct hotlist_folder *f = node_data;
+ data->enter_cb(data->ctx, f->data.value);
+ }
+
+ return NSERROR_OK;
+}
+/** Callback for hotlist_iterate node leaving */
+static nserror hotlist_iterate_leave_cb(void *ctx, void *node_data,
+ enum treeview_node_type type, bool *abort)
+{
+ struct hotlist_iterate_ctx *data = ctx;
+
+ if (type == TREE_NODE_FOLDER && data->leave_cb != NULL) {
+ data->leave_cb(data->ctx);
+ }
+
+ return NSERROR_OK;
+}
+/* Exported interface, documented in hotlist.h */
+nserror hotlist_iterate(void *ctx,
+ hotlist_folder_enter_cb enter_cb,
+ hotlist_address_cb address_cb,
+ hotlist_folder_leave_cb leave_cb)
+{
+ struct hotlist_iterate_ctx data;
+ nserror err;
+
+ data.enter_cb = enter_cb;
+ data.address_cb = address_cb;
+ data.leave_cb = leave_cb;
+ data.ctx = ctx;
+
+ err = treeview_walk(hl_ctx.tree, NULL,
+ hotlist_iterate_enter_cb,
+ hotlist_iterate_leave_cb,
+ &data, TREE_NODE_ENTRY | TREE_NODE_FOLDER);
+ if (err != NSERROR_OK)
+ return err;
+
+ return NSERROR_OK;
+}
+
+
/**
* Initialise the treeview entry feilds
*
diff --git a/desktop/hotlist.h b/desktop/hotlist.h
index 121eb95..c6e74f2 100644
--- a/desktop/hotlist.h
+++ b/desktop/hotlist.h
@@ -118,6 +118,54 @@ nserror hotlist_add_folder(const char *title, bool at_y, int y);
nserror hotlist_export(const char *path, const char *title);
/**
+ * Client callback for hotlist_iterate, reporting entry into folder
+ *
+ * \param ctx Client context
+ * \param title The entered folder's title
+ * \return NSERROR_OK on success, or appropriate error otherwise
+ */
+typedef nserror (*hotlist_folder_enter_cb)(void *ctx, const char *title);
+
+/**
+ * Client callback for hotlist_iterate, reporting a hotlist address
+ *
+ * \param ctx Client context
+ * \param url The entry's address
+ * \param title The entry's title
+ * \return NSERROR_OK on success, or appropriate error otherwise
+ */
+typedef nserror (*hotlist_address_cb)(void *ctx, nsurl *url, const char *title);
+
+/**
+ * Client callback for hotlist_iterate, reporting a hotlist folder departure
+ *
+ * \param ctx Client context
+ * \param title The departed folder's title
+ * \return NSERROR_OK on success, or appropriate error otherwise
+ */
+typedef nserror (*hotlist_folder_leave_cb)(void *ctx);
+
+
+/**
+ * Walk (depth first) the hotlist, calling callbacks on entering folders,
+ * address nodes, and on leaving folders.
+ *
+ * \param ctx Client context, passed back to callback function
+ * \param enter_cb Function to call on entering nodes, or NULL
+ * \param address_cb Function to call on address nodes, or NULL
+ * \param leave_cb Function to call on leaving nodes, or NULL
+ * \return NSERROR_OK on success, or appropriate error otherwise
+ *
+ * Example usage: Generate a menu containing hotlist entries. For flat list
+ * set enter_cb and leave_cb to NULL, or for hierarchical menu
+ * provide the folder callbacks.
+ */
+nserror hotlist_iterate(void *ctx,
+ hotlist_folder_enter_cb enter_cb,
+ hotlist_address_cb address_cb,
+ hotlist_folder_leave_cb leave_cb);
+
+/**
* Redraw the hotlist.
*
* \param x X coordinate to render treeview at
-----------------------------------------------------------------------
Summary of changes:
desktop/hotlist.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++
desktop/hotlist.h | 48 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 109 insertions(+), 0 deletions(-)
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index 9f98138..68caa20 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -948,6 +948,67 @@ nserror hotlist_export(const char *path, const char *title)
}
+struct hotlist_iterate_ctx {
+ hotlist_folder_enter_cb enter_cb;
+ hotlist_address_cb address_cb;
+ hotlist_folder_leave_cb leave_cb;
+ void *ctx;
+};
+/** Callback for hotlist_iterate node entering */
+static nserror hotlist_iterate_enter_cb(void *ctx, void *node_data,
+ enum treeview_node_type type, bool *abort)
+{
+ struct hotlist_iterate_ctx *data = ctx;
+
+ if (type == TREE_NODE_ENTRY && data->address_cb != NULL) {
+ struct hotlist_entry *e = node_data;
+ data->address_cb(data->ctx, e->url,
+ e->data[HL_TITLE].value);
+
+ } else if (type == TREE_NODE_FOLDER && data->enter_cb != NULL) {
+ struct hotlist_folder *f = node_data;
+ data->enter_cb(data->ctx, f->data.value);
+ }
+
+ return NSERROR_OK;
+}
+/** Callback for hotlist_iterate node leaving */
+static nserror hotlist_iterate_leave_cb(void *ctx, void *node_data,
+ enum treeview_node_type type, bool *abort)
+{
+ struct hotlist_iterate_ctx *data = ctx;
+
+ if (type == TREE_NODE_FOLDER && data->leave_cb != NULL) {
+ data->leave_cb(data->ctx);
+ }
+
+ return NSERROR_OK;
+}
+/* Exported interface, documented in hotlist.h */
+nserror hotlist_iterate(void *ctx,
+ hotlist_folder_enter_cb enter_cb,
+ hotlist_address_cb address_cb,
+ hotlist_folder_leave_cb leave_cb)
+{
+ struct hotlist_iterate_ctx data;
+ nserror err;
+
+ data.enter_cb = enter_cb;
+ data.address_cb = address_cb;
+ data.leave_cb = leave_cb;
+ data.ctx = ctx;
+
+ err = treeview_walk(hl_ctx.tree, NULL,
+ hotlist_iterate_enter_cb,
+ hotlist_iterate_leave_cb,
+ &data, TREE_NODE_ENTRY | TREE_NODE_FOLDER);
+ if (err != NSERROR_OK)
+ return err;
+
+ return NSERROR_OK;
+}
+
+
/**
* Initialise the treeview entry feilds
*
diff --git a/desktop/hotlist.h b/desktop/hotlist.h
index 121eb95..c6e74f2 100644
--- a/desktop/hotlist.h
+++ b/desktop/hotlist.h
@@ -118,6 +118,54 @@ nserror hotlist_add_folder(const char *title, bool at_y, int y);
nserror hotlist_export(const char *path, const char *title);
/**
+ * Client callback for hotlist_iterate, reporting entry into folder
+ *
+ * \param ctx Client context
+ * \param title The entered folder's title
+ * \return NSERROR_OK on success, or appropriate error otherwise
+ */
+typedef nserror (*hotlist_folder_enter_cb)(void *ctx, const char *title);
+
+/**
+ * Client callback for hotlist_iterate, reporting a hotlist address
+ *
+ * \param ctx Client context
+ * \param url The entry's address
+ * \param title The entry's title
+ * \return NSERROR_OK on success, or appropriate error otherwise
+ */
+typedef nserror (*hotlist_address_cb)(void *ctx, nsurl *url, const char *title);
+
+/**
+ * Client callback for hotlist_iterate, reporting a hotlist folder departure
+ *
+ * \param ctx Client context
+ * \param title The departed folder's title
+ * \return NSERROR_OK on success, or appropriate error otherwise
+ */
+typedef nserror (*hotlist_folder_leave_cb)(void *ctx);
+
+
+/**
+ * Walk (depth first) the hotlist, calling callbacks on entering folders,
+ * address nodes, and on leaving folders.
+ *
+ * \param ctx Client context, passed back to callback function
+ * \param enter_cb Function to call on entering nodes, or NULL
+ * \param address_cb Function to call on address nodes, or NULL
+ * \param leave_cb Function to call on leaving nodes, or NULL
+ * \return NSERROR_OK on success, or appropriate error otherwise
+ *
+ * Example usage: Generate a menu containing hotlist entries. For flat list
+ * set enter_cb and leave_cb to NULL, or for hierarchical menu
+ * provide the folder callbacks.
+ */
+nserror hotlist_iterate(void *ctx,
+ hotlist_folder_enter_cb enter_cb,
+ hotlist_address_cb address_cb,
+ hotlist_folder_leave_cb leave_cb);
+
+/**
* Redraw the hotlist.
*
* \param x X coordinate to render treeview at
--
NetSurf Browser
9 years, 8 months
netsurf: branch master updated. release/3.0-514-g1658554
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/1658554437f651a144311...
...commit http://git.netsurf-browser.org/netsurf.git/commit/1658554437f651a144311c1...
...tree http://git.netsurf-browser.org/netsurf.git/tree/1658554437f651a144311c18f...
The branch, master has been updated
via 1658554437f651a144311c18f21eb2bf449250c1 (commit)
from bd38b712c6aa8b3c7ee4c27226364209834428eb (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=1658554437f651a1443...
commit 1658554437f651a144311c18f21eb2bf449250c1
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Don't allow what treeview initialisation sets as the dimensions to be overwritten with defaults of 0.
diff --git a/riscos/treeview.c b/riscos/treeview.c
index 479a857..51b6809 100644
--- a/riscos/treeview.c
+++ b/riscos/treeview.c
@@ -155,12 +155,6 @@ ro_treeview *ro_treeview_create(wimp_w window, struct toolbar *toolbar,
tv->w = window;
tv->tb = toolbar;
- tv->tree = tree_create(flags, &ro_tree_callbacks, tv);
- if (tv->tree == NULL) {
- free(tv);
- return NULL;
- }
-
/* Set the tree redraw origin at a default 0,0 RO units. */
tv->origin.x = 0;
@@ -181,6 +175,12 @@ ro_treeview *ro_treeview_create(wimp_w window, struct toolbar *toolbar,
tv->drag = TREE_NO_DRAG;
+ tv->tree = tree_create(flags, &ro_tree_callbacks, tv);
+ if (tv->tree == NULL) {
+ free(tv);
+ return NULL;
+ }
+
/* Record the callback info. */
tv->callbacks = callbacks;
-----------------------------------------------------------------------
Summary of changes:
riscos/treeview.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/riscos/treeview.c b/riscos/treeview.c
index 479a857..51b6809 100644
--- a/riscos/treeview.c
+++ b/riscos/treeview.c
@@ -155,12 +155,6 @@ ro_treeview *ro_treeview_create(wimp_w window, struct toolbar *toolbar,
tv->w = window;
tv->tb = toolbar;
- tv->tree = tree_create(flags, &ro_tree_callbacks, tv);
- if (tv->tree == NULL) {
- free(tv);
- return NULL;
- }
-
/* Set the tree redraw origin at a default 0,0 RO units. */
tv->origin.x = 0;
@@ -181,6 +175,12 @@ ro_treeview *ro_treeview_create(wimp_w window, struct toolbar *toolbar,
tv->drag = TREE_NO_DRAG;
+ tv->tree = tree_create(flags, &ro_tree_callbacks, tv);
+ if (tv->tree == NULL) {
+ free(tv);
+ return NULL;
+ }
+
/* Record the callback info. */
tv->callbacks = callbacks;
--
NetSurf Browser
9 years, 8 months
netsurf: branch master updated. release/3.0-513-gbd38b71
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/bd38b712c6aa8b3c7ee4c...
...commit http://git.netsurf-browser.org/netsurf.git/commit/bd38b712c6aa8b3c7ee4c27...
...tree http://git.netsurf-browser.org/netsurf.git/tree/bd38b712c6aa8b3c7ee4c2722...
The branch, master has been updated
via bd38b712c6aa8b3c7ee4c27226364209834428eb (commit)
from a9fd785581a8f2d1838bded42f8a59fc4d7da2f5 (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=bd38b712c6aa8b3c7ee...
commit bd38b712c6aa8b3c7ee4c27226364209834428eb
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Avoid an error.
diff --git a/amiga/menu.c b/amiga/menu.c
index d2db1f1..7c42e77 100644
--- a/amiga/menu.c
+++ b/amiga/menu.c
@@ -81,8 +81,10 @@ int menu_glyph_width[NSA_GLYPH_MAX];
bool menu_glyphs_loaded = false;
ULONG ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin);
+#if 0
void ami_menu_scan_2(struct tree *tree, struct node *root, WORD *gen,
int *item, struct gui_window_2 *gwin);
+#endif
void ami_menu_arexx_scan(struct gui_window_2 *gwin);
/* Functions for menu selections */
@@ -565,10 +567,10 @@ ULONG ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin)
#endif
}
+#if 0
void ami_menu_scan_2(struct tree *tree, struct node *root, WORD *gen,
int *item, struct gui_window_2 *gwin)
{
-#if 0
struct node *tempnode;
struct node_element *element=NULL;
struct node *node;
@@ -606,8 +608,8 @@ void ami_menu_scan_2(struct tree *tree, struct node *root, WORD *gen,
}
*gen = *gen - 1;
-#endif
}
+#endif
void ami_menu_update_checked(struct gui_window_2 *gwin)
{
-----------------------------------------------------------------------
Summary of changes:
amiga/menu.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/amiga/menu.c b/amiga/menu.c
index d2db1f1..7c42e77 100644
--- a/amiga/menu.c
+++ b/amiga/menu.c
@@ -81,8 +81,10 @@ int menu_glyph_width[NSA_GLYPH_MAX];
bool menu_glyphs_loaded = false;
ULONG ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin);
+#if 0
void ami_menu_scan_2(struct tree *tree, struct node *root, WORD *gen,
int *item, struct gui_window_2 *gwin);
+#endif
void ami_menu_arexx_scan(struct gui_window_2 *gwin);
/* Functions for menu selections */
@@ -565,10 +567,10 @@ ULONG ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin)
#endif
}
+#if 0
void ami_menu_scan_2(struct tree *tree, struct node *root, WORD *gen,
int *item, struct gui_window_2 *gwin)
{
-#if 0
struct node *tempnode;
struct node_element *element=NULL;
struct node *node;
@@ -606,8 +608,8 @@ void ami_menu_scan_2(struct tree *tree, struct node *root, WORD *gen,
}
*gen = *gen - 1;
-#endif
}
+#endif
void ami_menu_update_checked(struct gui_window_2 *gwin)
{
--
NetSurf Browser
9 years, 8 months
netsurf: branch master updated. release/3.0-512-ga9fd785
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/a9fd785581a8f2d1838bd...
...commit http://git.netsurf-browser.org/netsurf.git/commit/a9fd785581a8f2d1838bded...
...tree http://git.netsurf-browser.org/netsurf.git/tree/a9fd785581a8f2d1838bded42...
The branch, master has been updated
via a9fd785581a8f2d1838bded42f8a59fc4d7da2f5 (commit)
from 80e8465e917d4755fd35a168c9e9b2605b85af33 (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=a9fd785581a8f2d1838...
commit a9fd785581a8f2d1838bded42f8a59fc4d7da2f5
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Some cocoa build fixes.
diff --git a/cocoa/BookmarksController.m b/cocoa/BookmarksController.m
index 96041ab..2f8d9d8 100644
--- a/cocoa/BookmarksController.m
+++ b/cocoa/BookmarksController.m
@@ -164,7 +164,7 @@ static const char *cocoa_hotlist_path( void )
{
struct browser_window *bw = [[(NetSurfApp *)NSApp frontTab] browser];
if (bw && bw->current_content) {
- hotlist_add_url( nsurl_access(hlcache_handle_get_url( bw->current_content )) );
+ hotlist_add_url( hlcache_handle_get_url( bw->current_content ) );
}
}
diff --git a/cocoa/Tree.h b/cocoa/Tree.h
index e38df5a..fbdb7f7 100644
--- a/cocoa/Tree.h
+++ b/cocoa/Tree.h
@@ -38,7 +38,6 @@
}
@property (readwrite, assign, nonatomic) id <TreeDelegate> delegate;
-@property (readwrite, assign, nonatomic, getter=isRedrawing) BOOL redrawing;
- initWithFlags: (unsigned int) flags;
diff --git a/cocoa/Tree.m b/cocoa/Tree.m
index 7da7b68..5e0247a 100644
--- a/cocoa/Tree.m
+++ b/cocoa/Tree.m
@@ -64,11 +64,6 @@ static const struct treeview_table cocoa_tree_callbacks = {
return tree;
}
-- (BOOL) isRedrawing;
-{
- return tree_get_redraw( tree );
-}
-
- (void) setRedrawing: (BOOL) newRedrawing;
{
}
-----------------------------------------------------------------------
Summary of changes:
cocoa/BookmarksController.m | 2 +-
cocoa/Tree.h | 1 -
cocoa/Tree.m | 5 -----
3 files changed, 1 insertions(+), 7 deletions(-)
diff --git a/cocoa/BookmarksController.m b/cocoa/BookmarksController.m
index 96041ab..2f8d9d8 100644
--- a/cocoa/BookmarksController.m
+++ b/cocoa/BookmarksController.m
@@ -164,7 +164,7 @@ static const char *cocoa_hotlist_path( void )
{
struct browser_window *bw = [[(NetSurfApp *)NSApp frontTab] browser];
if (bw && bw->current_content) {
- hotlist_add_url( nsurl_access(hlcache_handle_get_url( bw->current_content )) );
+ hotlist_add_url( hlcache_handle_get_url( bw->current_content ) );
}
}
diff --git a/cocoa/Tree.h b/cocoa/Tree.h
index e38df5a..fbdb7f7 100644
--- a/cocoa/Tree.h
+++ b/cocoa/Tree.h
@@ -38,7 +38,6 @@
}
@property (readwrite, assign, nonatomic) id <TreeDelegate> delegate;
-@property (readwrite, assign, nonatomic, getter=isRedrawing) BOOL redrawing;
- initWithFlags: (unsigned int) flags;
diff --git a/cocoa/Tree.m b/cocoa/Tree.m
index 7da7b68..5e0247a 100644
--- a/cocoa/Tree.m
+++ b/cocoa/Tree.m
@@ -64,11 +64,6 @@ static const struct treeview_table cocoa_tree_callbacks = {
return tree;
}
-- (BOOL) isRedrawing;
-{
- return tree_get_redraw( tree );
-}
-
- (void) setRedrawing: (BOOL) newRedrawing;
{
}
--
NetSurf Browser
9 years, 8 months
netsurf: branch master updated. release/3.0-511-g80e8465
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/80e8465e917d4755fd35a...
...commit http://git.netsurf-browser.org/netsurf.git/commit/80e8465e917d4755fd35a16...
...tree http://git.netsurf-browser.org/netsurf.git/tree/80e8465e917d4755fd35a168c...
The branch, master has been updated
via 80e8465e917d4755fd35a168c9e9b2605b85af33 (commit)
via f477fd257023c0c0a464e3cc4d5ff0bd49a5c469 (commit)
via b9e3f7ae3d8164f6a7037028af96a88b03a277b9 (commit)
via 42afcf918f06a64a0a0ec97f9228755a51a976ce (commit)
via 1569e9e2a89f0bc8806050a972e25c1f0c73a2f2 (commit)
via f2b4a7a997b8fc952ab96cadb68477ee5d5a434a (commit)
via 11b784a16772bc396ccca60acac6402f88a82ca7 (commit)
via c2375339a1556d687ce0ccc8bec633a8737f585e (commit)
via b56d684a312a39f6cfb93b3ef60d0df2feb9a017 (commit)
via 472108576e2366a5db606c450928b4bc1d1af63b (commit)
via cf8ffa412a55a8884fdd8f348b3fb28108d59b6c (commit)
via e9f65ff9cb60c94b43d4b875892918b90fb2a067 (commit)
via 4473f4b8a8b929c4c5e9dac3013da75f7c66865f (commit)
via 49c7994d0580a655ddcc78e07205eea45d74132c (commit)
via 46e569c481f1c5196fd90b05bd801809355f2d84 (commit)
via 9f35fd3fee6279f0bcd4fa0b3758548bbceaf1ab (commit)
via 128fdbec438f951348eb70829ab90b423e271d66 (commit)
via 5c7ca39ada083e74ba93549efe71c67c906d91bc (commit)
via 28a948bd32bee735f571ae7f297adb69b289d8ba (commit)
via 29328e50774c7ec3d755ed96777938f03bd1b367 (commit)
via ec3547ec9d34e6fbc48437fc2d24ff778c82209b (commit)
via 81b2a859c0f9f145be16fb4f9b11df84ada3a1b8 (commit)
via 452c89aa8345f6478d61313ba47860c49ec82a58 (commit)
via 6a4a297b2f21fdac7f7fcc6b37754786d57a7b9d (commit)
via fadaa306d019d89f86478e9918b9bb2b43fa9ea2 (commit)
via 5d76b448b1fdff056255ed4b000b521591e5b955 (commit)
via 4ce2f6fd553fc9e1eb544eb7664a97c25f103bf4 (commit)
via 8f2f4ca2a8a122acea79599886d69505d3d8007c (commit)
from b9c2b5df6540ef19c522bafb40086d67121ba50a (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=80e8465e917d4755fd3...
commit 80e8465e917d4755fd35a168c9e9b2605b85af33
Merge: f477fd2 b9c2b5d
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Merge branch 'master' of git://git.netsurf-browser.org/netsurf
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=f477fd257023c0c0a46...
commit f477fd257023c0c0a464e3cc4d5ff0bd49a5c469
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Remove height getters from treeview client modules API.
diff --git a/desktop/cookie_manager.c b/desktop/cookie_manager.c
index c2ccb0a..13c6ac9 100644
--- a/desktop/cookie_manager.c
+++ b/desktop/cookie_manager.c
@@ -857,13 +857,6 @@ bool cookie_manager_has_selection(void)
/* Exported interface, documented in cookie_manager.h */
-int cookie_manager_get_height(void)
-{
- return treeview_get_height(cm_ctx.tree);
-}
-
-
-/* Exported interface, documented in cookie_manager.h */
nserror cookie_manager_expand(bool only_folders)
{
return treeview_expand(cm_ctx.tree, only_folders);
diff --git a/desktop/cookie_manager.h b/desktop/cookie_manager.h
index 86111f3..aa61a3e 100644
--- a/desktop/cookie_manager.h
+++ b/desktop/cookie_manager.h
@@ -110,13 +110,6 @@ void cookie_manager_keypress(uint32_t key);
bool cookie_manager_has_selection(void);
/**
- * Find current height
- *
- * \return height in px
- */
-int cookie_manager_get_height(void);
-
-/**
* Expand the treeview's nodes
*
* \param only_folders Iff true, only folders are expanded.
diff --git a/desktop/global_history.c b/desktop/global_history.c
index a4919e9..e0c8e39 100644
--- a/desktop/global_history.c
+++ b/desktop/global_history.c
@@ -964,13 +964,6 @@ bool global_history_has_selection(void)
/* Exported interface, documented in global_history.h */
-int global_history_get_height(void)
-{
- return treeview_get_height(gh_ctx.tree);
-}
-
-
-/* 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 9e0b749..4ebe139 100644
--- a/desktop/global_history.h
+++ b/desktop/global_history.h
@@ -110,13 +110,6 @@ void global_history_keypress(uint32_t key);
bool global_history_has_selection(void);
/**
- * Find current height
- *
- * \return height in px
- */
-int global_history_get_height(void);
-
-/**
* 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 70453cc..9f98138 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -1421,13 +1421,6 @@ void hotlist_edit_selection(void)
/* Exported interface, documented in hotlist.h */
-int hotlist_get_height(void)
-{
- return treeview_get_height(hl_ctx.tree);
-}
-
-
-/* Exported interface, documented in hotlist.h */
nserror hotlist_expand(bool only_folders)
{
return treeview_expand(hl_ctx.tree, only_folders);
diff --git a/desktop/hotlist.h b/desktop/hotlist.h
index ff95d66..121eb95 100644
--- a/desktop/hotlist.h
+++ b/desktop/hotlist.h
@@ -158,13 +158,6 @@ bool hotlist_has_selection(void);
void hotlist_edit_selection(void);
/**
- * Find current height
- *
- * \return height in px
- */
-int hotlist_get_height(void);
-
-/**
* Expand the treeview's nodes
*
* \param only_folders Iff true, only folders are expanded.
diff --git a/desktop/sslcert_viewer.c b/desktop/sslcert_viewer.c
index f1cfcca..e0e87fb 100644
--- a/desktop/sslcert_viewer.c
+++ b/desktop/sslcert_viewer.c
@@ -504,10 +504,3 @@ void sslcert_viewer_keypress(struct sslcert_session_data *ssl_d,
{
treeview_keypress(ssl_d->tree, key);
}
-
-
-/* Exported interface, documented in sslcert_viewer.h */
-int sslcert_viewer_get_height(struct sslcert_session_data *ssl_d)
-{
- return treeview_get_height(ssl_d->tree);
-}
diff --git a/desktop/sslcert_viewer.h b/desktop/sslcert_viewer.h
index 002e919..e02f095 100644
--- a/desktop/sslcert_viewer.h
+++ b/desktop/sslcert_viewer.h
@@ -125,11 +125,4 @@ void sslcert_viewer_mouse_action(struct sslcert_session_data *ssl_d,
void sslcert_viewer_keypress(struct sslcert_session_data *ssl_d,
uint32_t key);
-/**
- * Find current height
- *
- * \return height in px
- */
-int sslcert_viewer_get_height(struct sslcert_session_data *ssl_d);
-
#endif
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=b9e3f7ae3d8164f6a70...
commit b9e3f7ae3d8164f6a7037028af96a88b03a277b9
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Ensure tree height is provided when treeview building is complete.
diff --git a/desktop/cookie_manager.c b/desktop/cookie_manager.c
index b789706..c2ccb0a 100644
--- a/desktop/cookie_manager.c
+++ b/desktop/cookie_manager.c
@@ -789,6 +789,9 @@ nserror cookie_manager_init(struct core_window_callback_table *cw_t,
* the treeview is built. */
cm_ctx.built = true;
+ /* Inform client of window height */
+ treeview_get_height(cm_ctx.tree);
+
LOG(("Generated cookie manager data"));
return NSERROR_OK;
diff --git a/desktop/global_history.c b/desktop/global_history.c
index 449fdcc..a4919e9 100644
--- a/desktop/global_history.c
+++ b/desktop/global_history.c
@@ -767,11 +767,6 @@ nserror global_history_init(struct core_window_callback_table *cw_t,
return err;
}
- /* History tree is built
- * We suppress the treeview height callback on entry insertion before
- * the treeview is built. */
- gh_ctx.built = true;
-
/* Expand the "Today" folder node */
err = treeview_node_expand(gh_ctx.tree,
gh_ctx.folders[GH_TODAY].folder);
@@ -779,6 +774,14 @@ nserror global_history_init(struct core_window_callback_table *cw_t,
return err;
}
+ /* History tree is built
+ * We suppress the treeview height callback on entry insertion before
+ * the treeview is built. */
+ gh_ctx.built = true;
+
+ /* Inform client of window height */
+ treeview_get_height(gh_ctx.tree);
+
LOG(("Loaded global history"));
return NSERROR_OK;
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index 2e71582..70453cc 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -1089,6 +1089,9 @@ nserror hotlist_init(struct core_window_callback_table *cw_t,
* the treeview is built. */
hl_ctx.built = true;
+ /* Inform client of window height */
+ treeview_get_height(hl_ctx.tree);
+
LOG(("Loaded hotlist"));
return NSERROR_OK;
diff --git a/desktop/treeview.c b/desktop/treeview.c
index a2c9e0d..f9b984c 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -3428,6 +3428,8 @@ 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);
+
return tree->root->height;
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=42afcf918f06a64a0a0...
commit 42afcf918f06a64a0a0ec97f9228755a51a976ce
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Make externally induced node expand/contract cause redraw.
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 992b6d8..a2c9e0d 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -1337,8 +1337,15 @@ nserror treeview_destroy(treeview *tree)
}
-/* Exported interface, documented in treeview.h */
-nserror treeview_node_expand(treeview *tree, treeview_node *node)
+/**
+ * Expand a treeview's nodes
+ *
+ * \param tree Treeview object to expand nodes in
+ * \param only_folders Iff true, only folders are expanded.
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+static nserror treeview_node_expand_internal(treeview *tree,
+ treeview_node *node)
{
treeview_node *child;
struct treeview_node_entry *e;
@@ -1422,6 +1429,28 @@ nserror treeview_node_expand(treeview *tree, treeview_node *node)
}
+/* Exported interface, documented in treeview.h */
+nserror treeview_node_expand(treeview *tree, treeview_node *node)
+{
+ nserror err;
+ struct rect r;
+
+ err = treeview_node_expand_internal(tree, node);
+ if (err != NSERROR_OK)
+ return err;
+
+ r.x0 = 0;
+ r.y0 = treeview_node_y(tree, node);
+ r.x1 = REDRAW_MAX;
+ r.y1 = tree->root->height;
+
+ /* Redraw */
+ tree->cw_t->redraw_request(tree->cw_h, &r);
+
+ return NSERROR_OK;
+}
+
+
struct treeview_contract_data {
bool only_entries;
};
@@ -1454,8 +1483,15 @@ static nserror treeview_node_contract_cb(treeview_node *n, void *ctx, bool *end)
return NSERROR_OK;
}
-/* Exported interface, documented in treeview.h */
-nserror treeview_node_contract(treeview *tree, treeview_node *node)
+/**
+ * Contract a treeview node
+ *
+ * \param tree Treeview object to contract node in
+ * \param node Node to contract
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+static nserror treeview_node_contract_internal(treeview *tree,
+ treeview_node *node)
{
struct treeview_contract_data data;
bool selected;
@@ -1488,15 +1524,45 @@ nserror treeview_node_contract(treeview *tree, treeview_node *node)
/* Exported interface, documented in treeview.h */
+nserror treeview_node_contract(treeview *tree, treeview_node *node)
+{
+ nserror err;
+ struct rect r;
+
+ assert(tree != NULL);
+
+ r.x0 = 0;
+ r.y0 = treeview_node_y(tree, node);
+ r.x1 = REDRAW_MAX;
+ r.y1 = tree->root->height;
+
+ err = treeview_node_contract_internal(tree, node);
+ if (err != NSERROR_OK)
+ return err;
+
+ /* Redraw */
+ tree->cw_t->redraw_request(tree->cw_h, &r);
+
+ return NSERROR_OK;
+}
+
+
+/* Exported interface, documented in treeview.h */
nserror treeview_contract(treeview *tree, bool all)
{
struct treeview_contract_data data;
bool selected;
treeview_node *n;
+ struct rect r;
assert(tree != NULL);
assert(tree->root != NULL);
+ r.x0 = 0;
+ r.y0 = 0;
+ r.x1 = REDRAW_MAX;
+ r.y1 = tree->root->height;
+
data.only_entries = !all;
for (n = tree->root->children; n != NULL; n = n->next_sib) {
@@ -1520,6 +1586,9 @@ 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);
+ /* Redraw */
+ tree->cw_t->redraw_request(tree->cw_h, &r);
+
return NSERROR_OK;
}
@@ -1544,7 +1613,7 @@ static nserror treeview_expand_cb(treeview_node *n, void *ctx,
return NSERROR_OK;
}
- err = treeview_node_expand(data->tree, n);
+ err = treeview_node_expand_internal(data->tree, n);
return err;
}
@@ -1552,6 +1621,8 @@ static nserror treeview_expand_cb(treeview_node *n, void *ctx,
nserror treeview_expand(treeview *tree, bool only_folders)
{
struct treeview_expand_data data;
+ nserror err;
+ struct rect r;
assert(tree != NULL);
assert(tree->root != NULL);
@@ -1559,8 +1630,20 @@ nserror treeview_expand(treeview *tree, bool only_folders)
data.tree = tree;
data.only_folders = only_folders;
- return treeview_walk_internal(tree->root, true, NULL,
+ err = treeview_walk_internal(tree->root, true, NULL,
treeview_expand_cb, &data);
+ if (err != NSERROR_OK)
+ return err;
+
+ r.x0 = 0;
+ r.y0 = 0;
+ r.x1 = REDRAW_MAX;
+ r.y1 = tree->root->height;
+
+ /* Redraw */
+ tree->cw_t->redraw_request(tree->cw_h, &r);
+
+ return NSERROR_OK;
}
@@ -2234,7 +2317,7 @@ static nserror treeview_move_selection(treeview *tree, struct rect *rect)
if (!(parent->flags & TREE_NODE_EXPANDED)) {
if (node->flags & TREE_NODE_EXPANDED)
- treeview_node_contract(tree, node);
+ treeview_node_contract_internal(tree, node);
node->flags &= ~TREE_NODE_SELECTED;
}
@@ -2457,7 +2540,7 @@ static bool treeview_keyboard_navigation(treeview *tree, uint32_t key,
if (ns.curr != NULL) {
if (!(ns.curr->flags & TREE_NODE_EXPANDED)) {
/* Toggle node to expanded */
- treeview_node_expand(tree, ns.curr);
+ treeview_node_expand_internal(tree, ns.curr);
if (ns.curr->children != NULL) {
/* Step to first child */
ns.curr->children->flags |=
@@ -2468,7 +2551,7 @@ static bool treeview_keyboard_navigation(treeview *tree, uint32_t key,
}
} else {
/* Toggle node to contracted */
- treeview_node_contract(tree, ns.curr);
+ treeview_node_contract_internal(tree, ns.curr);
/* Retain current node selection */
ns.curr->flags |= TREE_NODE_SELECTED;
}
@@ -3108,9 +3191,9 @@ static nserror treeview_node_mouse_action_cb(treeview_node *node, void *ctx,
/* Toggle node expansion */
if (node->flags & TREE_NODE_EXPANDED) {
- err = treeview_node_contract(ma->tree, node);
+ err = treeview_node_contract_internal(ma->tree, node);
} else {
- err = treeview_node_expand(ma->tree, node);
+ err = treeview_node_expand_internal(ma->tree, node);
}
if (err != NSERROR_OK) {
return err;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=1569e9e2a89f0bc8806...
commit 1569e9e2a89f0bc8806050a972e25c1f0c73a2f2
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Change recursife node collapse behaviour slightly.
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 0f011b3..992b6d8 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -1422,10 +1422,13 @@ nserror treeview_node_expand(treeview *tree, treeview_node *node)
}
-
+struct treeview_contract_data {
+ bool only_entries;
+};
/** Treewalk node callback for handling node contraction. */
static nserror treeview_node_contract_cb(treeview_node *n, void *ctx, bool *end)
{
+ struct treeview_contract_data *data = ctx;
int h_reduction;
assert(n != NULL);
@@ -1433,7 +1436,8 @@ static nserror treeview_node_contract_cb(treeview_node *n, void *ctx, bool *end)
n->flags &= ~TREE_NODE_SELECTED;
- if ((n->flags & TREE_NODE_EXPANDED) == false) {
+ if ((n->flags & TREE_NODE_EXPANDED) == false ||
+ (n->type == TREE_NODE_FOLDER && data->only_entries)) {
/* Nothing to do. */
return NSERROR_OK;
}
@@ -1453,6 +1457,7 @@ static nserror treeview_node_contract_cb(treeview_node *n, void *ctx, bool *end)
/* Exported interface, documented in treeview.h */
nserror treeview_node_contract(treeview *tree, treeview_node *node)
{
+ struct treeview_contract_data data;
bool selected;
assert(node != NULL);
@@ -1462,14 +1467,15 @@ nserror treeview_node_contract(treeview *tree, treeview_node *node)
return NSERROR_OK;
}
+ data.only_entries = false;
selected = node->flags & TREE_NODE_SELECTED;
/* Contract children. */
treeview_walk_internal(node, false, treeview_node_contract_cb,
- NULL, NULL);
+ NULL, &data);
/* Contract node */
- treeview_node_contract_cb(node, NULL, false);
+ treeview_node_contract_cb(node, &data, false);
if (selected)
node->flags |= TREE_NODE_SELECTED;
@@ -1484,30 +1490,31 @@ nserror treeview_node_contract(treeview *tree, treeview_node *node)
/* Exported interface, documented in treeview.h */
nserror treeview_contract(treeview *tree, bool all)
{
+ struct treeview_contract_data data;
bool selected;
treeview_node *n;
assert(tree != NULL);
assert(tree->root != NULL);
+ data.only_entries = !all;
+
for (n = tree->root->children; n != NULL; n = n->next_sib) {
if ((n->flags & TREE_NODE_EXPANDED) == false) {
continue;
}
- if (n->type == TREE_NODE_FOLDER || all) {
- selected = n->flags & TREE_NODE_SELECTED;
+ selected = n->flags & TREE_NODE_SELECTED;
- /* Contract children. */
- treeview_walk_internal(n, false,
- treeview_node_contract_cb, NULL, NULL);
+ /* Contract children. */
+ treeview_walk_internal(n, false,
+ treeview_node_contract_cb, NULL, &data);
- /* Contract node */
- treeview_node_contract_cb(n, NULL, false);
+ /* Contract node */
+ treeview_node_contract_cb(n, &data, false);
- if (selected)
- n->flags |= TREE_NODE_SELECTED;
- }
+ if (selected)
+ n->flags |= TREE_NODE_SELECTED;
}
/* Inform front end of change in dimensions */
@@ -1517,7 +1524,7 @@ nserror treeview_contract(treeview *tree, bool all)
}
-struct treeview_contract_data {
+struct treeview_expand_data {
treeview *tree;
bool only_folders;
};
@@ -1525,7 +1532,7 @@ struct treeview_contract_data {
static nserror treeview_expand_cb(treeview_node *n, void *ctx,
bool *skip_children, bool *end)
{
- struct treeview_contract_data *data = ctx;
+ struct treeview_expand_data *data = ctx;
nserror err;
assert(n != NULL);
@@ -1544,7 +1551,7 @@ static nserror treeview_expand_cb(treeview_node *n, void *ctx,
/* Exported interface, documented in treeview.h */
nserror treeview_expand(treeview *tree, bool only_folders)
{
- struct treeview_contract_data data;
+ struct treeview_expand_data data;
assert(tree != NULL);
assert(tree->root != NULL);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=f2b4a7a997b8fc952ab...
commit f2b4a7a997b8fc952ab96cadb68477ee5d5a434a
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Port to new recursive expand/contract functions.
diff --git a/amiga/tree.c b/amiga/tree.c
index 15a7711..d5ae885 100644
--- a/amiga/tree.c
+++ b/amiga/tree.c
@@ -1013,13 +1013,13 @@ BOOL ami_tree_event(struct treeview_window *twin)
switch(twin->type)
{
case AMI_TREE_HISTORY:
- history_global_expand_all();
+ global_history_expand(false);
break;
case AMI_TREE_COOKIES:
- cookies_expand_all();
+ cookie_manager_expand(false);
break;
case AMI_TREE_HOTLIST:
- hotlist_old_expand_all();
+ hotlist_expand(false);
break;
}
break;
@@ -1028,13 +1028,13 @@ BOOL ami_tree_event(struct treeview_window *twin)
switch(twin->type)
{
case AMI_TREE_HISTORY:
- history_global_expand_directories();
+ global_history_expand(true);
break;
case AMI_TREE_COOKIES:
- cookies_expand_domains();
+ cookie_manager_expand(true);
break;
case AMI_TREE_HOTLIST:
- hotlist_old_expand_directories();
+ hotlist_expand(true);
break;
}
break;
@@ -1043,13 +1043,13 @@ BOOL ami_tree_event(struct treeview_window *twin)
switch(twin->type)
{
case AMI_TREE_HISTORY:
- history_global_expand_addresses();
+ global_history_expand(false);
break;
case AMI_TREE_COOKIES:
- cookies_expand_cookies();
+ cookie_manager_expand(false);
break;
case AMI_TREE_HOTLIST:
- hotlist_old_expand_addresses();
+ hotlist_expand(false);
break;
}
break;
@@ -1063,13 +1063,13 @@ BOOL ami_tree_event(struct treeview_window *twin)
switch(twin->type)
{
case AMI_TREE_HISTORY:
- history_global_collapse_all();
+ global_history_contract(true);
break;
case AMI_TREE_COOKIES:
- cookies_collapse_all();
+ cookie_manager_contract(true);
break;
case AMI_TREE_HOTLIST:
- hotlist_old_collapse_all();
+ hotlist_contract(true);
break;
}
break;
@@ -1078,13 +1078,13 @@ BOOL ami_tree_event(struct treeview_window *twin)
switch(twin->type)
{
case AMI_TREE_HISTORY:
- history_global_collapse_directories();
+ global_history_contract(true);
break;
case AMI_TREE_COOKIES:
- cookies_collapse_domains();
+ cookie_manager_contract(true);
break;
case AMI_TREE_HOTLIST:
- hotlist_old_collapse_directories();
+ hotlist_contract(true);
break;
}
break;
@@ -1093,13 +1093,13 @@ BOOL ami_tree_event(struct treeview_window *twin)
switch(twin->type)
{
case AMI_TREE_HISTORY:
- history_global_collapse_addresses();
+ global_history_contract(false);
break;
case AMI_TREE_COOKIES:
- cookies_collapse_cookies();
+ cookie_manager_contract(false);
break;
case AMI_TREE_HOTLIST:
- hotlist_old_collapse_addresses();
+ hotlist_contract(false);
break;
}
break;
diff --git a/cocoa/BookmarksController.m b/cocoa/BookmarksController.m
index 9c20c54..96041ab 100644
--- a/cocoa/BookmarksController.m
+++ b/cocoa/BookmarksController.m
@@ -181,8 +181,8 @@ static const char *cocoa_hotlist_path( void )
- (void) windowDidLoad;
{
- hotlist_old_expand_all();
- hotlist_old_collapse_all();
+ hotlist_expand(false);
+ hotlist_contract(true);
[view setTree: tree];
}
diff --git a/gtk/cookies.c b/gtk/cookies.c
index e020c53..35470ce 100644
--- a/gtk/cookies.c
+++ b/gtk/cookies.c
@@ -187,36 +187,36 @@ MENUHANDLER(clear_selection)
/* view menu*/
MENUHANDLER(expand_all)
{
- cookies_expand_all();
+ cookie_manager_expand(false);
return TRUE;
}
MENUHANDLER(expand_domains)
{
- cookies_expand_domains();
+ cookie_manager_expand(true);
return TRUE;
}
MENUHANDLER(expand_cookies)
{
- cookies_expand_cookies();
+ cookie_manager_expand(false);
return TRUE;
}
MENUHANDLER(collapse_all)
{
- cookies_collapse_all();
+ cookie_manager_contract(true);
return TRUE;
}
MENUHANDLER(collapse_domains)
{
- cookies_collapse_domains();
+ cookie_manager_contract(true);
return TRUE;
}
MENUHANDLER(collapse_cookies)
{
- cookies_collapse_cookies();
+ cookie_manager_contract(false);
return TRUE;
}
diff --git a/gtk/history.c b/gtk/history.c
index c443739..2cf1438 100644
--- a/gtk/history.c
+++ b/gtk/history.c
@@ -223,37 +223,37 @@ MENUHANDLER(clear_selection)
/* view menu*/
MENUHANDLER(expand_all)
{
- history_global_expand_all();
+ global_history_expand(false);
return TRUE;
}
MENUHANDLER(expand_directories)
{
- history_global_expand_directories();
+ global_history_expand(true);
return TRUE;
}
MENUHANDLER(expand_addresses)
{
- history_global_expand_addresses();
+ global_history_expand(false);
return TRUE;
}
MENUHANDLER(collapse_all)
{
- history_global_collapse_all();
+ global_history_contract(true);
return TRUE;
}
MENUHANDLER(collapse_directories)
{
- history_global_collapse_directories();
+ global_history_contract(true);
return TRUE;
}
MENUHANDLER(collapse_addresses)
{
- history_global_collapse_addresses();
+ global_history_contract(false);
return TRUE;
}
diff --git a/gtk/hotlist.c b/gtk/hotlist.c
index 9506ed7..db09099 100644
--- a/gtk/hotlist.c
+++ b/gtk/hotlist.c
@@ -239,37 +239,37 @@ MENUHANDLER(clear_selection)
/* view menu*/
MENUHANDLER(expand_all)
{
- hotlist_old_expand_all();
+ hotlist_expand(false);
return TRUE;
}
MENUHANDLER(expand_directories)
{
- hotlist_old_expand_directories();
+ hotlist_expand(true);
return TRUE;
}
MENUHANDLER(expand_addresses)
{
- hotlist_old_expand_addresses();
+ hotlist_expand(false);
return TRUE;
}
MENUHANDLER(collapse_all)
{
- hotlist_old_collapse_all();
+ hotlist_contract(true);
return TRUE;
}
MENUHANDLER(collapse_directories)
{
- hotlist_old_collapse_directories();
+ hotlist_contract(true);
return TRUE;
}
MENUHANDLER(collapse_addresses)
{
- hotlist_old_collapse_addresses();
+ hotlist_contract(false);
return TRUE;
}
diff --git a/riscos/cookies.c b/riscos/cookies.c
index dfdbc5d..7f37de8 100644
--- a/riscos/cookies.c
+++ b/riscos/cookies.c
@@ -183,19 +183,19 @@ void ro_gui_cookies_toolbar_click(button_bar_action action)
break;
case TOOLBAR_BUTTON_EXPAND:
- cookies_expand_cookies();
+ cookie_manager_expand(false);
break;
case TOOLBAR_BUTTON_COLLAPSE:
- cookies_collapse_cookies();
+ cookie_manager_contract(false);
break;
case TOOLBAR_BUTTON_OPEN:
- cookies_expand_domains();
+ cookie_manager_expand(true);
break;
case TOOLBAR_BUTTON_CLOSE:
- cookies_collapse_domains();
+ cookie_manager_contract(true);
break;
default:
@@ -300,22 +300,22 @@ bool ro_gui_cookies_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
{
switch (action) {
case TREE_EXPAND_ALL:
- cookies_expand_all();
+ cookie_manager_expand(false);
return true;
case TREE_EXPAND_FOLDERS:
- cookies_expand_domains();
+ cookie_manager_expand(true);
return true;
case TREE_EXPAND_LINKS:
- cookies_expand_cookies();
+ cookie_manager_expand(false);
return true;
case TREE_COLLAPSE_ALL:
- cookies_collapse_all();
+ cookie_manager_contract(true);
return true;
case TREE_COLLAPSE_FOLDERS:
- cookies_collapse_domains();
+ cookie_manager_contract(true);
return true;
case TREE_COLLAPSE_LINKS:
- cookies_collapse_cookies();
+ cookie_manager_contract(false);
return true;
case TREE_SELECTION_DELETE:
cookie_manager_keypress(KEY_DELETE_LEFT);
diff --git a/riscos/global_history.c b/riscos/global_history.c
index aecc989..dfabbe9 100644
--- a/riscos/global_history.c
+++ b/riscos/global_history.c
@@ -189,19 +189,19 @@ void ro_gui_global_history_toolbar_click(button_bar_action action)
break;
case TOOLBAR_BUTTON_EXPAND:
- history_global_expand_addresses();
+ global_history_expand(false);
break;
case TOOLBAR_BUTTON_COLLAPSE:
- history_global_collapse_addresses();
+ global_history_contract(false);
break;
case TOOLBAR_BUTTON_OPEN:
- history_global_expand_directories();
+ global_history_expand(true);
break;
case TOOLBAR_BUTTON_CLOSE:
- history_global_collapse_directories();
+ global_history_contract(true);
break;
case TOOLBAR_BUTTON_LAUNCH:
@@ -324,22 +324,22 @@ bool ro_gui_global_history_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
ro_gui_dialog_open_persistent(w, dialog_saveas, true);
return true;
case TREE_EXPAND_ALL:
- history_global_expand_all();
+ global_history_expand(false);
return true;
case TREE_EXPAND_FOLDERS:
- history_global_expand_directories();
+ global_history_expand(true);
return true;
case TREE_EXPAND_LINKS:
- history_global_expand_addresses();
+ global_history_expand(false);
return true;
case TREE_COLLAPSE_ALL:
- history_global_collapse_all();
+ global_history_contract(true);
return true;
case TREE_COLLAPSE_FOLDERS:
- history_global_collapse_directories();
+ global_history_contract(true);
return true;
case TREE_COLLAPSE_LINKS:
- history_global_collapse_addresses();
+ global_history_contract(false);
return true;
case TREE_SELECTION_LAUNCH:
global_history_keypress(KEY_CR);
diff --git a/riscos/hotlist.c b/riscos/hotlist.c
index 73c8002..d00e724 100644
--- a/riscos/hotlist.c
+++ b/riscos/hotlist.c
@@ -231,19 +231,19 @@ void ro_gui_hotlist_toolbar_click(button_bar_action action)
break;
case TOOLBAR_BUTTON_EXPAND:
- hotlist_old_expand_addresses();
+ hotlist_expand(false);
break;
case TOOLBAR_BUTTON_COLLAPSE:
- hotlist_old_collapse_addresses();
+ hotlist_contract(false);
break;
case TOOLBAR_BUTTON_OPEN:
- hotlist_old_expand_directories();
+ hotlist_expand(true);
break;
case TOOLBAR_BUTTON_CLOSE:
- hotlist_old_collapse_directories();
+ hotlist_contract(true);
break;
case TOOLBAR_BUTTON_LAUNCH:
@@ -372,22 +372,22 @@ bool ro_gui_hotlist_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
hotlist_add_entry(NULL, NULL, false, 0);
return true;
case TREE_EXPAND_ALL:
- hotlist_old_expand_all();
+ hotlist_expand(false);
return true;
case TREE_EXPAND_FOLDERS:
- hotlist_old_expand_directories();
+ hotlist_expand(true);
return true;
case TREE_EXPAND_LINKS:
- hotlist_old_expand_addresses();
+ hotlist_expand(false);
return true;
case TREE_COLLAPSE_ALL:
- hotlist_old_collapse_all();
+ hotlist_contract(true);
return true;
case TREE_COLLAPSE_FOLDERS:
- hotlist_old_collapse_directories();
+ hotlist_contract(true);
return true;
case TREE_COLLAPSE_LINKS:
- hotlist_old_collapse_addresses();
+ hotlist_contract(false);
return true;
case TREE_SELECTION_EDIT:
hotlist_edit_selection();
@@ -541,7 +541,7 @@ static void ro_gui_hotlist_addurl_bounce(wimp_message *message)
if (nsurl_create(hotlist_url, &nsurl) != NSERROR_OK)
return;
- hotlist_add_page(nsurl);
+ hotlist_add_url(nsurl);
nsurl_unref(nsurl);
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=11b784a16772bc396cc...
commit 11b784a16772bc396ccca60acac6402f88a82ca7
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Node collapsing needs to happen when leaving nodes.
diff --git a/desktop/treeview.c b/desktop/treeview.c
index 58e199b..0f011b3 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -1424,8 +1424,7 @@ nserror treeview_node_expand(treeview *tree, treeview_node *node)
/** Treewalk node callback for handling node contraction. */
-static nserror treeview_node_contract_cb(treeview_node *n, void *ctx,
- bool *skip_children, bool *end)
+static nserror treeview_node_contract_cb(treeview_node *n, void *ctx, bool *end)
{
int h_reduction;
@@ -1466,11 +1465,11 @@ nserror treeview_node_contract(treeview *tree, treeview_node *node)
selected = node->flags & TREE_NODE_SELECTED;
/* Contract children. */
- treeview_walk_internal(node, false, NULL,
- treeview_node_contract_cb, NULL);
+ treeview_walk_internal(node, false, treeview_node_contract_cb,
+ NULL, NULL);
/* Contract node */
- treeview_node_contract_cb(node, NULL, false, false);
+ treeview_node_contract_cb(node, NULL, false);
if (selected)
node->flags |= TREE_NODE_SELECTED;
@@ -1500,11 +1499,11 @@ nserror treeview_contract(treeview *tree, bool all)
selected = n->flags & TREE_NODE_SELECTED;
/* Contract children. */
- treeview_walk_internal(n, false, NULL,
- treeview_node_contract_cb, NULL);
+ treeview_walk_internal(n, false,
+ treeview_node_contract_cb, NULL, NULL);
/* Contract node */
- treeview_node_contract_cb(n, NULL, false, false);
+ treeview_node_contract_cb(n, NULL, false);
if (selected)
n->flags |= TREE_NODE_SELECTED;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=c2375339a1556d687ce...
commit c2375339a1556d687ce0ccc8bec633a8737f585e
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Add recursive expand/contract functions to hotlist, global history, and cookie manager modules.
diff --git a/desktop/cookie_manager.c b/desktop/cookie_manager.c
index d9fd21c..b789706 100644
--- a/desktop/cookie_manager.c
+++ b/desktop/cookie_manager.c
@@ -859,3 +859,17 @@ int cookie_manager_get_height(void)
return treeview_get_height(cm_ctx.tree);
}
+
+/* Exported interface, documented in cookie_manager.h */
+nserror cookie_manager_expand(bool only_folders)
+{
+ return treeview_expand(cm_ctx.tree, only_folders);
+}
+
+
+/* Exported interface, documented in cookie_manager.h */
+nserror cookie_manager_contract(bool all)
+{
+ return treeview_contract(cm_ctx.tree, all);
+}
+
diff --git a/desktop/cookie_manager.h b/desktop/cookie_manager.h
index 4da85a8..86111f3 100644
--- a/desktop/cookie_manager.h
+++ b/desktop/cookie_manager.h
@@ -116,4 +116,20 @@ bool cookie_manager_has_selection(void);
*/
int cookie_manager_get_height(void);
+/**
+ * Expand the treeview's nodes
+ *
+ * \param only_folders Iff true, only folders are expanded.
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror cookie_manager_expand(bool only_folders);
+
+/**
+ * Contract the treeview's nodes
+ *
+ * \param all Iff false, only entries are contracted.
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror cookie_manager_contract(bool all);
+
#endif
diff --git a/desktop/global_history.c b/desktop/global_history.c
index d20eb37..449fdcc 100644
--- a/desktop/global_history.c
+++ b/desktop/global_history.c
@@ -966,3 +966,17 @@ int global_history_get_height(void)
return treeview_get_height(gh_ctx.tree);
}
+
+/* Exported interface, documented in global_history.h */
+nserror global_history_expand(bool only_folders)
+{
+ return treeview_expand(gh_ctx.tree, only_folders);
+}
+
+
+/* Exported interface, documented in global_history.h */
+nserror global_history_contract(bool all)
+{
+ return treeview_contract(gh_ctx.tree, all);
+}
+
diff --git a/desktop/global_history.h b/desktop/global_history.h
index a720d30..9e0b749 100644
--- a/desktop/global_history.h
+++ b/desktop/global_history.h
@@ -116,4 +116,20 @@ bool global_history_has_selection(void);
*/
int global_history_get_height(void);
+/**
+ * Expand the treeview's nodes
+ *
+ * \param only_folders Iff true, only folders are expanded.
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror global_history_expand(bool only_folders);
+
+/**
+ * Contract the treeview's nodes
+ *
+ * \param all Iff false, only entries are contracted.
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror global_history_contract(bool all);
+
#endif
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index ce91563..2e71582 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -1423,3 +1423,17 @@ int hotlist_get_height(void)
return treeview_get_height(hl_ctx.tree);
}
+
+/* Exported interface, documented in hotlist.h */
+nserror hotlist_expand(bool only_folders)
+{
+ return treeview_expand(hl_ctx.tree, only_folders);
+}
+
+
+/* Exported interface, documented in hotlist.h */
+nserror hotlist_contract(bool all)
+{
+ return treeview_contract(hl_ctx.tree, all);
+}
+
diff --git a/desktop/hotlist.h b/desktop/hotlist.h
index d192eaa..ff95d66 100644
--- a/desktop/hotlist.h
+++ b/desktop/hotlist.h
@@ -164,4 +164,20 @@ void hotlist_edit_selection(void);
*/
int hotlist_get_height(void);
+/**
+ * Expand the treeview's nodes
+ *
+ * \param only_folders Iff true, only folders are expanded.
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror hotlist_expand(bool only_folders);
+
+/**
+ * Contract the treeview's nodes
+ *
+ * \param all Iff false, only entries are contracted.
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror hotlist_contract(bool all);
+
#endif
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=b56d684a312a39f6cfb...
commit b56d684a312a39f6cfb93b3ef60d0df2feb9a017
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Add a pair of recursive expand/contract functions.
diff --git a/desktop/treeview.c b/desktop/treeview.c
index dd4efcd..58e199b 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -1338,8 +1338,7 @@ nserror treeview_destroy(treeview *tree)
/* Exported interface, documented in treeview.h */
-nserror treeview_node_expand(treeview *tree,
- treeview_node *node)
+nserror treeview_node_expand(treeview *tree, treeview_node *node)
{
treeview_node *child;
struct treeview_node_entry *e;
@@ -1423,6 +1422,7 @@ nserror treeview_node_expand(treeview *tree,
}
+
/** Treewalk node callback for handling node contraction. */
static nserror treeview_node_contract_cb(treeview_node *n, void *ctx,
bool *skip_children, bool *end)
@@ -1483,6 +1483,82 @@ nserror treeview_node_contract(treeview *tree, treeview_node *node)
/* Exported interface, documented in treeview.h */
+nserror treeview_contract(treeview *tree, bool all)
+{
+ bool selected;
+ treeview_node *n;
+
+ assert(tree != NULL);
+ assert(tree->root != NULL);
+
+ for (n = tree->root->children; n != NULL; n = n->next_sib) {
+ if ((n->flags & TREE_NODE_EXPANDED) == false) {
+ continue;
+ }
+
+ if (n->type == TREE_NODE_FOLDER || all) {
+ selected = n->flags & TREE_NODE_SELECTED;
+
+ /* Contract children. */
+ treeview_walk_internal(n, false, NULL,
+ treeview_node_contract_cb, NULL);
+
+ /* Contract node */
+ treeview_node_contract_cb(n, NULL, false, false);
+
+ if (selected)
+ n->flags |= TREE_NODE_SELECTED;
+ }
+ }
+
+ /* Inform front end of change in dimensions */
+ tree->cw_t->update_size(tree->cw_h, -1, tree->root->height);
+
+ return NSERROR_OK;
+}
+
+
+struct treeview_contract_data {
+ treeview *tree;
+ bool only_folders;
+};
+/** Treewalk node callback for handling recursive node expansion. */
+static nserror treeview_expand_cb(treeview_node *n, void *ctx,
+ bool *skip_children, bool *end)
+{
+ struct treeview_contract_data *data = ctx;
+ nserror err;
+
+ assert(n != NULL);
+ assert(n->type != TREE_NODE_ROOT);
+
+ if (n->flags & TREE_NODE_EXPANDED ||
+ (data->only_folders && n->type != TREE_NODE_FOLDER)) {
+ /* Nothing to do. */
+ return NSERROR_OK;
+ }
+
+ err = treeview_node_expand(data->tree, n);
+
+ return err;
+}
+/* Exported interface, documented in treeview.h */
+nserror treeview_expand(treeview *tree, bool only_folders)
+{
+ struct treeview_contract_data data;
+
+ assert(tree != NULL);
+ assert(tree->root != NULL);
+
+ data.tree = tree;
+ data.only_folders = only_folders;
+
+ return treeview_walk_internal(tree->root, true, NULL,
+ treeview_expand_cb, &data);
+}
+
+
+/* Exported interface, documented in treeview.h */
void treeview_redraw(treeview *tree, int x, int y, struct rect *clip,
const struct redraw_context *ctx)
{
diff --git a/desktop/treeview.h b/desktop/treeview.h
index b4a028f..9af72f9 100644
--- a/desktop/treeview.h
+++ b/desktop/treeview.h
@@ -301,7 +301,7 @@ nserror treeview_delete_node(treeview *tree, treeview_node *n,
/**
* Expand a treeview node
*
- * \param tree Treeview object to expande node in
+ * \param tree Treeview object to expand node in
* \param node Node to expand
* \return NSERROR_OK on success, appropriate error otherwise
*/
@@ -317,6 +317,24 @@ nserror treeview_node_expand(treeview *tree, treeview_node *node);
nserror treeview_node_contract(treeview *tree, treeview_node *node);
/**
+ * Expand a treeview's nodes
+ *
+ * \param tree Treeview object to expand nodes in
+ * \param only_folders Iff true, only folders are expanded.
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror treeview_expand(treeview *tree, bool only_folders);
+
+/**
+ * Contract a treeview's nodes
+ *
+ * \param tree Treeview object to contract nodes in
+ * \param all Iff false, only entries are contracted.
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror treeview_contract(treeview *tree, bool all);
+
+/**
* Redraw a treeview object
*
* \param tree Treeview object to render
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=472108576e2366a5db6...
commit 472108576e2366a5db606c450928b4bc1d1af63b
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Make it more clear that tree.c is deprecated.
diff --git a/desktop/tree.c b/desktop/tree.c
index 9e86668..cb981b3 100644
--- a/desktop/tree.c
+++ b/desktop/tree.c
@@ -18,7 +18,7 @@
*/
/** \file
- * Generic tree handling (implementation).
+ * deprecated compatibility layer for new treeview modules. Do not use.
*/
#include <assert.h>
@@ -292,16 +292,7 @@ static bool treeview_test_keypress(struct tree *tree, uint32_t key)
/* -------------------------------------------------------------------------- */
-
-
-/**
- * Creates and initialises a new tree.
- *
- * \param flags Flag word for flags to create the new tree with
- * \param callbacks Callback functions to support the tree in the frontend.
- * \param client_data Data to be passed to start_redraw and end_redraw
- * \return The newly created tree, or NULL on memory exhaustion
- */
+/** deprecated compatibility layer for new treeview modules. Do not use. */
struct tree *tree_create(unsigned int flags,
const struct treeview_table *callbacks, void *client_data)
{
@@ -324,31 +315,14 @@ struct tree *tree_create(unsigned int flags,
return tree;
}
-
-/**
- * Deletes all nodes of a tree and the tree itself.
- *
- * \param tree the tree to be deleted
- */
+/** deprecated compatibility layer for new treeview modules. Do not use. */
void tree_delete(struct tree *tree)
{
treeview_test_fini(tree);
free(tree);
}
-
-/**
- * Redraws a tree.
- *
- * \param tree the tree to draw
- * \param x X coordinate to draw the tree at (wrt plot origin)
- * \param y Y coordinate to draw the tree at (wrt plot origin)
- * \param clip_x minimum x of the clipping rectangle (wrt tree origin)
- * \param clip_y minimum y of the clipping rectangle (wrt tree origin)
- * \param clip_width width of the clipping rectangle
- * \param clip_height height of the clipping rectangle
- * \param ctx current redraw context
- */
+/** deprecated compatibility layer for new treeview modules. Do not use. */
void tree_draw(struct tree *tree, int x, int y,
int clip_x, int clip_y, int clip_width, int clip_height,
const struct redraw_context *ctx)
@@ -359,16 +333,7 @@ void tree_draw(struct tree *tree, int x, int y,
clip_width, clip_height, ctx);
}
-
-/**
- * Handles a mouse action for a tree
- *
- * \param tree the tree to handle a click for
- * \param mouse the mouse state
- * \param x X coordinate of mouse action
- * \param y Y coordinate of mouse action
- * \return whether the click was handled
- */
+/** deprecated compatibility layer for new treeview modules. Do not use. */
bool tree_mouse_action(struct tree *tree, browser_mouse_state mouse, int x,
int y)
{
@@ -381,17 +346,7 @@ bool tree_mouse_action(struct tree *tree, browser_mouse_state mouse, int x,
return false;
}
-
-/**
- * Handle the end of a drag operation
- *
- * \param tree the tree on which the drag was performed
- * \param mouse mouse state during drag end
- * \param x0 x coordinate of drag start
- * \param y0 y coordinate of drag start
- * \param x1 x coordinate of drag end
- * \param y1 y coordinate of drag end
- */
+/** deprecated compatibility layer for new treeview modules. Do not use. */
void tree_drag_end(struct tree *tree, browser_mouse_state mouse, int x0, int y0,
int x1, int y1)
{
@@ -400,14 +355,7 @@ void tree_drag_end(struct tree *tree, browser_mouse_state mouse, int x0, int y0,
treeview_test_mouse_action(tree, BROWSER_MOUSE_HOVER, x1, y1);
}
-
-/**
- * Key press handling for a tree.
- *
- * \param tree The tree which got the keypress
- * \param key The ucs4 character codepoint
- * \return true if the keypress is dealt with, false otherwise.
- */
+/** deprecated compatibility layer for new treeview modules. Do not use. */
bool tree_keypress(struct tree *tree, uint32_t key)
{
if (treeview_test_keypress(tree, key)) {
@@ -417,6 +365,7 @@ bool tree_keypress(struct tree *tree, uint32_t key)
return false;
}
+/** deprecated compatibility layer for new treeview modules. Do not use. */
tree_drag_type tree_drag_status(struct tree *tree)
{
assert(tree != NULL);
diff --git a/desktop/tree.h b/desktop/tree.h
index 52bea7d..db164c0 100644
--- a/desktop/tree.h
+++ b/desktop/tree.h
@@ -18,7 +18,7 @@
*/
/** \file
- * Generic tree handling (interface).
+ * deprecated compatibility layer for new treeview modules. Do not use.
*/
#ifndef _NETSURF_DESKTOP_TREE_H_
@@ -67,6 +67,7 @@ struct tree *tree_create(unsigned int flags,
const struct treeview_table *callbacks,
void *client_data);
+/** deprecated compatibility layer for new treeview modules. Do not use. */
void tree_delete(struct tree *tree);
tree_drag_type tree_drag_status(struct tree *tree);
void tree_draw(struct tree *tree, int x, int y,
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=cf8ffa412a55a8884fd...
commit cf8ffa412a55a8884fdd8f348b3fb28108d59b6c
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Remove old hotlist, cookies, and history_global_core modules.
New versions of expand/collapse node functions for these modules aren't yet implemented.
diff --git a/amiga/context_menu.c b/amiga/context_menu.c
index 4d4d73a..5a3da55 100644
--- a/amiga/context_menu.c
+++ b/amiga/context_menu.c
@@ -41,7 +41,7 @@
#include "amiga/utf8.h"
#include "desktop/browser_private.h"
#include "desktop/local_history.h"
-#include "desktop/hotlist_old.h"
+#include "desktop/hotlist.h"
#include "desktop/searchweb.h"
#include "desktop/textinput.h"
#include "render/form.h"
@@ -767,7 +767,14 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
case CMID_URLHOTLIST:
case CMID_PAGEHOTLIST:
- hotlist_old_add_page(userdata);
+ {
+ nsurl *nsurl;
+ if (nsurl_create(url, &nsurl) != NSERROR_OK)
+ break;
+
+ hotlist_add_url(nsurl);
+ nsurl_unref(nsurl);
+ }
break;
case CMID_FRAMECOPYURL:
@@ -1215,7 +1222,7 @@ static uint32 ami_context_menu_hook_tree(struct Hook *hook, Object *item, APTR r
break;
case CMID_TREE_EDITFOLDER:
- hotlist_old_edit_selected();
+ hotlist_edit_selection();
break;
case CMID_TREE_EDITTITLE:
@@ -1227,11 +1234,11 @@ static uint32 ami_context_menu_hook_tree(struct Hook *hook, Object *item, APTR r
break;
case CMID_TREE_NEWFOLDER:
- hotlist_old_add_folder(true);
+ hotlist_add_folder(NULL, false, 0);
break;
case CMID_TREE_NEWITEM:
- hotlist_old_add_entry(true);
+ hotlist_add_entry(NULL, NULL, false, 0);
break;
case CMID_TREE_SETDEFAULT:
diff --git a/amiga/cookies.c b/amiga/cookies.c
index 0c3e908..e29df34 100755
--- a/amiga/cookies.c
+++ b/amiga/cookies.c
@@ -18,7 +18,7 @@
#include <proto/exec.h>
#include "amiga/cookies.h"
-#include "desktop/cookies_old.h"
+#include "desktop/cookie_manager.h"
#include "amiga/tree.h"
void ami_cookies_initialise(void)
diff --git a/amiga/history.c b/amiga/history.c
index 8543d8d..663c2d9 100755
--- a/amiga/history.c
+++ b/amiga/history.c
@@ -18,7 +18,6 @@
#include "amiga/history.h"
#include "amiga/tree.h"
-#include "desktop/history_global_core.h"
#include <proto/exec.h>
#include "amiga/tree.h"
diff --git a/amiga/history.h b/amiga/history.h
index b69d46c..1f06474 100755
--- a/amiga/history.h
+++ b/amiga/history.h
@@ -19,7 +19,6 @@
#ifndef AMIGA_HISTORY_H
#define AMIGA_HISTORY_H
#include "desktop/tree.h"
-#include "desktop/history_global_core.h"
#define GLOBAL_HISTORY_RECENT_URLS 16
diff --git a/amiga/hotlist.c b/amiga/hotlist.c
index 1b195b4..6fa1568 100755
--- a/amiga/hotlist.c
+++ b/amiga/hotlist.c
@@ -19,40 +19,6 @@
#include <proto/exec.h>
#include "amiga/hotlist.h"
#include "amiga/tree.h"
-#include "desktop/hotlist_old.h"
-#include "utils/messages.h"
-
-bool ami_hotlist_find_dir(struct tree *tree, const char *dir_name)
-{
- struct node *root = tree_node_get_child(tree_get_root(tree));
- struct node *node;
- struct node_element *element;
-
- for (node = root; node; node = tree_node_get_next(node))
- {
- element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
- if(!element) element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
- if(element && (strcmp(tree_node_element_get_text(element), dir_name) == 0))
- {
- return true;
- }
- }
-
- return false;
-}
-
-void ami_hotlist_add_default_dirs(struct tree *tree)
-{
- if(ami_hotlist_find_dir(tree, messages_get("HotlistMenu")) == false) {
- tree_create_folder_node(tree, tree_get_root(tree),
- messages_get("HotlistMenu"), true, true, false);
- }
-
- if(ami_hotlist_find_dir(tree, messages_get("HotlistToolbar")) == false) {
- tree_create_folder_node(tree, tree_get_root(tree),
- messages_get("HotlistToolbar"), true, true, false);
- }
-}
void ami_hotlist_initialise(const char *hotlist_file)
{
@@ -60,8 +26,6 @@ void ami_hotlist_initialise(const char *hotlist_file)
hotlist_window = ami_tree_create(TREE_HOTLIST, NULL);
if(!hotlist_window) return;
-
- ami_hotlist_add_default_dirs(ami_tree_get_tree(hotlist_window));
}
void ami_hotlist_free(const char *hotlist_file)
diff --git a/amiga/menu.c b/amiga/menu.c
index f114253..d2db1f1 100644
--- a/amiga/menu.c
+++ b/amiga/menu.c
@@ -58,7 +58,7 @@
#include "amiga/theme.h"
#include "amiga/tree.h"
#include "amiga/utf8.h"
-#include "desktop/hotlist_old.h"
+#include "desktop/hotlist.h"
#include "desktop/browser_private.h"
#include "desktop/gui.h"
#include "desktop/textinput.h"
@@ -1037,7 +1037,7 @@ static void ami_menu_item_hotlist_add(struct Hook *hook, APTR window, struct Int
nsurl_access(hlcache_handle_get_url(bw->current_content)) == NULL)
return;
- hotlist_old_add_page(nsurl_access(hlcache_handle_get_url(bw->current_content)));
+ hotlist_add_url(hlcache_handle_get_url(bw->current_content));
}
static void ami_menu_item_hotlist_show(struct Hook *hook, APTR window, struct IntuiMessage *msg)
diff --git a/amiga/misc.c b/amiga/misc.c
index 11af051..003a5fb 100755
--- a/amiga/misc.c
+++ b/amiga/misc.c
@@ -32,7 +32,7 @@
#include "amiga/gui.h"
#include "amiga/utf8.h"
-#include "desktop/cookies_old.h"
+#include "desktop/cookie_manager.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/url.h"
diff --git a/amiga/tree.c b/amiga/tree.c
index 27e4cdb..15a7711 100644
--- a/amiga/tree.c
+++ b/amiga/tree.c
@@ -55,9 +55,9 @@
#include "amiga/filetype.h"
#include "utils/nsoption.h"
#include "content/urldb.h"
-#include "desktop/cookies_old.h"
-#include "desktop/history_global_core.h"
-#include "desktop/hotlist_old.h"
+#include "desktop/cookie_manager.h"
+#include "desktop/global_history.h"
+#include "desktop/hotlist.h"
#include "desktop/sslcert_viewer.h"
#include "utils/utils.h"
#include "utils/messages.h"
@@ -324,11 +324,13 @@ void ami_tree_drag_end(struct treeview_window *twin, int x, int y)
}
}
+#if 0
else if((tw = ami_window_at_pointer(AMINS_TVWINDOW)) &&
(tw != twin) && (tw->type == AMI_TREE_HOTLIST))
{
- hotlist_old_add_page_xy(tree_url_node_get_url(selected_node), x, y);
+ hotlist_add_entry(tree_url_node_get_url(selected_node), NULL, true, y);
}
+#endif
}
tree_drag_end(twin->tree, twin->mouse_state,
twin->drag_x, twin->drag_y,
@@ -997,9 +999,9 @@ BOOL ami_tree_event(struct treeview_window *twin)
AddPart(fname,savereq->fr_File,1024);
ami_update_pointer(twin->win, GUI_POINTER_WAIT);
if(twin->type == AMI_TREE_HISTORY)
- history_global_export(fname);
+ global_history_export(fname, NULL);
else if(twin->type == AMI_TREE_HOTLIST)
- hotlist_old_export(fname);
+ hotlist_export(fname, NULL);
ami_update_pointer(twin->win, GUI_POINTER_DEFAULT);
}
break;
@@ -1142,13 +1144,13 @@ BOOL ami_tree_event(struct treeview_window *twin)
switch(twin->type)
{
case AMI_TREE_HISTORY:
- history_global_delete_selected();
+ global_history_keypress(KEY_DELETE_LEFT);
break;
case AMI_TREE_COOKIES:
- cookies_delete_selected();
+ cookie_manager_keypress(KEY_DELETE_LEFT);
break;
case AMI_TREE_HOTLIST:
- hotlist_old_delete_selected();
+ hotlist_keypress(KEY_DELETE_LEFT);
break;
}
ami_tree_update_buttons(twin);
@@ -1158,13 +1160,13 @@ BOOL ami_tree_event(struct treeview_window *twin)
switch(twin->type)
{
case AMI_TREE_HISTORY:
- history_global_select_all();
+ global_history_keypress(KEY_SELECT_ALL);
break;
case AMI_TREE_COOKIES:
- cookies_select_all();
+ cookie_manager_keypress(KEY_SELECT_ALL);
break;
case AMI_TREE_HOTLIST:
- hotlist_old_select_all();
+ hotlist_keypress(KEY_SELECT_ALL);
break;
}
ami_tree_update_buttons(twin);
@@ -1174,13 +1176,13 @@ BOOL ami_tree_event(struct treeview_window *twin)
switch(twin->type)
{
case AMI_TREE_HISTORY:
- history_global_clear_selection();
+ global_history_keypress(KEY_CLEAR_SELECTION);
break;
case AMI_TREE_COOKIES:
- cookies_clear_selection();
+ cookie_manager_keypress(KEY_CLEAR_SELECTION);
break;
case AMI_TREE_HOTLIST:
- hotlist_old_clear_selection();
+ hotlist_keypress(KEY_CLEAR_SELECTION);
break;
}
ami_tree_update_buttons(twin);
diff --git a/atari/history.c b/atari/history.c
index 97636e2..1a19d4a 100755
--- a/atari/history.c
+++ b/atari/history.c
@@ -25,7 +25,7 @@
#include "utils/nsoption.h"
#include "desktop/tree.h"
#include "desktop/gui.h"
-#include "desktop/history_global_core.h"
+#include "desktop/global_history.h"
#include "desktop/browser.h"
#include "utils/messages.h"
#include "content/content.h"
diff --git a/atari/hotlist.c b/atari/hotlist.c
index 9211f3c..57cf0c0 100755
--- a/atari/hotlist.c
+++ b/atari/hotlist.c
@@ -28,7 +28,7 @@
#include "content/hlcache.h"
#include "content/urldb.h"
#include "utils/nsoption.h"
-#include "desktop/hotlist_old.h"
+#include "desktop/hotlist.h"
#include "desktop/tree.h"
#include "desktop/gui.h"
#include "utils/log.h"
@@ -61,20 +61,20 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
switch (msg[4]) {
case TOOLBAR_HOTLIST_CREATE_FOLDER:
- hotlist_old_add_folder(true);
+ hotlist_add_folder(NULL, false, 0);
break;
case TOOLBAR_HOTLIST_ADD:
- atari_hotlist_add_page("http://www.de", "");
+ atari_hotlist_add_page(NULL, NULL);
break;
case TOOLBAR_HOTLIST_DELETE:
- hotlist_old_delete_selected();
+ hotlist_keypress(KEY_DELETE_LEFT);
gemtk_wm_exec_redraw(tv->window, NULL);
break;
case TOOLBAR_HOTLIST_EDIT:
- hotlist_old_edit_selected();
+ hotlist_edit_selection();
break;
}
@@ -207,15 +207,20 @@ void atari_hotlist_add_page( const char * url, const char * title )
struct node * root;
struct node * selected = NULL;
struct node * folder = NULL;
+ nsurl *nsurl;
NSTREEVIEW tv = hl.tv;
if(hl.tv == NULL )
return;
atari_hotlist_open();
+ if (nsurl_create(url, &nsurl) != NSERROR_OK)
+ return;
+
if( hl.tv->click.x >= 0 && hl.tv->click.y >= 0 ){
- hotlist_old_add_page_xy( url, hl.tv->click.x, hl.tv->click.y );
+ hotlist_add_entry( nsurl, title, true, hl.tv->click.y );
} else {
- hotlist_old_add_page( url );
+ hotlist_add_url( nsurl );
}
+ nsurl_unref(nsurl);
}
diff --git a/atari/misc.c b/atari/misc.c
index 75410d2..974d37e 100755
--- a/atari/misc.c
+++ b/atari/misc.c
@@ -27,7 +27,7 @@
#include "content/content.h"
#include "content/hlcache.h"
-#include "desktop/cookies_old.h"
+#include "desktop/cookie_manager.h"
#include "desktop/mouse.h"
#include "desktop/tree.h"
#include "utils/nsoption.h"
diff --git a/beos/gui.cpp b/beos/gui.cpp
index 0abef08..ffaccc8 100644
--- a/beos/gui.cpp
+++ b/beos/gui.cpp
@@ -50,7 +50,6 @@ extern "C" {
#include "content/urldb.h"
#include "desktop/401login.h"
#include "desktop/browser_private.h"
-#include "desktop/cookies_old.h"
#include "desktop/gui.h"
#include "desktop/netsurf.h"
#include "utils/nsoption.h"
@@ -1078,11 +1077,6 @@ char *url_to_path(const char *url)
return path;
}
-bool cookies_update(const char *domain, const struct cookie_data *data)
-{
- return true;
-}
-
static void *myrealloc(void *ptr, size_t len, void *pw)
{
if (len == 0) {
diff --git a/cocoa/BookmarksController.m b/cocoa/BookmarksController.m
index 035d950..9c20c54 100644
--- a/cocoa/BookmarksController.m
+++ b/cocoa/BookmarksController.m
@@ -24,7 +24,7 @@
#import "cocoa/gui.h"
#import "desktop/browser_private.h"
-#import "desktop/hotlist_old.h"
+#import "desktop/hotlist.h"
#import "desktop/tree.h"
#import "utils/messages.h"
@@ -66,7 +66,7 @@ static const char *cocoa_hotlist_path( void )
- (void) save;
{
- hotlist_old_export( cocoa_hotlist_path() );
+ hotlist_export( cocoa_hotlist_path(), NULL );
}
- (void) dealloc;
@@ -164,8 +164,7 @@ static const char *cocoa_hotlist_path( void )
{
struct browser_window *bw = [[(NetSurfApp *)NSApp frontTab] browser];
if (bw && bw->current_content) {
- const char *url = nsurl_access(hlcache_handle_get_url( bw->current_content ));
- hotlist_old_add_page( url );
+ hotlist_add_url( nsurl_access(hlcache_handle_get_url( bw->current_content )) );
}
}
@@ -198,17 +197,17 @@ static const char *cocoa_hotlist_path( void )
- (IBAction) editSelected: (id) sender;
{
- hotlist_old_edit_selected();
+ hotlist_edit_selection();
}
- (IBAction) deleteSelected: (id) sender;
{
- hotlist_old_delete_selected();
+ hotlist_keypress(KEY_DELETE_LEFT);
}
- (IBAction) addFolder: (id) sender;
{
- hotlist_old_add_folder(true);
+ hotlist_add_folder(NULL, false, 0);
}
@end
diff --git a/cocoa/HistoryWindowController.m b/cocoa/HistoryWindowController.m
index d62f458..cae679b 100644
--- a/cocoa/HistoryWindowController.m
+++ b/cocoa/HistoryWindowController.m
@@ -20,7 +20,7 @@
#import "cocoa/Tree.h"
#import "cocoa/TreeView.h"
-#import "desktop/history_global_core.h"
+#import "desktop/global_history.h"
@implementation HistoryWindowController
diff --git a/content/urldb.c b/content/urldb.c
index 0dbb392..3cf6549 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -100,7 +100,6 @@
#include "image/bitmap.h"
#include "content/content.h"
#include "content/urldb.h"
-#include "desktop/cookies_old.h"
#include "desktop/cookie_manager.h"
#include "utils/nsoption.h"
#include "utils/log.h"
diff --git a/desktop/Makefile b/desktop/Makefile
index 8dccc22..f702007 100644
--- a/desktop/Makefile
+++ b/desktop/Makefile
@@ -1,9 +1,9 @@
# Sources for desktop
-S_DESKTOP := cookie_manager.c cookies_old.c history_global_core.c hotlist_old.c knockout.c \
- hotlist.c mouse.c plot_style.c print.c search.c searchweb.c \
- scrollbar.c sslcert_viewer.c textarea.c thumbnail.c tree.c \
- version.c system_colour.c global_history.c treeview.c
+S_DESKTOP := cookie_manager.c knockout.c hotlist.c mouse.c \
+ plot_style.c print.c search.c searchweb.c scrollbar.c \
+ sslcert_viewer.c textarea.c thumbnail.c tree.c version.c \
+ system_colour.c global_history.c treeview.c
S_DESKTOP := $(addprefix desktop/,$(S_DESKTOP))
diff --git a/desktop/browser.c b/desktop/browser.c
index de03735..9999444 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -47,9 +47,7 @@
#include "desktop/frames.h"
#include "desktop/global_history.h"
#include "desktop/gui.h"
-#include "desktop/history_global_core.h"
#include "desktop/hotlist.h"
-#include "desktop/hotlist_old.h"
#include "desktop/knockout.h"
#include "desktop/local_history.h"
#include "utils/nsoption.h"
diff --git a/desktop/cookie_manager.c b/desktop/cookie_manager.c
index 5f7f038..d9fd21c 100644
--- a/desktop/cookie_manager.c
+++ b/desktop/cookie_manager.c
@@ -24,7 +24,6 @@
#include <stdlib.h>
#include "content/urldb.h"
-#include "desktop/browser.h"
#include "desktop/cookie_manager.h"
#include "desktop/treeview.h"
#include "utils/messages.h"
diff --git a/desktop/cookie_manager.h b/desktop/cookie_manager.h
index b844907..4da85a8 100644
--- a/desktop/cookie_manager.h
+++ b/desktop/cookie_manager.h
@@ -24,8 +24,12 @@
#define _NETSURF_DESKTOP_COOKIE_MANAGER_H_
#include <stdbool.h>
+#include <stdint.h>
+#include "desktop/browser.h"
#include "desktop/core_window.h"
+#include "desktop/textinput.h"
+#include "utils/errors.h"
struct cookie_data;
diff --git a/desktop/cookies_old.c b/desktop/cookies_old.c
deleted file mode 100644
index 7981e91..0000000
--- a/desktop/cookies_old.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright 2006 Richard Wilson <info(a)tinct.net>
- * Copyright 2009 Paul Blokus <paul_pl(a)users.sourceforge.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/** \file
- * Cookies (implementation).
- */
-
-#include <assert.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include "content/content.h"
-#include "content/hlcache.h"
-#include "content/urldb.h"
-#include "desktop/cookies_old.h"
-#include "utils/nsoption.h"
-#include "desktop/tree.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/schedule.h"
-#include "utils/url.h"
-#include "utils/utils.h"
-
-/* Actions to be connected to front end specific toolbars */
-
-/**
- * Delete nodes which are currently selected.
- */
-void cookies_delete_selected(void)
-{
-}
-
-/**
- * Delete all nodes.
- */
-void cookies_delete_all(void)
-{
-}
-
-/**
- * Select all nodes in the tree.
- */
-void cookies_select_all(void)
-{
-}
-
-/**
- * Unselect all nodes.
- */
-void cookies_clear_selection(void)
-{
-}
-
-/**
- * Expand both domain and cookie nodes.
- */
-void cookies_expand_all(void)
-{
-}
-
-/**
- * Expand domain nodes only.
- */
-void cookies_expand_domains(void)
-{
-}
-
-/**
- * Expand cookie nodes only.
- */
-void cookies_expand_cookies(void)
-{
-}
-
-/**
- * Collapse both domain and cookie nodes.
- */
-void cookies_collapse_all(void)
-{
-}
-
-/**
- * Collapse domain nodes only.
- */
-void cookies_collapse_domains(void)
-{
-}
-
-/**
- * Collapse cookie nodes only.
- */
-void cookies_collapse_cookies(void)
-{
-}
diff --git a/desktop/cookies_old.h b/desktop/cookies_old.h
deleted file mode 100644
index dba5f17..0000000
--- a/desktop/cookies_old.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2006 Richard Wilson <info(a)tinct.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/** \file
- * Cookies (interface).
- */
-
-#ifndef _NETSURF_DESKTOP_COOKIES_OLD_H_
-#define _NETSURF_DESKTOP_COOKIES_OLD_H_
-
-#include <stdbool.h>
-
-#include "desktop/tree.h"
-
-void cookies_delete_selected(void);
-void cookies_delete_all(void);
-void cookies_select_all(void);
-void cookies_clear_selection(void);
-void cookies_expand_all(void);
-void cookies_expand_domains(void);
-void cookies_expand_cookies(void);
-void cookies_collapse_all(void);
-void cookies_collapse_domains(void);
-void cookies_collapse_cookies(void);
-
-#endif
diff --git a/desktop/global_history.c b/desktop/global_history.c
index 2b384b1..d20eb37 100644
--- a/desktop/global_history.c
+++ b/desktop/global_history.c
@@ -20,7 +20,6 @@
#include <stdlib.h>
#include "content/urldb.h"
-#include "desktop/browser.h"
#include "desktop/global_history.h"
#include "desktop/treeview.h"
#include "utils/messages.h"
diff --git a/desktop/global_history.h b/desktop/global_history.h
index 6e5ff1e..a720d30 100644
--- a/desktop/global_history.h
+++ b/desktop/global_history.h
@@ -20,8 +20,12 @@
#define _NETSURF_DESKTOP_GLOBAL_HISTORY_H_
#include <stdbool.h>
+#include <stdint.h>
+#include "desktop/browser.h"
#include "desktop/core_window.h"
+#include "desktop/textinput.h"
+#include "utils/errors.h"
#include "utils/nsurl.h"
diff --git a/desktop/history_global_core.c b/desktop/history_global_core.c
deleted file mode 100644
index 1f788ad..0000000
--- a/desktop/history_global_core.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright 2005 Richard Wilson <info(a)tinct.net>
- * Copyright 2009 Paul Blokus <paul_pl(a)users.sourceforge.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include <stdlib.h>
-
-#include "content/content.h"
-#include "content/hlcache.h"
-#include "content/urldb.h"
-#include "desktop/browser.h"
-#include "desktop/history_global_core.h"
-#include "desktop/global_history.h"
-#include "desktop/plotters.h"
-#include "desktop/tree.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
-#include "utils/log.h"
-
-
-/* Actions to be connected to front end specific toolbars */
-
-/**
- * Save the global history in a human-readable form under the given location.
- *
- * \param path the path where the history will be saved
- */
-bool history_global_export(const char *path)
-{
- return global_history_export(path, NULL) == NSERROR_OK;
-}
-
-/**
- * Delete nodes which are currently selected.
- */
-void history_global_delete_selected(void)
-{
-}
-
-/**
- * Delete all nodes.
- */
-void history_global_delete_all(void)
-{
-}
-
-/**
- * Select all nodes in the tree.
- */
-void history_global_select_all(void)
-{
-}
-
-/**
- * Unselect all nodes.
- */
-void history_global_clear_selection(void)
-{
-}
-
-/**
- * Expand grouping folders and history entries.
- */
-void history_global_expand_all(void)
-{
-}
-
-/**
- * Expand grouping folders only.
- */
-void history_global_expand_directories(void)
-{
-}
-
-/**
- * Expand history entries only.
- */
-void history_global_expand_addresses(void)
-{
-}
-
-/**
- * Collapse grouping folders and history entries.
- */
-void history_global_collapse_all(void)
-{
-}
-
-/**
- * Collapse grouping folders only.
- */
-void history_global_collapse_directories(void)
-{
-}
-
-/**
- * Collapse history entries only.
- */
-void history_global_collapse_addresses(void)
-{
-}
-
-/**
- * Open the selected entries in seperate browser windows.
- *
- * \param tabs open multiple entries in tabs in the new window
- */
-void history_global_launch_selected(bool tabs)
-{
-}
diff --git a/desktop/history_global_core.h b/desktop/history_global_core.h
deleted file mode 100644
index 29b3f09..0000000
--- a/desktop/history_global_core.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2005 Richard Wilson <info(a)tinct.net>
- * Copyright 2009 Paul Blokus <paul_pl(a)users.sourceforge.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef _NETSURF_DESKTOP_HISTORY_GLOBAL_H_
-#define _NETSURF_DESKTOP_HISTORY_GLOBAL_H_
-
-#include <stdbool.h>
-
-#include "desktop/tree.h"
-
-bool history_global_export(const char *path);
-void history_global_delete_selected(void);
-void history_global_delete_all(void);
-void history_global_select_all(void);
-void history_global_clear_selection(void);
-void history_global_expand_all(void);
-void history_global_expand_directories(void);
-void history_global_expand_addresses(void);
-void history_global_collapse_all(void);
-void history_global_collapse_directories(void);
-void history_global_collapse_addresses(void);
-void history_global_launch_selected(bool tabs);
-
-#endif
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index 683fdc4..ce91563 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -24,7 +24,6 @@
#include <dom/bindings/hubbub/parser.h>
#include "content/urldb.h"
-#include "desktop/browser.h"
#include "desktop/hotlist.h"
#include "desktop/treeview.h"
#include "utils/corestrings.h"
@@ -1336,7 +1335,7 @@ nserror hotlist_add_entry(nsurl *url, const char *title, bool at_y, int y)
if (title != NULL) {
title = strdup(title);
if (title == NULL) {
- nsurl_ref(url);
+ nsurl_unref(url);
return NSERROR_NOMEM;
}
}
diff --git a/desktop/hotlist.h b/desktop/hotlist.h
index 171fdd7..d192eaa 100644
--- a/desktop/hotlist.h
+++ b/desktop/hotlist.h
@@ -20,8 +20,12 @@
#define _NETSURF_DESKTOP_HOTLIST_H_
#include <stdbool.h>
+#include <stdint.h>
+#include "desktop/browser.h"
#include "desktop/core_window.h"
+#include "desktop/textinput.h"
+#include "utils/errors.h"
#include "utils/nsurl.h"
diff --git a/desktop/hotlist_old.c b/desktop/hotlist_old.c
deleted file mode 100644
index a2c094a..0000000
--- a/desktop/hotlist_old.c
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright 2004, 2005 Richard Wilson <info(a)tinct.net>
- * Copyright 2009 Paul Blokus <paul_pl(a)users.sourceforge.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <ctype.h>
-#include <stdlib.h>
-
-#include "utils/nsoption.h"
-#include "content/content.h"
-#include "content/hlcache.h"
-#include "content/urldb.h"
-#include "desktop/browser.h"
-#include "desktop/hotlist.h"
-#include "desktop/hotlist_old.h"
-#include "desktop/plotters.h"
-#include "desktop/textinput.h"
-#include "desktop/tree.h"
-
-#include "utils/messages.h"
-#include "utils/utils.h"
-#include "utils/log.h"
-
-/**
- * Save the hotlist in a human-readable form under the given location.
- *
- * \param path the path where the hotlist will be saved
- */
-bool hotlist_old_export(const char *path)
-{
- nserror err;
- err = hotlist_export(path, NULL);
- return (err == NSERROR_OK);
-}
-
-/**
- * Edit the node which is currently selected. Works only if one node is
- * selected.
- */
-void hotlist_old_edit_selected(void)
-{
- /* Update new hotlist */
- hotlist_edit_selection();
-}
-
-/**
- * Delete nodes which are currently selected.
- */
-void hotlist_old_delete_selected(void)
-{
- hotlist_keypress(KEY_DELETE_LEFT);
-}
-
-/**
- * Select all nodes in the tree.
- */
-void hotlist_old_select_all(void)
-{
- hotlist_keypress(KEY_SELECT_ALL);
-}
-
-/**
- * Unselect all nodes.
- */
-void hotlist_old_clear_selection(void)
-{
- hotlist_keypress(KEY_CLEAR_SELECTION);
-}
-
-/**
- * Expand grouping folders and history entries.
- */
-void hotlist_old_expand_all(void)
-{
-}
-
-/**
- * Expand grouping folders only.
- */
-void hotlist_old_expand_directories(void)
-{
-}
-
-/**
- * Expand history entries only.
- */
-void hotlist_old_expand_addresses(void)
-{
-}
-
-/**
- * Collapse grouping folders and history entries.
- */
-void hotlist_old_collapse_all(void)
-{
-}
-
-/**
- * Collapse grouping folders only.
- */
-void hotlist_old_collapse_directories(void)
-{
-}
-
-/**
- * Collapse history entries only.
- */
-void hotlist_old_collapse_addresses(void)
-{
-}
-
-/**
- * Add a folder node.
- *
- * \param selected create the folder in the currently-selected node
- */
-void hotlist_old_add_folder(bool selected)
-{
- hotlist_add_folder(NULL, false, 0);
-}
-
-/**
- * Add an entry node.
- *
- * \param selected add the entry in the currently-selected node
- */
-void hotlist_old_add_entry(bool selected)
-{
- nsurl *url;
-
- if (nsurl_create("http://netsurf-browser.org/", &url) != NSERROR_OK)
- return;
-
- hotlist_add_entry(url, "New untitled entry", false, 0);
- nsurl_unref(url);
-}
-
-/**
- * Adds the currently viewed page to the hotlist
- */
-void hotlist_old_add_page(const char *url)
-{
- nsurl *nsurl;
-
- if (url == NULL)
- return;
-
- if (nsurl_create(url, &nsurl) != NSERROR_OK)
- return;
-
- /* Update new hotlist */
- hotlist_add_url(nsurl);
- nsurl_unref(nsurl);
-}
-
-/**
- * Adds the currently viewed page to the hotlist at the given co-ordinates
- * \param url url of the page
- * \param x X cooridinate with respect to tree origin
- * \param y Y cooridinate with respect to tree origin
- */
-void hotlist_old_add_page_xy(const char *url, int x, int y)
-{
- nsurl *nsurl;
-
- if (url == NULL)
- return;
-
- if (nsurl_create(url, &nsurl) != NSERROR_OK)
- return;
-
- /* Update new hotlist */
- hotlist_add_entry(nsurl, NULL, true, y);
- nsurl_unref(nsurl);
-}
-
-/**
- * Open the selected entries in separate browser windows.
- *
- * \param tabs open multiple entries in tabs in the new window
- */
-void hotlist_old_launch_selected(bool tabs)
-{
- hotlist_keypress(KEY_CR);
-}
-
-/**
- * Set the hotlist's default folder to the selected node.
- *
- * \param clear reset the default to tree root
- */
-bool hotlist_old_set_default_folder(bool clear)
-{
- return false;
-}
diff --git a/desktop/hotlist_old.h b/desktop/hotlist_old.h
deleted file mode 100644
index 9e88d84..0000000
--- a/desktop/hotlist_old.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2004, 2005 Richard Wilson <info(a)tinct.net>
- * Copyright 2009 Paul Blokus <paul_pl(a)users.sourceforge.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-
-/** \file
- * Hotlist (interface).
- */
-
-#ifndef _NETSURF_DESKTOP_HOTLIST_OLD_H_
-#define _NETSURF_DESKTOP_HOTLIST_OLD_H_
-
-#include <stdbool.h>
-
-#include "desktop/tree.h"
-
-bool hotlist_old_export(const char *path);
-void hotlist_old_edit_selected(void);
-void hotlist_old_delete_selected(void);
-void hotlist_old_select_all(void);
-void hotlist_old_clear_selection(void);
-void hotlist_old_expand_all(void);
-void hotlist_old_expand_directories(void);
-void hotlist_old_expand_addresses(void);
-void hotlist_old_collapse_all(void);
-void hotlist_old_collapse_directories(void);
-void hotlist_old_collapse_addresses(void);
-void hotlist_old_add_folder(bool selected);
-void hotlist_old_add_entry(bool selected);
-void hotlist_old_add_page(const char *url);
-void hotlist_old_add_page_xy(const char *url, int x, int y);
-void hotlist_old_launch_selected(bool tabs);
-bool hotlist_old_set_default_folder(bool clear);
-#endif
diff --git a/desktop/sslcert_viewer.c b/desktop/sslcert_viewer.c
index 7362371..f1cfcca 100644
--- a/desktop/sslcert_viewer.c
+++ b/desktop/sslcert_viewer.c
@@ -27,7 +27,6 @@
#include "content/fetch.h"
#include "content/urldb.h"
-#include "desktop/browser.h"
#include "desktop/sslcert_viewer.h"
#include "desktop/treeview.h"
#include "utils/messages.h"
diff --git a/desktop/sslcert_viewer.h b/desktop/sslcert_viewer.h
index c5bb5c0..002e919 100644
--- a/desktop/sslcert_viewer.h
+++ b/desktop/sslcert_viewer.h
@@ -22,8 +22,12 @@
#define _NETSURF_DESKTOP_SSLCERT_VIEWER_H_
#include <stdbool.h>
+#include <stdint.h>
+#include "desktop/browser.h"
#include "desktop/core_window.h"
+#include "desktop/textinput.h"
+#include "utils/errors.h"
struct sslcert_session_data;
diff --git a/framebuffer/misc.c b/framebuffer/misc.c
index 0568e36..2dd0367 100644
--- a/framebuffer/misc.c
+++ b/framebuffer/misc.c
@@ -21,7 +21,6 @@
#include <stdio.h>
#include <string.h>
-#include "desktop/cookies_old.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
diff --git a/gtk/cookies.c b/gtk/cookies.c
index 4c56563..e020c53 100644
--- a/gtk/cookies.c
+++ b/gtk/cookies.c
@@ -21,9 +21,10 @@
*/
-#include "desktop/cookies_old.h"
+#include "desktop/cookie_manager.h"
#include "desktop/plotters.h"
#include "desktop/tree.h"
+#include "desktop/textinput.h"
#include "utils/log.h"
#include "gtk/gui.h"
#include "gtk/cookies.h"
@@ -160,25 +161,26 @@ void nsgtk_cookies_destroy(void)
/* edit menu */
MENUHANDLER(delete_selected)
{
- cookies_delete_selected();
+ cookie_manager_keypress(KEY_DELETE_LEFT);
return TRUE;
}
MENUHANDLER(delete_all)
{
- cookies_delete_all();
+ cookie_manager_keypress(KEY_SELECT_ALL);
+ cookie_manager_keypress(KEY_DELETE_LEFT);
return TRUE;
}
MENUHANDLER(select_all)
{
- cookies_select_all();
+ cookie_manager_keypress(KEY_SELECT_ALL);
return TRUE;
}
MENUHANDLER(clear_selection)
{
- cookies_clear_selection();
+ cookie_manager_keypress(KEY_CLEAR_SELECTION);
return TRUE;
}
diff --git a/gtk/gui.c b/gtk/gui.c
index 1f191d6..226d718 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -45,9 +45,7 @@
#include "content/hlcache.h"
#include "content/urldb.h"
#include "desktop/browser_private.h"
-#include "desktop/cookies_old.h"
#include "desktop/gui.h"
-#include "desktop/history_global_core.h"
#include "desktop/netsurf.h"
#include "utils/nsoption.h"
#include "desktop/save_complete.h"
diff --git a/gtk/history.c b/gtk/history.c
index bfdb90b..c443739 100644
--- a/gtk/history.c
+++ b/gtk/history.c
@@ -18,9 +18,10 @@
*/
-#include "desktop/history_global_core.h"
+#include "desktop/global_history.h"
#include "desktop/plotters.h"
#include "desktop/tree.h"
+#include "desktop/textinput.h"
#include "gtk/gui.h"
#include "gtk/history.h"
#include "gtk/plotters.h"
@@ -184,7 +185,7 @@ MENUHANDLER(export)
gchar *filename = gtk_file_chooser_get_filename(
GTK_FILE_CHOOSER(save_dialog));
- history_global_export(filename);
+ global_history_export(filename, NULL);
g_free(filename);
}
@@ -196,25 +197,26 @@ MENUHANDLER(export)
/* edit menu */
MENUHANDLER(delete_selected)
{
- history_global_delete_selected();
+ global_history_keypress(KEY_DELETE_LEFT);
return TRUE;
}
MENUHANDLER(delete_all)
{
- history_global_delete_all();
+ global_history_keypress(KEY_SELECT_ALL);
+ global_history_keypress(KEY_DELETE_LEFT);
return TRUE;
}
MENUHANDLER(select_all)
{
- history_global_select_all();
+ global_history_keypress(KEY_SELECT_ALL);
return TRUE;
}
MENUHANDLER(clear_selection)
{
- history_global_clear_selection();
+ global_history_keypress(KEY_CLEAR_SELECTION);
return TRUE;
}
@@ -257,6 +259,6 @@ MENUHANDLER(collapse_addresses)
MENUHANDLER(launch)
{
- history_global_launch_selected(true);
+ global_history_keypress(KEY_CR);
return TRUE;
}
diff --git a/gtk/hotlist.c b/gtk/hotlist.c
index 618d9d4..9506ed7 100644
--- a/gtk/hotlist.c
+++ b/gtk/hotlist.c
@@ -17,7 +17,7 @@
*/
-#include "desktop/hotlist_old.h"
+#include "desktop/hotlist.h"
#include "utils/nsoption.h"
#include "desktop/plotters.h"
#include "desktop/tree.h"
@@ -190,7 +190,7 @@ MENUHANDLER(export)
gchar *filename = gtk_file_chooser_get_filename(
GTK_FILE_CHOOSER(save_dialog));
- hotlist_old_export(filename);
+ hotlist_export(filename, NULL);
g_free(filename);
}
@@ -201,38 +201,38 @@ MENUHANDLER(export)
MENUHANDLER(new_folder)
{
- hotlist_old_add_folder(true);
+ hotlist_add_folder(NULL, false, 0);
return TRUE;
}
MENUHANDLER(new_entry)
{
- hotlist_old_add_entry(true);
+ hotlist_add_entry(NULL, NULL, false, 0);
return TRUE;
}
/* edit menu */
MENUHANDLER(edit_selected)
{
- hotlist_old_edit_selected();
+ hotlist_edit_selection();
return TRUE;
}
MENUHANDLER(delete_selected)
{
- hotlist_old_delete_selected();
+ hotlist_keypress(KEY_DELETE_LEFT);
return TRUE;
}
MENUHANDLER(select_all)
{
- hotlist_old_select_all();
+ hotlist_keypress(KEY_SELECT_ALL);
return TRUE;
}
MENUHANDLER(clear_selection)
{
- hotlist_old_clear_selection();
+ hotlist_keypress(KEY_CLEAR_SELECTION);
return TRUE;
}
@@ -275,6 +275,6 @@ MENUHANDLER(collapse_addresses)
MENUHANDLER(launch)
{
- hotlist_old_launch_selected(true);
+ hotlist_keypress(KEY_CR);
return TRUE;
}
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index d2aabaf..fdc3cc7 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -34,7 +34,7 @@
#include "css/utils.h"
#include "desktop/browser_private.h"
#include "desktop/local_history.h"
-#include "desktop/hotlist_old.h"
+#include "desktop/hotlist.h"
#include "desktop/gui.h"
#include "desktop/netsurf.h"
#include "utils/nsoption.h"
@@ -1540,7 +1540,7 @@ MULTIHANDLER(addbookmarks)
if (bw == NULL || bw->current_content == NULL ||
hlcache_handle_get_url(bw->current_content) == NULL)
return TRUE;
- hotlist_old_add_page(nsurl_access(hlcache_handle_get_url(bw->current_content)));
+ hotlist_add_url(hlcache_handle_get_url(bw->current_content));
return TRUE;
}
diff --git a/riscos/cookies.c b/riscos/cookies.c
index eb74f51..dfdbc5d 100644
--- a/riscos/cookies.c
+++ b/riscos/cookies.c
@@ -31,8 +31,8 @@
#include "oslib/wimpspriteop.h"
#include "content/urldb.h"
#include "desktop/cookie_manager.h"
-#include "desktop/cookies_old.h"
#include "desktop/tree.h"
+#include "desktop/textinput.h"
#include "riscos/cookies.h"
#include "riscos/dialog.h"
#include "riscos/menus.h"
@@ -179,7 +179,7 @@ void ro_gui_cookies_toolbar_click(button_bar_action action)
{
switch (action) {
case TOOLBAR_BUTTON_DELETE:
- cookies_delete_selected();
+ cookie_manager_keypress(KEY_DELETE_LEFT);
break;
case TOOLBAR_BUTTON_EXPAND:
@@ -318,13 +318,13 @@ bool ro_gui_cookies_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
cookies_collapse_cookies();
return true;
case TREE_SELECTION_DELETE:
- cookies_delete_selected();
+ cookie_manager_keypress(KEY_DELETE_LEFT);
return true;
case TREE_SELECT_ALL:
- cookies_select_all();
+ cookie_manager_keypress(KEY_SELECT_ALL);
return true;
case TREE_CLEAR_SELECTION:
- cookies_clear_selection();
+ cookie_manager_keypress(KEY_CLEAR_SELECTION);
return true;
case TOOLBAR_BUTTONS:
ro_toolbar_set_display_buttons(cookies_window.toolbar,
diff --git a/riscos/global_history.c b/riscos/global_history.c
index 3a060c0..aecc989 100644
--- a/riscos/global_history.c
+++ b/riscos/global_history.c
@@ -30,7 +30,6 @@
#include "oslib/wimp.h"
#include "oslib/wimpspriteop.h"
#include "content/urldb.h"
-#include "desktop/history_global_core.h"
#include "desktop/global_history.h"
#include "desktop/tree.h"
#include "riscos/dialog.h"
@@ -186,7 +185,7 @@ void ro_gui_global_history_toolbar_click(button_bar_action action)
{
switch (action) {
case TOOLBAR_BUTTON_DELETE:
- history_global_delete_selected();
+ global_history_keypress(KEY_DELETE_LEFT);
break;
case TOOLBAR_BUTTON_EXPAND:
@@ -206,7 +205,7 @@ void ro_gui_global_history_toolbar_click(button_bar_action action)
break;
case TOOLBAR_BUTTON_LAUNCH:
- history_global_launch_selected(false);
+ global_history_keypress(KEY_CR);
break;
default:
@@ -343,16 +342,16 @@ bool ro_gui_global_history_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
history_global_collapse_addresses();
return true;
case TREE_SELECTION_LAUNCH:
- history_global_launch_selected(false);
+ global_history_keypress(KEY_CR);
return true;
case TREE_SELECTION_DELETE:
- history_global_delete_selected();
+ global_history_keypress(KEY_DELETE_LEFT);
return true;
case TREE_SELECT_ALL:
- history_global_select_all();
+ global_history_keypress(KEY_SELECT_ALL);
return true;
case TREE_CLEAR_SELECTION:
- history_global_clear_selection();
+ global_history_keypress(KEY_CLEAR_SELECTION);
return true;
case TOOLBAR_BUTTONS:
ro_toolbar_set_display_buttons(global_history_window.toolbar,
diff --git a/riscos/gui.c b/riscos/gui.c
index 39a34de..5811454 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -55,10 +55,7 @@
#include "content/hlcache.h"
#include "content/urldb.h"
#include "content/fetchers/resource.h"
-#include "desktop/cookies_old.h"
#include "desktop/gui.h"
-#include "desktop/history_global_core.h"
-#include "desktop/hotlist_old.h"
#include "desktop/netsurf.h"
#include "utils/nsoption.h"
#include "desktop/save_complete.h"
diff --git a/riscos/hotlist.c b/riscos/hotlist.c
index 721e532..73c8002 100644
--- a/riscos/hotlist.c
+++ b/riscos/hotlist.c
@@ -33,7 +33,6 @@
#include "content/content.h"
#include "content/hlcache.h"
#include "content/urldb.h"
-#include "desktop/hotlist_old.h"
#include "desktop/hotlist.h"
#include "desktop/tree.h"
#include "riscos/dialog.h"
@@ -228,7 +227,7 @@ void ro_gui_hotlist_toolbar_click(button_bar_action action)
{
switch (action) {
case TOOLBAR_BUTTON_DELETE:
- hotlist_old_delete_selected();
+ hotlist_keypress(KEY_DELETE_LEFT);
break;
case TOOLBAR_BUTTON_EXPAND:
@@ -248,11 +247,11 @@ void ro_gui_hotlist_toolbar_click(button_bar_action action)
break;
case TOOLBAR_BUTTON_LAUNCH:
- hotlist_old_launch_selected(false);
+ hotlist_keypress(KEY_CR);
break;
case TOOLBAR_BUTTON_CREATE:
- hotlist_old_add_folder(true);
+ hotlist_add_folder(NULL, false, 0);
break;
default:
@@ -367,10 +366,10 @@ bool ro_gui_hotlist_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
ro_gui_dialog_open_persistent(w, dialog_saveas, true);
return true;
case TREE_NEW_FOLDER:
- hotlist_old_add_folder(true);
+ hotlist_add_folder(NULL, false, 0);
return true;
case TREE_NEW_LINK:
- hotlist_old_add_entry(true);
+ hotlist_add_entry(NULL, NULL, false, 0);
return true;
case TREE_EXPAND_ALL:
hotlist_old_expand_all();
@@ -391,19 +390,19 @@ bool ro_gui_hotlist_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
hotlist_old_collapse_addresses();
return true;
case TREE_SELECTION_EDIT:
- hotlist_old_edit_selected();
+ hotlist_edit_selection();
return true;
case TREE_SELECTION_LAUNCH:
- hotlist_old_launch_selected(false);
+ hotlist_keypress(KEY_CR);
return true;
case TREE_SELECTION_DELETE:
- hotlist_old_delete_selected();
+ hotlist_keypress(KEY_DELETE_LEFT);
return true;
case TREE_SELECT_ALL:
- hotlist_old_select_all();
+ hotlist_keypress(KEY_SELECT_ALL);
return true;
case TREE_CLEAR_SELECTION:
- hotlist_old_clear_selection();
+ hotlist_keypress(KEY_CLEAR_SELECTION);
return true;
case TOOLBAR_BUTTONS:
ro_toolbar_set_display_buttons(hotlist_window.toolbar,
@@ -469,12 +468,16 @@ void ro_gui_hotlist_add_page(const char *url)
if (url == NULL)
return;
+ if (nsurl_create(url, &nsurl) != NSERROR_OK)
+ return;
+
/* If we're not using external hotlists, add the page to NetSurf's
* own hotlist and return...
*/
if (!nsoption_bool(external_hotlists)) {
- hotlist_old_add_page(url);
+ hotlist_add_url(nsurl);
+ nsurl_unref(nsurl);
return;
}
@@ -487,8 +490,6 @@ void ro_gui_hotlist_add_page(const char *url)
LOG(("Sending Hotlist AddURL to potential hotlist clients."));
- if (nsurl_create(url, &nsurl) != NSERROR_OK)
- return;
data = urldb_get_url_data(nsurl);
if (data == NULL)
return;
@@ -534,8 +535,15 @@ static void ro_gui_hotlist_addurl_bounce(wimp_message *message)
{
LOG(("Hotlist AddURL Bounced"));
- if (hotlist_url != NULL)
- hotlist_old_add_page(hotlist_url);
+ if (hotlist_url != NULL) {
+ nsurl *nsurl;
+
+ if (nsurl_create(hotlist_url, &nsurl) != NSERROR_OK)
+ return;
+
+ hotlist_add_page(nsurl);
+ nsurl_unref(nsurl);
+ }
ro_gui_hotlist_add_cleanup();
@@ -591,14 +599,24 @@ void ro_gui_hotlist_add_cleanup(void)
void ro_gui_hotlist_url_drop(wimp_message *message, const char *url)
{
int x, y;
+ nsurl *nsurl;
+
if (hotlist_window.window != message->data.data_xfer.w)
return;
+ if (url == NULL)
+ return;
+
+ if (nsurl_create(url, &nsurl) != NSERROR_OK)
+ return;
+
ro_gui_tree_get_tree_coordinates(hotlist_window.tree,
message->data.data_xfer.pos.x,
message->data.data_xfer.pos.y,
&x, &y);
- hotlist_old_add_page_xy(url, x, y);
+
+ hotlist_add_entry(nsurl, NULL, true, y);
+ nsurl_unref(nsurl);
}
#endif
diff --git a/riscos/menus.c b/riscos/menus.c
index 5a576f8..e51fc34 100644
--- a/riscos/menus.c
+++ b/riscos/menus.c
@@ -34,10 +34,9 @@
#include "content/content.h"
#include "content/hlcache.h"
#include "content/urldb.h"
-#include "desktop/cookies_old.h"
+#include "desktop/cookie_manager.h"
#include "desktop/browser.h"
#include "desktop/gui.h"
-#include "desktop/history_global_core.h"
#include "desktop/local_history.h"
#include "desktop/netsurf.h"
#include "desktop/textinput.h"
diff --git a/riscos/save.c b/riscos/save.c
index 0a91140..ad2d4c4 100644
--- a/riscos/save.c
+++ b/riscos/save.c
@@ -37,8 +37,8 @@
#include "oslib/wimpspriteop.h"
#include "content/content.h"
#include "content/hlcache.h"
-#include "desktop/hotlist_old.h"
-#include "desktop/history_global_core.h"
+#include "desktop/hotlist.h"
+#include "desktop/global_history.h"
#include "desktop/netsurf.h"
#include "desktop/save_complete.h"
#include "desktop/save_text.h"
@@ -882,7 +882,7 @@ bool ro_gui_save_content(hlcache_handle *h, char *path, bool force_overwrite)
LINK_TEXT, path);
case GUI_SAVE_HOTLIST_EXPORT_HTML:
- if (!hotlist_old_export(path))
+ if (hotlist_export(path, NULL) != NSERROR_OK)
return false;
error = xosfile_set_type(path, 0xfaf);
if (error)
@@ -890,7 +890,7 @@ bool ro_gui_save_content(hlcache_handle *h, char *path, bool force_overwrite)
error->errnum, error->errmess));
break;
case GUI_SAVE_HISTORY_EXPORT_HTML:
- if (!history_global_export(path))
+ if (global_history_export(path, NULL) != NSERROR_OK)
return false;
error = xosfile_set_type(path, 0xfaf);
if (error)
diff --git a/riscos/window.c b/riscos/window.c
index 7971763..d3375be 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -46,7 +46,7 @@
#include "content/urldb.h"
#include "css/css.h"
#include "desktop/browser_private.h"
-#include "desktop/cookies_old.h"
+#include "desktop/cookie_manager.h"
#include "desktop/scrollbar.h"
#include "desktop/frames.h"
#include "desktop/local_history.h"
@@ -2763,7 +2763,8 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
break;
case COOKIES_DELETE:
- cookies_delete_all();
+ cookie_manager_keypress(KEY_SELECT_ALL);
+ cookie_manager_keypress(KEY_DELETE_LEFT);
break;
/* page actions */
diff --git a/test/llcache.c b/test/llcache.c
index b3eb0d2..643ff7f 100644
--- a/test/llcache.c
+++ b/test/llcache.c
@@ -105,24 +105,24 @@ char *url_to_path(const char *url)
* Things that are absolutely not reasonable, and should disappear *
******************************************************************************/
-#include "desktop/cookies_old.h"
+#include "desktop/cookie_manager.h"
#include "desktop/gui.h"
#include "desktop/tree.h"
-/* desktop/cookies_old.h -- used by urldb
+/* desktop/cookie_manager.h -- used by urldb
*
* URLdb should have a cookies update event + handler registration
*/
-bool cookies_schedule_update(const struct cookie_data *data)
+bool cookie_manager_add(const struct cookie_data *data)
{
return true;
}
-/* desktop/cookies_old.h -- used by urldb
+/* desktop/cookie_manager.h -- used by urldb
*
* URLdb should have a cookies removal handler registration
*/
-void cookies_remove(const struct cookie_data *data)
+void cookie_manager_remove(const struct cookie_data *data)
{
}
diff --git a/test/urldbtest.c b/test/urldbtest.c
index 7c72ed7..cc657ed 100644
--- a/test/urldbtest.c
+++ b/test/urldbtest.c
@@ -32,7 +32,7 @@
#include "image/bitmap.h"
#include "content/content.h"
#include "content/urldb.h"
-#include "desktop/cookies_old.h"
+#include "desktop/cookie_manager.h"
#include "utils/nsoption.h"
#ifdef riscos
/** \todo lose this */
@@ -52,12 +52,12 @@ static void netsurf_lwc_iterator(lwc_string *str, void *pw)
LOG(("[%3u] %.*s", str->refcnt, (int) lwc_string_length(str), lwc_string_data(str)));
}
-bool cookies_schedule_update(const struct cookie_data *data)
+bool cookie_manager_add(const struct cookie_data *data)
{
return true;
}
-void cookies_remove(const struct cookie_data *data)
+void cookie_manager_remove(const struct cookie_data *data)
{
}
diff --git a/windows/misc.c b/windows/misc.c
index 51c02ca..d820a5b 100644
--- a/windows/misc.c
+++ b/windows/misc.c
@@ -25,7 +25,6 @@
#include <windows.h>
-#include "desktop/cookies_old.h"
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/url.h"
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=e9f65ff9cb60c94b43d...
commit e9f65ff9cb60c94b43d4b875892918b90fb2a067
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Remove cookies, history_global, and hotlist_old _initialise and _cleanup functions.
diff --git a/amiga/cookies.c b/amiga/cookies.c
index c1f8868..0c3e908 100755
--- a/amiga/cookies.c
+++ b/amiga/cookies.c
@@ -26,14 +26,10 @@ void ami_cookies_initialise(void)
cookies_window = ami_tree_create(TREE_COOKIES, NULL);
if(!cookies_window) return;
-
- cookies_initialise(ami_tree_get_tree(cookies_window),
- NULL, NULL);
}
void ami_cookies_free()
{
- cookies_cleanup();
ami_tree_destroy(cookies_window);
cookies_window = NULL;
}
diff --git a/amiga/history.c b/amiga/history.c
index 6206efd..8543d8d 100755
--- a/amiga/history.c
+++ b/amiga/history.c
@@ -27,14 +27,10 @@ void ami_global_history_initialise(void)
global_history_window = ami_tree_create(TREE_HISTORY, NULL);
if(!global_history_window) return;
-
- history_global_initialise(ami_tree_get_tree(global_history_window),
- NULL);
}
void ami_global_history_free()
{
- history_global_cleanup();
ami_tree_destroy(global_history_window);
global_history_window = NULL;
}
diff --git a/amiga/hotlist.c b/amiga/hotlist.c
index fa93b46..1b195b4 100755
--- a/amiga/hotlist.c
+++ b/amiga/hotlist.c
@@ -60,16 +60,12 @@ void ami_hotlist_initialise(const char *hotlist_file)
hotlist_window = ami_tree_create(TREE_HOTLIST, NULL);
if(!hotlist_window) return;
-
- hotlist_old_initialise(ami_tree_get_tree(hotlist_window),
- hotlist_file, NULL);
ami_hotlist_add_default_dirs(ami_tree_get_tree(hotlist_window));
}
void ami_hotlist_free(const char *hotlist_file)
{
- hotlist_old_cleanup(hotlist_file);
ami_tree_destroy(hotlist_window);
hotlist_window = NULL;
}
diff --git a/atari/history.c b/atari/history.c
index da923a4..97636e2 100755
--- a/atari/history.c
+++ b/atari/history.c
@@ -127,7 +127,6 @@ bool atari_global_history_init( void )
return( false );
}
- history_global_initialise(gl_history.tv->tree, "dir.png");
gl_history.init = true;
}
return( true );
@@ -141,7 +140,6 @@ void atari_global_history_destroy( void )
return;
}
if( gl_history.window != NULL ) {
- history_global_cleanup();
if( gl_history.open )
atari_global_history_close();
wind_delete(gemtk_wm_get_handle(gl_history.window));
diff --git a/atari/hotlist.c b/atari/hotlist.c
index 75732a6..9211f3c 100755
--- a/atari/hotlist.c
+++ b/atari/hotlist.c
@@ -139,12 +139,6 @@ void atari_hotlist_init(void)
return;
}
- hotlist_old_initialise(
- hl.tv->tree,
- (char*)&hl.path,
- "dir.png"
- );
-
} else {
}
@@ -189,7 +183,6 @@ void atari_hotlist_destroy(void)
return;
}
if( hl.window != NULL ) {
- hotlist_old_cleanup( (char*)&hl.path );
if (hl.open)
atari_hotlist_close();
wind_delete(gemtk_wm_get_handle(hl.window));
diff --git a/cocoa/BookmarksController.m b/cocoa/BookmarksController.m
index 5112b66..035d950 100644
--- a/cocoa/BookmarksController.m
+++ b/cocoa/BookmarksController.m
@@ -49,7 +49,6 @@ static const char *cocoa_hotlist_path( void )
if ((self = [super initWithWindowNibName: @"BookmarksWindow"]) == nil) return nil;
tree_hotlist_path = cocoa_hotlist_path();
tree = [[Tree alloc] initWithFlags: TREE_HOTLIST];
- hotlist_old_initialise( [tree tree], cocoa_hotlist_path(), "directory.png" );
nodeForMenu = NSCreateMapTable( NSNonOwnedPointerMapKeyCallBacks, NSNonOwnedPointerMapValueCallBacks, 0 );
[[NSNotificationCenter defaultCenter] addObserver:self
@@ -74,7 +73,6 @@ static const char *cocoa_hotlist_path( void )
{
[self setView: nil];
NSFreeMapTable( nodeForMenu );
- hotlist_old_cleanup( cocoa_hotlist_path() );
[tree release];
[[NSNotificationCenter defaultCenter] removeObserver: self];
diff --git a/cocoa/HistoryWindowController.m b/cocoa/HistoryWindowController.m
index 436f786..d62f458 100644
--- a/cocoa/HistoryWindowController.m
+++ b/cocoa/HistoryWindowController.m
@@ -31,14 +31,12 @@
if ((self = [super initWithWindowNibName: @"HistoryWindow"]) == nil) return nil;
tree = [[Tree alloc] initWithFlags: TREE_HISTORY];
- history_global_initialise( [tree tree], "directory.png" );
return self;
}
- (void) dealloc;
{
- history_global_cleanup();
[tree release];
[self setView: nil];
diff --git a/desktop/cookies_old.c b/desktop/cookies_old.c
index bd3adec..7981e91 100644
--- a/desktop/cookies_old.c
+++ b/desktop/cookies_old.c
@@ -39,31 +39,6 @@
#include "utils/url.h"
#include "utils/utils.h"
-/**
- * Initialises cookies tree.
- *
- * \param data user data for the callbacks
- * \param start_redraw callback function called before every redraw
- * \param end_redraw callback function called after every redraw
- * \return true on success, false on memory exhaustion
- */
-bool cookies_initialise(struct tree *tree, const char* folder_icon_name, const char* cookie_icon_name)
-{
-
- if (tree == NULL)
- return false;
-
- return true;
-}
-
-
-/**
- * Free memory and release all other resources.
- */
-void cookies_cleanup(void)
-{
-}
-
/* Actions to be connected to front end specific toolbars */
/**
diff --git a/desktop/cookies_old.h b/desktop/cookies_old.h
index 78998bc..dba5f17 100644
--- a/desktop/cookies_old.h
+++ b/desktop/cookies_old.h
@@ -27,10 +27,6 @@
#include "desktop/tree.h"
-bool cookies_initialise(struct tree *tree, const char* folder_icon_name, const char* cookie_icon_name);
-
-void cookies_cleanup(void);
-
void cookies_delete_selected(void);
void cookies_delete_all(void);
void cookies_select_all(void);
diff --git a/desktop/history_global_core.c b/desktop/history_global_core.c
index cb889dc..1f788ad 100644
--- a/desktop/history_global_core.c
+++ b/desktop/history_global_core.c
@@ -33,32 +33,6 @@
#include "utils/log.h"
-
-/**
- * Initialises the global history tree.
- *
- * \param data user data for the callbacks
- * \param start_redraw callback function called before every redraw
- * \param end_redraw callback function called after every redraw
- * \return true on success, false on memory exhaustion
- */
-bool history_global_initialise(struct tree *tree, const char* folder_icon_name)
-{
- if (tree == NULL)
- return false;
-
- return true;
-}
-
-
-/**
- * Deletes the global history tree.
- */
-void history_global_cleanup(void)
-{
-}
-
-
/* Actions to be connected to front end specific toolbars */
/**
diff --git a/desktop/history_global_core.h b/desktop/history_global_core.h
index 0e61682..29b3f09 100644
--- a/desktop/history_global_core.h
+++ b/desktop/history_global_core.h
@@ -24,9 +24,6 @@
#include "desktop/tree.h"
-bool history_global_initialise(struct tree *tree, const char* folder_icon_name);
-void history_global_cleanup(void);
-
bool history_global_export(const char *path);
void history_global_delete_selected(void);
void history_global_delete_all(void);
diff --git a/desktop/hotlist_old.c b/desktop/hotlist_old.c
index b09ace3..a2c094a 100644
--- a/desktop/hotlist_old.c
+++ b/desktop/hotlist_old.c
@@ -35,27 +35,6 @@
#include "utils/utils.h"
#include "utils/log.h"
-
-
-/* exported interface documented in hotlist.h */
-bool hotlist_old_initialise(struct tree *tree, const char *hotlist_path,
- const char* folder_icon_name)
-{
- if (tree == NULL)
- return false;
-
- return true;
-}
-
-
-/**
- * Deletes the global history tree and saves the hotlist.
- * \param hotlist_path the path where the hotlist should be saved
- */
-void hotlist_old_cleanup(const char *hotlist_path)
-{
-}
-
/**
* Save the hotlist in a human-readable form under the given location.
*
diff --git a/desktop/hotlist_old.h b/desktop/hotlist_old.h
index b063677..9e88d84 100644
--- a/desktop/hotlist_old.h
+++ b/desktop/hotlist_old.h
@@ -30,18 +30,6 @@
#include "desktop/tree.h"
-/**
- * Initialise the hotlist from a frontend.
- *
- * \param tree The tree object which holds the hotlist.
- * \param hotlist_path The file path to initialise the hotlist entries from.
- * \param folder_icon_name The name to use for folder icons.
- */
-bool hotlist_old_initialise(struct tree *tree, const char *hotlist_path, const char* folder_icon_name);
-
-void hotlist_old_cleanup(const char *hotlist_path);
-
-
bool hotlist_old_export(const char *path);
void hotlist_old_edit_selected(void);
void hotlist_old_delete_selected(void);
diff --git a/gtk/cookies.c b/gtk/cookies.c
index 7a199e7..4c56563 100644
--- a/gtk/cookies.c
+++ b/gtk/cookies.c
@@ -123,9 +123,6 @@ bool nsgtk_cookies_init(const char *glade_file_location)
CONNECT(window, "delete_event", gtk_widget_hide_on_delete, NULL);
CONNECT(window, "hide", nsgtk_tree_window_hide, cookies_window);
-
- cookies_initialise(nsgtk_treeview_get_tree(cookies_window),
- NULL, NULL);
nsgtk_cookies_init_menu();
@@ -156,7 +153,6 @@ void nsgtk_cookies_init_menu()
void nsgtk_cookies_destroy(void)
{
/* TODO: what about gladeFile? */
- cookies_cleanup();
nsgtk_treeview_destroy(cookies_window);
}
diff --git a/gtk/history.c b/gtk/history.c
index 7410a15..bfdb90b 100644
--- a/gtk/history.c
+++ b/gtk/history.c
@@ -126,9 +126,6 @@ bool nsgtk_history_init(const char *glade_file_location)
CONNECT(window, "delete_event", gtk_widget_hide_on_delete, NULL);
CONNECT(window, "hide", nsgtk_tree_window_hide, global_history_window);
- history_global_initialise(
- nsgtk_treeview_get_tree(global_history_window), NULL);
-
nsgtk_history_init_menu();
return true;
@@ -162,7 +159,6 @@ void nsgtk_history_init_menu(void)
void nsgtk_history_destroy(void)
{
/* TODO: what about gladeFile? */
- history_global_cleanup();
nsgtk_treeview_destroy(global_history_window);
}
diff --git a/gtk/hotlist.c b/gtk/hotlist.c
index 3a0bae9..618d9d4 100644
--- a/gtk/hotlist.c
+++ b/gtk/hotlist.c
@@ -133,9 +133,6 @@ bool nsgtk_hotlist_init(const char *glade_file_location)
CONNECT(window, "delete_event", gtk_widget_hide_on_delete, NULL);
CONNECT(window, "hide", nsgtk_tree_window_hide, hotlist_window);
-
- hotlist_old_initialise(nsgtk_treeview_get_tree(hotlist_window),
- nsoption_charp(hotlist_path), NULL);
nsgtk_hotlist_init_menu();
@@ -168,7 +165,6 @@ void nsgtk_hotlist_init_menu(void)
void nsgtk_hotlist_destroy(void)
{
/* TODO: what about gladeFile? */
- hotlist_old_cleanup(nsoption_charp(hotlist_path));
nsgtk_treeview_destroy(hotlist_window);
}
diff --git a/riscos/cookies.c b/riscos/cookies.c
index 1eb084f..eb74f51 100644
--- a/riscos/cookies.c
+++ b/riscos/cookies.c
@@ -117,12 +117,6 @@ void ro_gui_cookies_postinitialise(void)
ro_toolbar_update_client_data(cookies_window.toolbar,
cookies_window.tv);
- /* Initialise the cookies into the tree. */
-
- cookies_initialise(ro_treeview_get_tree(cookies_window.tv),
- NULL, NULL);
-
-
/* Build the cookies window menu. */
static const struct ns_menu cookies_definition = {
diff --git a/riscos/global_history.c b/riscos/global_history.c
index a3ab089..3a060c0 100644
--- a/riscos/global_history.c
+++ b/riscos/global_history.c
@@ -122,11 +122,6 @@ void ro_gui_global_history_postinitialise(void)
ro_toolbar_update_client_data(global_history_window.toolbar,
global_history_window.tv);
- /* Initialise the global history into the tree. */
-
- history_global_initialise(
- ro_treeview_get_tree(global_history_window.tv), NULL);
-
/* Build the global history window menu. */
static const struct ns_menu global_history_definition = {
diff --git a/riscos/gui.c b/riscos/gui.c
index c402b88..39a34de 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -932,9 +932,6 @@ void gui_quit(void)
urldb_save_cookies(nsoption_charp(cookie_jar));
urldb_save(nsoption_charp(url_save));
ro_gui_window_quit();
- history_global_cleanup();
- cookies_cleanup();
- hotlist_old_cleanup(nsoption_charp(hotlist_save));
ro_gui_saveas_quit();
rufl_quit();
free(gui_sprites);
diff --git a/riscos/hotlist.c b/riscos/hotlist.c
index 28bac83..721e532 100644
--- a/riscos/hotlist.c
+++ b/riscos/hotlist.c
@@ -141,12 +141,6 @@ void ro_gui_hotlist_postinitialise(void)
ro_toolbar_update_client_data(hotlist_window.toolbar,
hotlist_window.tv);
- /* Initialise the hotlist into the tree. */
-
- hotlist_old_initialise(ro_treeview_get_tree(hotlist_window.tv),
- nsoption_charp(hotlist_path), NULL);
-
-
/* Build the hotlist window menu. */
static const struct ns_menu hotlist_definition = {
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=4473f4b8a8b929c4c5e...
commit 4473f4b8a8b929c4c5e9dac3013da75f7c66865f
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Remove tree icon_name globals from all the front ends.
diff --git a/amiga/cookies.c b/amiga/cookies.c
index a095a6e..c1f8868 100755
--- a/amiga/cookies.c
+++ b/amiga/cookies.c
@@ -28,8 +28,7 @@ void ami_cookies_initialise(void)
if(!cookies_window) return;
cookies_initialise(ami_tree_get_tree(cookies_window),
- tree_directory_icon_name,
- tree_content_icon_name);
+ NULL, NULL);
}
void ami_cookies_free()
diff --git a/amiga/gui.c b/amiga/gui.c
index 9f87043..6a9e6d2 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -162,8 +162,6 @@ struct Hook newprefs_hook;
static char *current_user;
static char *current_user_dir;
-const char tree_directory_icon_name[] = "def_drawer.info";
-const char tree_content_icon_name[] = "def_project.info";
static const __attribute__((used)) char *stack_cookie = "\0$STACK:131072\0";
const char * const versvn;
diff --git a/amiga/history.c b/amiga/history.c
index 23a6a70..6206efd 100755
--- a/amiga/history.c
+++ b/amiga/history.c
@@ -29,7 +29,7 @@ void ami_global_history_initialise(void)
if(!global_history_window) return;
history_global_initialise(ami_tree_get_tree(global_history_window),
- tree_directory_icon_name);
+ NULL);
}
void ami_global_history_free()
diff --git a/amiga/hotlist.c b/amiga/hotlist.c
index daea820..fa93b46 100755
--- a/amiga/hotlist.c
+++ b/amiga/hotlist.c
@@ -62,8 +62,7 @@ void ami_hotlist_initialise(const char *hotlist_file)
if(!hotlist_window) return;
hotlist_old_initialise(ami_tree_get_tree(hotlist_window),
- hotlist_file,
- tree_directory_icon_name);
+ hotlist_file, NULL);
ami_hotlist_add_default_dirs(ami_tree_get_tree(hotlist_window));
}
diff --git a/amiga/tree.h b/amiga/tree.h
index 179b61a..d8d50fe 100755
--- a/amiga/tree.h
+++ b/amiga/tree.h
@@ -25,10 +25,6 @@
#include "amiga/gui.h"
#include "desktop/tree.h"
-/* defined in front end code */
-extern const char tree_directory_icon_name[];
-extern const char tree_content_icon_name[];
-
struct treeview_window;
enum
diff --git a/atari/history.c b/atari/history.c
index b17f2c2..da923a4 100755
--- a/atari/history.c
+++ b/atari/history.c
@@ -41,7 +41,6 @@
//TODO: remove/add guiwin handle on close / open - so that the list
// is kept tiny.
-extern char * tree_directory_icon_name;
extern GRECT desk_area;
struct s_atari_global_history gl_history;
diff --git a/beos/Makefile.target b/beos/Makefile.target
index 8df9ec3..499ec16 100644
--- a/beos/Makefile.target
+++ b/beos/Makefile.target
@@ -89,7 +89,7 @@ endif
# S_BEOS are sources purely for the BeOS build
S_BEOS := about.cpp bitmap.cpp download.cpp fetch_rsrc.cpp filetype.cpp \
font.cpp gui.cpp login.cpp gui_options.cpp plotters.cpp \
- scaffolding.cpp search.cpp schedule.cpp thumbnail.cpp treeview.cpp \
+ scaffolding.cpp search.cpp schedule.cpp thumbnail.cpp \
throbber.cpp window.cpp
S_BEOS := $(addprefix beos/,$(S_BEOS))
diff --git a/beos/treeview.cpp b/beos/treeview.cpp
deleted file mode 100644
index f3d3d35..0000000
--- a/beos/treeview.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2008 François Revol <mmu_man(a)users.sourceforge.net>
- * Copyright 2004 Richard Wilson <not_ginger_matt(a)users.sourceforge.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/** \file
- * Generic tree handling (implementation).
- */
-
-
-#define __STDBOOL_H__ 1
-extern "C" {
-#include "utils/config.h"
-#include "desktop/tree.h"
-}
-
-const char tree_directory_icon_name[] = "directory.png";
-const char tree_content_icon_name[] = "content.png";
-
-
-
diff --git a/framebuffer/Makefile.target b/framebuffer/Makefile.target
index bad31ed..d423e29 100644
--- a/framebuffer/Makefile.target
+++ b/framebuffer/Makefile.target
@@ -136,7 +136,7 @@ $(eval $(foreach V,$(filter FB_IMAGE_%,$(.VARIABLES)),$(call convert_image,$($(V
# ----------------------------------------------------------------------------
# S_FRAMEBUFFER are sources purely for the framebuffer build
-S_FRAMEBUFFER := gui.c framebuffer.c tree.c schedule.c \
+S_FRAMEBUFFER := gui.c framebuffer.c schedule.c \
thumbnail.c misc.c bitmap.c filetype.c login.c findfile.c \
localhistory.c clipboard.c
diff --git a/framebuffer/tree.c b/framebuffer/tree.c
deleted file mode 100644
index 942a4aa..0000000
--- a/framebuffer/tree.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2008 Vincent Sanders <vince(a)simtec.co.uk>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "desktop/tree.h"
-
-const char tree_directory_icon_name[] = "directory.png";
-const char tree_content_icon_name[] = "content.png";
-
diff --git a/gtk/cookies.c b/gtk/cookies.c
index f8b2b7d..7a199e7 100644
--- a/gtk/cookies.c
+++ b/gtk/cookies.c
@@ -125,8 +125,7 @@ bool nsgtk_cookies_init(const char *glade_file_location)
CONNECT(window, "hide", nsgtk_tree_window_hide, cookies_window);
cookies_initialise(nsgtk_treeview_get_tree(cookies_window),
- tree_directory_icon_name,
- tree_content_icon_name);
+ NULL, NULL);
nsgtk_cookies_init_menu();
diff --git a/gtk/history.c b/gtk/history.c
index ae02823..7410a15 100644
--- a/gtk/history.c
+++ b/gtk/history.c
@@ -127,8 +127,7 @@ bool nsgtk_history_init(const char *glade_file_location)
CONNECT(window, "hide", nsgtk_tree_window_hide, global_history_window);
history_global_initialise(
- nsgtk_treeview_get_tree(global_history_window),
- tree_directory_icon_name);
+ nsgtk_treeview_get_tree(global_history_window), NULL);
nsgtk_history_init_menu();
diff --git a/gtk/hotlist.c b/gtk/hotlist.c
index 2975998..3a0bae9 100644
--- a/gtk/hotlist.c
+++ b/gtk/hotlist.c
@@ -135,8 +135,7 @@ bool nsgtk_hotlist_init(const char *glade_file_location)
CONNECT(window, "hide", nsgtk_tree_window_hide, hotlist_window);
hotlist_old_initialise(nsgtk_treeview_get_tree(hotlist_window),
- nsoption_charp(hotlist_path),
- tree_directory_icon_name);
+ nsoption_charp(hotlist_path), NULL);
nsgtk_hotlist_init_menu();
diff --git a/gtk/treeview.c b/gtk/treeview.c
index 8fc53c3..2a4732a 100644
--- a/gtk/treeview.c
+++ b/gtk/treeview.c
@@ -49,9 +49,6 @@ struct nsgtk_treeview {
struct tree *tree;
};
-const char tree_directory_icon_name[] = "directory.png";
-const char tree_content_icon_name[] = "content.png";
-
void nsgtk_treeview_destroy(struct nsgtk_treeview *tv)
{
tree_delete(tv->tree);
diff --git a/gtk/treeview.h b/gtk/treeview.h
index 4c94da4..12eb180 100644
--- a/gtk/treeview.h
+++ b/gtk/treeview.h
@@ -26,10 +26,6 @@
#include "desktop/browser.h"
-/* defined in front end code */
-extern const char tree_directory_icon_name[];
-extern const char tree_content_icon_name[];
-
struct nsgtk_treeview;
struct nsgtk_treeview *nsgtk_treeview_create(unsigned int flags,
diff --git a/riscos/cookies.c b/riscos/cookies.c
index ea961e2..1eb084f 100644
--- a/riscos/cookies.c
+++ b/riscos/cookies.c
@@ -120,8 +120,7 @@ void ro_gui_cookies_postinitialise(void)
/* Initialise the cookies into the tree. */
cookies_initialise(ro_treeview_get_tree(cookies_window.tv),
- tree_directory_icon_name,
- tree_content_icon_name);
+ NULL, NULL);
/* Build the cookies window menu. */
diff --git a/riscos/global_history.c b/riscos/global_history.c
index 704f804..a3ab089 100644
--- a/riscos/global_history.c
+++ b/riscos/global_history.c
@@ -125,8 +125,7 @@ void ro_gui_global_history_postinitialise(void)
/* Initialise the global history into the tree. */
history_global_initialise(
- ro_treeview_get_tree(global_history_window.tv),
- tree_directory_icon_name);
+ ro_treeview_get_tree(global_history_window.tv), NULL);
/* Build the global history window menu. */
diff --git a/riscos/hotlist.c b/riscos/hotlist.c
index a0a1cf6..28bac83 100644
--- a/riscos/hotlist.c
+++ b/riscos/hotlist.c
@@ -144,8 +144,7 @@ void ro_gui_hotlist_postinitialise(void)
/* Initialise the hotlist into the tree. */
hotlist_old_initialise(ro_treeview_get_tree(hotlist_window.tv),
- nsoption_charp(hotlist_path),
- tree_directory_icon_name);
+ nsoption_charp(hotlist_path), NULL);
/* Build the hotlist window menu. */
diff --git a/riscos/treeview.c b/riscos/treeview.c
index 004091a..479a857 100644
--- a/riscos/treeview.c
+++ b/riscos/treeview.c
@@ -60,10 +60,6 @@
#define wimp_KEY_END wimp_KEY_COPY
#endif
-/** \todo Ugh! */
-const char tree_directory_icon_name[] = "directory.png";
-const char tree_content_icon_name[] = "content.png";
-
struct ro_treeview
{
struct tree *tree; /*< Pointer to treeview tree block. */
diff --git a/riscos/treeview.h b/riscos/treeview.h
index 0745e00..77505ac 100644
--- a/riscos/treeview.h
+++ b/riscos/treeview.h
@@ -31,10 +31,6 @@
#include "desktop/tree.h"
#include "riscos/toolbar.h"
-/* defined in front end code */
-extern const char tree_directory_icon_name[];
-extern const char tree_content_icon_name[];
-
typedef struct ro_treeview ro_treeview;
struct ro_treeview_callbacks {
diff --git a/windows/Makefile.target b/windows/Makefile.target
index f490795..1cdb4a6 100644
--- a/windows/Makefile.target
+++ b/windows/Makefile.target
@@ -66,8 +66,7 @@ S_RESOURCES := windows_resource.o
# S_WINDOWS are sources purely for the windows build
S_WINDOWS := main.c window.c gui.c drawable.c misc.c plot.c findfile.c \
font.c bitmap.c about.c prefs.c download.c filetype.c \
- localhistory.c login.c schedule.c thumbnail.c tree.c \
- windbg.c
+ localhistory.c login.c schedule.c thumbnail.c windbg.c
S_WINDOWS := $(addprefix windows/,$(S_WINDOWS))
# This is the final source build list
diff --git a/windows/tree.c b/windows/tree.c
deleted file mode 100644
index 942a4aa..0000000
--- a/windows/tree.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2008 Vincent Sanders <vince(a)simtec.co.uk>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "desktop/tree.h"
-
-const char tree_directory_icon_name[] = "directory.png";
-const char tree_content_icon_name[] = "content.png";
-
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=49c7994d0580a655ddc...
commit 49c7994d0580a655ddcc78e07205eea45d74132c
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Remove bulk of old treeview implementation.
diff --git a/amiga/gui.c b/amiga/gui.c
index d18e410..9f87043 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -579,8 +579,6 @@ static nserror ami_set_options(struct nsoption_s *defaults)
}
}
- tree_set_icon_dir(strdup("ENV:Sys"));
-
#ifndef __amigaos4__
nsoption_set_bool(download_notify, false);
nsoption_set_bool(context_menu, false);
diff --git a/amiga/tree.c b/amiga/tree.c
index 0515f70..27e4cdb 100644
--- a/amiga/tree.c
+++ b/amiga/tree.c
@@ -665,7 +665,6 @@ void ami_tree_open(struct treeview_window *twin,int type)
ami_tree_update_buttons(twin);
ami_tree_resized(twin->tree, twin->max_width, twin->max_height, twin);
- tree_set_redraw(twin->tree, true);
ami_tree_draw(twin);
}
@@ -673,7 +672,6 @@ void ami_tree_close(struct treeview_window *twin)
{
int i;
- tree_set_redraw(twin->tree, false);
twin->win = NULL;
DisposeObject(twin->objects[OID_MAIN]);
DelObjectNoFree(twin->node);
diff --git a/atari/gui.c b/atari/gui.c
index 5c384b7..8db4765 100644
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -1004,8 +1004,6 @@ static void gui_init(int argc, char** argv)
LOG(("Initializing plotters..."));
plot_init(nsoption_charp(atari_font_driver));
- tree_set_icon_dir(nsoption_charp(tree_icons_path));
-
aes_event_in.emi_m1leave = MO_LEAVE;
aes_event_in.emi_m1.g_w = 1;
aes_event_in.emi_m1.g_h = 1;
diff --git a/atari/treeview.c b/atari/treeview.c
index 97fe8a9..f25bf7e 100755
--- a/atari/treeview.c
+++ b/atari/treeview.c
@@ -223,11 +223,7 @@ static void __CDECL on_mbutton_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
cur_rel_x = origin_rel_x;
cur_rel_y = origin_rel_y;
- if( tree_is_edited(tv->tree) ){
- gem_set_cursor(&gem_cursors.ibeam);
- } else {
- gem_set_cursor(&gem_cursors.hand);
- }
+ gem_set_cursor(&gem_cursors.hand);
tv->startdrag.x = origin_rel_x;
tv->startdrag.y = origin_rel_y;
@@ -292,7 +288,6 @@ void atari_treeview_open( NSTREEVIEW tv )
{
if( tv->window != NULL ) {
gemtk_wm_link(tv->window);
- tree_set_redraw(tv->tree, true);
}
}
@@ -300,7 +295,6 @@ void atari_treeview_open( NSTREEVIEW tv )
void atari_treeview_close(NSTREEVIEW tv)
{
if(tv->window != NULL) {
- tree_set_redraw(tv->tree, false);
gemtk_wm_unlink(tv->window);
}
}
diff --git a/cocoa/BookmarksController.m b/cocoa/BookmarksController.m
index 28f53b8..5112b66 100644
--- a/cocoa/BookmarksController.m
+++ b/cocoa/BookmarksController.m
@@ -97,7 +97,6 @@ static const char *cocoa_hotlist_path( void )
[menu addItem: [[item copy] autorelease]];
}
hasSeparator = false;
- node = [tree rootNode];
}
for (struct node *child = tree_node_get_child( node );
diff --git a/cocoa/Tree.h b/cocoa/Tree.h
index b03f48b..e38df5a 100644
--- a/cocoa/Tree.h
+++ b/cocoa/Tree.h
@@ -42,7 +42,6 @@
- initWithFlags: (unsigned int) flags;
-- (struct node *) rootNode;
- (struct tree *) tree;
@end
diff --git a/cocoa/Tree.m b/cocoa/Tree.m
index 582187f..7da7b68 100644
--- a/cocoa/Tree.m
+++ b/cocoa/Tree.m
@@ -59,11 +59,6 @@ static const struct treeview_table cocoa_tree_callbacks = {
[super dealloc];
}
-- (struct node *) rootNode;
-{
- return tree_get_root( tree );
-}
-
- (struct tree *) tree;
{
return tree;
@@ -76,15 +71,11 @@ static const struct treeview_table cocoa_tree_callbacks = {
- (void) setRedrawing: (BOOL) newRedrawing;
{
- tree_set_redraw( tree, newRedrawing );
}
+ (void) initialize;
{
- if (self == [Tree class]) {
- tree_set_icon_dir( strdup( [[[NSBundle mainBundle] pathForResource: @"Icons" ofType: @""] UTF8String] ) );
- }
}
//MARK: -
diff --git a/desktop/tree.c b/desktop/tree.c
index 607d12b..9e86668 100644
--- a/desktop/tree.c
+++ b/desktop/tree.c
@@ -30,152 +30,21 @@
#include "content/hlcache.h"
#include "css/utils.h"
#include "desktop/browser.h"
-#include "desktop/knockout.h"
-#include "desktop/textarea.h"
-#include "desktop/textinput.h"
#include "desktop/tree.h"
#include "utils/nsoption.h"
-#include "desktop/plotters.h"
#include "render/font.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/url.h"
-#undef TREE_NOISY_DEBUG
-
-#define MAXIMUM_URL_LENGTH 1024
-
-#define TREE_TEXT_SIZE_PT 11
-#define TREE_ICON_SIZE 17
-#define NODE_INSTEP 20
-
-static int tree_text_size_px;
-static int TREE_LINE_HEIGHT;
-
-static char *tree_icons_dir = NULL;
-
-static plot_font_style_t plot_fstyle = {
- .family = PLOT_FONT_FAMILY_SANS_SERIF,
- .size = TREE_TEXT_SIZE_PT * FONT_SIZE_SCALE,
- .weight = 400,
- .flags = FONTF_NONE
-};
-
-static plot_font_style_t plot_fstyle_def_folder = {
- .family = PLOT_FONT_FAMILY_SANS_SERIF,
- .size = TREE_TEXT_SIZE_PT * FONT_SIZE_SCALE,
- .weight = 700,
- .flags = FONTF_NONE
-};
-
-static plot_font_style_t plot_fstyle_selected = {
- .family = PLOT_FONT_FAMILY_SANS_SERIF,
- .size = TREE_TEXT_SIZE_PT * FONT_SIZE_SCALE,
- .weight = 400,
- .flags = FONTF_NONE
-};
-
-static plot_font_style_t plot_fstyle_selected_def_folder = {
- .family = PLOT_FONT_FAMILY_SANS_SERIF,
- .size = TREE_TEXT_SIZE_PT * FONT_SIZE_SCALE,
- .weight = 700,
- .flags = FONTF_NONE
-};
-
-/** plot style for treeview backgrounds. */
-static plot_style_t plot_style_fill_tree_background = {
- .fill_type = PLOT_OP_TYPE_SOLID
-};
-
-/** plot style for treeview backgrounds. */
-static plot_style_t plot_style_fill_tree_selected = {
- .fill_type = PLOT_OP_TYPE_SOLID
-};
-
-/** plot style for treeview furniture lines. */
-static plot_style_t plot_style_stroke_tree_furniture = {
- .stroke_type = PLOT_OP_TYPE_SOLID
-};
-
-/** plot style for treeview furniture fills. */
-static plot_style_t plot_style_fill_tree_furniture = {
- .fill_type = PLOT_OP_TYPE_SOLID
-};
-
-struct node;
-struct tree;
-
-struct node_element_box {
- int x; /**< X offset from origin */
- int y; /**< Y offset from origin */
- int width; /**< Element width */
- int height; /**< Element height */
-};
-
-struct node_element {
- struct node *parent; /**< Parent node */
- node_element_type type; /**< Element type */
- struct node_element_box box; /**< Element bounding box */
- char *text; /**< Text for the element */
- void *bitmap; /**< Bitmap for the element */
- struct node_element *next; /**< Next node element */
- unsigned int flag; /**< Client specified flag for data
- being represented */
- bool editable; /**< Whether the node text can be
- * modified, editable text is deleted
- * without noticing the tree user
- */
-};
-
-struct node {
- bool selected; /**< Whether the node is selected */
- bool expanded; /**< Whether the node is expanded */
- bool folder; /**< Whether the node is a folder */
- bool def_folder; /**< Whether the node is the default folder */
- bool retain_in_memory; /**< Whether the node remains
- in memory after deletion */
- bool deleted; /**< Whether the node is currently
- deleted */
- bool processing; /**< Internal flag used when moving */
- struct node_element_box box; /**< Bounding box of all elements */
- struct node_element data; /**< Data to display */
- struct node *parent; /**< Parent entry (NULL for root) */
- struct node *child; /**< First child */
- struct node *last_child; /**< Last child */
- struct node *previous; /**< Previous child of the parent */
- struct node *next; /**< Next child of the parent */
-
- /** Sorting function for the node (for folder nodes only) */
- int (*sort) (struct node *, struct node *);
- /** Gets called for each deleted node_element and on node launch */
- tree_node_user_callback user_callback;
- /** User data to be passed to delete_callback */
- void *callback_data;
-};
-
struct tree {
- struct node *root; /* Tree root element */
- int width; /* Tree width */
- int height; /* Tree height */
- unsigned int flags; /* Tree flags */
- struct textarea *textarea; /* Handle for UTF-8 textarea */
- int ta_height; /* Textarea height */
- struct node_element *editing; /* Node element being edited */
-
- bool redraw; /* Flag indicating whether the tree
- should be redrawn on layout
- changes */
+ unsigned int flags; /* Tree flags */
tree_drag_type drag;
const struct treeview_table *callbacks;
- void *client_data; /* User assigned data for the
- callbacks */
- struct node *def_folder; /* Node to be used for additions by default */
+ void *client_data; /* User assigned data for the callbacks */
};
-
-
-
#include "desktop/treeview.h"
#include "desktop/hotlist.h"
#include "desktop/cookie_manager.h"
@@ -184,7 +53,6 @@ struct tree {
struct sslcert_session_data *ssl_current_session = NULL;
const char *tree_hotlist_path = NULL;
-
int treeview_inits;
static void treeview_test_redraw_request(struct core_window *cw,
@@ -257,7 +125,7 @@ static bool treeview_test_init(struct tree *tree)
{
nserror err;
- if (tree->flags & TREE_SSLCERT) {
+ if (tree->flags == TREE_SSLCERT) {
treeview_inits++;
@@ -277,19 +145,19 @@ static bool treeview_test_init(struct tree *tree)
if (treeview_inits == 1)
treeview_init();
- if (tree->flags & TREE_COOKIES) {
+ if (tree->flags == TREE_COOKIES) {
err = cookie_manager_init(&cw_t, (struct core_window *)tree);
if (err != NSERROR_OK) {
warn_user("Couldn't init new cookie manager.", 0);
}
}
- if (tree->flags & TREE_HISTORY) {
+ if (tree->flags == TREE_HISTORY) {
err = global_history_init(&cw_t, (struct core_window *)tree);
if (err != NSERROR_OK) {
warn_user("Couldn't init new global history.", 0);
}
}
- if (tree->flags & TREE_HOTLIST) {
+ if (tree->flags == TREE_HOTLIST) {
err = hotlist_init(&cw_t, (struct core_window *)tree,
tree_hotlist_path);
if (err != NSERROR_OK) {
@@ -304,7 +172,7 @@ static bool treeview_test_fini(struct tree *tree)
{
nserror err;
- if (tree->flags & TREE_SSLCERT) {
+ if (tree->flags == TREE_SSLCERT) {
err = sslcert_viewer_fini(ssl_current_session);
if (err != NSERROR_OK) {
warn_user("Couldn't finalise sslcert viewer.", 0);
@@ -317,19 +185,19 @@ static bool treeview_test_fini(struct tree *tree)
return true;
}
- if (tree->flags & TREE_COOKIES) {
+ if (tree->flags == TREE_COOKIES) {
err = cookie_manager_fini();
if (err != NSERROR_OK) {
warn_user("Couldn't finalise cookie manager.", 0);
}
}
- if (tree->flags & TREE_HISTORY) {
+ if (tree->flags == TREE_HISTORY) {
err = global_history_fini();
if (err != NSERROR_OK) {
warn_user("Couldn't finalise cookie manager.", 0);
}
}
- if (tree->flags & TREE_HOTLIST) {
+ if (tree->flags == TREE_HOTLIST) {
err = hotlist_fini(tree_hotlist_path);
if (err != NSERROR_OK) {
warn_user("Couldn't finalise hotlist.", 0);
@@ -354,20 +222,20 @@ static bool treeview_test_redraw(struct tree *tree, int x, int y,
clip.x1 = clip_x + clip_width;
clip.y1 = clip_y + clip_height;
- if (tree->flags & TREE_SSLCERT) {
+ if (tree->flags == TREE_SSLCERT) {
sslcert_viewer_redraw(ssl_current_session, x, y, &clip, ctx);
return true;
}
- if (tree->flags & TREE_COOKIES) {
+ if (tree->flags == TREE_COOKIES) {
cookie_manager_redraw(x, y, &clip, ctx);
return true;
}
- if (tree->flags & TREE_HISTORY) {
+ if (tree->flags == TREE_HISTORY) {
global_history_redraw(x, y, &clip, ctx);
return true;
}
- if (tree->flags & TREE_HOTLIST) {
+ if (tree->flags == TREE_HOTLIST) {
hotlist_redraw(x, y, &clip, ctx);
return true;
}
@@ -378,20 +246,20 @@ static bool treeview_test_redraw(struct tree *tree, int x, int y,
static bool treeview_test_mouse_action(struct tree *tree,
browser_mouse_state mouse, int x, int y)
{
- if (tree->flags & TREE_SSLCERT) {
+ if (tree->flags == TREE_SSLCERT) {
sslcert_viewer_mouse_action(ssl_current_session, mouse, x, y);
return true;
}
- if (tree->flags & TREE_COOKIES) {
+ if (tree->flags == TREE_COOKIES) {
cookie_manager_mouse_action(mouse, x, y);
return true;
}
- if (tree->flags & TREE_HISTORY) {
+ if (tree->flags == TREE_HISTORY) {
global_history_mouse_action(mouse, x, y);
return true;
}
- if (tree->flags & TREE_HOTLIST) {
+ if (tree->flags == TREE_HOTLIST) {
hotlist_mouse_action(mouse, x, y);
return true;
}
@@ -401,20 +269,20 @@ static bool treeview_test_mouse_action(struct tree *tree,
static bool treeview_test_keypress(struct tree *tree, uint32_t key)
{
- if (tree->flags & TREE_SSLCERT) {
+ if (tree->flags == TREE_SSLCERT) {
sslcert_viewer_keypress(ssl_current_session, key);
return true;
}
- if (tree->flags & TREE_COOKIES) {
+ if (tree->flags == TREE_COOKIES) {
cookie_manager_keypress(key);
return true;
}
- if (tree->flags & TREE_HISTORY) {
+ if (tree->flags == TREE_HISTORY) {
global_history_keypress(key);
return true;
}
- if (tree->flags & TREE_HOTLIST) {
+ if (tree->flags == TREE_HOTLIST) {
hotlist_keypress(key);
return true;
}
@@ -422,68 +290,10 @@ static bool treeview_test_keypress(struct tree *tree, uint32_t key)
return false;
}
+/* -------------------------------------------------------------------------- */
-
-
-
-
-
-
-
-
-
-
-
-void tree_set_icon_dir(char *icon_dir)
-{
- LOG(("Tree icon directory set to %s", icon_dir));
- tree_icons_dir = icon_dir;
-}
-
-/**
- * Set up colours for plot styles used in tree redraw.
- */
-void tree_setup_colours(void)
-{
- /* Background colour */
- plot_style_fill_tree_background.fill_colour =
- gui_system_colour_char("Window");
-
- /* Selection background colour */
- plot_style_fill_tree_selected.fill_colour =
- gui_system_colour_char("Highlight");
-
- /* Furniture line colour */
- plot_style_stroke_tree_furniture.stroke_colour = blend_colour(
- gui_system_colour_char("Window"),
- gui_system_colour_char("WindowText"));
-
- /* Furniture fill colour */
- plot_style_fill_tree_furniture.fill_colour =
- gui_system_colour_char("Window");
-
- /* Text colour */
- plot_fstyle.foreground = gui_system_colour_char("WindowText");
- plot_fstyle.background = gui_system_colour_char("Window");
- plot_fstyle_def_folder.foreground =
- gui_system_colour_char("InfoText");
- plot_fstyle_def_folder.background =
- gui_system_colour_char("Window");
-
- /* Selected text colour */
- plot_fstyle_selected.foreground =
- gui_system_colour_char("HighlightText");
- plot_fstyle_selected.background =
- gui_system_colour_char("Highlight");
- plot_fstyle_selected_def_folder.foreground =
- gui_system_colour_char("HighlightText");
- plot_fstyle_selected_def_folder.background =
- gui_system_colour_char("Highlight");
-}
-
-
/**
* Creates and initialises a new tree.
*
@@ -504,41 +314,11 @@ struct tree *tree_create(unsigned int flags,
return NULL;
}
- tree->root = tree_create_folder_node(NULL,
- NULL,
- messages_get("Root"),
- false, false, false);
- if (tree->root == NULL) {
- free(tree);
- return NULL;
- }
- tree->root->expanded = true;
-
- tree->width = 0;
- tree->height = 0;
tree->flags = flags;
- tree->textarea = NULL;
- tree->editing = NULL;
- tree->redraw = false;
tree->drag = TREE_NO_DRAG;
tree->callbacks = callbacks;
tree->client_data = client_data;
- /* Set text height in pixels */
- tree_text_size_px =
- (TREE_TEXT_SIZE_PT * FIXTOINT(nscss_screen_dpi) + 36) /
- 72;
- /* Set line height appropriate for this text height in pixels
- * Using 4/3 text height */
- TREE_LINE_HEIGHT = (tree_text_size_px * 8 + 3) / 6;
-
- /* But if that's too small for the icons, base the line height on
- * the icon height. */
- if (TREE_LINE_HEIGHT < TREE_ICON_SIZE + 2)
- TREE_LINE_HEIGHT = TREE_ICON_SIZE + 2;
-
- tree_setup_colours();
-
treeview_test_init(tree);
return tree;
@@ -546,2823 +326,99 @@ struct tree *tree_create(unsigned int flags,
/**
- * Recalculates the dimensions of a node element.
- *
- * \param tree the tree to which the element belongs, may be NULL
- * \param element the element to recalculate
- */
-static void tree_recalculate_node_element(struct tree *tree,
- struct node_element *element)
-{
- struct bitmap *bitmap = NULL;
- int width, height;
- static char *cache_text = NULL;
- static int cache_size = 0;
- plot_font_style_t *fstyle;
- static plot_font_style_t *cache_fstyle = NULL;
-
- assert(element != NULL);
-
- if (element->parent->def_folder)
- fstyle = &plot_fstyle_def_folder;
- else
- fstyle = &plot_fstyle;
-
- switch (element->type) {
- case NODE_ELEMENT_TEXT_PLUS_ICON:
- case NODE_ELEMENT_TEXT:
- if(element->text == NULL)
- break;
-
- if (tree != NULL && element == tree->editing) {
- textarea_get_dimensions(tree->textarea,
- &element->box.width, NULL);
- } else {
- if ((cache_text != NULL) &&
- (strcmp(cache_text, element->text) == 0) &&
- (cache_fstyle == fstyle)) {
- element->box.width = cache_size;
- #ifdef TREE_NOISY_DEBUG
- LOG(("Tree font width cache hit"));
- #endif
- } else {
- if(cache_text != NULL) free(cache_text);
- nsfont.font_width(fstyle,
- element->text,
- strlen(element->text),
- &cache_size);
- element->box.width = cache_size;
- cache_text = strdup(element->text);
- cache_fstyle = fstyle;
- }
- }
-
- element->box.width += 8;
- element->box.height = TREE_LINE_HEIGHT;
-
- if (element->type == NODE_ELEMENT_TEXT_PLUS_ICON)
- element->box.width += NODE_INSTEP;
-
- break;
-
- case NODE_ELEMENT_BITMAP:
- bitmap = element->bitmap;
- if (bitmap != NULL) {
- width = bitmap_get_width(bitmap);
- height = bitmap_get_height(bitmap);
- element->box.width = width + 1;
- element->box.height = height + 2;
- } else {
- element->box.width = 0;
- element->box.height = 0;
- }
- break;
- }
-}
-
-
-/**
- * Calculates the height of a node including any children
- *
- * \param node the node to calculate the height of
- * \return the total height of the node and children
- */
-static int tree_get_node_height(struct node *node)
-{
- int y1;
-
- assert(node != NULL);
-
- if ((node->child == NULL) || (node->expanded == false)) {
- return node->box.height;
- }
-
- y1 = node->box.y;
- if (y1 < 0) {
- y1 = 0;
- }
- node = node->child;
-
- while ((node->next != NULL) ||
- ((node->child != NULL) && (node->expanded))) {
- for (; node->next != NULL; node = node->next);
-
- if ((node->child != NULL) && (node->expanded)) {
- node = node->child;
- }
- }
- return node->box.y + node->box.height - y1;
-}
-
-
-/**
- * Calculates the width of a node including any children
- *
- * \param node the node to calculate the height of
- * \return the total width of the node and children
- */
-static int tree_get_node_width(struct node *node)
-{
- int width = 0;
- int child_width;
-
- assert(node != NULL);
-
- for (; node != NULL; node = node->next) {
- if (width < (node->box.x + node->box.width)) {
- width = node->box.x + node->box.width;
- }
-
- if ((node->child != NULL) && (node->expanded)) {
- child_width = tree_get_node_width(node->child);
- if (width < child_width) {
- width = child_width;
- }
- }
- }
- return width;
-}
-
-
-/**
- * Recalculates the position of a node, its siblings and children.
- *
- * \param tree the tree to which 'root' belongs
- * \param root the root node to update from
- */
-static void tree_recalculate_node_positions(struct tree *tree,
- struct node *root)
-{
- struct node *parent;
- struct node *node;
- struct node *child;
- struct node_element *element;
- int y;
- bool has_icon;
-
- for (node = root; node != NULL; node = node->next) {
-
- parent = node->parent;
-
- if (node->previous != NULL) {
- node->box.x = node->previous->box.x;
- node->box.y = node->previous->box.y +
- tree_get_node_height(node->previous);
- } else if (parent != NULL) {
- node->box.x = parent->box.x + NODE_INSTEP;
- node->box.y = parent->box.y +
- parent->box.height;
- for (child = parent->child; child != node;
- child = child->next)
- node->box.y += child->box.height;
- } else {
- node->box.x = tree->flags & TREE_NO_FURNITURE
- ? -NODE_INSTEP + 4 : 0;
- node->box.y = -TREE_LINE_HEIGHT;
- }
-
- if (!node->expanded) {
- node->data.box.x = node->box.x;
- node->data.box.y = node->box.y;
- continue;
- }
-
- if (node->folder) {
- node->data.box.x = node->box.x;
- node->data.box.y = node->box.y;
- tree_recalculate_node_positions(tree, node->child);
- } else {
- y = node->box.y;
- has_icon = false;
- for (element = &node->data; element != NULL;
- element = element->next)
- if (element->type ==
- NODE_ELEMENT_TEXT_PLUS_ICON) {
- has_icon = true;
- break;
- }
-
- for (element = &node->data; element != NULL;
- element = element->next) {
- element->box.x = node->box.x;
- if (element->type !=
- NODE_ELEMENT_TEXT_PLUS_ICON &&
- has_icon)
- element->box.x += NODE_INSTEP;
- element->box.y = y;
- y += element->box.height;
- }
- }
-
- }
-}
-
-
-/**
- * Recalculates the size of a node.
- *
- * \param tree the tree to which node belongs, may be NULL
- * \param node the node to update
- * \param recalculate_sizes whether the node elements have changed
- */
-static void tree_recalculate_node_sizes(struct tree *tree, struct node *node,
- bool recalculate_sizes)
-{
- struct node_element *element;
- int height;
-
- assert(node != NULL);
-
- height = node->box.height;
- node->box.width = 0;
- node->box.height = 0;
- if (node->expanded) {
- for (element = &node->data; element != NULL;
- element = element->next) {
- if (recalculate_sizes) {
- #ifdef TREE_NOISY_DEBUG
- if(element->text) LOG(("%s", element->text));
- #endif
- tree_recalculate_node_element(tree, element);
- }
- node->box.width = (node->box.width > element->box.x +
- element->box.width - node->box.x) ?
- node->box.width :
- element->box.width + element->box.x -
- node->box.x;
- node->box.height += element->box.height;
- }
- } else {
- if (recalculate_sizes)
- for (element = &node->data; element != NULL;
- element = element->next) {
- #ifdef TREE_NOISY_DEBUG
- if(element->text) LOG(("%s", element->text));
- #endif
- tree_recalculate_node_element(tree, element);
- }
-
- node->box.width = node->data.box.width;
- node->box.height = node->data.box.height;
- }
-
- if (tree != NULL && height != node->box.height)
- tree_recalculate_node_positions(tree, tree->root);
-}
-
-
-/* exported interface documented in desktop/tree.h */
-struct node *tree_create_folder_node(struct tree *tree, struct node *parent,
- const char *title, bool editable, bool retain_in_memory,
- bool deleted)
-{
- struct node *node;
-
- assert(title != NULL);
-
- node = calloc(sizeof(struct node), 1);
- if (node == NULL) {
- return NULL;
- }
-
- node->data.text = strdup(title);
- if (node->data.text == NULL) {
- free(node);
- return NULL;
- }
-
- node->folder = true;
- node->retain_in_memory = retain_in_memory;
- node->deleted = deleted;
- node->data.parent = node;
- node->data.type = NODE_ELEMENT_TEXT;
- node->data.flag = TREE_ELEMENT_TITLE;
- node->data.editable = editable;
- node->sort = NULL;
- node->user_callback = NULL;
- node->previous = NULL;
-
- tree_recalculate_node_sizes(tree, node, true);
- if (parent != NULL) {
- tree_link_node(tree, parent, node, false);
- }
-
- return node;
-}
-
-/* exported interface documented in desktop/tree.h */
-struct node *tree_create_leaf_node(struct tree *tree, struct node *parent,
- const char *title, bool editable, bool retain_in_memory,
- bool deleted)
-{
- struct node *node;
-
- assert(title != NULL);
-
- node = calloc(sizeof(struct node), 1);
- if (node == NULL) {
- return NULL;
- }
-
- node->data.text = strdup(title);
- if (node->data.text == NULL) {
- free(node);
- return NULL;
- }
-
- node->folder = false;
- node->retain_in_memory = retain_in_memory;
- node->deleted = deleted;
- node->data.parent = node;
- node->data.type = NODE_ELEMENT_TEXT;
- node->data.flag = TREE_ELEMENT_TITLE;
- node->data.editable = editable;
- node->sort = NULL;
- node->user_callback = NULL;
- node->previous = NULL;
-
- tree_recalculate_node_sizes(tree, node, true);
- if (parent != NULL) {
- tree_link_node(tree, parent, node, false);
- }
-
- return node;
-}
-
-
-/**
- * Creates an empty text node element and links it to a node.
- *
- * \param parent the parent node
- * \param type the required element type
- * \param flag user assigned flag used for searches
- * \return the newly created element.
- */
-struct node_element *tree_create_node_element(struct node *parent,
- node_element_type type, unsigned int flag, bool editable)
-{
- struct node_element *element;
-
- element = calloc(sizeof(struct node_element), 1);
- if (element == NULL)
- return NULL;
-
- element->parent = parent;
- element->flag = flag;
- element->type = type;
- element->editable = editable;
- element->next = parent->data.next;
- parent->data.next = element;
-
- return element;
-}
-
-
-/**
- * Inserts a node into the correct place according to the parent's sort function
+ * Deletes all nodes of a tree and the tree itself.
*
- * \param parent the node whose child node 'node' becomes
- * \param node the node to be inserted
+ * \param tree the tree to be deleted
*/
-static void tree_sort_insert(struct node *parent, struct node *node)
+void tree_delete(struct tree *tree)
{
- struct node *after;
-
- assert(node != NULL);
- assert(parent != NULL);
- assert(parent->sort != NULL);
-
- after = parent->last_child;
- while ((after != NULL) &&
- (parent->sort(node, after) == -1))
- after = after->previous;
-
- if (after != NULL) {
- if (after->next != NULL)
- after->next->previous = node;
- node->next = after->next;
- node->previous = after;
- after->next = node;
- } else {
- node->previous = NULL;
- node->next = parent->child;
- if (parent->child != NULL) {
- parent->child->previous = node;
- }
- parent->child = node;
- }
-
- if (node->next == NULL)
- parent->last_child = node;
-
- node->parent = parent;
+ treeview_test_fini(tree);
+ free(tree);
}
/**
- * Recalculates the size of a tree.
+ * Redraws a tree.
*
- * \param tree the tree to recalculate
+ * \param tree the tree to draw
+ * \param x X coordinate to draw the tree at (wrt plot origin)
+ * \param y Y coordinate to draw the tree at (wrt plot origin)
+ * \param clip_x minimum x of the clipping rectangle (wrt tree origin)
+ * \param clip_y minimum y of the clipping rectangle (wrt tree origin)
+ * \param clip_width width of the clipping rectangle
+ * \param clip_height height of the clipping rectangle
+ * \param ctx current redraw context
*/
-static void tree_recalculate_size(struct tree *tree)
+void tree_draw(struct tree *tree, int x, int y,
+ int clip_x, int clip_y, int clip_width, int clip_height,
+ const struct redraw_context *ctx)
{
- int width, height;
-
assert(tree != NULL);
- width = tree->width;
- height = tree->height;
-
- tree->width = tree_get_node_width(tree->root);
- tree->height = tree_get_node_height(tree->root);
-
- if ((width != tree->width) || (height != tree->height))
- tree->callbacks->resized(tree, tree->width, tree->height,
- tree->client_data);
+ treeview_test_redraw(tree, x, y, clip_x, clip_y,
+ clip_width, clip_height, ctx);
}
+
/**
- * Recalculate the node data and redraw the relevant section of the tree.
+ * Handles a mouse action for a tree
*
- * \param tree the tree to redraw, may be NULL
- * \param node the node to update
- * \param recalculate_sizes whether the elements have changed
- * \param expansion the request is the result of a node expansion
+ * \param tree the tree to handle a click for
+ * \param mouse the mouse state
+ * \param x X coordinate of mouse action
+ * \param y Y coordinate of mouse action
+ * \return whether the click was handled
*/
-static void tree_handle_node_changed(struct tree *tree, struct node *node,
- bool recalculate_sizes, bool expansion)
+bool tree_mouse_action(struct tree *tree, browser_mouse_state mouse, int x,
+ int y)
{
- int node_width, node_height, tree_width, tree_height;
-
- assert(node != NULL);
assert(tree != NULL);
- node_width = node->box.width;
- node_height = node->box.height;
- tree_width = tree->width;
- tree_height = tree->height;
-
- if ((recalculate_sizes) || (expansion)) {
- tree_recalculate_node_sizes(tree, node, true);
+ if (treeview_test_mouse_action(tree, mouse, x, y)) {
+ return true;
}
- if (tree != NULL) {
- if ((node->box.height != node_height) || (expansion)) {
- tree_recalculate_node_positions(tree, tree->root);
- tree_recalculate_size(tree);
- if (tree->width > tree_width)
- tree_width = tree->width;
- if (tree->height > tree_height)
- tree_height = tree->height;
- if (tree->redraw) {
- tree->callbacks->redraw_request(0, node->box.y,
- tree_width,
- tree_height - node->box.y,
- tree->client_data);
- }
- } else {
- if (node->box.width > node_width)
- node_width = node->box.width;
- if (tree->redraw)
- tree->callbacks->redraw_request(node->box.x,
- node->box.y,
- node_width, node->box.height,
- tree->client_data);
- if (recalculate_sizes) {
- tree_recalculate_size(tree);
- }
- }
- }
+ return false;
}
/**
- * Links a node to another node.
+ * Handle the end of a drag operation
*
- * \param tree the tree in which the link takes place, may be NULL
- * \param link the node to link before/as a child (folders)
- * or before/after (link)
- * \param node the node to link
- * \param before whether to link siblings before or after the supplied node
+ * \param tree the tree on which the drag was performed
+ * \param mouse mouse state during drag end
+ * \param x0 x coordinate of drag start
+ * \param y0 y coordinate of drag start
+ * \param x1 x coordinate of drag end
+ * \param y1 y coordinate of drag end
*/
-void tree_link_node(struct tree *tree, struct node *link, struct node *node,
- bool before)
+void tree_drag_end(struct tree *tree, browser_mouse_state mouse, int x0, int y0,
+ int x1, int y1)
{
+ assert(tree != NULL);
- struct node *parent;
- bool sort = false;
-
- assert(link != NULL);
- assert(node != NULL);
-
- if ((link->folder == 0) || (before)) {
- parent = node->parent = link->parent;
- if (parent->sort) {
- sort = true;
- } else {
- if (before) {
- node->next = link;
- node->previous = link->previous;
- if (link->previous != NULL)
- link->previous->next = node;
- link->previous = node;
- if ((parent != NULL) && (parent->child == link))
- parent->child = node;
- } else {
- node->previous = link;
- node->next = link->next;
- if (link->next != NULL)
- link->next->previous = node;
- link->next = node;
- if ((parent != NULL) &&
- (parent->last_child == link))
- parent->last_child = node;
- }
- }
- } else {
- parent = node->parent = link;
- if (parent->sort != NULL) {
- sort = true;
- } else {
- node->next = NULL;
- if (link->child == NULL) {
- link->child = link->last_child = node;
- node->previous = NULL;
- } else {
- link->last_child->next = node;
- node->previous = link->last_child;
- link->last_child = node;
- }
- }
-
- }
-
- if (sort) {
- tree_sort_insert(parent, node);
- }
-
- tree_handle_node_changed(tree, link, false, true);
-
- node->deleted = false;
+ treeview_test_mouse_action(tree, BROWSER_MOUSE_HOVER, x1, y1);
}
/**
- * Recalculate the node element and redraw the relevant section of the tree.
- * The tree size is not updated.
+ * Key press handling for a tree.
*
- * \param tree the tree to redraw, may be NULL
- * \param element the node element to update
+ * \param tree The tree which got the keypress
+ * \param key The ucs4 character codepoint
+ * \return true if the keypress is dealt with, false otherwise.
*/
-static void tree_handle_node_element_changed(struct tree *tree,
- struct node_element *element, bool text_changed)
+bool tree_keypress(struct tree *tree, uint32_t key)
{
- int width, height;
-
- assert(element != NULL);
-
- width = element->box.width;
- height = element->box.height;
-
- if(text_changed == true) {
- #ifdef TREE_NOISY_DEBUG
- if(element->text) LOG(("%s", element->text));
- #endif
- tree_recalculate_node_element(tree, element);
+ if (treeview_test_keypress(tree, key)) {
+ return true;
}
- if (element->box.height != height) {
- tree_recalculate_node_sizes(tree, element->parent, false);
- if ((tree != NULL) && (tree->redraw)) {
- tree->callbacks->redraw_request(0, element->box.y,
- tree->width + element->box.width -
- width,
- tree->height - element->box.y +
- element->box.height - height,
- tree->client_data);
- }
- } else {
- if (element->box.width != width) {
- tree_recalculate_node_sizes(tree, element->parent,
- false);
- }
-
- if (tree != NULL) {
- width = (width > element->box.width) ? width :
- element->box.width;
- if (tree->redraw) {
- tree->callbacks->redraw_request(element->box.x,
- element->box.y,
- width,
- element->box.height,
- tree->client_data);
- }
- }
- }
+ return false;
}
-
-/**
- * Stops editing a node_element
- *
- * \param tree The tree to stop editing for
- * \param keep_changes If true the changes made to the text will be kept,
- * if false they will be dropped
- */
-static void tree_stop_edit(struct tree *tree, bool keep_changes)
+tree_drag_type tree_drag_status(struct tree *tree)
{
- int text_len;
- char *text = NULL;
- struct node_element *element;
- struct node_msg_data msg_data;
- node_callback_resp response;
-
assert(tree != NULL);
-
- if (tree->editing == NULL || tree->textarea == NULL)
- return;
-
- element = tree->editing;
-
- if (keep_changes) {
- text_len = textarea_get_text(tree->textarea, NULL, 0);
- text = malloc(text_len * sizeof(char));
- if (text == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- textarea_destroy(tree->textarea);
- tree->textarea = NULL;
- return;
- }
- textarea_get_text(tree->textarea, text, text_len);
- }
-
-
- if (keep_changes && element->parent->user_callback != NULL) {
- msg_data.msg = NODE_ELEMENT_EDIT_FINISHING;
- msg_data.flag = element->flag;
- msg_data.node = element->parent;
- msg_data.data.text = text;
- response = element->parent->user_callback(
- element->parent->callback_data,
- &msg_data);
-
- switch (response) {
- case NODE_CALLBACK_REJECT:
- free(text);
- text = NULL;
- break;
- case NODE_CALLBACK_CONTINUE:
- free(text);
- text = NULL;
- return;
- case NODE_CALLBACK_HANDLED:
- case NODE_CALLBACK_NOT_HANDLED:
- text = msg_data.data.text;
- break;
- }
- }
-
- textarea_destroy(tree->textarea);
- tree->textarea = NULL;
- tree->editing = NULL;
-
- if (text != NULL)
- tree_update_node_element(tree, element, text, NULL);
- else
- tree_handle_node_element_changed(tree, element, true);
-
-
- tree_recalculate_size(tree);
- if (element->parent->user_callback != NULL) {
- msg_data.msg = keep_changes ? NODE_ELEMENT_EDIT_FINISHED :
- NODE_ELEMENT_EDIT_CANCELLED;
- msg_data.flag = element->flag;
- msg_data.node = element->parent;
- element->parent->user_callback(element->parent->callback_data,
- &msg_data);
- }
-}
-
-
-/**
- * Delinks a node from the tree structures.
- *
- * \param tree the tree in which the delink takes place, may be NULL
- * \param node the node to delink
- */
-void tree_delink_node(struct tree *tree, struct node *node)
-{
- struct node *parent;
-
- assert(node != NULL);
-
- /* do not remove the root */
- if (tree != NULL && node == tree->root)
- return;
- if ((tree != NULL) && (tree->editing != NULL)) {
- parent = tree->editing->parent;
- while (parent != NULL) {
- if (node == parent) {
- tree_stop_edit(tree, false);
- break;
- }
- parent = parent->parent;
- }
- }
-
- if (node->parent->child == node)
- node->parent->child = node->next;
- if (node->parent->last_child == node)
- node->parent->last_child = node->previous;
- parent = node->parent;
- node->parent = NULL;
-
- if (node->previous != NULL)
- node->previous->next = node->next;
- if (node->next != NULL)
- node->next->previous = node->previous;
- node->previous = NULL;
- node->next = NULL;
-
- tree_handle_node_changed(tree, parent, false, true);
-}
-
-
-/**
- * Deletes a node from the tree.
- *
- * \param tree the tree to delete from, may be NULL
- * \param node the node to delete
- * \param siblings whether to delete all siblings
- */
-static void tree_delete_node_internal(struct tree *tree, struct node *node,
- bool siblings)
-{
- struct node *next, *child, *parent;
- struct node_element *e, *f;
- node_callback_resp response;
- struct node_msg_data msg_data;
-
- assert(node != NULL);
-
- if (tree != NULL && tree->root == node)
- return;
-
- next = node->next;
- parent = node->parent;
- if (tree != NULL && parent == tree->root)
- parent = NULL;
- if ((tree != NULL) && (tree->def_folder == node))
- tree->def_folder = NULL;
- tree_delink_node(tree, node);
- child = node->child;
- node->child = NULL;
-
- node->deleted = true;
- if (child != NULL)
- tree_delete_node_internal(tree, child, true);
-
- if (!node->retain_in_memory) {
- node->retain_in_memory = true;
- for (e = &node->data; e != NULL; e = f) {
- if (e->text != NULL) {
- response = NODE_CALLBACK_NOT_HANDLED;
- if (!e->editable &&
- node->user_callback != NULL) {
- msg_data.msg = NODE_DELETE_ELEMENT_TXT;
- msg_data.flag = e->flag;
- msg_data.node = node;
- msg_data.data.text = (void *)e->text;
- response = node->user_callback(
- node->callback_data,
- &msg_data);
- }
- if (response != NODE_CALLBACK_HANDLED)
- free((void *)e->text);
- e->text = NULL;
- }
- if (e->bitmap != NULL) {
- response = NODE_CALLBACK_NOT_HANDLED;
- if (node->user_callback != NULL) {
- msg_data.msg = NODE_DELETE_ELEMENT_IMG;
- msg_data.flag = e->flag;
- msg_data.node = node;
- msg_data.data.bitmap =
- (void *)e->bitmap;
- response = node->user_callback(
- node->callback_data,
- &msg_data);
- }
- /* TODO the type of this field is platform
- dependent */
- if (response != NODE_CALLBACK_HANDLED)
- free(e->bitmap);
- e->bitmap = NULL;
- }
- f = e->next;
- if (e != &node->data)
- free(e);
- }
- free(node);
- }
-
- if (siblings && next)
- tree_delete_node_internal(tree, next, true);
- if ((tree->flags & TREE_DELETE_EMPTY_DIRS) && parent != NULL &&
- parent->child == NULL && !parent->deleted)
- tree_delete_node_internal(tree, parent, false);
-}
-
-
-/**
- * Deletes all nodes of a tree and the tree itself.
- *
- * \param tree the tree to be deleted
- */
-void tree_delete(struct tree *tree)
-{
- tree->redraw = false;
-
- treeview_test_fini(tree);
-
- if (tree->root->child != NULL)
- tree_delete_node_internal(tree, tree->root->child, true);
-
- free((void *)tree->root->data.text);
- free(tree->root);
- free(tree);
-}
-
-
-/**
- * Gets the redraw property of the given tree.
- *
- * \param tree the tree for which to retrieve the property
- * \return the redraw property of the tree
- */
-bool tree_get_redraw(struct tree *tree)
-{
- return tree->redraw;
-}
-
-
-/**
- * Deletes a node from the tree.
- *
- * \param tree the tree to delete from, may be NULL
- * \param node the node to delete
- * \param siblings whether to delete all siblings
- */
-void tree_delete_node(struct tree *tree, struct node *node, bool siblings)
-{
- int y = node->box.y;
- int height = tree->height;
- int width = tree->width;
- bool redraw_setting = tree->redraw;
-
- tree->redraw = false;
-
- tree_delete_node_internal(tree, node, siblings);
- tree_recalculate_node_positions(tree, tree->root);
-
- tree->redraw = redraw_setting;
-
- if (tree->redraw)
- tree->callbacks->redraw_request(0, y,
- width, height, tree->client_data);
- tree_recalculate_size(tree);
-}
-
-
-/**
- * Sets an icon for a node
- *
- * \param tree The tree to which node belongs, may be NULL
- * \param node The node for which the icon is set
- * \param icon the image to use
- */
-void tree_set_node_icon(struct tree *tree, struct node *node,
- hlcache_handle *icon)
-{
- node->data.type = NODE_ELEMENT_TEXT_PLUS_ICON;
- tree_update_node_element(tree, &(node->data), NULL, icon);
-}
-
-
-/**
- * Updates all siblings and descendants of a node to an expansion state.
- * No update is performed for the tree changes.
- *
- * \param tree the tree to which 'node' belongs
- * \param node the node to set all siblings and descendants of
- * \param expanded the expansion state to set
- */
-static void tree_set_node_expanded_all(struct tree *tree, struct node *node,
- bool expanded)
-{
- for (; node != NULL; node = node->next) {
- if (node->expanded != expanded) {
- node->expanded = expanded;
- tree_recalculate_node_sizes(tree, node, false);
- }
- if ((node->child != NULL) && (node->expanded))
- tree_set_node_expanded_all(tree, node->child, expanded);
- }
-}
-
-
-/**
- * Updates [all siblings and descendants of] a node to an expansion state.
- *
- * \param tree the tree to update
- * \param node the node to set [all siblings and descendants of]
- * \param expanded the expansion state to set
- * \param folder whether to update folders, if this together with leaf
- * will be false only 'node' will be updated
- * \param leaf whether to update leaves (check also description for folder)
- * \return whether any changes were made
- */
-static bool tree_set_node_expanded_internal(struct tree *tree,
- struct node *node, bool expanded, bool folder, bool leaf)
-{
- bool redraw = false;
- struct node *end = (folder == false && leaf == false) ?
- node->next : NULL;
-
- if (tree->editing != NULL && node == tree->editing->parent)
- tree_stop_edit(tree, false);
-
- for (; node != end; node = node->next) {
- if ((node->expanded != expanded) && (node != tree->root) &&
- ((folder && (node->folder)) ||
- (leaf && (!node->folder)) ||
- (!folder && !leaf))) {
- node->expanded = expanded;
- if (node->child != NULL)
- tree_set_node_expanded_all(tree,
- node->child, false);
- if ((node->data.next != NULL) &&
- (node->data.next->box.height == 0))
- tree_recalculate_node_sizes(tree, node, true);
- else
- tree_recalculate_node_sizes(tree, node, false);
- redraw = true;
- }
- if ((folder || leaf) && (node->child != NULL) &&
- (node->expanded))
- redraw |= tree_set_node_expanded_internal(tree,
- node->child, expanded, folder, leaf);
- }
- return redraw;
-}
-
-
-/**
- * Updates [all siblings and descendants of] a node to an expansion state.
- *
- * \param tree the tree to update
- * \param node the node to set [all siblings and descendants of]
- * \param expanded the expansion state to set
- * \param folder whether to update folders, if this together with leaf
- * will be false only 'node' will be updated
- * \param leaf whether to update leaves (check also description for folder)
- */
-void tree_set_node_expanded(struct tree *tree, struct node *node, bool expanded,
- bool folder, bool leaf)
-{
- if (tree_set_node_expanded_internal(tree, node, expanded, folder, leaf))
- tree_handle_node_changed(tree, node, false, true);
-}
-
-
-/**
- * Updates a node to an selected state. The required areas of the tree are
- * redrawn.
- *
- * \param tree the tree to update nodes for, may be NULL
- * \param node the node to set all siblings and descendants of
- * \param all if true update node together with its siblings and
- * descendants
- * \param selected the selection state to set
- */
-void tree_set_node_selected(struct tree *tree, struct node *node, bool all,
- bool selected)
-{
- struct node *end;
-
- if (tree != NULL && node == tree->root)
- node = tree->root->child;
- if (node == NULL)
- return;
-
- end = all ? NULL : node->next;
-
- for (; node != end; node = node->next) {
- if (node->selected != selected) {
- node->selected = selected;
- if (tree != NULL && tree->redraw)
- tree->callbacks->redraw_request(
- node->data.box.x,
- node->data.box.y,
- node->data.box.width,
- node->data.box.height,
- tree->client_data);
- }
- if (all && (node->child != NULL) && (node->expanded))
- tree_set_node_selected(tree, node->child, all,
- selected);
- }
-}
-
-
-/**
- * Sets the sort function for a node
- *
- * \param tree the tree to which 'node' belongs, may be NULL
- * \param node the node to be inserted
- * \param sort pointer to the sorting function
- */
-void tree_set_node_sort_function(struct tree *tree, struct node *node,
- int (*sort) (struct node *, struct node *))
-{
- struct node *child;
-
- node->sort = sort;
-
- if (tree != NULL && tree->editing != NULL)
- tree_stop_edit(tree, false);
-
- /* the node had already some children so they must get sorted */
- if (node->child != NULL) {
-
- child = node->child;
- node->child = NULL;
-
- while (child != NULL) {
- tree_sort_insert(node, child);
- child = child->next;
- }
-
- }
-
- if (tree != NULL)
- tree_recalculate_node_positions(tree, node->child);
-}
-
-
-/**
- * Sets the delete callback for a node.
- *
- * \param node the node for which the callback is set
- * \param callback the callback functions to be set
- * \param data user data to be passed to callback
- */
-void tree_set_node_user_callback(struct node *node,
- tree_node_user_callback callback, void *data)
-{
- node->user_callback = callback;
- node->callback_data = data;
-}
-
-
-/**
- * Sets the redraw property to the given value. If redraw is true, the tree will
- * be redrawn on layout/appearance changes.
- *
- * \param tree the tree for which the property is set
- * \param redraw the value to set
- */
-void tree_set_redraw(struct tree *tree, bool redraw)
-{
- /* the tree might have no graphical representation, do not set the
- redraw flag in such case */
- if (tree->callbacks == NULL)
- return;
- tree->redraw = redraw;
-}
-
-
-/**
- * Checks whether a node, its siblings or any children are selected.
- *
- * \param node the root node to check from
- * \return whether 'node', its siblings or any children are selected.
- */
-bool tree_node_has_selection(struct node *node)
-{
- for (; node != NULL; node = node->next) {
- if (node->selected)
- return true;
- if ((node->child != NULL) && (node->expanded) &&
- (tree_node_has_selection(node->child)))
- return true;
- }
- return false;
-}
-
-
-/**
- * Returns the current value of the nodes deleted property.
- *
- * \param node the node to be checked
- * \return the current value of the nodes deleted property
- */
-bool tree_node_is_deleted(struct node *node)
-{
- return node->deleted;
-}
-
-
-/**
- * Returns true if the node is a folder
- *
- * \param node the node to be checked
- * \return true if the node is a folder, false otherwise
- */
-bool tree_node_is_folder(struct node *node)
-{
- return node->folder;
-}
-
-
-/**
- * Returns true if the node is the default folder for a tree
- *
- * \param node the node to be checked
- * \return true if the node is a default folder, false otherwise
- */
-bool tree_node_is_default(struct node *node)
-{
- return node->def_folder;
-}
-
-
-/**
- * Update the text of a node element if it has changed.
- *
- * \param element The node element to update.
- * \param text The text to update the element with. The ownership of
- * this string is taken by this function and must not be
- * referred to after the function exits.
- */
-bool tree_update_element_text(struct tree *tree,
- struct node_element *element, char *text)
-{
- const char *node_text; /* existing node text */
-
- if (text == NULL)
- return false;
-
- if (element == NULL) {
- free(text);
- return false;
- }
-
- node_text = tree_node_element_get_text(element);
-
- if ((node_text == NULL) || (strcmp(node_text, text) != 0)) {
- tree_update_node_element(tree, element, text, NULL);
- } else {
- /* text does not need changing, free it */
- free(text);
- }
- return true;
-}
-
-
-/**
- * Updates the content of a node_element.
- *
- * \param tree the tree owning element, may be NULL
- * \param element the element to be updated
- * \param text new text to be set, may be NULL
- * \param bitmap new bitmap to be set, may be NULL
- */
-void tree_update_node_element(struct tree *tree, struct node_element *element,
- const char *text, void *bitmap)
-{
- node_callback_resp response;
- struct node_msg_data msg_data;
- bool text_changed = false;
-
- assert(element != NULL);
-
- if ((tree != NULL) && (element == tree->editing)) {
- tree_stop_edit(tree, false);
- }
-
- if ((text != NULL) &&
- (element->type == NODE_ELEMENT_TEXT ||
- element->type == NODE_ELEMENT_TEXT_PLUS_ICON)) {
- if (element->text != NULL) {
- if (strcmp(element->text, text) == 0) {
- text_changed = true;
- }
- response = NODE_CALLBACK_NOT_HANDLED;
- if ((!element->editable) &&
- (element->parent->user_callback != NULL)) {
- msg_data.msg = NODE_DELETE_ELEMENT_TXT;
- msg_data.flag = element->flag;
- msg_data.node = element->parent;
- msg_data.data.text = (void *)element->text;
- response = element->parent->user_callback(
- element->parent->callback_data,
- &msg_data);
- }
- if (response != NODE_CALLBACK_HANDLED) {
- free(element->text);
- }
- }
- element->text = (char *)text;
- }
-
- if ((bitmap != NULL) &&
- ((element->type == NODE_ELEMENT_BITMAP) ||
- (element->type == NODE_ELEMENT_TEXT_PLUS_ICON))) {
- if (element->bitmap != NULL) {
- response = NODE_CALLBACK_NOT_HANDLED;
- if (element->parent->user_callback != NULL) {
- msg_data.msg = NODE_DELETE_ELEMENT_IMG;
- msg_data.flag = element->flag;
- msg_data.node = element->parent;
- msg_data.data.bitmap = (void *)element->bitmap;
- response = element->parent->user_callback(
- element->parent->callback_data,
- &msg_data);
- }
-
- if (response != NODE_CALLBACK_HANDLED) {
- free(element->bitmap);
- }
- } else {
- /* Increase the box width to accomodate the new icon */
- element->box.width += NODE_INSTEP;
- }
-
- element->bitmap = bitmap;
- }
-
- tree_handle_node_element_changed(tree, element, text_changed);
-}
-
-
-/**
- * Returns the node element's text
- *
- * \return the node element's text
- */
-const char *tree_node_element_get_text(struct node_element *element)
-{
- return element->text;
-}
-
-
-/**
- * Returns the node element's icon
- *
- * \return the node element's icon
- */
-struct bitmap *tree_node_element_get_icon(struct node_element *element)
-{
- return element->bitmap;
-}
-
-
-/**
- * Get the root node of a tree
- *
- * \param tree the tree to get the root of
- * \return the root of the tree
- */
-struct node *tree_get_root(struct tree *tree)
-{
- return tree->root;
-}
-
-
-/**
- * Returns whether the current tree is being edited at this time
- *
- * \param tree the tree to be checked
- * \return true if the tree is currently being edited
- */
-bool tree_is_edited(struct tree *tree)
-{
- return tree->editing == NULL ? false : true;
-}
-
-
-/**
- * Get the drag state of a tree
- *
- * \param tree the tree to get the state of
- * \return drag type (defined in desktop/tree.h)
- */
-tree_drag_type tree_drag_status(struct tree *tree)
-{
return tree->drag;
}
-
-
-/**
- * Get the default node of a tree for additions
- *
- * \param tree the tree to get the default node of
- * \return the default node
- */
-struct node *tree_get_default_folder_node(struct tree *tree)
-{
- if (tree->def_folder != NULL) {
- return tree->def_folder;
- } else {
- return tree_get_root(tree);
- }
-}
-
-
-/**
- * Set the default node of a tree to the selected node
- *
- * \param tree the tree to set the default node of
- * \param node the node to set as default (NULL for selected node)
- * \return success
- */
-bool tree_set_default_folder_node(struct tree *tree, struct node *node)
-{
- struct node *sel_node;
-
- if (node == NULL) {
- sel_node = tree_get_selected_node(tree->root);
- } else {
- sel_node = node;
- }
-
- if((sel_node == NULL) ||
- (tree_node_is_folder(sel_node) == false)) {
- return false;
- }
-
- tree_clear_default_folder_node(tree);
-
- tree->def_folder = sel_node;
- sel_node->def_folder = true;
- tree_handle_node_changed(tree, sel_node, true, false);
-
- return true;
-}
-
-
-/**
- * Clear the default node of a tree
- *
- * \param tree the tree to clear the default node of
- */
-void tree_clear_default_folder_node(struct tree *tree)
-{
- struct node *def_node = NULL;
- def_node = tree_get_default_folder_node(tree);
-
- if (def_node != NULL) {
- tree->def_folder = NULL;
- def_node->def_folder = false;
- tree_handle_node_changed(tree, def_node, true, false);
- }
-}
-
-
-/**
- * Returns the parent of a node
- *
- * \param node the node to get the parent of
- * \return the node's parent
- */
-struct node *tree_node_get_parent(struct node *node)
-{
- return node->parent;
-}
-
-
-/**
- * Returns the first child of a node
- *
- * \param node the node to get the child of
- * \return the nodes first child
- */
-struct node *tree_node_get_child(struct node *node)
-{
- return node->child;
-}
-
-
-/**
- * Returns the closest sibling a node
- *
- * \param node the node to get the sibling of
- * \return the nodes sibling
- */
-struct node *tree_node_get_next(struct node *node)
-{
- return node->next;
-}
-
-
-/**
- * Draws an element's expansion icon
- *
- * \param tree the tree to draw the expansion for
- * \param element the element to draw the expansion for
- * \param tree_x X coordinate of the tree
- * \param tree_y Y coordinate of the tree
- * \param ctx current redraw context
- */
-static void tree_draw_node_expansion_toggle(struct tree *tree,
- struct node *node, int tree_x, int tree_y,
- const struct redraw_context *ctx)
-{
- const struct plotter_table *plot = ctx->plot;
- int x, y;
-
- assert(tree != NULL);
- assert(node != NULL);
-
- if ((node->child != NULL) || (node->data.next != NULL)) {
- x = tree_x + node->box.x - (NODE_INSTEP / 2) - 4;
- y = tree_y + node->box.y + (TREE_LINE_HEIGHT - 9) / 2;
- plot->rectangle(x, y, x + 9, y + 9,
- &plot_style_fill_tree_furniture);
- plot->rectangle(x , y, x + 8, y + 8,
- &plot_style_stroke_tree_furniture);
- plot->line(x + 2, y + 4, x + 7, y + 4,
- &plot_style_stroke_tree_furniture);
- if (!node->expanded)
- plot->line(x + 4, y + 2, x + 4, y + 7,
- &plot_style_stroke_tree_furniture);
-
- }
-
-}
-
-
-/**
- * Draws an element, including any expansion icons
- *
- * \param tree the tree to draw an element for
- * \param element the element to draw
- * \param tree_x X coordinate to draw the tree at (wrt plot origin)
- * \param tree_y Y coordinate to draw the tree at (wrt plot origin)
- * \param clip clipping rectangle (wrt plot origin)
- * \param ctx current redraw context
- */
-static void tree_draw_node_element(struct tree *tree,
- struct node_element *element, int tree_x, int tree_y,
- const struct rect *clip, const struct redraw_context *ctx)
-{
- const struct plotter_table *plot = ctx->plot;
- struct bitmap *bitmap = NULL;
- int x, y, width;
- bool selected = false;
- bool def_folder = false;
- hlcache_handle *icon;
- plot_font_style_t *fstyle;
- const int icon_inset = (TREE_LINE_HEIGHT - TREE_ICON_SIZE) / 2;
-
- assert(tree != NULL);
- assert(element != NULL);
- assert(element->parent != NULL);
-
- x = tree_x + element->box.x;
- y = tree_y + element->box.y;
- width = element->box.width;
- if (&element->parent->data == element) {
- if (element->parent->selected)
- selected = true;
- if (element->parent->def_folder)
- def_folder = true;
- }
-
- switch (element->type) {
- case NODE_ELEMENT_TEXT_PLUS_ICON:
- icon = element->bitmap;
- if (icon != NULL && (content_get_status(icon) ==
- CONTENT_STATUS_READY ||
- content_get_status(icon) ==
- CONTENT_STATUS_DONE) &&
- x + TREE_ICON_SIZE > clip->x0 &&
- x < clip->x1) {
- struct rect c;
- /* Clip to image area */
- c.x0 = x;
- c.y0 = y + icon_inset;
- c.x1 = x + TREE_ICON_SIZE;
- c.y1 = y + icon_inset + TREE_ICON_SIZE;
- if (c.x0 < clip->x0) c.x0 = clip->x0;
- if (c.y0 < clip->y0) c.y0 = clip->y0;
- if (c.x1 > clip->x1) c.x1 = clip->x1;
- if (c.y1 > clip->y1) c.y1 = clip->y1;
-
- if (c.x1 > c.x0 && c.y1 > c.y0) {
- /* Valid clip rectangles only */
- struct content_redraw_data data;
-
- plot->clip(&c);
-
- data.x = x;
- data.y = y + icon_inset;
- data.width = TREE_ICON_SIZE;
- data.height = TREE_ICON_SIZE;
-
- data.background_colour = 0xFFFFFF;
- data.scale = 1;
- data.repeat_x = false;
- data.repeat_y = false;
-
- content_redraw(icon, &data, &c, ctx);
-
- /* Restore previous clipping area */
- plot->clip(clip);
- }
- }
-
- x += NODE_INSTEP;
- width -= NODE_INSTEP;
-
- /* fall through */
- case NODE_ELEMENT_TEXT:
- if (element->text == NULL || clip->x1 < x)
- break;
-
- if (element == tree->editing)
- return;
-
- if (selected) {
- if (def_folder == true)
- fstyle = &plot_fstyle_selected_def_folder;
- else
- fstyle = &plot_fstyle_selected;
-
- plot->rectangle(x, y, x + width,
- y + element->box.height,
- &plot_style_fill_tree_selected);
- } else {
- if (def_folder == true)
- fstyle = &plot_fstyle_def_folder;
- else
- fstyle = &plot_fstyle;
- }
-
- plot->text(x + 4, y + (TREE_LINE_HEIGHT * 3 + 2) / 4,
- element->text, strlen(element->text),
- fstyle);
- break;
- case NODE_ELEMENT_BITMAP:
- bitmap = element->bitmap;
- if (bitmap == NULL)
- break;
- plot->bitmap(x, y, element->box.width - 1,
- element->box.height - 2,
- bitmap, 0xFFFFFF, BITMAPF_NONE);
- if (!(tree->flags & TREE_NO_FURNITURE))
- plot->rectangle(x, y, x + element->box.width - 1,
- y + element->box.height - 3,
- &plot_style_stroke_tree_furniture);
-
- break;
- }
-
-}
-
-
-/**
- * Redraws a node.
- *
- * \param tree the tree to draw
- * \param node the node to draw children and siblings of
- * \param tree_x X coordinate to draw the tree at (wrt plot origin)
- * \param tree_y Y coordinate to draw the tree at (wrt plot origin)
- * \param clip clipping rectangle (wrt plot origin)
- * \param ctx current redraw context
- */
-static void tree_draw_node(struct tree *tree, struct node *node,
- int tree_x, int tree_y, struct rect clip,
- const struct redraw_context *ctx)
-{
- const struct plotter_table *plot = ctx->plot;
- struct node_element *element;
- struct node *parent;
- int x0, y0, x1, y1;
- struct rect node_extents;
-
- assert(tree != NULL);
- assert(node != NULL);
-
- /* Find node's extents, including children's area */
- node_extents.x0 = tree_x + node->box.x - NODE_INSTEP;
- node_extents.y0 = tree_y + node->box.y;
- node_extents.x1 = tree_x + node->box.x + node->box.width + NODE_INSTEP;
- if (node->next != NULL)
- node_extents.y1 = tree_y + node->next->box.y;
- else
- node_extents.y1 = tree_y + node->box.y + node->box.height;
-
- /* Nothing to draw, if node is outside clip region */
- if ((node_extents.x1 < clip.x0) && (node_extents.y1 < clip.y0) &&
- (node_extents.x0 > clip.x1) &&
- (node_extents.y0 > clip.y1)) {
- return;
- }
-
- /* Intersect clip region with node's extents */
- if (clip.x0 < node_extents.x0) clip.x0 = node_extents.x0;
- if (clip.y0 < node_extents.y0) clip.y0 = node_extents.y0;
- if (clip.x1 > node_extents.x1) clip.x1 = node_extents.x1;
- if (clip.y1 > node_extents.y1) clip.y1 = node_extents.y1;
-
- if (clip.x0 >= clip.x1 || clip.y0 >= clip.y1) {
- /* Invalid clip rectangle */
- return;
- }
-
- /* Set up the clipping area */
- plot->clip(&clip);
-
- /* Draw node's furniture */
- if (!(tree->flags & TREE_NO_FURNITURE)) {
- /* Display furniture */
- if (node->previous != NULL) {
- /* There is a node above this
- * Display furniture; line connecting up to previous */
- x0 = x1 = tree_x + node->box.x - (NODE_INSTEP / 2);
- y0 = tree_y + node->previous->box.y;
- y1 = tree_y + node->box.y + (TREE_LINE_HEIGHT / 2);
- plot->line(x0, y0, x1, y1,
- &plot_style_stroke_tree_furniture);
- }
- if (node->next != NULL) {
- /* There is a node below this
- * Display furniture; line connecting down to next */
- x0 = x1 = tree_x + node->box.x - (NODE_INSTEP / 2);
- y0 = tree_y + node->box.y + (TREE_LINE_HEIGHT / 2);
- y1 = tree_y + node->next->box.y;
- plot->line(x0, y0, x1, y1,
- &plot_style_stroke_tree_furniture);
- }
-
- parent = node->parent;
- if ((parent != NULL) && (parent != tree->root) &&
- (parent->child == node)) {
- /* Node is first child */
- x0 = x1 = tree_x + parent->box.x + (NODE_INSTEP / 2);
- y0 = tree_y + parent->data.box.y +
- parent->data.box.height;
- y1 = y0 + (TREE_LINE_HEIGHT / 2);
- plot->line(x0, y0, x1, y1,
- &plot_style_stroke_tree_furniture);
- }
- /* Line from expansion toggle to icon */
- x0 = tree_x + node->box.x - (NODE_INSTEP / 2);
- x1 = x0 + (NODE_INSTEP / 2) - 2;
- y0 = y1 = tree_y + node->data.box.y + node->data.box.height -
- (TREE_LINE_HEIGHT / 2);
- plot->line(x0, y0, x1, y1, &plot_style_stroke_tree_furniture);
-
- tree_draw_node_expansion_toggle(tree, node,
- tree_x, tree_y, ctx);
- }
-
- /* Draw node's element(s)
- * NOTE: node's children are handled later in tree_draw_tree() */
- if (node->expanded) {
- for (element = &node->data; element != NULL;
- element = element->next) {
- /* Draw each element of expanded node */
- tree_draw_node_element(tree, element, tree_x, tree_y,
- &clip, ctx);
- }
- } else {
- /* Draw main title element of node */
- tree_draw_node_element(tree, &node->data, tree_x, tree_y,
- &clip, ctx);
- }
-}
-
-
-/**
- * Redraws a node's descendants.
- *
- * \param tree the tree to draw
- * \param node the node to draw children and siblings of
- * \param tree_x X coordinate to draw the tree at (wrt plot origin)
- * \param tree_y Y coordinate to draw the tree at (wrt plot origin)
- * \param clip clipping rectangle (wrt plot origin)
- * \param ctx current redraw context
- */
-static void tree_draw_tree(struct tree *tree, struct node *node,
- int tree_x, int tree_y, struct rect clip,
- const struct redraw_context *ctx)
-{
- struct node *child;
-
- assert(tree != NULL);
- assert(node != NULL);
-
- for (child = node->child; child != NULL; child = child->next) {
- /* Draw children that are inside the clip region */
-
- if (child->next != NULL &&
- (child->next->box.y + tree_y < clip.y0))
- /* Child is above clip region */
- continue;
- if (child->box.y + tree_y > clip.y1)
- /* Child is below clip region
- * further siblings will be too */
- return;
-
- /* Draw current child */
- tree_draw_node(tree, child, tree_x, tree_y, clip, ctx);
- /* And its children */
- if ((child->child != NULL) && (child->expanded)) {
- /* Child has children and they are visible */
- tree_draw_tree(tree, child, tree_x, tree_y, clip, ctx);
- }
- }
-}
-
-
-/**
- * Redraws a tree.
- *
- * \param tree the tree to draw
- * \param x X coordinate to draw the tree at (wrt plot origin)
- * \param y Y coordinate to draw the tree at (wrt plot origin)
- * \param clip_x minimum x of the clipping rectangle (wrt tree origin)
- * \param clip_y minimum y of the clipping rectangle (wrt tree origin)
- * \param clip_width width of the clipping rectangle
- * \param clip_height height of the clipping rectangle
- * \param ctx current redraw context
- */
-void tree_draw(struct tree *tree, int x, int y,
- int clip_x, int clip_y, int clip_width, int clip_height,
- const struct redraw_context *ctx)
-{
- struct redraw_context new_ctx = *ctx;
- struct rect clip;
-
- assert(tree != NULL);
- assert(tree->root != NULL);
-
- if (treeview_test_redraw(tree, x, y, clip_x, clip_y,
- clip_width, clip_height, ctx)) {
- return;
- }
-
- /* Start knockout rendering if it's available for this plotter */
- if (ctx->plot->option_knockout)
- knockout_plot_start(ctx, &new_ctx);
-
- /* Set up clip rectangle */
- clip.x0 = x + clip_x;
- clip.y0 = y + clip_y;
- clip.x1 = clip.x0 + clip_width;
- clip.y1 = clip.y0 + clip_height;
- new_ctx.plot->clip(&clip);
-
- /* Flat fill extents of clipping area */
- new_ctx.plot->rectangle(clip.x0, clip.y0, clip.x1, clip.y1,
- &plot_style_fill_tree_background);
-
- /* don't draw empty trees or trees with redraw flag set to false */
- if (tree->root->child != NULL && tree->redraw) {
-
- /* Draw the tree */
- tree_draw_tree(tree, tree->root, x, y, clip, &new_ctx);
-
- /* Draw textarea, if present */
- if (tree->editing != NULL) {
- x = x + tree->editing->box.x;
- y = y + tree->editing->box.y;
- if (tree->editing->type == NODE_ELEMENT_TEXT_PLUS_ICON)
- x += NODE_INSTEP;
- textarea_redraw(tree->textarea, x, y,
- plot_style_fill_tree_background.
- fill_colour,
- 1.0, &clip, &new_ctx);
- }
- }
-
- /* Rendering complete */
- if (ctx->plot->option_knockout)
- knockout_plot_end();
-}
-
-
-/**
- * Finds a node element from a node with a specific user_type
- *
- * \param node the node to examine
- * \param flag user assinged flag used is searches
- * \param after if this is not NULL the search will start after the given
- * node_element
- * \return the corresponding element
- */
-struct node_element *tree_node_find_element(struct node *node,
- unsigned int flag, struct node_element *after)
-{
- struct node_element *element;
-
- if (after == NULL)
- element = &node->data;
- else {
- assert(after->parent == node);
- element = after->next;
- }
-
- for (; element != NULL; element = element->next)
- if (element->flag == flag) return element;
-
- return NULL;
-}
-
-
-/**
- * Deletes all selected nodes from the tree.
- *
- * \param tree the tree to delete from
- * \param node the node to delete
- */
-void tree_delete_selected_nodes(struct tree *tree, struct node *node)
-{
- struct node *next;
- int y = node->box.y;
- int height = tree->height;
- int width = tree->width;
- bool redraw_setting = tree->redraw;
-
- tree->redraw = false;
-
- if (node == tree->root) {
- if (node->child != NULL)
- tree_delete_selected_nodes(tree, node->child);
-
- tree->redraw = redraw_setting;
-
- if (tree->redraw)
- tree->callbacks->redraw_request(0, y,
- width, height,
- tree->client_data);
- return;
- }
-
- while (node != NULL) {
- next = node->next;
- if (node->selected)
- tree_delete_node(tree, node, false);
- else if (node->child != NULL)
- tree_delete_selected_nodes(tree, node->child);
- node = next;
- }
-
- tree->redraw = redraw_setting;
-
- if (tree->redraw)
- tree->callbacks->redraw_request(0, y,
- width, height,
- tree->client_data);
-}
-
-
-/**
- * Returns the selected node, or NULL if multiple nodes are selected.
- *
- * \param node the node to search sibling and children
- * \return the selected node, or NULL if multiple nodes are selected
- */
-struct node *tree_get_selected_node(struct node *node)
-{
- struct node *result = NULL;
- struct node *temp;
-
- for (; node != NULL; node = node->next) {
- if (node->selected) {
- if (result != NULL)
- return NULL;
- result = node;
- }
- if ((node->child != NULL) && (node->expanded)) {
- temp = tree_get_selected_node(node->child);
- if (temp != NULL) {
- if (result != NULL)
- return NULL;
- else
- result = temp;
- }
- }
- }
- return result;
-}
-
-
-/**
- * Finds a node element at a specific location.
- *
- * \param node the root node to check from
- * \param x the x co-ordinate
- * \param y the y co-ordinate
- * \param expansion_toggle whether the coordinate was in an expansion toggle
- * \return the node at the specified position, or NULL for none
- */
-static struct node_element *tree_get_node_element_at(struct node *node,
- int x, int y, bool *expansion_toggle)
-{
- struct node_element *element;
- int x0, x1, y0, y1;
-
- *expansion_toggle = false;
- for (; node != NULL; node = node->next) {
- if (node->box.y > y) return NULL;
- if ((node->box.x - NODE_INSTEP < x) && (node->box.y < y) &&
- (node->box.x + node->box.width >= x) &&
- (node->box.y + node->box.height >= y)) {
- if (node->expanded) {
- for (element = &node->data; element != NULL;
- element = element->next) {
- x0 = element->box.x;
- y0 = element->box.y;
- x1 = element->box.x +
- element->box.width;
- y1 = element->box.y +
- element->box.height;
- if ((x0 < x) && (y0 < y) && (x1 >= x)
- && (y1 >= y))
- return element;
- }
- } else {
- x0 = node->data.box.x;
- y0 = node->data.box.y;
- x1 = node->data.box.x + node->data.box.width;
- y1 = node->data.box.y + node->data.box.height;
- if ((x0 < x) && (y0 < y) && (x1 >= x) &&
- (y1>= y))
- return &node->data;
- }
- if (((node->child != NULL) ||
- (node->data.next != NULL)) &&
- (node->data.box.x - NODE_INSTEP + 4 < x)
- && (node->data.box.y + 4 < y) &&
- (node->data.box.x > x) &&
- (node->data.box.y + TREE_LINE_HEIGHT > y)) {
- /* Node either has node children, or node
- * has more than one element.
- * Coordinate is over node expansion toggle area
- */
- *expansion_toggle = true;
- return &node->data;
- }
- }
-
- element = tree_get_node_element_at(node->child, x, y,
- expansion_toggle);
- if ((node->child != NULL) && (node->expanded) &&
- (element != NULL))
- return element;
- }
- return NULL;
-}
-
-
-/**
- * Finds a node at a specific location.
- *
- * \param root the root node to check from
- * \param x the x co-ordinate
- * \param y the y co-ordinate
- * \param expansion_toggle whether the coordinate was in an expansion toggle
- * \return the node at the specified position, or NULL for none
- */
-static struct node *tree_get_node_at(struct node *root, int x, int y,
- bool *expansion_toggle)
-{
- struct node_element *result;
-
- if ((result = tree_get_node_element_at(root, x, y, expansion_toggle)))
- return result->parent;
- return NULL;
-}
-
-
-/**
- * Gets link characteristics to insert a node at a specified position.
- *
- * \param tree the tree to find link information for
- * \param x the x co-ordinate
- * \param y the y co-ordinate
- * \param before set to whether the node should be linked before on exit
- * \return the node to link with
- */
-struct node *tree_get_link_details(struct tree *tree, int x, int y,
- bool *before)
-{
- struct node *node = NULL;
- bool expansion_toggle;
-
- assert(tree != NULL);
- assert(tree->root != NULL);
-
- *before = false;
- if (tree->root->child != NULL)
- node = tree_get_node_at(tree->root->child, x, y,
- &expansion_toggle);
- if ((node == NULL) || (expansion_toggle))
- return tree->root;
-
- if (y < (node->box.y + (node->box.height / 2))) {
- *before = true;
- } else if ((node->folder) && (node->expanded) &&
- (node->child != NULL)) {
- node = node->child;
- *before = true;
- }
- return node;
-}
-
-
-/**
- * Launches all the selected nodes of the tree
- *
- * \param tree the tree for which all nodes will be launched
- * \param node the node which will be checked together with its children
- * \param tabs launch node in a new tab instead of a new window
- */
-static void tree_launch_selected_internal(struct tree *tree, struct node *node,
- bool tabs)
-{
- struct node_msg_data msg_data;
-
- msg_data.data.bw = NULL;
-
- for (; node != NULL; node = node->next) {
- if (node->selected && node->user_callback != NULL) {
- msg_data.msg = NODE_LAUNCH;
- if (tabs == true) {
- msg_data.flag = TREE_ELEMENT_LAUNCH_IN_TABS;
- } else {
- msg_data.flag = TREE_ELEMENT_TITLE;
- }
-
- msg_data.node = node;
- node->user_callback(node->callback_data, &msg_data);
- }
- if (node->child != NULL)
- tree_launch_selected_internal(tree, node->child, tabs);
- }
-}
-
-
-/**
- * Launches all the selected nodes of the tree
- *
- * \param tree the tree for which all nodes will be launched
- * \param tabs launch nodes in new tabs instead of new windows
- */
-void tree_launch_selected(struct tree *tree, bool tabs)
-{
- if (tree->root->child != NULL)
- tree_launch_selected_internal(tree, tree->root->child, tabs);
-}
-
-
-/**
- * Updates the node at position x,y to a selected state.
- * The required areas of the tree are redrawn.
- *
- * \param tree the tree to update nodes for, may be NULL
- * \param x x position in tree
- * \param y y position in tree
- * \param selected the selection state to set
- */
-void tree_set_node_selected_at(struct tree *tree, int x, int y, bool selected)
-{
- bool expansion_toggle;
- struct node *node;
-
- node = tree_get_node_at(tree->root, x, y, &expansion_toggle);
-
- if ((node == NULL) || (expansion_toggle == true))
- return;
-
- tree_set_node_selected(tree, node, false, selected);
-}
-
-
-/**
- * Handles a mouse action for a tree
- *
- * \param tree the tree to handle a click for
- * \param mouse the mouse state
- * \param x X coordinate of mouse action
- * \param y Y coordinate of mouse action
- * \return whether the click was handled
- */
-bool tree_mouse_action(struct tree *tree, browser_mouse_state mouse, int x,
- int y)
-{
- bool expansion_toggle;
- struct node *node;
- struct node *last;
- struct node_element *element;
- struct node_msg_data msg_data;
-
- bool double_click_1 = mouse & BROWSER_MOUSE_DOUBLE_CLICK &&
- mouse & BROWSER_MOUSE_CLICK_1;
- bool double_click_2 = mouse & BROWSER_MOUSE_DOUBLE_CLICK &&
- mouse & BROWSER_MOUSE_CLICK_2;
-
- assert(tree != NULL);
- assert(tree->root != NULL);
-
- if (treeview_test_mouse_action(tree, mouse, x, y)) {
- return true;
- }
-
- if (tree->root->child == NULL)
- return true;
-
- element = tree_get_node_element_at(tree->root->child, x, y,
- &expansion_toggle);
-
- /* pass in-textarea mouse action and drags which started in it
- to the textarea */
- if (tree->editing != NULL) {
- int x0, x1, y0, y1;
- x0 = tree->editing->box.x;
- if (tree->editing->type == NODE_ELEMENT_TEXT_PLUS_ICON)
- x0 += NODE_INSTEP;
- x1 = tree->editing->box.x + tree->editing->box.width;
- y0 = tree->editing->box.y;
- y1 = tree->editing->box.y + tree->ta_height;
-
- if (tree->drag == TREE_TEXTAREA_DRAG &&
- (mouse & (BROWSER_MOUSE_HOLDING_1 |
- BROWSER_MOUSE_HOLDING_2))) {
- /* Track the drag path */
- textarea_mouse_action(tree->textarea, mouse,
- x - x0, y - y0);
- return true;
- }
-
- if ((x >= x0) && (x < x1) && (y >= y0) && (y < y1)) {
- textarea_mouse_action(tree->textarea, mouse,
- x - x0, y - y0);
- return true;
-
- }
- }
-
- /* we are not interested in the drag path, return */
- if (mouse & (BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_HOLDING_2))
- return true;
-
- /* cancel edit */
- if (tree->editing != NULL)
- tree_stop_edit(tree, false);
-
- /* no item either means cancel selection on (select) click or a drag */
- if (element == NULL) {
- if (tree->flags & TREE_SINGLE_SELECT) {
- tree_set_node_selected(tree, tree->root->child, true,
- false);
- return true;
- }
- if (mouse & (BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_DRAG_1))
- tree_set_node_selected(tree, tree->root->child, true,
- false);
- if (mouse & (BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_DRAG_2)) {
-
- /** @todo the tree window has to scroll the tree when
- * mouse reaches border while dragging this isn't
- * solved for the browser window too.
- */
- tree->drag = TREE_SELECT_DRAG;
- }
- return true;
- }
-
- node = element->parent;
-
- /* A click on expansion toggle or double click on folder toggles node
- * expansion */
- if (((expansion_toggle) && (mouse & (BROWSER_MOUSE_CLICK_1 |
- BROWSER_MOUSE_CLICK_2))) ||
- (((!expansion_toggle) && (node->child != NULL)) &&
- (double_click_1 || double_click_2))) {
-
- /* clear any selection */
- tree_set_node_selected(tree, tree->root->child, true, false);
-
- /* expand / contract node and redraw */
- tree_set_node_expanded(tree, node, !node->expanded,
- false, false);
-
- /* find the last child node if expanded */
- last = node;
- if ((last->child != NULL) && (last->expanded)) {
- last = last->child;
- while ((last->next != NULL) ||
- ((last->child != NULL) &&
- (last->expanded))) {
- if (last->next != NULL)
- last = last->next;
- else
- last = last->child;
- }
- }
- /* scroll to the bottom element then back to the top */
- element = &last->data;
- if (last->expanded)
- for (; element->next != NULL; element = element->next);
- tree->callbacks->scroll_visible(element->box.y,
- element->box.height,
- tree->client_data);
- tree->callbacks->scroll_visible(node->data.box.y,
- node->data.box.height,
- tree->client_data);
- return true;
- }
-
- /* no use for any other expansion toggle click */
- if (expansion_toggle)
- return true;
-
- /* single/double ctrl+click or alt+click starts editing */
- if ((element->editable) && (!tree->editing) &&
- ((element->type == NODE_ELEMENT_TEXT) ||
- (element->type == NODE_ELEMENT_TEXT_PLUS_ICON)) &&
- (mouse & BROWSER_MOUSE_CLICK_1 || double_click_1) &&
- (mouse & BROWSER_MOUSE_MOD_2 ||
- mouse & BROWSER_MOUSE_MOD_3)) {
- tree_set_node_selected(tree, tree->root->child, true, false);
- tree_start_edit(tree, element);
- return true;
- }
-
- /* double click launches the leaf */
- if (double_click_1 || double_click_2) {
- if (node->user_callback == NULL)
- return false;
- msg_data.msg = NODE_LAUNCH;
- msg_data.flag = TREE_ELEMENT_TITLE;
- msg_data.node = node;
- if (node->user_callback(node->callback_data, &msg_data) !=
- NODE_CALLBACK_HANDLED)
- return false;
-
- return true;
- }
-
- /* single click (select) cancels current selection and selects item */
- if (mouse & BROWSER_MOUSE_CLICK_1 || (mouse & BROWSER_MOUSE_CLICK_2 &&
- tree->flags & TREE_SINGLE_SELECT)) {
- if (tree->flags & TREE_NO_SELECT)
- return true;
- if (!node->selected) {
- tree_set_node_selected(tree, tree->root->child, true,
- false);
- node->selected = true;
- tree_handle_node_element_changed(tree, &node->data, false);
- }
- return true;
- }
-
- /* single click (adjust) toggles item selection */
- if (mouse & BROWSER_MOUSE_CLICK_2) {
- if (tree->flags & TREE_NO_SELECT)
- return true;
- node->selected = !node->selected;
- tree_handle_node_element_changed(tree, &node->data, false);
- return true;
- }
-
- /* drag starts a drag operation */
- if ((!tree->editing) && (mouse & (BROWSER_MOUSE_DRAG_1 |
- BROWSER_MOUSE_DRAG_2))) {
- if (tree->flags & TREE_NO_DRAGS)
- return true;
-
- if (!node->selected) {
- tree_set_node_selected(tree, tree->root->child, true,
- false);
- node->selected = true;
- tree_handle_node_element_changed(tree, &node->data, false);
- }
-
- if (tree->flags & TREE_MOVABLE)
- tree->drag = TREE_MOVE_DRAG;
- else tree->drag = TREE_UNKNOWN_DRAG;
-
- return true;
- }
-
-
- return false;
-}
-
-
-/**
- * Updates the selected state for a region of nodes.
- *
- * \param tree the tree to update
- * \param node the node to update children and siblings of
- * \param y the minimum y of the selection rectangle
- * \param height the height of the selection rectangle
- * \param invert whether to invert the selected state
- */
-static void tree_handle_selection_area_node(struct tree *tree,
- struct node *node, int y, int height, bool invert)
-{
- struct node_element *element;
- struct node *update;
- int y_max;
- int y0, y1;
-
- assert(tree != NULL);
- assert(node != NULL);
-
- y_max = y + height;
-
- for (; node != NULL; node = node->next) {
- if (node->box.y > y_max) return;
- y0 = node->box.y;
- y1 = node->box.y + node->box.height;
- if ((y0 < y_max) && (y1 >= y)) {
- update = NULL;
- if (node->expanded) {
- for (element = &node->data; element != NULL;
- element = element->next) {
- y0 = element->box.y;
- y1 = element->box.y +
- element->box.height;
- if ((y0 < y_max) && (y1 >= y)) {
- update = element->parent;
- break;
- }
- }
- } else {
- y0 = node->data.box.y;
- y1 = node->data.box.y + node->data.box.height;
- if ((y0 < y_max) && (y1 >= y))
- update = node->data.parent;
- }
- if ((update) && (node != tree->root)) {
- if (invert) {
- node->selected = !node->selected;
- tree_handle_node_element_changed(tree,
- &node->data, false);
- } else if (!node->selected) {
- node->selected = true;
- tree_handle_node_element_changed(tree,
- &node->data, false);
- }
- }
- }
- if ((node->child != NULL) && (node->expanded))
- tree_handle_selection_area_node(tree, node->child, y,
- height, invert);
- }
-}
-
-
-/**
- * Updates the selected state for a region of nodes.
- *
- * \param tree the tree to update
- * \param y the minimum y of the selection rectangle
- * \param height the height of the selection rectangle
- * \param invert whether to invert the selected state
- */
-static void tree_handle_selection_area(struct tree *tree, int y, int height,
- bool invert)
-{
- assert(tree != NULL);
- assert(tree->root != NULL);
-
- if (tree->root->child == NULL)
- return;
-
- if (height < 0) {
- y += height;
- height = -height;
- }
- tree_handle_selection_area_node(tree, tree->root->child, y, height,
- invert);
-}
-
-
-/**
- * Clears the processing flag.
- *
- * \param node the node to process siblings and children of
- */
-static void tree_clear_processing(struct node *node)
-{
- for (; node != NULL; node = node->next) {
- node->processing = false;
- if (node->child != NULL)
- tree_clear_processing(node->child);
- }
-}
-
-
-/**
- * Sets the processing flag to the selection state.
- *
- * \param node the node to process siblings and children of
- */
-static void tree_selected_to_processing(struct node *node)
-{
- for (; node != NULL; node = node->next) {
- node->processing = node->selected;
- if ((node->child != NULL) && (node->expanded))
- tree_selected_to_processing(node->child);
- }
-}
-
-
-/**
- * Moves the first node in a tree with the processing flag set.
- *
- * \param tree the tree in which the move takes place
- * \param node the node to move siblings/children of
- * \param link the node to link before/as a child (folders) or before/after
- * (link)
- * \param before whether to link siblings before or after the supplied node
- * \param first whether to always link after the supplied node (ie not
- * inside of folders)
- * \return the node moved
- */
-static struct node *tree_move_processing_node(struct tree *tree,
- struct node *node, struct node *link, bool before, bool first)
-{
- struct node *result;
-
- bool folder = link->folder;
- for (; node != NULL; node = node->next) {
- if (node->processing) {
- node->processing = false;
- tree_delink_node(tree, node);
- if (!first)
- link->folder = false;
- tree_link_node(tree, link, node, before);
- if (!first)
- link->folder = folder;
- return node;
- }
- if (node->child != NULL) {
- result = tree_move_processing_node(tree, node->child,
- link, before, first);
- if (result != NULL)
- return result;
- }
- }
- return NULL;
-}
-
-
-/**
- * Moves nodes within a tree.
- *
- * \param tree the tree to process
- * \param destination the node to link before/as a child (folders)
- * or before/after (link)
- * \param before whether to link siblings before or after the supplied
- * node
- */
-static void tree_move_selected_nodes(struct tree *tree,
- struct node *destination, bool before)
-{
- struct node *link;
- struct node *test;
- bool error;
-
- tree_clear_processing(tree->root);
- tree_selected_to_processing(tree->root);
-
- /* the destination node cannot be a child of any node with
- the processing flag set */
- error = destination->processing;
- for (test = destination; test != NULL; test = test->parent)
- error |= test->processing;
- if (error) {
- tree_clear_processing(tree->root);
- return;
- }
- if ((destination->folder) && (!destination->expanded) && (!before)) {
- tree_set_node_expanded(tree, destination, true, false, false);
- }
- link = tree_move_processing_node(tree, tree->root, destination, before,
- true);
- while (link != NULL)
- link = tree_move_processing_node(tree, tree->root, link, false,
- false);
-
- tree_clear_processing(tree->root);
- tree_recalculate_node_positions(tree, tree->root);
- if (tree->redraw)
- tree->callbacks->redraw_request(0, 0, tree->width, tree->height,
- tree->client_data);
-}
-
-
-/**
- * Handle the end of a drag operation
- *
- * \param tree the tree on which the drag was performed
- * \param mouse mouse state during drag end
- * \param x0 x coordinate of drag start
- * \param y0 y coordinate of drag start
- * \param x1 x coordinate of drag end
- * \param y1 y coordinate of drag end
- */
-void tree_drag_end(struct tree *tree, browser_mouse_state mouse, int x0, int y0,
- int x1, int y1)
-{
-
- bool before;
- struct node *node;
- int x, y;
-
- if (treeview_test_mouse_action(tree, BROWSER_MOUSE_HOVER, x1, y1)) {
- return;
- }
-
- switch (tree->drag) {
- case TREE_NO_DRAG:
- case TREE_UNKNOWN_DRAG:
- break;
-
- case TREE_TEXTAREA_DRAG:
- x = tree->editing->box.x;
- y = tree->editing->box.y;
- if (tree->editing->type == NODE_ELEMENT_TEXT_PLUS_ICON)
- x += NODE_INSTEP;
- textarea_mouse_action(tree->textarea, BROWSER_MOUSE_HOVER,
- x1 - x, y1 - y);
- break;
-
- case TREE_SELECT_DRAG:
- tree_handle_selection_area(tree, y0, y1 - y0,
- (mouse | BROWSER_MOUSE_HOLDING_2));
- break;
-
- case TREE_MOVE_DRAG:
- if (!(tree->flags & TREE_MOVABLE))
- return;
- node = tree_get_link_details(tree, x1, y1, &before);
- tree_move_selected_nodes(tree, node, before);
- break;
- }
-
- tree->drag = TREE_NO_DRAG;
-}
-
-
-/**
- * Key press handling for a tree.
- *
- * \param tree The tree which got the keypress
- * \param key The ucs4 character codepoint
- * \return true if the keypress is dealt with, false otherwise.
- */
-bool tree_keypress(struct tree *tree, uint32_t key)
-{
- if (treeview_test_keypress(tree, key)) {
- return true;
- }
-
- if (tree->editing != NULL)
- switch (key) {
- case KEY_ESCAPE:
- tree_stop_edit(tree, false);
- return true;
- case KEY_NL:
- case KEY_CR:
- tree_stop_edit(tree, true);
- return true;
- default:
- return textarea_keypress(tree->textarea, key);
- }
-
- return false;
-}
-
-
-/**
- * Alphabetical comparison function for nodes
- *
- * \param n1 first node to compare
- * \param n2 first node to compare
- * \return 0 if equal, greater then zero if n1 > n2,
- * less then zero if n2 < n1
- */
-int tree_alphabetical_sort(struct node *n1, struct node *n2)
-{
- return strcmp(n1->data.text, n2->data.text);
-}
-
-
-/**
- * Redraw requests from the textarea are piped through this because we have to
- * check the redraw flag of the tree before requesting a redraw and change the
- * position to tree origin relative.
- */
-
-static void tree_textarea_callback(void *data, struct textarea_msg *msg)
-{
- struct tree *tree = data;
- int x, y;
-
- switch (msg->type) {
- case TEXTAREA_MSG_DRAG_REPORT:
- if (msg->data.drag == TEXTAREA_DRAG_NONE) {
- /* Textarea drag finished */
- tree->drag = TREE_NO_DRAG;
- } else {
- /* Textarea drag started */
- tree->drag = TREE_TEXTAREA_DRAG;
- }
- break;
-
- case TEXTAREA_MSG_REDRAW_REQUEST:
- x = msg->data.redraw.x0 + tree->editing->box.x;
- y = msg->data.redraw.y0 + tree->editing->box.y;
-
- if (tree->editing->type == NODE_ELEMENT_TEXT_PLUS_ICON)
- x += NODE_INSTEP;
-
- /* Redraw the textarea */
- if (tree->redraw)
- tree->callbacks->redraw_request(x, y,
- msg->data.redraw.x1 -
- msg->data.redraw.x0,
- msg->data.redraw.y1 -
- msg->data.redraw.y0,
- tree->client_data);
- break;
-
- default:
- break;
- }
-}
-
-
-/**
- * Starts editing a node_element
- *
- * \param tree The tree to which element belongs
- * \param element The element to start being edited
- */
-void tree_start_edit(struct tree *tree, struct node_element *element)
-{
- struct node *parent;
- int width, height;
- textarea_setup ta_setup;
- textarea_flags ta_flags;
-
- assert(tree != NULL);
- assert(element != NULL);
-
- if (tree->editing != NULL)
- tree_stop_edit(tree, true);
-
- parent = element->parent;
- if (&parent->data == element)
- parent = parent->parent;
- for (; parent != NULL; parent = parent->parent) {
- if (!parent->expanded) {
- tree_set_node_expanded(tree, parent, true,
- false, false);
- }
- }
-
- tree->editing = element;
- tree->callbacks->get_window_dimensions(&width, NULL, tree->client_data);
- width -= element->box.x;
- height = element->box.height;
- if (element->type == NODE_ELEMENT_TEXT_PLUS_ICON)
- width -= NODE_INSTEP;
-
- tree->ta_height = height;
-
- ta_flags = TEXTAREA_INTERNAL_CARET;
-
- ta_setup.width = width;
- ta_setup.height = tree->ta_height;
- ta_setup.pad_top = 0;
- ta_setup.pad_right = 4;
- ta_setup.pad_bottom = 0;
- ta_setup.pad_left = 4;
- ta_setup.border_width = 1;
- ta_setup.border_col = 0x000000;
- ta_setup.selected_text = 0xffffff;
- ta_setup.selected_bg = 0x000000;
- ta_setup.text = plot_fstyle;
- ta_setup.text.foreground = 0x000000;
- ta_setup.text.background = 0xffffff;
-
- tree->textarea = textarea_create(ta_flags, &ta_setup,
- tree_textarea_callback, tree);
- if (tree->textarea == NULL) {
- tree_stop_edit(tree, false);
- return;
- }
- textarea_set_text(tree->textarea, element->text);
-
- tree_handle_node_element_changed(tree, element, true);
- tree_recalculate_size(tree);
- tree->callbacks->scroll_visible(element->box.y, element->box.height,
- tree->client_data);
-}
-
-
-/**
- * Callback for fetchcache(). Should be removed once bitmaps get loaded directly
- * from disc
- */
-static nserror tree_icon_callback(hlcache_handle *handle,
- const hlcache_event *event, void *pw)
-{
- return NSERROR_OK;
-}
-
-
-/**
- * Tree utility function. Placed here so that this code doesn't have to be
- * copied by each user.
- *
- * \param name the name of the loaded icon, if it's not a full path the icon is
- * looked for in the directory specified by tree_icons_dir
- * \return the icon in form of a content or NULL on failure
- */
-hlcache_handle *tree_load_icon(const char *name)
-{
- char *url = NULL;
- const char *icon_url = NULL;
- int len;
- hlcache_handle *c;
- nserror err;
- nsurl *icon_nsurl;
-
- /** @todo something like bitmap_from_disc is needed here */
-
- if (!strncmp(name, "file://", 7)) {
- icon_url = name;
- } else {
- char *native_path;
-
- if (tree_icons_dir == NULL)
- return NULL;
-
- /* path + separator + leafname + '\0' */
- len = strlen(tree_icons_dir) + 1 + strlen(name) + 1;
- native_path = malloc(len);
- if (native_path == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- return NULL;
- }
-
- /* Build native path */
- memcpy(native_path, tree_icons_dir,
- strlen(tree_icons_dir) + 1);
- path_add_part(native_path, len, name);
-
- /* Convert native path to URL */
- url = path_to_url(native_path);
-
- free(native_path);
- icon_url = url;
- }
-
- err = nsurl_create(icon_url, &icon_nsurl);
- if (err != NSERROR_OK) {
- if (url != NULL)
- free(url);
- return NULL;
- }
-
- /* Fetch the icon */
- err = hlcache_handle_retrieve(icon_nsurl, 0, 0, 0,
- tree_icon_callback, 0, 0,
- CONTENT_IMAGE, &c);
-
- nsurl_unref(icon_nsurl);
-
- /* If we built the URL here, free it */
- if (url != NULL)
- free(url);
-
- if (err != NSERROR_OK) {
- return NULL;
- }
-
- return c;
-}
diff --git a/desktop/tree.h b/desktop/tree.h
index 84d90f3..52bea7d 100644
--- a/desktop/tree.h
+++ b/desktop/tree.h
@@ -28,48 +28,22 @@
#include <stdint.h>
#include "desktop/browser.h"
-#include "image/bitmap.h"
struct sslcert_session_data;
extern struct sslcert_session_data *ssl_current_session;
extern const char *tree_hotlist_path;
-
-struct hlcache_handle;
-
/* Tree flags */
enum tree_flags {
- TREE_NO_FLAGS = 0,
- TREE_NO_DRAGS = 1,
- TREE_NO_FURNITURE = 2,
- TREE_SINGLE_SELECT = 4,
- TREE_NO_SELECT = 8,
- TREE_MOVABLE = 16,
- TREE_DELETE_EMPTY_DIRS = 32, /**< if the last child of a
- * directory is deleted the
- * directory will be deleted
- * too.
- */
- /* The following are to aid transition to new treeviews */
- TREE_HISTORY = 64,
- TREE_COOKIES = 128,
- TREE_SSLCERT = 256,
- TREE_HOTLIST = 512
+ TREE_HISTORY,
+ TREE_COOKIES,
+ TREE_SSLCERT,
+ TREE_HOTLIST
};
-/** A "flag" value to indicate the element data contains title
- * text. This value should be the first node_element in every
- * node. All other values should be different than this one. The term
- * flag is misused as it is actually a value used by the API consumer
- * to indicate teh type of data a node element contains.
- */
-#define TREE_ELEMENT_TITLE 0x00
-#define TREE_ELEMENT_LAUNCH_IN_TABS 0x05 /* Launch in tabs instead of windows */
struct tree;
-struct node;
-struct node_element;
typedef enum {
TREE_NO_DRAG = 0,
@@ -79,45 +53,6 @@ typedef enum {
TREE_UNKNOWN_DRAG /** < A drag the tree itself won't handle */
} tree_drag_type;
-typedef enum {
- NODE_ELEMENT_TEXT, /**< Text only */
- NODE_ELEMENT_TEXT_PLUS_ICON, /**< Text and icon */
- NODE_ELEMENT_BITMAP /**< Bitmap only */
-} node_element_type;
-
-typedef enum {
- NODE_DELETE_ELEMENT_TXT, /**< The text of an element of the
- * node is being deleted */
- NODE_DELETE_ELEMENT_IMG, /**< The bitmap or icon of a node is
- * being deleted */
- NODE_LAUNCH, /**< The node has been launched */
- NODE_ELEMENT_EDIT_CANCELLED, /**< Editing opperation cancelled. */
- NODE_ELEMENT_EDIT_FINISHING, /**< New text has to be accepted
- * or rejected. */
- NODE_ELEMENT_EDIT_FINISHED /**< Editing of a node_element has
- * been finished. */
-} node_msg;
-
-typedef enum {
- NODE_CALLBACK_HANDLED,
- NODE_CALLBACK_NOT_HANDLED,
- NODE_CALLBACK_REJECT, /**< reject new text for node element
- * and leave editing mode. */
- NODE_CALLBACK_CONTINUE /**< don't leave editig mode. */
-} node_callback_resp;
-
-/** Internal node message. */
-struct node_msg_data {
- node_msg msg; /**< The type of message. */
- unsigned int flag; /**< message flags. */
- struct node *node; /**< tree node messsage concerns. */
- union {
- char *text; /**< textural data. */
- void *bitmap; /**< bitmap data. */
- struct browser_window *bw; /**< clone browser_window. */
- } data; /**< The message data. */
-};
-
/** callbacks to perform necessary operations on treeview. */
struct treeview_table {
void (*redraw_request)(int x, int y, int width, int height,
@@ -128,123 +63,20 @@ struct treeview_table {
void (*get_window_dimensions)(int *width, int *height, void *data); /**< get dimensions of window */
};
-/**
- * Informs the client about any events requiring his action
- *
- * \param user_data the user data which was passed at tree creation
- * \param msg_data structure containing all the message information
- * \return the appropriate node_callback_resp response
- */
-typedef node_callback_resp (*tree_node_user_callback)(void *user_data,
- struct node_msg_data *msg_data);
-
-/* Non-platform specific code */
-
-void tree_set_icon_dir(char *icon_dir);
-void tree_setup_colours(void);
-
-/* Functions for creating/deleting tree primitives and for tree structure
- manipulation */
struct tree *tree_create(unsigned int flags,
const struct treeview_table *callbacks,
void *client_data);
-/**
- * Creates a folder node with the specified title, and optionally links it into
- * the tree.
- *
- * \param tree the owner tree of 'parent', may be NULL
- * \param parent the parent node, or NULL not to link
- * \param title the node title
- * \param editable if true, the node title will be editable
- * \param retain_in_memory if true, the node will stay in memory after deletion
- * \param deleted if true, the node is created with the deleted flag
- * \return the newly created node or NULL on error.
- */
-struct node *tree_create_folder_node(struct tree *tree, struct node *parent,
- const char *title, bool editable, bool retain_in_memory,
- bool deleted);
-
-/**
- * Creates a leaf node with the specified title, and optionally links it into
- * the tree.
- *
- * \param tree the owner tree of 'parent', may be NULL
- * \param parent the parent node, or NULL not to link
- * \param title the node title.
- * \param editable if true, the node title will be editable
- * \param retain_in_memory if true, the node will stay in memory after deletion
- * \param deleted if true, the node is created with the deleted flag
- * \return the newly created node or NULL on error.
- */
-struct node *tree_create_leaf_node(struct tree *tree, struct node *parent,
- const char *title, bool editable, bool retain_in_memory,
- bool deleted);
-
-struct node_element *tree_create_node_element(struct node *parent,
- node_element_type type, unsigned int flag, bool editable);
-void tree_link_node(struct tree *tree, struct node *link, struct node *node,
- bool before);
-void tree_delink_node(struct tree *tree, struct node *node);
void tree_delete(struct tree *tree);
-void tree_delete_node(struct tree *tree, struct node *node, bool siblings);
-
-/* setters and getters for properties and data */
-void tree_set_node_icon(struct tree *tree, struct node *node,
- struct hlcache_handle *icon);
-void tree_set_node_expanded(struct tree *tree, struct node *node, bool expanded,
- bool folder, bool leaf);
-void tree_set_node_selected(struct tree *tree, struct node *node, bool all,
- bool selected);
-void tree_set_node_selected_at(struct tree *tree, int x, int y, bool selected);
-void tree_set_node_sort_function(struct tree *tree, struct node *node,
- int (*sort) (struct node *, struct node *));
-void tree_set_node_user_callback(struct node *node,
- tree_node_user_callback callback, void *data);
-void tree_set_redraw(struct tree *tree, bool redraw);
-bool tree_get_redraw(struct tree *tree);
-bool tree_node_has_selection(struct node *node);
-bool tree_node_is_deleted(struct node *node);
-bool tree_node_is_folder(struct node *node);
-bool tree_node_is_default(struct node *node);
-void tree_update_node_element(struct tree *tree, struct node_element *element,
- const char *text, void *bitmap);
-bool tree_update_element_text(struct tree *tree, struct node_element *element, char *text);
-const char *tree_node_element_get_text(struct node_element *element);
-struct bitmap *tree_node_element_get_icon(struct node_element *element);
-struct node *tree_get_root(struct tree *tree);
-bool tree_is_edited(struct tree *tree);
tree_drag_type tree_drag_status(struct tree *tree);
-
-struct node *tree_get_default_folder_node(struct tree *tree);
-bool tree_set_default_folder_node(struct tree *tree, struct node *node);
-void tree_clear_default_folder_node(struct tree *tree);
-
-/* functions for traversing the tree */
-struct node *tree_node_get_parent(struct node *node);
-struct node *tree_node_get_child(struct node *node);
-struct node *tree_node_get_next(struct node *node);
-
void tree_draw(struct tree *tree, int x, int y,
int clip_x, int clip_y, int clip_width, int clip_height,
const struct redraw_context *ctx);
-
-struct node_element *tree_node_find_element(struct node *node,
- unsigned int flag, struct node_element *after);
-void tree_delete_selected_nodes(struct tree *tree, struct node *node);
-struct node *tree_get_selected_node(struct node *node);
-struct node *tree_get_link_details(struct tree *tree, int x, int y,
- bool *before);
-void tree_launch_selected(struct tree *tree, bool tabs);
-
bool tree_mouse_action(struct tree *tree, browser_mouse_state mouse,
int x, int y);
void tree_drag_end(struct tree *tree, browser_mouse_state mouse, int x0, int y0,
int x1, int y1);
bool tree_keypress(struct tree *tree, uint32_t key);
-int tree_alphabetical_sort(struct node *, struct node *);
-void tree_start_edit(struct tree *tree, struct node_element *element);
-struct hlcache_handle *tree_load_icon(const char *name);
#endif
diff --git a/gtk/gui.c b/gtk/gui.c
index 6e187a1..1f191d6 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -316,10 +316,6 @@ static void check_options(char **respath)
/* user options should be stored in the users home directory */
snprintf(buf, PATH_MAX, "%s/.netsurf/Choices", hdir);
options_file_location = strdup(buf);
-
- filepath_sfinddef(respath, buf, "icons/", "~/.netsurf/");
- LOG(("Using '%s' as Tree icons dir", buf));
- tree_set_icon_dir(strdup(buf));
filepath_sfinddef(respath, buf, "Print", "~/.netsurf/");
LOG(("Using '%s' as Print Settings file", buf));
diff --git a/gtk/treeview.c b/gtk/treeview.c
index 8a4c73c..8fc53c3 100644
--- a/gtk/treeview.c
+++ b/gtk/treeview.c
@@ -166,7 +166,6 @@ nsgtk_tree_window_draw_event(GtkWidget *widget, cairo_t *cr, gpointer data)
cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
- tree_set_redraw(tree, true);
tree_draw(tree, 0, 0, x1, y1, x2 - x1, y2 - y1, &ctx);
current_widget = NULL;
@@ -196,7 +195,6 @@ nsgtk_tree_window_draw_event(GtkWidget *widget, GdkEventExpose *event, gpointer
current_widget = widget;
current_cr = gdk_cairo_create(nsgtk_widget_get_window(widget));
- tree_set_redraw(tree, true);
tree_draw(tree, 0, 0, x, y, width, height, &ctx);
current_widget = NULL;
@@ -209,11 +207,6 @@ nsgtk_tree_window_draw_event(GtkWidget *widget, GdkEventExpose *event, gpointer
void nsgtk_tree_window_hide(GtkWidget *widget, gpointer g)
{
- struct nsgtk_treeview *tw = g;
- struct tree *tree = tw->tree;
-
- if (tree != NULL)
- tree_set_redraw(tree, false);
}
gboolean nsgtk_tree_window_button_press_event(GtkWidget *widget,
@@ -390,32 +383,26 @@ gboolean nsgtk_tree_window_keypress_event(GtkWidget *widget, GdkEventKey *event,
GtkAdjustment *hscroll;
GtkAdjustment *scroll = NULL;
gdouble hpage, vpage;
- bool edited;
nskey = gtk_gui_gdkkey_to_nskey(event);
-
+
+ if (tree_keypress(tree, nskey) == true)
+ return TRUE;
vscroll = gtk_scrolled_window_get_vadjustment(tw->scrolled);
hscroll = gtk_scrolled_window_get_hadjustment(tw->scrolled);
g_object_get(vscroll, "page-size", &vpage, NULL);
g_object_get(hscroll, "page-size", &hpage, NULL);
-
-
- edited = tree_is_edited(tree);
switch (event->keyval) {
case GDK_KEY(Home):
case GDK_KEY(KP_Home):
- if (edited)
- break;
scroll = vscroll;
value = nsgtk_adjustment_get_lower(scroll);
break;
case GDK_KEY(End):
- case GDK_KEY(KP_End):
- if (edited)
- break;
+ case GDK_KEY(KP_End):
scroll = vscroll;
value = nsgtk_adjustment_get_upper(scroll) - vpage;
if (value < nsgtk_adjustment_get_lower(scroll))
@@ -423,9 +410,7 @@ gboolean nsgtk_tree_window_keypress_event(GtkWidget *widget, GdkEventKey *event,
break;
case GDK_KEY(Left):
- case GDK_KEY(KP_Left):
- if (edited)
- break;
+ case GDK_KEY(KP_Left):
scroll = hscroll;
value = gtk_adjustment_get_value(scroll) -
nsgtk_adjustment_get_step_increment(scroll);
@@ -444,8 +429,6 @@ gboolean nsgtk_tree_window_keypress_event(GtkWidget *widget, GdkEventKey *event,
case GDK_KEY(Right):
case GDK_KEY(KP_Right):
- if (edited)
- break;
scroll = hscroll;
value = gtk_adjustment_get_value(scroll) +
nsgtk_adjustment_get_step_increment(scroll);
@@ -483,16 +466,13 @@ gboolean nsgtk_tree_window_keypress_event(GtkWidget *widget, GdkEventKey *event,
value = nsgtk_adjustment_get_upper(scroll) - vpage;
break;
- default:
- tree_keypress(tree, nskey);
- return TRUE;
+ default:
+ break;
}
if (scroll != NULL)
gtk_adjustment_set_value(scroll, value);
- tree_keypress(tree, nskey);
-
return TRUE;
}
diff --git a/monkey/utils.c b/monkey/utils.c
index c38e9bf..3e09106 100644
--- a/monkey/utils.c
+++ b/monkey/utils.c
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
+#include "utils/config.h"
#include "utils/utils.h"
#include "utils/url.h"
#include "utils/utf8.h"
diff --git a/riscos/cookies.c b/riscos/cookies.c
index c2dcc4e..ea961e2 100644
--- a/riscos/cookies.c
+++ b/riscos/cookies.c
@@ -30,6 +30,7 @@
#include "oslib/wimp.h"
#include "oslib/wimpspriteop.h"
#include "content/urldb.h"
+#include "desktop/cookie_manager.h"
#include "desktop/cookies_old.h"
#include "desktop/tree.h"
#include "riscos/cookies.h"
@@ -165,8 +166,6 @@ void ro_gui_cookies_postinitialise(void)
void ro_gui_cookies_open(void)
{
- tree_set_redraw(ro_treeview_get_tree(cookies_window.tv), true);
-
ro_gui_cookies_toolbar_update_buttons();
if (!ro_gui_dialog_open_top(cookies_window.window,
@@ -220,7 +219,7 @@ void ro_gui_cookies_toolbar_update_buttons(void)
{
ro_toolbar_set_button_shaded_state(cookies_window.toolbar,
TOOLBAR_BUTTON_DELETE,
- !ro_treeview_has_selection(cookies_window.tv));
+ !cookie_manager_has_selection());
}
@@ -256,7 +255,7 @@ bool ro_gui_cookies_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
if (menu != cookies_window.menu)
return false;
- selection = ro_treeview_has_selection(cookies_window.tv);
+ selection = cookie_manager_has_selection();
ro_gui_menu_set_entry_shaded(cookies_window.menu,
TREE_SELECTION, !selection);
diff --git a/riscos/global_history.c b/riscos/global_history.c
index 830f17c..704f804 100644
--- a/riscos/global_history.c
+++ b/riscos/global_history.c
@@ -31,6 +31,7 @@
#include "oslib/wimpspriteop.h"
#include "content/urldb.h"
#include "desktop/history_global_core.h"
+#include "desktop/global_history.h"
#include "desktop/tree.h"
#include "riscos/dialog.h"
#include "riscos/global_history.h"
@@ -171,8 +172,6 @@ void ro_gui_global_history_postinitialise(void)
void ro_gui_global_history_open(void)
{
- tree_set_redraw(ro_treeview_get_tree(global_history_window.tv), true);
-
ro_gui_global_history_toolbar_update_buttons();
if (!ro_gui_dialog_open_top(global_history_window.window,
@@ -230,11 +229,11 @@ void ro_gui_global_history_toolbar_update_buttons(void)
{
ro_toolbar_set_button_shaded_state(global_history_window.toolbar,
TOOLBAR_BUTTON_DELETE,
- !ro_treeview_has_selection(global_history_window.tv));
+ !global_history_has_selection());
ro_toolbar_set_button_shaded_state(global_history_window.toolbar,
TOOLBAR_BUTTON_LAUNCH,
- !ro_treeview_has_selection(global_history_window.tv));
+ !global_history_has_selection());
}
@@ -270,7 +269,7 @@ bool ro_gui_global_history_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
if (menu != global_history_window.menu)
return false;
- selection = ro_treeview_has_selection(global_history_window.tv);
+ selection = global_history_has_selection();
ro_gui_menu_set_entry_shaded(global_history_window.menu,
TREE_SELECTION, !selection);
diff --git a/riscos/gui.c b/riscos/gui.c
index d450b6d..c402b88 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -429,7 +429,6 @@ static void gui_init(int argc, char** argv)
int length;
char *nsdir_temp;
byte *base;
- char *tree_icons_dir;
/* re-enable all FPU exceptions/traps except inexact operations,
* which we're not interested in, and underflow which is incorrectly
@@ -458,12 +457,6 @@ static void gui_init(int argc, char** argv)
ro_plot_patterned_lines = false;
}
- tree_icons_dir = strdup("NetSurf:Resources.Icons");
- if (tree_icons_dir == NULL)
- die("Failed initialising string options");
- tree_set_icon_dir(tree_icons_dir);
-
-
/* Create our choices directories */
ro_gui_create_dirs();
diff --git a/riscos/hotlist.c b/riscos/hotlist.c
index 9b1e9f1..a0a1cf6 100644
--- a/riscos/hotlist.c
+++ b/riscos/hotlist.c
@@ -34,6 +34,7 @@
#include "content/hlcache.h"
#include "content/urldb.h"
#include "desktop/hotlist_old.h"
+#include "desktop/hotlist.h"
#include "desktop/tree.h"
#include "riscos/dialog.h"
#include "riscos/hotlist.h"
@@ -215,8 +216,6 @@ void ro_gui_hotlist_open(void)
error->errmess);
}
- tree_set_redraw(ro_treeview_get_tree(hotlist_window.tv), true);
-
ro_gui_hotlist_toolbar_update_buttons();
if (!ro_gui_dialog_open_top(hotlist_window.window,
@@ -277,11 +276,11 @@ void ro_gui_hotlist_toolbar_update_buttons(void)
{
ro_toolbar_set_button_shaded_state(hotlist_window.toolbar,
TOOLBAR_BUTTON_DELETE,
- !ro_treeview_has_selection(hotlist_window.tv));
+ !hotlist_has_selection());
ro_toolbar_set_button_shaded_state(hotlist_window.toolbar,
TOOLBAR_BUTTON_LAUNCH,
- !ro_treeview_has_selection(hotlist_window.tv));
+ !hotlist_has_selection());
}
@@ -316,7 +315,7 @@ bool ro_gui_hotlist_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
if (menu != hotlist_window.menu)
return false;
- selection = ro_treeview_has_selection(hotlist_window.tv);
+ selection = hotlist_has_selection();
ro_gui_menu_set_entry_shaded(hotlist_window.menu,
TREE_SELECTION, !selection);
diff --git a/riscos/sslcert.c b/riscos/sslcert.c
index 4835817..1395d27 100644
--- a/riscos/sslcert.c
+++ b/riscos/sslcert.c
@@ -158,8 +158,6 @@ void gui_cert_verify(nsurl *url,
return;
}
- tree_set_redraw(ro_treeview_get_tree(sslcert_window->tv), true);
-
/* Set up the certificate window event handling.
*
* (The action buttons are registered as button events, not OK and
diff --git a/riscos/treeview.c b/riscos/treeview.c
index 5d1126b..004091a 100644
--- a/riscos/treeview.c
+++ b/riscos/treeview.c
@@ -284,22 +284,6 @@ wimp_w ro_treeview_get_window(ro_treeview *tv)
}
/**
- * Return an indication of whether the supplied treeview object contains a
- * selection.
- *
- * \param *tv The ro_treeview object of interest.
- * \return true if there is a selection in the tree; else false.
- */
-
-bool ro_treeview_has_selection(ro_treeview *tv)
-{
- if (tv != NULL)
- return tree_node_has_selection(tree_get_root(tv->tree));
- else
- return false;
-}
-
-/**
* Callback to force a redraw of part of the treeview window.
*
* \param x Min X Coordinate of area to be redrawn.
@@ -853,8 +837,8 @@ static bool ro_treeview_mouse_click(wimp_pointer *pointer)
mouse = 0;
if (pointer->buttons == wimp_CLICK_MENU) {
- if (!tree_node_has_selection(tree_get_root(tv->tree)))
- mouse |= BROWSER_MOUSE_CLICK_1;
+ /* TODO: test for no selection, and pass click to select node */
+ /* mouse |= BROWSER_MOUSE_CLICK_1; */
} else {
mouse = ro_gui_mouse_click_state(pointer->buttons,
wimp_BUTTON_DOUBLE_CLICK_DRAG);
diff --git a/riscos/treeview.h b/riscos/treeview.h
index 5491952..0745e00 100644
--- a/riscos/treeview.h
+++ b/riscos/treeview.h
@@ -50,7 +50,6 @@ const struct toolbar_callbacks *ro_treeview_get_toolbar_callbacks(void);
struct tree *ro_treeview_get_tree(ro_treeview *tv);
wimp_w ro_treeview_get_window(ro_treeview *tv);
-bool ro_treeview_has_selection(ro_treeview *tv);
void ro_treeview_set_origin(ro_treeview *tv, int x, int y);
void ro_treeview_mouse_at(wimp_pointer *pointer);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=46e569c481f1c5196fd...
commit 46e569c481f1c5196fd90b05bd801809355f2d84
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Use TREE_HOTLIST directly.
diff --git a/amiga/hotlist.c b/amiga/hotlist.c
index 9b9fd80..daea820 100755
--- a/amiga/hotlist.c
+++ b/amiga/hotlist.c
@@ -57,7 +57,7 @@ void ami_hotlist_add_default_dirs(struct tree *tree)
void ami_hotlist_initialise(const char *hotlist_file)
{
tree_hotlist_path = hotlist_file;
- hotlist_window = ami_tree_create(hotlist_old_get_tree_flags(), NULL);
+ hotlist_window = ami_tree_create(TREE_HOTLIST, NULL);
if(!hotlist_window) return;
diff --git a/atari/hotlist.c b/atari/hotlist.c
index 9a818a3..75732a6 100755
--- a/atari/hotlist.c
+++ b/atari/hotlist.c
@@ -129,7 +129,7 @@ void atari_hotlist_init(void)
gemtk_wm_unlink(hl.window);
tree_hotlist_path = (const char*)&hl.path;
hl.tv = atari_treeview_create(
- hotlist_old_get_tree_flags(),
+ TREE_HOTLIST,
hl.window,
handle_event
);
diff --git a/cocoa/BookmarksController.m b/cocoa/BookmarksController.m
index 7c1d804..28f53b8 100644
--- a/cocoa/BookmarksController.m
+++ b/cocoa/BookmarksController.m
@@ -48,7 +48,7 @@ static const char *cocoa_hotlist_path( void )
{
if ((self = [super initWithWindowNibName: @"BookmarksWindow"]) == nil) return nil;
tree_hotlist_path = cocoa_hotlist_path();
- tree = [[Tree alloc] initWithFlags: hotlist_old_get_tree_flags()];
+ tree = [[Tree alloc] initWithFlags: TREE_HOTLIST];
hotlist_old_initialise( [tree tree], cocoa_hotlist_path(), "directory.png" );
nodeForMenu = NSCreateMapTable( NSNonOwnedPointerMapKeyCallBacks, NSNonOwnedPointerMapValueCallBacks, 0 );
diff --git a/desktop/hotlist_old.c b/desktop/hotlist_old.c
index ad24045..b09ace3 100644
--- a/desktop/hotlist_old.c
+++ b/desktop/hotlist_old.c
@@ -49,17 +49,6 @@ bool hotlist_old_initialise(struct tree *tree, const char *hotlist_path,
/**
- * Get flags with which the hotlist tree should be created;
- *
- * \return the flags
- */
-unsigned int hotlist_old_get_tree_flags(void)
-{
- return TREE_HOTLIST;
-}
-
-
-/**
* Deletes the global history tree and saves the hotlist.
* \param hotlist_path the path where the hotlist should be saved
*/
diff --git a/desktop/hotlist_old.h b/desktop/hotlist_old.h
index 487b336..b063677 100644
--- a/desktop/hotlist_old.h
+++ b/desktop/hotlist_old.h
@@ -39,7 +39,6 @@
*/
bool hotlist_old_initialise(struct tree *tree, const char *hotlist_path, const char* folder_icon_name);
-unsigned int hotlist_old_get_tree_flags(void);
void hotlist_old_cleanup(const char *hotlist_path);
diff --git a/gtk/hotlist.c b/gtk/hotlist.c
index 8a1c815..2975998 100644
--- a/gtk/hotlist.c
+++ b/gtk/hotlist.c
@@ -122,7 +122,7 @@ bool nsgtk_hotlist_init(const char *glade_file_location)
tree_hotlist_path = nsoption_charp(hotlist_path);
- hotlist_window = nsgtk_treeview_create(hotlist_old_get_tree_flags(), window,
+ hotlist_window = nsgtk_treeview_create(TREE_HOTLIST, window,
scrolled, drawing_area);
if (hotlist_window == NULL)
diff --git a/riscos/hotlist.c b/riscos/hotlist.c
index 09f8c71..9b1e9f1 100644
--- a/riscos/hotlist.c
+++ b/riscos/hotlist.c
@@ -131,7 +131,7 @@ void ro_gui_hotlist_postinitialise(void)
tree_hotlist_path = nsoption_charp(hotlist_path);
hotlist_window.tv = ro_treeview_create(hotlist_window.window,
hotlist_window.toolbar, &ro_hotlist_treeview_callbacks,
- hotlist_old_get_tree_flags());
+ TREE_HOTLIST);
if (hotlist_window.tv == NULL) {
LOG(("Failed to allocate treeview"));
return;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=9f35fd3fee6279f0bcd...
commit 9f35fd3fee6279f0bcd4fa0b3758548bbceaf1ab
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Use TREE_HISTORY directly.
diff --git a/amiga/history.c b/amiga/history.c
index cc161d0..23a6a70 100755
--- a/amiga/history.c
+++ b/amiga/history.c
@@ -24,7 +24,7 @@
void ami_global_history_initialise(void)
{
- global_history_window = ami_tree_create(history_global_get_tree_flags(), NULL);
+ global_history_window = ami_tree_create(TREE_HISTORY, NULL);
if(!global_history_window) return;
diff --git a/atari/history.c b/atari/history.c
index fd4e8f5..b17f2c2 100755
--- a/atari/history.c
+++ b/atari/history.c
@@ -117,7 +117,7 @@ bool atari_global_history_init( void )
}
wind_set_str(handle, WF_NAME, (char*)messages_get("GlobalHistory"));
- gl_history.tv = atari_treeview_create(history_global_get_tree_flags(),
+ gl_history.tv = atari_treeview_create(TREE_HISTORY,
gl_history.window, handle_event);
gemtk_wm_unlink(gl_history.window);
diff --git a/cocoa/HistoryWindowController.m b/cocoa/HistoryWindowController.m
index 94fb297..436f786 100644
--- a/cocoa/HistoryWindowController.m
+++ b/cocoa/HistoryWindowController.m
@@ -30,7 +30,7 @@
{
if ((self = [super initWithWindowNibName: @"HistoryWindow"]) == nil) return nil;
- tree = [[Tree alloc] initWithFlags: history_global_get_tree_flags()];
+ tree = [[Tree alloc] initWithFlags: TREE_HISTORY];
history_global_initialise( [tree tree], "directory.png" );
return self;
diff --git a/desktop/history_global_core.c b/desktop/history_global_core.c
index 8c46516..cb889dc 100644
--- a/desktop/history_global_core.c
+++ b/desktop/history_global_core.c
@@ -52,17 +52,6 @@ bool history_global_initialise(struct tree *tree, const char* folder_icon_name)
/**
- * Get flags with which the global history tree should be created;
- *
- * \return the flags
- */
-unsigned int history_global_get_tree_flags(void)
-{
- return TREE_HISTORY;
-}
-
-
-/**
* Deletes the global history tree.
*/
void history_global_cleanup(void)
diff --git a/desktop/history_global_core.h b/desktop/history_global_core.h
index 7b8e682..0e61682 100644
--- a/desktop/history_global_core.h
+++ b/desktop/history_global_core.h
@@ -25,7 +25,6 @@
#include "desktop/tree.h"
bool history_global_initialise(struct tree *tree, const char* folder_icon_name);
-unsigned int history_global_get_tree_flags(void);
void history_global_cleanup(void);
bool history_global_export(const char *path);
diff --git a/gtk/history.c b/gtk/history.c
index e7b0836..ae02823 100644
--- a/gtk/history.c
+++ b/gtk/history.c
@@ -115,8 +115,7 @@ bool nsgtk_history_init(const char *glade_file_location)
drawing_area = GTK_DRAWING_AREA(gtk_builder_get_object(gladeFile, "globalHistoryDrawingArea"));
global_history_window = nsgtk_treeview_create(
- history_global_get_tree_flags(), window, scrolled,
- drawing_area);
+ TREE_HISTORY, window, scrolled, drawing_area);
if (global_history_window == NULL)
return false;
diff --git a/riscos/global_history.c b/riscos/global_history.c
index 8eeb924..830f17c 100644
--- a/riscos/global_history.c
+++ b/riscos/global_history.c
@@ -112,7 +112,7 @@ void ro_gui_global_history_postinitialise(void)
ro_treeview_create(global_history_window.window,
global_history_window.toolbar,
&ro_global_history_treeview_callbacks,
- history_global_get_tree_flags());
+ TREE_HISTORY);
if (global_history_window.tv == NULL) {
LOG(("Failed to allocate treeview"));
return;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=128fdbec438f951348e...
commit 128fdbec438f951348eb70829ab90b423e271d66
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Select TREE_COOKIES directly.
diff --git a/amiga/cookies.c b/amiga/cookies.c
index 05fd9f8..a095a6e 100755
--- a/amiga/cookies.c
+++ b/amiga/cookies.c
@@ -23,7 +23,7 @@
void ami_cookies_initialise(void)
{
- cookies_window = ami_tree_create(cookies_get_tree_flags(), NULL);
+ cookies_window = ami_tree_create(TREE_COOKIES, NULL);
if(!cookies_window) return;
diff --git a/desktop/cookies_old.c b/desktop/cookies_old.c
index c944d35..bd3adec 100644
--- a/desktop/cookies_old.c
+++ b/desktop/cookies_old.c
@@ -58,17 +58,6 @@ bool cookies_initialise(struct tree *tree, const char* folder_icon_name, const c
/**
- * Get flags with which the cookies tree should be created;
- *
- * \return the flags
- */
-unsigned int cookies_get_tree_flags(void)
-{
- return TREE_COOKIES;
-}
-
-
-/**
* Free memory and release all other resources.
*/
void cookies_cleanup(void)
diff --git a/desktop/cookies_old.h b/desktop/cookies_old.h
index 47194ff..78998bc 100644
--- a/desktop/cookies_old.h
+++ b/desktop/cookies_old.h
@@ -28,7 +28,6 @@
#include "desktop/tree.h"
bool cookies_initialise(struct tree *tree, const char* folder_icon_name, const char* cookie_icon_name);
-unsigned int cookies_get_tree_flags(void);
void cookies_cleanup(void);
diff --git a/gtk/cookies.c b/gtk/cookies.c
index 99b2a80..f8b2b7d 100644
--- a/gtk/cookies.c
+++ b/gtk/cookies.c
@@ -112,7 +112,7 @@ bool nsgtk_cookies_init(const char *glade_file_location)
drawing_area = GTK_DRAWING_AREA(gtk_builder_get_object(gladeFile,
"cookiesDrawingArea"));
- cookies_window = nsgtk_treeview_create(cookies_get_tree_flags(), window,
+ cookies_window = nsgtk_treeview_create(TREE_COOKIES, window,
scrolled, drawing_area);
if (cookies_window == NULL)
diff --git a/riscos/cookies.c b/riscos/cookies.c
index 14a1d03..c2dcc4e 100644
--- a/riscos/cookies.c
+++ b/riscos/cookies.c
@@ -107,7 +107,7 @@ void ro_gui_cookies_postinitialise(void)
cookies_window.tv = ro_treeview_create(cookies_window.window,
cookies_window.toolbar, &ro_cookies_treeview_callbacks,
- cookies_get_tree_flags());
+ TREE_COOKIES);
if (cookies_window.tv == NULL) {
LOG(("Failed to allocate treeview"));
return;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=5c7ca39ada083e74ba9...
commit 5c7ca39ada083e74ba93549efe71c67c906d91bc
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Remove tree_url_node module. Had to disable treeview scanning in amiga and cocoa front ends. Amiga front end very likely broken.
diff --git a/amiga/context_menu.c b/amiga/context_menu.c
index e7bbe62..4d4d73a 100644
--- a/amiga/context_menu.c
+++ b/amiga/context_menu.c
@@ -44,7 +44,6 @@
#include "desktop/hotlist_old.h"
#include "desktop/searchweb.h"
#include "desktop/textinput.h"
-#include "desktop/tree_url_node.h"
#include "render/form.h"
#include "utils/utf8.h"
#include "utils/messages.h"
@@ -1220,11 +1219,11 @@ static uint32 ami_context_menu_hook_tree(struct Hook *hook, Object *item, APTR r
break;
case CMID_TREE_EDITTITLE:
- tree_url_node_edit_title(tree, userdata);
+ warn_user("TODO.", 0);
break;
case CMID_TREE_EDITLINK:
- tree_url_node_edit_url(tree, userdata);
+ warn_user("TODO.", 0);
break;
case CMID_TREE_NEWFOLDER:
@@ -1236,15 +1235,15 @@ static uint32 ami_context_menu_hook_tree(struct Hook *hook, Object *item, APTR r
break;
case CMID_TREE_SETDEFAULT:
- hotlist_old_set_default_folder(false);
+ warn_user("TODO.", 0);
break;
case CMID_TREE_CLEARDEFAULT:
- hotlist_old_set_default_folder(true);
+ warn_user("TODO.", 0);
break;
case CMID_TREE_ADDHOTLIST:
- hotlist_old_add_page(tree_url_node_get_url(userdata));
+ warn_user("TODO.", 0);
break;
case CMID_TREE_DELETE:
diff --git a/amiga/gui.c b/amiga/gui.c
index f60e478..d18e410 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -29,7 +29,6 @@
#include "desktop/searchweb.h"
#include "desktop/textinput.h"
#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
#include "image/ico.h"
#include "utils/log.h"
#include "utils/messages.h"
@@ -2857,6 +2856,7 @@ void ami_update_buttons(struct gui_window_2 *gwin)
void ami_gui_hotlist_scan_2(struct tree *tree, struct node *root, WORD *gen, int *item,
struct List *speed_button_list, struct gui_window_2 *gwin)
{
+#if 0
struct node *tempnode;
struct node_element *element=NULL;
struct node *node;
@@ -2889,10 +2889,12 @@ void ami_gui_hotlist_scan_2(struct tree *tree, struct node *root, WORD *gen, int
}
*gen = *gen - 1;
+#endif
}
int ami_gui_hotlist_scan(struct tree *tree, struct List *speed_button_list, struct gui_window_2 *gwin)
{
+#if 0
struct node *root = tree_node_get_child(tree_get_root(tree));
struct node *node;
struct node_element *element;
@@ -2910,6 +2912,9 @@ int ami_gui_hotlist_scan(struct tree *tree, struct List *speed_button_list, stru
}
return item;
+#else
+ return 0;
+#endif
}
void ami_gui_hotlist_toolbar_add(struct gui_window_2 *gwin)
diff --git a/amiga/menu.c b/amiga/menu.c
index 6d8c5eb..f114253 100644
--- a/amiga/menu.c
+++ b/amiga/menu.c
@@ -58,7 +58,6 @@
#include "amiga/theme.h"
#include "amiga/tree.h"
#include "amiga/utf8.h"
-#include "desktop/tree_url_node.h"
#include "desktop/hotlist_old.h"
#include "desktop/browser_private.h"
#include "desktop/gui.h"
@@ -540,6 +539,7 @@ void ami_menu_arexx_scan(struct gui_window_2 *gwin)
ULONG ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin)
{
+#if 0
struct node *root = tree_node_get_child(tree_get_root(tree));
struct node *node;
struct node_element *element;
@@ -560,11 +560,15 @@ ULONG ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin)
}
return(item - AMI_MENU_HOTLIST);
+#else
+ return 0;
+#endif
}
void ami_menu_scan_2(struct tree *tree, struct node *root, WORD *gen,
int *item, struct gui_window_2 *gwin)
{
+#if 0
struct node *tempnode;
struct node_element *element=NULL;
struct node *node;
@@ -602,6 +606,7 @@ void ami_menu_scan_2(struct tree *tree, struct node *root, WORD *gen,
}
*gen = *gen - 1;
+#endif
}
void ami_menu_update_checked(struct gui_window_2 *gwin)
diff --git a/amiga/tree.c b/amiga/tree.c
index 478000b..0515f70 100644
--- a/amiga/tree.c
+++ b/amiga/tree.c
@@ -59,7 +59,6 @@
#include "desktop/history_global_core.h"
#include "desktop/hotlist_old.h"
#include "desktop/sslcert_viewer.h"
-#include "desktop/tree_url_node.h"
#include "utils/utils.h"
#include "utils/messages.h"
@@ -194,18 +193,6 @@ void ami_tree_get_window_dimensions(int *width, int *height, void *data)
}
/**
- * Translates a content_type to the name of a respective icon
- *
- * \param content_type content type
- * \param buffer buffer for the icon name
- */
-void tree_icon_name_from_content_type(char *buffer, content_type type)
-{
- const char *ftype = ami_content_type_to_file_type(type);
- sprintf(buffer, "def_%s.info", ftype);
-}
-
-/**
* Scrolls the tree to make an element visible
*
* \param y Y coordinate of the element
diff --git a/atari/history.c b/atari/history.c
index 5501b90..fd4e8f5 100755
--- a/atari/history.c
+++ b/atari/history.c
@@ -24,7 +24,6 @@
#include "desktop/browser.h"
#include "utils/nsoption.h"
#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
#include "desktop/gui.h"
#include "desktop/history_global_core.h"
#include "desktop/browser.h"
diff --git a/atari/hotlist.c b/atari/hotlist.c
index 6c80db3..9a818a3 100755
--- a/atari/hotlist.c
+++ b/atari/hotlist.c
@@ -30,7 +30,6 @@
#include "utils/nsoption.h"
#include "desktop/hotlist_old.h"
#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
#include "desktop/gui.h"
#include "utils/log.h"
#include "utils/messages.h"
diff --git a/atari/treeview.c b/atari/treeview.c
index 261b2ee..97fe8a9 100755
--- a/atari/treeview.c
+++ b/atari/treeview.c
@@ -27,7 +27,6 @@
#include "desktop/plotters.h"
#include "desktop/textinput.h"
#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
#include "desktop/textinput.h"
#include "utils/log.h"
#include "utils/messages.h"
@@ -527,23 +526,3 @@ void atari_treeview_get_dimensions(int *width, int *height,
*height = work.g_h;
}
}
-
-
-/**
- * Translates a content_type to the name of a respective icon
- *
- * \param content_type content type
- * \param buffer buffer for the icon name
- */
-void tree_icon_name_from_content_type(char *buffer, content_type type)
-{
- switch (type) {
- case CONTENT_HTML:
- case CONTENT_TEXTPLAIN:
- case CONTENT_CSS:
- case CONTENT_IMAGE:
- default:
- strcpy( buffer, "content.png" );
- break;
- }
-}
diff --git a/beos/treeview.cpp b/beos/treeview.cpp
index 4728995..f3d3d35 100644
--- a/beos/treeview.cpp
+++ b/beos/treeview.cpp
@@ -26,7 +26,6 @@
extern "C" {
#include "utils/config.h"
#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
}
const char tree_directory_icon_name[] = "directory.png";
@@ -34,23 +33,3 @@ const char tree_content_icon_name[] = "content.png";
-
-/**
- * Translates a content_type to the name of a respective icon
- *
- * \param content_type content type
- * \param buffer buffer for the icon name
- */
-void tree_icon_name_from_content_type(char *buffer, content_type type)
-{
- // TODO: design/acquire icons
- switch (type) {
- case CONTENT_HTML:
- case CONTENT_TEXTPLAIN:
- case CONTENT_CSS:
- case CONTENT_IMAGE:
- default:
- sprintf(buffer, tree_content_icon_name);
- break;
- }
-}
diff --git a/cocoa/BookmarksController.m b/cocoa/BookmarksController.m
index a2c5a45..7c1d804 100644
--- a/cocoa/BookmarksController.m
+++ b/cocoa/BookmarksController.m
@@ -26,7 +26,6 @@
#import "desktop/browser_private.h"
#import "desktop/hotlist_old.h"
#import "desktop/tree.h"
-#import "desktop/tree_url_node.h"
#import "utils/messages.h"
@interface BookmarksController ()
@@ -85,6 +84,7 @@ static const char *cocoa_hotlist_path( void )
- (void) menuNeedsUpdate: (NSMenu *)menu
{
+#if 0
for (NSMenuItem *item in [menu itemArray]) {
if ([item hasSubmenu]) NSMapRemove( nodeForMenu, [item submenu] );
[menu removeItem: item];
@@ -125,6 +125,7 @@ static const char *cocoa_hotlist_path( void )
[item setAction: @selector( openBookmarkURL: )];
}
}
+#endif
}
- (IBAction) openBookmarkURL: (id) sender;
diff --git a/cocoa/utils.m b/cocoa/utils.m
index 0e10b9b..cd9313d 100644
--- a/cocoa/utils.m
+++ b/cocoa/utils.m
@@ -19,7 +19,6 @@
#import <Cocoa/Cocoa.h>
#import "utils/utils.h"
-#import "desktop/tree_url_node.h"
#define UNIMPL() NSLog( @"Function '%s' unimplemented", __func__ )
@@ -55,12 +54,3 @@ bool path_add_part(char *path, int length, const char *newpart)
return true;
}
-
-void tree_icon_name_from_content_type(char *buffer, content_type type)
-{
- switch (type) {
- default:
- strcpy( buffer, "content.png" );
- break;
- }
-}
\ No newline at end of file
diff --git a/desktop/Makefile b/desktop/Makefile
index 4ba2b85..8dccc22 100644
--- a/desktop/Makefile
+++ b/desktop/Makefile
@@ -3,7 +3,7 @@
S_DESKTOP := cookie_manager.c cookies_old.c history_global_core.c hotlist_old.c knockout.c \
hotlist.c mouse.c plot_style.c print.c search.c searchweb.c \
scrollbar.c sslcert_viewer.c textarea.c thumbnail.c tree.c \
- tree_url_node.c version.c system_colour.c global_history.c treeview.c
+ version.c system_colour.c global_history.c treeview.c
S_DESKTOP := $(addprefix desktop/,$(S_DESKTOP))
diff --git a/desktop/history_global_core.c b/desktop/history_global_core.c
index 5bf43f1..8c46516 100644
--- a/desktop/history_global_core.c
+++ b/desktop/history_global_core.c
@@ -28,7 +28,6 @@
#include "desktop/global_history.h"
#include "desktop/plotters.h"
#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/log.h"
diff --git a/desktop/hotlist_old.c b/desktop/hotlist_old.c
index 861658d..ad24045 100644
--- a/desktop/hotlist_old.c
+++ b/desktop/hotlist_old.c
@@ -30,7 +30,6 @@
#include "desktop/plotters.h"
#include "desktop/textinput.h"
#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
#include "utils/messages.h"
#include "utils/utils.h"
diff --git a/desktop/tree_url_node.c b/desktop/tree_url_node.c
deleted file mode 100644
index 241a106..0000000
--- a/desktop/tree_url_node.c
+++ /dev/null
@@ -1,972 +0,0 @@
-/*
- * Copyright 2005 Richard Wilson <info(a)tinct.net>
- * Copyright 2009 Paul Blokus <paul_pl(a)users.sourceforge.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/** \file
- * Creation of URL nodes with use of trees (implementation)
- */
-
-
-#include <assert.h>
-#include <ctype.h>
-
-#include <dom/dom.h>
-#include <dom/bindings/hubbub/parser.h>
-
-#include "content/content.h"
-#include "content/hlcache.h"
-#include "content/urldb.h"
-#include "desktop/browser.h"
-#include "utils/nsoption.h"
-#include "desktop/tree_url_node.h"
-#include "utils/corestrings.h"
-#include "utils/libdom.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/url.h"
-#include "utils/utf8.h"
-#include "utils/utils.h"
-
-/** Flags for each type of url tree node. */
-enum tree_element_url {
- TREE_ELEMENT_URL = 0x01,
- TREE_ELEMENT_LAST_VISIT = 0x02,
- TREE_ELEMENT_VISITS = 0x03,
- TREE_ELEMENT_THUMBNAIL = 0x04,
-};
-
-#define MAX_ICON_NAME_LEN 256
-
-static bool initialised = false;
-
-static hlcache_handle *folder_icon;
-
-struct icon_entry {
- content_type type;
- hlcache_handle *icon;
-};
-
-struct icon_entry icon_table[] = {
- {CONTENT_HTML, NULL},
- {CONTENT_TEXTPLAIN, NULL},
- {CONTENT_CSS, NULL},
- {CONTENT_IMAGE, NULL},
- {CONTENT_NONE, NULL},
-
- /* this serves as a sentinel */
- {CONTENT_HTML, NULL}
-};
-
-static uint32_t tun_users = 0;
-
-void tree_url_node_init(const char *folder_icon_name)
-{
- struct icon_entry *entry;
- char icon_name[MAX_ICON_NAME_LEN];
-
- tun_users++;
-
- if (initialised)
- return;
- initialised = true;
-
- folder_icon = tree_load_icon(folder_icon_name);
-
- entry = icon_table;
- do {
-
- tree_icon_name_from_content_type(icon_name, entry->type);
- entry->icon = tree_load_icon(icon_name);
-
- ++entry;
- } while (entry->type != CONTENT_HTML);
-}
-
-
-void tree_url_node_cleanup()
-{
- struct icon_entry *entry;
-
- tun_users--;
-
- if (tun_users > 0)
- return;
-
- if (!initialised)
- return;
- initialised = false;
-
- hlcache_handle_release(folder_icon);
-
- entry = icon_table;
- do {
- hlcache_handle_release(entry->icon);
- ++entry;
- } while (entry->type != CONTENT_HTML);
-}
-
-/**
- * Creates a tree entry for a URL, and links it into the tree
- *
- * \param parent the node to link to
- * \param url the URL (copied)
- * \param data the URL data to use
- * \param title custom title to use or NULL to use url
- * \return the node created, or NULL for failure
- */
-struct node *tree_create_URL_node(struct tree *tree, struct node *parent,
- nsurl *url, const char *title,
- tree_node_user_callback user_callback, void *callback_data)
-{
- struct node *node = NULL;
- struct node_element *element;
-
- if (title == NULL) {
- node = tree_create_leaf_node(tree,
- parent,
- nsurl_access(url),
- true, false, false);
- } else {
- char *squashed;
-
- squashed = squash_whitespace(title);
- if (squashed != NULL) {
- node = tree_create_leaf_node(tree,
- parent,
- squashed,
- true, false, false);
- free(squashed);
- }
- }
- if (node == NULL) {
- return NULL;
- }
-
- if (user_callback != NULL) {
- tree_set_node_user_callback(node, user_callback,
- callback_data);
- }
-
- tree_create_node_element(node, NODE_ELEMENT_BITMAP,
- TREE_ELEMENT_THUMBNAIL, false);
- tree_create_node_element(node, NODE_ELEMENT_TEXT, TREE_ELEMENT_VISITS,
- false);
- tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_LAST_VISIT, false);
- element = tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_URL, true);
- if (element != NULL) {
- char *text_cp = strdup(nsurl_access(url));
- if (text_cp == NULL) {
- tree_delete_node(tree, node, false);
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- return NULL;
- }
- tree_update_node_element(tree, element, text_cp, NULL);
- }
-
- return node;
-}
-
-
-/**
- * Creates a read only tree entry for a URL, and links it into the tree.
- *
- * \param parent the node to link to
- * \param url the URL
- * \param data the URL data to use
- * \return the node created, or NULL for failure
- */
-struct node *tree_create_URL_node_readonly(struct tree *tree,
- struct node *parent, nsurl *url,
- const struct url_data *data,
- tree_node_user_callback user_callback, void *callback_data)
-{
- struct node *node;
- struct node_element *element;
- const char *title;
-
- assert(url && data);
-
- if (data->title != NULL) {
- title = data->title;
- } else {
- title = nsurl_access(url);
- }
-
- node = tree_create_leaf_node(tree, parent, title, false, false, false);
- if (node == NULL) {
- return NULL;
- }
-
- if (user_callback != NULL) {
- tree_set_node_user_callback(node, user_callback,
- callback_data);
- }
-
- tree_create_node_element(node, NODE_ELEMENT_BITMAP,
- TREE_ELEMENT_THUMBNAIL, false);
- tree_create_node_element(node, NODE_ELEMENT_TEXT, TREE_ELEMENT_VISITS,
- false);
- tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_LAST_VISIT, false);
- element = tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_URL, false);
- if (element != NULL) {
- tree_update_node_element(tree, element, nsurl_access(url),
- NULL);
- }
-
- tree_update_URL_node(tree, node, url, data);
-
- return node;
-}
-
-
-/**
- * Updates the node details for a URL node.
- *
- * \param node the node to update
- */
-void tree_update_URL_node(struct tree *tree, struct node *node,
- nsurl *url, const struct url_data *data)
-{
- struct node_element *element;
- struct bitmap *bitmap = NULL;
- struct icon_entry *entry;
- char *text_cp;
-
- assert(node != NULL);
-
- element = tree_node_find_element(node, TREE_ELEMENT_URL, NULL);
- if (element == NULL)
- return;
-
- if (data != NULL) {
- if (data->title == NULL)
- urldb_set_url_title(url, nsurl_access(url));
-
- if (data->title == NULL)
- return;
-
- element = tree_node_find_element(node, TREE_ELEMENT_TITLE,
- NULL);
-
- text_cp = strdup(data->title);
- if (text_cp == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- return;
- }
- tree_update_node_element(tree, element, text_cp, NULL);
- } else {
- data = urldb_get_url_data(url);
- if (data == NULL)
- return;
- }
-
- entry = icon_table;
- do {
- if (entry->type == data->type) {
- if (entry->icon != NULL)
- tree_set_node_icon(tree, node, entry->icon);
- break;
- }
- ++entry;
- } while (entry->type != CONTENT_HTML);
-
- /* update last visit text */
- element = tree_node_find_element(node, TREE_ELEMENT_LAST_VISIT, element);
- tree_update_element_text(tree,
- element,
- messages_get_buff("TreeLast",
- (data->last_visit > 0) ?
- ctime((time_t *)&data->last_visit) :
- messages_get("TreeUnknown")));
-
-
- /* update number of visits text */
- element = tree_node_find_element(node, TREE_ELEMENT_VISITS, element);
- tree_update_element_text(tree,
- element,
- messages_get_buff("TreeVisits", data->visits));
-
-
- /* update thumbnail */
- element = tree_node_find_element(node, TREE_ELEMENT_THUMBNAIL, element);
- if (element != NULL) {
- bitmap = urldb_get_thumbnail(url);
-
- if (bitmap != NULL) {
- tree_update_node_element(tree, element, NULL, bitmap);
- }
- }
-}
-
-
-const char *tree_url_node_get_title(struct node *node)
-{
- struct node_element *element;
- element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
- if (element == NULL)
- return NULL;
- return tree_node_element_get_text(element);
-}
-
-
-const char *tree_url_node_get_url(struct node *node)
-{
- struct node_element *element;
- element = tree_node_find_element(node, TREE_ELEMENT_URL, NULL);
- if (element == NULL)
- return NULL;
- return tree_node_element_get_text(element);
-}
-
-
-struct bitmap *tree_url_node_get_icon(struct node *node)
-{
- struct node_element *element;
- element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
- if (element == NULL)
- return NULL;
- return tree_node_element_get_icon(element);
-}
-
-
-void tree_url_node_edit_title(struct tree *tree, struct node *node)
-{
- struct node_element *element;
- element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
- tree_start_edit(tree, element);
-}
-
-void tree_url_node_edit_url(struct tree *tree, struct node *node)
-{
- struct node_element *element;
- element = tree_node_find_element(node, TREE_ELEMENT_URL, NULL);
- tree_start_edit(tree, element);
-}
-
-node_callback_resp tree_url_node_callback(void *user_data,
- struct node_msg_data *msg_data)
-{
- struct tree *tree;
- struct node_element *element;
- nsurl *url;
- nserror error;
- const char *text;
- char *norm_text;
- const struct url_data *data;
-
- /** @todo memory leaks on non-shared folder deletion. */
- switch (msg_data->msg) {
- case NODE_DELETE_ELEMENT_TXT:
- switch (msg_data->flag) {
- /* only history is using non-editable url
- * elements so only history deletion will run
- * this code
- */
- case TREE_ELEMENT_URL:
- /* reset URL characteristics */
- error = nsurl_create(msg_data->data.text, &url);
- if (error != NSERROR_OK) {
- warn_user("NoMemory", 0);
- return NODE_CALLBACK_REJECT;
- }
- urldb_reset_url_visit_data(url);
- nsurl_unref(url);
- return NODE_CALLBACK_HANDLED;
- case TREE_ELEMENT_TITLE:
- return NODE_CALLBACK_HANDLED;
- }
- break;
- case NODE_DELETE_ELEMENT_IMG:
- if (msg_data->flag == TREE_ELEMENT_THUMBNAIL ||
- msg_data->flag == TREE_ELEMENT_TITLE)
- return NODE_CALLBACK_HANDLED;
- break;
- case NODE_LAUNCH:
- element = tree_node_find_element(msg_data->node,
- TREE_ELEMENT_URL, NULL);
- if (element != NULL) {
- nserror error;
- enum browser_window_nav_flags flags;
-
- text = tree_node_element_get_text(element);
-
- error = nsurl_create(text, &url);
- if (error == NSERROR_OK) {
- struct browser_window *clone = NULL;
-
- flags = BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY;
- if (msg_data->flag == TREE_ELEMENT_LAUNCH_IN_TABS) {
- flags |= BROWSER_WINDOW_TAB;
- clone = msg_data->data.bw;
- }
- error = browser_window_create(flags,
- url,
- NULL,
- clone,
- &msg_data->data.bw);
- nsurl_unref(url);
- }
- if (error != NSERROR_OK) {
- warn_user(messages_get_errorcode(error), 0);
- }
-
- return NODE_CALLBACK_HANDLED;
- }
- break;
-
- case NODE_ELEMENT_EDIT_FINISHING:
-
- text = msg_data->data.text;
-
- if (msg_data->flag == TREE_ELEMENT_URL) {
- size_t len;
- error = nsurl_create(text, &url);
- if (error != NSERROR_OK) {
- warn_user("NoMemory", 0);
- return NODE_CALLBACK_REJECT;
- }
- error = nsurl_get(url, NSURL_WITH_FRAGMENT,
- &norm_text, &len);
- if (error != NSERROR_OK) {
- warn_user("NoMemory", 0);
- return NODE_CALLBACK_REJECT;
- }
-
- msg_data->data.text = norm_text;
-
- data = urldb_get_url_data(url);
- if (data == NULL) {
- urldb_add_url(url);
- urldb_set_url_persistence(url, true);
- data = urldb_get_url_data(url);
- if (data == NULL) {
- nsurl_unref(url);
- return NODE_CALLBACK_REJECT;
- }
- }
- tree = user_data;
- tree_update_URL_node(tree, msg_data->node,
- url, NULL);
- nsurl_unref(url);
- }
- else if (msg_data->flag == TREE_ELEMENT_TITLE) {
- while (isspace(*text))
- text++;
- norm_text = strdup(text);
- if (norm_text == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- return NODE_CALLBACK_REJECT;
- }
- /* don't allow zero length entry text, return
- false */
- if (norm_text[0] == '\0') {
- warn_user("NoNameError", 0);
- msg_data->data.text = NULL;
- return NODE_CALLBACK_CONTINUE;
- }
- msg_data->data.text = norm_text;
- }
-
- return NODE_CALLBACK_HANDLED;
- default:
- break;
- }
- return NODE_CALLBACK_NOT_HANDLED;
-}
-
-typedef struct {
- struct tree *tree;
- struct node *directory;
- tree_node_user_callback callback;
- void *callback_data;
- bool last_was_h4;
- dom_string *title;
-} tree_url_load_ctx;
-
-static void tree_url_load_directory(dom_node *ul, tree_url_load_ctx *ctx);
-
-/**
- * Parse an entry represented as a li.
- *
- * \param li DOM node for parsed li
- * \param directory directory to add this entry to
- */
-static void tree_url_load_entry(dom_node *li, tree_url_load_ctx *ctx)
-{
- dom_node *a;
- dom_string *title1;
- dom_string *url1;
- char *title, *url2;
- nsurl *url;
- const struct url_data *data;
- struct node *entry;
- dom_exception derror;
- nserror error;
-
- /* The li must contain an "a" element */
- a = libdom_find_first_element(li, corestring_lwc_a);
- if (a == NULL) {
- warn_user("TreeLoadError", "(Missing <a> in <li>)");
- return;
- }
-
- derror = dom_node_get_text_content(a, &title1);
- if (derror != DOM_NO_ERR) {
- warn_user("TreeLoadError", "(No title)");
- dom_node_unref(a);
- return;
- }
-
- derror = dom_element_get_attribute(a, corestring_dom_href, &url1);
- if (derror != DOM_NO_ERR || url1 == NULL) {
- warn_user("TreeLoadError", "(No URL)");
- dom_string_unref(title1);
- dom_node_unref(a);
- return;
- }
-
- if (title1 != NULL) {
- title = strndup(dom_string_data(title1),
- dom_string_byte_length(title1));
- dom_string_unref(title1);
- } else {
- title = strdup("");
- }
- if (title == NULL) {
- warn_user("NoMemory", NULL);
- dom_string_unref(url1);
- dom_node_unref(a);
- return;
- }
-
- /* We're loading external input.
- * This may be garbage, so attempt to normalise via nsurl
- */
- url2 = strndup(dom_string_data(url1), dom_string_byte_length(url1));
- if (url2 == NULL) {
- warn_user("NoMemory", NULL);
- free(title);
- dom_string_unref(url1);
- dom_node_unref(a);
- return;
- }
-
- dom_string_unref(url1);
-
- error = nsurl_create(url2, &url);
-
- if (error != NSERROR_OK) {
- LOG(("Failed normalising '%s'", url2));
-
- free(url2);
-
- warn_user(messages_get_errorcode(error), NULL);
-
- free(title);
- dom_node_unref(a);
-
- return;
- }
-
- free(url2);
-
- data = urldb_get_url_data(url);
- if (data == NULL) {
- /* No entry in database, so add one */
- urldb_add_url(url);
- /* now attempt to get url data */
- data = urldb_get_url_data(url);
- }
- if (data == NULL) {
- nsurl_unref(url);
- free(title);
- dom_node_unref(a);
-
- return;
- }
-
- /* Make this URL persistent */
- urldb_set_url_persistence(url, true);
-
- /* Force the title in the hotlist */
- urldb_set_url_title(url, title);
-
- entry = tree_create_URL_node(ctx->tree, ctx->directory, url, title,
- ctx->callback, ctx->callback_data);
-
- if (entry == NULL) {
- /** \todo why isn't this fatal? */
- warn_user("NoMemory", 0);
- } else {
- tree_update_URL_node(ctx->tree, entry, url, data);
- }
-
- nsurl_unref(url);
- free(title);
- dom_node_unref(a);
-}
-
-static nserror tree_url_load_directory_cb(dom_node *node, void *ctx)
-{
- /* TODO: return appropriate errors */
- tree_url_load_ctx *tctx = ctx;
- dom_string *name;
- dom_exception error;
-
- /* The ul may contain entries as a li, or directories as
- * an h4 followed by a ul. Non-element nodes may be present
- * (eg. text, comments), and are ignored. */
-
- error = dom_node_get_node_name(node, &name);
- if (error != DOM_NO_ERR || name == NULL)
- return NSERROR_NOMEM;
-
- if (dom_string_caseless_lwc_isequal(name, corestring_lwc_li)) {
- /* entry */
- tree_url_load_entry(node, tctx);
- tctx->last_was_h4 = false;
- } else if (dom_string_caseless_lwc_isequal(name, corestring_lwc_h4)) {
- /* directory (a) */
- dom_string *title;
-
- error = dom_node_get_text_content(node, &title);
- if (error != DOM_NO_ERR || title == NULL) {
- warn_user("TreeLoadError", "(Empty <h4> "
- "or memory exhausted.)");
- dom_string_unref(name);
- return NSERROR_NOMEM;
- }
-
- if (tctx->title != NULL)
- dom_string_unref(tctx->title);
- tctx->title = title;
- tctx->last_was_h4 = true;
- } else if (tctx->last_was_h4 && dom_string_caseless_lwc_isequal(name,
- corestring_lwc_ul)) {
- /* directory (b) */
- dom_string *id;
- bool dir_is_default;
- struct node *dir;
- char *title;
- tree_url_load_ctx new_ctx;
-
- error = dom_element_get_attribute(node, corestring_dom_id, &id);
- if (error != DOM_NO_ERR) {
- dom_string_unref(name);
- return NSERROR_NOMEM;
- }
-
- if (id != NULL) {
- dir_is_default = dom_string_caseless_lwc_isequal(id,
- corestring_lwc_default);
-
- dom_string_unref(id);
- } else {
- dir_is_default = false;
- }
-
- title = strndup(dom_string_data(tctx->title),
- dom_string_byte_length(tctx->title));
- if (title == NULL) {
- dom_string_unref(name);
- return NSERROR_NOMEM;
- }
-
- dir = tree_create_folder_node(tctx->tree, tctx->directory,
- title, true, false, false);
- free(title);
- if (dir == NULL) {
- dom_string_unref(name);
- return NSERROR_NOMEM;
- }
-
- if (dir_is_default)
- tree_set_default_folder_node(tctx->tree, dir);
-
- if (tctx->callback != NULL)
- tree_set_node_user_callback(dir, tctx->callback,
- tctx->callback_data);
-
- if (folder_icon != NULL)
- tree_set_node_icon(tctx->tree, dir, folder_icon);
-
- new_ctx.tree = tctx->tree;
- new_ctx.directory = dir;
- new_ctx.callback = tctx->callback;
- new_ctx.callback_data = tctx->callback_data;
- new_ctx.last_was_h4 = false;
- new_ctx.title = NULL;
-
- tree_url_load_directory(node, &new_ctx);
-
- if (new_ctx.title != NULL) {
- dom_string_unref(new_ctx.title);
- new_ctx.title = NULL;
- }
- tctx->last_was_h4 = false;
- } else {
- tctx->last_was_h4 = false;
- }
-
- dom_string_unref(name);
-
- return NSERROR_OK;
-}
-
-/**
- * Parse a directory represented as a ul.
- *
- * \param ul DOM node for parsed ul
- * \param directory directory to add this directory to
- */
-static void tree_url_load_directory(dom_node *ul, tree_url_load_ctx *ctx)
-{
- assert(ul != NULL);
- assert(ctx != NULL);
- assert(ctx->directory != NULL);
-
- libdom_iterate_child_elements(ul, tree_url_load_directory_cb, ctx);
-}
-
-/**
- * Loads an url tree from a specified file.
- *
- * \param filename name of file to read
- * \param tree empty tree which data will be read into
- * \return the file represented as a tree, or NULL on failure
- */
-bool tree_urlfile_load(const char *filename, struct tree *tree,
- tree_node_user_callback callback, void *callback_data)
-{
- dom_document *document;
- dom_node *html, *body, *ul;
- struct node *root;
- nserror error;
- tree_url_load_ctx ctx;
-
- if (filename == NULL) {
- return false;
- }
-
- error = libdom_parse_file(filename, "iso-8859-1", &document);
- if (error != NSERROR_OK) {
- if (error != NSERROR_NOT_FOUND) {
- warn_user("TreeLoadError", messages_get("ParsingFail"));
- }
- return false;
- }
-
- html = libdom_find_first_element((dom_node *) document,
- corestring_lwc_html);
- if (html == NULL) {
- dom_node_unref(document);
- warn_user("TreeLoadError", "(<html> not found)");
- return false;
- }
-
- body = libdom_find_first_element(html, corestring_lwc_body);
- if (body == NULL) {
- dom_node_unref(html);
- dom_node_unref(document);
- warn_user("TreeLoadError", "(<html>...<body> not found)");
- return false;
- }
-
- ul = libdom_find_first_element(body, corestring_lwc_ul);
- if (ul == NULL) {
- dom_node_unref(body);
- dom_node_unref(html);
- dom_node_unref(document);
- warn_user("TreeLoadError",
- "(<html>...<body>...<ul> not found.)");
- return false;
- }
-
- root = tree_get_root(tree);
-
- ctx.tree = tree;
- ctx.directory = root;
- ctx.callback = callback;
- ctx.callback_data = callback_data;
- ctx.last_was_h4 = false;
- ctx.title = NULL;
-
- tree_url_load_directory(ul, &ctx);
- tree_set_node_expanded(tree, root, true, false, false);
-
- if (ctx.title != NULL) {
- dom_string_unref(ctx.title);
- ctx.title = NULL;
- }
-
- dom_node_unref(ul);
- dom_node_unref(body);
- dom_node_unref(html);
- dom_node_unref(document);
-
- return true;
-}
-
-/**
- * Add an entry to the HTML tree for saving.
- *
- * The node must contain a sequence of node_elements in the following order:
- *
- * \param entry hotlist entry to add
- * \param fp File to write to
- * \return true on success, false on memory exhaustion
- */
-static bool tree_url_save_entry(struct node *entry, FILE *fp)
-{
- const char *href, *text;
- char *latin1_href, *latin1_text;
- utf8_convert_ret ret;
-
- text = tree_url_node_get_title(entry);
- if (text == NULL)
- return false;
-
- href = tree_url_node_get_url(entry);
- if (href == NULL)
- return false;
-
- ret = utf8_to_html(text, "iso-8859-1", strlen(text), &latin1_text);
- if (ret != UTF8_CONVERT_OK)
- return false;
-
- ret = utf8_to_html(href, "iso-8859-1", strlen(href), &latin1_href);
- if (ret != UTF8_CONVERT_OK) {
- free(latin1_text);
- return false;
- }
-
- fprintf(fp, "<li><a href=\"%s\">%s</a></li>",
- latin1_href, latin1_text);
-
- free(latin1_href);
- free(latin1_text);
-
- return true;
-}
-
-/**
- * Add a directory to the HTML tree for saving.
- *
- * \param directory hotlist directory to add
- * \param fp File to write to
- * \return true on success, false on memory exhaustion
- */
-static bool tree_url_save_directory(struct node *directory, FILE *fp)
-{
- struct node *child;
-
- fputs("<ul", fp);
- if (tree_node_is_default(directory))
- fputs(" id=\"default\"", fp);
- fputc('>', fp);
-
- if (tree_node_get_child(directory) != NULL)
- fputc('\n', fp);
-
- for (child = tree_node_get_child(directory); child != NULL;
- child = tree_node_get_next(child)) {
- if (tree_node_is_folder(child) == false) {
- /* entry */
- if (tree_url_save_entry(child, fp) == false)
- return false;
- } else {
- /* directory */
- /* invalid HTML */
- const char *text;
- char *latin1_text;
- utf8_convert_ret ret;
-
- text = tree_url_node_get_title(child);
- if (text == NULL)
- return false;
-
- ret = utf8_to_html(text, "iso-8859-1",
- strlen(text), &latin1_text);
- if (ret != UTF8_CONVERT_OK)
- return false;
-
- fprintf(fp, "<h4>%s</h4>\n", latin1_text);
-
- free(latin1_text);
-
- if (tree_url_save_directory(child, fp) == false)
- return false;
- }
-
- fputc('\n', fp);
- }
-
- fputs("</ul>", fp);
-
- return true;
-}
-
-
-/**
- * Perform a save to a specified file in the form of a html page
- *
- * \param filename the file to save to
- * \param page_title title of the page
- */
-bool tree_urlfile_save(struct tree *tree, const char *filename,
- const char *page_title)
-{
- FILE *fp;
-
- fp = fopen(filename, "w");
- if (fp == NULL)
- return NULL;
-
- /* Unfortunately the Browse Hotlist format is invalid HTML,
- * so this is a lie.
- */
- fputs("<!DOCTYPE html "
- "PUBLIC \"//W3C/DTD HTML 4.01//EN\" "
- "\"http://www.w3.org/TR/html4/strict.dtd\">\n", fp);
- fputs("<html>\n<head>\n", fp);
- fputs("<meta http-equiv=\"Content-Type\" "
- "content=\"text/html; charset=iso-8859-1\">\n", fp);
- fprintf(fp, "<title>%s</title>\n", page_title);
- fputs("</head>\n<body>", fp);
-
- if (tree_url_save_directory(tree_get_root(tree), fp) == false) {
- warn_user("HotlistSaveError", 0);
- fclose(fp);
- return false;
- }
-
- fputs("</body>\n</html>\n", fp);
-
- fclose(fp);
-
- return true;
-}
-
diff --git a/desktop/tree_url_node.h b/desktop/tree_url_node.h
deleted file mode 100644
index bcbc192..0000000
--- a/desktop/tree_url_node.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2005 Richard Wilson <info(a)tinct.net>
- * Copyright 2009 Paul Blokus <paul_pl(a)users.sourceforge.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/** \file
- * Creation of URL nodes with use of trees public API
- */
-
-#ifndef _NETSURF_DESKTOP_TREE_URL_NODE_H_
-#define _NETSURF_DESKTOP_TREE_URL_NODE_H_
-
-
-#include "desktop/tree.h"
-#include "utils/nsurl.h"
-
-struct url_data;
-
-void tree_url_node_init(const char *folder_icon_name);
-void tree_url_node_cleanup(void);
-struct node *tree_create_URL_node(struct tree *tree,
- struct node *parent, nsurl *url, const char *title,
- tree_node_user_callback, void *callback_data);
-struct node *tree_create_URL_node_readonly(struct tree *tree,
- struct node *parent, nsurl *url,
- const struct url_data *data,
- tree_node_user_callback, void *callback_data);
-void tree_update_URL_node(struct tree *tree, struct node *node,
- nsurl *url, const struct url_data *data);
-const char *tree_url_node_get_title(struct node *node);
-const char *tree_url_node_get_url(struct node *node);
-struct bitmap *tree_url_node_get_icon(struct node *node);
-void tree_url_node_edit_title(struct tree *tree, struct node *node);
-void tree_url_node_edit_url(struct tree *tree, struct node *node);
-
-node_callback_resp tree_url_node_callback(void *user_data,
- struct node_msg_data *msg_data);
-
-bool tree_urlfile_load(const char *filename, struct tree *tree,
- tree_node_user_callback, void *callback_data);
-bool tree_urlfile_save(struct tree *tree, const char *filename,
- const char *page_title);
-
-/* front end specific */
-void tree_icon_name_from_content_type(char *buffer, content_type type);
-
-#endif
diff --git a/framebuffer/tree.c b/framebuffer/tree.c
index c661edc..942a4aa 100644
--- a/framebuffer/tree.c
+++ b/framebuffer/tree.c
@@ -17,29 +17,7 @@
*/
#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
const char tree_directory_icon_name[] = "directory.png";
const char tree_content_icon_name[] = "content.png";
-
-
-/**
- * Translates a content_type to the name of a respective icon
- *
- * \param content_type content type
- * \param buffer buffer for the icon name
- */
-void tree_icon_name_from_content_type(char *buffer, content_type type)
-{
- // TODO: design/acquire icons
- switch (type) {
- case CONTENT_HTML:
- case CONTENT_TEXTPLAIN:
- case CONTENT_CSS:
- case CONTENT_IMAGE:
- default:
- sprintf(buffer, tree_content_icon_name);
- break;
- }
-}
diff --git a/gtk/treeview.c b/gtk/treeview.c
index d836eb6..8a4c73c 100644
--- a/gtk/treeview.c
+++ b/gtk/treeview.c
@@ -29,7 +29,6 @@
#include <gdk/gdkkeysyms.h>
#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
#include "desktop/plotters.h"
#include "gtk/compat.h"
#include "gtk/gui.h"
@@ -89,26 +88,6 @@ static void nsgtk_tree_resized(struct tree *tree, int width, int height, void *d
}
/**
- * Translates a content_type to the name of a respective icon
- *
- * \param content_type content type
- * \param buffer buffer for the icon name
- */
-void tree_icon_name_from_content_type(char *buffer, content_type type)
-{
- // TODO: design/acquire icons
- switch (type) {
- case CONTENT_HTML:
- case CONTENT_TEXTPLAIN:
- case CONTENT_CSS:
- case CONTENT_IMAGE:
- default:
- sprintf(buffer, tree_content_icon_name);
- break;
- }
-}
-
-/**
* Scrolls the tree to make an element visible
*
* \param y Y coordinate of the element
diff --git a/monkey/utils.c b/monkey/utils.c
index 886c1ff..c38e9bf 100644
--- a/monkey/utils.c
+++ b/monkey/utils.c
@@ -20,8 +20,6 @@
#include <stdlib.h>
#include <string.h>
-#include "desktop/tree_url_node.h"
-
#include "utils/utils.h"
#include "utils/url.h"
#include "utils/utf8.h"
@@ -137,9 +135,4 @@ utf8_from_local_encoding(const char *string, size_t len,
return (*result == NULL) ? UTF8_CONVERT_NOMEM : UTF8_CONVERT_OK;
}
-void
-tree_icon_name_from_content_type(char *buffer, content_type type)
-{
- sprintf(buffer, "%s", "content.png");
-}
diff --git a/riscos/gui.c b/riscos/gui.c
index a312b38..d450b6d 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -63,7 +63,6 @@
#include "utils/nsoption.h"
#include "desktop/save_complete.h"
#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
#include "render/font.h"
#include "riscos/content-handlers/artworks.h"
#include "riscos/bitmap.h"
diff --git a/riscos/treeview.c b/riscos/treeview.c
index 7727663..5d1126b 100644
--- a/riscos/treeview.c
+++ b/riscos/treeview.c
@@ -40,7 +40,6 @@
#include "desktop/plotters.h"
#include "desktop/textinput.h"
#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
#include "riscos/bitmap.h"
#include "riscos/dialog.h"
#include "riscos/gui.h"
@@ -1294,25 +1293,3 @@ int ro_treeview_get_help(help_full_message_request *message_data)
return -1;
}
-/**
- * Convert a content type into an icon name.
- *
- * \todo -- Currently we don't have any icons apart from the default.
- *
- * \param *buffer A buffer to return the icon name
- * \param type The content type to return an icon name for.
- */
-
-void tree_icon_name_from_content_type(char *buffer, content_type type)
-{
- switch (type) {
- case CONTENT_HTML:
- case CONTENT_TEXTPLAIN:
- case CONTENT_CSS:
- case CONTENT_IMAGE:
- default:
- sprintf(buffer, tree_content_icon_name);
- break;
- }
-}
-
diff --git a/windows/tree.c b/windows/tree.c
index ec0750b..942a4aa 100644
--- a/windows/tree.c
+++ b/windows/tree.c
@@ -17,29 +17,7 @@
*/
#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
-
const char tree_directory_icon_name[] = "directory.png";
const char tree_content_icon_name[] = "content.png";
-
-/**
- * Translates a content_type to the name of a respective icon
- *
- * \param content_type content type
- * \param buffer buffer for the icon name
- */
-void tree_icon_name_from_content_type(char *buffer, content_type type)
-{
- // TODO: design/acquire icons
- switch (type) {
- case CONTENT_HTML:
- case CONTENT_TEXTPLAIN:
- case CONTENT_CSS:
- case CONTENT_IMAGE:
- default:
- sprintf(buffer, tree_content_icon_name);
- break;
- }
-}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=28a948bd32bee735f57...
commit 28a948bd32bee735f571ae7f297adb69b289d8ba
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Reduce old hotlist to skeleton.
diff --git a/desktop/hotlist_old.c b/desktop/hotlist_old.c
index 956e85b..861658d 100644
--- a/desktop/hotlist_old.c
+++ b/desktop/hotlist_old.c
@@ -36,151 +36,15 @@
#include "utils/utils.h"
#include "utils/log.h"
-#define URL_CHUNK_LENGTH 512
-
-static struct tree *hotlist_old_tree;
-static struct node *hotlist_old_tree_root;
-
-static bool creating_node;
-static hlcache_handle *folder_icon;
-
-static const struct {
- const char *url;
- const char *msg_key;
-} hotlist_old_default_entries[] = {
- { "http://www.netsurf-browser.org/", "HotlistHomepage" },
- { "http://www.netsurf-browser.org/downloads/riscos/testbuilds",
- "HotlistTestBuild" },
- { "http://www.netsurf-browser.org/documentation",
- "HotlistDocumentation" },
- { "http://sourceforge.net/tracker/?atid=464312&group_id=51719",
- "HotlistBugTracker" },
- { "http://sourceforge.net/tracker/?atid=464315&group_id=51719",
- "HotlistFeatureRequest" }
-};
-#define hotlist_old_ENTRIES_COUNT (sizeof(hotlist_old_default_entries) / sizeof(hotlist_old_default_entries[0]))
-
-static node_callback_resp hotlist_old_node_callback(void *user_data,
- struct node_msg_data *msg_data)
-{
- struct node *node = msg_data->node;
- const char *text;
- char *norm_text;
- bool is_folder = tree_node_is_folder(node);
- bool cancelled = false;
-
- switch (msg_data->msg) {
- case NODE_ELEMENT_EDIT_CANCELLED:
- cancelled = true;
- /* fall through */
- case NODE_ELEMENT_EDIT_FINISHED:
- if (creating_node && !cancelled &&
- (is_folder == false) &&
- (msg_data->flag == TREE_ELEMENT_TITLE)) {
- tree_url_node_edit_url(hotlist_old_tree, node);
- } else {
- creating_node = false;
- }
- return NODE_CALLBACK_HANDLED;
-
- case NODE_ELEMENT_EDIT_FINISHING:
- if (creating_node && (is_folder == false))
- return tree_url_node_callback(hotlist_old_tree, msg_data);
-
- if (is_folder == true) {
- text = msg_data->data.text;
- while (isspace(*text))
- text++;
- norm_text = strdup(text);
- if (norm_text == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- return NODE_CALLBACK_REJECT;
- }
- /* don't allow zero length entry text, return false */
- if (norm_text[0] == '\0') {
- warn_user("NoNameError", 0);
- msg_data->data.text = NULL;
- return NODE_CALLBACK_CONTINUE;
- }
- msg_data->data.text = norm_text;
- }
- break;
-
- case NODE_DELETE_ELEMENT_IMG:
- return NODE_CALLBACK_HANDLED;
-
- default:
- if (is_folder == false)
- return tree_url_node_callback(hotlist_old_tree, msg_data);
- }
-
- return NODE_CALLBACK_NOT_HANDLED;
-}
+
/* exported interface documented in hotlist.h */
bool hotlist_old_initialise(struct tree *tree, const char *hotlist_path,
const char* folder_icon_name)
{
- struct node *node;
- const struct url_data *url_data;
- int hlst_loop;
-
- /* Either load or create a hotlist */
-
- creating_node = false;
-
- folder_icon = tree_load_icon(folder_icon_name);
-
- tree_url_node_init(folder_icon_name);
-
if (tree == NULL)
return false;
- hotlist_old_tree = tree;
- hotlist_old_tree_root = tree_get_root(hotlist_old_tree);
-
- if (tree_urlfile_load(hotlist_path, hotlist_old_tree,
- hotlist_old_node_callback, NULL)) {
- return true;
- }
-
- /* failed to load hotlist file, use default list */
- node = tree_create_folder_node(hotlist_old_tree,
- hotlist_old_tree_root,
- messages_get("NetSurf"),
- true,
- false,
- false);
- if (node == NULL) {
- warn_user(messages_get_errorcode(NSERROR_NOMEM), 0);
- return false;
- }
-
- tree_set_node_user_callback(node, hotlist_old_node_callback, NULL);
- tree_set_node_icon(hotlist_old_tree, node, folder_icon);
-
- for (hlst_loop = 0; hlst_loop != hotlist_old_ENTRIES_COUNT; hlst_loop++) {
- nsurl *url;
- if (nsurl_create(hotlist_old_default_entries[hlst_loop].url,
- &url) != NSERROR_OK) {
- return false;
- }
- url_data = urldb_get_url_data(url);
- if (url_data == NULL) {
- urldb_add_url(url);
- urldb_set_url_persistence(url, true);
- url_data = urldb_get_url_data(url);
- }
- if (url_data != NULL) {
- tree_create_URL_node(hotlist_old_tree, node, url,
- messages_get(hotlist_old_default_entries[hlst_loop].msg_key),
- hotlist_old_node_callback, NULL);
- tree_update_URL_node(hotlist_old_tree, node, url, url_data);
- }
- nsurl_unref(url);
- }
-
return true;
}
@@ -192,7 +56,7 @@ bool hotlist_old_initialise(struct tree *tree, const char *hotlist_path,
*/
unsigned int hotlist_old_get_tree_flags(void)
{
- return TREE_MOVABLE | TREE_HOTLIST;
+ return TREE_HOTLIST;
}
@@ -202,13 +66,6 @@ unsigned int hotlist_old_get_tree_flags(void)
*/
void hotlist_old_cleanup(const char *hotlist_path)
{
- LOG(("Exporting hotlist..."));
- hotlist_old_export(hotlist_path);
- LOG(("Releasing handles..."));
- hlcache_handle_release(folder_icon);
- LOG(("Clearing hotlist tree nodes..."));
- tree_url_node_cleanup();
- LOG(("Hotlist cleaned up."));
}
/**
@@ -262,8 +119,6 @@ void hotlist_old_clear_selection(void)
*/
void hotlist_old_expand_all(void)
{
- tree_set_node_expanded(hotlist_old_tree, hotlist_old_tree_root,
- true, true, true);
}
/**
@@ -271,8 +126,6 @@ void hotlist_old_expand_all(void)
*/
void hotlist_old_expand_directories(void)
{
- tree_set_node_expanded(hotlist_old_tree, hotlist_old_tree_root,
- true, true, false);
}
/**
@@ -280,8 +133,6 @@ void hotlist_old_expand_directories(void)
*/
void hotlist_old_expand_addresses(void)
{
- tree_set_node_expanded(hotlist_old_tree, hotlist_old_tree_root,
- true, false, true);
}
/**
@@ -289,8 +140,6 @@ void hotlist_old_expand_addresses(void)
*/
void hotlist_old_collapse_all(void)
{
- tree_set_node_expanded(hotlist_old_tree, hotlist_old_tree_root,
- false, true, true);
}
/**
@@ -298,8 +147,6 @@ void hotlist_old_collapse_all(void)
*/
void hotlist_old_collapse_directories(void)
{
- tree_set_node_expanded(hotlist_old_tree, hotlist_old_tree_root,
- false, true, false);
}
/**
@@ -307,8 +154,6 @@ void hotlist_old_collapse_directories(void)
*/
void hotlist_old_collapse_addresses(void)
{
- tree_set_node_expanded(hotlist_old_tree,
- hotlist_old_tree_root, false, false, true);
}
/**
@@ -393,10 +238,5 @@ void hotlist_old_launch_selected(bool tabs)
*/
bool hotlist_old_set_default_folder(bool clear)
{
- if (clear == true) {
- tree_clear_default_folder_node(hotlist_old_tree);
- return true;
- } else {
- return tree_set_default_folder_node(hotlist_old_tree, NULL);
- }
+ return false;
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=29328e50774c7ec3d75...
commit 29328e50774c7ec3d755ed96777938f03bd1b367
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Reduce to skeleton.
diff --git a/desktop/history_global_core.c b/desktop/history_global_core.c
index b03485a..5bf43f1 100644
--- a/desktop/history_global_core.c
+++ b/desktop/history_global_core.c
@@ -25,6 +25,7 @@
#include "content/urldb.h"
#include "desktop/browser.h"
#include "desktop/history_global_core.h"
+#include "desktop/global_history.h"
#include "desktop/plotters.h"
#include "desktop/tree.h"
#include "desktop/tree_url_node.h"
@@ -32,229 +33,7 @@
#include "utils/utils.h"
#include "utils/log.h"
-#define MAXIMUM_BASE_NODES 16
-#define GLOBAL_HISTORY_RECENT_URLS 16
-#define URL_CHUNK_LENGTH 512
-static struct node *global_history_base_node[MAXIMUM_BASE_NODES];
-static int global_history_base_node_time[MAXIMUM_BASE_NODES];
-static int global_history_base_node_count = 0;
-
-static bool global_history_initialised;
-
-static struct tree *global_history_tree;
-static struct node *global_history_tree_root;
-
-static hlcache_handle *folder_icon;
-
-static const char *const weekday_msg_name [] =
-{
- "Sunday",
- "Monday",
- "Tuesday",
- "Wednesday",
- "Thursday",
- "Friday",
- "Saturday"
-};
-
-/**
- * Find an entry in the global history
- *
- * \param url The URL to find
- * \return Pointer to node, or NULL if not found
- */
-static struct node *history_global_find(const char *url)
-{
- int i;
- struct node *node;
- const char *text;
-
- for (i = 0; i < global_history_base_node_count; i++) {
- if (!tree_node_is_deleted(global_history_base_node[i])) {
- node = tree_node_get_child(global_history_base_node[i]);
- for (; node != NULL; node = tree_node_get_next(node)) {
- text = tree_url_node_get_url(node);
- if ((text != NULL) && !strcmp(url, text))
- return node;
- }
- }
- }
- return NULL;
-}
-
-/**
- * Internal routine to actually perform global history addition
- *
- * \param url The URL to add
- * \param data URL data associated with URL
- * \return true (for urldb_iterate_entries)
- */
-static bool history_global_add_internal(nsurl *url, const struct url_data *data)
-{
- int i, j;
- struct node *parent = NULL;
- struct node *link;
- struct node *node;
- bool before = false;
- int visit_date;
-
- assert((url != NULL) && (data != NULL));
-
- visit_date = data->last_visit;
-
- /* find parent node */
- for (i = 0; i < global_history_base_node_count; i++) {
- if (global_history_base_node_time[i] <= visit_date) {
- parent = global_history_base_node[i];
- break;
- }
- }
-
- /* the entry is too old to care about */
- if (parent == NULL)
- return true;
-
- if (tree_node_is_deleted(parent)) {
- /* parent was deleted, so find place to insert it */
- link = global_history_tree_root;
-
- for (j = global_history_base_node_count - 1; j >= 0; j--) {
- if (!tree_node_is_deleted(global_history_base_node[j]) &&
- global_history_base_node_time[j] >
- global_history_base_node_time[i]) {
- link = global_history_base_node[j];
- before = true;
- break;
- }
- }
-
- tree_set_node_selected(global_history_tree,
- parent, true, false);
- tree_set_node_expanded(global_history_tree,
- parent, false, true, true);
- tree_link_node(global_history_tree, link, parent, before);
- }
-
- /* find any previous occurance */
- if (global_history_initialised == false) {
- node = history_global_find(nsurl_access(url));
- if (node != NULL) {
- tree_update_URL_node(global_history_tree,
- node, url, data);
- tree_delink_node(global_history_tree, node);
- tree_link_node(global_history_tree, parent, node,
- false);
- return true;
- }
- }
-
- /* Add the node at the bottom */
- node = tree_create_URL_node_readonly(global_history_tree,
- parent, url, data,
- tree_url_node_callback, NULL);
-
- return true;
-}
-
-static node_callback_resp
-history_global_node_callback(void *user_data,
- struct node_msg_data *msg_data)
-{
- if (msg_data->msg == NODE_DELETE_ELEMENT_IMG)
- return NODE_CALLBACK_HANDLED;
- return NODE_CALLBACK_NOT_HANDLED;
-}
-
-/**
- * Initialises a single grouping node for the global history tree.
- *
- * \return false on memory exhaustion, true otherwise
- */
-static bool history_global_initialise_node(const char *title,
- time_t base, int days_back)
-{
- struct tm *full_time;
- struct node *node;
-
- base += days_back * 60 * 60 * 24;
- if (title == NULL) {
- full_time = localtime(&base);
- title = messages_get(weekday_msg_name[full_time->tm_wday]);
- }
-
- node = tree_create_folder_node(NULL, NULL, title, false, true, true);
- if (node == NULL) {
- warn_user(messages_get_errorcode(NSERROR_NOMEM), 0);
- return false;
- }
-
- if (folder_icon != NULL) {
- tree_set_node_icon(global_history_tree, node, folder_icon);
- }
-
- tree_set_node_user_callback(node, history_global_node_callback, NULL);
-
- global_history_base_node[global_history_base_node_count] = node;
- global_history_base_node_time[global_history_base_node_count] = base;
- global_history_base_node_count++;
-
- return true;
-}
-
-/**
- * Initialises the grouping nodes(Today, Yesterday etc.) for the global history
- * tree.
- *
- * \return false on memory exhaustion, true otherwise
- */
-static bool history_global_initialise_nodes(void)
-{
- struct tm *full_time;
- time_t t;
- int weekday;
- int i;
-
- /* get the current time */
- t = time(NULL);
- if (t == -1) {
- LOG(("time info unaviable"));
- return false;
- }
-
- /* get the time at the start of today */
- full_time = localtime(&t);
- weekday = full_time->tm_wday;
- full_time->tm_sec = 0;
- full_time->tm_min = 0;
- full_time->tm_hour = 0;
- t = mktime(full_time);
- if (t == -1) {
- LOG(("mktime failed"));
- return false;
- }
-
- history_global_initialise_node(messages_get("DateToday"), t, 0);
- if (weekday > 0)
- if (!history_global_initialise_node(
- messages_get("DateYesterday"), t, -1))
- return false;
- for (i = 2; i <= weekday; i++)
- if (!history_global_initialise_node(NULL, t, -i))
- return false;
-
- if (!history_global_initialise_node(messages_get("Date1Week"),
- t, -weekday - 7))
- return false;
- if (!history_global_initialise_node(messages_get("Date2Week"),
- t, -weekday - 14))
- return false;
- if (!history_global_initialise_node(messages_get("Date3Week"),
- t, -weekday - 21))
- return false;
-
- return true;
-}
/**
* Initialises the global history tree.
@@ -266,26 +45,9 @@ static bool history_global_initialise_nodes(void)
*/
bool history_global_initialise(struct tree *tree, const char* folder_icon_name)
{
- folder_icon = tree_load_icon(folder_icon_name);
- tree_url_node_init(folder_icon_name);
-
if (tree == NULL)
return false;
- global_history_tree = tree;
- global_history_tree_root = tree_get_root(global_history_tree);
-
- if (!history_global_initialise_nodes())
- return false;
-
- LOG(("Building history tree"));
-
- global_history_initialised = true;
- urldb_iterate_entries(history_global_add_internal);
- global_history_initialised = false;
- tree_set_node_expanded(global_history_tree, global_history_tree_root,
- false, true, true);
- LOG(("History tree built"));
return true;
}
@@ -297,7 +59,7 @@ bool history_global_initialise(struct tree *tree, const char* folder_icon_name)
*/
unsigned int history_global_get_tree_flags(void)
{
- return TREE_NO_FLAGS | TREE_HISTORY;
+ return TREE_HISTORY;
}
@@ -306,25 +68,6 @@ unsigned int history_global_get_tree_flags(void)
*/
void history_global_cleanup(void)
{
- hlcache_handle_release(folder_icon);
- tree_url_node_cleanup();
-}
-
-
-/**
- * Adds a url to the global history.
- *
- * \param url the url to be added
- */
-void history_global_add(nsurl *url)
-{
- const struct url_data *data;
-
- data = urldb_get_url_data(url);
- if (data == NULL)
- return;
-
- history_global_add_internal(url, data);
}
@@ -337,7 +80,7 @@ void history_global_add(nsurl *url)
*/
bool history_global_export(const char *path)
{
- return tree_urlfile_save(global_history_tree, path, "NetSurf history");
+ return global_history_export(path, NULL) == NSERROR_OK;
}
/**
@@ -345,8 +88,6 @@ bool history_global_export(const char *path)
*/
void history_global_delete_selected(void)
{
- tree_delete_selected_nodes(global_history_tree,
- global_history_tree_root);
}
/**
@@ -354,17 +95,6 @@ void history_global_delete_selected(void)
*/
void history_global_delete_all(void)
{
- bool redraw_needed = tree_get_redraw(global_history_tree);
- if (redraw_needed)
- tree_set_redraw(global_history_tree, false);
-
- tree_set_node_selected(global_history_tree, global_history_tree_root,
- true, true);
- tree_delete_selected_nodes(global_history_tree,
- global_history_tree_root);
-
- if (redraw_needed)
- tree_set_redraw(global_history_tree, true);
}
/**
@@ -372,8 +102,6 @@ void history_global_delete_all(void)
*/
void history_global_select_all(void)
{
- tree_set_node_selected(global_history_tree, global_history_tree_root,
- true, true);
}
/**
@@ -381,8 +109,6 @@ void history_global_select_all(void)
*/
void history_global_clear_selection(void)
{
- tree_set_node_selected(global_history_tree, global_history_tree_root,
- true, false);
}
/**
@@ -390,8 +116,6 @@ void history_global_clear_selection(void)
*/
void history_global_expand_all(void)
{
- tree_set_node_expanded(global_history_tree, global_history_tree_root,
- true, true, true);
}
/**
@@ -399,8 +123,6 @@ void history_global_expand_all(void)
*/
void history_global_expand_directories(void)
{
- tree_set_node_expanded(global_history_tree, global_history_tree_root,
- true, true, false);
}
/**
@@ -408,8 +130,6 @@ void history_global_expand_directories(void)
*/
void history_global_expand_addresses(void)
{
- tree_set_node_expanded(global_history_tree, global_history_tree_root,
- true, false, true);
}
/**
@@ -417,8 +137,6 @@ void history_global_expand_addresses(void)
*/
void history_global_collapse_all(void)
{
- tree_set_node_expanded(global_history_tree, global_history_tree_root,
- false, true, true);
}
/**
@@ -426,8 +144,6 @@ void history_global_collapse_all(void)
*/
void history_global_collapse_directories(void)
{
- tree_set_node_expanded(global_history_tree, global_history_tree_root,
- false, true, false);
}
/**
@@ -435,8 +151,6 @@ void history_global_collapse_directories(void)
*/
void history_global_collapse_addresses(void)
{
- tree_set_node_expanded(global_history_tree, global_history_tree_root,
- false, false, true);
}
/**
@@ -446,5 +160,4 @@ void history_global_collapse_addresses(void)
*/
void history_global_launch_selected(bool tabs)
{
- tree_launch_selected(global_history_tree, tabs);
}
diff --git a/desktop/history_global_core.h b/desktop/history_global_core.h
index 9bf5a0b..7b8e682 100644
--- a/desktop/history_global_core.h
+++ b/desktop/history_global_core.h
@@ -28,8 +28,6 @@ bool history_global_initialise(struct tree *tree, const char* folder_icon_name);
unsigned int history_global_get_tree_flags(void);
void history_global_cleanup(void);
-void history_global_add(nsurl *url);
-
bool history_global_export(const char *path);
void history_global_delete_selected(void);
void history_global_delete_all(void);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=ec3547ec9d34e6fbc48...
commit ec3547ec9d34e6fbc48437fc2d24ff778c82209b
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Remove unused type.
diff --git a/desktop/cookies_old.h b/desktop/cookies_old.h
index 5f401d4..47194ff 100644
--- a/desktop/cookies_old.h
+++ b/desktop/cookies_old.h
@@ -27,8 +27,6 @@
#include "desktop/tree.h"
-struct cookie_data;
-
bool cookies_initialise(struct tree *tree, const char* folder_icon_name, const char* cookie_icon_name);
unsigned int cookies_get_tree_flags(void);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=81b2a859c0f9f145be1...
commit 81b2a859c0f9f145be16fb4f9b11df84ada3a1b8
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Reduce old cookie manager to skeleton.
diff --git a/desktop/cookies_old.c b/desktop/cookies_old.c
index 0aaf61f..c944d35 100644
--- a/desktop/cookies_old.c
+++ b/desktop/cookies_old.c
@@ -39,318 +39,6 @@
#include "utils/url.h"
#include "utils/utils.h"
-/** Flags for each type of cookie tree node. */
-enum tree_element_cookie {
- TREE_ELEMENT_PERSISTENT = 0x01,
- TREE_ELEMENT_VERSION = 0x02,
- TREE_ELEMENT_SECURE = 0x03,
- TREE_ELEMENT_LAST_USED = 0x04,
- TREE_ELEMENT_EXPIRES = 0x05,
- TREE_ELEMENT_PATH = 0x06,
- TREE_ELEMENT_DOMAIN = 0x07,
- TREE_ELEMENT_COMMENT = 0x08,
- TREE_ELEMENT_VALUE = 0x09,
-};
-
-static struct tree *cookies_tree;
-static struct node *cookies_tree_root;
-static bool user_delete;
-static hlcache_handle *folder_icon;
-static hlcache_handle *cookie_icon;
-
-
-/**
- * Find an entry in the cookie tree
- *
- * \param node the node to check the children of
- * \param title The title to find
- * \return Pointer to node, or NULL if not found
- */
-static struct node *cookies_find(struct node *node, const char *title)
-{
- struct node *search;
- struct node_element *element;
-
- assert(node !=NULL);
-
- for (search = tree_node_get_child(node); search;
- search = tree_node_get_next(search)) {
- element = tree_node_find_element(search, TREE_ELEMENT_TITLE,
- NULL);
- if (strcmp(title, tree_node_element_get_text(element)) == 0)
- return search;
- }
- return NULL;
-}
-
-/**
- * Callback for all cookie tree nodes.
- */
-static node_callback_resp cookies_node_callback(void *user_data, struct node_msg_data *msg_data)
-{
- struct node *node = msg_data->node;
- struct node_element *domain, *path;
- const char *domain_t, *path_t, *name_t;
- char *space;
- bool is_folder = tree_node_is_folder(node);
-
- /* we don't remove any icons here */
- if (msg_data->msg == NODE_DELETE_ELEMENT_IMG)
- return NODE_CALLBACK_HANDLED;
-
- /* let the tree handle events other than text data removal */
- if (msg_data->msg != NODE_DELETE_ELEMENT_TXT)
- return NODE_CALLBACK_NOT_HANDLED;
-
- /* check if it's a domain folder */
- if (is_folder)
- return NODE_CALLBACK_NOT_HANDLED;
-
- switch (msg_data->flag) {
- case TREE_ELEMENT_TITLE:
- if (!user_delete)
- break;
- /* get the rest of the cookie data */
- domain = tree_node_find_element(node,
- TREE_ELEMENT_DOMAIN, NULL);
- path = tree_node_find_element(node, TREE_ELEMENT_PATH,
- NULL);
-
- if ((domain != NULL) &&
- (path != NULL)) {
- domain_t = tree_node_element_get_text(domain) +
- strlen(messages_get(
- "TreeDomain")) - 4;
- space = strchr(domain_t, ' ');
- if (space != NULL)
- *space = '\0';
- path_t = tree_node_element_get_text(path) +
- strlen(messages_get("TreePath"))
- - 4;
- space = strchr(path_t, ' ');
- if (space != NULL)
- *space = '\0';
- name_t = msg_data->data.text;
- urldb_delete_cookie(domain_t, path_t, name_t);
- }
- break;
- default:
- break;
- }
-
- free(msg_data->data.text);
-
- return NODE_CALLBACK_HANDLED;
-}
-
-
-/**
- * Updates a tree entry for a cookie.
- *
- * All information is copied from the cookie_data, and as such can
- * be edited and should be freed.
- *
- * \param node The node to update
- * \param data The cookie data to use
- * \return true if node updated, or false for failure
- */
-static bool cookies_update_cookie_node(struct node *node,
- const struct cookie_data *data)
-{
- struct node_element *element;
- char buffer[32];
-
- assert(data != NULL);
-
- /* update the value text */
- element = tree_node_find_element(node, TREE_ELEMENT_VALUE, NULL);
- tree_update_element_text(cookies_tree,
- element,
- messages_get_buff("TreeValue",
- data->value != NULL ?
- data->value :
- messages_get("TreeUnused")));
-
-
- /* update the comment text */
- if ((data->comment != NULL) &&
- (strcmp(data->comment, "") != 0)) {
- element = tree_node_find_element(node, TREE_ELEMENT_COMMENT, NULL);
- tree_update_element_text(cookies_tree,
- element,
- messages_get_buff("TreeComment",
- data->comment));
- }
-
- /* update domain text */
- element = tree_node_find_element(node, TREE_ELEMENT_DOMAIN, element);
- tree_update_element_text(cookies_tree,
- element,
- messages_get_buff("TreeDomain",
- data->domain,
- data->domain_from_set ?
- messages_get("TreeHeaders") :
- ""));
-
- /* update path text */
- element = tree_node_find_element(node, TREE_ELEMENT_PATH, element);
- tree_update_element_text(cookies_tree,
- element,
- messages_get_buff("TreePath", data->path,
- data->path_from_set ?
- messages_get("TreeHeaders") :
- ""));
-
- /* update expiry text */
- element = tree_node_find_element(node, TREE_ELEMENT_EXPIRES, element);
- tree_update_element_text(cookies_tree,
- element,
- messages_get_buff("TreeExpires",
- (data->expires > 0)
- ? (data->expires == 1)
- ? messages_get("TreeSession")
- : ctime(&data->expires)
- : messages_get("TreeUnknown")));
-
- /* update last used text */
- element = tree_node_find_element(node, TREE_ELEMENT_LAST_USED, element);
- tree_update_element_text(cookies_tree,
- element,
- messages_get_buff("TreeLastUsed",
- (data->last_used > 0) ?
- ctime(&data->last_used) :
- messages_get("TreeUnknown")));
-
- /* update secure text */
- element = tree_node_find_element(node, TREE_ELEMENT_SECURE, element);
- tree_update_element_text(cookies_tree,
- element,
- messages_get_buff("TreeSecure",
- data->secure ?
- messages_get("Yes") :
- messages_get("No")));
-
- /* update version text */
- element = tree_node_find_element(node, TREE_ELEMENT_VERSION, element);
- snprintf(buffer, sizeof(buffer), "TreeVersion%i", data->version);
- tree_update_element_text(cookies_tree,
- element,
- messages_get_buff("TreeVersion",
- messages_get(buffer)));
-
- /* update persistant text */
- element = tree_node_find_element(node, TREE_ELEMENT_PERSISTENT, element);
- tree_update_element_text(cookies_tree,
- element,
- messages_get_buff("TreePersistent",
- data->no_destroy ?
- messages_get("Yes") :
- messages_get("No")));
-
- return true;
-}
-
-/**
- * Creates an empty tree entry for a cookie, and links it into the tree.
- *
- * All information is copied from the cookie_data, and as such can
- * be edited and should be freed.
- *
- * \param parent the node to link to
- * \param data the cookie data to use
- * \return the node created, or NULL for failure
- */
-static struct node *cookies_create_cookie_node(struct node *parent,
- const struct cookie_data *data)
-{
- struct node *node;
-
- node = tree_create_leaf_node(cookies_tree,
- NULL,
- data->name,
- false, false, false);
- if (node == NULL) {
- return NULL;
- }
-
- tree_set_node_user_callback(node, cookies_node_callback, NULL);
-
- tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_PERSISTENT, false);
-
- tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_VERSION, false);
-
- tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_SECURE, false);
-
- tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_LAST_USED, false);
-
- tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_EXPIRES, false);
-
- tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_PATH, false);
-
- tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_DOMAIN, false);
-
- if ((data->comment) && (strcmp(data->comment, "")))
- tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_COMMENT, false);
- tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_VALUE, false);
- tree_set_node_icon(cookies_tree, node, cookie_icon);
-
- if (!cookies_update_cookie_node(node, data))
- {
- tree_delete_node(NULL, node, false);
- return NULL;
- }
-
- tree_link_node(cookies_tree, parent, node, false);
- return node;
-}
-
-
-/**
- * Called when scheduled event gets fired. Actually performs the update.
- */
-static void cookies_schedule_callback(const void *scheduled_data)
-{
- const struct cookie_data *data = scheduled_data;
- struct node *node = NULL;
- struct node *cookie_node = NULL;
-
- assert(data != NULL);
-
- node = cookies_find(cookies_tree_root, data->domain);
-
- if (node == NULL) {
- node = tree_create_folder_node(cookies_tree,
- cookies_tree_root,
- data->domain,
- false, false, false);
- if (node != NULL) {
- tree_set_node_user_callback(node,
- cookies_node_callback,
- NULL);
- tree_set_node_icon(cookies_tree, node, folder_icon);
- }
- }
-
- if (node != NULL) {
- cookie_node = cookies_find(node, data->name);
- if (cookie_node == NULL) {
- cookies_create_cookie_node(node, data);
- } else {
- cookies_update_cookie_node(cookie_node, data);
- }
-
- }
-}
-
/**
* Initialises cookies tree.
*
@@ -365,22 +53,6 @@ bool cookies_initialise(struct tree *tree, const char* folder_icon_name, const c
if (tree == NULL)
return false;
- LOG(("Making cookie tree"));
-
- folder_icon = tree_load_icon(folder_icon_name);
- cookie_icon = tree_load_icon(cookie_icon_name);
-
- /* Create an empty tree */
- cookies_tree = tree;
- cookies_tree_root = tree_get_root(cookies_tree);
-
- user_delete = false;
- urldb_iterate_cookies(cookies_schedule_update);
- tree_set_node_expanded(cookies_tree, cookies_tree_root,
- false, true, true);
-
- LOG(("Made cookie tree"));
-
return true;
}
@@ -392,30 +64,7 @@ bool cookies_initialise(struct tree *tree, const char* folder_icon_name, const c
*/
unsigned int cookies_get_tree_flags(void)
{
- return TREE_DELETE_EMPTY_DIRS | TREE_COOKIES;
-}
-
-
-/* exported interface documented in cookies_old.h */
-bool cookies_schedule_update(const struct cookie_data *data)
-{
- assert(data != NULL);
- assert(user_delete == false);
-
- if (cookies_tree_root != NULL)
- cookies_schedule_callback(data);
-
- return true;
-}
-
-
-/* exported interface documented in cookies_old.h */
-void cookies_remove(const struct cookie_data *data)
-{
- assert(data != NULL);
-
- if (cookies_tree_root != NULL)
- cookies_schedule_callback(data);
+ return TREE_COOKIES;
}
@@ -424,8 +73,6 @@ void cookies_remove(const struct cookie_data *data)
*/
void cookies_cleanup(void)
{
- hlcache_handle_release(folder_icon);
- hlcache_handle_release(cookie_icon);
}
/* Actions to be connected to front end specific toolbars */
@@ -435,9 +82,6 @@ void cookies_cleanup(void)
*/
void cookies_delete_selected(void)
{
- user_delete = true;
- tree_delete_selected_nodes(cookies_tree, cookies_tree_root);
- user_delete = false;
}
/**
@@ -445,17 +89,6 @@ void cookies_delete_selected(void)
*/
void cookies_delete_all(void)
{
- bool needs_redraw = tree_get_redraw(cookies_tree);
- if (needs_redraw)
- tree_set_redraw(cookies_tree, false);
-
- user_delete = true;
- tree_set_node_selected(cookies_tree, cookies_tree_root, true, true);
- tree_delete_selected_nodes(cookies_tree, cookies_tree_root);
- user_delete = false;
-
- if (needs_redraw)
- tree_set_redraw(cookies_tree, true);
}
/**
@@ -463,7 +96,6 @@ void cookies_delete_all(void)
*/
void cookies_select_all(void)
{
- tree_set_node_selected(cookies_tree, cookies_tree_root, true, true);
}
/**
@@ -471,7 +103,6 @@ void cookies_select_all(void)
*/
void cookies_clear_selection(void)
{
- tree_set_node_selected(cookies_tree, cookies_tree_root, true, false);
}
/**
@@ -479,8 +110,6 @@ void cookies_clear_selection(void)
*/
void cookies_expand_all(void)
{
- tree_set_node_expanded(cookies_tree, cookies_tree_root,
- true, true, true);
}
/**
@@ -488,8 +117,6 @@ void cookies_expand_all(void)
*/
void cookies_expand_domains(void)
{
- tree_set_node_expanded(cookies_tree, cookies_tree_root,
- true, true, false);
}
/**
@@ -497,8 +124,6 @@ void cookies_expand_domains(void)
*/
void cookies_expand_cookies(void)
{
- tree_set_node_expanded(cookies_tree, cookies_tree_root,
- true, false, true);
}
/**
@@ -506,8 +131,6 @@ void cookies_expand_cookies(void)
*/
void cookies_collapse_all(void)
{
- tree_set_node_expanded(cookies_tree, cookies_tree_root,
- false, true, true);
}
/**
@@ -515,8 +138,6 @@ void cookies_collapse_all(void)
*/
void cookies_collapse_domains(void)
{
- tree_set_node_expanded(cookies_tree, cookies_tree_root,
- false, true, false);
}
/**
@@ -524,6 +145,4 @@ void cookies_collapse_domains(void)
*/
void cookies_collapse_cookies(void)
{
- tree_set_node_expanded(cookies_tree, cookies_tree_root,
- false, false, true);
}
diff --git a/desktop/cookies_old.h b/desktop/cookies_old.h
index 18ba658..5f401d4 100644
--- a/desktop/cookies_old.h
+++ b/desktop/cookies_old.h
@@ -32,24 +32,6 @@ struct cookie_data;
bool cookies_initialise(struct tree *tree, const char* folder_icon_name, const char* cookie_icon_name);
unsigned int cookies_get_tree_flags(void);
-/**
- * Perform cookie updates and addition. The update is only scheduled here.
- * The actual update is performed in the callback function.
- *
- * \param data Data of cookie being updated.
- * \return true (for urldb_iterate_entries)
- */
-bool cookies_schedule_update(const struct cookie_data *data);
-
-/**
- * Remove a cookie from the active set.
- * The cookie is to be removed from the active set and no futher
- * references made to the cookie data.
- *
- * \param data Data of cookie being removed.
- */
-void cookies_remove(const struct cookie_data *data);
-
void cookies_cleanup(void);
void cookies_delete_selected(void);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=452c89aa8345f6478d6...
commit 452c89aa8345f6478d61313ba47860c49ec82a58
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Remove unused hotlist_old_visited.
diff --git a/desktop/hotlist_old.c b/desktop/hotlist_old.c
index b893a08..956e85b 100644
--- a/desktop/hotlist_old.c
+++ b/desktop/hotlist_old.c
@@ -211,55 +211,6 @@ void hotlist_old_cleanup(const char *hotlist_path)
LOG(("Hotlist cleaned up."));
}
-
-/**
- * Informs the hotlist that some content has been visited. Internal procedure.
- *
- * \param content the content visited
- * \param node the node to update siblings and children of
- */
-static void hotlist_old_visited_internal(hlcache_handle *content, struct node *node)
-{
- struct node *child;
- const char *text;
- const char *url;
- nsurl *nsurl;
-
- if (content == NULL ||
- hlcache_handle_get_url(content) == NULL ||
- hotlist_old_tree == NULL)
- return;
-
- nsurl = hlcache_handle_get_url(content);
- url = nsurl_access(nsurl);
-
- for (; node; node = tree_node_get_next(node)) {
- if (!tree_node_is_folder(node)) {
- text = tree_url_node_get_url(node);
- if (strcmp(text, url) == 0) {
- tree_update_URL_node(hotlist_old_tree, node,
- nsurl, NULL);
- }
- }
- child = tree_node_get_child(node);
- if (child != NULL) {
- hotlist_old_visited_internal(content, child);
- }
- }
-}
-
-/**
- * Informs the hotlist that some content has been visited
- *
- * \param content the content visited
- */
-void hotlist_old_visited(hlcache_handle *content)
-{
- if (hotlist_old_tree != NULL) {
- hotlist_old_visited_internal(content, tree_get_root(hotlist_old_tree));
- }
-}
-
/**
* Save the hotlist in a human-readable form under the given location.
*
diff --git a/desktop/hotlist_old.h b/desktop/hotlist_old.h
index 776bef2..487b336 100644
--- a/desktop/hotlist_old.h
+++ b/desktop/hotlist_old.h
@@ -42,7 +42,6 @@ bool hotlist_old_initialise(struct tree *tree, const char *hotlist_path, const c
unsigned int hotlist_old_get_tree_flags(void);
void hotlist_old_cleanup(const char *hotlist_path);
-void hotlist_old_visited(struct hlcache_handle *c);
bool hotlist_old_export(const char *path);
void hotlist_old_edit_selected(void);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=6a4a297b2f21fdac7f7...
commit 6a4a297b2f21fdac7f7fcc6b37754786d57a7b9d
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Remove temp_treeview_test option. Now it's always "enabled".
diff --git a/desktop/options.h b/desktop/options.h
index 7ed6fc1..391dfbc 100644
--- a/desktop/options.h
+++ b/desktop/options.h
@@ -275,6 +275,3 @@ NSOPTION_COLOUR(sys_colour_ThreeDShadow, 0x00d5d5d5)
NSOPTION_COLOUR(sys_colour_Window, 0x00f1f1f1)
NSOPTION_COLOUR(sys_colour_WindowFrame, 0x004e4e4e)
NSOPTION_COLOUR(sys_colour_WindowText, 0x00000000)
-
-/** Temporary option for enabling test of new treeview */
-NSOPTION_BOOL(temp_treeview_test, false)
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=fadaa306d019d89f864...
commit fadaa306d019d89f86478e9918b9bb2b43fa9ea2
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Always redirect to the new treeview implementations.
diff --git a/desktop/tree.c b/desktop/tree.c
index 8966be3..607d12b 100644
--- a/desktop/tree.c
+++ b/desktop/tree.c
@@ -272,10 +272,6 @@ static bool treeview_test_init(struct tree *tree)
return true;
}
- /* Check if we're testing the new treeview */
- if (nsoption_bool(temp_treeview_test) == false)
- return false;
-
treeview_inits++;
if (treeview_inits == 1)
@@ -321,10 +317,6 @@ static bool treeview_test_fini(struct tree *tree)
return true;
}
- /* Check if we're testing the new treeview */
- if (nsoption_bool(temp_treeview_test) == false)
- return false;
-
if (tree->flags & TREE_COOKIES) {
err = cookie_manager_fini();
if (err != NSERROR_OK) {
@@ -367,10 +359,6 @@ static bool treeview_test_redraw(struct tree *tree, int x, int y,
return true;
}
- /* Check if we're testing the new treeview */
- if (nsoption_bool(temp_treeview_test) == false)
- return false;
-
if (tree->flags & TREE_COOKIES) {
cookie_manager_redraw(x, y, &clip, ctx);
return true;
@@ -395,10 +383,6 @@ static bool treeview_test_mouse_action(struct tree *tree,
return true;
}
- /* Check if we're testing the new treeview */
- if (nsoption_bool(temp_treeview_test) == false)
- return false;
-
if (tree->flags & TREE_COOKIES) {
cookie_manager_mouse_action(mouse, x, y);
return true;
@@ -422,10 +406,6 @@ static bool treeview_test_keypress(struct tree *tree, uint32_t key)
return true;
}
- /* Check if we're testing the new treeview */
- if (nsoption_bool(temp_treeview_test) == false)
- return false;
-
if (tree->flags & TREE_COOKIES) {
cookie_manager_keypress(key);
return true;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=5d76b448b1fdff05625...
commit 5d76b448b1fdff056255ed4b000b521591e5b955
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Use new hotlist.
diff --git a/desktop/hotlist_old.c b/desktop/hotlist_old.c
index 7be9499..b893a08 100644
--- a/desktop/hotlist_old.c
+++ b/desktop/hotlist_old.c
@@ -267,12 +267,9 @@ void hotlist_old_visited(hlcache_handle *content)
*/
bool hotlist_old_export(const char *path)
{
- if (nsoption_bool(temp_treeview_test) != false) {
- nserror err;
- err = hotlist_export(path, NULL);
- return (err == NSERROR_OK);
- }
- return tree_urlfile_save(hotlist_old_tree, path, "NetSurf hotlist");
+ nserror err;
+ err = hotlist_export(path, NULL);
+ return (err == NSERROR_OK);
}
/**
@@ -281,22 +278,8 @@ bool hotlist_old_export(const char *path)
*/
void hotlist_old_edit_selected(void)
{
- struct node *node;
- struct node_element *element;
-
/* Update new hotlist */
- if (nsoption_bool(temp_treeview_test) != false) {
- hotlist_edit_selection();
- return;
- }
-
- node = tree_get_selected_node(hotlist_old_tree_root);
-
- if (node != NULL) {
- creating_node = true;
- element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
- tree_start_edit(hotlist_old_tree, element);
- }
+ hotlist_edit_selection();
}
/**
@@ -304,11 +287,7 @@ void hotlist_old_edit_selected(void)
*/
void hotlist_old_delete_selected(void)
{
- if (nsoption_bool(temp_treeview_test) != false) {
- hotlist_keypress(KEY_DELETE_LEFT);
- return;
- }
- tree_delete_selected_nodes(hotlist_old_tree, hotlist_old_tree_root);
+ hotlist_keypress(KEY_DELETE_LEFT);
}
/**
@@ -316,12 +295,7 @@ void hotlist_old_delete_selected(void)
*/
void hotlist_old_select_all(void)
{
- if (nsoption_bool(temp_treeview_test) != false) {
- hotlist_keypress(KEY_SELECT_ALL);
- return;
- }
- tree_set_node_selected(hotlist_old_tree, hotlist_old_tree_root,
- true, true);
+ hotlist_keypress(KEY_SELECT_ALL);
}
/**
@@ -329,12 +303,7 @@ void hotlist_old_select_all(void)
*/
void hotlist_old_clear_selection(void)
{
- if (nsoption_bool(temp_treeview_test) != false) {
- hotlist_keypress(KEY_CLEAR_SELECTION);
- return;
- }
- tree_set_node_selected(hotlist_old_tree, hotlist_old_tree_root,
- true, false);
+ hotlist_keypress(KEY_CLEAR_SELECTION);
}
/**
@@ -398,42 +367,7 @@ void hotlist_old_collapse_addresses(void)
*/
void hotlist_old_add_folder(bool selected)
{
- struct node *node, *parent = NULL;
-
- /* Update new hotlist */
- if (nsoption_bool(temp_treeview_test) != false) {
- hotlist_add_folder(NULL, false, 0);
- return;
- }
-
- creating_node = true;
-
- if (selected == true) {
- parent = tree_get_selected_node(tree_get_root(hotlist_old_tree));
- if (parent && (tree_node_is_folder(parent) == false)) {
- parent = tree_node_get_parent(parent);
- }
- }
-
- if (parent == NULL) {
- parent = tree_get_default_folder_node(hotlist_old_tree);
- }
-
- node = tree_create_folder_node(hotlist_old_tree,
- parent,
- messages_get("Untitled"),
- true,
- false,
- false);
- if (node == NULL) {
- warn_user(messages_get_errorcode(NSERROR_NOMEM), 0);
- return;
- }
-
- tree_set_node_user_callback(node, hotlist_old_node_callback, NULL);
- tree_set_node_icon(hotlist_old_tree, node, folder_icon);
- tree_start_edit(hotlist_old_tree,
- tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL));
+ hotlist_add_folder(NULL, false, 0);
}
/**
@@ -443,40 +377,13 @@ void hotlist_old_add_folder(bool selected)
*/
void hotlist_old_add_entry(bool selected)
{
- struct node *node;
- struct node *parent = NULL;
nsurl *url;
- creating_node = true;
-
- if (selected == true) {
- parent = tree_get_selected_node(tree_get_root(hotlist_old_tree));
- if (parent && (tree_node_is_folder(parent) == false)) {
- parent = tree_node_get_parent(parent);
- }
- }
-
- if (parent == NULL) {
- parent = tree_get_default_folder_node(hotlist_old_tree);
- }
if (nsurl_create("http://netsurf-browser.org/", &url) != NSERROR_OK)
return;
- /* Update new hotlist */
- if (nsoption_bool(temp_treeview_test) != false) {
- hotlist_add_entry(url, "New untitled entry", false, 0);
- nsurl_unref(url);
- return;
- }
- node = tree_create_URL_node(hotlist_old_tree, parent, url, "Untitled",
- hotlist_old_node_callback, NULL);
-
+ hotlist_add_entry(url, "New untitled entry", false, 0);
nsurl_unref(url);
-
- if (node == NULL)
- return;
- tree_set_node_user_callback(node, hotlist_old_node_callback, NULL);
- tree_url_node_edit_title(hotlist_old_tree, node);
}
/**
@@ -484,8 +391,6 @@ void hotlist_old_add_entry(bool selected)
*/
void hotlist_old_add_page(const char *url)
{
- const struct url_data *data;
- struct node *node, *parent;
nsurl *nsurl;
if (url == NULL)
@@ -495,21 +400,7 @@ void hotlist_old_add_page(const char *url)
return;
/* Update new hotlist */
- if (nsoption_bool(temp_treeview_test) != false) {
- hotlist_add_url(nsurl);
- nsurl_unref(nsurl);
- return;
- }
-
- data = urldb_get_url_data(nsurl);
- if (data == NULL)
- return;
-
- parent = tree_get_default_folder_node(hotlist_old_tree);
- node = tree_create_URL_node(hotlist_old_tree, parent, nsurl, NULL,
- hotlist_old_node_callback, NULL);
- tree_update_URL_node(hotlist_old_tree, node, nsurl, data);
-
+ hotlist_add_url(nsurl);
nsurl_unref(nsurl);
}
@@ -521,9 +412,6 @@ void hotlist_old_add_page(const char *url)
*/
void hotlist_old_add_page_xy(const char *url, int x, int y)
{
- const struct url_data *data;
- struct node *link, *node;
- bool before;
nsurl *nsurl;
if (url == NULL)
@@ -533,24 +421,7 @@ void hotlist_old_add_page_xy(const char *url, int x, int y)
return;
/* Update new hotlist */
- if (nsoption_bool(temp_treeview_test) != false) {
- hotlist_add_entry(nsurl, NULL, true, y);
- nsurl_unref(nsurl);
- return;
- }
-
- data = urldb_get_url_data(nsurl);
- if (data == NULL) {
- urldb_add_url(nsurl);
- urldb_set_url_persistence(nsurl, true);
- data = urldb_get_url_data(nsurl);
- }
- if (data != NULL) {
- link = tree_get_link_details(hotlist_old_tree, x, y, &before);
- node = tree_create_URL_node(NULL, NULL, nsurl,
- NULL, hotlist_old_node_callback, NULL);
- tree_link_node(hotlist_old_tree, link, node, before);
- }
+ hotlist_add_entry(nsurl, NULL, true, y);
nsurl_unref(nsurl);
}
@@ -561,11 +432,7 @@ void hotlist_old_add_page_xy(const char *url, int x, int y)
*/
void hotlist_old_launch_selected(bool tabs)
{
- if (nsoption_bool(temp_treeview_test) != false) {
- hotlist_keypress(KEY_CR);
- return;
- }
- tree_launch_selected(hotlist_old_tree, tabs);
+ hotlist_keypress(KEY_CR);
}
/**
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=4ce2f6fd553fc9e1eb5...
commit 4ce2f6fd553fc9e1eb544eb7664a97c25f103bf4
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Update to use new hotlist and global history manager.
diff --git a/desktop/browser.c b/desktop/browser.c
index 42738db..de03735 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -1252,10 +1252,7 @@ static nserror browser_window_callback(hlcache_handle *c,
content_get_type(c));
/* This is safe as we've just added the URL */
- if (nsoption_bool(temp_treeview_test) == false)
- history_global_add(urldb_get_url(url));
- else
- global_history_add(urldb_get_url(url));
+ global_history_add(urldb_get_url(url));
}
}
@@ -1287,10 +1284,7 @@ static nserror browser_window_callback(hlcache_handle *c,
browser_window_update_favicon(c, bw, NULL);
history_update(bw->history, c);
- if (nsoption_bool(temp_treeview_test) == false)
- hotlist_old_visited(c);
- else
- hotlist_update_url(hlcache_handle_get_url(c));
+ hotlist_update_url(hlcache_handle_get_url(c));
if (bw->refresh_interval != -1)
schedule(bw->refresh_interval,
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=8f2f4ca2a8a122acea7...
commit 8f2f4ca2a8a122acea79599886d69505d3d8007c
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Use new cookie manager.
diff --git a/content/urldb.c b/content/urldb.c
index feb7c6f..0dbb392 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -2542,12 +2542,7 @@ char *urldb_get_cookie(nsurl *url, bool include_http_only)
c->last_used = now;
- if (nsoption_bool(temp_treeview_test) == false)
- cookies_schedule_update(
- (struct cookie_data *)c);
- else
- cookie_manager_add(
- (struct cookie_data *)c);
+ cookie_manager_add((struct cookie_data *)c);
}
}
}
@@ -2583,12 +2578,7 @@ char *urldb_get_cookie(nsurl *url, bool include_http_only)
c->last_used = now;
- if (nsoption_bool(temp_treeview_test) == false)
- cookies_schedule_update(
- (struct cookie_data *)c);
- else
- cookie_manager_add(
- (struct cookie_data *)c);
+ cookie_manager_add((struct cookie_data *)c);
}
}
@@ -2632,11 +2622,7 @@ char *urldb_get_cookie(nsurl *url, bool include_http_only)
c->last_used = now;
- if (nsoption_bool(temp_treeview_test) == false)
- cookies_schedule_update(
- (struct cookie_data *)c);
- else
- cookie_manager_add((struct cookie_data *)c);
+ cookie_manager_add((struct cookie_data *)c);
}
}
@@ -2670,11 +2656,7 @@ char *urldb_get_cookie(nsurl *url, bool include_http_only)
c->last_used = now;
- if (nsoption_bool(temp_treeview_test) == false)
- cookies_schedule_update(
- (struct cookie_data *)c);
- else
- cookie_manager_add((struct cookie_data *)c);
+ cookie_manager_add((struct cookie_data *)c);
}
}
@@ -3429,10 +3411,7 @@ bool urldb_insert_cookie(struct cookie_internal_data *c, lwc_string *scheme,
else
p->cookies = d->next;
- if (nsoption_bool(temp_treeview_test) == false)
- cookies_remove((struct cookie_data *)d);
- else
- cookie_manager_remove((struct cookie_data *)d);
+ cookie_manager_remove((struct cookie_data *)d);
urldb_free_cookie(d);
urldb_free_cookie(c);
@@ -3449,17 +3428,10 @@ bool urldb_insert_cookie(struct cookie_internal_data *c, lwc_string *scheme,
else
p->cookies = c;
- if (nsoption_bool(temp_treeview_test) == false)
- cookies_remove((struct cookie_data *)d);
- else
- cookie_manager_remove((struct cookie_data *)d);
+ cookie_manager_remove((struct cookie_data *)d);
urldb_free_cookie(d);
- if (nsoption_bool(temp_treeview_test) == false)
- cookies_schedule_update(
- (struct cookie_data *)c);
- else
- cookie_manager_add((struct cookie_data *)c);
+ cookie_manager_add((struct cookie_data *)c);
}
} else {
c->prev = p->cookies_end;
@@ -3470,10 +3442,7 @@ bool urldb_insert_cookie(struct cookie_internal_data *c, lwc_string *scheme,
p->cookies = c;
p->cookies_end = c;
- if (nsoption_bool(temp_treeview_test) == false)
- cookies_schedule_update((struct cookie_data *)c);
- else
- cookie_manager_add((struct cookie_data *)c);
+ cookie_manager_add((struct cookie_data *)c);
}
return true;
-----------------------------------------------------------------------
Summary of changes:
amiga/context_menu.c | 28 +-
amiga/cookies.c | 9 +-
amiga/gui.c | 11 +-
amiga/history.c | 7 +-
amiga/history.h | 1 -
amiga/hotlist.c | 43 +-
amiga/menu.c | 11 +-
amiga/misc.c | 2 +-
amiga/tree.c | 83 +-
amiga/tree.h | 4 -
atari/gui.c | 2 -
atari/history.c | 8 +-
atari/hotlist.c | 29 +-
atari/misc.c | 2 +-
atari/treeview.c | 29 +-
beos/Makefile.target | 2 +-
beos/gui.cpp | 6 -
beos/treeview.cpp | 56 -
cocoa/BookmarksController.m | 25 +-
cocoa/HistoryWindowController.m | 6 +-
cocoa/Tree.h | 1 -
cocoa/Tree.m | 9 -
cocoa/utils.m | 10 -
content/urldb.c | 48 +-
desktop/Makefile | 8 +-
desktop/browser.c | 12 +-
desktop/cookie_manager.c | 15 +-
desktop/cookie_manager.h | 19 +-
desktop/cookies_old.c | 529 -------
desktop/cookies_old.h | 66 -
desktop/global_history.c | 25 +-
desktop/global_history.h | 19 +-
desktop/history_global_core.c | 450 ------
desktop/history_global_core.h | 46 -
desktop/hotlist.c | 17 +-
desktop/hotlist.h | 19 +-
desktop/hotlist_old.c | 584 --------
desktop/hotlist_old.h | 64 -
desktop/options.h | 3 -
desktop/sslcert_viewer.c | 8 -
desktop/sslcert_viewer.h | 11 +-
desktop/tree.c | 3121 +--------------------------------------
desktop/tree.h | 179 +---
desktop/tree_url_node.c | 972 ------------
desktop/tree_url_node.h | 61 -
desktop/treeview.c | 197 +++-
desktop/treeview.h | 20 +-
framebuffer/Makefile.target | 2 +-
framebuffer/misc.c | 1 -
framebuffer/tree.c | 45 -
gtk/cookies.c | 31 +-
gtk/gui.c | 6 -
gtk/history.c | 36 +-
gtk/hotlist.c | 37 +-
gtk/scaffolding.c | 4 +-
gtk/treeview.c | 58 +-
gtk/treeview.h | 4 -
monkey/utils.c | 8 +-
riscos/cookies.c | 46 +-
riscos/global_history.c | 50 +-
riscos/gui.c | 14 -
riscos/hotlist.c | 90 +-
riscos/menus.c | 3 +-
riscos/save.c | 8 +-
riscos/sslcert.c | 2 -
riscos/treeview.c | 47 +-
riscos/treeview.h | 5 -
riscos/window.c | 5 +-
test/llcache.c | 10 +-
test/urldbtest.c | 6 +-
windows/Makefile.target | 3 +-
windows/misc.c | 1 -
windows/tree.c | 45 -
73 files changed, 636 insertions(+), 6808 deletions(-)
delete mode 100644 beos/treeview.cpp
delete mode 100644 desktop/cookies_old.c
delete mode 100644 desktop/cookies_old.h
delete mode 100644 desktop/history_global_core.c
delete mode 100644 desktop/history_global_core.h
delete mode 100644 desktop/hotlist_old.c
delete mode 100644 desktop/hotlist_old.h
delete mode 100644 desktop/tree_url_node.c
delete mode 100644 desktop/tree_url_node.h
delete mode 100644 framebuffer/tree.c
delete mode 100644 windows/tree.c
diff --git a/amiga/context_menu.c b/amiga/context_menu.c
index e7bbe62..5a3da55 100644
--- a/amiga/context_menu.c
+++ b/amiga/context_menu.c
@@ -41,10 +41,9 @@
#include "amiga/utf8.h"
#include "desktop/browser_private.h"
#include "desktop/local_history.h"
-#include "desktop/hotlist_old.h"
+#include "desktop/hotlist.h"
#include "desktop/searchweb.h"
#include "desktop/textinput.h"
-#include "desktop/tree_url_node.h"
#include "render/form.h"
#include "utils/utf8.h"
#include "utils/messages.h"
@@ -768,7 +767,14 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
case CMID_URLHOTLIST:
case CMID_PAGEHOTLIST:
- hotlist_old_add_page(userdata);
+ {
+ nsurl *nsurl;
+ if (nsurl_create(url, &nsurl) != NSERROR_OK)
+ break;
+
+ hotlist_add_url(nsurl);
+ nsurl_unref(nsurl);
+ }
break;
case CMID_FRAMECOPYURL:
@@ -1216,35 +1222,35 @@ static uint32 ami_context_menu_hook_tree(struct Hook *hook, Object *item, APTR r
break;
case CMID_TREE_EDITFOLDER:
- hotlist_old_edit_selected();
+ hotlist_edit_selection();
break;
case CMID_TREE_EDITTITLE:
- tree_url_node_edit_title(tree, userdata);
+ warn_user("TODO.", 0);
break;
case CMID_TREE_EDITLINK:
- tree_url_node_edit_url(tree, userdata);
+ warn_user("TODO.", 0);
break;
case CMID_TREE_NEWFOLDER:
- hotlist_old_add_folder(true);
+ hotlist_add_folder(NULL, false, 0);
break;
case CMID_TREE_NEWITEM:
- hotlist_old_add_entry(true);
+ hotlist_add_entry(NULL, NULL, false, 0);
break;
case CMID_TREE_SETDEFAULT:
- hotlist_old_set_default_folder(false);
+ warn_user("TODO.", 0);
break;
case CMID_TREE_CLEARDEFAULT:
- hotlist_old_set_default_folder(true);
+ warn_user("TODO.", 0);
break;
case CMID_TREE_ADDHOTLIST:
- hotlist_old_add_page(tree_url_node_get_url(userdata));
+ warn_user("TODO.", 0);
break;
case CMID_TREE_DELETE:
diff --git a/amiga/cookies.c b/amiga/cookies.c
index 05fd9f8..e29df34 100755
--- a/amiga/cookies.c
+++ b/amiga/cookies.c
@@ -18,23 +18,18 @@
#include <proto/exec.h>
#include "amiga/cookies.h"
-#include "desktop/cookies_old.h"
+#include "desktop/cookie_manager.h"
#include "amiga/tree.h"
void ami_cookies_initialise(void)
{
- cookies_window = ami_tree_create(cookies_get_tree_flags(), NULL);
+ cookies_window = ami_tree_create(TREE_COOKIES, NULL);
if(!cookies_window) return;
-
- cookies_initialise(ami_tree_get_tree(cookies_window),
- tree_directory_icon_name,
- tree_content_icon_name);
}
void ami_cookies_free()
{
- cookies_cleanup();
ami_tree_destroy(cookies_window);
cookies_window = NULL;
}
diff --git a/amiga/gui.c b/amiga/gui.c
index f60e478..6a9e6d2 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -29,7 +29,6 @@
#include "desktop/searchweb.h"
#include "desktop/textinput.h"
#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
#include "image/ico.h"
#include "utils/log.h"
#include "utils/messages.h"
@@ -163,8 +162,6 @@ struct Hook newprefs_hook;
static char *current_user;
static char *current_user_dir;
-const char tree_directory_icon_name[] = "def_drawer.info";
-const char tree_content_icon_name[] = "def_project.info";
static const __attribute__((used)) char *stack_cookie = "\0$STACK:131072\0";
const char * const versvn;
@@ -580,8 +577,6 @@ static nserror ami_set_options(struct nsoption_s *defaults)
}
}
- tree_set_icon_dir(strdup("ENV:Sys"));
-
#ifndef __amigaos4__
nsoption_set_bool(download_notify, false);
nsoption_set_bool(context_menu, false);
@@ -2857,6 +2852,7 @@ void ami_update_buttons(struct gui_window_2 *gwin)
void ami_gui_hotlist_scan_2(struct tree *tree, struct node *root, WORD *gen, int *item,
struct List *speed_button_list, struct gui_window_2 *gwin)
{
+#if 0
struct node *tempnode;
struct node_element *element=NULL;
struct node *node;
@@ -2889,10 +2885,12 @@ void ami_gui_hotlist_scan_2(struct tree *tree, struct node *root, WORD *gen, int
}
*gen = *gen - 1;
+#endif
}
int ami_gui_hotlist_scan(struct tree *tree, struct List *speed_button_list, struct gui_window_2 *gwin)
{
+#if 0
struct node *root = tree_node_get_child(tree_get_root(tree));
struct node *node;
struct node_element *element;
@@ -2910,6 +2908,9 @@ int ami_gui_hotlist_scan(struct tree *tree, struct List *speed_button_list, stru
}
return item;
+#else
+ return 0;
+#endif
}
void ami_gui_hotlist_toolbar_add(struct gui_window_2 *gwin)
diff --git a/amiga/history.c b/amiga/history.c
index cc161d0..663c2d9 100755
--- a/amiga/history.c
+++ b/amiga/history.c
@@ -18,23 +18,18 @@
#include "amiga/history.h"
#include "amiga/tree.h"
-#include "desktop/history_global_core.h"
#include <proto/exec.h>
#include "amiga/tree.h"
void ami_global_history_initialise(void)
{
- global_history_window = ami_tree_create(history_global_get_tree_flags(), NULL);
+ global_history_window = ami_tree_create(TREE_HISTORY, NULL);
if(!global_history_window) return;
-
- history_global_initialise(ami_tree_get_tree(global_history_window),
- tree_directory_icon_name);
}
void ami_global_history_free()
{
- history_global_cleanup();
ami_tree_destroy(global_history_window);
global_history_window = NULL;
}
diff --git a/amiga/history.h b/amiga/history.h
index b69d46c..1f06474 100755
--- a/amiga/history.h
+++ b/amiga/history.h
@@ -19,7 +19,6 @@
#ifndef AMIGA_HISTORY_H
#define AMIGA_HISTORY_H
#include "desktop/tree.h"
-#include "desktop/history_global_core.h"
#define GLOBAL_HISTORY_RECENT_URLS 16
diff --git a/amiga/hotlist.c b/amiga/hotlist.c
index 9b9fd80..6fa1568 100755
--- a/amiga/hotlist.c
+++ b/amiga/hotlist.c
@@ -19,58 +19,17 @@
#include <proto/exec.h>
#include "amiga/hotlist.h"
#include "amiga/tree.h"
-#include "desktop/hotlist_old.h"
-#include "utils/messages.h"
-
-bool ami_hotlist_find_dir(struct tree *tree, const char *dir_name)
-{
- struct node *root = tree_node_get_child(tree_get_root(tree));
- struct node *node;
- struct node_element *element;
-
- for (node = root; node; node = tree_node_get_next(node))
- {
- element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
- if(!element) element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
- if(element && (strcmp(tree_node_element_get_text(element), dir_name) == 0))
- {
- return true;
- }
- }
-
- return false;
-}
-
-void ami_hotlist_add_default_dirs(struct tree *tree)
-{
- if(ami_hotlist_find_dir(tree, messages_get("HotlistMenu")) == false) {
- tree_create_folder_node(tree, tree_get_root(tree),
- messages_get("HotlistMenu"), true, true, false);
- }
-
- if(ami_hotlist_find_dir(tree, messages_get("HotlistToolbar")) == false) {
- tree_create_folder_node(tree, tree_get_root(tree),
- messages_get("HotlistToolbar"), true, true, false);
- }
-}
void ami_hotlist_initialise(const char *hotlist_file)
{
tree_hotlist_path = hotlist_file;
- hotlist_window = ami_tree_create(hotlist_old_get_tree_flags(), NULL);
+ hotlist_window = ami_tree_create(TREE_HOTLIST, NULL);
if(!hotlist_window) return;
-
- hotlist_old_initialise(ami_tree_get_tree(hotlist_window),
- hotlist_file,
- tree_directory_icon_name);
-
- ami_hotlist_add_default_dirs(ami_tree_get_tree(hotlist_window));
}
void ami_hotlist_free(const char *hotlist_file)
{
- hotlist_old_cleanup(hotlist_file);
ami_tree_destroy(hotlist_window);
hotlist_window = NULL;
}
diff --git a/amiga/menu.c b/amiga/menu.c
index 6d8c5eb..d2db1f1 100644
--- a/amiga/menu.c
+++ b/amiga/menu.c
@@ -58,8 +58,7 @@
#include "amiga/theme.h"
#include "amiga/tree.h"
#include "amiga/utf8.h"
-#include "desktop/tree_url_node.h"
-#include "desktop/hotlist_old.h"
+#include "desktop/hotlist.h"
#include "desktop/browser_private.h"
#include "desktop/gui.h"
#include "desktop/textinput.h"
@@ -540,6 +539,7 @@ void ami_menu_arexx_scan(struct gui_window_2 *gwin)
ULONG ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin)
{
+#if 0
struct node *root = tree_node_get_child(tree_get_root(tree));
struct node *node;
struct node_element *element;
@@ -560,11 +560,15 @@ ULONG ami_menu_scan(struct tree *tree, struct gui_window_2 *gwin)
}
return(item - AMI_MENU_HOTLIST);
+#else
+ return 0;
+#endif
}
void ami_menu_scan_2(struct tree *tree, struct node *root, WORD *gen,
int *item, struct gui_window_2 *gwin)
{
+#if 0
struct node *tempnode;
struct node_element *element=NULL;
struct node *node;
@@ -602,6 +606,7 @@ void ami_menu_scan_2(struct tree *tree, struct node *root, WORD *gen,
}
*gen = *gen - 1;
+#endif
}
void ami_menu_update_checked(struct gui_window_2 *gwin)
@@ -1032,7 +1037,7 @@ static void ami_menu_item_hotlist_add(struct Hook *hook, APTR window, struct Int
nsurl_access(hlcache_handle_get_url(bw->current_content)) == NULL)
return;
- hotlist_old_add_page(nsurl_access(hlcache_handle_get_url(bw->current_content)));
+ hotlist_add_url(hlcache_handle_get_url(bw->current_content));
}
static void ami_menu_item_hotlist_show(struct Hook *hook, APTR window, struct IntuiMessage *msg)
diff --git a/amiga/misc.c b/amiga/misc.c
index 11af051..003a5fb 100755
--- a/amiga/misc.c
+++ b/amiga/misc.c
@@ -32,7 +32,7 @@
#include "amiga/gui.h"
#include "amiga/utf8.h"
-#include "desktop/cookies_old.h"
+#include "desktop/cookie_manager.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/url.h"
diff --git a/amiga/tree.c b/amiga/tree.c
index 478000b..d5ae885 100644
--- a/amiga/tree.c
+++ b/amiga/tree.c
@@ -55,11 +55,10 @@
#include "amiga/filetype.h"
#include "utils/nsoption.h"
#include "content/urldb.h"
-#include "desktop/cookies_old.h"
-#include "desktop/history_global_core.h"
-#include "desktop/hotlist_old.h"
+#include "desktop/cookie_manager.h"
+#include "desktop/global_history.h"
+#include "desktop/hotlist.h"
#include "desktop/sslcert_viewer.h"
-#include "desktop/tree_url_node.h"
#include "utils/utils.h"
#include "utils/messages.h"
@@ -194,18 +193,6 @@ void ami_tree_get_window_dimensions(int *width, int *height, void *data)
}
/**
- * Translates a content_type to the name of a respective icon
- *
- * \param content_type content type
- * \param buffer buffer for the icon name
- */
-void tree_icon_name_from_content_type(char *buffer, content_type type)
-{
- const char *ftype = ami_content_type_to_file_type(type);
- sprintf(buffer, "def_%s.info", ftype);
-}
-
-/**
* Scrolls the tree to make an element visible
*
* \param y Y coordinate of the element
@@ -337,11 +324,13 @@ void ami_tree_drag_end(struct treeview_window *twin, int x, int y)
}
}
+#if 0
else if((tw = ami_window_at_pointer(AMINS_TVWINDOW)) &&
(tw != twin) && (tw->type == AMI_TREE_HOTLIST))
{
- hotlist_old_add_page_xy(tree_url_node_get_url(selected_node), x, y);
+ hotlist_add_entry(tree_url_node_get_url(selected_node), NULL, true, y);
}
+#endif
}
tree_drag_end(twin->tree, twin->mouse_state,
twin->drag_x, twin->drag_y,
@@ -678,7 +667,6 @@ void ami_tree_open(struct treeview_window *twin,int type)
ami_tree_update_buttons(twin);
ami_tree_resized(twin->tree, twin->max_width, twin->max_height, twin);
- tree_set_redraw(twin->tree, true);
ami_tree_draw(twin);
}
@@ -686,7 +674,6 @@ void ami_tree_close(struct treeview_window *twin)
{
int i;
- tree_set_redraw(twin->tree, false);
twin->win = NULL;
DisposeObject(twin->objects[OID_MAIN]);
DelObjectNoFree(twin->node);
@@ -1012,9 +999,9 @@ BOOL ami_tree_event(struct treeview_window *twin)
AddPart(fname,savereq->fr_File,1024);
ami_update_pointer(twin->win, GUI_POINTER_WAIT);
if(twin->type == AMI_TREE_HISTORY)
- history_global_export(fname);
+ global_history_export(fname, NULL);
else if(twin->type == AMI_TREE_HOTLIST)
- hotlist_old_export(fname);
+ hotlist_export(fname, NULL);
ami_update_pointer(twin->win, GUI_POINTER_DEFAULT);
}
break;
@@ -1026,13 +1013,13 @@ BOOL ami_tree_event(struct treeview_window *twin)
switch(twin->type)
{
case AMI_TREE_HISTORY:
- history_global_expand_all();
+ global_history_expand(false);
break;
case AMI_TREE_COOKIES:
- cookies_expand_all();
+ cookie_manager_expand(false);
break;
case AMI_TREE_HOTLIST:
- hotlist_old_expand_all();
+ hotlist_expand(false);
break;
}
break;
@@ -1041,13 +1028,13 @@ BOOL ami_tree_event(struct treeview_window *twin)
switch(twin->type)
{
case AMI_TREE_HISTORY:
- history_global_expand_directories();
+ global_history_expand(true);
break;
case AMI_TREE_COOKIES:
- cookies_expand_domains();
+ cookie_manager_expand(true);
break;
case AMI_TREE_HOTLIST:
- hotlist_old_expand_directories();
+ hotlist_expand(true);
break;
}
break;
@@ -1056,13 +1043,13 @@ BOOL ami_tree_event(struct treeview_window *twin)
switch(twin->type)
{
case AMI_TREE_HISTORY:
- history_global_expand_addresses();
+ global_history_expand(false);
break;
case AMI_TREE_COOKIES:
- cookies_expand_cookies();
+ cookie_manager_expand(false);
break;
case AMI_TREE_HOTLIST:
- hotlist_old_expand_addresses();
+ hotlist_expand(false);
break;
}
break;
@@ -1076,13 +1063,13 @@ BOOL ami_tree_event(struct treeview_window *twin)
switch(twin->type)
{
case AMI_TREE_HISTORY:
- history_global_collapse_all();
+ global_history_contract(true);
break;
case AMI_TREE_COOKIES:
- cookies_collapse_all();
+ cookie_manager_contract(true);
break;
case AMI_TREE_HOTLIST:
- hotlist_old_collapse_all();
+ hotlist_contract(true);
break;
}
break;
@@ -1091,13 +1078,13 @@ BOOL ami_tree_event(struct treeview_window *twin)
switch(twin->type)
{
case AMI_TREE_HISTORY:
- history_global_collapse_directories();
+ global_history_contract(true);
break;
case AMI_TREE_COOKIES:
- cookies_collapse_domains();
+ cookie_manager_contract(true);
break;
case AMI_TREE_HOTLIST:
- hotlist_old_collapse_directories();
+ hotlist_contract(true);
break;
}
break;
@@ -1106,13 +1093,13 @@ BOOL ami_tree_event(struct treeview_window *twin)
switch(twin->type)
{
case AMI_TREE_HISTORY:
- history_global_collapse_addresses();
+ global_history_contract(false);
break;
case AMI_TREE_COOKIES:
- cookies_collapse_cookies();
+ cookie_manager_contract(false);
break;
case AMI_TREE_HOTLIST:
- hotlist_old_collapse_addresses();
+ hotlist_contract(false);
break;
}
break;
@@ -1157,13 +1144,13 @@ BOOL ami_tree_event(struct treeview_window *twin)
switch(twin->type)
{
case AMI_TREE_HISTORY:
- history_global_delete_selected();
+ global_history_keypress(KEY_DELETE_LEFT);
break;
case AMI_TREE_COOKIES:
- cookies_delete_selected();
+ cookie_manager_keypress(KEY_DELETE_LEFT);
break;
case AMI_TREE_HOTLIST:
- hotlist_old_delete_selected();
+ hotlist_keypress(KEY_DELETE_LEFT);
break;
}
ami_tree_update_buttons(twin);
@@ -1173,13 +1160,13 @@ BOOL ami_tree_event(struct treeview_window *twin)
switch(twin->type)
{
case AMI_TREE_HISTORY:
- history_global_select_all();
+ global_history_keypress(KEY_SELECT_ALL);
break;
case AMI_TREE_COOKIES:
- cookies_select_all();
+ cookie_manager_keypress(KEY_SELECT_ALL);
break;
case AMI_TREE_HOTLIST:
- hotlist_old_select_all();
+ hotlist_keypress(KEY_SELECT_ALL);
break;
}
ami_tree_update_buttons(twin);
@@ -1189,13 +1176,13 @@ BOOL ami_tree_event(struct treeview_window *twin)
switch(twin->type)
{
case AMI_TREE_HISTORY:
- history_global_clear_selection();
+ global_history_keypress(KEY_CLEAR_SELECTION);
break;
case AMI_TREE_COOKIES:
- cookies_clear_selection();
+ cookie_manager_keypress(KEY_CLEAR_SELECTION);
break;
case AMI_TREE_HOTLIST:
- hotlist_old_clear_selection();
+ hotlist_keypress(KEY_CLEAR_SELECTION);
break;
}
ami_tree_update_buttons(twin);
diff --git a/amiga/tree.h b/amiga/tree.h
index 179b61a..d8d50fe 100755
--- a/amiga/tree.h
+++ b/amiga/tree.h
@@ -25,10 +25,6 @@
#include "amiga/gui.h"
#include "desktop/tree.h"
-/* defined in front end code */
-extern const char tree_directory_icon_name[];
-extern const char tree_content_icon_name[];
-
struct treeview_window;
enum
diff --git a/atari/gui.c b/atari/gui.c
index 5c384b7..8db4765 100644
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -1004,8 +1004,6 @@ static void gui_init(int argc, char** argv)
LOG(("Initializing plotters..."));
plot_init(nsoption_charp(atari_font_driver));
- tree_set_icon_dir(nsoption_charp(tree_icons_path));
-
aes_event_in.emi_m1leave = MO_LEAVE;
aes_event_in.emi_m1.g_w = 1;
aes_event_in.emi_m1.g_h = 1;
diff --git a/atari/history.c b/atari/history.c
index 5501b90..1a19d4a 100755
--- a/atari/history.c
+++ b/atari/history.c
@@ -24,9 +24,8 @@
#include "desktop/browser.h"
#include "utils/nsoption.h"
#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
#include "desktop/gui.h"
-#include "desktop/history_global_core.h"
+#include "desktop/global_history.h"
#include "desktop/browser.h"
#include "utils/messages.h"
#include "content/content.h"
@@ -42,7 +41,6 @@
//TODO: remove/add guiwin handle on close / open - so that the list
// is kept tiny.
-extern char * tree_directory_icon_name;
extern GRECT desk_area;
struct s_atari_global_history gl_history;
@@ -118,7 +116,7 @@ bool atari_global_history_init( void )
}
wind_set_str(handle, WF_NAME, (char*)messages_get("GlobalHistory"));
- gl_history.tv = atari_treeview_create(history_global_get_tree_flags(),
+ gl_history.tv = atari_treeview_create(TREE_HISTORY,
gl_history.window, handle_event);
gemtk_wm_unlink(gl_history.window);
@@ -129,7 +127,6 @@ bool atari_global_history_init( void )
return( false );
}
- history_global_initialise(gl_history.tv->tree, "dir.png");
gl_history.init = true;
}
return( true );
@@ -143,7 +140,6 @@ void atari_global_history_destroy( void )
return;
}
if( gl_history.window != NULL ) {
- history_global_cleanup();
if( gl_history.open )
atari_global_history_close();
wind_delete(gemtk_wm_get_handle(gl_history.window));
diff --git a/atari/hotlist.c b/atari/hotlist.c
index 6c80db3..57cf0c0 100755
--- a/atari/hotlist.c
+++ b/atari/hotlist.c
@@ -28,9 +28,8 @@
#include "content/hlcache.h"
#include "content/urldb.h"
#include "utils/nsoption.h"
-#include "desktop/hotlist_old.h"
+#include "desktop/hotlist.h"
#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
#include "desktop/gui.h"
#include "utils/log.h"
#include "utils/messages.h"
@@ -62,20 +61,20 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
switch (msg[4]) {
case TOOLBAR_HOTLIST_CREATE_FOLDER:
- hotlist_old_add_folder(true);
+ hotlist_add_folder(NULL, false, 0);
break;
case TOOLBAR_HOTLIST_ADD:
- atari_hotlist_add_page("http://www.de", "");
+ atari_hotlist_add_page(NULL, NULL);
break;
case TOOLBAR_HOTLIST_DELETE:
- hotlist_old_delete_selected();
+ hotlist_keypress(KEY_DELETE_LEFT);
gemtk_wm_exec_redraw(tv->window, NULL);
break;
case TOOLBAR_HOTLIST_EDIT:
- hotlist_old_edit_selected();
+ hotlist_edit_selection();
break;
}
@@ -130,7 +129,7 @@ void atari_hotlist_init(void)
gemtk_wm_unlink(hl.window);
tree_hotlist_path = (const char*)&hl.path;
hl.tv = atari_treeview_create(
- hotlist_old_get_tree_flags(),
+ TREE_HOTLIST,
hl.window,
handle_event
);
@@ -140,12 +139,6 @@ void atari_hotlist_init(void)
return;
}
- hotlist_old_initialise(
- hl.tv->tree,
- (char*)&hl.path,
- "dir.png"
- );
-
} else {
}
@@ -190,7 +183,6 @@ void atari_hotlist_destroy(void)
return;
}
if( hl.window != NULL ) {
- hotlist_old_cleanup( (char*)&hl.path );
if (hl.open)
atari_hotlist_close();
wind_delete(gemtk_wm_get_handle(hl.window));
@@ -215,15 +207,20 @@ void atari_hotlist_add_page( const char * url, const char * title )
struct node * root;
struct node * selected = NULL;
struct node * folder = NULL;
+ nsurl *nsurl;
NSTREEVIEW tv = hl.tv;
if(hl.tv == NULL )
return;
atari_hotlist_open();
+ if (nsurl_create(url, &nsurl) != NSERROR_OK)
+ return;
+
if( hl.tv->click.x >= 0 && hl.tv->click.y >= 0 ){
- hotlist_old_add_page_xy( url, hl.tv->click.x, hl.tv->click.y );
+ hotlist_add_entry( nsurl, title, true, hl.tv->click.y );
} else {
- hotlist_old_add_page( url );
+ hotlist_add_url( nsurl );
}
+ nsurl_unref(nsurl);
}
diff --git a/atari/misc.c b/atari/misc.c
index 75410d2..974d37e 100755
--- a/atari/misc.c
+++ b/atari/misc.c
@@ -27,7 +27,7 @@
#include "content/content.h"
#include "content/hlcache.h"
-#include "desktop/cookies_old.h"
+#include "desktop/cookie_manager.h"
#include "desktop/mouse.h"
#include "desktop/tree.h"
#include "utils/nsoption.h"
diff --git a/atari/treeview.c b/atari/treeview.c
index 261b2ee..f25bf7e 100755
--- a/atari/treeview.c
+++ b/atari/treeview.c
@@ -27,7 +27,6 @@
#include "desktop/plotters.h"
#include "desktop/textinput.h"
#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
#include "desktop/textinput.h"
#include "utils/log.h"
#include "utils/messages.h"
@@ -224,11 +223,7 @@ static void __CDECL on_mbutton_event(NSTREEVIEW tv, EVMULT_OUT *ev_out,
cur_rel_x = origin_rel_x;
cur_rel_y = origin_rel_y;
- if( tree_is_edited(tv->tree) ){
- gem_set_cursor(&gem_cursors.ibeam);
- } else {
- gem_set_cursor(&gem_cursors.hand);
- }
+ gem_set_cursor(&gem_cursors.hand);
tv->startdrag.x = origin_rel_x;
tv->startdrag.y = origin_rel_y;
@@ -293,7 +288,6 @@ void atari_treeview_open( NSTREEVIEW tv )
{
if( tv->window != NULL ) {
gemtk_wm_link(tv->window);
- tree_set_redraw(tv->tree, true);
}
}
@@ -301,7 +295,6 @@ void atari_treeview_open( NSTREEVIEW tv )
void atari_treeview_close(NSTREEVIEW tv)
{
if(tv->window != NULL) {
- tree_set_redraw(tv->tree, false);
gemtk_wm_unlink(tv->window);
}
}
@@ -527,23 +520,3 @@ void atari_treeview_get_dimensions(int *width, int *height,
*height = work.g_h;
}
}
-
-
-/**
- * Translates a content_type to the name of a respective icon
- *
- * \param content_type content type
- * \param buffer buffer for the icon name
- */
-void tree_icon_name_from_content_type(char *buffer, content_type type)
-{
- switch (type) {
- case CONTENT_HTML:
- case CONTENT_TEXTPLAIN:
- case CONTENT_CSS:
- case CONTENT_IMAGE:
- default:
- strcpy( buffer, "content.png" );
- break;
- }
-}
diff --git a/beos/Makefile.target b/beos/Makefile.target
index 8df9ec3..499ec16 100644
--- a/beos/Makefile.target
+++ b/beos/Makefile.target
@@ -89,7 +89,7 @@ endif
# S_BEOS are sources purely for the BeOS build
S_BEOS := about.cpp bitmap.cpp download.cpp fetch_rsrc.cpp filetype.cpp \
font.cpp gui.cpp login.cpp gui_options.cpp plotters.cpp \
- scaffolding.cpp search.cpp schedule.cpp thumbnail.cpp treeview.cpp \
+ scaffolding.cpp search.cpp schedule.cpp thumbnail.cpp \
throbber.cpp window.cpp
S_BEOS := $(addprefix beos/,$(S_BEOS))
diff --git a/beos/gui.cpp b/beos/gui.cpp
index 0abef08..ffaccc8 100644
--- a/beos/gui.cpp
+++ b/beos/gui.cpp
@@ -50,7 +50,6 @@ extern "C" {
#include "content/urldb.h"
#include "desktop/401login.h"
#include "desktop/browser_private.h"
-#include "desktop/cookies_old.h"
#include "desktop/gui.h"
#include "desktop/netsurf.h"
#include "utils/nsoption.h"
@@ -1078,11 +1077,6 @@ char *url_to_path(const char *url)
return path;
}
-bool cookies_update(const char *domain, const struct cookie_data *data)
-{
- return true;
-}
-
static void *myrealloc(void *ptr, size_t len, void *pw)
{
if (len == 0) {
diff --git a/beos/treeview.cpp b/beos/treeview.cpp
deleted file mode 100644
index 4728995..0000000
--- a/beos/treeview.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2008 François Revol <mmu_man(a)users.sourceforge.net>
- * Copyright 2004 Richard Wilson <not_ginger_matt(a)users.sourceforge.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/** \file
- * Generic tree handling (implementation).
- */
-
-
-#define __STDBOOL_H__ 1
-extern "C" {
-#include "utils/config.h"
-#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
-}
-
-const char tree_directory_icon_name[] = "directory.png";
-const char tree_content_icon_name[] = "content.png";
-
-
-
-
-/**
- * Translates a content_type to the name of a respective icon
- *
- * \param content_type content type
- * \param buffer buffer for the icon name
- */
-void tree_icon_name_from_content_type(char *buffer, content_type type)
-{
- // TODO: design/acquire icons
- switch (type) {
- case CONTENT_HTML:
- case CONTENT_TEXTPLAIN:
- case CONTENT_CSS:
- case CONTENT_IMAGE:
- default:
- sprintf(buffer, tree_content_icon_name);
- break;
- }
-}
diff --git a/cocoa/BookmarksController.m b/cocoa/BookmarksController.m
index a2c5a45..96041ab 100644
--- a/cocoa/BookmarksController.m
+++ b/cocoa/BookmarksController.m
@@ -24,9 +24,8 @@
#import "cocoa/gui.h"
#import "desktop/browser_private.h"
-#import "desktop/hotlist_old.h"
+#import "desktop/hotlist.h"
#import "desktop/tree.h"
-#import "desktop/tree_url_node.h"
#import "utils/messages.h"
@interface BookmarksController ()
@@ -49,8 +48,7 @@ static const char *cocoa_hotlist_path( void )
{
if ((self = [super initWithWindowNibName: @"BookmarksWindow"]) == nil) return nil;
tree_hotlist_path = cocoa_hotlist_path();
- tree = [[Tree alloc] initWithFlags: hotlist_old_get_tree_flags()];
- hotlist_old_initialise( [tree tree], cocoa_hotlist_path(), "directory.png" );
+ tree = [[Tree alloc] initWithFlags: TREE_HOTLIST];
nodeForMenu = NSCreateMapTable( NSNonOwnedPointerMapKeyCallBacks, NSNonOwnedPointerMapValueCallBacks, 0 );
[[NSNotificationCenter defaultCenter] addObserver:self
@@ -68,14 +66,13 @@ static const char *cocoa_hotlist_path( void )
- (void) save;
{
- hotlist_old_export( cocoa_hotlist_path() );
+ hotlist_export( cocoa_hotlist_path(), NULL );
}
- (void) dealloc;
{
[self setView: nil];
NSFreeMapTable( nodeForMenu );
- hotlist_old_cleanup( cocoa_hotlist_path() );
[tree release];
[[NSNotificationCenter defaultCenter] removeObserver: self];
@@ -85,6 +82,7 @@ static const char *cocoa_hotlist_path( void )
- (void) menuNeedsUpdate: (NSMenu *)menu
{
+#if 0
for (NSMenuItem *item in [menu itemArray]) {
if ([item hasSubmenu]) NSMapRemove( nodeForMenu, [item submenu] );
[menu removeItem: item];
@@ -97,7 +95,6 @@ static const char *cocoa_hotlist_path( void )
[menu addItem: [[item copy] autorelease]];
}
hasSeparator = false;
- node = [tree rootNode];
}
for (struct node *child = tree_node_get_child( node );
@@ -125,6 +122,7 @@ static const char *cocoa_hotlist_path( void )
[item setAction: @selector( openBookmarkURL: )];
}
}
+#endif
}
- (IBAction) openBookmarkURL: (id) sender;
@@ -166,8 +164,7 @@ static const char *cocoa_hotlist_path( void )
{
struct browser_window *bw = [[(NetSurfApp *)NSApp frontTab] browser];
if (bw && bw->current_content) {
- const char *url = nsurl_access(hlcache_handle_get_url( bw->current_content ));
- hotlist_old_add_page( url );
+ hotlist_add_url( nsurl_access(hlcache_handle_get_url( bw->current_content )) );
}
}
@@ -184,8 +181,8 @@ static const char *cocoa_hotlist_path( void )
- (void) windowDidLoad;
{
- hotlist_old_expand_all();
- hotlist_old_collapse_all();
+ hotlist_expand(false);
+ hotlist_contract(true);
[view setTree: tree];
}
@@ -200,17 +197,17 @@ static const char *cocoa_hotlist_path( void )
- (IBAction) editSelected: (id) sender;
{
- hotlist_old_edit_selected();
+ hotlist_edit_selection();
}
- (IBAction) deleteSelected: (id) sender;
{
- hotlist_old_delete_selected();
+ hotlist_keypress(KEY_DELETE_LEFT);
}
- (IBAction) addFolder: (id) sender;
{
- hotlist_old_add_folder(true);
+ hotlist_add_folder(NULL, false, 0);
}
@end
diff --git a/cocoa/HistoryWindowController.m b/cocoa/HistoryWindowController.m
index 94fb297..cae679b 100644
--- a/cocoa/HistoryWindowController.m
+++ b/cocoa/HistoryWindowController.m
@@ -20,7 +20,7 @@
#import "cocoa/Tree.h"
#import "cocoa/TreeView.h"
-#import "desktop/history_global_core.h"
+#import "desktop/global_history.h"
@implementation HistoryWindowController
@@ -30,15 +30,13 @@
{
if ((self = [super initWithWindowNibName: @"HistoryWindow"]) == nil) return nil;
- tree = [[Tree alloc] initWithFlags: history_global_get_tree_flags()];
- history_global_initialise( [tree tree], "directory.png" );
+ tree = [[Tree alloc] initWithFlags: TREE_HISTORY];
return self;
}
- (void) dealloc;
{
- history_global_cleanup();
[tree release];
[self setView: nil];
diff --git a/cocoa/Tree.h b/cocoa/Tree.h
index b03f48b..e38df5a 100644
--- a/cocoa/Tree.h
+++ b/cocoa/Tree.h
@@ -42,7 +42,6 @@
- initWithFlags: (unsigned int) flags;
-- (struct node *) rootNode;
- (struct tree *) tree;
@end
diff --git a/cocoa/Tree.m b/cocoa/Tree.m
index 582187f..7da7b68 100644
--- a/cocoa/Tree.m
+++ b/cocoa/Tree.m
@@ -59,11 +59,6 @@ static const struct treeview_table cocoa_tree_callbacks = {
[super dealloc];
}
-- (struct node *) rootNode;
-{
- return tree_get_root( tree );
-}
-
- (struct tree *) tree;
{
return tree;
@@ -76,15 +71,11 @@ static const struct treeview_table cocoa_tree_callbacks = {
- (void) setRedrawing: (BOOL) newRedrawing;
{
- tree_set_redraw( tree, newRedrawing );
}
+ (void) initialize;
{
- if (self == [Tree class]) {
- tree_set_icon_dir( strdup( [[[NSBundle mainBundle] pathForResource: @"Icons" ofType: @""] UTF8String] ) );
- }
}
//MARK: -
diff --git a/cocoa/utils.m b/cocoa/utils.m
index 0e10b9b..cd9313d 100644
--- a/cocoa/utils.m
+++ b/cocoa/utils.m
@@ -19,7 +19,6 @@
#import <Cocoa/Cocoa.h>
#import "utils/utils.h"
-#import "desktop/tree_url_node.h"
#define UNIMPL() NSLog( @"Function '%s' unimplemented", __func__ )
@@ -55,12 +54,3 @@ bool path_add_part(char *path, int length, const char *newpart)
return true;
}
-
-void tree_icon_name_from_content_type(char *buffer, content_type type)
-{
- switch (type) {
- default:
- strcpy( buffer, "content.png" );
- break;
- }
-}
\ No newline at end of file
diff --git a/content/urldb.c b/content/urldb.c
index feb7c6f..3cf6549 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -100,7 +100,6 @@
#include "image/bitmap.h"
#include "content/content.h"
#include "content/urldb.h"
-#include "desktop/cookies_old.h"
#include "desktop/cookie_manager.h"
#include "utils/nsoption.h"
#include "utils/log.h"
@@ -2542,12 +2541,7 @@ char *urldb_get_cookie(nsurl *url, bool include_http_only)
c->last_used = now;
- if (nsoption_bool(temp_treeview_test) == false)
- cookies_schedule_update(
- (struct cookie_data *)c);
- else
- cookie_manager_add(
- (struct cookie_data *)c);
+ cookie_manager_add((struct cookie_data *)c);
}
}
}
@@ -2583,12 +2577,7 @@ char *urldb_get_cookie(nsurl *url, bool include_http_only)
c->last_used = now;
- if (nsoption_bool(temp_treeview_test) == false)
- cookies_schedule_update(
- (struct cookie_data *)c);
- else
- cookie_manager_add(
- (struct cookie_data *)c);
+ cookie_manager_add((struct cookie_data *)c);
}
}
@@ -2632,11 +2621,7 @@ char *urldb_get_cookie(nsurl *url, bool include_http_only)
c->last_used = now;
- if (nsoption_bool(temp_treeview_test) == false)
- cookies_schedule_update(
- (struct cookie_data *)c);
- else
- cookie_manager_add((struct cookie_data *)c);
+ cookie_manager_add((struct cookie_data *)c);
}
}
@@ -2670,11 +2655,7 @@ char *urldb_get_cookie(nsurl *url, bool include_http_only)
c->last_used = now;
- if (nsoption_bool(temp_treeview_test) == false)
- cookies_schedule_update(
- (struct cookie_data *)c);
- else
- cookie_manager_add((struct cookie_data *)c);
+ cookie_manager_add((struct cookie_data *)c);
}
}
@@ -3429,10 +3410,7 @@ bool urldb_insert_cookie(struct cookie_internal_data *c, lwc_string *scheme,
else
p->cookies = d->next;
- if (nsoption_bool(temp_treeview_test) == false)
- cookies_remove((struct cookie_data *)d);
- else
- cookie_manager_remove((struct cookie_data *)d);
+ cookie_manager_remove((struct cookie_data *)d);
urldb_free_cookie(d);
urldb_free_cookie(c);
@@ -3449,17 +3427,10 @@ bool urldb_insert_cookie(struct cookie_internal_data *c, lwc_string *scheme,
else
p->cookies = c;
- if (nsoption_bool(temp_treeview_test) == false)
- cookies_remove((struct cookie_data *)d);
- else
- cookie_manager_remove((struct cookie_data *)d);
+ cookie_manager_remove((struct cookie_data *)d);
urldb_free_cookie(d);
- if (nsoption_bool(temp_treeview_test) == false)
- cookies_schedule_update(
- (struct cookie_data *)c);
- else
- cookie_manager_add((struct cookie_data *)c);
+ cookie_manager_add((struct cookie_data *)c);
}
} else {
c->prev = p->cookies_end;
@@ -3470,10 +3441,7 @@ bool urldb_insert_cookie(struct cookie_internal_data *c, lwc_string *scheme,
p->cookies = c;
p->cookies_end = c;
- if (nsoption_bool(temp_treeview_test) == false)
- cookies_schedule_update((struct cookie_data *)c);
- else
- cookie_manager_add((struct cookie_data *)c);
+ cookie_manager_add((struct cookie_data *)c);
}
return true;
diff --git a/desktop/Makefile b/desktop/Makefile
index 4ba2b85..f702007 100644
--- a/desktop/Makefile
+++ b/desktop/Makefile
@@ -1,9 +1,9 @@
# Sources for desktop
-S_DESKTOP := cookie_manager.c cookies_old.c history_global_core.c hotlist_old.c knockout.c \
- hotlist.c mouse.c plot_style.c print.c search.c searchweb.c \
- scrollbar.c sslcert_viewer.c textarea.c thumbnail.c tree.c \
- tree_url_node.c version.c system_colour.c global_history.c treeview.c
+S_DESKTOP := cookie_manager.c knockout.c hotlist.c mouse.c \
+ plot_style.c print.c search.c searchweb.c scrollbar.c \
+ sslcert_viewer.c textarea.c thumbnail.c tree.c version.c \
+ system_colour.c global_history.c treeview.c
S_DESKTOP := $(addprefix desktop/,$(S_DESKTOP))
diff --git a/desktop/browser.c b/desktop/browser.c
index 42738db..9999444 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -47,9 +47,7 @@
#include "desktop/frames.h"
#include "desktop/global_history.h"
#include "desktop/gui.h"
-#include "desktop/history_global_core.h"
#include "desktop/hotlist.h"
-#include "desktop/hotlist_old.h"
#include "desktop/knockout.h"
#include "desktop/local_history.h"
#include "utils/nsoption.h"
@@ -1252,10 +1250,7 @@ static nserror browser_window_callback(hlcache_handle *c,
content_get_type(c));
/* This is safe as we've just added the URL */
- if (nsoption_bool(temp_treeview_test) == false)
- history_global_add(urldb_get_url(url));
- else
- global_history_add(urldb_get_url(url));
+ global_history_add(urldb_get_url(url));
}
}
@@ -1287,10 +1282,7 @@ static nserror browser_window_callback(hlcache_handle *c,
browser_window_update_favicon(c, bw, NULL);
history_update(bw->history, c);
- if (nsoption_bool(temp_treeview_test) == false)
- hotlist_old_visited(c);
- else
- hotlist_update_url(hlcache_handle_get_url(c));
+ hotlist_update_url(hlcache_handle_get_url(c));
if (bw->refresh_interval != -1)
schedule(bw->refresh_interval,
diff --git a/desktop/cookie_manager.c b/desktop/cookie_manager.c
index 5f7f038..13c6ac9 100644
--- a/desktop/cookie_manager.c
+++ b/desktop/cookie_manager.c
@@ -24,7 +24,6 @@
#include <stdlib.h>
#include "content/urldb.h"
-#include "desktop/browser.h"
#include "desktop/cookie_manager.h"
#include "desktop/treeview.h"
#include "utils/messages.h"
@@ -790,6 +789,9 @@ nserror cookie_manager_init(struct core_window_callback_table *cw_t,
* the treeview is built. */
cm_ctx.built = true;
+ /* Inform client of window height */
+ treeview_get_height(cm_ctx.tree);
+
LOG(("Generated cookie manager data"));
return NSERROR_OK;
@@ -855,8 +857,15 @@ bool cookie_manager_has_selection(void)
/* Exported interface, documented in cookie_manager.h */
-int cookie_manager_get_height(void)
+nserror cookie_manager_expand(bool only_folders)
+{
+ return treeview_expand(cm_ctx.tree, only_folders);
+}
+
+
+/* Exported interface, documented in cookie_manager.h */
+nserror cookie_manager_contract(bool all)
{
- return treeview_get_height(cm_ctx.tree);
+ return treeview_contract(cm_ctx.tree, all);
}
diff --git a/desktop/cookie_manager.h b/desktop/cookie_manager.h
index b844907..aa61a3e 100644
--- a/desktop/cookie_manager.h
+++ b/desktop/cookie_manager.h
@@ -24,8 +24,12 @@
#define _NETSURF_DESKTOP_COOKIE_MANAGER_H_
#include <stdbool.h>
+#include <stdint.h>
+#include "desktop/browser.h"
#include "desktop/core_window.h"
+#include "desktop/textinput.h"
+#include "utils/errors.h"
struct cookie_data;
@@ -106,10 +110,19 @@ void cookie_manager_keypress(uint32_t key);
bool cookie_manager_has_selection(void);
/**
- * Find current height
+ * Expand the treeview's nodes
*
- * \return height in px
+ * \param only_folders Iff true, only folders are expanded.
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror cookie_manager_expand(bool only_folders);
+
+/**
+ * Contract the treeview's nodes
+ *
+ * \param all Iff false, only entries are contracted.
+ * \return NSERROR_OK on success, appropriate error otherwise
*/
-int cookie_manager_get_height(void);
+nserror cookie_manager_contract(bool all);
#endif
diff --git a/desktop/cookies_old.c b/desktop/cookies_old.c
deleted file mode 100644
index 0aaf61f..0000000
--- a/desktop/cookies_old.c
+++ /dev/null
@@ -1,529 +0,0 @@
-/*
- * Copyright 2006 Richard Wilson <info(a)tinct.net>
- * Copyright 2009 Paul Blokus <paul_pl(a)users.sourceforge.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/** \file
- * Cookies (implementation).
- */
-
-#include <assert.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include "content/content.h"
-#include "content/hlcache.h"
-#include "content/urldb.h"
-#include "desktop/cookies_old.h"
-#include "utils/nsoption.h"
-#include "desktop/tree.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/schedule.h"
-#include "utils/url.h"
-#include "utils/utils.h"
-
-/** Flags for each type of cookie tree node. */
-enum tree_element_cookie {
- TREE_ELEMENT_PERSISTENT = 0x01,
- TREE_ELEMENT_VERSION = 0x02,
- TREE_ELEMENT_SECURE = 0x03,
- TREE_ELEMENT_LAST_USED = 0x04,
- TREE_ELEMENT_EXPIRES = 0x05,
- TREE_ELEMENT_PATH = 0x06,
- TREE_ELEMENT_DOMAIN = 0x07,
- TREE_ELEMENT_COMMENT = 0x08,
- TREE_ELEMENT_VALUE = 0x09,
-};
-
-static struct tree *cookies_tree;
-static struct node *cookies_tree_root;
-static bool user_delete;
-static hlcache_handle *folder_icon;
-static hlcache_handle *cookie_icon;
-
-
-/**
- * Find an entry in the cookie tree
- *
- * \param node the node to check the children of
- * \param title The title to find
- * \return Pointer to node, or NULL if not found
- */
-static struct node *cookies_find(struct node *node, const char *title)
-{
- struct node *search;
- struct node_element *element;
-
- assert(node !=NULL);
-
- for (search = tree_node_get_child(node); search;
- search = tree_node_get_next(search)) {
- element = tree_node_find_element(search, TREE_ELEMENT_TITLE,
- NULL);
- if (strcmp(title, tree_node_element_get_text(element)) == 0)
- return search;
- }
- return NULL;
-}
-
-/**
- * Callback for all cookie tree nodes.
- */
-static node_callback_resp cookies_node_callback(void *user_data, struct node_msg_data *msg_data)
-{
- struct node *node = msg_data->node;
- struct node_element *domain, *path;
- const char *domain_t, *path_t, *name_t;
- char *space;
- bool is_folder = tree_node_is_folder(node);
-
- /* we don't remove any icons here */
- if (msg_data->msg == NODE_DELETE_ELEMENT_IMG)
- return NODE_CALLBACK_HANDLED;
-
- /* let the tree handle events other than text data removal */
- if (msg_data->msg != NODE_DELETE_ELEMENT_TXT)
- return NODE_CALLBACK_NOT_HANDLED;
-
- /* check if it's a domain folder */
- if (is_folder)
- return NODE_CALLBACK_NOT_HANDLED;
-
- switch (msg_data->flag) {
- case TREE_ELEMENT_TITLE:
- if (!user_delete)
- break;
- /* get the rest of the cookie data */
- domain = tree_node_find_element(node,
- TREE_ELEMENT_DOMAIN, NULL);
- path = tree_node_find_element(node, TREE_ELEMENT_PATH,
- NULL);
-
- if ((domain != NULL) &&
- (path != NULL)) {
- domain_t = tree_node_element_get_text(domain) +
- strlen(messages_get(
- "TreeDomain")) - 4;
- space = strchr(domain_t, ' ');
- if (space != NULL)
- *space = '\0';
- path_t = tree_node_element_get_text(path) +
- strlen(messages_get("TreePath"))
- - 4;
- space = strchr(path_t, ' ');
- if (space != NULL)
- *space = '\0';
- name_t = msg_data->data.text;
- urldb_delete_cookie(domain_t, path_t, name_t);
- }
- break;
- default:
- break;
- }
-
- free(msg_data->data.text);
-
- return NODE_CALLBACK_HANDLED;
-}
-
-
-/**
- * Updates a tree entry for a cookie.
- *
- * All information is copied from the cookie_data, and as such can
- * be edited and should be freed.
- *
- * \param node The node to update
- * \param data The cookie data to use
- * \return true if node updated, or false for failure
- */
-static bool cookies_update_cookie_node(struct node *node,
- const struct cookie_data *data)
-{
- struct node_element *element;
- char buffer[32];
-
- assert(data != NULL);
-
- /* update the value text */
- element = tree_node_find_element(node, TREE_ELEMENT_VALUE, NULL);
- tree_update_element_text(cookies_tree,
- element,
- messages_get_buff("TreeValue",
- data->value != NULL ?
- data->value :
- messages_get("TreeUnused")));
-
-
- /* update the comment text */
- if ((data->comment != NULL) &&
- (strcmp(data->comment, "") != 0)) {
- element = tree_node_find_element(node, TREE_ELEMENT_COMMENT, NULL);
- tree_update_element_text(cookies_tree,
- element,
- messages_get_buff("TreeComment",
- data->comment));
- }
-
- /* update domain text */
- element = tree_node_find_element(node, TREE_ELEMENT_DOMAIN, element);
- tree_update_element_text(cookies_tree,
- element,
- messages_get_buff("TreeDomain",
- data->domain,
- data->domain_from_set ?
- messages_get("TreeHeaders") :
- ""));
-
- /* update path text */
- element = tree_node_find_element(node, TREE_ELEMENT_PATH, element);
- tree_update_element_text(cookies_tree,
- element,
- messages_get_buff("TreePath", data->path,
- data->path_from_set ?
- messages_get("TreeHeaders") :
- ""));
-
- /* update expiry text */
- element = tree_node_find_element(node, TREE_ELEMENT_EXPIRES, element);
- tree_update_element_text(cookies_tree,
- element,
- messages_get_buff("TreeExpires",
- (data->expires > 0)
- ? (data->expires == 1)
- ? messages_get("TreeSession")
- : ctime(&data->expires)
- : messages_get("TreeUnknown")));
-
- /* update last used text */
- element = tree_node_find_element(node, TREE_ELEMENT_LAST_USED, element);
- tree_update_element_text(cookies_tree,
- element,
- messages_get_buff("TreeLastUsed",
- (data->last_used > 0) ?
- ctime(&data->last_used) :
- messages_get("TreeUnknown")));
-
- /* update secure text */
- element = tree_node_find_element(node, TREE_ELEMENT_SECURE, element);
- tree_update_element_text(cookies_tree,
- element,
- messages_get_buff("TreeSecure",
- data->secure ?
- messages_get("Yes") :
- messages_get("No")));
-
- /* update version text */
- element = tree_node_find_element(node, TREE_ELEMENT_VERSION, element);
- snprintf(buffer, sizeof(buffer), "TreeVersion%i", data->version);
- tree_update_element_text(cookies_tree,
- element,
- messages_get_buff("TreeVersion",
- messages_get(buffer)));
-
- /* update persistant text */
- element = tree_node_find_element(node, TREE_ELEMENT_PERSISTENT, element);
- tree_update_element_text(cookies_tree,
- element,
- messages_get_buff("TreePersistent",
- data->no_destroy ?
- messages_get("Yes") :
- messages_get("No")));
-
- return true;
-}
-
-/**
- * Creates an empty tree entry for a cookie, and links it into the tree.
- *
- * All information is copied from the cookie_data, and as such can
- * be edited and should be freed.
- *
- * \param parent the node to link to
- * \param data the cookie data to use
- * \return the node created, or NULL for failure
- */
-static struct node *cookies_create_cookie_node(struct node *parent,
- const struct cookie_data *data)
-{
- struct node *node;
-
- node = tree_create_leaf_node(cookies_tree,
- NULL,
- data->name,
- false, false, false);
- if (node == NULL) {
- return NULL;
- }
-
- tree_set_node_user_callback(node, cookies_node_callback, NULL);
-
- tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_PERSISTENT, false);
-
- tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_VERSION, false);
-
- tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_SECURE, false);
-
- tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_LAST_USED, false);
-
- tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_EXPIRES, false);
-
- tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_PATH, false);
-
- tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_DOMAIN, false);
-
- if ((data->comment) && (strcmp(data->comment, "")))
- tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_COMMENT, false);
- tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_VALUE, false);
- tree_set_node_icon(cookies_tree, node, cookie_icon);
-
- if (!cookies_update_cookie_node(node, data))
- {
- tree_delete_node(NULL, node, false);
- return NULL;
- }
-
- tree_link_node(cookies_tree, parent, node, false);
- return node;
-}
-
-
-/**
- * Called when scheduled event gets fired. Actually performs the update.
- */
-static void cookies_schedule_callback(const void *scheduled_data)
-{
- const struct cookie_data *data = scheduled_data;
- struct node *node = NULL;
- struct node *cookie_node = NULL;
-
- assert(data != NULL);
-
- node = cookies_find(cookies_tree_root, data->domain);
-
- if (node == NULL) {
- node = tree_create_folder_node(cookies_tree,
- cookies_tree_root,
- data->domain,
- false, false, false);
- if (node != NULL) {
- tree_set_node_user_callback(node,
- cookies_node_callback,
- NULL);
- tree_set_node_icon(cookies_tree, node, folder_icon);
- }
- }
-
- if (node != NULL) {
- cookie_node = cookies_find(node, data->name);
- if (cookie_node == NULL) {
- cookies_create_cookie_node(node, data);
- } else {
- cookies_update_cookie_node(cookie_node, data);
- }
-
- }
-}
-
-/**
- * Initialises cookies tree.
- *
- * \param data user data for the callbacks
- * \param start_redraw callback function called before every redraw
- * \param end_redraw callback function called after every redraw
- * \return true on success, false on memory exhaustion
- */
-bool cookies_initialise(struct tree *tree, const char* folder_icon_name, const char* cookie_icon_name)
-{
-
- if (tree == NULL)
- return false;
-
- LOG(("Making cookie tree"));
-
- folder_icon = tree_load_icon(folder_icon_name);
- cookie_icon = tree_load_icon(cookie_icon_name);
-
- /* Create an empty tree */
- cookies_tree = tree;
- cookies_tree_root = tree_get_root(cookies_tree);
-
- user_delete = false;
- urldb_iterate_cookies(cookies_schedule_update);
- tree_set_node_expanded(cookies_tree, cookies_tree_root,
- false, true, true);
-
- LOG(("Made cookie tree"));
-
- return true;
-}
-
-
-/**
- * Get flags with which the cookies tree should be created;
- *
- * \return the flags
- */
-unsigned int cookies_get_tree_flags(void)
-{
- return TREE_DELETE_EMPTY_DIRS | TREE_COOKIES;
-}
-
-
-/* exported interface documented in cookies_old.h */
-bool cookies_schedule_update(const struct cookie_data *data)
-{
- assert(data != NULL);
- assert(user_delete == false);
-
- if (cookies_tree_root != NULL)
- cookies_schedule_callback(data);
-
- return true;
-}
-
-
-/* exported interface documented in cookies_old.h */
-void cookies_remove(const struct cookie_data *data)
-{
- assert(data != NULL);
-
- if (cookies_tree_root != NULL)
- cookies_schedule_callback(data);
-}
-
-
-/**
- * Free memory and release all other resources.
- */
-void cookies_cleanup(void)
-{
- hlcache_handle_release(folder_icon);
- hlcache_handle_release(cookie_icon);
-}
-
-/* Actions to be connected to front end specific toolbars */
-
-/**
- * Delete nodes which are currently selected.
- */
-void cookies_delete_selected(void)
-{
- user_delete = true;
- tree_delete_selected_nodes(cookies_tree, cookies_tree_root);
- user_delete = false;
-}
-
-/**
- * Delete all nodes.
- */
-void cookies_delete_all(void)
-{
- bool needs_redraw = tree_get_redraw(cookies_tree);
- if (needs_redraw)
- tree_set_redraw(cookies_tree, false);
-
- user_delete = true;
- tree_set_node_selected(cookies_tree, cookies_tree_root, true, true);
- tree_delete_selected_nodes(cookies_tree, cookies_tree_root);
- user_delete = false;
-
- if (needs_redraw)
- tree_set_redraw(cookies_tree, true);
-}
-
-/**
- * Select all nodes in the tree.
- */
-void cookies_select_all(void)
-{
- tree_set_node_selected(cookies_tree, cookies_tree_root, true, true);
-}
-
-/**
- * Unselect all nodes.
- */
-void cookies_clear_selection(void)
-{
- tree_set_node_selected(cookies_tree, cookies_tree_root, true, false);
-}
-
-/**
- * Expand both domain and cookie nodes.
- */
-void cookies_expand_all(void)
-{
- tree_set_node_expanded(cookies_tree, cookies_tree_root,
- true, true, true);
-}
-
-/**
- * Expand domain nodes only.
- */
-void cookies_expand_domains(void)
-{
- tree_set_node_expanded(cookies_tree, cookies_tree_root,
- true, true, false);
-}
-
-/**
- * Expand cookie nodes only.
- */
-void cookies_expand_cookies(void)
-{
- tree_set_node_expanded(cookies_tree, cookies_tree_root,
- true, false, true);
-}
-
-/**
- * Collapse both domain and cookie nodes.
- */
-void cookies_collapse_all(void)
-{
- tree_set_node_expanded(cookies_tree, cookies_tree_root,
- false, true, true);
-}
-
-/**
- * Collapse domain nodes only.
- */
-void cookies_collapse_domains(void)
-{
- tree_set_node_expanded(cookies_tree, cookies_tree_root,
- false, true, false);
-}
-
-/**
- * Collapse cookie nodes only.
- */
-void cookies_collapse_cookies(void)
-{
- tree_set_node_expanded(cookies_tree, cookies_tree_root,
- false, false, true);
-}
diff --git a/desktop/cookies_old.h b/desktop/cookies_old.h
deleted file mode 100644
index 18ba658..0000000
--- a/desktop/cookies_old.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2006 Richard Wilson <info(a)tinct.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/** \file
- * Cookies (interface).
- */
-
-#ifndef _NETSURF_DESKTOP_COOKIES_OLD_H_
-#define _NETSURF_DESKTOP_COOKIES_OLD_H_
-
-#include <stdbool.h>
-
-#include "desktop/tree.h"
-
-struct cookie_data;
-
-bool cookies_initialise(struct tree *tree, const char* folder_icon_name, const char* cookie_icon_name);
-unsigned int cookies_get_tree_flags(void);
-
-/**
- * Perform cookie updates and addition. The update is only scheduled here.
- * The actual update is performed in the callback function.
- *
- * \param data Data of cookie being updated.
- * \return true (for urldb_iterate_entries)
- */
-bool cookies_schedule_update(const struct cookie_data *data);
-
-/**
- * Remove a cookie from the active set.
- * The cookie is to be removed from the active set and no futher
- * references made to the cookie data.
- *
- * \param data Data of cookie being removed.
- */
-void cookies_remove(const struct cookie_data *data);
-
-void cookies_cleanup(void);
-
-void cookies_delete_selected(void);
-void cookies_delete_all(void);
-void cookies_select_all(void);
-void cookies_clear_selection(void);
-void cookies_expand_all(void);
-void cookies_expand_domains(void);
-void cookies_expand_cookies(void);
-void cookies_collapse_all(void);
-void cookies_collapse_domains(void);
-void cookies_collapse_cookies(void);
-
-#endif
diff --git a/desktop/global_history.c b/desktop/global_history.c
index 2b384b1..e0c8e39 100644
--- a/desktop/global_history.c
+++ b/desktop/global_history.c
@@ -20,7 +20,6 @@
#include <stdlib.h>
#include "content/urldb.h"
-#include "desktop/browser.h"
#include "desktop/global_history.h"
#include "desktop/treeview.h"
#include "utils/messages.h"
@@ -768,11 +767,6 @@ nserror global_history_init(struct core_window_callback_table *cw_t,
return err;
}
- /* History tree is built
- * We suppress the treeview height callback on entry insertion before
- * the treeview is built. */
- gh_ctx.built = true;
-
/* Expand the "Today" folder node */
err = treeview_node_expand(gh_ctx.tree,
gh_ctx.folders[GH_TODAY].folder);
@@ -780,6 +774,14 @@ nserror global_history_init(struct core_window_callback_table *cw_t,
return err;
}
+ /* History tree is built
+ * We suppress the treeview height callback on entry insertion before
+ * the treeview is built. */
+ gh_ctx.built = true;
+
+ /* Inform client of window height */
+ treeview_get_height(gh_ctx.tree);
+
LOG(("Loaded global history"));
return NSERROR_OK;
@@ -962,8 +964,15 @@ bool global_history_has_selection(void)
/* Exported interface, documented in global_history.h */
-int global_history_get_height(void)
+nserror global_history_expand(bool only_folders)
+{
+ return treeview_expand(gh_ctx.tree, only_folders);
+}
+
+
+/* Exported interface, documented in global_history.h */
+nserror global_history_contract(bool all)
{
- return treeview_get_height(gh_ctx.tree);
+ return treeview_contract(gh_ctx.tree, all);
}
diff --git a/desktop/global_history.h b/desktop/global_history.h
index 6e5ff1e..4ebe139 100644
--- a/desktop/global_history.h
+++ b/desktop/global_history.h
@@ -20,8 +20,12 @@
#define _NETSURF_DESKTOP_GLOBAL_HISTORY_H_
#include <stdbool.h>
+#include <stdint.h>
+#include "desktop/browser.h"
#include "desktop/core_window.h"
+#include "desktop/textinput.h"
+#include "utils/errors.h"
#include "utils/nsurl.h"
@@ -106,10 +110,19 @@ void global_history_keypress(uint32_t key);
bool global_history_has_selection(void);
/**
- * Find current height
+ * Expand the treeview's nodes
*
- * \return height in px
+ * \param only_folders Iff true, only folders are expanded.
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror global_history_expand(bool only_folders);
+
+/**
+ * Contract the treeview's nodes
+ *
+ * \param all Iff false, only entries are contracted.
+ * \return NSERROR_OK on success, appropriate error otherwise
*/
-int global_history_get_height(void);
+nserror global_history_contract(bool all);
#endif
diff --git a/desktop/history_global_core.c b/desktop/history_global_core.c
deleted file mode 100644
index b03485a..0000000
--- a/desktop/history_global_core.c
+++ /dev/null
@@ -1,450 +0,0 @@
-/*
- * Copyright 2005 Richard Wilson <info(a)tinct.net>
- * Copyright 2009 Paul Blokus <paul_pl(a)users.sourceforge.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include <stdlib.h>
-
-#include "content/content.h"
-#include "content/hlcache.h"
-#include "content/urldb.h"
-#include "desktop/browser.h"
-#include "desktop/history_global_core.h"
-#include "desktop/plotters.h"
-#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
-#include "utils/log.h"
-
-#define MAXIMUM_BASE_NODES 16
-#define GLOBAL_HISTORY_RECENT_URLS 16
-#define URL_CHUNK_LENGTH 512
-
-static struct node *global_history_base_node[MAXIMUM_BASE_NODES];
-static int global_history_base_node_time[MAXIMUM_BASE_NODES];
-static int global_history_base_node_count = 0;
-
-static bool global_history_initialised;
-
-static struct tree *global_history_tree;
-static struct node *global_history_tree_root;
-
-static hlcache_handle *folder_icon;
-
-static const char *const weekday_msg_name [] =
-{
- "Sunday",
- "Monday",
- "Tuesday",
- "Wednesday",
- "Thursday",
- "Friday",
- "Saturday"
-};
-
-/**
- * Find an entry in the global history
- *
- * \param url The URL to find
- * \return Pointer to node, or NULL if not found
- */
-static struct node *history_global_find(const char *url)
-{
- int i;
- struct node *node;
- const char *text;
-
- for (i = 0; i < global_history_base_node_count; i++) {
- if (!tree_node_is_deleted(global_history_base_node[i])) {
- node = tree_node_get_child(global_history_base_node[i]);
- for (; node != NULL; node = tree_node_get_next(node)) {
- text = tree_url_node_get_url(node);
- if ((text != NULL) && !strcmp(url, text))
- return node;
- }
- }
- }
- return NULL;
-}
-
-/**
- * Internal routine to actually perform global history addition
- *
- * \param url The URL to add
- * \param data URL data associated with URL
- * \return true (for urldb_iterate_entries)
- */
-static bool history_global_add_internal(nsurl *url, const struct url_data *data)
-{
- int i, j;
- struct node *parent = NULL;
- struct node *link;
- struct node *node;
- bool before = false;
- int visit_date;
-
- assert((url != NULL) && (data != NULL));
-
- visit_date = data->last_visit;
-
- /* find parent node */
- for (i = 0; i < global_history_base_node_count; i++) {
- if (global_history_base_node_time[i] <= visit_date) {
- parent = global_history_base_node[i];
- break;
- }
- }
-
- /* the entry is too old to care about */
- if (parent == NULL)
- return true;
-
- if (tree_node_is_deleted(parent)) {
- /* parent was deleted, so find place to insert it */
- link = global_history_tree_root;
-
- for (j = global_history_base_node_count - 1; j >= 0; j--) {
- if (!tree_node_is_deleted(global_history_base_node[j]) &&
- global_history_base_node_time[j] >
- global_history_base_node_time[i]) {
- link = global_history_base_node[j];
- before = true;
- break;
- }
- }
-
- tree_set_node_selected(global_history_tree,
- parent, true, false);
- tree_set_node_expanded(global_history_tree,
- parent, false, true, true);
- tree_link_node(global_history_tree, link, parent, before);
- }
-
- /* find any previous occurance */
- if (global_history_initialised == false) {
- node = history_global_find(nsurl_access(url));
- if (node != NULL) {
- tree_update_URL_node(global_history_tree,
- node, url, data);
- tree_delink_node(global_history_tree, node);
- tree_link_node(global_history_tree, parent, node,
- false);
- return true;
- }
- }
-
- /* Add the node at the bottom */
- node = tree_create_URL_node_readonly(global_history_tree,
- parent, url, data,
- tree_url_node_callback, NULL);
-
- return true;
-}
-
-static node_callback_resp
-history_global_node_callback(void *user_data,
- struct node_msg_data *msg_data)
-{
- if (msg_data->msg == NODE_DELETE_ELEMENT_IMG)
- return NODE_CALLBACK_HANDLED;
- return NODE_CALLBACK_NOT_HANDLED;
-}
-
-/**
- * Initialises a single grouping node for the global history tree.
- *
- * \return false on memory exhaustion, true otherwise
- */
-static bool history_global_initialise_node(const char *title,
- time_t base, int days_back)
-{
- struct tm *full_time;
- struct node *node;
-
- base += days_back * 60 * 60 * 24;
- if (title == NULL) {
- full_time = localtime(&base);
- title = messages_get(weekday_msg_name[full_time->tm_wday]);
- }
-
- node = tree_create_folder_node(NULL, NULL, title, false, true, true);
- if (node == NULL) {
- warn_user(messages_get_errorcode(NSERROR_NOMEM), 0);
- return false;
- }
-
- if (folder_icon != NULL) {
- tree_set_node_icon(global_history_tree, node, folder_icon);
- }
-
- tree_set_node_user_callback(node, history_global_node_callback, NULL);
-
- global_history_base_node[global_history_base_node_count] = node;
- global_history_base_node_time[global_history_base_node_count] = base;
- global_history_base_node_count++;
-
- return true;
-}
-
-/**
- * Initialises the grouping nodes(Today, Yesterday etc.) for the global history
- * tree.
- *
- * \return false on memory exhaustion, true otherwise
- */
-static bool history_global_initialise_nodes(void)
-{
- struct tm *full_time;
- time_t t;
- int weekday;
- int i;
-
- /* get the current time */
- t = time(NULL);
- if (t == -1) {
- LOG(("time info unaviable"));
- return false;
- }
-
- /* get the time at the start of today */
- full_time = localtime(&t);
- weekday = full_time->tm_wday;
- full_time->tm_sec = 0;
- full_time->tm_min = 0;
- full_time->tm_hour = 0;
- t = mktime(full_time);
- if (t == -1) {
- LOG(("mktime failed"));
- return false;
- }
-
- history_global_initialise_node(messages_get("DateToday"), t, 0);
- if (weekday > 0)
- if (!history_global_initialise_node(
- messages_get("DateYesterday"), t, -1))
- return false;
- for (i = 2; i <= weekday; i++)
- if (!history_global_initialise_node(NULL, t, -i))
- return false;
-
- if (!history_global_initialise_node(messages_get("Date1Week"),
- t, -weekday - 7))
- return false;
- if (!history_global_initialise_node(messages_get("Date2Week"),
- t, -weekday - 14))
- return false;
- if (!history_global_initialise_node(messages_get("Date3Week"),
- t, -weekday - 21))
- return false;
-
- return true;
-}
-
-/**
- * Initialises the global history tree.
- *
- * \param data user data for the callbacks
- * \param start_redraw callback function called before every redraw
- * \param end_redraw callback function called after every redraw
- * \return true on success, false on memory exhaustion
- */
-bool history_global_initialise(struct tree *tree, const char* folder_icon_name)
-{
- folder_icon = tree_load_icon(folder_icon_name);
- tree_url_node_init(folder_icon_name);
-
- if (tree == NULL)
- return false;
-
- global_history_tree = tree;
- global_history_tree_root = tree_get_root(global_history_tree);
-
- if (!history_global_initialise_nodes())
- return false;
-
- LOG(("Building history tree"));
-
- global_history_initialised = true;
- urldb_iterate_entries(history_global_add_internal);
- global_history_initialised = false;
- tree_set_node_expanded(global_history_tree, global_history_tree_root,
- false, true, true);
- LOG(("History tree built"));
- return true;
-}
-
-
-/**
- * Get flags with which the global history tree should be created;
- *
- * \return the flags
- */
-unsigned int history_global_get_tree_flags(void)
-{
- return TREE_NO_FLAGS | TREE_HISTORY;
-}
-
-
-/**
- * Deletes the global history tree.
- */
-void history_global_cleanup(void)
-{
- hlcache_handle_release(folder_icon);
- tree_url_node_cleanup();
-}
-
-
-/**
- * Adds a url to the global history.
- *
- * \param url the url to be added
- */
-void history_global_add(nsurl *url)
-{
- const struct url_data *data;
-
- data = urldb_get_url_data(url);
- if (data == NULL)
- return;
-
- history_global_add_internal(url, data);
-}
-
-
-/* Actions to be connected to front end specific toolbars */
-
-/**
- * Save the global history in a human-readable form under the given location.
- *
- * \param path the path where the history will be saved
- */
-bool history_global_export(const char *path)
-{
- return tree_urlfile_save(global_history_tree, path, "NetSurf history");
-}
-
-/**
- * Delete nodes which are currently selected.
- */
-void history_global_delete_selected(void)
-{
- tree_delete_selected_nodes(global_history_tree,
- global_history_tree_root);
-}
-
-/**
- * Delete all nodes.
- */
-void history_global_delete_all(void)
-{
- bool redraw_needed = tree_get_redraw(global_history_tree);
- if (redraw_needed)
- tree_set_redraw(global_history_tree, false);
-
- tree_set_node_selected(global_history_tree, global_history_tree_root,
- true, true);
- tree_delete_selected_nodes(global_history_tree,
- global_history_tree_root);
-
- if (redraw_needed)
- tree_set_redraw(global_history_tree, true);
-}
-
-/**
- * Select all nodes in the tree.
- */
-void history_global_select_all(void)
-{
- tree_set_node_selected(global_history_tree, global_history_tree_root,
- true, true);
-}
-
-/**
- * Unselect all nodes.
- */
-void history_global_clear_selection(void)
-{
- tree_set_node_selected(global_history_tree, global_history_tree_root,
- true, false);
-}
-
-/**
- * Expand grouping folders and history entries.
- */
-void history_global_expand_all(void)
-{
- tree_set_node_expanded(global_history_tree, global_history_tree_root,
- true, true, true);
-}
-
-/**
- * Expand grouping folders only.
- */
-void history_global_expand_directories(void)
-{
- tree_set_node_expanded(global_history_tree, global_history_tree_root,
- true, true, false);
-}
-
-/**
- * Expand history entries only.
- */
-void history_global_expand_addresses(void)
-{
- tree_set_node_expanded(global_history_tree, global_history_tree_root,
- true, false, true);
-}
-
-/**
- * Collapse grouping folders and history entries.
- */
-void history_global_collapse_all(void)
-{
- tree_set_node_expanded(global_history_tree, global_history_tree_root,
- false, true, true);
-}
-
-/**
- * Collapse grouping folders only.
- */
-void history_global_collapse_directories(void)
-{
- tree_set_node_expanded(global_history_tree, global_history_tree_root,
- false, true, false);
-}
-
-/**
- * Collapse history entries only.
- */
-void history_global_collapse_addresses(void)
-{
- tree_set_node_expanded(global_history_tree, global_history_tree_root,
- false, false, true);
-}
-
-/**
- * Open the selected entries in seperate browser windows.
- *
- * \param tabs open multiple entries in tabs in the new window
- */
-void history_global_launch_selected(bool tabs)
-{
- tree_launch_selected(global_history_tree, tabs);
-}
diff --git a/desktop/history_global_core.h b/desktop/history_global_core.h
deleted file mode 100644
index 9bf5a0b..0000000
--- a/desktop/history_global_core.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2005 Richard Wilson <info(a)tinct.net>
- * Copyright 2009 Paul Blokus <paul_pl(a)users.sourceforge.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef _NETSURF_DESKTOP_HISTORY_GLOBAL_H_
-#define _NETSURF_DESKTOP_HISTORY_GLOBAL_H_
-
-#include <stdbool.h>
-
-#include "desktop/tree.h"
-
-bool history_global_initialise(struct tree *tree, const char* folder_icon_name);
-unsigned int history_global_get_tree_flags(void);
-void history_global_cleanup(void);
-
-void history_global_add(nsurl *url);
-
-bool history_global_export(const char *path);
-void history_global_delete_selected(void);
-void history_global_delete_all(void);
-void history_global_select_all(void);
-void history_global_clear_selection(void);
-void history_global_expand_all(void);
-void history_global_expand_directories(void);
-void history_global_expand_addresses(void);
-void history_global_collapse_all(void);
-void history_global_collapse_directories(void);
-void history_global_collapse_addresses(void);
-void history_global_launch_selected(bool tabs);
-
-#endif
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index 683fdc4..9f98138 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -24,7 +24,6 @@
#include <dom/bindings/hubbub/parser.h>
#include "content/urldb.h"
-#include "desktop/browser.h"
#include "desktop/hotlist.h"
#include "desktop/treeview.h"
#include "utils/corestrings.h"
@@ -1090,6 +1089,9 @@ nserror hotlist_init(struct core_window_callback_table *cw_t,
* the treeview is built. */
hl_ctx.built = true;
+ /* Inform client of window height */
+ treeview_get_height(hl_ctx.tree);
+
LOG(("Loaded hotlist"));
return NSERROR_OK;
@@ -1336,7 +1338,7 @@ nserror hotlist_add_entry(nsurl *url, const char *title, bool at_y, int y)
if (title != NULL) {
title = strdup(title);
if (title == NULL) {
- nsurl_ref(url);
+ nsurl_unref(url);
return NSERROR_NOMEM;
}
}
@@ -1419,8 +1421,15 @@ void hotlist_edit_selection(void)
/* Exported interface, documented in hotlist.h */
-int hotlist_get_height(void)
+nserror hotlist_expand(bool only_folders)
+{
+ return treeview_expand(hl_ctx.tree, only_folders);
+}
+
+
+/* Exported interface, documented in hotlist.h */
+nserror hotlist_contract(bool all)
{
- return treeview_get_height(hl_ctx.tree);
+ return treeview_contract(hl_ctx.tree, all);
}
diff --git a/desktop/hotlist.h b/desktop/hotlist.h
index 171fdd7..121eb95 100644
--- a/desktop/hotlist.h
+++ b/desktop/hotlist.h
@@ -20,8 +20,12 @@
#define _NETSURF_DESKTOP_HOTLIST_H_
#include <stdbool.h>
+#include <stdint.h>
+#include "desktop/browser.h"
#include "desktop/core_window.h"
+#include "desktop/textinput.h"
+#include "utils/errors.h"
#include "utils/nsurl.h"
@@ -154,10 +158,19 @@ bool hotlist_has_selection(void);
void hotlist_edit_selection(void);
/**
- * Find current height
+ * Expand the treeview's nodes
*
- * \return height in px
+ * \param only_folders Iff true, only folders are expanded.
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror hotlist_expand(bool only_folders);
+
+/**
+ * Contract the treeview's nodes
+ *
+ * \param all Iff false, only entries are contracted.
+ * \return NSERROR_OK on success, appropriate error otherwise
*/
-int hotlist_get_height(void);
+nserror hotlist_contract(bool all);
#endif
diff --git a/desktop/hotlist_old.c b/desktop/hotlist_old.c
deleted file mode 100644
index 7be9499..0000000
--- a/desktop/hotlist_old.c
+++ /dev/null
@@ -1,584 +0,0 @@
-/*
- * Copyright 2004, 2005 Richard Wilson <info(a)tinct.net>
- * Copyright 2009 Paul Blokus <paul_pl(a)users.sourceforge.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <ctype.h>
-#include <stdlib.h>
-
-#include "utils/nsoption.h"
-#include "content/content.h"
-#include "content/hlcache.h"
-#include "content/urldb.h"
-#include "desktop/browser.h"
-#include "desktop/hotlist.h"
-#include "desktop/hotlist_old.h"
-#include "desktop/plotters.h"
-#include "desktop/textinput.h"
-#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
-
-#include "utils/messages.h"
-#include "utils/utils.h"
-#include "utils/log.h"
-
-#define URL_CHUNK_LENGTH 512
-
-static struct tree *hotlist_old_tree;
-static struct node *hotlist_old_tree_root;
-
-static bool creating_node;
-static hlcache_handle *folder_icon;
-
-static const struct {
- const char *url;
- const char *msg_key;
-} hotlist_old_default_entries[] = {
- { "http://www.netsurf-browser.org/", "HotlistHomepage" },
- { "http://www.netsurf-browser.org/downloads/riscos/testbuilds",
- "HotlistTestBuild" },
- { "http://www.netsurf-browser.org/documentation",
- "HotlistDocumentation" },
- { "http://sourceforge.net/tracker/?atid=464312&group_id=51719",
- "HotlistBugTracker" },
- { "http://sourceforge.net/tracker/?atid=464315&group_id=51719",
- "HotlistFeatureRequest" }
-};
-#define hotlist_old_ENTRIES_COUNT (sizeof(hotlist_old_default_entries) / sizeof(hotlist_old_default_entries[0]))
-
-static node_callback_resp hotlist_old_node_callback(void *user_data,
- struct node_msg_data *msg_data)
-{
- struct node *node = msg_data->node;
- const char *text;
- char *norm_text;
- bool is_folder = tree_node_is_folder(node);
- bool cancelled = false;
-
- switch (msg_data->msg) {
- case NODE_ELEMENT_EDIT_CANCELLED:
- cancelled = true;
- /* fall through */
- case NODE_ELEMENT_EDIT_FINISHED:
- if (creating_node && !cancelled &&
- (is_folder == false) &&
- (msg_data->flag == TREE_ELEMENT_TITLE)) {
- tree_url_node_edit_url(hotlist_old_tree, node);
- } else {
- creating_node = false;
- }
- return NODE_CALLBACK_HANDLED;
-
- case NODE_ELEMENT_EDIT_FINISHING:
- if (creating_node && (is_folder == false))
- return tree_url_node_callback(hotlist_old_tree, msg_data);
-
- if (is_folder == true) {
- text = msg_data->data.text;
- while (isspace(*text))
- text++;
- norm_text = strdup(text);
- if (norm_text == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- return NODE_CALLBACK_REJECT;
- }
- /* don't allow zero length entry text, return false */
- if (norm_text[0] == '\0') {
- warn_user("NoNameError", 0);
- msg_data->data.text = NULL;
- return NODE_CALLBACK_CONTINUE;
- }
- msg_data->data.text = norm_text;
- }
- break;
-
- case NODE_DELETE_ELEMENT_IMG:
- return NODE_CALLBACK_HANDLED;
-
- default:
- if (is_folder == false)
- return tree_url_node_callback(hotlist_old_tree, msg_data);
- }
-
- return NODE_CALLBACK_NOT_HANDLED;
-}
-
-/* exported interface documented in hotlist.h */
-bool hotlist_old_initialise(struct tree *tree, const char *hotlist_path,
- const char* folder_icon_name)
-{
- struct node *node;
- const struct url_data *url_data;
- int hlst_loop;
-
- /* Either load or create a hotlist */
-
- creating_node = false;
-
- folder_icon = tree_load_icon(folder_icon_name);
-
- tree_url_node_init(folder_icon_name);
-
- if (tree == NULL)
- return false;
-
- hotlist_old_tree = tree;
- hotlist_old_tree_root = tree_get_root(hotlist_old_tree);
-
- if (tree_urlfile_load(hotlist_path, hotlist_old_tree,
- hotlist_old_node_callback, NULL)) {
- return true;
- }
-
- /* failed to load hotlist file, use default list */
- node = tree_create_folder_node(hotlist_old_tree,
- hotlist_old_tree_root,
- messages_get("NetSurf"),
- true,
- false,
- false);
- if (node == NULL) {
- warn_user(messages_get_errorcode(NSERROR_NOMEM), 0);
- return false;
- }
-
- tree_set_node_user_callback(node, hotlist_old_node_callback, NULL);
- tree_set_node_icon(hotlist_old_tree, node, folder_icon);
-
- for (hlst_loop = 0; hlst_loop != hotlist_old_ENTRIES_COUNT; hlst_loop++) {
- nsurl *url;
- if (nsurl_create(hotlist_old_default_entries[hlst_loop].url,
- &url) != NSERROR_OK) {
- return false;
- }
- url_data = urldb_get_url_data(url);
- if (url_data == NULL) {
- urldb_add_url(url);
- urldb_set_url_persistence(url, true);
- url_data = urldb_get_url_data(url);
- }
- if (url_data != NULL) {
- tree_create_URL_node(hotlist_old_tree, node, url,
- messages_get(hotlist_old_default_entries[hlst_loop].msg_key),
- hotlist_old_node_callback, NULL);
- tree_update_URL_node(hotlist_old_tree, node, url, url_data);
- }
- nsurl_unref(url);
- }
-
- return true;
-}
-
-
-/**
- * Get flags with which the hotlist tree should be created;
- *
- * \return the flags
- */
-unsigned int hotlist_old_get_tree_flags(void)
-{
- return TREE_MOVABLE | TREE_HOTLIST;
-}
-
-
-/**
- * Deletes the global history tree and saves the hotlist.
- * \param hotlist_path the path where the hotlist should be saved
- */
-void hotlist_old_cleanup(const char *hotlist_path)
-{
- LOG(("Exporting hotlist..."));
- hotlist_old_export(hotlist_path);
- LOG(("Releasing handles..."));
- hlcache_handle_release(folder_icon);
- LOG(("Clearing hotlist tree nodes..."));
- tree_url_node_cleanup();
- LOG(("Hotlist cleaned up."));
-}
-
-
-/**
- * Informs the hotlist that some content has been visited. Internal procedure.
- *
- * \param content the content visited
- * \param node the node to update siblings and children of
- */
-static void hotlist_old_visited_internal(hlcache_handle *content, struct node *node)
-{
- struct node *child;
- const char *text;
- const char *url;
- nsurl *nsurl;
-
- if (content == NULL ||
- hlcache_handle_get_url(content) == NULL ||
- hotlist_old_tree == NULL)
- return;
-
- nsurl = hlcache_handle_get_url(content);
- url = nsurl_access(nsurl);
-
- for (; node; node = tree_node_get_next(node)) {
- if (!tree_node_is_folder(node)) {
- text = tree_url_node_get_url(node);
- if (strcmp(text, url) == 0) {
- tree_update_URL_node(hotlist_old_tree, node,
- nsurl, NULL);
- }
- }
- child = tree_node_get_child(node);
- if (child != NULL) {
- hotlist_old_visited_internal(content, child);
- }
- }
-}
-
-/**
- * Informs the hotlist that some content has been visited
- *
- * \param content the content visited
- */
-void hotlist_old_visited(hlcache_handle *content)
-{
- if (hotlist_old_tree != NULL) {
- hotlist_old_visited_internal(content, tree_get_root(hotlist_old_tree));
- }
-}
-
-/**
- * Save the hotlist in a human-readable form under the given location.
- *
- * \param path the path where the hotlist will be saved
- */
-bool hotlist_old_export(const char *path)
-{
- if (nsoption_bool(temp_treeview_test) != false) {
- nserror err;
- err = hotlist_export(path, NULL);
- return (err == NSERROR_OK);
- }
- return tree_urlfile_save(hotlist_old_tree, path, "NetSurf hotlist");
-}
-
-/**
- * Edit the node which is currently selected. Works only if one node is
- * selected.
- */
-void hotlist_old_edit_selected(void)
-{
- struct node *node;
- struct node_element *element;
-
- /* Update new hotlist */
- if (nsoption_bool(temp_treeview_test) != false) {
- hotlist_edit_selection();
- return;
- }
-
- node = tree_get_selected_node(hotlist_old_tree_root);
-
- if (node != NULL) {
- creating_node = true;
- element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
- tree_start_edit(hotlist_old_tree, element);
- }
-}
-
-/**
- * Delete nodes which are currently selected.
- */
-void hotlist_old_delete_selected(void)
-{
- if (nsoption_bool(temp_treeview_test) != false) {
- hotlist_keypress(KEY_DELETE_LEFT);
- return;
- }
- tree_delete_selected_nodes(hotlist_old_tree, hotlist_old_tree_root);
-}
-
-/**
- * Select all nodes in the tree.
- */
-void hotlist_old_select_all(void)
-{
- if (nsoption_bool(temp_treeview_test) != false) {
- hotlist_keypress(KEY_SELECT_ALL);
- return;
- }
- tree_set_node_selected(hotlist_old_tree, hotlist_old_tree_root,
- true, true);
-}
-
-/**
- * Unselect all nodes.
- */
-void hotlist_old_clear_selection(void)
-{
- if (nsoption_bool(temp_treeview_test) != false) {
- hotlist_keypress(KEY_CLEAR_SELECTION);
- return;
- }
- tree_set_node_selected(hotlist_old_tree, hotlist_old_tree_root,
- true, false);
-}
-
-/**
- * Expand grouping folders and history entries.
- */
-void hotlist_old_expand_all(void)
-{
- tree_set_node_expanded(hotlist_old_tree, hotlist_old_tree_root,
- true, true, true);
-}
-
-/**
- * Expand grouping folders only.
- */
-void hotlist_old_expand_directories(void)
-{
- tree_set_node_expanded(hotlist_old_tree, hotlist_old_tree_root,
- true, true, false);
-}
-
-/**
- * Expand history entries only.
- */
-void hotlist_old_expand_addresses(void)
-{
- tree_set_node_expanded(hotlist_old_tree, hotlist_old_tree_root,
- true, false, true);
-}
-
-/**
- * Collapse grouping folders and history entries.
- */
-void hotlist_old_collapse_all(void)
-{
- tree_set_node_expanded(hotlist_old_tree, hotlist_old_tree_root,
- false, true, true);
-}
-
-/**
- * Collapse grouping folders only.
- */
-void hotlist_old_collapse_directories(void)
-{
- tree_set_node_expanded(hotlist_old_tree, hotlist_old_tree_root,
- false, true, false);
-}
-
-/**
- * Collapse history entries only.
- */
-void hotlist_old_collapse_addresses(void)
-{
- tree_set_node_expanded(hotlist_old_tree,
- hotlist_old_tree_root, false, false, true);
-}
-
-/**
- * Add a folder node.
- *
- * \param selected create the folder in the currently-selected node
- */
-void hotlist_old_add_folder(bool selected)
-{
- struct node *node, *parent = NULL;
-
- /* Update new hotlist */
- if (nsoption_bool(temp_treeview_test) != false) {
- hotlist_add_folder(NULL, false, 0);
- return;
- }
-
- creating_node = true;
-
- if (selected == true) {
- parent = tree_get_selected_node(tree_get_root(hotlist_old_tree));
- if (parent && (tree_node_is_folder(parent) == false)) {
- parent = tree_node_get_parent(parent);
- }
- }
-
- if (parent == NULL) {
- parent = tree_get_default_folder_node(hotlist_old_tree);
- }
-
- node = tree_create_folder_node(hotlist_old_tree,
- parent,
- messages_get("Untitled"),
- true,
- false,
- false);
- if (node == NULL) {
- warn_user(messages_get_errorcode(NSERROR_NOMEM), 0);
- return;
- }
-
- tree_set_node_user_callback(node, hotlist_old_node_callback, NULL);
- tree_set_node_icon(hotlist_old_tree, node, folder_icon);
- tree_start_edit(hotlist_old_tree,
- tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL));
-}
-
-/**
- * Add an entry node.
- *
- * \param selected add the entry in the currently-selected node
- */
-void hotlist_old_add_entry(bool selected)
-{
- struct node *node;
- struct node *parent = NULL;
- nsurl *url;
- creating_node = true;
-
- if (selected == true) {
- parent = tree_get_selected_node(tree_get_root(hotlist_old_tree));
- if (parent && (tree_node_is_folder(parent) == false)) {
- parent = tree_node_get_parent(parent);
- }
- }
-
- if (parent == NULL) {
- parent = tree_get_default_folder_node(hotlist_old_tree);
- }
-
- if (nsurl_create("http://netsurf-browser.org/", &url) != NSERROR_OK)
- return;
-
- /* Update new hotlist */
- if (nsoption_bool(temp_treeview_test) != false) {
- hotlist_add_entry(url, "New untitled entry", false, 0);
- nsurl_unref(url);
- return;
- }
- node = tree_create_URL_node(hotlist_old_tree, parent, url, "Untitled",
- hotlist_old_node_callback, NULL);
-
- nsurl_unref(url);
-
- if (node == NULL)
- return;
- tree_set_node_user_callback(node, hotlist_old_node_callback, NULL);
- tree_url_node_edit_title(hotlist_old_tree, node);
-}
-
-/**
- * Adds the currently viewed page to the hotlist
- */
-void hotlist_old_add_page(const char *url)
-{
- const struct url_data *data;
- struct node *node, *parent;
- nsurl *nsurl;
-
- if (url == NULL)
- return;
-
- if (nsurl_create(url, &nsurl) != NSERROR_OK)
- return;
-
- /* Update new hotlist */
- if (nsoption_bool(temp_treeview_test) != false) {
- hotlist_add_url(nsurl);
- nsurl_unref(nsurl);
- return;
- }
-
- data = urldb_get_url_data(nsurl);
- if (data == NULL)
- return;
-
- parent = tree_get_default_folder_node(hotlist_old_tree);
- node = tree_create_URL_node(hotlist_old_tree, parent, nsurl, NULL,
- hotlist_old_node_callback, NULL);
- tree_update_URL_node(hotlist_old_tree, node, nsurl, data);
-
- nsurl_unref(nsurl);
-}
-
-/**
- * Adds the currently viewed page to the hotlist at the given co-ordinates
- * \param url url of the page
- * \param x X cooridinate with respect to tree origin
- * \param y Y cooridinate with respect to tree origin
- */
-void hotlist_old_add_page_xy(const char *url, int x, int y)
-{
- const struct url_data *data;
- struct node *link, *node;
- bool before;
- nsurl *nsurl;
-
- if (url == NULL)
- return;
-
- if (nsurl_create(url, &nsurl) != NSERROR_OK)
- return;
-
- /* Update new hotlist */
- if (nsoption_bool(temp_treeview_test) != false) {
- hotlist_add_entry(nsurl, NULL, true, y);
- nsurl_unref(nsurl);
- return;
- }
-
- data = urldb_get_url_data(nsurl);
- if (data == NULL) {
- urldb_add_url(nsurl);
- urldb_set_url_persistence(nsurl, true);
- data = urldb_get_url_data(nsurl);
- }
- if (data != NULL) {
- link = tree_get_link_details(hotlist_old_tree, x, y, &before);
- node = tree_create_URL_node(NULL, NULL, nsurl,
- NULL, hotlist_old_node_callback, NULL);
- tree_link_node(hotlist_old_tree, link, node, before);
- }
- nsurl_unref(nsurl);
-}
-
-/**
- * Open the selected entries in separate browser windows.
- *
- * \param tabs open multiple entries in tabs in the new window
- */
-void hotlist_old_launch_selected(bool tabs)
-{
- if (nsoption_bool(temp_treeview_test) != false) {
- hotlist_keypress(KEY_CR);
- return;
- }
- tree_launch_selected(hotlist_old_tree, tabs);
-}
-
-/**
- * Set the hotlist's default folder to the selected node.
- *
- * \param clear reset the default to tree root
- */
-bool hotlist_old_set_default_folder(bool clear)
-{
- if (clear == true) {
- tree_clear_default_folder_node(hotlist_old_tree);
- return true;
- } else {
- return tree_set_default_folder_node(hotlist_old_tree, NULL);
- }
-}
diff --git a/desktop/hotlist_old.h b/desktop/hotlist_old.h
deleted file mode 100644
index 776bef2..0000000
--- a/desktop/hotlist_old.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2004, 2005 Richard Wilson <info(a)tinct.net>
- * Copyright 2009 Paul Blokus <paul_pl(a)users.sourceforge.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-
-/** \file
- * Hotlist (interface).
- */
-
-#ifndef _NETSURF_DESKTOP_HOTLIST_OLD_H_
-#define _NETSURF_DESKTOP_HOTLIST_OLD_H_
-
-#include <stdbool.h>
-
-#include "desktop/tree.h"
-
-/**
- * Initialise the hotlist from a frontend.
- *
- * \param tree The tree object which holds the hotlist.
- * \param hotlist_path The file path to initialise the hotlist entries from.
- * \param folder_icon_name The name to use for folder icons.
- */
-bool hotlist_old_initialise(struct tree *tree, const char *hotlist_path, const char* folder_icon_name);
-
-unsigned int hotlist_old_get_tree_flags(void);
-void hotlist_old_cleanup(const char *hotlist_path);
-
-void hotlist_old_visited(struct hlcache_handle *c);
-
-bool hotlist_old_export(const char *path);
-void hotlist_old_edit_selected(void);
-void hotlist_old_delete_selected(void);
-void hotlist_old_select_all(void);
-void hotlist_old_clear_selection(void);
-void hotlist_old_expand_all(void);
-void hotlist_old_expand_directories(void);
-void hotlist_old_expand_addresses(void);
-void hotlist_old_collapse_all(void);
-void hotlist_old_collapse_directories(void);
-void hotlist_old_collapse_addresses(void);
-void hotlist_old_add_folder(bool selected);
-void hotlist_old_add_entry(bool selected);
-void hotlist_old_add_page(const char *url);
-void hotlist_old_add_page_xy(const char *url, int x, int y);
-void hotlist_old_launch_selected(bool tabs);
-bool hotlist_old_set_default_folder(bool clear);
-#endif
diff --git a/desktop/options.h b/desktop/options.h
index 7ed6fc1..391dfbc 100644
--- a/desktop/options.h
+++ b/desktop/options.h
@@ -275,6 +275,3 @@ NSOPTION_COLOUR(sys_colour_ThreeDShadow, 0x00d5d5d5)
NSOPTION_COLOUR(sys_colour_Window, 0x00f1f1f1)
NSOPTION_COLOUR(sys_colour_WindowFrame, 0x004e4e4e)
NSOPTION_COLOUR(sys_colour_WindowText, 0x00000000)
-
-/** Temporary option for enabling test of new treeview */
-NSOPTION_BOOL(temp_treeview_test, false)
diff --git a/desktop/sslcert_viewer.c b/desktop/sslcert_viewer.c
index 7362371..e0e87fb 100644
--- a/desktop/sslcert_viewer.c
+++ b/desktop/sslcert_viewer.c
@@ -27,7 +27,6 @@
#include "content/fetch.h"
#include "content/urldb.h"
-#include "desktop/browser.h"
#include "desktop/sslcert_viewer.h"
#include "desktop/treeview.h"
#include "utils/messages.h"
@@ -505,10 +504,3 @@ void sslcert_viewer_keypress(struct sslcert_session_data *ssl_d,
{
treeview_keypress(ssl_d->tree, key);
}
-
-
-/* Exported interface, documented in sslcert_viewer.h */
-int sslcert_viewer_get_height(struct sslcert_session_data *ssl_d)
-{
- return treeview_get_height(ssl_d->tree);
-}
diff --git a/desktop/sslcert_viewer.h b/desktop/sslcert_viewer.h
index c5bb5c0..e02f095 100644
--- a/desktop/sslcert_viewer.h
+++ b/desktop/sslcert_viewer.h
@@ -22,8 +22,12 @@
#define _NETSURF_DESKTOP_SSLCERT_VIEWER_H_
#include <stdbool.h>
+#include <stdint.h>
+#include "desktop/browser.h"
#include "desktop/core_window.h"
+#include "desktop/textinput.h"
+#include "utils/errors.h"
struct sslcert_session_data;
@@ -121,11 +125,4 @@ void sslcert_viewer_mouse_action(struct sslcert_session_data *ssl_d,
void sslcert_viewer_keypress(struct sslcert_session_data *ssl_d,
uint32_t key);
-/**
- * Find current height
- *
- * \return height in px
- */
-int sslcert_viewer_get_height(struct sslcert_session_data *ssl_d);
-
#endif
diff --git a/desktop/tree.c b/desktop/tree.c
index 8966be3..cb981b3 100644
--- a/desktop/tree.c
+++ b/desktop/tree.c
@@ -18,7 +18,7 @@
*/
/** \file
- * Generic tree handling (implementation).
+ * deprecated compatibility layer for new treeview modules. Do not use.
*/
#include <assert.h>
@@ -30,152 +30,21 @@
#include "content/hlcache.h"
#include "css/utils.h"
#include "desktop/browser.h"
-#include "desktop/knockout.h"
-#include "desktop/textarea.h"
-#include "desktop/textinput.h"
#include "desktop/tree.h"
#include "utils/nsoption.h"
-#include "desktop/plotters.h"
#include "render/font.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/url.h"
-#undef TREE_NOISY_DEBUG
-
-#define MAXIMUM_URL_LENGTH 1024
-
-#define TREE_TEXT_SIZE_PT 11
-#define TREE_ICON_SIZE 17
-#define NODE_INSTEP 20
-
-static int tree_text_size_px;
-static int TREE_LINE_HEIGHT;
-
-static char *tree_icons_dir = NULL;
-
-static plot_font_style_t plot_fstyle = {
- .family = PLOT_FONT_FAMILY_SANS_SERIF,
- .size = TREE_TEXT_SIZE_PT * FONT_SIZE_SCALE,
- .weight = 400,
- .flags = FONTF_NONE
-};
-
-static plot_font_style_t plot_fstyle_def_folder = {
- .family = PLOT_FONT_FAMILY_SANS_SERIF,
- .size = TREE_TEXT_SIZE_PT * FONT_SIZE_SCALE,
- .weight = 700,
- .flags = FONTF_NONE
-};
-
-static plot_font_style_t plot_fstyle_selected = {
- .family = PLOT_FONT_FAMILY_SANS_SERIF,
- .size = TREE_TEXT_SIZE_PT * FONT_SIZE_SCALE,
- .weight = 400,
- .flags = FONTF_NONE
-};
-
-static plot_font_style_t plot_fstyle_selected_def_folder = {
- .family = PLOT_FONT_FAMILY_SANS_SERIF,
- .size = TREE_TEXT_SIZE_PT * FONT_SIZE_SCALE,
- .weight = 700,
- .flags = FONTF_NONE
-};
-
-/** plot style for treeview backgrounds. */
-static plot_style_t plot_style_fill_tree_background = {
- .fill_type = PLOT_OP_TYPE_SOLID
-};
-
-/** plot style for treeview backgrounds. */
-static plot_style_t plot_style_fill_tree_selected = {
- .fill_type = PLOT_OP_TYPE_SOLID
-};
-
-/** plot style for treeview furniture lines. */
-static plot_style_t plot_style_stroke_tree_furniture = {
- .stroke_type = PLOT_OP_TYPE_SOLID
-};
-
-/** plot style for treeview furniture fills. */
-static plot_style_t plot_style_fill_tree_furniture = {
- .fill_type = PLOT_OP_TYPE_SOLID
-};
-
-struct node;
-struct tree;
-
-struct node_element_box {
- int x; /**< X offset from origin */
- int y; /**< Y offset from origin */
- int width; /**< Element width */
- int height; /**< Element height */
-};
-
-struct node_element {
- struct node *parent; /**< Parent node */
- node_element_type type; /**< Element type */
- struct node_element_box box; /**< Element bounding box */
- char *text; /**< Text for the element */
- void *bitmap; /**< Bitmap for the element */
- struct node_element *next; /**< Next node element */
- unsigned int flag; /**< Client specified flag for data
- being represented */
- bool editable; /**< Whether the node text can be
- * modified, editable text is deleted
- * without noticing the tree user
- */
-};
-
-struct node {
- bool selected; /**< Whether the node is selected */
- bool expanded; /**< Whether the node is expanded */
- bool folder; /**< Whether the node is a folder */
- bool def_folder; /**< Whether the node is the default folder */
- bool retain_in_memory; /**< Whether the node remains
- in memory after deletion */
- bool deleted; /**< Whether the node is currently
- deleted */
- bool processing; /**< Internal flag used when moving */
- struct node_element_box box; /**< Bounding box of all elements */
- struct node_element data; /**< Data to display */
- struct node *parent; /**< Parent entry (NULL for root) */
- struct node *child; /**< First child */
- struct node *last_child; /**< Last child */
- struct node *previous; /**< Previous child of the parent */
- struct node *next; /**< Next child of the parent */
-
- /** Sorting function for the node (for folder nodes only) */
- int (*sort) (struct node *, struct node *);
- /** Gets called for each deleted node_element and on node launch */
- tree_node_user_callback user_callback;
- /** User data to be passed to delete_callback */
- void *callback_data;
-};
-
struct tree {
- struct node *root; /* Tree root element */
- int width; /* Tree width */
- int height; /* Tree height */
- unsigned int flags; /* Tree flags */
- struct textarea *textarea; /* Handle for UTF-8 textarea */
- int ta_height; /* Textarea height */
- struct node_element *editing; /* Node element being edited */
-
- bool redraw; /* Flag indicating whether the tree
- should be redrawn on layout
- changes */
+ unsigned int flags; /* Tree flags */
tree_drag_type drag;
const struct treeview_table *callbacks;
- void *client_data; /* User assigned data for the
- callbacks */
- struct node *def_folder; /* Node to be used for additions by default */
+ void *client_data; /* User assigned data for the callbacks */
};
-
-
-
#include "desktop/treeview.h"
#include "desktop/hotlist.h"
#include "desktop/cookie_manager.h"
@@ -184,7 +53,6 @@ struct tree {
struct sslcert_session_data *ssl_current_session = NULL;
const char *tree_hotlist_path = NULL;
-
int treeview_inits;
static void treeview_test_redraw_request(struct core_window *cw,
@@ -257,7 +125,7 @@ static bool treeview_test_init(struct tree *tree)
{
nserror err;
- if (tree->flags & TREE_SSLCERT) {
+ if (tree->flags == TREE_SSLCERT) {
treeview_inits++;
@@ -272,28 +140,24 @@ static bool treeview_test_init(struct tree *tree)
return true;
}
- /* Check if we're testing the new treeview */
- if (nsoption_bool(temp_treeview_test) == false)
- return false;
-
treeview_inits++;
if (treeview_inits == 1)
treeview_init();
- if (tree->flags & TREE_COOKIES) {
+ if (tree->flags == TREE_COOKIES) {
err = cookie_manager_init(&cw_t, (struct core_window *)tree);
if (err != NSERROR_OK) {
warn_user("Couldn't init new cookie manager.", 0);
}
}
- if (tree->flags & TREE_HISTORY) {
+ if (tree->flags == TREE_HISTORY) {
err = global_history_init(&cw_t, (struct core_window *)tree);
if (err != NSERROR_OK) {
warn_user("Couldn't init new global history.", 0);
}
}
- if (tree->flags & TREE_HOTLIST) {
+ if (tree->flags == TREE_HOTLIST) {
err = hotlist_init(&cw_t, (struct core_window *)tree,
tree_hotlist_path);
if (err != NSERROR_OK) {
@@ -308,7 +172,7 @@ static bool treeview_test_fini(struct tree *tree)
{
nserror err;
- if (tree->flags & TREE_SSLCERT) {
+ if (tree->flags == TREE_SSLCERT) {
err = sslcert_viewer_fini(ssl_current_session);
if (err != NSERROR_OK) {
warn_user("Couldn't finalise sslcert viewer.", 0);
@@ -321,23 +185,19 @@ static bool treeview_test_fini(struct tree *tree)
return true;
}
- /* Check if we're testing the new treeview */
- if (nsoption_bool(temp_treeview_test) == false)
- return false;
-
- if (tree->flags & TREE_COOKIES) {
+ if (tree->flags == TREE_COOKIES) {
err = cookie_manager_fini();
if (err != NSERROR_OK) {
warn_user("Couldn't finalise cookie manager.", 0);
}
}
- if (tree->flags & TREE_HISTORY) {
+ if (tree->flags == TREE_HISTORY) {
err = global_history_fini();
if (err != NSERROR_OK) {
warn_user("Couldn't finalise cookie manager.", 0);
}
}
- if (tree->flags & TREE_HOTLIST) {
+ if (tree->flags == TREE_HOTLIST) {
err = hotlist_fini(tree_hotlist_path);
if (err != NSERROR_OK) {
warn_user("Couldn't finalise hotlist.", 0);
@@ -362,24 +222,20 @@ static bool treeview_test_redraw(struct tree *tree, int x, int y,
clip.x1 = clip_x + clip_width;
clip.y1 = clip_y + clip_height;
- if (tree->flags & TREE_SSLCERT) {
+ if (tree->flags == TREE_SSLCERT) {
sslcert_viewer_redraw(ssl_current_session, x, y, &clip, ctx);
return true;
}
- /* Check if we're testing the new treeview */
- if (nsoption_bool(temp_treeview_test) == false)
- return false;
-
- if (tree->flags & TREE_COOKIES) {
+ if (tree->flags == TREE_COOKIES) {
cookie_manager_redraw(x, y, &clip, ctx);
return true;
}
- if (tree->flags & TREE_HISTORY) {
+ if (tree->flags == TREE_HISTORY) {
global_history_redraw(x, y, &clip, ctx);
return true;
}
- if (tree->flags & TREE_HOTLIST) {
+ if (tree->flags == TREE_HOTLIST) {
hotlist_redraw(x, y, &clip, ctx);
return true;
}
@@ -390,24 +246,20 @@ static bool treeview_test_redraw(struct tree *tree, int x, int y,
static bool treeview_test_mouse_action(struct tree *tree,
browser_mouse_state mouse, int x, int y)
{
- if (tree->flags & TREE_SSLCERT) {
+ if (tree->flags == TREE_SSLCERT) {
sslcert_viewer_mouse_action(ssl_current_session, mouse, x, y);
return true;
}
- /* Check if we're testing the new treeview */
- if (nsoption_bool(temp_treeview_test) == false)
- return false;
-
- if (tree->flags & TREE_COOKIES) {
+ if (tree->flags == TREE_COOKIES) {
cookie_manager_mouse_action(mouse, x, y);
return true;
}
- if (tree->flags & TREE_HISTORY) {
+ if (tree->flags == TREE_HISTORY) {
global_history_mouse_action(mouse, x, y);
return true;
}
- if (tree->flags & TREE_HOTLIST) {
+ if (tree->flags == TREE_HOTLIST) {
hotlist_mouse_action(mouse, x, y);
return true;
}
@@ -417,24 +269,20 @@ static bool treeview_test_mouse_action(struct tree *tree,
static bool treeview_test_keypress(struct tree *tree, uint32_t key)
{
- if (tree->flags & TREE_SSLCERT) {
+ if (tree->flags == TREE_SSLCERT) {
sslcert_viewer_keypress(ssl_current_session, key);
return true;
}
- /* Check if we're testing the new treeview */
- if (nsoption_bool(temp_treeview_test) == false)
- return false;
-
- if (tree->flags & TREE_COOKIES) {
+ if (tree->flags == TREE_COOKIES) {
cookie_manager_keypress(key);
return true;
}
- if (tree->flags & TREE_HISTORY) {
+ if (tree->flags == TREE_HISTORY) {
global_history_keypress(key);
return true;
}
- if (tree->flags & TREE_HOTLIST) {
+ if (tree->flags == TREE_HOTLIST) {
hotlist_keypress(key);
return true;
}
@@ -442,76 +290,9 @@ static bool treeview_test_keypress(struct tree *tree, uint32_t key)
return false;
}
+/* -------------------------------------------------------------------------- */
-
-
-
-
-
-
-
-
-
-
-
-
-
-void tree_set_icon_dir(char *icon_dir)
-{
- LOG(("Tree icon directory set to %s", icon_dir));
- tree_icons_dir = icon_dir;
-}
-
-/**
- * Set up colours for plot styles used in tree redraw.
- */
-void tree_setup_colours(void)
-{
- /* Background colour */
- plot_style_fill_tree_background.fill_colour =
- gui_system_colour_char("Window");
-
- /* Selection background colour */
- plot_style_fill_tree_selected.fill_colour =
- gui_system_colour_char("Highlight");
-
- /* Furniture line colour */
- plot_style_stroke_tree_furniture.stroke_colour = blend_colour(
- gui_system_colour_char("Window"),
- gui_system_colour_char("WindowText"));
-
- /* Furniture fill colour */
- plot_style_fill_tree_furniture.fill_colour =
- gui_system_colour_char("Window");
-
- /* Text colour */
- plot_fstyle.foreground = gui_system_colour_char("WindowText");
- plot_fstyle.background = gui_system_colour_char("Window");
- plot_fstyle_def_folder.foreground =
- gui_system_colour_char("InfoText");
- plot_fstyle_def_folder.background =
- gui_system_colour_char("Window");
-
- /* Selected text colour */
- plot_fstyle_selected.foreground =
- gui_system_colour_char("HighlightText");
- plot_fstyle_selected.background =
- gui_system_colour_char("Highlight");
- plot_fstyle_selected_def_folder.foreground =
- gui_system_colour_char("HighlightText");
- plot_fstyle_selected_def_folder.background =
- gui_system_colour_char("Highlight");
-}
-
-
-/**
- * Creates and initialises a new tree.
- *
- * \param flags Flag word for flags to create the new tree with
- * \param callbacks Callback functions to support the tree in the frontend.
- * \param client_data Data to be passed to start_redraw and end_redraw
- * \return The newly created tree, or NULL on memory exhaustion
- */
+/** deprecated compatibility layer for new treeview modules. Do not use. */
struct tree *tree_create(unsigned int flags,
const struct treeview_table *callbacks, void *client_data)
{
@@ -524,2865 +305,69 @@ struct tree *tree_create(unsigned int flags,
return NULL;
}
- tree->root = tree_create_folder_node(NULL,
- NULL,
- messages_get("Root"),
- false, false, false);
- if (tree->root == NULL) {
- free(tree);
- return NULL;
- }
- tree->root->expanded = true;
-
- tree->width = 0;
- tree->height = 0;
tree->flags = flags;
- tree->textarea = NULL;
- tree->editing = NULL;
- tree->redraw = false;
tree->drag = TREE_NO_DRAG;
tree->callbacks = callbacks;
tree->client_data = client_data;
- /* Set text height in pixels */
- tree_text_size_px =
- (TREE_TEXT_SIZE_PT * FIXTOINT(nscss_screen_dpi) + 36) /
- 72;
- /* Set line height appropriate for this text height in pixels
- * Using 4/3 text height */
- TREE_LINE_HEIGHT = (tree_text_size_px * 8 + 3) / 6;
-
- /* But if that's too small for the icons, base the line height on
- * the icon height. */
- if (TREE_LINE_HEIGHT < TREE_ICON_SIZE + 2)
- TREE_LINE_HEIGHT = TREE_ICON_SIZE + 2;
-
- tree_setup_colours();
-
treeview_test_init(tree);
return tree;
}
-
-/**
- * Recalculates the dimensions of a node element.
- *
- * \param tree the tree to which the element belongs, may be NULL
- * \param element the element to recalculate
- */
-static void tree_recalculate_node_element(struct tree *tree,
- struct node_element *element)
-{
- struct bitmap *bitmap = NULL;
- int width, height;
- static char *cache_text = NULL;
- static int cache_size = 0;
- plot_font_style_t *fstyle;
- static plot_font_style_t *cache_fstyle = NULL;
-
- assert(element != NULL);
-
- if (element->parent->def_folder)
- fstyle = &plot_fstyle_def_folder;
- else
- fstyle = &plot_fstyle;
-
- switch (element->type) {
- case NODE_ELEMENT_TEXT_PLUS_ICON:
- case NODE_ELEMENT_TEXT:
- if(element->text == NULL)
- break;
-
- if (tree != NULL && element == tree->editing) {
- textarea_get_dimensions(tree->textarea,
- &element->box.width, NULL);
- } else {
- if ((cache_text != NULL) &&
- (strcmp(cache_text, element->text) == 0) &&
- (cache_fstyle == fstyle)) {
- element->box.width = cache_size;
- #ifdef TREE_NOISY_DEBUG
- LOG(("Tree font width cache hit"));
- #endif
- } else {
- if(cache_text != NULL) free(cache_text);
- nsfont.font_width(fstyle,
- element->text,
- strlen(element->text),
- &cache_size);
- element->box.width = cache_size;
- cache_text = strdup(element->text);
- cache_fstyle = fstyle;
- }
- }
-
- element->box.width += 8;
- element->box.height = TREE_LINE_HEIGHT;
-
- if (element->type == NODE_ELEMENT_TEXT_PLUS_ICON)
- element->box.width += NODE_INSTEP;
-
- break;
-
- case NODE_ELEMENT_BITMAP:
- bitmap = element->bitmap;
- if (bitmap != NULL) {
- width = bitmap_get_width(bitmap);
- height = bitmap_get_height(bitmap);
- element->box.width = width + 1;
- element->box.height = height + 2;
- } else {
- element->box.width = 0;
- element->box.height = 0;
- }
- break;
- }
-}
-
-
-/**
- * Calculates the height of a node including any children
- *
- * \param node the node to calculate the height of
- * \return the total height of the node and children
- */
-static int tree_get_node_height(struct node *node)
-{
- int y1;
-
- assert(node != NULL);
-
- if ((node->child == NULL) || (node->expanded == false)) {
- return node->box.height;
- }
-
- y1 = node->box.y;
- if (y1 < 0) {
- y1 = 0;
- }
- node = node->child;
-
- while ((node->next != NULL) ||
- ((node->child != NULL) && (node->expanded))) {
- for (; node->next != NULL; node = node->next);
-
- if ((node->child != NULL) && (node->expanded)) {
- node = node->child;
- }
- }
- return node->box.y + node->box.height - y1;
-}
-
-
-/**
- * Calculates the width of a node including any children
- *
- * \param node the node to calculate the height of
- * \return the total width of the node and children
- */
-static int tree_get_node_width(struct node *node)
-{
- int width = 0;
- int child_width;
-
- assert(node != NULL);
-
- for (; node != NULL; node = node->next) {
- if (width < (node->box.x + node->box.width)) {
- width = node->box.x + node->box.width;
- }
-
- if ((node->child != NULL) && (node->expanded)) {
- child_width = tree_get_node_width(node->child);
- if (width < child_width) {
- width = child_width;
- }
- }
- }
- return width;
-}
-
-
-/**
- * Recalculates the position of a node, its siblings and children.
- *
- * \param tree the tree to which 'root' belongs
- * \param root the root node to update from
- */
-static void tree_recalculate_node_positions(struct tree *tree,
- struct node *root)
-{
- struct node *parent;
- struct node *node;
- struct node *child;
- struct node_element *element;
- int y;
- bool has_icon;
-
- for (node = root; node != NULL; node = node->next) {
-
- parent = node->parent;
-
- if (node->previous != NULL) {
- node->box.x = node->previous->box.x;
- node->box.y = node->previous->box.y +
- tree_get_node_height(node->previous);
- } else if (parent != NULL) {
- node->box.x = parent->box.x + NODE_INSTEP;
- node->box.y = parent->box.y +
- parent->box.height;
- for (child = parent->child; child != node;
- child = child->next)
- node->box.y += child->box.height;
- } else {
- node->box.x = tree->flags & TREE_NO_FURNITURE
- ? -NODE_INSTEP + 4 : 0;
- node->box.y = -TREE_LINE_HEIGHT;
- }
-
- if (!node->expanded) {
- node->data.box.x = node->box.x;
- node->data.box.y = node->box.y;
- continue;
- }
-
- if (node->folder) {
- node->data.box.x = node->box.x;
- node->data.box.y = node->box.y;
- tree_recalculate_node_positions(tree, node->child);
- } else {
- y = node->box.y;
- has_icon = false;
- for (element = &node->data; element != NULL;
- element = element->next)
- if (element->type ==
- NODE_ELEMENT_TEXT_PLUS_ICON) {
- has_icon = true;
- break;
- }
-
- for (element = &node->data; element != NULL;
- element = element->next) {
- element->box.x = node->box.x;
- if (element->type !=
- NODE_ELEMENT_TEXT_PLUS_ICON &&
- has_icon)
- element->box.x += NODE_INSTEP;
- element->box.y = y;
- y += element->box.height;
- }
- }
-
- }
-}
-
-
-/**
- * Recalculates the size of a node.
- *
- * \param tree the tree to which node belongs, may be NULL
- * \param node the node to update
- * \param recalculate_sizes whether the node elements have changed
- */
-static void tree_recalculate_node_sizes(struct tree *tree, struct node *node,
- bool recalculate_sizes)
-{
- struct node_element *element;
- int height;
-
- assert(node != NULL);
-
- height = node->box.height;
- node->box.width = 0;
- node->box.height = 0;
- if (node->expanded) {
- for (element = &node->data; element != NULL;
- element = element->next) {
- if (recalculate_sizes) {
- #ifdef TREE_NOISY_DEBUG
- if(element->text) LOG(("%s", element->text));
- #endif
- tree_recalculate_node_element(tree, element);
- }
- node->box.width = (node->box.width > element->box.x +
- element->box.width - node->box.x) ?
- node->box.width :
- element->box.width + element->box.x -
- node->box.x;
- node->box.height += element->box.height;
- }
- } else {
- if (recalculate_sizes)
- for (element = &node->data; element != NULL;
- element = element->next) {
- #ifdef TREE_NOISY_DEBUG
- if(element->text) LOG(("%s", element->text));
- #endif
- tree_recalculate_node_element(tree, element);
- }
-
- node->box.width = node->data.box.width;
- node->box.height = node->data.box.height;
- }
-
- if (tree != NULL && height != node->box.height)
- tree_recalculate_node_positions(tree, tree->root);
-}
-
-
-/* exported interface documented in desktop/tree.h */
-struct node *tree_create_folder_node(struct tree *tree, struct node *parent,
- const char *title, bool editable, bool retain_in_memory,
- bool deleted)
-{
- struct node *node;
-
- assert(title != NULL);
-
- node = calloc(sizeof(struct node), 1);
- if (node == NULL) {
- return NULL;
- }
-
- node->data.text = strdup(title);
- if (node->data.text == NULL) {
- free(node);
- return NULL;
- }
-
- node->folder = true;
- node->retain_in_memory = retain_in_memory;
- node->deleted = deleted;
- node->data.parent = node;
- node->data.type = NODE_ELEMENT_TEXT;
- node->data.flag = TREE_ELEMENT_TITLE;
- node->data.editable = editable;
- node->sort = NULL;
- node->user_callback = NULL;
- node->previous = NULL;
-
- tree_recalculate_node_sizes(tree, node, true);
- if (parent != NULL) {
- tree_link_node(tree, parent, node, false);
- }
-
- return node;
-}
-
-/* exported interface documented in desktop/tree.h */
-struct node *tree_create_leaf_node(struct tree *tree, struct node *parent,
- const char *title, bool editable, bool retain_in_memory,
- bool deleted)
-{
- struct node *node;
-
- assert(title != NULL);
-
- node = calloc(sizeof(struct node), 1);
- if (node == NULL) {
- return NULL;
- }
-
- node->data.text = strdup(title);
- if (node->data.text == NULL) {
- free(node);
- return NULL;
- }
-
- node->folder = false;
- node->retain_in_memory = retain_in_memory;
- node->deleted = deleted;
- node->data.parent = node;
- node->data.type = NODE_ELEMENT_TEXT;
- node->data.flag = TREE_ELEMENT_TITLE;
- node->data.editable = editable;
- node->sort = NULL;
- node->user_callback = NULL;
- node->previous = NULL;
-
- tree_recalculate_node_sizes(tree, node, true);
- if (parent != NULL) {
- tree_link_node(tree, parent, node, false);
- }
-
- return node;
-}
-
-
-/**
- * Creates an empty text node element and links it to a node.
- *
- * \param parent the parent node
- * \param type the required element type
- * \param flag user assigned flag used for searches
- * \return the newly created element.
- */
-struct node_element *tree_create_node_element(struct node *parent,
- node_element_type type, unsigned int flag, bool editable)
-{
- struct node_element *element;
-
- element = calloc(sizeof(struct node_element), 1);
- if (element == NULL)
- return NULL;
-
- element->parent = parent;
- element->flag = flag;
- element->type = type;
- element->editable = editable;
- element->next = parent->data.next;
- parent->data.next = element;
-
- return element;
-}
-
-
-/**
- * Inserts a node into the correct place according to the parent's sort function
- *
- * \param parent the node whose child node 'node' becomes
- * \param node the node to be inserted
- */
-static void tree_sort_insert(struct node *parent, struct node *node)
+/** deprecated compatibility layer for new treeview modules. Do not use. */
+void tree_delete(struct tree *tree)
{
- struct node *after;
-
- assert(node != NULL);
- assert(parent != NULL);
- assert(parent->sort != NULL);
-
- after = parent->last_child;
- while ((after != NULL) &&
- (parent->sort(node, after) == -1))
- after = after->previous;
-
- if (after != NULL) {
- if (after->next != NULL)
- after->next->previous = node;
- node->next = after->next;
- node->previous = after;
- after->next = node;
- } else {
- node->previous = NULL;
- node->next = parent->child;
- if (parent->child != NULL) {
- parent->child->previous = node;
- }
- parent->child = node;
- }
-
- if (node->next == NULL)
- parent->last_child = node;
-
- node->parent = parent;
+ treeview_test_fini(tree);
+ free(tree);
}
-
-/**
- * Recalculates the size of a tree.
- *
- * \param tree the tree to recalculate
- */
-static void tree_recalculate_size(struct tree *tree)
+/** deprecated compatibility layer for new treeview modules. Do not use. */
+void tree_draw(struct tree *tree, int x, int y,
+ int clip_x, int clip_y, int clip_width, int clip_height,
+ const struct redraw_context *ctx)
{
- int width, height;
-
assert(tree != NULL);
- width = tree->width;
- height = tree->height;
-
- tree->width = tree_get_node_width(tree->root);
- tree->height = tree_get_node_height(tree->root);
-
- if ((width != tree->width) || (height != tree->height))
- tree->callbacks->resized(tree, tree->width, tree->height,
- tree->client_data);
+ treeview_test_redraw(tree, x, y, clip_x, clip_y,
+ clip_width, clip_height, ctx);
}
-/**
- * Recalculate the node data and redraw the relevant section of the tree.
- *
- * \param tree the tree to redraw, may be NULL
- * \param node the node to update
- * \param recalculate_sizes whether the elements have changed
- * \param expansion the request is the result of a node expansion
- */
-static void tree_handle_node_changed(struct tree *tree, struct node *node,
- bool recalculate_sizes, bool expansion)
+/** deprecated compatibility layer for new treeview modules. Do not use. */
+bool tree_mouse_action(struct tree *tree, browser_mouse_state mouse, int x,
+ int y)
{
- int node_width, node_height, tree_width, tree_height;
-
- assert(node != NULL);
assert(tree != NULL);
- node_width = node->box.width;
- node_height = node->box.height;
- tree_width = tree->width;
- tree_height = tree->height;
-
- if ((recalculate_sizes) || (expansion)) {
- tree_recalculate_node_sizes(tree, node, true);
+ if (treeview_test_mouse_action(tree, mouse, x, y)) {
+ return true;
}
- if (tree != NULL) {
- if ((node->box.height != node_height) || (expansion)) {
- tree_recalculate_node_positions(tree, tree->root);
- tree_recalculate_size(tree);
- if (tree->width > tree_width)
- tree_width = tree->width;
- if (tree->height > tree_height)
- tree_height = tree->height;
- if (tree->redraw) {
- tree->callbacks->redraw_request(0, node->box.y,
- tree_width,
- tree_height - node->box.y,
- tree->client_data);
- }
- } else {
- if (node->box.width > node_width)
- node_width = node->box.width;
- if (tree->redraw)
- tree->callbacks->redraw_request(node->box.x,
- node->box.y,
- node_width, node->box.height,
- tree->client_data);
- if (recalculate_sizes) {
- tree_recalculate_size(tree);
- }
- }
- }
+ return false;
}
-
-/**
- * Links a node to another node.
- *
- * \param tree the tree in which the link takes place, may be NULL
- * \param link the node to link before/as a child (folders)
- * or before/after (link)
- * \param node the node to link
- * \param before whether to link siblings before or after the supplied node
- */
-void tree_link_node(struct tree *tree, struct node *link, struct node *node,
- bool before)
+/** deprecated compatibility layer for new treeview modules. Do not use. */
+void tree_drag_end(struct tree *tree, browser_mouse_state mouse, int x0, int y0,
+ int x1, int y1)
{
+ assert(tree != NULL);
- struct node *parent;
- bool sort = false;
-
- assert(link != NULL);
- assert(node != NULL);
-
- if ((link->folder == 0) || (before)) {
- parent = node->parent = link->parent;
- if (parent->sort) {
- sort = true;
- } else {
- if (before) {
- node->next = link;
- node->previous = link->previous;
- if (link->previous != NULL)
- link->previous->next = node;
- link->previous = node;
- if ((parent != NULL) && (parent->child == link))
- parent->child = node;
- } else {
- node->previous = link;
- node->next = link->next;
- if (link->next != NULL)
- link->next->previous = node;
- link->next = node;
- if ((parent != NULL) &&
- (parent->last_child == link))
- parent->last_child = node;
- }
- }
- } else {
- parent = node->parent = link;
- if (parent->sort != NULL) {
- sort = true;
- } else {
- node->next = NULL;
- if (link->child == NULL) {
- link->child = link->last_child = node;
- node->previous = NULL;
- } else {
- link->last_child->next = node;
- node->previous = link->last_child;
- link->last_child = node;
- }
- }
-
- }
-
- if (sort) {
- tree_sort_insert(parent, node);
- }
-
- tree_handle_node_changed(tree, link, false, true);
-
- node->deleted = false;
+ treeview_test_mouse_action(tree, BROWSER_MOUSE_HOVER, x1, y1);
}
-
-/**
- * Recalculate the node element and redraw the relevant section of the tree.
- * The tree size is not updated.
- *
- * \param tree the tree to redraw, may be NULL
- * \param element the node element to update
- */
-static void tree_handle_node_element_changed(struct tree *tree,
- struct node_element *element, bool text_changed)
+/** deprecated compatibility layer for new treeview modules. Do not use. */
+bool tree_keypress(struct tree *tree, uint32_t key)
{
- int width, height;
-
- assert(element != NULL);
-
- width = element->box.width;
- height = element->box.height;
-
- if(text_changed == true) {
- #ifdef TREE_NOISY_DEBUG
- if(element->text) LOG(("%s", element->text));
- #endif
- tree_recalculate_node_element(tree, element);
+ if (treeview_test_keypress(tree, key)) {
+ return true;
}
- if (element->box.height != height) {
- tree_recalculate_node_sizes(tree, element->parent, false);
- if ((tree != NULL) && (tree->redraw)) {
- tree->callbacks->redraw_request(0, element->box.y,
- tree->width + element->box.width -
- width,
- tree->height - element->box.y +
- element->box.height - height,
- tree->client_data);
- }
- } else {
- if (element->box.width != width) {
- tree_recalculate_node_sizes(tree, element->parent,
- false);
- }
-
- if (tree != NULL) {
- width = (width > element->box.width) ? width :
- element->box.width;
- if (tree->redraw) {
- tree->callbacks->redraw_request(element->box.x,
- element->box.y,
- width,
- element->box.height,
- tree->client_data);
- }
- }
- }
+ return false;
}
-
-/**
- * Stops editing a node_element
- *
- * \param tree The tree to stop editing for
- * \param keep_changes If true the changes made to the text will be kept,
- * if false they will be dropped
- */
-static void tree_stop_edit(struct tree *tree, bool keep_changes)
+/** deprecated compatibility layer for new treeview modules. Do not use. */
+tree_drag_type tree_drag_status(struct tree *tree)
{
- int text_len;
- char *text = NULL;
- struct node_element *element;
- struct node_msg_data msg_data;
- node_callback_resp response;
-
assert(tree != NULL);
-
- if (tree->editing == NULL || tree->textarea == NULL)
- return;
-
- element = tree->editing;
-
- if (keep_changes) {
- text_len = textarea_get_text(tree->textarea, NULL, 0);
- text = malloc(text_len * sizeof(char));
- if (text == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- textarea_destroy(tree->textarea);
- tree->textarea = NULL;
- return;
- }
- textarea_get_text(tree->textarea, text, text_len);
- }
-
-
- if (keep_changes && element->parent->user_callback != NULL) {
- msg_data.msg = NODE_ELEMENT_EDIT_FINISHING;
- msg_data.flag = element->flag;
- msg_data.node = element->parent;
- msg_data.data.text = text;
- response = element->parent->user_callback(
- element->parent->callback_data,
- &msg_data);
-
- switch (response) {
- case NODE_CALLBACK_REJECT:
- free(text);
- text = NULL;
- break;
- case NODE_CALLBACK_CONTINUE:
- free(text);
- text = NULL;
- return;
- case NODE_CALLBACK_HANDLED:
- case NODE_CALLBACK_NOT_HANDLED:
- text = msg_data.data.text;
- break;
- }
- }
-
- textarea_destroy(tree->textarea);
- tree->textarea = NULL;
- tree->editing = NULL;
-
- if (text != NULL)
- tree_update_node_element(tree, element, text, NULL);
- else
- tree_handle_node_element_changed(tree, element, true);
-
-
- tree_recalculate_size(tree);
- if (element->parent->user_callback != NULL) {
- msg_data.msg = keep_changes ? NODE_ELEMENT_EDIT_FINISHED :
- NODE_ELEMENT_EDIT_CANCELLED;
- msg_data.flag = element->flag;
- msg_data.node = element->parent;
- element->parent->user_callback(element->parent->callback_data,
- &msg_data);
- }
-}
-
-
-/**
- * Delinks a node from the tree structures.
- *
- * \param tree the tree in which the delink takes place, may be NULL
- * \param node the node to delink
- */
-void tree_delink_node(struct tree *tree, struct node *node)
-{
- struct node *parent;
-
- assert(node != NULL);
-
- /* do not remove the root */
- if (tree != NULL && node == tree->root)
- return;
- if ((tree != NULL) && (tree->editing != NULL)) {
- parent = tree->editing->parent;
- while (parent != NULL) {
- if (node == parent) {
- tree_stop_edit(tree, false);
- break;
- }
- parent = parent->parent;
- }
- }
-
- if (node->parent->child == node)
- node->parent->child = node->next;
- if (node->parent->last_child == node)
- node->parent->last_child = node->previous;
- parent = node->parent;
- node->parent = NULL;
-
- if (node->previous != NULL)
- node->previous->next = node->next;
- if (node->next != NULL)
- node->next->previous = node->previous;
- node->previous = NULL;
- node->next = NULL;
-
- tree_handle_node_changed(tree, parent, false, true);
-}
-
-
-/**
- * Deletes a node from the tree.
- *
- * \param tree the tree to delete from, may be NULL
- * \param node the node to delete
- * \param siblings whether to delete all siblings
- */
-static void tree_delete_node_internal(struct tree *tree, struct node *node,
- bool siblings)
-{
- struct node *next, *child, *parent;
- struct node_element *e, *f;
- node_callback_resp response;
- struct node_msg_data msg_data;
-
- assert(node != NULL);
-
- if (tree != NULL && tree->root == node)
- return;
-
- next = node->next;
- parent = node->parent;
- if (tree != NULL && parent == tree->root)
- parent = NULL;
- if ((tree != NULL) && (tree->def_folder == node))
- tree->def_folder = NULL;
- tree_delink_node(tree, node);
- child = node->child;
- node->child = NULL;
-
- node->deleted = true;
- if (child != NULL)
- tree_delete_node_internal(tree, child, true);
-
- if (!node->retain_in_memory) {
- node->retain_in_memory = true;
- for (e = &node->data; e != NULL; e = f) {
- if (e->text != NULL) {
- response = NODE_CALLBACK_NOT_HANDLED;
- if (!e->editable &&
- node->user_callback != NULL) {
- msg_data.msg = NODE_DELETE_ELEMENT_TXT;
- msg_data.flag = e->flag;
- msg_data.node = node;
- msg_data.data.text = (void *)e->text;
- response = node->user_callback(
- node->callback_data,
- &msg_data);
- }
- if (response != NODE_CALLBACK_HANDLED)
- free((void *)e->text);
- e->text = NULL;
- }
- if (e->bitmap != NULL) {
- response = NODE_CALLBACK_NOT_HANDLED;
- if (node->user_callback != NULL) {
- msg_data.msg = NODE_DELETE_ELEMENT_IMG;
- msg_data.flag = e->flag;
- msg_data.node = node;
- msg_data.data.bitmap =
- (void *)e->bitmap;
- response = node->user_callback(
- node->callback_data,
- &msg_data);
- }
- /* TODO the type of this field is platform
- dependent */
- if (response != NODE_CALLBACK_HANDLED)
- free(e->bitmap);
- e->bitmap = NULL;
- }
- f = e->next;
- if (e != &node->data)
- free(e);
- }
- free(node);
- }
-
- if (siblings && next)
- tree_delete_node_internal(tree, next, true);
- if ((tree->flags & TREE_DELETE_EMPTY_DIRS) && parent != NULL &&
- parent->child == NULL && !parent->deleted)
- tree_delete_node_internal(tree, parent, false);
-}
-
-
-/**
- * Deletes all nodes of a tree and the tree itself.
- *
- * \param tree the tree to be deleted
- */
-void tree_delete(struct tree *tree)
-{
- tree->redraw = false;
-
- treeview_test_fini(tree);
-
- if (tree->root->child != NULL)
- tree_delete_node_internal(tree, tree->root->child, true);
-
- free((void *)tree->root->data.text);
- free(tree->root);
- free(tree);
-}
-
-
-/**
- * Gets the redraw property of the given tree.
- *
- * \param tree the tree for which to retrieve the property
- * \return the redraw property of the tree
- */
-bool tree_get_redraw(struct tree *tree)
-{
- return tree->redraw;
-}
-
-
-/**
- * Deletes a node from the tree.
- *
- * \param tree the tree to delete from, may be NULL
- * \param node the node to delete
- * \param siblings whether to delete all siblings
- */
-void tree_delete_node(struct tree *tree, struct node *node, bool siblings)
-{
- int y = node->box.y;
- int height = tree->height;
- int width = tree->width;
- bool redraw_setting = tree->redraw;
-
- tree->redraw = false;
-
- tree_delete_node_internal(tree, node, siblings);
- tree_recalculate_node_positions(tree, tree->root);
-
- tree->redraw = redraw_setting;
-
- if (tree->redraw)
- tree->callbacks->redraw_request(0, y,
- width, height, tree->client_data);
- tree_recalculate_size(tree);
-}
-
-
-/**
- * Sets an icon for a node
- *
- * \param tree The tree to which node belongs, may be NULL
- * \param node The node for which the icon is set
- * \param icon the image to use
- */
-void tree_set_node_icon(struct tree *tree, struct node *node,
- hlcache_handle *icon)
-{
- node->data.type = NODE_ELEMENT_TEXT_PLUS_ICON;
- tree_update_node_element(tree, &(node->data), NULL, icon);
-}
-
-
-/**
- * Updates all siblings and descendants of a node to an expansion state.
- * No update is performed for the tree changes.
- *
- * \param tree the tree to which 'node' belongs
- * \param node the node to set all siblings and descendants of
- * \param expanded the expansion state to set
- */
-static void tree_set_node_expanded_all(struct tree *tree, struct node *node,
- bool expanded)
-{
- for (; node != NULL; node = node->next) {
- if (node->expanded != expanded) {
- node->expanded = expanded;
- tree_recalculate_node_sizes(tree, node, false);
- }
- if ((node->child != NULL) && (node->expanded))
- tree_set_node_expanded_all(tree, node->child, expanded);
- }
-}
-
-
-/**
- * Updates [all siblings and descendants of] a node to an expansion state.
- *
- * \param tree the tree to update
- * \param node the node to set [all siblings and descendants of]
- * \param expanded the expansion state to set
- * \param folder whether to update folders, if this together with leaf
- * will be false only 'node' will be updated
- * \param leaf whether to update leaves (check also description for folder)
- * \return whether any changes were made
- */
-static bool tree_set_node_expanded_internal(struct tree *tree,
- struct node *node, bool expanded, bool folder, bool leaf)
-{
- bool redraw = false;
- struct node *end = (folder == false && leaf == false) ?
- node->next : NULL;
-
- if (tree->editing != NULL && node == tree->editing->parent)
- tree_stop_edit(tree, false);
-
- for (; node != end; node = node->next) {
- if ((node->expanded != expanded) && (node != tree->root) &&
- ((folder && (node->folder)) ||
- (leaf && (!node->folder)) ||
- (!folder && !leaf))) {
- node->expanded = expanded;
- if (node->child != NULL)
- tree_set_node_expanded_all(tree,
- node->child, false);
- if ((node->data.next != NULL) &&
- (node->data.next->box.height == 0))
- tree_recalculate_node_sizes(tree, node, true);
- else
- tree_recalculate_node_sizes(tree, node, false);
- redraw = true;
- }
- if ((folder || leaf) && (node->child != NULL) &&
- (node->expanded))
- redraw |= tree_set_node_expanded_internal(tree,
- node->child, expanded, folder, leaf);
- }
- return redraw;
-}
-
-
-/**
- * Updates [all siblings and descendants of] a node to an expansion state.
- *
- * \param tree the tree to update
- * \param node the node to set [all siblings and descendants of]
- * \param expanded the expansion state to set
- * \param folder whether to update folders, if this together with leaf
- * will be false only 'node' will be updated
- * \param leaf whether to update leaves (check also description for folder)
- */
-void tree_set_node_expanded(struct tree *tree, struct node *node, bool expanded,
- bool folder, bool leaf)
-{
- if (tree_set_node_expanded_internal(tree, node, expanded, folder, leaf))
- tree_handle_node_changed(tree, node, false, true);
-}
-
-
-/**
- * Updates a node to an selected state. The required areas of the tree are
- * redrawn.
- *
- * \param tree the tree to update nodes for, may be NULL
- * \param node the node to set all siblings and descendants of
- * \param all if true update node together with its siblings and
- * descendants
- * \param selected the selection state to set
- */
-void tree_set_node_selected(struct tree *tree, struct node *node, bool all,
- bool selected)
-{
- struct node *end;
-
- if (tree != NULL && node == tree->root)
- node = tree->root->child;
- if (node == NULL)
- return;
-
- end = all ? NULL : node->next;
-
- for (; node != end; node = node->next) {
- if (node->selected != selected) {
- node->selected = selected;
- if (tree != NULL && tree->redraw)
- tree->callbacks->redraw_request(
- node->data.box.x,
- node->data.box.y,
- node->data.box.width,
- node->data.box.height,
- tree->client_data);
- }
- if (all && (node->child != NULL) && (node->expanded))
- tree_set_node_selected(tree, node->child, all,
- selected);
- }
-}
-
-
-/**
- * Sets the sort function for a node
- *
- * \param tree the tree to which 'node' belongs, may be NULL
- * \param node the node to be inserted
- * \param sort pointer to the sorting function
- */
-void tree_set_node_sort_function(struct tree *tree, struct node *node,
- int (*sort) (struct node *, struct node *))
-{
- struct node *child;
-
- node->sort = sort;
-
- if (tree != NULL && tree->editing != NULL)
- tree_stop_edit(tree, false);
-
- /* the node had already some children so they must get sorted */
- if (node->child != NULL) {
-
- child = node->child;
- node->child = NULL;
-
- while (child != NULL) {
- tree_sort_insert(node, child);
- child = child->next;
- }
-
- }
-
- if (tree != NULL)
- tree_recalculate_node_positions(tree, node->child);
-}
-
-
-/**
- * Sets the delete callback for a node.
- *
- * \param node the node for which the callback is set
- * \param callback the callback functions to be set
- * \param data user data to be passed to callback
- */
-void tree_set_node_user_callback(struct node *node,
- tree_node_user_callback callback, void *data)
-{
- node->user_callback = callback;
- node->callback_data = data;
-}
-
-
-/**
- * Sets the redraw property to the given value. If redraw is true, the tree will
- * be redrawn on layout/appearance changes.
- *
- * \param tree the tree for which the property is set
- * \param redraw the value to set
- */
-void tree_set_redraw(struct tree *tree, bool redraw)
-{
- /* the tree might have no graphical representation, do not set the
- redraw flag in such case */
- if (tree->callbacks == NULL)
- return;
- tree->redraw = redraw;
-}
-
-
-/**
- * Checks whether a node, its siblings or any children are selected.
- *
- * \param node the root node to check from
- * \return whether 'node', its siblings or any children are selected.
- */
-bool tree_node_has_selection(struct node *node)
-{
- for (; node != NULL; node = node->next) {
- if (node->selected)
- return true;
- if ((node->child != NULL) && (node->expanded) &&
- (tree_node_has_selection(node->child)))
- return true;
- }
- return false;
-}
-
-
-/**
- * Returns the current value of the nodes deleted property.
- *
- * \param node the node to be checked
- * \return the current value of the nodes deleted property
- */
-bool tree_node_is_deleted(struct node *node)
-{
- return node->deleted;
-}
-
-
-/**
- * Returns true if the node is a folder
- *
- * \param node the node to be checked
- * \return true if the node is a folder, false otherwise
- */
-bool tree_node_is_folder(struct node *node)
-{
- return node->folder;
-}
-
-
-/**
- * Returns true if the node is the default folder for a tree
- *
- * \param node the node to be checked
- * \return true if the node is a default folder, false otherwise
- */
-bool tree_node_is_default(struct node *node)
-{
- return node->def_folder;
-}
-
-
-/**
- * Update the text of a node element if it has changed.
- *
- * \param element The node element to update.
- * \param text The text to update the element with. The ownership of
- * this string is taken by this function and must not be
- * referred to after the function exits.
- */
-bool tree_update_element_text(struct tree *tree,
- struct node_element *element, char *text)
-{
- const char *node_text; /* existing node text */
-
- if (text == NULL)
- return false;
-
- if (element == NULL) {
- free(text);
- return false;
- }
-
- node_text = tree_node_element_get_text(element);
-
- if ((node_text == NULL) || (strcmp(node_text, text) != 0)) {
- tree_update_node_element(tree, element, text, NULL);
- } else {
- /* text does not need changing, free it */
- free(text);
- }
- return true;
-}
-
-
-/**
- * Updates the content of a node_element.
- *
- * \param tree the tree owning element, may be NULL
- * \param element the element to be updated
- * \param text new text to be set, may be NULL
- * \param bitmap new bitmap to be set, may be NULL
- */
-void tree_update_node_element(struct tree *tree, struct node_element *element,
- const char *text, void *bitmap)
-{
- node_callback_resp response;
- struct node_msg_data msg_data;
- bool text_changed = false;
-
- assert(element != NULL);
-
- if ((tree != NULL) && (element == tree->editing)) {
- tree_stop_edit(tree, false);
- }
-
- if ((text != NULL) &&
- (element->type == NODE_ELEMENT_TEXT ||
- element->type == NODE_ELEMENT_TEXT_PLUS_ICON)) {
- if (element->text != NULL) {
- if (strcmp(element->text, text) == 0) {
- text_changed = true;
- }
- response = NODE_CALLBACK_NOT_HANDLED;
- if ((!element->editable) &&
- (element->parent->user_callback != NULL)) {
- msg_data.msg = NODE_DELETE_ELEMENT_TXT;
- msg_data.flag = element->flag;
- msg_data.node = element->parent;
- msg_data.data.text = (void *)element->text;
- response = element->parent->user_callback(
- element->parent->callback_data,
- &msg_data);
- }
- if (response != NODE_CALLBACK_HANDLED) {
- free(element->text);
- }
- }
- element->text = (char *)text;
- }
-
- if ((bitmap != NULL) &&
- ((element->type == NODE_ELEMENT_BITMAP) ||
- (element->type == NODE_ELEMENT_TEXT_PLUS_ICON))) {
- if (element->bitmap != NULL) {
- response = NODE_CALLBACK_NOT_HANDLED;
- if (element->parent->user_callback != NULL) {
- msg_data.msg = NODE_DELETE_ELEMENT_IMG;
- msg_data.flag = element->flag;
- msg_data.node = element->parent;
- msg_data.data.bitmap = (void *)element->bitmap;
- response = element->parent->user_callback(
- element->parent->callback_data,
- &msg_data);
- }
-
- if (response != NODE_CALLBACK_HANDLED) {
- free(element->bitmap);
- }
- } else {
- /* Increase the box width to accomodate the new icon */
- element->box.width += NODE_INSTEP;
- }
-
- element->bitmap = bitmap;
- }
-
- tree_handle_node_element_changed(tree, element, text_changed);
-}
-
-
-/**
- * Returns the node element's text
- *
- * \return the node element's text
- */
-const char *tree_node_element_get_text(struct node_element *element)
-{
- return element->text;
-}
-
-
-/**
- * Returns the node element's icon
- *
- * \return the node element's icon
- */
-struct bitmap *tree_node_element_get_icon(struct node_element *element)
-{
- return element->bitmap;
-}
-
-
-/**
- * Get the root node of a tree
- *
- * \param tree the tree to get the root of
- * \return the root of the tree
- */
-struct node *tree_get_root(struct tree *tree)
-{
- return tree->root;
-}
-
-
-/**
- * Returns whether the current tree is being edited at this time
- *
- * \param tree the tree to be checked
- * \return true if the tree is currently being edited
- */
-bool tree_is_edited(struct tree *tree)
-{
- return tree->editing == NULL ? false : true;
-}
-
-
-/**
- * Get the drag state of a tree
- *
- * \param tree the tree to get the state of
- * \return drag type (defined in desktop/tree.h)
- */
-tree_drag_type tree_drag_status(struct tree *tree)
-{
return tree->drag;
}
-
-
-/**
- * Get the default node of a tree for additions
- *
- * \param tree the tree to get the default node of
- * \return the default node
- */
-struct node *tree_get_default_folder_node(struct tree *tree)
-{
- if (tree->def_folder != NULL) {
- return tree->def_folder;
- } else {
- return tree_get_root(tree);
- }
-}
-
-
-/**
- * Set the default node of a tree to the selected node
- *
- * \param tree the tree to set the default node of
- * \param node the node to set as default (NULL for selected node)
- * \return success
- */
-bool tree_set_default_folder_node(struct tree *tree, struct node *node)
-{
- struct node *sel_node;
-
- if (node == NULL) {
- sel_node = tree_get_selected_node(tree->root);
- } else {
- sel_node = node;
- }
-
- if((sel_node == NULL) ||
- (tree_node_is_folder(sel_node) == false)) {
- return false;
- }
-
- tree_clear_default_folder_node(tree);
-
- tree->def_folder = sel_node;
- sel_node->def_folder = true;
- tree_handle_node_changed(tree, sel_node, true, false);
-
- return true;
-}
-
-
-/**
- * Clear the default node of a tree
- *
- * \param tree the tree to clear the default node of
- */
-void tree_clear_default_folder_node(struct tree *tree)
-{
- struct node *def_node = NULL;
- def_node = tree_get_default_folder_node(tree);
-
- if (def_node != NULL) {
- tree->def_folder = NULL;
- def_node->def_folder = false;
- tree_handle_node_changed(tree, def_node, true, false);
- }
-}
-
-
-/**
- * Returns the parent of a node
- *
- * \param node the node to get the parent of
- * \return the node's parent
- */
-struct node *tree_node_get_parent(struct node *node)
-{
- return node->parent;
-}
-
-
-/**
- * Returns the first child of a node
- *
- * \param node the node to get the child of
- * \return the nodes first child
- */
-struct node *tree_node_get_child(struct node *node)
-{
- return node->child;
-}
-
-
-/**
- * Returns the closest sibling a node
- *
- * \param node the node to get the sibling of
- * \return the nodes sibling
- */
-struct node *tree_node_get_next(struct node *node)
-{
- return node->next;
-}
-
-
-/**
- * Draws an element's expansion icon
- *
- * \param tree the tree to draw the expansion for
- * \param element the element to draw the expansion for
- * \param tree_x X coordinate of the tree
- * \param tree_y Y coordinate of the tree
- * \param ctx current redraw context
- */
-static void tree_draw_node_expansion_toggle(struct tree *tree,
- struct node *node, int tree_x, int tree_y,
- const struct redraw_context *ctx)
-{
- const struct plotter_table *plot = ctx->plot;
- int x, y;
-
- assert(tree != NULL);
- assert(node != NULL);
-
- if ((node->child != NULL) || (node->data.next != NULL)) {
- x = tree_x + node->box.x - (NODE_INSTEP / 2) - 4;
- y = tree_y + node->box.y + (TREE_LINE_HEIGHT - 9) / 2;
- plot->rectangle(x, y, x + 9, y + 9,
- &plot_style_fill_tree_furniture);
- plot->rectangle(x , y, x + 8, y + 8,
- &plot_style_stroke_tree_furniture);
- plot->line(x + 2, y + 4, x + 7, y + 4,
- &plot_style_stroke_tree_furniture);
- if (!node->expanded)
- plot->line(x + 4, y + 2, x + 4, y + 7,
- &plot_style_stroke_tree_furniture);
-
- }
-
-}
-
-
-/**
- * Draws an element, including any expansion icons
- *
- * \param tree the tree to draw an element for
- * \param element the element to draw
- * \param tree_x X coordinate to draw the tree at (wrt plot origin)
- * \param tree_y Y coordinate to draw the tree at (wrt plot origin)
- * \param clip clipping rectangle (wrt plot origin)
- * \param ctx current redraw context
- */
-static void tree_draw_node_element(struct tree *tree,
- struct node_element *element, int tree_x, int tree_y,
- const struct rect *clip, const struct redraw_context *ctx)
-{
- const struct plotter_table *plot = ctx->plot;
- struct bitmap *bitmap = NULL;
- int x, y, width;
- bool selected = false;
- bool def_folder = false;
- hlcache_handle *icon;
- plot_font_style_t *fstyle;
- const int icon_inset = (TREE_LINE_HEIGHT - TREE_ICON_SIZE) / 2;
-
- assert(tree != NULL);
- assert(element != NULL);
- assert(element->parent != NULL);
-
- x = tree_x + element->box.x;
- y = tree_y + element->box.y;
- width = element->box.width;
- if (&element->parent->data == element) {
- if (element->parent->selected)
- selected = true;
- if (element->parent->def_folder)
- def_folder = true;
- }
-
- switch (element->type) {
- case NODE_ELEMENT_TEXT_PLUS_ICON:
- icon = element->bitmap;
- if (icon != NULL && (content_get_status(icon) ==
- CONTENT_STATUS_READY ||
- content_get_status(icon) ==
- CONTENT_STATUS_DONE) &&
- x + TREE_ICON_SIZE > clip->x0 &&
- x < clip->x1) {
- struct rect c;
- /* Clip to image area */
- c.x0 = x;
- c.y0 = y + icon_inset;
- c.x1 = x + TREE_ICON_SIZE;
- c.y1 = y + icon_inset + TREE_ICON_SIZE;
- if (c.x0 < clip->x0) c.x0 = clip->x0;
- if (c.y0 < clip->y0) c.y0 = clip->y0;
- if (c.x1 > clip->x1) c.x1 = clip->x1;
- if (c.y1 > clip->y1) c.y1 = clip->y1;
-
- if (c.x1 > c.x0 && c.y1 > c.y0) {
- /* Valid clip rectangles only */
- struct content_redraw_data data;
-
- plot->clip(&c);
-
- data.x = x;
- data.y = y + icon_inset;
- data.width = TREE_ICON_SIZE;
- data.height = TREE_ICON_SIZE;
-
- data.background_colour = 0xFFFFFF;
- data.scale = 1;
- data.repeat_x = false;
- data.repeat_y = false;
-
- content_redraw(icon, &data, &c, ctx);
-
- /* Restore previous clipping area */
- plot->clip(clip);
- }
- }
-
- x += NODE_INSTEP;
- width -= NODE_INSTEP;
-
- /* fall through */
- case NODE_ELEMENT_TEXT:
- if (element->text == NULL || clip->x1 < x)
- break;
-
- if (element == tree->editing)
- return;
-
- if (selected) {
- if (def_folder == true)
- fstyle = &plot_fstyle_selected_def_folder;
- else
- fstyle = &plot_fstyle_selected;
-
- plot->rectangle(x, y, x + width,
- y + element->box.height,
- &plot_style_fill_tree_selected);
- } else {
- if (def_folder == true)
- fstyle = &plot_fstyle_def_folder;
- else
- fstyle = &plot_fstyle;
- }
-
- plot->text(x + 4, y + (TREE_LINE_HEIGHT * 3 + 2) / 4,
- element->text, strlen(element->text),
- fstyle);
- break;
- case NODE_ELEMENT_BITMAP:
- bitmap = element->bitmap;
- if (bitmap == NULL)
- break;
- plot->bitmap(x, y, element->box.width - 1,
- element->box.height - 2,
- bitmap, 0xFFFFFF, BITMAPF_NONE);
- if (!(tree->flags & TREE_NO_FURNITURE))
- plot->rectangle(x, y, x + element->box.width - 1,
- y + element->box.height - 3,
- &plot_style_stroke_tree_furniture);
-
- break;
- }
-
-}
-
-
-/**
- * Redraws a node.
- *
- * \param tree the tree to draw
- * \param node the node to draw children and siblings of
- * \param tree_x X coordinate to draw the tree at (wrt plot origin)
- * \param tree_y Y coordinate to draw the tree at (wrt plot origin)
- * \param clip clipping rectangle (wrt plot origin)
- * \param ctx current redraw context
- */
-static void tree_draw_node(struct tree *tree, struct node *node,
- int tree_x, int tree_y, struct rect clip,
- const struct redraw_context *ctx)
-{
- const struct plotter_table *plot = ctx->plot;
- struct node_element *element;
- struct node *parent;
- int x0, y0, x1, y1;
- struct rect node_extents;
-
- assert(tree != NULL);
- assert(node != NULL);
-
- /* Find node's extents, including children's area */
- node_extents.x0 = tree_x + node->box.x - NODE_INSTEP;
- node_extents.y0 = tree_y + node->box.y;
- node_extents.x1 = tree_x + node->box.x + node->box.width + NODE_INSTEP;
- if (node->next != NULL)
- node_extents.y1 = tree_y + node->next->box.y;
- else
- node_extents.y1 = tree_y + node->box.y + node->box.height;
-
- /* Nothing to draw, if node is outside clip region */
- if ((node_extents.x1 < clip.x0) && (node_extents.y1 < clip.y0) &&
- (node_extents.x0 > clip.x1) &&
- (node_extents.y0 > clip.y1)) {
- return;
- }
-
- /* Intersect clip region with node's extents */
- if (clip.x0 < node_extents.x0) clip.x0 = node_extents.x0;
- if (clip.y0 < node_extents.y0) clip.y0 = node_extents.y0;
- if (clip.x1 > node_extents.x1) clip.x1 = node_extents.x1;
- if (clip.y1 > node_extents.y1) clip.y1 = node_extents.y1;
-
- if (clip.x0 >= clip.x1 || clip.y0 >= clip.y1) {
- /* Invalid clip rectangle */
- return;
- }
-
- /* Set up the clipping area */
- plot->clip(&clip);
-
- /* Draw node's furniture */
- if (!(tree->flags & TREE_NO_FURNITURE)) {
- /* Display furniture */
- if (node->previous != NULL) {
- /* There is a node above this
- * Display furniture; line connecting up to previous */
- x0 = x1 = tree_x + node->box.x - (NODE_INSTEP / 2);
- y0 = tree_y + node->previous->box.y;
- y1 = tree_y + node->box.y + (TREE_LINE_HEIGHT / 2);
- plot->line(x0, y0, x1, y1,
- &plot_style_stroke_tree_furniture);
- }
- if (node->next != NULL) {
- /* There is a node below this
- * Display furniture; line connecting down to next */
- x0 = x1 = tree_x + node->box.x - (NODE_INSTEP / 2);
- y0 = tree_y + node->box.y + (TREE_LINE_HEIGHT / 2);
- y1 = tree_y + node->next->box.y;
- plot->line(x0, y0, x1, y1,
- &plot_style_stroke_tree_furniture);
- }
-
- parent = node->parent;
- if ((parent != NULL) && (parent != tree->root) &&
- (parent->child == node)) {
- /* Node is first child */
- x0 = x1 = tree_x + parent->box.x + (NODE_INSTEP / 2);
- y0 = tree_y + parent->data.box.y +
- parent->data.box.height;
- y1 = y0 + (TREE_LINE_HEIGHT / 2);
- plot->line(x0, y0, x1, y1,
- &plot_style_stroke_tree_furniture);
- }
- /* Line from expansion toggle to icon */
- x0 = tree_x + node->box.x - (NODE_INSTEP / 2);
- x1 = x0 + (NODE_INSTEP / 2) - 2;
- y0 = y1 = tree_y + node->data.box.y + node->data.box.height -
- (TREE_LINE_HEIGHT / 2);
- plot->line(x0, y0, x1, y1, &plot_style_stroke_tree_furniture);
-
- tree_draw_node_expansion_toggle(tree, node,
- tree_x, tree_y, ctx);
- }
-
- /* Draw node's element(s)
- * NOTE: node's children are handled later in tree_draw_tree() */
- if (node->expanded) {
- for (element = &node->data; element != NULL;
- element = element->next) {
- /* Draw each element of expanded node */
- tree_draw_node_element(tree, element, tree_x, tree_y,
- &clip, ctx);
- }
- } else {
- /* Draw main title element of node */
- tree_draw_node_element(tree, &node->data, tree_x, tree_y,
- &clip, ctx);
- }
-}
-
-
-/**
- * Redraws a node's descendants.
- *
- * \param tree the tree to draw
- * \param node the node to draw children and siblings of
- * \param tree_x X coordinate to draw the tree at (wrt plot origin)
- * \param tree_y Y coordinate to draw the tree at (wrt plot origin)
- * \param clip clipping rectangle (wrt plot origin)
- * \param ctx current redraw context
- */
-static void tree_draw_tree(struct tree *tree, struct node *node,
- int tree_x, int tree_y, struct rect clip,
- const struct redraw_context *ctx)
-{
- struct node *child;
-
- assert(tree != NULL);
- assert(node != NULL);
-
- for (child = node->child; child != NULL; child = child->next) {
- /* Draw children that are inside the clip region */
-
- if (child->next != NULL &&
- (child->next->box.y + tree_y < clip.y0))
- /* Child is above clip region */
- continue;
- if (child->box.y + tree_y > clip.y1)
- /* Child is below clip region
- * further siblings will be too */
- return;
-
- /* Draw current child */
- tree_draw_node(tree, child, tree_x, tree_y, clip, ctx);
- /* And its children */
- if ((child->child != NULL) && (child->expanded)) {
- /* Child has children and they are visible */
- tree_draw_tree(tree, child, tree_x, tree_y, clip, ctx);
- }
- }
-}
-
-
-/**
- * Redraws a tree.
- *
- * \param tree the tree to draw
- * \param x X coordinate to draw the tree at (wrt plot origin)
- * \param y Y coordinate to draw the tree at (wrt plot origin)
- * \param clip_x minimum x of the clipping rectangle (wrt tree origin)
- * \param clip_y minimum y of the clipping rectangle (wrt tree origin)
- * \param clip_width width of the clipping rectangle
- * \param clip_height height of the clipping rectangle
- * \param ctx current redraw context
- */
-void tree_draw(struct tree *tree, int x, int y,
- int clip_x, int clip_y, int clip_width, int clip_height,
- const struct redraw_context *ctx)
-{
- struct redraw_context new_ctx = *ctx;
- struct rect clip;
-
- assert(tree != NULL);
- assert(tree->root != NULL);
-
- if (treeview_test_redraw(tree, x, y, clip_x, clip_y,
- clip_width, clip_height, ctx)) {
- return;
- }
-
- /* Start knockout rendering if it's available for this plotter */
- if (ctx->plot->option_knockout)
- knockout_plot_start(ctx, &new_ctx);
-
- /* Set up clip rectangle */
- clip.x0 = x + clip_x;
- clip.y0 = y + clip_y;
- clip.x1 = clip.x0 + clip_width;
- clip.y1 = clip.y0 + clip_height;
- new_ctx.plot->clip(&clip);
-
- /* Flat fill extents of clipping area */
- new_ctx.plot->rectangle(clip.x0, clip.y0, clip.x1, clip.y1,
- &plot_style_fill_tree_background);
-
- /* don't draw empty trees or trees with redraw flag set to false */
- if (tree->root->child != NULL && tree->redraw) {
-
- /* Draw the tree */
- tree_draw_tree(tree, tree->root, x, y, clip, &new_ctx);
-
- /* Draw textarea, if present */
- if (tree->editing != NULL) {
- x = x + tree->editing->box.x;
- y = y + tree->editing->box.y;
- if (tree->editing->type == NODE_ELEMENT_TEXT_PLUS_ICON)
- x += NODE_INSTEP;
- textarea_redraw(tree->textarea, x, y,
- plot_style_fill_tree_background.
- fill_colour,
- 1.0, &clip, &new_ctx);
- }
- }
-
- /* Rendering complete */
- if (ctx->plot->option_knockout)
- knockout_plot_end();
-}
-
-
-/**
- * Finds a node element from a node with a specific user_type
- *
- * \param node the node to examine
- * \param flag user assinged flag used is searches
- * \param after if this is not NULL the search will start after the given
- * node_element
- * \return the corresponding element
- */
-struct node_element *tree_node_find_element(struct node *node,
- unsigned int flag, struct node_element *after)
-{
- struct node_element *element;
-
- if (after == NULL)
- element = &node->data;
- else {
- assert(after->parent == node);
- element = after->next;
- }
-
- for (; element != NULL; element = element->next)
- if (element->flag == flag) return element;
-
- return NULL;
-}
-
-
-/**
- * Deletes all selected nodes from the tree.
- *
- * \param tree the tree to delete from
- * \param node the node to delete
- */
-void tree_delete_selected_nodes(struct tree *tree, struct node *node)
-{
- struct node *next;
- int y = node->box.y;
- int height = tree->height;
- int width = tree->width;
- bool redraw_setting = tree->redraw;
-
- tree->redraw = false;
-
- if (node == tree->root) {
- if (node->child != NULL)
- tree_delete_selected_nodes(tree, node->child);
-
- tree->redraw = redraw_setting;
-
- if (tree->redraw)
- tree->callbacks->redraw_request(0, y,
- width, height,
- tree->client_data);
- return;
- }
-
- while (node != NULL) {
- next = node->next;
- if (node->selected)
- tree_delete_node(tree, node, false);
- else if (node->child != NULL)
- tree_delete_selected_nodes(tree, node->child);
- node = next;
- }
-
- tree->redraw = redraw_setting;
-
- if (tree->redraw)
- tree->callbacks->redraw_request(0, y,
- width, height,
- tree->client_data);
-}
-
-
-/**
- * Returns the selected node, or NULL if multiple nodes are selected.
- *
- * \param node the node to search sibling and children
- * \return the selected node, or NULL if multiple nodes are selected
- */
-struct node *tree_get_selected_node(struct node *node)
-{
- struct node *result = NULL;
- struct node *temp;
-
- for (; node != NULL; node = node->next) {
- if (node->selected) {
- if (result != NULL)
- return NULL;
- result = node;
- }
- if ((node->child != NULL) && (node->expanded)) {
- temp = tree_get_selected_node(node->child);
- if (temp != NULL) {
- if (result != NULL)
- return NULL;
- else
- result = temp;
- }
- }
- }
- return result;
-}
-
-
-/**
- * Finds a node element at a specific location.
- *
- * \param node the root node to check from
- * \param x the x co-ordinate
- * \param y the y co-ordinate
- * \param expansion_toggle whether the coordinate was in an expansion toggle
- * \return the node at the specified position, or NULL for none
- */
-static struct node_element *tree_get_node_element_at(struct node *node,
- int x, int y, bool *expansion_toggle)
-{
- struct node_element *element;
- int x0, x1, y0, y1;
-
- *expansion_toggle = false;
- for (; node != NULL; node = node->next) {
- if (node->box.y > y) return NULL;
- if ((node->box.x - NODE_INSTEP < x) && (node->box.y < y) &&
- (node->box.x + node->box.width >= x) &&
- (node->box.y + node->box.height >= y)) {
- if (node->expanded) {
- for (element = &node->data; element != NULL;
- element = element->next) {
- x0 = element->box.x;
- y0 = element->box.y;
- x1 = element->box.x +
- element->box.width;
- y1 = element->box.y +
- element->box.height;
- if ((x0 < x) && (y0 < y) && (x1 >= x)
- && (y1 >= y))
- return element;
- }
- } else {
- x0 = node->data.box.x;
- y0 = node->data.box.y;
- x1 = node->data.box.x + node->data.box.width;
- y1 = node->data.box.y + node->data.box.height;
- if ((x0 < x) && (y0 < y) && (x1 >= x) &&
- (y1>= y))
- return &node->data;
- }
- if (((node->child != NULL) ||
- (node->data.next != NULL)) &&
- (node->data.box.x - NODE_INSTEP + 4 < x)
- && (node->data.box.y + 4 < y) &&
- (node->data.box.x > x) &&
- (node->data.box.y + TREE_LINE_HEIGHT > y)) {
- /* Node either has node children, or node
- * has more than one element.
- * Coordinate is over node expansion toggle area
- */
- *expansion_toggle = true;
- return &node->data;
- }
- }
-
- element = tree_get_node_element_at(node->child, x, y,
- expansion_toggle);
- if ((node->child != NULL) && (node->expanded) &&
- (element != NULL))
- return element;
- }
- return NULL;
-}
-
-
-/**
- * Finds a node at a specific location.
- *
- * \param root the root node to check from
- * \param x the x co-ordinate
- * \param y the y co-ordinate
- * \param expansion_toggle whether the coordinate was in an expansion toggle
- * \return the node at the specified position, or NULL for none
- */
-static struct node *tree_get_node_at(struct node *root, int x, int y,
- bool *expansion_toggle)
-{
- struct node_element *result;
-
- if ((result = tree_get_node_element_at(root, x, y, expansion_toggle)))
- return result->parent;
- return NULL;
-}
-
-
-/**
- * Gets link characteristics to insert a node at a specified position.
- *
- * \param tree the tree to find link information for
- * \param x the x co-ordinate
- * \param y the y co-ordinate
- * \param before set to whether the node should be linked before on exit
- * \return the node to link with
- */
-struct node *tree_get_link_details(struct tree *tree, int x, int y,
- bool *before)
-{
- struct node *node = NULL;
- bool expansion_toggle;
-
- assert(tree != NULL);
- assert(tree->root != NULL);
-
- *before = false;
- if (tree->root->child != NULL)
- node = tree_get_node_at(tree->root->child, x, y,
- &expansion_toggle);
- if ((node == NULL) || (expansion_toggle))
- return tree->root;
-
- if (y < (node->box.y + (node->box.height / 2))) {
- *before = true;
- } else if ((node->folder) && (node->expanded) &&
- (node->child != NULL)) {
- node = node->child;
- *before = true;
- }
- return node;
-}
-
-
-/**
- * Launches all the selected nodes of the tree
- *
- * \param tree the tree for which all nodes will be launched
- * \param node the node which will be checked together with its children
- * \param tabs launch node in a new tab instead of a new window
- */
-static void tree_launch_selected_internal(struct tree *tree, struct node *node,
- bool tabs)
-{
- struct node_msg_data msg_data;
-
- msg_data.data.bw = NULL;
-
- for (; node != NULL; node = node->next) {
- if (node->selected && node->user_callback != NULL) {
- msg_data.msg = NODE_LAUNCH;
- if (tabs == true) {
- msg_data.flag = TREE_ELEMENT_LAUNCH_IN_TABS;
- } else {
- msg_data.flag = TREE_ELEMENT_TITLE;
- }
-
- msg_data.node = node;
- node->user_callback(node->callback_data, &msg_data);
- }
- if (node->child != NULL)
- tree_launch_selected_internal(tree, node->child, tabs);
- }
-}
-
-
-/**
- * Launches all the selected nodes of the tree
- *
- * \param tree the tree for which all nodes will be launched
- * \param tabs launch nodes in new tabs instead of new windows
- */
-void tree_launch_selected(struct tree *tree, bool tabs)
-{
- if (tree->root->child != NULL)
- tree_launch_selected_internal(tree, tree->root->child, tabs);
-}
-
-
-/**
- * Updates the node at position x,y to a selected state.
- * The required areas of the tree are redrawn.
- *
- * \param tree the tree to update nodes for, may be NULL
- * \param x x position in tree
- * \param y y position in tree
- * \param selected the selection state to set
- */
-void tree_set_node_selected_at(struct tree *tree, int x, int y, bool selected)
-{
- bool expansion_toggle;
- struct node *node;
-
- node = tree_get_node_at(tree->root, x, y, &expansion_toggle);
-
- if ((node == NULL) || (expansion_toggle == true))
- return;
-
- tree_set_node_selected(tree, node, false, selected);
-}
-
-
-/**
- * Handles a mouse action for a tree
- *
- * \param tree the tree to handle a click for
- * \param mouse the mouse state
- * \param x X coordinate of mouse action
- * \param y Y coordinate of mouse action
- * \return whether the click was handled
- */
-bool tree_mouse_action(struct tree *tree, browser_mouse_state mouse, int x,
- int y)
-{
- bool expansion_toggle;
- struct node *node;
- struct node *last;
- struct node_element *element;
- struct node_msg_data msg_data;
-
- bool double_click_1 = mouse & BROWSER_MOUSE_DOUBLE_CLICK &&
- mouse & BROWSER_MOUSE_CLICK_1;
- bool double_click_2 = mouse & BROWSER_MOUSE_DOUBLE_CLICK &&
- mouse & BROWSER_MOUSE_CLICK_2;
-
- assert(tree != NULL);
- assert(tree->root != NULL);
-
- if (treeview_test_mouse_action(tree, mouse, x, y)) {
- return true;
- }
-
- if (tree->root->child == NULL)
- return true;
-
- element = tree_get_node_element_at(tree->root->child, x, y,
- &expansion_toggle);
-
- /* pass in-textarea mouse action and drags which started in it
- to the textarea */
- if (tree->editing != NULL) {
- int x0, x1, y0, y1;
- x0 = tree->editing->box.x;
- if (tree->editing->type == NODE_ELEMENT_TEXT_PLUS_ICON)
- x0 += NODE_INSTEP;
- x1 = tree->editing->box.x + tree->editing->box.width;
- y0 = tree->editing->box.y;
- y1 = tree->editing->box.y + tree->ta_height;
-
- if (tree->drag == TREE_TEXTAREA_DRAG &&
- (mouse & (BROWSER_MOUSE_HOLDING_1 |
- BROWSER_MOUSE_HOLDING_2))) {
- /* Track the drag path */
- textarea_mouse_action(tree->textarea, mouse,
- x - x0, y - y0);
- return true;
- }
-
- if ((x >= x0) && (x < x1) && (y >= y0) && (y < y1)) {
- textarea_mouse_action(tree->textarea, mouse,
- x - x0, y - y0);
- return true;
-
- }
- }
-
- /* we are not interested in the drag path, return */
- if (mouse & (BROWSER_MOUSE_HOLDING_1 | BROWSER_MOUSE_HOLDING_2))
- return true;
-
- /* cancel edit */
- if (tree->editing != NULL)
- tree_stop_edit(tree, false);
-
- /* no item either means cancel selection on (select) click or a drag */
- if (element == NULL) {
- if (tree->flags & TREE_SINGLE_SELECT) {
- tree_set_node_selected(tree, tree->root->child, true,
- false);
- return true;
- }
- if (mouse & (BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_DRAG_1))
- tree_set_node_selected(tree, tree->root->child, true,
- false);
- if (mouse & (BROWSER_MOUSE_DRAG_1 | BROWSER_MOUSE_DRAG_2)) {
-
- /** @todo the tree window has to scroll the tree when
- * mouse reaches border while dragging this isn't
- * solved for the browser window too.
- */
- tree->drag = TREE_SELECT_DRAG;
- }
- return true;
- }
-
- node = element->parent;
-
- /* A click on expansion toggle or double click on folder toggles node
- * expansion */
- if (((expansion_toggle) && (mouse & (BROWSER_MOUSE_CLICK_1 |
- BROWSER_MOUSE_CLICK_2))) ||
- (((!expansion_toggle) && (node->child != NULL)) &&
- (double_click_1 || double_click_2))) {
-
- /* clear any selection */
- tree_set_node_selected(tree, tree->root->child, true, false);
-
- /* expand / contract node and redraw */
- tree_set_node_expanded(tree, node, !node->expanded,
- false, false);
-
- /* find the last child node if expanded */
- last = node;
- if ((last->child != NULL) && (last->expanded)) {
- last = last->child;
- while ((last->next != NULL) ||
- ((last->child != NULL) &&
- (last->expanded))) {
- if (last->next != NULL)
- last = last->next;
- else
- last = last->child;
- }
- }
- /* scroll to the bottom element then back to the top */
- element = &last->data;
- if (last->expanded)
- for (; element->next != NULL; element = element->next);
- tree->callbacks->scroll_visible(element->box.y,
- element->box.height,
- tree->client_data);
- tree->callbacks->scroll_visible(node->data.box.y,
- node->data.box.height,
- tree->client_data);
- return true;
- }
-
- /* no use for any other expansion toggle click */
- if (expansion_toggle)
- return true;
-
- /* single/double ctrl+click or alt+click starts editing */
- if ((element->editable) && (!tree->editing) &&
- ((element->type == NODE_ELEMENT_TEXT) ||
- (element->type == NODE_ELEMENT_TEXT_PLUS_ICON)) &&
- (mouse & BROWSER_MOUSE_CLICK_1 || double_click_1) &&
- (mouse & BROWSER_MOUSE_MOD_2 ||
- mouse & BROWSER_MOUSE_MOD_3)) {
- tree_set_node_selected(tree, tree->root->child, true, false);
- tree_start_edit(tree, element);
- return true;
- }
-
- /* double click launches the leaf */
- if (double_click_1 || double_click_2) {
- if (node->user_callback == NULL)
- return false;
- msg_data.msg = NODE_LAUNCH;
- msg_data.flag = TREE_ELEMENT_TITLE;
- msg_data.node = node;
- if (node->user_callback(node->callback_data, &msg_data) !=
- NODE_CALLBACK_HANDLED)
- return false;
-
- return true;
- }
-
- /* single click (select) cancels current selection and selects item */
- if (mouse & BROWSER_MOUSE_CLICK_1 || (mouse & BROWSER_MOUSE_CLICK_2 &&
- tree->flags & TREE_SINGLE_SELECT)) {
- if (tree->flags & TREE_NO_SELECT)
- return true;
- if (!node->selected) {
- tree_set_node_selected(tree, tree->root->child, true,
- false);
- node->selected = true;
- tree_handle_node_element_changed(tree, &node->data, false);
- }
- return true;
- }
-
- /* single click (adjust) toggles item selection */
- if (mouse & BROWSER_MOUSE_CLICK_2) {
- if (tree->flags & TREE_NO_SELECT)
- return true;
- node->selected = !node->selected;
- tree_handle_node_element_changed(tree, &node->data, false);
- return true;
- }
-
- /* drag starts a drag operation */
- if ((!tree->editing) && (mouse & (BROWSER_MOUSE_DRAG_1 |
- BROWSER_MOUSE_DRAG_2))) {
- if (tree->flags & TREE_NO_DRAGS)
- return true;
-
- if (!node->selected) {
- tree_set_node_selected(tree, tree->root->child, true,
- false);
- node->selected = true;
- tree_handle_node_element_changed(tree, &node->data, false);
- }
-
- if (tree->flags & TREE_MOVABLE)
- tree->drag = TREE_MOVE_DRAG;
- else tree->drag = TREE_UNKNOWN_DRAG;
-
- return true;
- }
-
-
- return false;
-}
-
-
-/**
- * Updates the selected state for a region of nodes.
- *
- * \param tree the tree to update
- * \param node the node to update children and siblings of
- * \param y the minimum y of the selection rectangle
- * \param height the height of the selection rectangle
- * \param invert whether to invert the selected state
- */
-static void tree_handle_selection_area_node(struct tree *tree,
- struct node *node, int y, int height, bool invert)
-{
- struct node_element *element;
- struct node *update;
- int y_max;
- int y0, y1;
-
- assert(tree != NULL);
- assert(node != NULL);
-
- y_max = y + height;
-
- for (; node != NULL; node = node->next) {
- if (node->box.y > y_max) return;
- y0 = node->box.y;
- y1 = node->box.y + node->box.height;
- if ((y0 < y_max) && (y1 >= y)) {
- update = NULL;
- if (node->expanded) {
- for (element = &node->data; element != NULL;
- element = element->next) {
- y0 = element->box.y;
- y1 = element->box.y +
- element->box.height;
- if ((y0 < y_max) && (y1 >= y)) {
- update = element->parent;
- break;
- }
- }
- } else {
- y0 = node->data.box.y;
- y1 = node->data.box.y + node->data.box.height;
- if ((y0 < y_max) && (y1 >= y))
- update = node->data.parent;
- }
- if ((update) && (node != tree->root)) {
- if (invert) {
- node->selected = !node->selected;
- tree_handle_node_element_changed(tree,
- &node->data, false);
- } else if (!node->selected) {
- node->selected = true;
- tree_handle_node_element_changed(tree,
- &node->data, false);
- }
- }
- }
- if ((node->child != NULL) && (node->expanded))
- tree_handle_selection_area_node(tree, node->child, y,
- height, invert);
- }
-}
-
-
-/**
- * Updates the selected state for a region of nodes.
- *
- * \param tree the tree to update
- * \param y the minimum y of the selection rectangle
- * \param height the height of the selection rectangle
- * \param invert whether to invert the selected state
- */
-static void tree_handle_selection_area(struct tree *tree, int y, int height,
- bool invert)
-{
- assert(tree != NULL);
- assert(tree->root != NULL);
-
- if (tree->root->child == NULL)
- return;
-
- if (height < 0) {
- y += height;
- height = -height;
- }
- tree_handle_selection_area_node(tree, tree->root->child, y, height,
- invert);
-}
-
-
-/**
- * Clears the processing flag.
- *
- * \param node the node to process siblings and children of
- */
-static void tree_clear_processing(struct node *node)
-{
- for (; node != NULL; node = node->next) {
- node->processing = false;
- if (node->child != NULL)
- tree_clear_processing(node->child);
- }
-}
-
-
-/**
- * Sets the processing flag to the selection state.
- *
- * \param node the node to process siblings and children of
- */
-static void tree_selected_to_processing(struct node *node)
-{
- for (; node != NULL; node = node->next) {
- node->processing = node->selected;
- if ((node->child != NULL) && (node->expanded))
- tree_selected_to_processing(node->child);
- }
-}
-
-
-/**
- * Moves the first node in a tree with the processing flag set.
- *
- * \param tree the tree in which the move takes place
- * \param node the node to move siblings/children of
- * \param link the node to link before/as a child (folders) or before/after
- * (link)
- * \param before whether to link siblings before or after the supplied node
- * \param first whether to always link after the supplied node (ie not
- * inside of folders)
- * \return the node moved
- */
-static struct node *tree_move_processing_node(struct tree *tree,
- struct node *node, struct node *link, bool before, bool first)
-{
- struct node *result;
-
- bool folder = link->folder;
- for (; node != NULL; node = node->next) {
- if (node->processing) {
- node->processing = false;
- tree_delink_node(tree, node);
- if (!first)
- link->folder = false;
- tree_link_node(tree, link, node, before);
- if (!first)
- link->folder = folder;
- return node;
- }
- if (node->child != NULL) {
- result = tree_move_processing_node(tree, node->child,
- link, before, first);
- if (result != NULL)
- return result;
- }
- }
- return NULL;
-}
-
-
-/**
- * Moves nodes within a tree.
- *
- * \param tree the tree to process
- * \param destination the node to link before/as a child (folders)
- * or before/after (link)
- * \param before whether to link siblings before or after the supplied
- * node
- */
-static void tree_move_selected_nodes(struct tree *tree,
- struct node *destination, bool before)
-{
- struct node *link;
- struct node *test;
- bool error;
-
- tree_clear_processing(tree->root);
- tree_selected_to_processing(tree->root);
-
- /* the destination node cannot be a child of any node with
- the processing flag set */
- error = destination->processing;
- for (test = destination; test != NULL; test = test->parent)
- error |= test->processing;
- if (error) {
- tree_clear_processing(tree->root);
- return;
- }
- if ((destination->folder) && (!destination->expanded) && (!before)) {
- tree_set_node_expanded(tree, destination, true, false, false);
- }
- link = tree_move_processing_node(tree, tree->root, destination, before,
- true);
- while (link != NULL)
- link = tree_move_processing_node(tree, tree->root, link, false,
- false);
-
- tree_clear_processing(tree->root);
- tree_recalculate_node_positions(tree, tree->root);
- if (tree->redraw)
- tree->callbacks->redraw_request(0, 0, tree->width, tree->height,
- tree->client_data);
-}
-
-
-/**
- * Handle the end of a drag operation
- *
- * \param tree the tree on which the drag was performed
- * \param mouse mouse state during drag end
- * \param x0 x coordinate of drag start
- * \param y0 y coordinate of drag start
- * \param x1 x coordinate of drag end
- * \param y1 y coordinate of drag end
- */
-void tree_drag_end(struct tree *tree, browser_mouse_state mouse, int x0, int y0,
- int x1, int y1)
-{
-
- bool before;
- struct node *node;
- int x, y;
-
- if (treeview_test_mouse_action(tree, BROWSER_MOUSE_HOVER, x1, y1)) {
- return;
- }
-
- switch (tree->drag) {
- case TREE_NO_DRAG:
- case TREE_UNKNOWN_DRAG:
- break;
-
- case TREE_TEXTAREA_DRAG:
- x = tree->editing->box.x;
- y = tree->editing->box.y;
- if (tree->editing->type == NODE_ELEMENT_TEXT_PLUS_ICON)
- x += NODE_INSTEP;
- textarea_mouse_action(tree->textarea, BROWSER_MOUSE_HOVER,
- x1 - x, y1 - y);
- break;
-
- case TREE_SELECT_DRAG:
- tree_handle_selection_area(tree, y0, y1 - y0,
- (mouse | BROWSER_MOUSE_HOLDING_2));
- break;
-
- case TREE_MOVE_DRAG:
- if (!(tree->flags & TREE_MOVABLE))
- return;
- node = tree_get_link_details(tree, x1, y1, &before);
- tree_move_selected_nodes(tree, node, before);
- break;
- }
-
- tree->drag = TREE_NO_DRAG;
-}
-
-
-/**
- * Key press handling for a tree.
- *
- * \param tree The tree which got the keypress
- * \param key The ucs4 character codepoint
- * \return true if the keypress is dealt with, false otherwise.
- */
-bool tree_keypress(struct tree *tree, uint32_t key)
-{
- if (treeview_test_keypress(tree, key)) {
- return true;
- }
-
- if (tree->editing != NULL)
- switch (key) {
- case KEY_ESCAPE:
- tree_stop_edit(tree, false);
- return true;
- case KEY_NL:
- case KEY_CR:
- tree_stop_edit(tree, true);
- return true;
- default:
- return textarea_keypress(tree->textarea, key);
- }
-
- return false;
-}
-
-
-/**
- * Alphabetical comparison function for nodes
- *
- * \param n1 first node to compare
- * \param n2 first node to compare
- * \return 0 if equal, greater then zero if n1 > n2,
- * less then zero if n2 < n1
- */
-int tree_alphabetical_sort(struct node *n1, struct node *n2)
-{
- return strcmp(n1->data.text, n2->data.text);
-}
-
-
-/**
- * Redraw requests from the textarea are piped through this because we have to
- * check the redraw flag of the tree before requesting a redraw and change the
- * position to tree origin relative.
- */
-
-static void tree_textarea_callback(void *data, struct textarea_msg *msg)
-{
- struct tree *tree = data;
- int x, y;
-
- switch (msg->type) {
- case TEXTAREA_MSG_DRAG_REPORT:
- if (msg->data.drag == TEXTAREA_DRAG_NONE) {
- /* Textarea drag finished */
- tree->drag = TREE_NO_DRAG;
- } else {
- /* Textarea drag started */
- tree->drag = TREE_TEXTAREA_DRAG;
- }
- break;
-
- case TEXTAREA_MSG_REDRAW_REQUEST:
- x = msg->data.redraw.x0 + tree->editing->box.x;
- y = msg->data.redraw.y0 + tree->editing->box.y;
-
- if (tree->editing->type == NODE_ELEMENT_TEXT_PLUS_ICON)
- x += NODE_INSTEP;
-
- /* Redraw the textarea */
- if (tree->redraw)
- tree->callbacks->redraw_request(x, y,
- msg->data.redraw.x1 -
- msg->data.redraw.x0,
- msg->data.redraw.y1 -
- msg->data.redraw.y0,
- tree->client_data);
- break;
-
- default:
- break;
- }
-}
-
-
-/**
- * Starts editing a node_element
- *
- * \param tree The tree to which element belongs
- * \param element The element to start being edited
- */
-void tree_start_edit(struct tree *tree, struct node_element *element)
-{
- struct node *parent;
- int width, height;
- textarea_setup ta_setup;
- textarea_flags ta_flags;
-
- assert(tree != NULL);
- assert(element != NULL);
-
- if (tree->editing != NULL)
- tree_stop_edit(tree, true);
-
- parent = element->parent;
- if (&parent->data == element)
- parent = parent->parent;
- for (; parent != NULL; parent = parent->parent) {
- if (!parent->expanded) {
- tree_set_node_expanded(tree, parent, true,
- false, false);
- }
- }
-
- tree->editing = element;
- tree->callbacks->get_window_dimensions(&width, NULL, tree->client_data);
- width -= element->box.x;
- height = element->box.height;
- if (element->type == NODE_ELEMENT_TEXT_PLUS_ICON)
- width -= NODE_INSTEP;
-
- tree->ta_height = height;
-
- ta_flags = TEXTAREA_INTERNAL_CARET;
-
- ta_setup.width = width;
- ta_setup.height = tree->ta_height;
- ta_setup.pad_top = 0;
- ta_setup.pad_right = 4;
- ta_setup.pad_bottom = 0;
- ta_setup.pad_left = 4;
- ta_setup.border_width = 1;
- ta_setup.border_col = 0x000000;
- ta_setup.selected_text = 0xffffff;
- ta_setup.selected_bg = 0x000000;
- ta_setup.text = plot_fstyle;
- ta_setup.text.foreground = 0x000000;
- ta_setup.text.background = 0xffffff;
-
- tree->textarea = textarea_create(ta_flags, &ta_setup,
- tree_textarea_callback, tree);
- if (tree->textarea == NULL) {
- tree_stop_edit(tree, false);
- return;
- }
- textarea_set_text(tree->textarea, element->text);
-
- tree_handle_node_element_changed(tree, element, true);
- tree_recalculate_size(tree);
- tree->callbacks->scroll_visible(element->box.y, element->box.height,
- tree->client_data);
-}
-
-
-/**
- * Callback for fetchcache(). Should be removed once bitmaps get loaded directly
- * from disc
- */
-static nserror tree_icon_callback(hlcache_handle *handle,
- const hlcache_event *event, void *pw)
-{
- return NSERROR_OK;
-}
-
-
-/**
- * Tree utility function. Placed here so that this code doesn't have to be
- * copied by each user.
- *
- * \param name the name of the loaded icon, if it's not a full path the icon is
- * looked for in the directory specified by tree_icons_dir
- * \return the icon in form of a content or NULL on failure
- */
-hlcache_handle *tree_load_icon(const char *name)
-{
- char *url = NULL;
- const char *icon_url = NULL;
- int len;
- hlcache_handle *c;
- nserror err;
- nsurl *icon_nsurl;
-
- /** @todo something like bitmap_from_disc is needed here */
-
- if (!strncmp(name, "file://", 7)) {
- icon_url = name;
- } else {
- char *native_path;
-
- if (tree_icons_dir == NULL)
- return NULL;
-
- /* path + separator + leafname + '\0' */
- len = strlen(tree_icons_dir) + 1 + strlen(name) + 1;
- native_path = malloc(len);
- if (native_path == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- return NULL;
- }
-
- /* Build native path */
- memcpy(native_path, tree_icons_dir,
- strlen(tree_icons_dir) + 1);
- path_add_part(native_path, len, name);
-
- /* Convert native path to URL */
- url = path_to_url(native_path);
-
- free(native_path);
- icon_url = url;
- }
-
- err = nsurl_create(icon_url, &icon_nsurl);
- if (err != NSERROR_OK) {
- if (url != NULL)
- free(url);
- return NULL;
- }
-
- /* Fetch the icon */
- err = hlcache_handle_retrieve(icon_nsurl, 0, 0, 0,
- tree_icon_callback, 0, 0,
- CONTENT_IMAGE, &c);
-
- nsurl_unref(icon_nsurl);
-
- /* If we built the URL here, free it */
- if (url != NULL)
- free(url);
-
- if (err != NSERROR_OK) {
- return NULL;
- }
-
- return c;
-}
diff --git a/desktop/tree.h b/desktop/tree.h
index 84d90f3..db164c0 100644
--- a/desktop/tree.h
+++ b/desktop/tree.h
@@ -18,7 +18,7 @@
*/
/** \file
- * Generic tree handling (interface).
+ * deprecated compatibility layer for new treeview modules. Do not use.
*/
#ifndef _NETSURF_DESKTOP_TREE_H_
@@ -28,48 +28,22 @@
#include <stdint.h>
#include "desktop/browser.h"
-#include "image/bitmap.h"
struct sslcert_session_data;
extern struct sslcert_session_data *ssl_current_session;
extern const char *tree_hotlist_path;
-
-struct hlcache_handle;
-
/* Tree flags */
enum tree_flags {
- TREE_NO_FLAGS = 0,
- TREE_NO_DRAGS = 1,
- TREE_NO_FURNITURE = 2,
- TREE_SINGLE_SELECT = 4,
- TREE_NO_SELECT = 8,
- TREE_MOVABLE = 16,
- TREE_DELETE_EMPTY_DIRS = 32, /**< if the last child of a
- * directory is deleted the
- * directory will be deleted
- * too.
- */
- /* The following are to aid transition to new treeviews */
- TREE_HISTORY = 64,
- TREE_COOKIES = 128,
- TREE_SSLCERT = 256,
- TREE_HOTLIST = 512
+ TREE_HISTORY,
+ TREE_COOKIES,
+ TREE_SSLCERT,
+ TREE_HOTLIST
};
-/** A "flag" value to indicate the element data contains title
- * text. This value should be the first node_element in every
- * node. All other values should be different than this one. The term
- * flag is misused as it is actually a value used by the API consumer
- * to indicate teh type of data a node element contains.
- */
-#define TREE_ELEMENT_TITLE 0x00
-#define TREE_ELEMENT_LAUNCH_IN_TABS 0x05 /* Launch in tabs instead of windows */
struct tree;
-struct node;
-struct node_element;
typedef enum {
TREE_NO_DRAG = 0,
@@ -79,45 +53,6 @@ typedef enum {
TREE_UNKNOWN_DRAG /** < A drag the tree itself won't handle */
} tree_drag_type;
-typedef enum {
- NODE_ELEMENT_TEXT, /**< Text only */
- NODE_ELEMENT_TEXT_PLUS_ICON, /**< Text and icon */
- NODE_ELEMENT_BITMAP /**< Bitmap only */
-} node_element_type;
-
-typedef enum {
- NODE_DELETE_ELEMENT_TXT, /**< The text of an element of the
- * node is being deleted */
- NODE_DELETE_ELEMENT_IMG, /**< The bitmap or icon of a node is
- * being deleted */
- NODE_LAUNCH, /**< The node has been launched */
- NODE_ELEMENT_EDIT_CANCELLED, /**< Editing opperation cancelled. */
- NODE_ELEMENT_EDIT_FINISHING, /**< New text has to be accepted
- * or rejected. */
- NODE_ELEMENT_EDIT_FINISHED /**< Editing of a node_element has
- * been finished. */
-} node_msg;
-
-typedef enum {
- NODE_CALLBACK_HANDLED,
- NODE_CALLBACK_NOT_HANDLED,
- NODE_CALLBACK_REJECT, /**< reject new text for node element
- * and leave editing mode. */
- NODE_CALLBACK_CONTINUE /**< don't leave editig mode. */
-} node_callback_resp;
-
-/** Internal node message. */
-struct node_msg_data {
- node_msg msg; /**< The type of message. */
- unsigned int flag; /**< message flags. */
- struct node *node; /**< tree node messsage concerns. */
- union {
- char *text; /**< textural data. */
- void *bitmap; /**< bitmap data. */
- struct browser_window *bw; /**< clone browser_window. */
- } data; /**< The message data. */
-};
-
/** callbacks to perform necessary operations on treeview. */
struct treeview_table {
void (*redraw_request)(int x, int y, int width, int height,
@@ -128,123 +63,21 @@ struct treeview_table {
void (*get_window_dimensions)(int *width, int *height, void *data); /**< get dimensions of window */
};
-/**
- * Informs the client about any events requiring his action
- *
- * \param user_data the user data which was passed at tree creation
- * \param msg_data structure containing all the message information
- * \return the appropriate node_callback_resp response
- */
-typedef node_callback_resp (*tree_node_user_callback)(void *user_data,
- struct node_msg_data *msg_data);
-
-/* Non-platform specific code */
-
-void tree_set_icon_dir(char *icon_dir);
-void tree_setup_colours(void);
-
-/* Functions for creating/deleting tree primitives and for tree structure
- manipulation */
struct tree *tree_create(unsigned int flags,
const struct treeview_table *callbacks,
void *client_data);
-/**
- * Creates a folder node with the specified title, and optionally links it into
- * the tree.
- *
- * \param tree the owner tree of 'parent', may be NULL
- * \param parent the parent node, or NULL not to link
- * \param title the node title
- * \param editable if true, the node title will be editable
- * \param retain_in_memory if true, the node will stay in memory after deletion
- * \param deleted if true, the node is created with the deleted flag
- * \return the newly created node or NULL on error.
- */
-struct node *tree_create_folder_node(struct tree *tree, struct node *parent,
- const char *title, bool editable, bool retain_in_memory,
- bool deleted);
-
-/**
- * Creates a leaf node with the specified title, and optionally links it into
- * the tree.
- *
- * \param tree the owner tree of 'parent', may be NULL
- * \param parent the parent node, or NULL not to link
- * \param title the node title.
- * \param editable if true, the node title will be editable
- * \param retain_in_memory if true, the node will stay in memory after deletion
- * \param deleted if true, the node is created with the deleted flag
- * \return the newly created node or NULL on error.
- */
-struct node *tree_create_leaf_node(struct tree *tree, struct node *parent,
- const char *title, bool editable, bool retain_in_memory,
- bool deleted);
-
-struct node_element *tree_create_node_element(struct node *parent,
- node_element_type type, unsigned int flag, bool editable);
-void tree_link_node(struct tree *tree, struct node *link, struct node *node,
- bool before);
-void tree_delink_node(struct tree *tree, struct node *node);
+/** deprecated compatibility layer for new treeview modules. Do not use. */
void tree_delete(struct tree *tree);
-void tree_delete_node(struct tree *tree, struct node *node, bool siblings);
-
-/* setters and getters for properties and data */
-void tree_set_node_icon(struct tree *tree, struct node *node,
- struct hlcache_handle *icon);
-void tree_set_node_expanded(struct tree *tree, struct node *node, bool expanded,
- bool folder, bool leaf);
-void tree_set_node_selected(struct tree *tree, struct node *node, bool all,
- bool selected);
-void tree_set_node_selected_at(struct tree *tree, int x, int y, bool selected);
-void tree_set_node_sort_function(struct tree *tree, struct node *node,
- int (*sort) (struct node *, struct node *));
-void tree_set_node_user_callback(struct node *node,
- tree_node_user_callback callback, void *data);
-void tree_set_redraw(struct tree *tree, bool redraw);
-bool tree_get_redraw(struct tree *tree);
-bool tree_node_has_selection(struct node *node);
-bool tree_node_is_deleted(struct node *node);
-bool tree_node_is_folder(struct node *node);
-bool tree_node_is_default(struct node *node);
-void tree_update_node_element(struct tree *tree, struct node_element *element,
- const char *text, void *bitmap);
-bool tree_update_element_text(struct tree *tree, struct node_element *element, char *text);
-const char *tree_node_element_get_text(struct node_element *element);
-struct bitmap *tree_node_element_get_icon(struct node_element *element);
-struct node *tree_get_root(struct tree *tree);
-bool tree_is_edited(struct tree *tree);
tree_drag_type tree_drag_status(struct tree *tree);
-
-struct node *tree_get_default_folder_node(struct tree *tree);
-bool tree_set_default_folder_node(struct tree *tree, struct node *node);
-void tree_clear_default_folder_node(struct tree *tree);
-
-/* functions for traversing the tree */
-struct node *tree_node_get_parent(struct node *node);
-struct node *tree_node_get_child(struct node *node);
-struct node *tree_node_get_next(struct node *node);
-
void tree_draw(struct tree *tree, int x, int y,
int clip_x, int clip_y, int clip_width, int clip_height,
const struct redraw_context *ctx);
-
-struct node_element *tree_node_find_element(struct node *node,
- unsigned int flag, struct node_element *after);
-void tree_delete_selected_nodes(struct tree *tree, struct node *node);
-struct node *tree_get_selected_node(struct node *node);
-struct node *tree_get_link_details(struct tree *tree, int x, int y,
- bool *before);
-void tree_launch_selected(struct tree *tree, bool tabs);
-
bool tree_mouse_action(struct tree *tree, browser_mouse_state mouse,
int x, int y);
void tree_drag_end(struct tree *tree, browser_mouse_state mouse, int x0, int y0,
int x1, int y1);
bool tree_keypress(struct tree *tree, uint32_t key);
-int tree_alphabetical_sort(struct node *, struct node *);
-void tree_start_edit(struct tree *tree, struct node_element *element);
-struct hlcache_handle *tree_load_icon(const char *name);
#endif
diff --git a/desktop/tree_url_node.c b/desktop/tree_url_node.c
deleted file mode 100644
index 241a106..0000000
--- a/desktop/tree_url_node.c
+++ /dev/null
@@ -1,972 +0,0 @@
-/*
- * Copyright 2005 Richard Wilson <info(a)tinct.net>
- * Copyright 2009 Paul Blokus <paul_pl(a)users.sourceforge.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/** \file
- * Creation of URL nodes with use of trees (implementation)
- */
-
-
-#include <assert.h>
-#include <ctype.h>
-
-#include <dom/dom.h>
-#include <dom/bindings/hubbub/parser.h>
-
-#include "content/content.h"
-#include "content/hlcache.h"
-#include "content/urldb.h"
-#include "desktop/browser.h"
-#include "utils/nsoption.h"
-#include "desktop/tree_url_node.h"
-#include "utils/corestrings.h"
-#include "utils/libdom.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/url.h"
-#include "utils/utf8.h"
-#include "utils/utils.h"
-
-/** Flags for each type of url tree node. */
-enum tree_element_url {
- TREE_ELEMENT_URL = 0x01,
- TREE_ELEMENT_LAST_VISIT = 0x02,
- TREE_ELEMENT_VISITS = 0x03,
- TREE_ELEMENT_THUMBNAIL = 0x04,
-};
-
-#define MAX_ICON_NAME_LEN 256
-
-static bool initialised = false;
-
-static hlcache_handle *folder_icon;
-
-struct icon_entry {
- content_type type;
- hlcache_handle *icon;
-};
-
-struct icon_entry icon_table[] = {
- {CONTENT_HTML, NULL},
- {CONTENT_TEXTPLAIN, NULL},
- {CONTENT_CSS, NULL},
- {CONTENT_IMAGE, NULL},
- {CONTENT_NONE, NULL},
-
- /* this serves as a sentinel */
- {CONTENT_HTML, NULL}
-};
-
-static uint32_t tun_users = 0;
-
-void tree_url_node_init(const char *folder_icon_name)
-{
- struct icon_entry *entry;
- char icon_name[MAX_ICON_NAME_LEN];
-
- tun_users++;
-
- if (initialised)
- return;
- initialised = true;
-
- folder_icon = tree_load_icon(folder_icon_name);
-
- entry = icon_table;
- do {
-
- tree_icon_name_from_content_type(icon_name, entry->type);
- entry->icon = tree_load_icon(icon_name);
-
- ++entry;
- } while (entry->type != CONTENT_HTML);
-}
-
-
-void tree_url_node_cleanup()
-{
- struct icon_entry *entry;
-
- tun_users--;
-
- if (tun_users > 0)
- return;
-
- if (!initialised)
- return;
- initialised = false;
-
- hlcache_handle_release(folder_icon);
-
- entry = icon_table;
- do {
- hlcache_handle_release(entry->icon);
- ++entry;
- } while (entry->type != CONTENT_HTML);
-}
-
-/**
- * Creates a tree entry for a URL, and links it into the tree
- *
- * \param parent the node to link to
- * \param url the URL (copied)
- * \param data the URL data to use
- * \param title custom title to use or NULL to use url
- * \return the node created, or NULL for failure
- */
-struct node *tree_create_URL_node(struct tree *tree, struct node *parent,
- nsurl *url, const char *title,
- tree_node_user_callback user_callback, void *callback_data)
-{
- struct node *node = NULL;
- struct node_element *element;
-
- if (title == NULL) {
- node = tree_create_leaf_node(tree,
- parent,
- nsurl_access(url),
- true, false, false);
- } else {
- char *squashed;
-
- squashed = squash_whitespace(title);
- if (squashed != NULL) {
- node = tree_create_leaf_node(tree,
- parent,
- squashed,
- true, false, false);
- free(squashed);
- }
- }
- if (node == NULL) {
- return NULL;
- }
-
- if (user_callback != NULL) {
- tree_set_node_user_callback(node, user_callback,
- callback_data);
- }
-
- tree_create_node_element(node, NODE_ELEMENT_BITMAP,
- TREE_ELEMENT_THUMBNAIL, false);
- tree_create_node_element(node, NODE_ELEMENT_TEXT, TREE_ELEMENT_VISITS,
- false);
- tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_LAST_VISIT, false);
- element = tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_URL, true);
- if (element != NULL) {
- char *text_cp = strdup(nsurl_access(url));
- if (text_cp == NULL) {
- tree_delete_node(tree, node, false);
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- return NULL;
- }
- tree_update_node_element(tree, element, text_cp, NULL);
- }
-
- return node;
-}
-
-
-/**
- * Creates a read only tree entry for a URL, and links it into the tree.
- *
- * \param parent the node to link to
- * \param url the URL
- * \param data the URL data to use
- * \return the node created, or NULL for failure
- */
-struct node *tree_create_URL_node_readonly(struct tree *tree,
- struct node *parent, nsurl *url,
- const struct url_data *data,
- tree_node_user_callback user_callback, void *callback_data)
-{
- struct node *node;
- struct node_element *element;
- const char *title;
-
- assert(url && data);
-
- if (data->title != NULL) {
- title = data->title;
- } else {
- title = nsurl_access(url);
- }
-
- node = tree_create_leaf_node(tree, parent, title, false, false, false);
- if (node == NULL) {
- return NULL;
- }
-
- if (user_callback != NULL) {
- tree_set_node_user_callback(node, user_callback,
- callback_data);
- }
-
- tree_create_node_element(node, NODE_ELEMENT_BITMAP,
- TREE_ELEMENT_THUMBNAIL, false);
- tree_create_node_element(node, NODE_ELEMENT_TEXT, TREE_ELEMENT_VISITS,
- false);
- tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_LAST_VISIT, false);
- element = tree_create_node_element(node, NODE_ELEMENT_TEXT,
- TREE_ELEMENT_URL, false);
- if (element != NULL) {
- tree_update_node_element(tree, element, nsurl_access(url),
- NULL);
- }
-
- tree_update_URL_node(tree, node, url, data);
-
- return node;
-}
-
-
-/**
- * Updates the node details for a URL node.
- *
- * \param node the node to update
- */
-void tree_update_URL_node(struct tree *tree, struct node *node,
- nsurl *url, const struct url_data *data)
-{
- struct node_element *element;
- struct bitmap *bitmap = NULL;
- struct icon_entry *entry;
- char *text_cp;
-
- assert(node != NULL);
-
- element = tree_node_find_element(node, TREE_ELEMENT_URL, NULL);
- if (element == NULL)
- return;
-
- if (data != NULL) {
- if (data->title == NULL)
- urldb_set_url_title(url, nsurl_access(url));
-
- if (data->title == NULL)
- return;
-
- element = tree_node_find_element(node, TREE_ELEMENT_TITLE,
- NULL);
-
- text_cp = strdup(data->title);
- if (text_cp == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- return;
- }
- tree_update_node_element(tree, element, text_cp, NULL);
- } else {
- data = urldb_get_url_data(url);
- if (data == NULL)
- return;
- }
-
- entry = icon_table;
- do {
- if (entry->type == data->type) {
- if (entry->icon != NULL)
- tree_set_node_icon(tree, node, entry->icon);
- break;
- }
- ++entry;
- } while (entry->type != CONTENT_HTML);
-
- /* update last visit text */
- element = tree_node_find_element(node, TREE_ELEMENT_LAST_VISIT, element);
- tree_update_element_text(tree,
- element,
- messages_get_buff("TreeLast",
- (data->last_visit > 0) ?
- ctime((time_t *)&data->last_visit) :
- messages_get("TreeUnknown")));
-
-
- /* update number of visits text */
- element = tree_node_find_element(node, TREE_ELEMENT_VISITS, element);
- tree_update_element_text(tree,
- element,
- messages_get_buff("TreeVisits", data->visits));
-
-
- /* update thumbnail */
- element = tree_node_find_element(node, TREE_ELEMENT_THUMBNAIL, element);
- if (element != NULL) {
- bitmap = urldb_get_thumbnail(url);
-
- if (bitmap != NULL) {
- tree_update_node_element(tree, element, NULL, bitmap);
- }
- }
-}
-
-
-const char *tree_url_node_get_title(struct node *node)
-{
- struct node_element *element;
- element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
- if (element == NULL)
- return NULL;
- return tree_node_element_get_text(element);
-}
-
-
-const char *tree_url_node_get_url(struct node *node)
-{
- struct node_element *element;
- element = tree_node_find_element(node, TREE_ELEMENT_URL, NULL);
- if (element == NULL)
- return NULL;
- return tree_node_element_get_text(element);
-}
-
-
-struct bitmap *tree_url_node_get_icon(struct node *node)
-{
- struct node_element *element;
- element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
- if (element == NULL)
- return NULL;
- return tree_node_element_get_icon(element);
-}
-
-
-void tree_url_node_edit_title(struct tree *tree, struct node *node)
-{
- struct node_element *element;
- element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
- tree_start_edit(tree, element);
-}
-
-void tree_url_node_edit_url(struct tree *tree, struct node *node)
-{
- struct node_element *element;
- element = tree_node_find_element(node, TREE_ELEMENT_URL, NULL);
- tree_start_edit(tree, element);
-}
-
-node_callback_resp tree_url_node_callback(void *user_data,
- struct node_msg_data *msg_data)
-{
- struct tree *tree;
- struct node_element *element;
- nsurl *url;
- nserror error;
- const char *text;
- char *norm_text;
- const struct url_data *data;
-
- /** @todo memory leaks on non-shared folder deletion. */
- switch (msg_data->msg) {
- case NODE_DELETE_ELEMENT_TXT:
- switch (msg_data->flag) {
- /* only history is using non-editable url
- * elements so only history deletion will run
- * this code
- */
- case TREE_ELEMENT_URL:
- /* reset URL characteristics */
- error = nsurl_create(msg_data->data.text, &url);
- if (error != NSERROR_OK) {
- warn_user("NoMemory", 0);
- return NODE_CALLBACK_REJECT;
- }
- urldb_reset_url_visit_data(url);
- nsurl_unref(url);
- return NODE_CALLBACK_HANDLED;
- case TREE_ELEMENT_TITLE:
- return NODE_CALLBACK_HANDLED;
- }
- break;
- case NODE_DELETE_ELEMENT_IMG:
- if (msg_data->flag == TREE_ELEMENT_THUMBNAIL ||
- msg_data->flag == TREE_ELEMENT_TITLE)
- return NODE_CALLBACK_HANDLED;
- break;
- case NODE_LAUNCH:
- element = tree_node_find_element(msg_data->node,
- TREE_ELEMENT_URL, NULL);
- if (element != NULL) {
- nserror error;
- enum browser_window_nav_flags flags;
-
- text = tree_node_element_get_text(element);
-
- error = nsurl_create(text, &url);
- if (error == NSERROR_OK) {
- struct browser_window *clone = NULL;
-
- flags = BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY;
- if (msg_data->flag == TREE_ELEMENT_LAUNCH_IN_TABS) {
- flags |= BROWSER_WINDOW_TAB;
- clone = msg_data->data.bw;
- }
- error = browser_window_create(flags,
- url,
- NULL,
- clone,
- &msg_data->data.bw);
- nsurl_unref(url);
- }
- if (error != NSERROR_OK) {
- warn_user(messages_get_errorcode(error), 0);
- }
-
- return NODE_CALLBACK_HANDLED;
- }
- break;
-
- case NODE_ELEMENT_EDIT_FINISHING:
-
- text = msg_data->data.text;
-
- if (msg_data->flag == TREE_ELEMENT_URL) {
- size_t len;
- error = nsurl_create(text, &url);
- if (error != NSERROR_OK) {
- warn_user("NoMemory", 0);
- return NODE_CALLBACK_REJECT;
- }
- error = nsurl_get(url, NSURL_WITH_FRAGMENT,
- &norm_text, &len);
- if (error != NSERROR_OK) {
- warn_user("NoMemory", 0);
- return NODE_CALLBACK_REJECT;
- }
-
- msg_data->data.text = norm_text;
-
- data = urldb_get_url_data(url);
- if (data == NULL) {
- urldb_add_url(url);
- urldb_set_url_persistence(url, true);
- data = urldb_get_url_data(url);
- if (data == NULL) {
- nsurl_unref(url);
- return NODE_CALLBACK_REJECT;
- }
- }
- tree = user_data;
- tree_update_URL_node(tree, msg_data->node,
- url, NULL);
- nsurl_unref(url);
- }
- else if (msg_data->flag == TREE_ELEMENT_TITLE) {
- while (isspace(*text))
- text++;
- norm_text = strdup(text);
- if (norm_text == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- return NODE_CALLBACK_REJECT;
- }
- /* don't allow zero length entry text, return
- false */
- if (norm_text[0] == '\0') {
- warn_user("NoNameError", 0);
- msg_data->data.text = NULL;
- return NODE_CALLBACK_CONTINUE;
- }
- msg_data->data.text = norm_text;
- }
-
- return NODE_CALLBACK_HANDLED;
- default:
- break;
- }
- return NODE_CALLBACK_NOT_HANDLED;
-}
-
-typedef struct {
- struct tree *tree;
- struct node *directory;
- tree_node_user_callback callback;
- void *callback_data;
- bool last_was_h4;
- dom_string *title;
-} tree_url_load_ctx;
-
-static void tree_url_load_directory(dom_node *ul, tree_url_load_ctx *ctx);
-
-/**
- * Parse an entry represented as a li.
- *
- * \param li DOM node for parsed li
- * \param directory directory to add this entry to
- */
-static void tree_url_load_entry(dom_node *li, tree_url_load_ctx *ctx)
-{
- dom_node *a;
- dom_string *title1;
- dom_string *url1;
- char *title, *url2;
- nsurl *url;
- const struct url_data *data;
- struct node *entry;
- dom_exception derror;
- nserror error;
-
- /* The li must contain an "a" element */
- a = libdom_find_first_element(li, corestring_lwc_a);
- if (a == NULL) {
- warn_user("TreeLoadError", "(Missing <a> in <li>)");
- return;
- }
-
- derror = dom_node_get_text_content(a, &title1);
- if (derror != DOM_NO_ERR) {
- warn_user("TreeLoadError", "(No title)");
- dom_node_unref(a);
- return;
- }
-
- derror = dom_element_get_attribute(a, corestring_dom_href, &url1);
- if (derror != DOM_NO_ERR || url1 == NULL) {
- warn_user("TreeLoadError", "(No URL)");
- dom_string_unref(title1);
- dom_node_unref(a);
- return;
- }
-
- if (title1 != NULL) {
- title = strndup(dom_string_data(title1),
- dom_string_byte_length(title1));
- dom_string_unref(title1);
- } else {
- title = strdup("");
- }
- if (title == NULL) {
- warn_user("NoMemory", NULL);
- dom_string_unref(url1);
- dom_node_unref(a);
- return;
- }
-
- /* We're loading external input.
- * This may be garbage, so attempt to normalise via nsurl
- */
- url2 = strndup(dom_string_data(url1), dom_string_byte_length(url1));
- if (url2 == NULL) {
- warn_user("NoMemory", NULL);
- free(title);
- dom_string_unref(url1);
- dom_node_unref(a);
- return;
- }
-
- dom_string_unref(url1);
-
- error = nsurl_create(url2, &url);
-
- if (error != NSERROR_OK) {
- LOG(("Failed normalising '%s'", url2));
-
- free(url2);
-
- warn_user(messages_get_errorcode(error), NULL);
-
- free(title);
- dom_node_unref(a);
-
- return;
- }
-
- free(url2);
-
- data = urldb_get_url_data(url);
- if (data == NULL) {
- /* No entry in database, so add one */
- urldb_add_url(url);
- /* now attempt to get url data */
- data = urldb_get_url_data(url);
- }
- if (data == NULL) {
- nsurl_unref(url);
- free(title);
- dom_node_unref(a);
-
- return;
- }
-
- /* Make this URL persistent */
- urldb_set_url_persistence(url, true);
-
- /* Force the title in the hotlist */
- urldb_set_url_title(url, title);
-
- entry = tree_create_URL_node(ctx->tree, ctx->directory, url, title,
- ctx->callback, ctx->callback_data);
-
- if (entry == NULL) {
- /** \todo why isn't this fatal? */
- warn_user("NoMemory", 0);
- } else {
- tree_update_URL_node(ctx->tree, entry, url, data);
- }
-
- nsurl_unref(url);
- free(title);
- dom_node_unref(a);
-}
-
-static nserror tree_url_load_directory_cb(dom_node *node, void *ctx)
-{
- /* TODO: return appropriate errors */
- tree_url_load_ctx *tctx = ctx;
- dom_string *name;
- dom_exception error;
-
- /* The ul may contain entries as a li, or directories as
- * an h4 followed by a ul. Non-element nodes may be present
- * (eg. text, comments), and are ignored. */
-
- error = dom_node_get_node_name(node, &name);
- if (error != DOM_NO_ERR || name == NULL)
- return NSERROR_NOMEM;
-
- if (dom_string_caseless_lwc_isequal(name, corestring_lwc_li)) {
- /* entry */
- tree_url_load_entry(node, tctx);
- tctx->last_was_h4 = false;
- } else if (dom_string_caseless_lwc_isequal(name, corestring_lwc_h4)) {
- /* directory (a) */
- dom_string *title;
-
- error = dom_node_get_text_content(node, &title);
- if (error != DOM_NO_ERR || title == NULL) {
- warn_user("TreeLoadError", "(Empty <h4> "
- "or memory exhausted.)");
- dom_string_unref(name);
- return NSERROR_NOMEM;
- }
-
- if (tctx->title != NULL)
- dom_string_unref(tctx->title);
- tctx->title = title;
- tctx->last_was_h4 = true;
- } else if (tctx->last_was_h4 && dom_string_caseless_lwc_isequal(name,
- corestring_lwc_ul)) {
- /* directory (b) */
- dom_string *id;
- bool dir_is_default;
- struct node *dir;
- char *title;
- tree_url_load_ctx new_ctx;
-
- error = dom_element_get_attribute(node, corestring_dom_id, &id);
- if (error != DOM_NO_ERR) {
- dom_string_unref(name);
- return NSERROR_NOMEM;
- }
-
- if (id != NULL) {
- dir_is_default = dom_string_caseless_lwc_isequal(id,
- corestring_lwc_default);
-
- dom_string_unref(id);
- } else {
- dir_is_default = false;
- }
-
- title = strndup(dom_string_data(tctx->title),
- dom_string_byte_length(tctx->title));
- if (title == NULL) {
- dom_string_unref(name);
- return NSERROR_NOMEM;
- }
-
- dir = tree_create_folder_node(tctx->tree, tctx->directory,
- title, true, false, false);
- free(title);
- if (dir == NULL) {
- dom_string_unref(name);
- return NSERROR_NOMEM;
- }
-
- if (dir_is_default)
- tree_set_default_folder_node(tctx->tree, dir);
-
- if (tctx->callback != NULL)
- tree_set_node_user_callback(dir, tctx->callback,
- tctx->callback_data);
-
- if (folder_icon != NULL)
- tree_set_node_icon(tctx->tree, dir, folder_icon);
-
- new_ctx.tree = tctx->tree;
- new_ctx.directory = dir;
- new_ctx.callback = tctx->callback;
- new_ctx.callback_data = tctx->callback_data;
- new_ctx.last_was_h4 = false;
- new_ctx.title = NULL;
-
- tree_url_load_directory(node, &new_ctx);
-
- if (new_ctx.title != NULL) {
- dom_string_unref(new_ctx.title);
- new_ctx.title = NULL;
- }
- tctx->last_was_h4 = false;
- } else {
- tctx->last_was_h4 = false;
- }
-
- dom_string_unref(name);
-
- return NSERROR_OK;
-}
-
-/**
- * Parse a directory represented as a ul.
- *
- * \param ul DOM node for parsed ul
- * \param directory directory to add this directory to
- */
-static void tree_url_load_directory(dom_node *ul, tree_url_load_ctx *ctx)
-{
- assert(ul != NULL);
- assert(ctx != NULL);
- assert(ctx->directory != NULL);
-
- libdom_iterate_child_elements(ul, tree_url_load_directory_cb, ctx);
-}
-
-/**
- * Loads an url tree from a specified file.
- *
- * \param filename name of file to read
- * \param tree empty tree which data will be read into
- * \return the file represented as a tree, or NULL on failure
- */
-bool tree_urlfile_load(const char *filename, struct tree *tree,
- tree_node_user_callback callback, void *callback_data)
-{
- dom_document *document;
- dom_node *html, *body, *ul;
- struct node *root;
- nserror error;
- tree_url_load_ctx ctx;
-
- if (filename == NULL) {
- return false;
- }
-
- error = libdom_parse_file(filename, "iso-8859-1", &document);
- if (error != NSERROR_OK) {
- if (error != NSERROR_NOT_FOUND) {
- warn_user("TreeLoadError", messages_get("ParsingFail"));
- }
- return false;
- }
-
- html = libdom_find_first_element((dom_node *) document,
- corestring_lwc_html);
- if (html == NULL) {
- dom_node_unref(document);
- warn_user("TreeLoadError", "(<html> not found)");
- return false;
- }
-
- body = libdom_find_first_element(html, corestring_lwc_body);
- if (body == NULL) {
- dom_node_unref(html);
- dom_node_unref(document);
- warn_user("TreeLoadError", "(<html>...<body> not found)");
- return false;
- }
-
- ul = libdom_find_first_element(body, corestring_lwc_ul);
- if (ul == NULL) {
- dom_node_unref(body);
- dom_node_unref(html);
- dom_node_unref(document);
- warn_user("TreeLoadError",
- "(<html>...<body>...<ul> not found.)");
- return false;
- }
-
- root = tree_get_root(tree);
-
- ctx.tree = tree;
- ctx.directory = root;
- ctx.callback = callback;
- ctx.callback_data = callback_data;
- ctx.last_was_h4 = false;
- ctx.title = NULL;
-
- tree_url_load_directory(ul, &ctx);
- tree_set_node_expanded(tree, root, true, false, false);
-
- if (ctx.title != NULL) {
- dom_string_unref(ctx.title);
- ctx.title = NULL;
- }
-
- dom_node_unref(ul);
- dom_node_unref(body);
- dom_node_unref(html);
- dom_node_unref(document);
-
- return true;
-}
-
-/**
- * Add an entry to the HTML tree for saving.
- *
- * The node must contain a sequence of node_elements in the following order:
- *
- * \param entry hotlist entry to add
- * \param fp File to write to
- * \return true on success, false on memory exhaustion
- */
-static bool tree_url_save_entry(struct node *entry, FILE *fp)
-{
- const char *href, *text;
- char *latin1_href, *latin1_text;
- utf8_convert_ret ret;
-
- text = tree_url_node_get_title(entry);
- if (text == NULL)
- return false;
-
- href = tree_url_node_get_url(entry);
- if (href == NULL)
- return false;
-
- ret = utf8_to_html(text, "iso-8859-1", strlen(text), &latin1_text);
- if (ret != UTF8_CONVERT_OK)
- return false;
-
- ret = utf8_to_html(href, "iso-8859-1", strlen(href), &latin1_href);
- if (ret != UTF8_CONVERT_OK) {
- free(latin1_text);
- return false;
- }
-
- fprintf(fp, "<li><a href=\"%s\">%s</a></li>",
- latin1_href, latin1_text);
-
- free(latin1_href);
- free(latin1_text);
-
- return true;
-}
-
-/**
- * Add a directory to the HTML tree for saving.
- *
- * \param directory hotlist directory to add
- * \param fp File to write to
- * \return true on success, false on memory exhaustion
- */
-static bool tree_url_save_directory(struct node *directory, FILE *fp)
-{
- struct node *child;
-
- fputs("<ul", fp);
- if (tree_node_is_default(directory))
- fputs(" id=\"default\"", fp);
- fputc('>', fp);
-
- if (tree_node_get_child(directory) != NULL)
- fputc('\n', fp);
-
- for (child = tree_node_get_child(directory); child != NULL;
- child = tree_node_get_next(child)) {
- if (tree_node_is_folder(child) == false) {
- /* entry */
- if (tree_url_save_entry(child, fp) == false)
- return false;
- } else {
- /* directory */
- /* invalid HTML */
- const char *text;
- char *latin1_text;
- utf8_convert_ret ret;
-
- text = tree_url_node_get_title(child);
- if (text == NULL)
- return false;
-
- ret = utf8_to_html(text, "iso-8859-1",
- strlen(text), &latin1_text);
- if (ret != UTF8_CONVERT_OK)
- return false;
-
- fprintf(fp, "<h4>%s</h4>\n", latin1_text);
-
- free(latin1_text);
-
- if (tree_url_save_directory(child, fp) == false)
- return false;
- }
-
- fputc('\n', fp);
- }
-
- fputs("</ul>", fp);
-
- return true;
-}
-
-
-/**
- * Perform a save to a specified file in the form of a html page
- *
- * \param filename the file to save to
- * \param page_title title of the page
- */
-bool tree_urlfile_save(struct tree *tree, const char *filename,
- const char *page_title)
-{
- FILE *fp;
-
- fp = fopen(filename, "w");
- if (fp == NULL)
- return NULL;
-
- /* Unfortunately the Browse Hotlist format is invalid HTML,
- * so this is a lie.
- */
- fputs("<!DOCTYPE html "
- "PUBLIC \"//W3C/DTD HTML 4.01//EN\" "
- "\"http://www.w3.org/TR/html4/strict.dtd\">\n", fp);
- fputs("<html>\n<head>\n", fp);
- fputs("<meta http-equiv=\"Content-Type\" "
- "content=\"text/html; charset=iso-8859-1\">\n", fp);
- fprintf(fp, "<title>%s</title>\n", page_title);
- fputs("</head>\n<body>", fp);
-
- if (tree_url_save_directory(tree_get_root(tree), fp) == false) {
- warn_user("HotlistSaveError", 0);
- fclose(fp);
- return false;
- }
-
- fputs("</body>\n</html>\n", fp);
-
- fclose(fp);
-
- return true;
-}
-
diff --git a/desktop/tree_url_node.h b/desktop/tree_url_node.h
deleted file mode 100644
index bcbc192..0000000
--- a/desktop/tree_url_node.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2005 Richard Wilson <info(a)tinct.net>
- * Copyright 2009 Paul Blokus <paul_pl(a)users.sourceforge.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/** \file
- * Creation of URL nodes with use of trees public API
- */
-
-#ifndef _NETSURF_DESKTOP_TREE_URL_NODE_H_
-#define _NETSURF_DESKTOP_TREE_URL_NODE_H_
-
-
-#include "desktop/tree.h"
-#include "utils/nsurl.h"
-
-struct url_data;
-
-void tree_url_node_init(const char *folder_icon_name);
-void tree_url_node_cleanup(void);
-struct node *tree_create_URL_node(struct tree *tree,
- struct node *parent, nsurl *url, const char *title,
- tree_node_user_callback, void *callback_data);
-struct node *tree_create_URL_node_readonly(struct tree *tree,
- struct node *parent, nsurl *url,
- const struct url_data *data,
- tree_node_user_callback, void *callback_data);
-void tree_update_URL_node(struct tree *tree, struct node *node,
- nsurl *url, const struct url_data *data);
-const char *tree_url_node_get_title(struct node *node);
-const char *tree_url_node_get_url(struct node *node);
-struct bitmap *tree_url_node_get_icon(struct node *node);
-void tree_url_node_edit_title(struct tree *tree, struct node *node);
-void tree_url_node_edit_url(struct tree *tree, struct node *node);
-
-node_callback_resp tree_url_node_callback(void *user_data,
- struct node_msg_data *msg_data);
-
-bool tree_urlfile_load(const char *filename, struct tree *tree,
- tree_node_user_callback, void *callback_data);
-bool tree_urlfile_save(struct tree *tree, const char *filename,
- const char *page_title);
-
-/* front end specific */
-void tree_icon_name_from_content_type(char *buffer, content_type type);
-
-#endif
diff --git a/desktop/treeview.c b/desktop/treeview.c
index dd4efcd..f9b984c 100644
--- a/desktop/treeview.c
+++ b/desktop/treeview.c
@@ -1337,8 +1337,14 @@ nserror treeview_destroy(treeview *tree)
}
-/* Exported interface, documented in treeview.h */
-nserror treeview_node_expand(treeview *tree,
+/**
+ * Expand a treeview's nodes
+ *
+ * \param tree Treeview object to expand nodes in
+ * \param only_folders Iff true, only folders are expanded.
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+static nserror treeview_node_expand_internal(treeview *tree,
treeview_node *node)
{
treeview_node *child;
@@ -1423,10 +1429,35 @@ nserror treeview_node_expand(treeview *tree,
}
+/* Exported interface, documented in treeview.h */
+nserror treeview_node_expand(treeview *tree, treeview_node *node)
+{
+ nserror err;
+ struct rect r;
+
+ err = treeview_node_expand_internal(tree, node);
+ if (err != NSERROR_OK)
+ return err;
+
+ r.x0 = 0;
+ r.y0 = treeview_node_y(tree, node);
+ r.x1 = REDRAW_MAX;
+ r.y1 = tree->root->height;
+
+ /* Redraw */
+ tree->cw_t->redraw_request(tree->cw_h, &r);
+
+ return NSERROR_OK;
+}
+
+
+struct treeview_contract_data {
+ bool only_entries;
+};
/** Treewalk node callback for handling node contraction. */
-static nserror treeview_node_contract_cb(treeview_node *n, void *ctx,
- bool *skip_children, bool *end)
+static nserror treeview_node_contract_cb(treeview_node *n, void *ctx, bool *end)
{
+ struct treeview_contract_data *data = ctx;
int h_reduction;
assert(n != NULL);
@@ -1434,7 +1465,8 @@ static nserror treeview_node_contract_cb(treeview_node *n, void *ctx,
n->flags &= ~TREE_NODE_SELECTED;
- if ((n->flags & TREE_NODE_EXPANDED) == false) {
+ if ((n->flags & TREE_NODE_EXPANDED) == false ||
+ (n->type == TREE_NODE_FOLDER && data->only_entries)) {
/* Nothing to do. */
return NSERROR_OK;
}
@@ -1451,9 +1483,17 @@ static nserror treeview_node_contract_cb(treeview_node *n, void *ctx,
return NSERROR_OK;
}
-/* Exported interface, documented in treeview.h */
-nserror treeview_node_contract(treeview *tree, treeview_node *node)
+/**
+ * Contract a treeview node
+ *
+ * \param tree Treeview object to contract node in
+ * \param node Node to contract
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+static nserror treeview_node_contract_internal(treeview *tree,
+ treeview_node *node)
{
+ struct treeview_contract_data data;
bool selected;
assert(node != NULL);
@@ -1463,14 +1503,15 @@ nserror treeview_node_contract(treeview *tree, treeview_node *node)
return NSERROR_OK;
}
+ data.only_entries = false;
selected = node->flags & TREE_NODE_SELECTED;
/* Contract children. */
- treeview_walk_internal(node, false, NULL,
- treeview_node_contract_cb, NULL);
+ treeview_walk_internal(node, false, treeview_node_contract_cb,
+ NULL, &data);
/* Contract node */
- treeview_node_contract_cb(node, NULL, false, false);
+ treeview_node_contract_cb(node, &data, false);
if (selected)
node->flags |= TREE_NODE_SELECTED;
@@ -1483,6 +1524,130 @@ nserror treeview_node_contract(treeview *tree, treeview_node *node)
/* Exported interface, documented in treeview.h */
+nserror treeview_node_contract(treeview *tree, treeview_node *node)
+{
+ nserror err;
+ struct rect r;
+
+ assert(tree != NULL);
+
+ r.x0 = 0;
+ r.y0 = treeview_node_y(tree, node);
+ r.x1 = REDRAW_MAX;
+ r.y1 = tree->root->height;
+
+ err = treeview_node_contract_internal(tree, node);
+ if (err != NSERROR_OK)
+ return err;
+
+ /* Redraw */
+ tree->cw_t->redraw_request(tree->cw_h, &r);
+
+ return NSERROR_OK;
+}
+
+
+/* Exported interface, documented in treeview.h */
+nserror treeview_contract(treeview *tree, bool all)
+{
+ struct treeview_contract_data data;
+ bool selected;
+ treeview_node *n;
+ struct rect r;
+
+ assert(tree != NULL);
+ assert(tree->root != NULL);
+
+ r.x0 = 0;
+ r.y0 = 0;
+ r.x1 = REDRAW_MAX;
+ r.y1 = tree->root->height;
+
+ data.only_entries = !all;
+
+ for (n = tree->root->children; n != NULL; n = n->next_sib) {
+ if ((n->flags & TREE_NODE_EXPANDED) == false) {
+ continue;
+ }
+
+ selected = n->flags & TREE_NODE_SELECTED;
+
+ /* Contract children. */
+ treeview_walk_internal(n, false,
+ treeview_node_contract_cb, NULL, &data);
+
+ /* Contract node */
+ treeview_node_contract_cb(n, &data, false);
+
+ if (selected)
+ n->flags |= TREE_NODE_SELECTED;
+ }
+
+ /* Inform front end of change in dimensions */
+ tree->cw_t->update_size(tree->cw_h, -1, tree->root->height);
+
+ /* Redraw */
+ tree->cw_t->redraw_request(tree->cw_h, &r);
+
+ return NSERROR_OK;
+}
+
+
+struct treeview_expand_data {
+ treeview *tree;
+ bool only_folders;
+};
+/** Treewalk node callback for handling recursive node expansion. */
+static nserror treeview_expand_cb(treeview_node *n, void *ctx,
+ bool *skip_children, bool *end)
+{
+ struct treeview_expand_data *data = ctx;
+ nserror err;
+
+ assert(n != NULL);
+ assert(n->type != TREE_NODE_ROOT);
+
+ if (n->flags & TREE_NODE_EXPANDED ||
+ (data->only_folders && n->type != TREE_NODE_FOLDER)) {
+ /* Nothing to do. */
+ return NSERROR_OK;
+ }
+
+ err = treeview_node_expand_internal(data->tree, n);
+
+ return err;
+}
+/* Exported interface, documented in treeview.h */
+nserror treeview_expand(treeview *tree, bool only_folders)
+{
+ struct treeview_expand_data data;
+ nserror err;
+ struct rect r;
+
+ assert(tree != NULL);
+ assert(tree->root != NULL);
+
+ data.tree = tree;
+ data.only_folders = only_folders;
+
+ err = treeview_walk_internal(tree->root, true, NULL,
+ treeview_expand_cb, &data);
+ if (err != NSERROR_OK)
+ return err;
+
+ r.x0 = 0;
+ r.y0 = 0;
+ r.x1 = REDRAW_MAX;
+ r.y1 = tree->root->height;
+
+ /* Redraw */
+ tree->cw_t->redraw_request(tree->cw_h, &r);
+
+ return NSERROR_OK;
+}
+
+
+/* Exported interface, documented in treeview.h */
void treeview_redraw(treeview *tree, int x, int y, struct rect *clip,
const struct redraw_context *ctx)
{
@@ -2152,7 +2317,7 @@ static nserror treeview_move_selection(treeview *tree, struct rect *rect)
if (!(parent->flags & TREE_NODE_EXPANDED)) {
if (node->flags & TREE_NODE_EXPANDED)
- treeview_node_contract(tree, node);
+ treeview_node_contract_internal(tree, node);
node->flags &= ~TREE_NODE_SELECTED;
}
@@ -2375,7 +2540,7 @@ static bool treeview_keyboard_navigation(treeview *tree, uint32_t key,
if (ns.curr != NULL) {
if (!(ns.curr->flags & TREE_NODE_EXPANDED)) {
/* Toggle node to expanded */
- treeview_node_expand(tree, ns.curr);
+ treeview_node_expand_internal(tree, ns.curr);
if (ns.curr->children != NULL) {
/* Step to first child */
ns.curr->children->flags |=
@@ -2386,7 +2551,7 @@ static bool treeview_keyboard_navigation(treeview *tree, uint32_t key,
}
} else {
/* Toggle node to contracted */
- treeview_node_contract(tree, ns.curr);
+ treeview_node_contract_internal(tree, ns.curr);
/* Retain current node selection */
ns.curr->flags |= TREE_NODE_SELECTED;
}
@@ -3026,9 +3191,9 @@ static nserror treeview_node_mouse_action_cb(treeview_node *node, void *ctx,
/* Toggle node expansion */
if (node->flags & TREE_NODE_EXPANDED) {
- err = treeview_node_contract(ma->tree, node);
+ err = treeview_node_contract_internal(ma->tree, node);
} else {
- err = treeview_node_expand(ma->tree, node);
+ err = treeview_node_expand_internal(ma->tree, node);
}
if (err != NSERROR_OK) {
return err;
@@ -3263,6 +3428,8 @@ 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);
+
return tree->root->height;
}
diff --git a/desktop/treeview.h b/desktop/treeview.h
index b4a028f..9af72f9 100644
--- a/desktop/treeview.h
+++ b/desktop/treeview.h
@@ -301,7 +301,7 @@ nserror treeview_delete_node(treeview *tree, treeview_node *n,
/**
* Expand a treeview node
*
- * \param tree Treeview object to expande node in
+ * \param tree Treeview object to expand node in
* \param node Node to expand
* \return NSERROR_OK on success, appropriate error otherwise
*/
@@ -317,6 +317,24 @@ nserror treeview_node_expand(treeview *tree, treeview_node *node);
nserror treeview_node_contract(treeview *tree, treeview_node *node);
/**
+ * Expand a treeview's nodes
+ *
+ * \param tree Treeview object to expand nodes in
+ * \param only_folders Iff true, only folders are expanded.
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror treeview_expand(treeview *tree, bool only_folders);
+
+/**
+ * Contract a treeview's nodes
+ *
+ * \param tree Treeview object to contract nodes in
+ * \param all Iff false, only entries are contracted.
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror treeview_contract(treeview *tree, bool all);
+
+/**
* Redraw a treeview object
*
* \param tree Treeview object to render
diff --git a/framebuffer/Makefile.target b/framebuffer/Makefile.target
index bad31ed..d423e29 100644
--- a/framebuffer/Makefile.target
+++ b/framebuffer/Makefile.target
@@ -136,7 +136,7 @@ $(eval $(foreach V,$(filter FB_IMAGE_%,$(.VARIABLES)),$(call convert_image,$($(V
# ----------------------------------------------------------------------------
# S_FRAMEBUFFER are sources purely for the framebuffer build
-S_FRAMEBUFFER := gui.c framebuffer.c tree.c schedule.c \
+S_FRAMEBUFFER := gui.c framebuffer.c schedule.c \
thumbnail.c misc.c bitmap.c filetype.c login.c findfile.c \
localhistory.c clipboard.c
diff --git a/framebuffer/misc.c b/framebuffer/misc.c
index 0568e36..2dd0367 100644
--- a/framebuffer/misc.c
+++ b/framebuffer/misc.c
@@ -21,7 +21,6 @@
#include <stdio.h>
#include <string.h>
-#include "desktop/cookies_old.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
diff --git a/framebuffer/tree.c b/framebuffer/tree.c
deleted file mode 100644
index c661edc..0000000
--- a/framebuffer/tree.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2008 Vincent Sanders <vince(a)simtec.co.uk>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
-
-const char tree_directory_icon_name[] = "directory.png";
-const char tree_content_icon_name[] = "content.png";
-
-
-
-/**
- * Translates a content_type to the name of a respective icon
- *
- * \param content_type content type
- * \param buffer buffer for the icon name
- */
-void tree_icon_name_from_content_type(char *buffer, content_type type)
-{
- // TODO: design/acquire icons
- switch (type) {
- case CONTENT_HTML:
- case CONTENT_TEXTPLAIN:
- case CONTENT_CSS:
- case CONTENT_IMAGE:
- default:
- sprintf(buffer, tree_content_icon_name);
- break;
- }
-}
diff --git a/gtk/cookies.c b/gtk/cookies.c
index 99b2a80..35470ce 100644
--- a/gtk/cookies.c
+++ b/gtk/cookies.c
@@ -21,9 +21,10 @@
*/
-#include "desktop/cookies_old.h"
+#include "desktop/cookie_manager.h"
#include "desktop/plotters.h"
#include "desktop/tree.h"
+#include "desktop/textinput.h"
#include "utils/log.h"
#include "gtk/gui.h"
#include "gtk/cookies.h"
@@ -112,7 +113,7 @@ bool nsgtk_cookies_init(const char *glade_file_location)
drawing_area = GTK_DRAWING_AREA(gtk_builder_get_object(gladeFile,
"cookiesDrawingArea"));
- cookies_window = nsgtk_treeview_create(cookies_get_tree_flags(), window,
+ cookies_window = nsgtk_treeview_create(TREE_COOKIES, window,
scrolled, drawing_area);
if (cookies_window == NULL)
@@ -123,10 +124,6 @@ bool nsgtk_cookies_init(const char *glade_file_location)
CONNECT(window, "delete_event", gtk_widget_hide_on_delete, NULL);
CONNECT(window, "hide", nsgtk_tree_window_hide, cookies_window);
-
- cookies_initialise(nsgtk_treeview_get_tree(cookies_window),
- tree_directory_icon_name,
- tree_content_icon_name);
nsgtk_cookies_init_menu();
@@ -157,7 +154,6 @@ void nsgtk_cookies_init_menu()
void nsgtk_cookies_destroy(void)
{
/* TODO: what about gladeFile? */
- cookies_cleanup();
nsgtk_treeview_destroy(cookies_window);
}
@@ -165,61 +161,62 @@ void nsgtk_cookies_destroy(void)
/* edit menu */
MENUHANDLER(delete_selected)
{
- cookies_delete_selected();
+ cookie_manager_keypress(KEY_DELETE_LEFT);
return TRUE;
}
MENUHANDLER(delete_all)
{
- cookies_delete_all();
+ cookie_manager_keypress(KEY_SELECT_ALL);
+ cookie_manager_keypress(KEY_DELETE_LEFT);
return TRUE;
}
MENUHANDLER(select_all)
{
- cookies_select_all();
+ cookie_manager_keypress(KEY_SELECT_ALL);
return TRUE;
}
MENUHANDLER(clear_selection)
{
- cookies_clear_selection();
+ cookie_manager_keypress(KEY_CLEAR_SELECTION);
return TRUE;
}
/* view menu*/
MENUHANDLER(expand_all)
{
- cookies_expand_all();
+ cookie_manager_expand(false);
return TRUE;
}
MENUHANDLER(expand_domains)
{
- cookies_expand_domains();
+ cookie_manager_expand(true);
return TRUE;
}
MENUHANDLER(expand_cookies)
{
- cookies_expand_cookies();
+ cookie_manager_expand(false);
return TRUE;
}
MENUHANDLER(collapse_all)
{
- cookies_collapse_all();
+ cookie_manager_contract(true);
return TRUE;
}
MENUHANDLER(collapse_domains)
{
- cookies_collapse_domains();
+ cookie_manager_contract(true);
return TRUE;
}
MENUHANDLER(collapse_cookies)
{
- cookies_collapse_cookies();
+ cookie_manager_contract(false);
return TRUE;
}
diff --git a/gtk/gui.c b/gtk/gui.c
index 6e187a1..226d718 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -45,9 +45,7 @@
#include "content/hlcache.h"
#include "content/urldb.h"
#include "desktop/browser_private.h"
-#include "desktop/cookies_old.h"
#include "desktop/gui.h"
-#include "desktop/history_global_core.h"
#include "desktop/netsurf.h"
#include "utils/nsoption.h"
#include "desktop/save_complete.h"
@@ -316,10 +314,6 @@ static void check_options(char **respath)
/* user options should be stored in the users home directory */
snprintf(buf, PATH_MAX, "%s/.netsurf/Choices", hdir);
options_file_location = strdup(buf);
-
- filepath_sfinddef(respath, buf, "icons/", "~/.netsurf/");
- LOG(("Using '%s' as Tree icons dir", buf));
- tree_set_icon_dir(strdup(buf));
filepath_sfinddef(respath, buf, "Print", "~/.netsurf/");
LOG(("Using '%s' as Print Settings file", buf));
diff --git a/gtk/history.c b/gtk/history.c
index e7b0836..2cf1438 100644
--- a/gtk/history.c
+++ b/gtk/history.c
@@ -18,9 +18,10 @@
*/
-#include "desktop/history_global_core.h"
+#include "desktop/global_history.h"
#include "desktop/plotters.h"
#include "desktop/tree.h"
+#include "desktop/textinput.h"
#include "gtk/gui.h"
#include "gtk/history.h"
#include "gtk/plotters.h"
@@ -115,8 +116,7 @@ bool nsgtk_history_init(const char *glade_file_location)
drawing_area = GTK_DRAWING_AREA(gtk_builder_get_object(gladeFile, "globalHistoryDrawingArea"));
global_history_window = nsgtk_treeview_create(
- history_global_get_tree_flags(), window, scrolled,
- drawing_area);
+ TREE_HISTORY, window, scrolled, drawing_area);
if (global_history_window == NULL)
return false;
@@ -127,10 +127,6 @@ bool nsgtk_history_init(const char *glade_file_location)
CONNECT(window, "delete_event", gtk_widget_hide_on_delete, NULL);
CONNECT(window, "hide", nsgtk_tree_window_hide, global_history_window);
- history_global_initialise(
- nsgtk_treeview_get_tree(global_history_window),
- tree_directory_icon_name);
-
nsgtk_history_init_menu();
return true;
@@ -164,7 +160,6 @@ void nsgtk_history_init_menu(void)
void nsgtk_history_destroy(void)
{
/* TODO: what about gladeFile? */
- history_global_cleanup();
nsgtk_treeview_destroy(global_history_window);
}
@@ -190,7 +185,7 @@ MENUHANDLER(export)
gchar *filename = gtk_file_chooser_get_filename(
GTK_FILE_CHOOSER(save_dialog));
- history_global_export(filename);
+ global_history_export(filename, NULL);
g_free(filename);
}
@@ -202,67 +197,68 @@ MENUHANDLER(export)
/* edit menu */
MENUHANDLER(delete_selected)
{
- history_global_delete_selected();
+ global_history_keypress(KEY_DELETE_LEFT);
return TRUE;
}
MENUHANDLER(delete_all)
{
- history_global_delete_all();
+ global_history_keypress(KEY_SELECT_ALL);
+ global_history_keypress(KEY_DELETE_LEFT);
return TRUE;
}
MENUHANDLER(select_all)
{
- history_global_select_all();
+ global_history_keypress(KEY_SELECT_ALL);
return TRUE;
}
MENUHANDLER(clear_selection)
{
- history_global_clear_selection();
+ global_history_keypress(KEY_CLEAR_SELECTION);
return TRUE;
}
/* view menu*/
MENUHANDLER(expand_all)
{
- history_global_expand_all();
+ global_history_expand(false);
return TRUE;
}
MENUHANDLER(expand_directories)
{
- history_global_expand_directories();
+ global_history_expand(true);
return TRUE;
}
MENUHANDLER(expand_addresses)
{
- history_global_expand_addresses();
+ global_history_expand(false);
return TRUE;
}
MENUHANDLER(collapse_all)
{
- history_global_collapse_all();
+ global_history_contract(true);
return TRUE;
}
MENUHANDLER(collapse_directories)
{
- history_global_collapse_directories();
+ global_history_contract(true);
return TRUE;
}
MENUHANDLER(collapse_addresses)
{
- history_global_collapse_addresses();
+ global_history_contract(false);
return TRUE;
}
MENUHANDLER(launch)
{
- history_global_launch_selected(true);
+ global_history_keypress(KEY_CR);
return TRUE;
}
diff --git a/gtk/hotlist.c b/gtk/hotlist.c
index 8a1c815..db09099 100644
--- a/gtk/hotlist.c
+++ b/gtk/hotlist.c
@@ -17,7 +17,7 @@
*/
-#include "desktop/hotlist_old.h"
+#include "desktop/hotlist.h"
#include "utils/nsoption.h"
#include "desktop/plotters.h"
#include "desktop/tree.h"
@@ -122,7 +122,7 @@ bool nsgtk_hotlist_init(const char *glade_file_location)
tree_hotlist_path = nsoption_charp(hotlist_path);
- hotlist_window = nsgtk_treeview_create(hotlist_old_get_tree_flags(), window,
+ hotlist_window = nsgtk_treeview_create(TREE_HOTLIST, window,
scrolled, drawing_area);
if (hotlist_window == NULL)
@@ -133,10 +133,6 @@ bool nsgtk_hotlist_init(const char *glade_file_location)
CONNECT(window, "delete_event", gtk_widget_hide_on_delete, NULL);
CONNECT(window, "hide", nsgtk_tree_window_hide, hotlist_window);
-
- hotlist_old_initialise(nsgtk_treeview_get_tree(hotlist_window),
- nsoption_charp(hotlist_path),
- tree_directory_icon_name);
nsgtk_hotlist_init_menu();
@@ -169,7 +165,6 @@ void nsgtk_hotlist_init_menu(void)
void nsgtk_hotlist_destroy(void)
{
/* TODO: what about gladeFile? */
- hotlist_old_cleanup(nsoption_charp(hotlist_path));
nsgtk_treeview_destroy(hotlist_window);
}
@@ -195,7 +190,7 @@ MENUHANDLER(export)
gchar *filename = gtk_file_chooser_get_filename(
GTK_FILE_CHOOSER(save_dialog));
- hotlist_old_export(filename);
+ hotlist_export(filename, NULL);
g_free(filename);
}
@@ -206,80 +201,80 @@ MENUHANDLER(export)
MENUHANDLER(new_folder)
{
- hotlist_old_add_folder(true);
+ hotlist_add_folder(NULL, false, 0);
return TRUE;
}
MENUHANDLER(new_entry)
{
- hotlist_old_add_entry(true);
+ hotlist_add_entry(NULL, NULL, false, 0);
return TRUE;
}
/* edit menu */
MENUHANDLER(edit_selected)
{
- hotlist_old_edit_selected();
+ hotlist_edit_selection();
return TRUE;
}
MENUHANDLER(delete_selected)
{
- hotlist_old_delete_selected();
+ hotlist_keypress(KEY_DELETE_LEFT);
return TRUE;
}
MENUHANDLER(select_all)
{
- hotlist_old_select_all();
+ hotlist_keypress(KEY_SELECT_ALL);
return TRUE;
}
MENUHANDLER(clear_selection)
{
- hotlist_old_clear_selection();
+ hotlist_keypress(KEY_CLEAR_SELECTION);
return TRUE;
}
/* view menu*/
MENUHANDLER(expand_all)
{
- hotlist_old_expand_all();
+ hotlist_expand(false);
return TRUE;
}
MENUHANDLER(expand_directories)
{
- hotlist_old_expand_directories();
+ hotlist_expand(true);
return TRUE;
}
MENUHANDLER(expand_addresses)
{
- hotlist_old_expand_addresses();
+ hotlist_expand(false);
return TRUE;
}
MENUHANDLER(collapse_all)
{
- hotlist_old_collapse_all();
+ hotlist_contract(true);
return TRUE;
}
MENUHANDLER(collapse_directories)
{
- hotlist_old_collapse_directories();
+ hotlist_contract(true);
return TRUE;
}
MENUHANDLER(collapse_addresses)
{
- hotlist_old_collapse_addresses();
+ hotlist_contract(false);
return TRUE;
}
MENUHANDLER(launch)
{
- hotlist_old_launch_selected(true);
+ hotlist_keypress(KEY_CR);
return TRUE;
}
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index d2aabaf..fdc3cc7 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -34,7 +34,7 @@
#include "css/utils.h"
#include "desktop/browser_private.h"
#include "desktop/local_history.h"
-#include "desktop/hotlist_old.h"
+#include "desktop/hotlist.h"
#include "desktop/gui.h"
#include "desktop/netsurf.h"
#include "utils/nsoption.h"
@@ -1540,7 +1540,7 @@ MULTIHANDLER(addbookmarks)
if (bw == NULL || bw->current_content == NULL ||
hlcache_handle_get_url(bw->current_content) == NULL)
return TRUE;
- hotlist_old_add_page(nsurl_access(hlcache_handle_get_url(bw->current_content)));
+ hotlist_add_url(hlcache_handle_get_url(bw->current_content));
return TRUE;
}
diff --git a/gtk/treeview.c b/gtk/treeview.c
index d836eb6..2a4732a 100644
--- a/gtk/treeview.c
+++ b/gtk/treeview.c
@@ -29,7 +29,6 @@
#include <gdk/gdkkeysyms.h>
#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
#include "desktop/plotters.h"
#include "gtk/compat.h"
#include "gtk/gui.h"
@@ -50,9 +49,6 @@ struct nsgtk_treeview {
struct tree *tree;
};
-const char tree_directory_icon_name[] = "directory.png";
-const char tree_content_icon_name[] = "content.png";
-
void nsgtk_treeview_destroy(struct nsgtk_treeview *tv)
{
tree_delete(tv->tree);
@@ -89,26 +85,6 @@ static void nsgtk_tree_resized(struct tree *tree, int width, int height, void *d
}
/**
- * Translates a content_type to the name of a respective icon
- *
- * \param content_type content type
- * \param buffer buffer for the icon name
- */
-void tree_icon_name_from_content_type(char *buffer, content_type type)
-{
- // TODO: design/acquire icons
- switch (type) {
- case CONTENT_HTML:
- case CONTENT_TEXTPLAIN:
- case CONTENT_CSS:
- case CONTENT_IMAGE:
- default:
- sprintf(buffer, tree_content_icon_name);
- break;
- }
-}
-
-/**
* Scrolls the tree to make an element visible
*
* \param y Y coordinate of the element
@@ -187,7 +163,6 @@ nsgtk_tree_window_draw_event(GtkWidget *widget, cairo_t *cr, gpointer data)
cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
- tree_set_redraw(tree, true);
tree_draw(tree, 0, 0, x1, y1, x2 - x1, y2 - y1, &ctx);
current_widget = NULL;
@@ -217,7 +192,6 @@ nsgtk_tree_window_draw_event(GtkWidget *widget, GdkEventExpose *event, gpointer
current_widget = widget;
current_cr = gdk_cairo_create(nsgtk_widget_get_window(widget));
- tree_set_redraw(tree, true);
tree_draw(tree, 0, 0, x, y, width, height, &ctx);
current_widget = NULL;
@@ -230,11 +204,6 @@ nsgtk_tree_window_draw_event(GtkWidget *widget, GdkEventExpose *event, gpointer
void nsgtk_tree_window_hide(GtkWidget *widget, gpointer g)
{
- struct nsgtk_treeview *tw = g;
- struct tree *tree = tw->tree;
-
- if (tree != NULL)
- tree_set_redraw(tree, false);
}
gboolean nsgtk_tree_window_button_press_event(GtkWidget *widget,
@@ -411,32 +380,26 @@ gboolean nsgtk_tree_window_keypress_event(GtkWidget *widget, GdkEventKey *event,
GtkAdjustment *hscroll;
GtkAdjustment *scroll = NULL;
gdouble hpage, vpage;
- bool edited;
nskey = gtk_gui_gdkkey_to_nskey(event);
-
+
+ if (tree_keypress(tree, nskey) == true)
+ return TRUE;
vscroll = gtk_scrolled_window_get_vadjustment(tw->scrolled);
hscroll = gtk_scrolled_window_get_hadjustment(tw->scrolled);
g_object_get(vscroll, "page-size", &vpage, NULL);
g_object_get(hscroll, "page-size", &hpage, NULL);
-
-
- edited = tree_is_edited(tree);
switch (event->keyval) {
case GDK_KEY(Home):
case GDK_KEY(KP_Home):
- if (edited)
- break;
scroll = vscroll;
value = nsgtk_adjustment_get_lower(scroll);
break;
case GDK_KEY(End):
- case GDK_KEY(KP_End):
- if (edited)
- break;
+ case GDK_KEY(KP_End):
scroll = vscroll;
value = nsgtk_adjustment_get_upper(scroll) - vpage;
if (value < nsgtk_adjustment_get_lower(scroll))
@@ -444,9 +407,7 @@ gboolean nsgtk_tree_window_keypress_event(GtkWidget *widget, GdkEventKey *event,
break;
case GDK_KEY(Left):
- case GDK_KEY(KP_Left):
- if (edited)
- break;
+ case GDK_KEY(KP_Left):
scroll = hscroll;
value = gtk_adjustment_get_value(scroll) -
nsgtk_adjustment_get_step_increment(scroll);
@@ -465,8 +426,6 @@ gboolean nsgtk_tree_window_keypress_event(GtkWidget *widget, GdkEventKey *event,
case GDK_KEY(Right):
case GDK_KEY(KP_Right):
- if (edited)
- break;
scroll = hscroll;
value = gtk_adjustment_get_value(scroll) +
nsgtk_adjustment_get_step_increment(scroll);
@@ -504,16 +463,13 @@ gboolean nsgtk_tree_window_keypress_event(GtkWidget *widget, GdkEventKey *event,
value = nsgtk_adjustment_get_upper(scroll) - vpage;
break;
- default:
- tree_keypress(tree, nskey);
- return TRUE;
+ default:
+ break;
}
if (scroll != NULL)
gtk_adjustment_set_value(scroll, value);
- tree_keypress(tree, nskey);
-
return TRUE;
}
diff --git a/gtk/treeview.h b/gtk/treeview.h
index 4c94da4..12eb180 100644
--- a/gtk/treeview.h
+++ b/gtk/treeview.h
@@ -26,10 +26,6 @@
#include "desktop/browser.h"
-/* defined in front end code */
-extern const char tree_directory_icon_name[];
-extern const char tree_content_icon_name[];
-
struct nsgtk_treeview;
struct nsgtk_treeview *nsgtk_treeview_create(unsigned int flags,
diff --git a/monkey/utils.c b/monkey/utils.c
index 886c1ff..3e09106 100644
--- a/monkey/utils.c
+++ b/monkey/utils.c
@@ -20,8 +20,7 @@
#include <stdlib.h>
#include <string.h>
-#include "desktop/tree_url_node.h"
-
+#include "utils/config.h"
#include "utils/utils.h"
#include "utils/url.h"
#include "utils/utf8.h"
@@ -137,9 +136,4 @@ utf8_from_local_encoding(const char *string, size_t len,
return (*result == NULL) ? UTF8_CONVERT_NOMEM : UTF8_CONVERT_OK;
}
-void
-tree_icon_name_from_content_type(char *buffer, content_type type)
-{
- sprintf(buffer, "%s", "content.png");
-}
diff --git a/riscos/cookies.c b/riscos/cookies.c
index 14a1d03..7f37de8 100644
--- a/riscos/cookies.c
+++ b/riscos/cookies.c
@@ -30,8 +30,9 @@
#include "oslib/wimp.h"
#include "oslib/wimpspriteop.h"
#include "content/urldb.h"
-#include "desktop/cookies_old.h"
+#include "desktop/cookie_manager.h"
#include "desktop/tree.h"
+#include "desktop/textinput.h"
#include "riscos/cookies.h"
#include "riscos/dialog.h"
#include "riscos/menus.h"
@@ -107,7 +108,7 @@ void ro_gui_cookies_postinitialise(void)
cookies_window.tv = ro_treeview_create(cookies_window.window,
cookies_window.toolbar, &ro_cookies_treeview_callbacks,
- cookies_get_tree_flags());
+ TREE_COOKIES);
if (cookies_window.tv == NULL) {
LOG(("Failed to allocate treeview"));
return;
@@ -116,13 +117,6 @@ void ro_gui_cookies_postinitialise(void)
ro_toolbar_update_client_data(cookies_window.toolbar,
cookies_window.tv);
- /* Initialise the cookies into the tree. */
-
- cookies_initialise(ro_treeview_get_tree(cookies_window.tv),
- tree_directory_icon_name,
- tree_content_icon_name);
-
-
/* Build the cookies window menu. */
static const struct ns_menu cookies_definition = {
@@ -165,8 +159,6 @@ void ro_gui_cookies_postinitialise(void)
void ro_gui_cookies_open(void)
{
- tree_set_redraw(ro_treeview_get_tree(cookies_window.tv), true);
-
ro_gui_cookies_toolbar_update_buttons();
if (!ro_gui_dialog_open_top(cookies_window.window,
@@ -187,23 +179,23 @@ void ro_gui_cookies_toolbar_click(button_bar_action action)
{
switch (action) {
case TOOLBAR_BUTTON_DELETE:
- cookies_delete_selected();
+ cookie_manager_keypress(KEY_DELETE_LEFT);
break;
case TOOLBAR_BUTTON_EXPAND:
- cookies_expand_cookies();
+ cookie_manager_expand(false);
break;
case TOOLBAR_BUTTON_COLLAPSE:
- cookies_collapse_cookies();
+ cookie_manager_contract(false);
break;
case TOOLBAR_BUTTON_OPEN:
- cookies_expand_domains();
+ cookie_manager_expand(true);
break;
case TOOLBAR_BUTTON_CLOSE:
- cookies_collapse_domains();
+ cookie_manager_contract(true);
break;
default:
@@ -220,7 +212,7 @@ void ro_gui_cookies_toolbar_update_buttons(void)
{
ro_toolbar_set_button_shaded_state(cookies_window.toolbar,
TOOLBAR_BUTTON_DELETE,
- !ro_treeview_has_selection(cookies_window.tv));
+ !cookie_manager_has_selection());
}
@@ -256,7 +248,7 @@ bool ro_gui_cookies_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
if (menu != cookies_window.menu)
return false;
- selection = ro_treeview_has_selection(cookies_window.tv);
+ selection = cookie_manager_has_selection();
ro_gui_menu_set_entry_shaded(cookies_window.menu,
TREE_SELECTION, !selection);
@@ -308,31 +300,31 @@ bool ro_gui_cookies_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
{
switch (action) {
case TREE_EXPAND_ALL:
- cookies_expand_all();
+ cookie_manager_expand(false);
return true;
case TREE_EXPAND_FOLDERS:
- cookies_expand_domains();
+ cookie_manager_expand(true);
return true;
case TREE_EXPAND_LINKS:
- cookies_expand_cookies();
+ cookie_manager_expand(false);
return true;
case TREE_COLLAPSE_ALL:
- cookies_collapse_all();
+ cookie_manager_contract(true);
return true;
case TREE_COLLAPSE_FOLDERS:
- cookies_collapse_domains();
+ cookie_manager_contract(true);
return true;
case TREE_COLLAPSE_LINKS:
- cookies_collapse_cookies();
+ cookie_manager_contract(false);
return true;
case TREE_SELECTION_DELETE:
- cookies_delete_selected();
+ cookie_manager_keypress(KEY_DELETE_LEFT);
return true;
case TREE_SELECT_ALL:
- cookies_select_all();
+ cookie_manager_keypress(KEY_SELECT_ALL);
return true;
case TREE_CLEAR_SELECTION:
- cookies_clear_selection();
+ cookie_manager_keypress(KEY_CLEAR_SELECTION);
return true;
case TOOLBAR_BUTTONS:
ro_toolbar_set_display_buttons(cookies_window.toolbar,
diff --git a/riscos/global_history.c b/riscos/global_history.c
index 8eeb924..dfabbe9 100644
--- a/riscos/global_history.c
+++ b/riscos/global_history.c
@@ -30,7 +30,7 @@
#include "oslib/wimp.h"
#include "oslib/wimpspriteop.h"
#include "content/urldb.h"
-#include "desktop/history_global_core.h"
+#include "desktop/global_history.h"
#include "desktop/tree.h"
#include "riscos/dialog.h"
#include "riscos/global_history.h"
@@ -112,7 +112,7 @@ void ro_gui_global_history_postinitialise(void)
ro_treeview_create(global_history_window.window,
global_history_window.toolbar,
&ro_global_history_treeview_callbacks,
- history_global_get_tree_flags());
+ TREE_HISTORY);
if (global_history_window.tv == NULL) {
LOG(("Failed to allocate treeview"));
return;
@@ -121,12 +121,6 @@ void ro_gui_global_history_postinitialise(void)
ro_toolbar_update_client_data(global_history_window.toolbar,
global_history_window.tv);
- /* Initialise the global history into the tree. */
-
- history_global_initialise(
- ro_treeview_get_tree(global_history_window.tv),
- tree_directory_icon_name);
-
/* Build the global history window menu. */
static const struct ns_menu global_history_definition = {
@@ -171,8 +165,6 @@ void ro_gui_global_history_postinitialise(void)
void ro_gui_global_history_open(void)
{
- tree_set_redraw(ro_treeview_get_tree(global_history_window.tv), true);
-
ro_gui_global_history_toolbar_update_buttons();
if (!ro_gui_dialog_open_top(global_history_window.window,
@@ -193,27 +185,27 @@ void ro_gui_global_history_toolbar_click(button_bar_action action)
{
switch (action) {
case TOOLBAR_BUTTON_DELETE:
- history_global_delete_selected();
+ global_history_keypress(KEY_DELETE_LEFT);
break;
case TOOLBAR_BUTTON_EXPAND:
- history_global_expand_addresses();
+ global_history_expand(false);
break;
case TOOLBAR_BUTTON_COLLAPSE:
- history_global_collapse_addresses();
+ global_history_contract(false);
break;
case TOOLBAR_BUTTON_OPEN:
- history_global_expand_directories();
+ global_history_expand(true);
break;
case TOOLBAR_BUTTON_CLOSE:
- history_global_collapse_directories();
+ global_history_contract(true);
break;
case TOOLBAR_BUTTON_LAUNCH:
- history_global_launch_selected(false);
+ global_history_keypress(KEY_CR);
break;
default:
@@ -230,11 +222,11 @@ void ro_gui_global_history_toolbar_update_buttons(void)
{
ro_toolbar_set_button_shaded_state(global_history_window.toolbar,
TOOLBAR_BUTTON_DELETE,
- !ro_treeview_has_selection(global_history_window.tv));
+ !global_history_has_selection());
ro_toolbar_set_button_shaded_state(global_history_window.toolbar,
TOOLBAR_BUTTON_LAUNCH,
- !ro_treeview_has_selection(global_history_window.tv));
+ !global_history_has_selection());
}
@@ -270,7 +262,7 @@ bool ro_gui_global_history_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
if (menu != global_history_window.menu)
return false;
- selection = ro_treeview_has_selection(global_history_window.tv);
+ selection = global_history_has_selection();
ro_gui_menu_set_entry_shaded(global_history_window.menu,
TREE_SELECTION, !selection);
@@ -332,34 +324,34 @@ bool ro_gui_global_history_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
ro_gui_dialog_open_persistent(w, dialog_saveas, true);
return true;
case TREE_EXPAND_ALL:
- history_global_expand_all();
+ global_history_expand(false);
return true;
case TREE_EXPAND_FOLDERS:
- history_global_expand_directories();
+ global_history_expand(true);
return true;
case TREE_EXPAND_LINKS:
- history_global_expand_addresses();
+ global_history_expand(false);
return true;
case TREE_COLLAPSE_ALL:
- history_global_collapse_all();
+ global_history_contract(true);
return true;
case TREE_COLLAPSE_FOLDERS:
- history_global_collapse_directories();
+ global_history_contract(true);
return true;
case TREE_COLLAPSE_LINKS:
- history_global_collapse_addresses();
+ global_history_contract(false);
return true;
case TREE_SELECTION_LAUNCH:
- history_global_launch_selected(false);
+ global_history_keypress(KEY_CR);
return true;
case TREE_SELECTION_DELETE:
- history_global_delete_selected();
+ global_history_keypress(KEY_DELETE_LEFT);
return true;
case TREE_SELECT_ALL:
- history_global_select_all();
+ global_history_keypress(KEY_SELECT_ALL);
return true;
case TREE_CLEAR_SELECTION:
- history_global_clear_selection();
+ global_history_keypress(KEY_CLEAR_SELECTION);
return true;
case TOOLBAR_BUTTONS:
ro_toolbar_set_display_buttons(global_history_window.toolbar,
diff --git a/riscos/gui.c b/riscos/gui.c
index a312b38..5811454 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -55,15 +55,11 @@
#include "content/hlcache.h"
#include "content/urldb.h"
#include "content/fetchers/resource.h"
-#include "desktop/cookies_old.h"
#include "desktop/gui.h"
-#include "desktop/history_global_core.h"
-#include "desktop/hotlist_old.h"
#include "desktop/netsurf.h"
#include "utils/nsoption.h"
#include "desktop/save_complete.h"
#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
#include "render/font.h"
#include "riscos/content-handlers/artworks.h"
#include "riscos/bitmap.h"
@@ -430,7 +426,6 @@ static void gui_init(int argc, char** argv)
int length;
char *nsdir_temp;
byte *base;
- char *tree_icons_dir;
/* re-enable all FPU exceptions/traps except inexact operations,
* which we're not interested in, and underflow which is incorrectly
@@ -459,12 +454,6 @@ static void gui_init(int argc, char** argv)
ro_plot_patterned_lines = false;
}
- tree_icons_dir = strdup("NetSurf:Resources.Icons");
- if (tree_icons_dir == NULL)
- die("Failed initialising string options");
- tree_set_icon_dir(tree_icons_dir);
-
-
/* Create our choices directories */
ro_gui_create_dirs();
@@ -940,9 +929,6 @@ void gui_quit(void)
urldb_save_cookies(nsoption_charp(cookie_jar));
urldb_save(nsoption_charp(url_save));
ro_gui_window_quit();
- history_global_cleanup();
- cookies_cleanup();
- hotlist_old_cleanup(nsoption_charp(hotlist_save));
ro_gui_saveas_quit();
rufl_quit();
free(gui_sprites);
diff --git a/riscos/hotlist.c b/riscos/hotlist.c
index 09f8c71..d00e724 100644
--- a/riscos/hotlist.c
+++ b/riscos/hotlist.c
@@ -33,7 +33,7 @@
#include "content/content.h"
#include "content/hlcache.h"
#include "content/urldb.h"
-#include "desktop/hotlist_old.h"
+#include "desktop/hotlist.h"
#include "desktop/tree.h"
#include "riscos/dialog.h"
#include "riscos/hotlist.h"
@@ -131,7 +131,7 @@ void ro_gui_hotlist_postinitialise(void)
tree_hotlist_path = nsoption_charp(hotlist_path);
hotlist_window.tv = ro_treeview_create(hotlist_window.window,
hotlist_window.toolbar, &ro_hotlist_treeview_callbacks,
- hotlist_old_get_tree_flags());
+ TREE_HOTLIST);
if (hotlist_window.tv == NULL) {
LOG(("Failed to allocate treeview"));
return;
@@ -140,13 +140,6 @@ void ro_gui_hotlist_postinitialise(void)
ro_toolbar_update_client_data(hotlist_window.toolbar,
hotlist_window.tv);
- /* Initialise the hotlist into the tree. */
-
- hotlist_old_initialise(ro_treeview_get_tree(hotlist_window.tv),
- nsoption_charp(hotlist_path),
- tree_directory_icon_name);
-
-
/* Build the hotlist window menu. */
static const struct ns_menu hotlist_definition = {
@@ -215,8 +208,6 @@ void ro_gui_hotlist_open(void)
error->errmess);
}
- tree_set_redraw(ro_treeview_get_tree(hotlist_window.tv), true);
-
ro_gui_hotlist_toolbar_update_buttons();
if (!ro_gui_dialog_open_top(hotlist_window.window,
@@ -236,31 +227,31 @@ void ro_gui_hotlist_toolbar_click(button_bar_action action)
{
switch (action) {
case TOOLBAR_BUTTON_DELETE:
- hotlist_old_delete_selected();
+ hotlist_keypress(KEY_DELETE_LEFT);
break;
case TOOLBAR_BUTTON_EXPAND:
- hotlist_old_expand_addresses();
+ hotlist_expand(false);
break;
case TOOLBAR_BUTTON_COLLAPSE:
- hotlist_old_collapse_addresses();
+ hotlist_contract(false);
break;
case TOOLBAR_BUTTON_OPEN:
- hotlist_old_expand_directories();
+ hotlist_expand(true);
break;
case TOOLBAR_BUTTON_CLOSE:
- hotlist_old_collapse_directories();
+ hotlist_contract(true);
break;
case TOOLBAR_BUTTON_LAUNCH:
- hotlist_old_launch_selected(false);
+ hotlist_keypress(KEY_CR);
break;
case TOOLBAR_BUTTON_CREATE:
- hotlist_old_add_folder(true);
+ hotlist_add_folder(NULL, false, 0);
break;
default:
@@ -277,11 +268,11 @@ void ro_gui_hotlist_toolbar_update_buttons(void)
{
ro_toolbar_set_button_shaded_state(hotlist_window.toolbar,
TOOLBAR_BUTTON_DELETE,
- !ro_treeview_has_selection(hotlist_window.tv));
+ !hotlist_has_selection());
ro_toolbar_set_button_shaded_state(hotlist_window.toolbar,
TOOLBAR_BUTTON_LAUNCH,
- !ro_treeview_has_selection(hotlist_window.tv));
+ !hotlist_has_selection());
}
@@ -316,7 +307,7 @@ bool ro_gui_hotlist_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
if (menu != hotlist_window.menu)
return false;
- selection = ro_treeview_has_selection(hotlist_window.tv);
+ selection = hotlist_has_selection();
ro_gui_menu_set_entry_shaded(hotlist_window.menu,
TREE_SELECTION, !selection);
@@ -375,43 +366,43 @@ bool ro_gui_hotlist_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
ro_gui_dialog_open_persistent(w, dialog_saveas, true);
return true;
case TREE_NEW_FOLDER:
- hotlist_old_add_folder(true);
+ hotlist_add_folder(NULL, false, 0);
return true;
case TREE_NEW_LINK:
- hotlist_old_add_entry(true);
+ hotlist_add_entry(NULL, NULL, false, 0);
return true;
case TREE_EXPAND_ALL:
- hotlist_old_expand_all();
+ hotlist_expand(false);
return true;
case TREE_EXPAND_FOLDERS:
- hotlist_old_expand_directories();
+ hotlist_expand(true);
return true;
case TREE_EXPAND_LINKS:
- hotlist_old_expand_addresses();
+ hotlist_expand(false);
return true;
case TREE_COLLAPSE_ALL:
- hotlist_old_collapse_all();
+ hotlist_contract(true);
return true;
case TREE_COLLAPSE_FOLDERS:
- hotlist_old_collapse_directories();
+ hotlist_contract(true);
return true;
case TREE_COLLAPSE_LINKS:
- hotlist_old_collapse_addresses();
+ hotlist_contract(false);
return true;
case TREE_SELECTION_EDIT:
- hotlist_old_edit_selected();
+ hotlist_edit_selection();
return true;
case TREE_SELECTION_LAUNCH:
- hotlist_old_launch_selected(false);
+ hotlist_keypress(KEY_CR);
return true;
case TREE_SELECTION_DELETE:
- hotlist_old_delete_selected();
+ hotlist_keypress(KEY_DELETE_LEFT);
return true;
case TREE_SELECT_ALL:
- hotlist_old_select_all();
+ hotlist_keypress(KEY_SELECT_ALL);
return true;
case TREE_CLEAR_SELECTION:
- hotlist_old_clear_selection();
+ hotlist_keypress(KEY_CLEAR_SELECTION);
return true;
case TOOLBAR_BUTTONS:
ro_toolbar_set_display_buttons(hotlist_window.toolbar,
@@ -477,12 +468,16 @@ void ro_gui_hotlist_add_page(const char *url)
if (url == NULL)
return;
+ if (nsurl_create(url, &nsurl) != NSERROR_OK)
+ return;
+
/* If we're not using external hotlists, add the page to NetSurf's
* own hotlist and return...
*/
if (!nsoption_bool(external_hotlists)) {
- hotlist_old_add_page(url);
+ hotlist_add_url(nsurl);
+ nsurl_unref(nsurl);
return;
}
@@ -495,8 +490,6 @@ void ro_gui_hotlist_add_page(const char *url)
LOG(("Sending Hotlist AddURL to potential hotlist clients."));
- if (nsurl_create(url, &nsurl) != NSERROR_OK)
- return;
data = urldb_get_url_data(nsurl);
if (data == NULL)
return;
@@ -542,8 +535,15 @@ static void ro_gui_hotlist_addurl_bounce(wimp_message *message)
{
LOG(("Hotlist AddURL Bounced"));
- if (hotlist_url != NULL)
- hotlist_old_add_page(hotlist_url);
+ if (hotlist_url != NULL) {
+ nsurl *nsurl;
+
+ if (nsurl_create(hotlist_url, &nsurl) != NSERROR_OK)
+ return;
+
+ hotlist_add_url(nsurl);
+ nsurl_unref(nsurl);
+ }
ro_gui_hotlist_add_cleanup();
@@ -599,14 +599,24 @@ void ro_gui_hotlist_add_cleanup(void)
void ro_gui_hotlist_url_drop(wimp_message *message, const char *url)
{
int x, y;
+ nsurl *nsurl;
+
if (hotlist_window.window != message->data.data_xfer.w)
return;
+ if (url == NULL)
+ return;
+
+ if (nsurl_create(url, &nsurl) != NSERROR_OK)
+ return;
+
ro_gui_tree_get_tree_coordinates(hotlist_window.tree,
message->data.data_xfer.pos.x,
message->data.data_xfer.pos.y,
&x, &y);
- hotlist_old_add_page_xy(url, x, y);
+
+ hotlist_add_entry(nsurl, NULL, true, y);
+ nsurl_unref(nsurl);
}
#endif
diff --git a/riscos/menus.c b/riscos/menus.c
index 5a576f8..e51fc34 100644
--- a/riscos/menus.c
+++ b/riscos/menus.c
@@ -34,10 +34,9 @@
#include "content/content.h"
#include "content/hlcache.h"
#include "content/urldb.h"
-#include "desktop/cookies_old.h"
+#include "desktop/cookie_manager.h"
#include "desktop/browser.h"
#include "desktop/gui.h"
-#include "desktop/history_global_core.h"
#include "desktop/local_history.h"
#include "desktop/netsurf.h"
#include "desktop/textinput.h"
diff --git a/riscos/save.c b/riscos/save.c
index 0a91140..ad2d4c4 100644
--- a/riscos/save.c
+++ b/riscos/save.c
@@ -37,8 +37,8 @@
#include "oslib/wimpspriteop.h"
#include "content/content.h"
#include "content/hlcache.h"
-#include "desktop/hotlist_old.h"
-#include "desktop/history_global_core.h"
+#include "desktop/hotlist.h"
+#include "desktop/global_history.h"
#include "desktop/netsurf.h"
#include "desktop/save_complete.h"
#include "desktop/save_text.h"
@@ -882,7 +882,7 @@ bool ro_gui_save_content(hlcache_handle *h, char *path, bool force_overwrite)
LINK_TEXT, path);
case GUI_SAVE_HOTLIST_EXPORT_HTML:
- if (!hotlist_old_export(path))
+ if (hotlist_export(path, NULL) != NSERROR_OK)
return false;
error = xosfile_set_type(path, 0xfaf);
if (error)
@@ -890,7 +890,7 @@ bool ro_gui_save_content(hlcache_handle *h, char *path, bool force_overwrite)
error->errnum, error->errmess));
break;
case GUI_SAVE_HISTORY_EXPORT_HTML:
- if (!history_global_export(path))
+ if (global_history_export(path, NULL) != NSERROR_OK)
return false;
error = xosfile_set_type(path, 0xfaf);
if (error)
diff --git a/riscos/sslcert.c b/riscos/sslcert.c
index 4835817..1395d27 100644
--- a/riscos/sslcert.c
+++ b/riscos/sslcert.c
@@ -158,8 +158,6 @@ void gui_cert_verify(nsurl *url,
return;
}
- tree_set_redraw(ro_treeview_get_tree(sslcert_window->tv), true);
-
/* Set up the certificate window event handling.
*
* (The action buttons are registered as button events, not OK and
diff --git a/riscos/treeview.c b/riscos/treeview.c
index 7727663..479a857 100644
--- a/riscos/treeview.c
+++ b/riscos/treeview.c
@@ -40,7 +40,6 @@
#include "desktop/plotters.h"
#include "desktop/textinput.h"
#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
#include "riscos/bitmap.h"
#include "riscos/dialog.h"
#include "riscos/gui.h"
@@ -61,10 +60,6 @@
#define wimp_KEY_END wimp_KEY_COPY
#endif
-/** \todo Ugh! */
-const char tree_directory_icon_name[] = "directory.png";
-const char tree_content_icon_name[] = "content.png";
-
struct ro_treeview
{
struct tree *tree; /*< Pointer to treeview tree block. */
@@ -285,22 +280,6 @@ wimp_w ro_treeview_get_window(ro_treeview *tv)
}
/**
- * Return an indication of whether the supplied treeview object contains a
- * selection.
- *
- * \param *tv The ro_treeview object of interest.
- * \return true if there is a selection in the tree; else false.
- */
-
-bool ro_treeview_has_selection(ro_treeview *tv)
-{
- if (tv != NULL)
- return tree_node_has_selection(tree_get_root(tv->tree));
- else
- return false;
-}
-
-/**
* Callback to force a redraw of part of the treeview window.
*
* \param x Min X Coordinate of area to be redrawn.
@@ -854,8 +833,8 @@ static bool ro_treeview_mouse_click(wimp_pointer *pointer)
mouse = 0;
if (pointer->buttons == wimp_CLICK_MENU) {
- if (!tree_node_has_selection(tree_get_root(tv->tree)))
- mouse |= BROWSER_MOUSE_CLICK_1;
+ /* TODO: test for no selection, and pass click to select node */
+ /* mouse |= BROWSER_MOUSE_CLICK_1; */
} else {
mouse = ro_gui_mouse_click_state(pointer->buttons,
wimp_BUTTON_DOUBLE_CLICK_DRAG);
@@ -1294,25 +1273,3 @@ int ro_treeview_get_help(help_full_message_request *message_data)
return -1;
}
-/**
- * Convert a content type into an icon name.
- *
- * \todo -- Currently we don't have any icons apart from the default.
- *
- * \param *buffer A buffer to return the icon name
- * \param type The content type to return an icon name for.
- */
-
-void tree_icon_name_from_content_type(char *buffer, content_type type)
-{
- switch (type) {
- case CONTENT_HTML:
- case CONTENT_TEXTPLAIN:
- case CONTENT_CSS:
- case CONTENT_IMAGE:
- default:
- sprintf(buffer, tree_content_icon_name);
- break;
- }
-}
-
diff --git a/riscos/treeview.h b/riscos/treeview.h
index 5491952..77505ac 100644
--- a/riscos/treeview.h
+++ b/riscos/treeview.h
@@ -31,10 +31,6 @@
#include "desktop/tree.h"
#include "riscos/toolbar.h"
-/* defined in front end code */
-extern const char tree_directory_icon_name[];
-extern const char tree_content_icon_name[];
-
typedef struct ro_treeview ro_treeview;
struct ro_treeview_callbacks {
@@ -50,7 +46,6 @@ const struct toolbar_callbacks *ro_treeview_get_toolbar_callbacks(void);
struct tree *ro_treeview_get_tree(ro_treeview *tv);
wimp_w ro_treeview_get_window(ro_treeview *tv);
-bool ro_treeview_has_selection(ro_treeview *tv);
void ro_treeview_set_origin(ro_treeview *tv, int x, int y);
void ro_treeview_mouse_at(wimp_pointer *pointer);
diff --git a/riscos/window.c b/riscos/window.c
index 7971763..d3375be 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -46,7 +46,7 @@
#include "content/urldb.h"
#include "css/css.h"
#include "desktop/browser_private.h"
-#include "desktop/cookies_old.h"
+#include "desktop/cookie_manager.h"
#include "desktop/scrollbar.h"
#include "desktop/frames.h"
#include "desktop/local_history.h"
@@ -2763,7 +2763,8 @@ bool ro_gui_window_menu_select(wimp_w w, wimp_i i, wimp_menu *menu,
break;
case COOKIES_DELETE:
- cookies_delete_all();
+ cookie_manager_keypress(KEY_SELECT_ALL);
+ cookie_manager_keypress(KEY_DELETE_LEFT);
break;
/* page actions */
diff --git a/test/llcache.c b/test/llcache.c
index b3eb0d2..643ff7f 100644
--- a/test/llcache.c
+++ b/test/llcache.c
@@ -105,24 +105,24 @@ char *url_to_path(const char *url)
* Things that are absolutely not reasonable, and should disappear *
******************************************************************************/
-#include "desktop/cookies_old.h"
+#include "desktop/cookie_manager.h"
#include "desktop/gui.h"
#include "desktop/tree.h"
-/* desktop/cookies_old.h -- used by urldb
+/* desktop/cookie_manager.h -- used by urldb
*
* URLdb should have a cookies update event + handler registration
*/
-bool cookies_schedule_update(const struct cookie_data *data)
+bool cookie_manager_add(const struct cookie_data *data)
{
return true;
}
-/* desktop/cookies_old.h -- used by urldb
+/* desktop/cookie_manager.h -- used by urldb
*
* URLdb should have a cookies removal handler registration
*/
-void cookies_remove(const struct cookie_data *data)
+void cookie_manager_remove(const struct cookie_data *data)
{
}
diff --git a/test/urldbtest.c b/test/urldbtest.c
index 7c72ed7..cc657ed 100644
--- a/test/urldbtest.c
+++ b/test/urldbtest.c
@@ -32,7 +32,7 @@
#include "image/bitmap.h"
#include "content/content.h"
#include "content/urldb.h"
-#include "desktop/cookies_old.h"
+#include "desktop/cookie_manager.h"
#include "utils/nsoption.h"
#ifdef riscos
/** \todo lose this */
@@ -52,12 +52,12 @@ static void netsurf_lwc_iterator(lwc_string *str, void *pw)
LOG(("[%3u] %.*s", str->refcnt, (int) lwc_string_length(str), lwc_string_data(str)));
}
-bool cookies_schedule_update(const struct cookie_data *data)
+bool cookie_manager_add(const struct cookie_data *data)
{
return true;
}
-void cookies_remove(const struct cookie_data *data)
+void cookie_manager_remove(const struct cookie_data *data)
{
}
diff --git a/windows/Makefile.target b/windows/Makefile.target
index f490795..1cdb4a6 100644
--- a/windows/Makefile.target
+++ b/windows/Makefile.target
@@ -66,8 +66,7 @@ S_RESOURCES := windows_resource.o
# S_WINDOWS are sources purely for the windows build
S_WINDOWS := main.c window.c gui.c drawable.c misc.c plot.c findfile.c \
font.c bitmap.c about.c prefs.c download.c filetype.c \
- localhistory.c login.c schedule.c thumbnail.c tree.c \
- windbg.c
+ localhistory.c login.c schedule.c thumbnail.c windbg.c
S_WINDOWS := $(addprefix windows/,$(S_WINDOWS))
# This is the final source build list
diff --git a/windows/misc.c b/windows/misc.c
index 51c02ca..d820a5b 100644
--- a/windows/misc.c
+++ b/windows/misc.c
@@ -25,7 +25,6 @@
#include <windows.h>
-#include "desktop/cookies_old.h"
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/url.h"
diff --git a/windows/tree.c b/windows/tree.c
deleted file mode 100644
index ec0750b..0000000
--- a/windows/tree.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2008 Vincent Sanders <vince(a)simtec.co.uk>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "desktop/tree.h"
-#include "desktop/tree_url_node.h"
-
-
-const char tree_directory_icon_name[] = "directory.png";
-const char tree_content_icon_name[] = "content.png";
-
-
-/**
- * Translates a content_type to the name of a respective icon
- *
- * \param content_type content type
- * \param buffer buffer for the icon name
- */
-void tree_icon_name_from_content_type(char *buffer, content_type type)
-{
- // TODO: design/acquire icons
- switch (type) {
- case CONTENT_HTML:
- case CONTENT_TEXTPLAIN:
- case CONTENT_CSS:
- case CONTENT_IMAGE:
- default:
- sprintf(buffer, tree_content_icon_name);
- break;
- }
-}
--
NetSurf Browser
9 years, 8 months
netsurf: branch master updated. release/3.0-483-gb9c2b5d
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/b9c2b5df6540ef19c522b...
...commit http://git.netsurf-browser.org/netsurf.git/commit/b9c2b5df6540ef19c522baf...
...tree http://git.netsurf-browser.org/netsurf.git/tree/b9c2b5df6540ef19c522bafb4...
The branch, master has been updated
via b9c2b5df6540ef19c522bafb40086d67121ba50a (commit)
from 9a59103c6a83225b50e98651c1b377d535b808c8 (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=b9c2b5df6540ef19c52...
commit b9c2b5df6540ef19c522bafb40086d67121ba50a
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
make js library selection target dependant
diff --git a/utils/jenkins-build.sh b/utils/jenkins-build.sh
index ea8a520..c4f8bd7 100755
--- a/utils/jenkins-build.sh
+++ b/utils/jenkins-build.sh
@@ -302,8 +302,18 @@ fi
# convert javascript parameters
if [ "${BUILD_JS}" = "json" ];then
- BUILD_MOZJS=NO
- BUILD_JS=YES
+ case ${TARGET} in
+ "riscos")
+ BUILD_MOZJS=NO
+ BUILD_JS=YES
+ ;;
+ *)
+ BUILD_MOZJS=YES
+ BUILD_JS=NO
+ ;;
+
+ esac
+
else
BUILD_JS=NO
BUILD_MOZJS=NO
-----------------------------------------------------------------------
Summary of changes:
utils/jenkins-build.sh | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/utils/jenkins-build.sh b/utils/jenkins-build.sh
index ea8a520..c4f8bd7 100755
--- a/utils/jenkins-build.sh
+++ b/utils/jenkins-build.sh
@@ -302,8 +302,18 @@ fi
# convert javascript parameters
if [ "${BUILD_JS}" = "json" ];then
- BUILD_MOZJS=NO
- BUILD_JS=YES
+ case ${TARGET} in
+ "riscos")
+ BUILD_MOZJS=NO
+ BUILD_JS=YES
+ ;;
+ *)
+ BUILD_MOZJS=YES
+ BUILD_JS=NO
+ ;;
+
+ esac
+
else
BUILD_JS=NO
BUILD_MOZJS=NO
--
NetSurf Browser
9 years, 8 months