From 4a2e1058b013a7a276a6c451f550eaf8e41b62f7 Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Wed, 29 Aug 2007 12:50:37 +0000 Subject: [PATCH] clean some window management bugs svn: r8888 --- ChangeLog | 7 +++++++ src/DisplayTabs/_NoteTab.py | 7 ++++--- src/Editors/_EditMediaRef.py | 13 ++++++++++++- src/Editors/_EditNote.py | 7 +++++++ src/Editors/_EditReference.py | 3 ++- src/ManagedWindow.py | 9 ++++++++- 6 files changed, 40 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1e14cb008..b5552f2dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-08-29 Benny Malengier + * src/Editors/_EditNote.py : ManagedWindow error, bad naming in menu + * src/Editors/_EditMediaRef.py : Bad naming in menu + * src/DisplayTabs/_NoteTab.py : ManagedWindow error, bad track + * src/Editors/_EditReference.py: Always give an id to ManagedWindow + * src/ManagedWindow.py : Add comment and better error message + 2007-08-29 Benny Malengier * src/Editors/_EditPerson.py: intendation error diff --git a/src/DisplayTabs/_NoteTab.py b/src/DisplayTabs/_NoteTab.py index cbcc14963..398b6ac43 100644 --- a/src/DisplayTabs/_NoteTab.py +++ b/src/DisplayTabs/_NoteTab.py @@ -108,8 +108,9 @@ class NoteTab(EmbeddedList): if self.notetype : note.set_type(self.notetype) try: - EditNote(self.dbstate, self.uistate, [], note, self.add_callback, - self.callertitle, extratype = [self.notetype]) + EditNote(self.dbstate, self.uistate, self.track, + note, self.add_callback, + self.callertitle, extratype = [self.notetype]) except Errors.WindowActiveError: pass @@ -123,7 +124,7 @@ class NoteTab(EmbeddedList): if handle: note = self.dbstate.db.get_note_from_handle(handle) try: - EditNote(self.dbstate, self.uistate, [], note, + EditNote(self.dbstate, self.uistate, self.track, note, self.edit_callback, self.callertitle, extratype = [self.notetype] ) except Errors.WindowActiveError: diff --git a/src/Editors/_EditMediaRef.py b/src/Editors/_EditMediaRef.py index c22cc9162..534c31339 100644 --- a/src/Editors/_EditMediaRef.py +++ b/src/Editors/_EditMediaRef.py @@ -132,7 +132,18 @@ class EditMediaRef(EditReference): self.top.get_widget("type").set_text(mt) else: self.top.get_widget("type").set_text("") - + + def build_menu_names(self, person): + """ + Provides the information needed by the base class to define the + window management menu entries. + """ + if self.source: + submenu_label = _('Media: %s') % self.source.get_gramps_id() + else: + submenu_label = _('New Media') + return (_('Media Reference Editor'),submenu_label) + def button_press_event(self, obj, event): if event.button==1 and event.type == gtk.gdk._2BUTTON_PRESS: self.view_media(obj) diff --git a/src/Editors/_EditNote.py b/src/Editors/_EditNote.py index 1e027675f..d7318c7c9 100644 --- a/src/Editors/_EditNote.py +++ b/src/Editors/_EditNote.py @@ -273,6 +273,13 @@ class EditNote(EditPrimary): log.debug("Initial Note: %s" % buffer.get_text()) else: self.empty = True + + def build_menu_names(self, person): + """ + Provides the information needed by the base class to define the + window management menu entries. + """ + return (_('Edit Note'), self.get_menu_title()) def on_textview_key_press_event(self, textview, event): """Handle shortcuts in the TextView.""" diff --git a/src/Editors/_EditReference.py b/src/Editors/_EditReference.py index 7f3086995..88b3b93c1 100644 --- a/src/Editors/_EditReference.py +++ b/src/Editors/_EditReference.py @@ -118,7 +118,8 @@ class EditReference(ManagedWindow.ManagedWindow): pass def build_window_key(self,sourceref): - if self.source: + #the window key for managedwindow identification. No need to return None + if self.source and self.source.get_handle(): return self.source.get_handle() else: return id(self) diff --git a/src/ManagedWindow.py b/src/ManagedWindow.py index 6a41b45e4..447940fca 100644 --- a/src/ManagedWindow.py +++ b/src/ManagedWindow.py @@ -187,13 +187,18 @@ class GrampsWindowManager: # if the item is identifiable then we need to remember # its id so that in the future we recall this window # instead of spawning a new one + # So people can make as many windows of type item.window_id = None + # Use this for add dialogs, where users may add as many values + # simultaneously as they want. + # Actually, we should do this away, as requiring at least id(obj) + # is not a big requirement ? if item.window_id: self.id2item[item.window_id] = item # Make sure we have a track parent_item = self.get_item_from_track(track) assert type(parent_item) == list or track == [], \ - "Gwm: add_item: Incorrect track." + "Gwm: add_item: Incorrect track - Is parent not a leaf?" # Prepare a new item, depending on whether it is branch or leaf if item.submenu_label: @@ -316,6 +321,8 @@ class ManagedWindow: @param obj The object that is used to id the managed window, The inheriting object needs a method build_menu_names(self,obj) which works on this obj and creates menu labels + for use in the Gramps Window Menu. + If self.submenu_label ='' then leaf, otherwise branch """