Make default hotlist folder persistent across sessions
svn path=/trunk/netsurf/; revision=13141
This commit is contained in:
parent
10237e0bde
commit
dd6d1ce527
|
@ -479,6 +479,6 @@ bool hotlist_set_default_folder(bool clear)
|
|||
tree_clear_default_folder_node(hotlist_tree);
|
||||
return true;
|
||||
} else {
|
||||
return tree_set_default_folder_node(hotlist_tree);
|
||||
return tree_set_default_folder_node(hotlist_tree, NULL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,6 +118,7 @@ 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
|
||||
|
@ -1396,6 +1397,18 @@ bool tree_node_is_folder(struct node *node)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
@ -1567,13 +1580,18 @@ struct node *tree_get_default_folder_node(struct tree *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)
|
||||
bool tree_set_default_folder_node(struct tree *tree, struct node *node)
|
||||
{
|
||||
struct node *sel_node;
|
||||
|
||||
sel_node = tree_get_selected_node(tree->root);
|
||||
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)) {
|
||||
|
@ -1581,6 +1599,7 @@ bool tree_set_default_folder_node(struct tree *tree)
|
|||
}
|
||||
|
||||
tree->def_folder = sel_node;
|
||||
sel_node->def_folder = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1592,7 +1611,13 @@ bool tree_set_default_folder_node(struct tree *tree)
|
|||
*/
|
||||
void tree_clear_default_folder_node(struct tree *tree)
|
||||
{
|
||||
tree->def_folder = NULL;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -166,6 +166,7 @@ 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);
|
||||
|
@ -175,7 +176,7 @@ 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);
|
||||
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 */
|
||||
|
|
|
@ -576,6 +576,7 @@ static void tree_url_load_directory(xmlNode *ul, struct tree *tree,
|
|||
char *title;
|
||||
struct node *dir;
|
||||
xmlNode *xmlnode;
|
||||
xmlChar *id;
|
||||
|
||||
assert(ul != NULL);
|
||||
assert(directory != NULL);
|
||||
|
@ -595,6 +596,7 @@ static void tree_url_load_directory(xmlNode *ul, struct tree *tree,
|
|||
|
||||
} else if (strcmp((const char *)xmlnode->name, "h4") == 0) {
|
||||
/* directory */
|
||||
bool dir_is_default = false;
|
||||
title = (char *) xmlNodeGetContent(xmlnode );
|
||||
if (!title) {
|
||||
warn_user("TreeLoadError", "(Empty <h4> "
|
||||
|
@ -613,6 +615,13 @@ static void tree_url_load_directory(xmlNode *ul, struct tree *tree,
|
|||
warn_user("TreeLoadError", "(Expected "
|
||||
"<ul> not present.)");
|
||||
return;
|
||||
} else {
|
||||
id = xmlGetProp(xmlnode, "id");
|
||||
if (id != NULL) {
|
||||
if(strcmp((const char *)id, "default") == 0)
|
||||
dir_is_default = true;
|
||||
xmlFree(id);
|
||||
}
|
||||
}
|
||||
|
||||
dir = tree_create_folder_node(tree, directory, title,
|
||||
|
@ -622,6 +631,10 @@ static void tree_url_load_directory(xmlNode *ul, struct tree *tree,
|
|||
return;
|
||||
}
|
||||
|
||||
if(dir_is_default == true) {
|
||||
tree_set_default_folder_node(tree, dir);
|
||||
}
|
||||
|
||||
if (callback != NULL)
|
||||
tree_set_node_user_callback(dir, callback,
|
||||
callback_data);
|
||||
|
@ -738,6 +751,8 @@ static bool tree_url_save_directory(struct node *directory, xmlNode *node)
|
|||
ul = xmlNewChild(node, NULL, (const xmlChar *)"ul", NULL);
|
||||
if (ul == NULL)
|
||||
return false;
|
||||
if (tree_node_is_default(directory) == true)
|
||||
xmlSetProp(ul, "id", "default");
|
||||
|
||||
for (child = tree_node_get_child(directory); child;
|
||||
child = tree_node_get_next(child)) {
|
||||
|
@ -767,12 +782,6 @@ static bool tree_url_save_directory(struct node *directory, xmlNode *node)
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Perform a save to a specified file in the form of a html page
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue