fix ScratchPad window close bug.

svn: r4670
This commit is contained in:
Richard Taylor 2005-05-25 06:56:41 +00:00
parent f57b31016f
commit 9d19ad4095
3 changed files with 54 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2005-05-25 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/plugins/ScratchPad.py: rename on_scratch_pad_delete_event for consistency
* src/plugins/scratchpad.glade: add on_scratch_pad_delete_event to fix bug
when window is close using the window manager close button.
2005-05-25 Alex Roitman <shura@gramps-project.org>
* src/EditSource.py (__init__): set cursor to WATCH before displaying
references; call display_references when idle;

View File

@ -94,6 +94,9 @@ class ScratchPadWrapper(object):
def pack(self):
return str(self._obj)
def is_valid(self):
return True
class ScratchPadGrampsTypeWrapper(ScratchPadWrapper):
def __init__(self,model,obj):
@ -108,6 +111,21 @@ class ScratchPadGrampsTypeWrapper(ScratchPadWrapper):
def pack(self):
return self._pickle
def is_valid(self):
valid_func_map = {'Person': self._db.get_person_from_handle,
'Family': self._db.get_family_from_handle,
'Event': self._db.get_event_from_handle,
'Place': self._db.get_place_from_handle,
'MediaObject': self._db.get_object_from_handle,
'Source': self._db.get_source_from_handle}
for (classname,handle) in self._obj.get_referenced_handles_recursively():
if classname in valid_func_map.keys():
if not valid_func_map[classname](handle):
return False
return True
class ScratchPadAddress(ScratchPadGrampsTypeWrapper):
@ -533,6 +551,27 @@ class ScratchPadListView:
self.database_changed(self._gramps_model.db)
self._gramps_model.connect('database-changed', self.database_changed)
db_signals = (
'person-update',
'person-delete',
'person-rebuild',
'family-update',
'family-delete',
'family-rebuild',
'source-update',
'source-delete',
'source-rebuild',
'place-update',
'place-delete',
'place-rebuild',
'media-update',
'media-delete',
'media-rebuild'
)
for signal in db_signals:
self._gramps_model.db.connect(signal,self.remove_invalid_objects)
self._widget = widget
self._target_type_to_wrapper_class_map = {}
@ -588,6 +627,13 @@ class ScratchPadListView:
def database_changed(self,db):
self._db = db
def remove_invalid_objects(self,dummy=None):
model = self._widget.get_model()
for o in model:
if not o.is_valid():
model.remove(o)
# Method to manage the wrapper classes.
def register_wrapper_classes(self):
@ -793,7 +839,7 @@ class ScratchPadWindow:
"on_clear_clicked": self.on_clear_clicked,
"on_help_clicked": self.on_help_clicked,
"on_objectlist_delete_event": self.on_delete_event,
"on_scratchPad_delete_event": self.on_delete_event
"on_scratch_pad_delete_event": self.on_delete_event
})
self.clear_all_btn.connect_object('clicked', gtk.ListStore.clear, ScratchPadWindow.otree)

View File

@ -20,6 +20,7 @@
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="has_separator">True</property>
<signal name="delete_event" handler="on_scratch_pad_delete_event" last_modification_time="Wed, 25 May 2005 06:50:50 GMT"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">