From 112f23efa7e91f5d8c17f3a4d5bebf2f9fe7dcdf Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Wed, 11 Dec 2002 15:25:12 +0000 Subject: [PATCH] Choose type to create from new box, not by key. Make panning work again. git-svn-id: http://dom-editor.googlecode.com/svn/branches/Gtk2@464 ef21e15d-ca94-4315-9c45-0d95b1b2e117 --- Dome/AppRun | 2 +- Dome/Display2.py | 9 +++++--- Dome/GUIView.py | 68 +++++++++++++++++++++++++++++++++++++++++--------------- Dome/View.py | 3 +++ 4 files changed, 60 insertions(+), 22 deletions(-) diff --git a/Dome/AppRun b/Dome/AppRun index a83f476..2e054de 100755 --- a/Dome/AppRun +++ b/Dome/AppRun @@ -2,7 +2,7 @@ # vi: set syntax=python : */ import gc -show_leaks = True +show_leaks = False import findrox import rox diff --git a/Dome/Display2.py b/Dome/Display2.py index 151826d..61b0f64 100644 --- a/Dome/Display2.py +++ b/Dome/Display2.py @@ -137,7 +137,7 @@ class Display(g.HBox): g.timeout_remove(self.update_timeout) self.update_timeout = 0 - del self.selection + #del self.selection del self.view del self.parent_window del self.ref_node @@ -171,7 +171,7 @@ class Display(g.HBox): self.update_timeout = 0 if not self.pm: return 0 - print "update" + #print "update" self.pm.draw_rectangle(self.surface.style.bg_gc[g.STATE_NORMAL], True, 0, 0, self.last_alloc[0], self.last_alloc[1]) @@ -357,7 +357,10 @@ class Display(g.HBox): self.backup_ref_node() - self.do_update_now() + if self.update_timeout: + g.timeout_remove(self.update_timeout) + self.update_timeout = 0 + self.update() return 1 diff --git a/Dome/GUIView.py b/Dome/GUIView.py index 85d3416..9ae5c7a 100644 --- a/Dome/GUIView.py +++ b/Dome/GUIView.py @@ -75,21 +75,10 @@ menu = Menu('main', [ ('/Network/Send SOAP message', 'do_soap_send', '', ''), ('/Create', None, '', ''), - ('/Create/Insert element', 'menu_insert_element', '', 'I'), - ('/Create/Append element', 'menu_append_element', '', 'A'), - ('/Create/Open element', 'menu_open_element', '', 'O'), - ('/Create/Open element at end', 'menu_open_element_end', '', 'E'), - - ('/Create/', '', '', ''), - - ('/Create/Insert text node', 'menu_insert_text', '', 'I'), - ('/Create/Append text node', 'menu_append_text', '', 'A'), - ('/Create/Open text node', 'menu_open_text', '', 'O'), - ('/Create/Open text node at end', 'menu_open_text_end', '', 'E'), - - ('/Create/', '', '', ''), - - ('/Create/Attribute', 'menu_show_add_attrib', '', 'plus'), + ('/Create/Insert node', 'menu_insert_element', '', 'I'), + ('/Create/Append node', 'menu_append_element', '', 'A'), + ('/Create/Open node inside', 'menu_open_element', '', 'O'), + ('/Create/Open node at end', 'menu_open_element_end', '', 'E'), ('/Process', None, '', ''), ('/Process/Substitute', 'menu_show_subst', '', 's'), @@ -487,6 +476,26 @@ class GUIView(Display, XDSLoader): GetArg('Rename to:', do, ['New name:']) + def do_create(self, action, nodeType, data): + action = action[0] + qname = True + if nodeType == Node.ELEMENT_NODE: + action += 'e' + elif nodeType == Node.TEXT_NODE: + action += 't' + qname = False + elif nodeType == Node.ATTRIBUTE_NODE: + action += 'a' + + if qname: + # Check name is valid + # XXX: Should be more strict + data = data.strip() + assert '\n' not in data + assert ' ' not in data + + self.view.may_record(['add_node', action, data]) + def show_add_box(self, action): if action[0] == 'i': text = 'Insert' @@ -507,9 +516,32 @@ class GUIView(Display, XDSLoader): else: assert 0 - def cb(value): - self.view.may_record(['add_node', action, value]) - GetArg('Add node', cb, [prompt], text) + box = g.Dialog() + text = g.TextView() + box.vbox.pack_start(text, TRUE, FALSE, 0) + text.set_size_request(400, 200) + box.set_has_separator(False) + + box.add_button(g.STOCK_CANCEL, g.RESPONSE_CANCEL) + box.add_button('Add _Element', Node.ELEMENT_NODE) + box.add_button('Add _Text', Node.TEXT_NODE) + box.add_button('Add _Attribute', Node.ATTRIBUTE_NODE) + box.set_default_response(g.RESPONSE_OK) + text.grab_focus() + def response(box, resp): + if resp == g.RESPONSE_CANCEL: + box.destroy() + return + buffer = text.get_buffer() + start = buffer.get_start_iter() + end = buffer.get_end_iter() + new = buffer.get_text(start, end, True) + if new: + self.do_create(action, resp, new) + box.destroy() + box.connect('response', response) + + box.show_all() def new_name(self): cur = self.view.get_current() diff --git a/Dome/View.py b/Dome/View.py index 36215d5..85ffc80 100644 --- a/Dome/View.py +++ b/Dome/View.py @@ -1193,6 +1193,9 @@ class View: (prefix, localName) = (None, data) namespaceURI = self.model.prefix_to_namespace(self.get_current(), prefix) new = self.model.doc.createElementNS(namespaceURI, data) + elif where[1] == 'a': + self.add_attrib(None, data) + return else: new = self.model.doc.createTextNode(data) -- 2.11.4.GIT