From 60c840628f4f2aebc86adea495258be1ecc738e8 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Tue, 14 Dec 2010 00:18:24 +0000 Subject: Small refactor to change icon names to being passed in from frontends instead of core treeview globals svn path=/trunk/netsurf/; revision=11053 --- desktop/cookies.c | 6 +++--- desktop/cookies.h | 2 +- desktop/history_global_core.c | 6 +++--- desktop/history_global_core.h | 2 +- desktop/hotlist.c | 8 ++++---- desktop/hotlist.h | 10 +++++++++- desktop/sslcert.c | 4 ++-- desktop/sslcert.h | 2 +- desktop/tree.h | 4 ---- desktop/tree_url_node.c | 4 ++-- desktop/tree_url_node.h | 2 +- 11 files changed, 27 insertions(+), 23 deletions(-) (limited to 'desktop') diff --git a/desktop/cookies.c b/desktop/cookies.c index 09aa079a9..e22dcc289 100644 --- a/desktop/cookies.c +++ b/desktop/cookies.c @@ -371,14 +371,14 @@ static void cookies_schedule_callback(void *scheduled_data) * \param end_redraw callback function called after every redraw * \return true on success, false on memory exhaustion */ -bool cookies_initialise(struct tree *tree) +bool cookies_initialise(struct tree *tree, const char* folder_icon_name, const char* cookie_icon_name) { if (tree == NULL) return false; - folder_icon = tree_load_icon(tree_directory_icon_name); - cookie_icon = tree_load_icon(tree_content_icon_name); + folder_icon = tree_load_icon(folder_icon_name); + cookie_icon = tree_load_icon(cookie_icon_name); /* Create an empty tree */ cookies_tree = tree; diff --git a/desktop/cookies.h b/desktop/cookies.h index 06278c006..9e0d79fbb 100644 --- a/desktop/cookies.h +++ b/desktop/cookies.h @@ -29,7 +29,7 @@ struct cookie_data; -bool cookies_initialise(struct tree *tree); +bool cookies_initialise(struct tree *tree, const char* folder_icon_name, const char* cookie_icon_name); unsigned int cookies_get_tree_flags(void); /** diff --git a/desktop/history_global_core.c b/desktop/history_global_core.c index 3589346ed..771928467 100644 --- a/desktop/history_global_core.c +++ b/desktop/history_global_core.c @@ -278,10 +278,10 @@ static bool history_global_initialise_nodes(void) * \param end_redraw callback function called after every redraw * \return true on success, false on memory exhaustion */ -bool history_global_initialise(struct tree *tree) +bool history_global_initialise(struct tree *tree, const char* folder_icon_name) { - folder_icon = tree_load_icon(tree_directory_icon_name); - tree_url_node_init(); + folder_icon = tree_load_icon(folder_icon_name); + tree_url_node_init(folder_icon_name); if (tree == NULL) return false; diff --git a/desktop/history_global_core.h b/desktop/history_global_core.h index 97c578f3d..1bb343dd6 100644 --- a/desktop/history_global_core.h +++ b/desktop/history_global_core.h @@ -24,7 +24,7 @@ #include "desktop/tree.h" -bool history_global_initialise(struct tree *tree); +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); diff --git a/desktop/hotlist.c b/desktop/hotlist.c index 74b071d8e..cb5362050 100644 --- a/desktop/hotlist.c +++ b/desktop/hotlist.c @@ -111,8 +111,8 @@ static node_callback_resp hotlist_node_callback(void *user_data, return NODE_CALLBACK_NOT_HANDLED; } - -bool hotlist_initialise(struct tree *tree, const char *hotlist_path) +/* exported interface documented in hotlist.h */ +bool hotlist_initialise(struct tree *tree, const char *hotlist_path, const char* folder_icon_name) { struct node *node; const struct url_data *url_data; @@ -123,9 +123,9 @@ bool hotlist_initialise(struct tree *tree, const char *hotlist_path) creating_node = false; - folder_icon = tree_load_icon(tree_directory_icon_name); + folder_icon = tree_load_icon(folder_icon_name); - tree_url_node_init(); + tree_url_node_init(folder_icon_name); if (tree == NULL) return false; diff --git a/desktop/hotlist.h b/desktop/hotlist.h index 84f573a90..efce84696 100644 --- a/desktop/hotlist.h +++ b/desktop/hotlist.h @@ -30,7 +30,15 @@ #include "desktop/tree.h" -bool hotlist_initialise(struct tree *tree, const char *hotlist_path); +/** + * 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_initialise(struct tree *tree, const char *hotlist_path, const char* folder_icon_name); + unsigned int hotlist_get_tree_flags(void); void hotlist_cleanup(const char *hotlist_path); diff --git a/desktop/sslcert.c b/desktop/sslcert.c index 2d10b4719..9aff25700 100644 --- a/desktop/sslcert.c +++ b/desktop/sslcert.c @@ -59,9 +59,9 @@ struct sslcert_session_data { static hlcache_handle *sslcert_icon; /** Initialise ssl certificate window. */ -void sslcert_init(void) +void sslcert_init(const char* icon_name) { - sslcert_icon = tree_load_icon(tree_content_icon_name); + sslcert_icon = tree_load_icon(icon_name); } diff --git a/desktop/sslcert.h b/desktop/sslcert.h index bc1b8bef8..8fe534846 100644 --- a/desktop/sslcert.h +++ b/desktop/sslcert.h @@ -26,7 +26,7 @@ struct sslcert_session_data; -void sslcert_init(void); +void sslcert_init(const char* icon_name); unsigned int sslcert_get_tree_flags(void); void sslcert_cleanup(void); diff --git a/desktop/tree.h b/desktop/tree.h index aaf82af83..1703c3784 100644 --- a/desktop/tree.h +++ b/desktop/tree.h @@ -55,10 +55,6 @@ enum tree_flags { */ #define TREE_ELEMENT_TITLE 0x00 -/* these should be defined in front end code */ -extern const char tree_directory_icon_name[]; -extern const char tree_content_icon_name[]; - struct tree; struct node; struct node_element; diff --git a/desktop/tree_url_node.c b/desktop/tree_url_node.c index ff21d97bf..182c9332d 100644 --- a/desktop/tree_url_node.c +++ b/desktop/tree_url_node.c @@ -103,7 +103,7 @@ struct icon_entry icon_table[] = { }; -void tree_url_node_init(void) +void tree_url_node_init(const char *folder_icon_name) { struct icon_entry *entry; char icon_name[MAX_ICON_NAME_LEN]; @@ -112,7 +112,7 @@ void tree_url_node_init(void) return; initialised = true; - folder_icon = tree_load_icon(tree_directory_icon_name); + folder_icon = tree_load_icon(folder_icon_name); entry = icon_table; do { diff --git a/desktop/tree_url_node.h b/desktop/tree_url_node.h index 4bee73ebc..fbecf7f28 100644 --- a/desktop/tree_url_node.h +++ b/desktop/tree_url_node.h @@ -27,7 +27,7 @@ #include "desktop/tree.h" -void tree_url_node_init(void); +void tree_url_node_init(const char *folder_icon_name); struct node *tree_create_URL_node(struct tree *tree, struct node *parent, const char *url, const char *title, tree_node_user_callback, void *callback_data); -- cgit v1.2.3