From bb4bda0b3a2dd71b2a8e248e33f7f63788171b9d Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Fri, 17 Dec 2010 11:10:22 +0000 Subject: When a hotlist entry edit ends by cancelling, rather than confirming the change, end the whole edit and don't pass onto next element for edit. svn path=/trunk/netsurf/; revision=11085 --- desktop/hotlist.c | 6 +++++- desktop/tree.c | 3 ++- desktop/tree.h | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'desktop') diff --git a/desktop/hotlist.c b/desktop/hotlist.c index cb5362050..dd29b6a84 100644 --- a/desktop/hotlist.c +++ b/desktop/hotlist.c @@ -64,10 +64,14 @@ static node_callback_resp hotlist_node_callback(void *user_data, const char *text; char *norm_text; bool is_folder = tree_node_is_folder(node); + bool cancelled = false; switch (msg_data->msg) { + case NODE_ELEMENT_EDIT_CANCELLED: + cancelled = true; + /* fall through */ case NODE_ELEMENT_EDIT_FINISHED: - if (creating_node && + if (creating_node && !cancelled && (is_folder == false) && (msg_data->flag == TREE_ELEMENT_TITLE)) { tree_url_node_edit_url(hotlist_tree, node); diff --git a/desktop/tree.c b/desktop/tree.c index cb3c915ff..1f7d8ffc3 100644 --- a/desktop/tree.c +++ b/desktop/tree.c @@ -879,7 +879,8 @@ static void tree_stop_edit(struct tree *tree, bool keep_changes) tree_recalculate_size(tree); if (element->parent->user_callback != NULL) { - msg_data.msg = NODE_ELEMENT_EDIT_FINISHED; + msg_data.msg = keep_changes ? NODE_ELEMENT_EDIT_FINISHED : + NODE_ELEMENT_EDIT_CANCELLED; msg_data.flag = element->flag; msg_data.node = element->parent; element->parent->user_callback(element->parent->callback_data, diff --git a/desktop/tree.h b/desktop/tree.h index 1703c3784..032b5e213 100644 --- a/desktop/tree.h +++ b/desktop/tree.h @@ -78,6 +78,7 @@ typedef enum { NODE_DELETE_ELEMENT_IMG, /**< The bitmap or icon of a node is * being deleted */ NODE_LAUNCH, /**< The node has been launched */ + NODE_ELEMENT_EDIT_CANCELLED, /**< Editing opperation cancelled. */ NODE_ELEMENT_EDIT_FINISHING, /**< New text has to be accepted * or rejected. */ NODE_ELEMENT_EDIT_FINISHED /**< Editing of a node_element has -- cgit v1.2.3