* src/DisplayTabs/_EmbeddedList.py: during rebuild, don't do select change
* src/DisplayTabs/_ButtonTab.py: avoid double call of selection_change * src/DisplayTabs/_GrampsTab.py: method to add db connects, and set connects * src/Editors/_EditPrimary.py: on add tab pass db connection method * src/Editors/_EditSecondary.py: on add tab pass db connection method * src/Editors/_EditReference.py: on add tab pass db connection method * src/DisplayTabs/_GalleryTab.py: use new structure to correctly update displaytab 2007-10-22 Benny Malengier <benny.malengier@gramps-project.org> svn: r9234
This commit is contained in:
parent
026d966e9f
commit
c51d00bc77
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
2007-10-22 Benny Malengier <benny.malengier@gramps-project.org>
|
||||
* src/DisplayTabs/_EmbeddedList.py: during rebuild, don't do select change
|
||||
* src/DisplayTabs/_ButtonTab.py: avoid double call of selection_change
|
||||
* src/DisplayTabs/_GrampsTab.py: method to add db connects, and set connects
|
||||
* src/Editors/_EditPrimary.py: on add tab pass db connection method
|
||||
* src/Editors/_EditSecondary.py: on add tab pass db connection method
|
||||
* src/Editors/_EditReference.py: on add tab pass db connection method
|
||||
* src/DisplayTabs/_GalleryTab.py: use new structure to correctly update
|
||||
displaytab
|
||||
|
||||
2007-10-22 Benny Malengier <benny.malengier@gramps-project.org>
|
||||
* src/GrampsDb/_GrampsInMemDB.py: xml load/save not working, fixed #1319
|
||||
|
||||
|
@ -82,6 +82,7 @@ class ButtonTab(GrampsTab):
|
||||
@param name: Notebook label name
|
||||
@type name: str/unicode
|
||||
"""
|
||||
self.dirty_selection = False
|
||||
GrampsTab.__init__(self,dbstate, uistate, track, name)
|
||||
self.tooltips = gtk.Tooltips()
|
||||
self.create_buttons(share_button)
|
||||
@ -182,6 +183,10 @@ class ButtonTab(GrampsTab):
|
||||
"""
|
||||
# Comparing to None is important, as empty strings
|
||||
# and 0 can be returned
|
||||
# This method is called as callback on change, and can be called
|
||||
# explicitly, dirty_selection must make sure they do not interact
|
||||
if self.dirty_selection:
|
||||
return
|
||||
if self.get_selected() != None:
|
||||
self.edit_btn.set_sensitive(True)
|
||||
if not self.dbstate.db.readonly:
|
||||
|
@ -354,6 +354,8 @@ class EmbeddedList(ButtonTab):
|
||||
Rebuilds the data in the database by creating a new model,
|
||||
using the build_model function passed at creation time.
|
||||
"""
|
||||
#during rebuild, don't do _selection_changed
|
||||
self.dirty_selection = True
|
||||
try:
|
||||
self.model = self.build_model(self.get_data(), self.dbstate.db)
|
||||
except AttributeError, msg:
|
||||
@ -363,4 +365,6 @@ class EmbeddedList(ButtonTab):
|
||||
|
||||
self.tree.set_model(self.model)
|
||||
self._set_label()
|
||||
#model and tree are reset, allow _selection_changed again, and force it
|
||||
self.dirty_selection = False
|
||||
self._selection_changed()
|
||||
|
@ -78,9 +78,12 @@ class GalleryTab(ButtonTab):
|
||||
|
||||
self.rebuild()
|
||||
self.show_all()
|
||||
|
||||
#connect external remove of object to rebuild
|
||||
self.dbstate.db.connect('media-delete',self.media_delete)
|
||||
|
||||
def connect_db_signals(self):
|
||||
#connect external remove/change of object to rebuild of grampstab
|
||||
self._add_db_signal('media-delete', self.media_delete)
|
||||
self._add_db_signal('media-rebuild', self.rebuild)
|
||||
self._add_db_signal('media-update', self.media_update)
|
||||
|
||||
def double_click(self, obj, event):
|
||||
"""
|
||||
@ -306,18 +309,34 @@ class GalleryTab(ButtonTab):
|
||||
Note: delete of object will cause reference on database to be removed,
|
||||
so this method need not do this
|
||||
"""
|
||||
rebuild = False
|
||||
ref_handles = [x.ref for x in self.media_list]
|
||||
for handle in del_media_handle_list :
|
||||
pos = None
|
||||
try :
|
||||
pos = ref_handles.index(handle)
|
||||
except ValueError :
|
||||
continue
|
||||
while 1:
|
||||
pos = None
|
||||
try :
|
||||
pos = ref_handles.index(handle)
|
||||
except ValueError :
|
||||
break
|
||||
|
||||
if pos is not None:
|
||||
#oeps, we need to remove this reference, and rebuild tab
|
||||
self.media_list.remove(self.media_list[pos])
|
||||
if pos is not None:
|
||||
#oeps, we need to remove this reference, and rebuild tab
|
||||
del self.media_list[pos]
|
||||
del ref_handles[pos]
|
||||
rebuild = True
|
||||
if rebuild:
|
||||
self.rebuild()
|
||||
|
||||
def media_update(self, upd_media_handle_list):
|
||||
"""
|
||||
Outside of this tab media objects have been changed. Check if tab
|
||||
and object must be changed.
|
||||
"""
|
||||
ref_handles = [x.ref for x in self.media_list]
|
||||
for handle in upd_media_handle_list :
|
||||
if handle in ref_handles:
|
||||
self.rebuild()
|
||||
break
|
||||
|
||||
def _set_dnd(self):
|
||||
"""
|
||||
|
@ -66,6 +66,8 @@ class GrampsTab(gtk.HBox):
|
||||
self.track = track
|
||||
self.changed = False
|
||||
|
||||
self._add_db_signal = None
|
||||
|
||||
# save name used for notebook label, and build the widget used
|
||||
# for the label
|
||||
|
||||
@ -135,6 +137,27 @@ class GrampsTab(gtk.HBox):
|
||||
"""
|
||||
return self.label_container
|
||||
|
||||
def add_db_signal_callback(self, add_db_signal):
|
||||
"""
|
||||
The grampstab must be able to react to database signals, however
|
||||
on destroy of the editor to which the tab is attached, these signals
|
||||
must be disconnected.
|
||||
This method sets the method with which to add database signals on tabs,
|
||||
typically EditPrimary and EditSecondary add tabs, and have methods to
|
||||
connect signals and register them so they are correctly disconnected
|
||||
on close
|
||||
"""
|
||||
self._add_db_signal = add_db_signal
|
||||
self.connect_db_signals()
|
||||
|
||||
def connect_db_signals(self):
|
||||
"""
|
||||
Function to connect db signals to GrampsTab methods. This function
|
||||
should be overridden in the derived class.
|
||||
It is called when the add_db_signal method is added.
|
||||
"""
|
||||
pass
|
||||
|
||||
def _set_label(self):
|
||||
"""
|
||||
Updates the label based of if the tab contains information. Tabs
|
||||
|
@ -99,6 +99,7 @@ class EditPrimary(ManagedWindow.ManagedWindow):
|
||||
|
||||
def _add_tab(self,notebook,page):
|
||||
notebook.insert_page(page, page.get_tab_widget())
|
||||
page.add_db_signal_callback(self._add_db_signal)
|
||||
return page
|
||||
|
||||
def _cleanup_on_exit(self):
|
||||
|
@ -100,6 +100,7 @@ class EditReference(ManagedWindow.ManagedWindow):
|
||||
|
||||
def _add_tab(self,notebook,page):
|
||||
notebook.insert_page(page, page.get_tab_widget())
|
||||
page.add_db_signal_callback(self._add_db_signal)
|
||||
return page
|
||||
|
||||
def _add_db_signal(self, name, callback):
|
||||
|
@ -96,6 +96,7 @@ class EditSecondary(ManagedWindow.ManagedWindow):
|
||||
|
||||
def _add_tab(self,notebook,page):
|
||||
notebook.insert_page(page, page.get_tab_widget())
|
||||
page.add_db_signal_callback(self._add_db_signal)
|
||||
return page
|
||||
|
||||
def _cleanup_on_exit(self):
|
||||
|
Loading…
Reference in New Issue
Block a user