summaryrefslogtreecommitdiff
path: root/desktop/tree.c
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2011-11-10 12:22:48 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2011-11-10 12:22:48 +0000
commit0b6e5da662decfc08f56bd28a8c7bc1f4fe90780 (patch)
tree73475a2ff7a584f43702f45e1d774586037204ad /desktop/tree.c
parent87c5f14c08fba088484c7925ac0d7b74f6c0521f (diff)
downloadnetsurf-0b6e5da662decfc08f56bd28a8c7bc1f4fe90780.tar.gz
netsurf-0b6e5da662decfc08f56bd28a8c7bc1f4fe90780.tar.bz2
Allow setting a default folder in the tree for hotlist entries to go into. Frontends
will need to be updated to use hotlist_set_default_folder() if they want to use this functionality. svn path=/trunk/netsurf/; revision=13139
Diffstat (limited to 'desktop/tree.c')
-rw-r--r--desktop/tree.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/desktop/tree.c b/desktop/tree.c
index bf7b643b9..1da1f7248 100644
--- a/desktop/tree.c
+++ b/desktop/tree.c
@@ -159,6 +159,7 @@ struct tree {
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 tree_set_icon_dir(char *icon_dir)
@@ -1034,6 +1035,8 @@ static void tree_delete_node_internal(struct tree *tree, struct node *node,
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;
@@ -1545,6 +1548,55 @@ tree_drag_type tree_drag_status(struct tree *tree)
/**
+ * 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
+ * \return success
+ */
+bool tree_set_default_folder_node(struct tree *tree)
+{
+ struct node *sel_node;
+
+ sel_node = tree_get_selected_node(tree->root);
+
+ if((sel_node == NULL) ||
+ (tree_node_is_folder(sel_node) == false)) {
+ return false;
+ }
+
+ tree->def_folder = sel_node;
+ 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)
+{
+ tree->def_folder = NULL;
+}
+
+
+/**
* Returns the first child of a node
*
* \param node the node to get the child of