mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-23 04:26:50 +03:00
Make READ_ONLY flag a combinator for NO_MOVES and NO_DELETES. Implement NO_DELETES.
This commit is contained in:
parent
c010535fbe
commit
26befde81c
@ -469,16 +469,30 @@ nserror treeview_create_node_entry(struct treeview *tree,
|
||||
}
|
||||
|
||||
|
||||
/* Exported interface, documented in treeview.h */
|
||||
nserror treeview_delete_node(struct treeview *tree, struct treeview_node *n)
|
||||
/**
|
||||
* Delete a treeview node
|
||||
*
|
||||
* \param tree Treeview object to delete node from
|
||||
* \param n Node to delete
|
||||
* \param interaction Delete is result of user interaction with treeview
|
||||
* \return NSERROR_OK on success, appropriate error otherwise
|
||||
*
|
||||
* Will emit folder or entry deletion msg callback.
|
||||
*/
|
||||
static nserror treeview_delete_node_internal(struct treeview *tree,
|
||||
struct treeview_node *n, bool interaction)
|
||||
{
|
||||
struct treeview_node_msg msg;
|
||||
msg.msg = TREE_MSG_NODE_DELETE;
|
||||
struct treeview_node *p;
|
||||
|
||||
if (interaction && (tree->flags & TREEVIEW_NO_DELETES)) {
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/* Destroy children first */
|
||||
while (n->children != NULL) {
|
||||
treeview_delete_node(tree, n->children);
|
||||
treeview_delete_node_internal(tree, n->children, interaction);
|
||||
}
|
||||
|
||||
/* Unlink node from tree */
|
||||
@ -527,6 +541,13 @@ nserror treeview_delete_node(struct treeview *tree, struct treeview_node *n)
|
||||
}
|
||||
|
||||
|
||||
/* Exported interface, documented in treeview.h */
|
||||
nserror treeview_delete_node(struct treeview *tree, struct treeview_node *n)
|
||||
{
|
||||
return treeview_delete_node_internal(tree, n, false);
|
||||
}
|
||||
|
||||
|
||||
/* Exported interface, documented in treeview.h */
|
||||
nserror treeview_create(struct treeview **tree,
|
||||
const struct treeview_callback_table *callbacks,
|
||||
@ -614,7 +635,7 @@ nserror treeview_destroy(struct treeview *tree)
|
||||
assert(tree != NULL);
|
||||
|
||||
/* Destroy nodes */
|
||||
treeview_delete_node(tree, tree->root);
|
||||
treeview_delete_node_internal(tree, tree->root, false);
|
||||
|
||||
/* Destroy feilds */
|
||||
for (f = 0; f <= tree->n_fields; f++) {
|
||||
@ -1086,7 +1107,7 @@ static bool treeview_node_selection_walk_cb(struct treeview_node *node,
|
||||
|
||||
case TREEVIEW_WALK_DELETE_SELECTION:
|
||||
if (node->flags & TREE_NODE_SELECTED) {
|
||||
treeview_delete_node(sw->tree, node);
|
||||
treeview_delete_node_internal(sw->tree, node, true);
|
||||
changed = true;
|
||||
}
|
||||
break;
|
||||
|
@ -44,10 +44,11 @@ typedef enum {
|
||||
} treeview_node_create_flags; /**< Relationship between nodes */
|
||||
|
||||
typedef enum {
|
||||
TREEVIEW_NO_FLAGS = (0), /* No flags set */
|
||||
TREEVIEW_READ_ONLY = (1 << 0), /* No edits */
|
||||
TREEVIEW_NO_MOVES = (1 << 1), /* No node drags */
|
||||
TREEVIEW_DELETE_EMPTY_DIRS = (1 << 2) /* Del. dirs on empty */
|
||||
TREEVIEW_NO_FLAGS = (0), /**< No flags set */
|
||||
TREEVIEW_NO_MOVES = (1 << 0), /**< No node drags */
|
||||
TREEVIEW_NO_DELETES = (1 << 1), /**< No node deletes */
|
||||
TREEVIEW_READ_ONLY = TREEVIEW_NO_MOVES | TREEVIEW_NO_DELETES,
|
||||
TREEVIEW_DEL_EMPTY_DIRS = (1 << 2) /**< Delete dirs on empty */
|
||||
} treeview_flags;
|
||||
|
||||
enum treeview_msg {
|
||||
|
Loading…
Reference in New Issue
Block a user