diff --git a/content/fetchers/resource.c b/content/fetchers/resource.c index 808bd8f3a..3de6f3c2c 100644 --- a/content/fetchers/resource.c +++ b/content/fetchers/resource.c @@ -85,6 +85,7 @@ static const char *fetch_resource_paths[] = { "icons/arrow-l.png", "icons/content.png", "icons/directory.png", + "icons/directory2.png", "icons/search.png" }; static struct fetch_resource_map_entry { diff --git a/desktop/hotlist.c b/desktop/hotlist.c index 6671a77d3..838b41b5e 100644 --- a/desktop/hotlist.c +++ b/desktop/hotlist.c @@ -322,9 +322,11 @@ static nserror hotlist_add_entry_internal(nsurl *url, const char *title, */ static nserror hotlist_add_folder_internal( const char *title, treeview_node *relation, - enum treeview_relationship rel, struct hotlist_folder **folder) + enum treeview_relationship rel, struct hotlist_folder **folder, + bool default_folder) { struct hotlist_folder *f; + treeview_node_options_flags flags = TREE_OPTION_NONE; treeview_node *n; nserror err; @@ -346,10 +348,14 @@ static nserror hotlist_add_folder_internal( } f->data.value_len = strlen(title); + if (hl_ctx.built) + flags |= TREE_OPTION_SUPPRESS_RESIZE | + TREE_OPTION_SUPPRESS_REDRAW; + if (default_folder) + flags |= TREE_OPTION_SPECIAL_DIR; + err = treeview_create_node_folder(hl_ctx.tree, - &n, relation, rel, &f->data, f, hl_ctx.built ? - TREE_OPTION_NONE : TREE_OPTION_SUPPRESS_RESIZE | - TREE_OPTION_SUPPRESS_REDRAW); + &n, relation, rel, &f->data, f, flags); if (err != NSERROR_OK) { free((void*)f->data.value); /* Eww */ free(f); @@ -658,16 +664,7 @@ nserror hotlist_load_directory_cb(dom_node *node, void *ctx) struct hotlist_folder *f; hotlist_load_ctx new_ctx; treeview_node *rel; - - title = dom_string_data(current_ctx->title); - - /* Add folder node */ - err = hotlist_add_folder_internal(title, current_ctx->rel, - current_ctx->relshp, &f); - if (err != NSERROR_OK) { - dom_string_unref(name); - return NSERROR_NOMEM; - } + bool default_folder = false; /* Check if folder should be default folder */ error = dom_element_get_attribute(node, corestring_dom_id, &id); @@ -677,11 +674,24 @@ nserror hotlist_load_directory_cb(dom_node *node, void *ctx) } if (id != NULL) { if (dom_string_lwc_isequal(id, corestring_lwc_default)) - hl_ctx.default_folder = f; + default_folder = true; dom_string_unref(id); } + title = dom_string_data(current_ctx->title); + + /* Add folder node */ + err = hotlist_add_folder_internal(title, current_ctx->rel, + current_ctx->relshp, &f, default_folder); + if (err != NSERROR_OK) { + dom_string_unref(name); + return NSERROR_NOMEM; + } + + if (default_folder) + hl_ctx.default_folder = f; + rel = f->folder; current_ctx->rel = rel; current_ctx->relshp = TREE_REL_NEXT_SIBLING; @@ -833,7 +843,7 @@ static nserror hotlist_generate(void) /* First make "NetSurf" folder for defualt entries */ title = "NetSurf"; err = hotlist_add_folder_internal(title, NULL, - TREE_REL_FIRST_CHILD, &f); + TREE_REL_FIRST_CHILD, &f, false); if (err != NSERROR_OK) { return err; } @@ -1223,7 +1233,7 @@ nserror hotlist_add_url(nsurl *url) const char *temp = messages_get("HotlistDefaultFolderName"); struct hotlist_folder *f; err = hotlist_add_folder_internal(temp, NULL, - TREE_REL_FIRST_CHILD, &f); + TREE_REL_FIRST_CHILD, &f, true); if (err != NSERROR_OK) return err; @@ -1451,7 +1461,7 @@ nserror hotlist_add_folder(const char *title, bool at_y, int y) return err; } - err = hotlist_add_folder_internal(title, relation, rel, &f); + err = hotlist_add_folder_internal(title, relation, rel, &f, false); if (err != NSERROR_OK) { return err; } diff --git a/desktop/treeview.c b/desktop/treeview.c index 767f1c714..0681b95ec 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -66,7 +66,8 @@ struct treeview_field { enum treeview_node_flags { TREE_NODE_NONE = 0, /**< No node flags set */ TREE_NODE_EXPANDED = (1 << 0), /**< Whether node is expanded */ - TREE_NODE_SELECTED = (1 << 1) /**< Whether node is selected */ + TREE_NODE_SELECTED = (1 << 1), /**< Whether node is selected */ + TREE_NODE_SPECIAL = (1 << 2) /**< Render as special node */ }; enum treeview_target_pos { @@ -194,6 +195,7 @@ enum treeview_resource_id { TREE_RES_ARROW = 0, TREE_RES_CONTENT, TREE_RES_FOLDER, + TREE_RES_FOLDER_SPECIAL, TREE_RES_SEARCH, TREE_RES_LAST }; @@ -201,6 +203,7 @@ static struct treeview_resource treeview_res[TREE_RES_LAST] = { { "resource:icons/arrow-l.png", NULL, 0, false }, { "resource:icons/content.png", NULL, 0, false }, { "resource:icons/directory.png", NULL, 0, false }, + { "resource:icons/directory2.png", NULL, 0, false }, { "resource:icons/search.png", NULL, 0, false } }; /**< Treeview content resources */ @@ -546,7 +549,8 @@ nserror treeview_create_node_folder(treeview *tree, return NSERROR_NOMEM; } - n->flags = TREE_NODE_NONE; + n->flags = (flags & TREE_OPTION_SPECIAL_DIR) ? + TREE_NODE_SPECIAL : TREE_NODE_NONE; n->type = TREE_NODE_FOLDER; n->height = tree_g.line_height; @@ -1791,7 +1795,9 @@ void treeview_redraw(treeview *tree, const int x, const int y, /* Render icon */ if (node->type == TREE_NODE_ENTRY) res = TREE_RES_CONTENT; - else if (node->type == TREE_NODE_FOLDER) + else if (node->flags & TREE_NODE_SPECIAL) + res = TREE_RES_FOLDER_SPECIAL; + else res = TREE_RES_FOLDER; if (treeview_res[res].ready) { diff --git a/desktop/treeview.h b/desktop/treeview.h index 8f5c44ebd..6fda230b1 100644 --- a/desktop/treeview.h +++ b/desktop/treeview.h @@ -46,8 +46,9 @@ enum treeview_relationship { typedef enum { TREE_OPTION_NONE = (0), /* No flags set */ - TREE_OPTION_SUPPRESS_RESIZE = (1 << 0), /* Suppress callback */ - TREE_OPTION_SUPPRESS_REDRAW = (1 << 1) /* Suppress callback */ + TREE_OPTION_SPECIAL_DIR = (1 << 0), /* Special folder */ + TREE_OPTION_SUPPRESS_RESIZE = (1 << 1), /* Suppress callback */ + TREE_OPTION_SUPPRESS_REDRAW = (1 << 2) /* Suppress callback */ } treeview_node_options_flags; /**< Node change handling options */ typedef enum {