* src/DisplayTabs/_EmbeddedList.py: during rebuild, don't do select change
* src/DisplayTabs/_NoteTab.py: connect db note changes so tab updates * 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 2007-10-21 Benny Malengier <benny.malengier@gramps-project.org> svn: r9229
This commit is contained in:
		@@ -1,3 +1,12 @@
 | 
			
		||||
2007-10-21 Benny Malengier <benny.malengier@gramps-project.org>
 | 
			
		||||
	* src/DisplayTabs/_EmbeddedList.py: during rebuild, don't do select change
 | 
			
		||||
	* src/DisplayTabs/_NoteTab.py: connect db note changes so tab updates
 | 
			
		||||
	* 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
 | 
			
		||||
 | 
			
		||||
2007-10-21 Benny Malengier <benny.malengier@gramps-project.org>
 | 
			
		||||
	* src/Editors/_EditPerson.py: If a family changes, rebuild family backref of all 
 | 
			
		||||
	open editors. issue #1309, causing corrupt database.
 | 
			
		||||
 
 | 
			
		||||
@@ -90,6 +90,7 @@ class ButtonTab(GrampsTab):
 | 
			
		||||
        @param move_buttons: Add up and down button to the Notebook tab or not
 | 
			
		||||
        @type name: bool
 | 
			
		||||
        """
 | 
			
		||||
        self.dirty_selection = False
 | 
			
		||||
        GrampsTab.__init__(self,dbstate, uistate, track, name)
 | 
			
		||||
        self.tooltips = gtk.Tooltips()
 | 
			
		||||
        self.create_buttons(share_button, move_buttons, jump_button)
 | 
			
		||||
@@ -237,6 +238,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 self.jump_btn:
 | 
			
		||||
 
 | 
			
		||||
@@ -402,6 +402,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:
 | 
			
		||||
@@ -413,4 +415,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()
 | 
			
		||||
 
 | 
			
		||||
@@ -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,19 @@ 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 _set_label(self):
 | 
			
		||||
        """
 | 
			
		||||
        Updates the label based of if the tab contains information. Tabs
 | 
			
		||||
@@ -158,4 +173,12 @@ class GrampsTab(gtk.HBox):
 | 
			
		||||
        can be used to add widgets to the interface.
 | 
			
		||||
        """
 | 
			
		||||
        pass
 | 
			
		||||
    
 | 
			
		||||
        
 | 
			
		||||
    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 after the interface is build.
 | 
			
		||||
        """
 | 
			
		||||
        pass
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -80,6 +80,12 @@ class NoteTab(EmbeddedList):
 | 
			
		||||
        EmbeddedList.__init__(self, dbstate, uistate, track, 
 | 
			
		||||
                              _("Notes"), NoteModel, share=True, move=True)
 | 
			
		||||
 | 
			
		||||
    def connect_db_signals(self):
 | 
			
		||||
        #connect external remove/change of object to rebuild of grampstab
 | 
			
		||||
        self._add_db_signal('note-delete', self.note_delete)
 | 
			
		||||
        self._add_db_signal('note-rebuild', self.rebuild)
 | 
			
		||||
        self._add_db_signal('note-update',self.note_update)
 | 
			
		||||
 | 
			
		||||
    def get_editor(self):
 | 
			
		||||
        pass
 | 
			
		||||
 | 
			
		||||
@@ -116,7 +122,7 @@ class NoteTab(EmbeddedList):
 | 
			
		||||
            try:
 | 
			
		||||
                from Editors import EditNote
 | 
			
		||||
                EditNote(self.dbstate, self.uistate, self.track, note,
 | 
			
		||||
                        self.edit_callback, self.callertitle,
 | 
			
		||||
                        callertitle = self.callertitle,
 | 
			
		||||
                        extratype = [self.notetype] )
 | 
			
		||||
            except Errors.WindowActiveError:
 | 
			
		||||
                pass
 | 
			
		||||
@@ -132,7 +138,29 @@ class NoteTab(EmbeddedList):
 | 
			
		||||
    
 | 
			
		||||
    def get_icon_name(self):
 | 
			
		||||
        return 'gramps-notes'
 | 
			
		||||
 | 
			
		||||
    def edit_callback(self, name):
 | 
			
		||||
        self.changed = True
 | 
			
		||||
        self.rebuild()
 | 
			
		||||
        
 | 
			
		||||
    def note_delete(self, del_note_handle_list):
 | 
			
		||||
        """
 | 
			
		||||
        Outside of this tab note objects have been deleted. Check if tab
 | 
			
		||||
        and object must be changed.
 | 
			
		||||
        Note: delete of object will cause reference on database to be removed,
 | 
			
		||||
              so this method need not do this
 | 
			
		||||
        """
 | 
			
		||||
        rebuild = False
 | 
			
		||||
        for handle in del_note_handle_list :
 | 
			
		||||
            while self.data.count(handle) > 0:
 | 
			
		||||
                self.data.remove(handle)
 | 
			
		||||
                rebuild = True
 | 
			
		||||
        if rebuild:
 | 
			
		||||
            self.rebuild()
 | 
			
		||||
                
 | 
			
		||||
    def note_update(self, upd_note_handle_list):
 | 
			
		||||
        """
 | 
			
		||||
        Outside of this tab note objects have been updated. Check if tab
 | 
			
		||||
        and object must be updated.
 | 
			
		||||
        """
 | 
			
		||||
        ref_handles = self.data
 | 
			
		||||
        for handle in upd_note_handle_list :
 | 
			
		||||
            if handle in self.data:
 | 
			
		||||
                self.rebuild()
 | 
			
		||||
                break
 | 
			
		||||
 
 | 
			
		||||
@@ -106,6 +106,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):
 | 
			
		||||
 
 | 
			
		||||
@@ -103,6 +103,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):
 | 
			
		||||
 
 | 
			
		||||
@@ -99,6 +99,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):
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user