From 59b7a9a498483146e92e809d41b0d269bebd77a6 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Tue, 9 Jul 2002 13:07:17 +0000 Subject: [PATCH] Creating a new node uses a dialog, not in-place editing. git-svn-id: http://dom-editor.googlecode.com/svn/trunk@352 ef21e15d-ca94-4315-9c45-0d95b1b2e117 --- Dome/GUIView.py | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/Dome/GUIView.py b/Dome/GUIView.py index 3460bcd..148c993 100644 --- a/Dome/GUIView.py +++ b/Dome/GUIView.py @@ -397,6 +397,30 @@ class GUIView(Display): do_search, ['XPath:'], '(@CURRENT@ is the current node\'s value)') + def show_add_box(self, action): + if action[0] == 'i': + text = 'Insert' + elif action[0] == 'a': + text = 'Append' + elif action[0] == 'o': + text = 'Open' + elif action[0] == 'e': + text = 'Open at end' + else: + assert 0 + if action[1] == 'e': + text += ' element' + prompt = 'Node name' + elif action[1] == 't': + text += ' text' + prompt = 'Text' + else: + assert 0 + + def cb(value): + self.view.may_record(['add_node', action, value]) + GetArg('Add node', cb, [prompt], text) + def new_name(self): cur = self.view.get_current() if cur.nodeType == Node.ELEMENT_NODE: @@ -405,43 +429,35 @@ class GUIView(Display): def menu_insert_element(self): "Insert element" - self.view.may_record(['add_node', 'ie', self.new_name()]) - self.show_editbox() + self.show_add_box('ie') def menu_append_element(self): "Append element" - self.view.may_record(['add_node', 'ae', self.new_name()]) - self.show_editbox() + self.show_add_box('ae') def menu_open_element(self): "Open element" - self.view.may_record(['add_node', 'oe', self.new_name()]) - self.show_editbox() + self.show_add_box('oe') def menu_open_element_end(self): "Open element at end" - self.view.may_record(['add_node', 'ee', self.new_name()]) - self.show_editbox() + self.show_add_box('ee') def menu_insert_text(self): "Insert text" - self.view.may_record(['add_node', 'it', '']) - self.show_editbox() + self.show_add_box('it') def menu_append_text(self): "Append text" - self.view.may_record(['add_node', 'at', '']) - self.show_editbox() + self.show_add_box('at') def menu_open_text(self): "Open text" - self.view.may_record(['add_node', 'ot', '']) - self.show_editbox() + self.show_add_box('ot') def menu_open_text_end(self): "Open text at end" - self.view.may_record(['add_node', 'et', '']) - self.show_editbox() + self.show_add_box('et') def menu_close_window(self): self.window.destroy() -- 2.11.4.GIT