clean some window management bugs

svn: r8888
This commit is contained in:
Benny Malengier 2007-08-29 12:50:37 +00:00
parent fb5541f635
commit 4a2e1058b0
6 changed files with 40 additions and 6 deletions

View File

@ -1,3 +1,10 @@
2007-08-29 Benny Malengier <bm@cage.ugent.be>
* 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 <bm@cage.ugent.be>
* src/Editors/_EditPerson.py: intendation error

View File

@ -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:

View File

@ -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)

View File

@ -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."""

View File

@ -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)

View File

@ -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
"""