summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2013-07-26 14:48:26 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2013-07-26 14:48:26 +0100
commit2bd587add5912c02db71746e83eda47b66fb80af (patch)
tree78001a9ca490a883c23c5dcd735b58585899c74d /desktop
parentbb870de150eb3c38a76daa802c82a6383a483a1d (diff)
downloadnetsurf-2bd587add5912c02db71746e83eda47b66fb80af.tar.gz
netsurf-2bd587add5912c02db71746e83eda47b66fb80af.tar.bz2
Make the parasitic hack of the old tree code more robust. Now if the temp_treeview_test option is set, the global history and cookie manager will be replaced with their respective new implementations.
Diffstat (limited to 'desktop')
-rw-r--r--desktop/cookies_old.c2
-rw-r--r--desktop/history_global_core.c2
-rw-r--r--desktop/hotlist.c2
-rw-r--r--desktop/sslcert.c2
-rw-r--r--desktop/tree.c103
-rw-r--r--desktop/tree.h5
6 files changed, 79 insertions, 37 deletions
diff --git a/desktop/cookies_old.c b/desktop/cookies_old.c
index 864fef65d..0aaf61f80 100644
--- a/desktop/cookies_old.c
+++ b/desktop/cookies_old.c
@@ -392,7 +392,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;
+ return TREE_DELETE_EMPTY_DIRS | TREE_COOKIES;
}
diff --git a/desktop/history_global_core.c b/desktop/history_global_core.c
index ce438302f..b03485acb 100644
--- a/desktop/history_global_core.c
+++ b/desktop/history_global_core.c
@@ -297,7 +297,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;
+ return TREE_NO_FLAGS | TREE_HISTORY;
}
diff --git a/desktop/hotlist.c b/desktop/hotlist.c
index 055de3af8..adc9e5f8f 100644
--- a/desktop/hotlist.c
+++ b/desktop/hotlist.c
@@ -189,7 +189,7 @@ bool hotlist_initialise(struct tree *tree, const char *hotlist_path,
*/
unsigned int hotlist_get_tree_flags(void)
{
- return TREE_MOVABLE;
+ return TREE_MOVABLE | TREE_HOTLIST;
}
diff --git a/desktop/sslcert.c b/desktop/sslcert.c
index 2b4d726e0..d5e7f6f55 100644
--- a/desktop/sslcert.c
+++ b/desktop/sslcert.c
@@ -73,7 +73,7 @@ void sslcert_init(const char* icon_name)
*/
unsigned int sslcert_get_tree_flags(void)
{
- return TREE_NO_DRAGS | TREE_NO_SELECT;
+ return TREE_NO_DRAGS | TREE_NO_SELECT | TREE_SSLCERT;
}
diff --git a/desktop/tree.c b/desktop/tree.c
index 46910e7de..7cac1cbda 100644
--- a/desktop/tree.c
+++ b/desktop/tree.c
@@ -177,8 +177,11 @@ struct tree {
#include "desktop/treeview.h"
+#include "desktop/cookie_manager.h"
#include "desktop/global_history.h"
+int treeview_inits;
+
static void treeview_test_redraw_request(struct core_window *cw, struct rect r)
{
struct tree *tree = (struct tree *)cw;
@@ -238,10 +241,22 @@ static bool treeview_test_init(struct tree *tree)
if (nsoption_bool(temp_treeview_test) == false)
return false;
- treeview_init();
- err = global_history_init(&cw_t, (struct core_window *)tree);
- if (err != NSERROR_OK) {
- warn_user("Duffed it.", 0);
+ treeview_inits++;
+
+ if (treeview_inits == 1)
+ treeview_init();
+
+ 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) {
+ err = global_history_init(&cw_t, (struct core_window *)tree);
+ if (err != NSERROR_OK) {
+ warn_user("Couldn't init new global history.", 0);
+ }
}
return true;
@@ -254,12 +269,23 @@ static bool treeview_test_fini(struct tree *tree)
if (nsoption_bool(temp_treeview_test) == false)
return false;
- err = global_history_fini();
- treeview_fini();
- if (err != NSERROR_OK) {
- warn_user("Duffed it.", 0);
+ 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) {
+ err = global_history_fini();
+ if (err != NSERROR_OK) {
+ warn_user("Couldn't finalise cookie manager.", 0);
+ }
}
+ if (treeview_inits == 1)
+ treeview_fini();
+ treeview_inits--;
+
return true;
}
@@ -277,9 +303,16 @@ static bool treeview_test_redraw(struct tree *tree, int x, int y,
clip.x1 = clip_x + clip_width;
clip.y1 = clip_y + clip_height;
- global_history_redraw(x, y, &clip, ctx);
+ if (tree->flags & TREE_COOKIES) {
+ cookie_manager_redraw(x, y, &clip, ctx);
+ return true;
+ }
+ if (tree->flags & TREE_HISTORY) {
+ global_history_redraw(x, y, &clip, ctx);
+ return true;
+ }
- return true;
+ return false;
}
static bool treeview_test_mouse_action(struct tree *tree,
@@ -288,9 +321,16 @@ static bool treeview_test_mouse_action(struct tree *tree,
if (nsoption_bool(temp_treeview_test) == false)
return false;
- global_history_mouse_action(mouse, x, y);
+ if (tree->flags & TREE_COOKIES) {
+ cookie_manager_mouse_action(mouse, x, y);
+ return true;
+ }
+ if (tree->flags & TREE_HISTORY) {
+ global_history_mouse_action(mouse, x, y);
+ return true;
+ }
- return true;
+ return false;
}
static bool treeview_test_keypress(struct tree *tree, uint32_t key)
@@ -298,9 +338,16 @@ static bool treeview_test_keypress(struct tree *tree, uint32_t key)
if (nsoption_bool(temp_treeview_test) == false)
return false;
- global_history_keypress(key);
+ if (tree->flags & TREE_COOKIES) {
+ cookie_manager_keypress(key);
+ return true;
+ }
+ if (tree->flags & TREE_HISTORY) {
+ global_history_keypress(key);
+ return true;
+ }
- return true;
+ return false;
}
@@ -420,9 +467,7 @@ struct tree *tree_create(unsigned int flags,
tree_setup_colours();
- if (flags == TREE_MOVABLE) {
- treeview_test_init(tree);
- }
+ treeview_test_init(tree);
return tree;
}
@@ -1267,9 +1312,7 @@ void tree_delete(struct tree *tree)
{
tree->redraw = false;
- if (tree->flags == TREE_MOVABLE) {
- treeview_test_fini(tree);
- }
+ treeview_test_fini(tree);
if (tree->root->child != NULL)
tree_delete_node_internal(tree, tree->root->child, true);
@@ -2196,11 +2239,9 @@ void tree_draw(struct tree *tree, int x, int y,
assert(tree != NULL);
assert(tree->root != NULL);
- if (tree->flags == TREE_MOVABLE) {
- if (treeview_test_redraw(tree, x, y, clip_x, clip_y,
- clip_width, clip_height, ctx)) {
- return;
- }
+ 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 */
@@ -2567,10 +2608,8 @@ bool tree_mouse_action(struct tree *tree, browser_mouse_state mouse, int x,
assert(tree != NULL);
assert(tree->root != NULL);
- if (tree->flags == TREE_MOVABLE) {
- if (treeview_test_mouse_action(tree, mouse, x, y)) {
- return true;
- }
+ if (treeview_test_mouse_action(tree, mouse, x, y)) {
+ return true;
}
if (tree->root->child == NULL)
@@ -3026,10 +3065,8 @@ void tree_drag_end(struct tree *tree, browser_mouse_state mouse, int x0, int y0,
*/
bool tree_keypress(struct tree *tree, uint32_t key)
{
- if (tree->flags == TREE_MOVABLE) {
- if (treeview_test_keypress(tree, key)) {
- return true;
- }
+ if (treeview_test_keypress(tree, key)) {
+ return true;
}
if (tree->editing != NULL)
diff --git a/desktop/tree.h b/desktop/tree.h
index 20ade30c0..7074f6090 100644
--- a/desktop/tree.h
+++ b/desktop/tree.h
@@ -45,6 +45,11 @@ enum tree_flags {
* 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
};
/** A "flag" value to indicate the element data contains title