* src/DataViews/_MyGrampsView.py: saves on quit only, load/save api

2007-12-26  Douglas S. Blank  <dblank@cs.brynmawr.edu>


svn: r9589
This commit is contained in:
Doug Blank 2007-12-26 16:48:51 +00:00
parent 8fca6769f9
commit 697816aba6
2 changed files with 29 additions and 14 deletions

View File

@ -1,3 +1,6 @@
2007-12-26 Douglas S. Blank <dblank@cs.brynmawr.edu>
* src/DataViews/_MyGrampsView.py: saves on quit only, load/save api
2007-12-26 Douglas S. Blank <dblank@cs.brynmawr.edu> 2007-12-26 Douglas S. Blank <dblank@cs.brynmawr.edu>
* src/ViewManager.py: added __delete_pages called on quit * src/ViewManager.py: added __delete_pages called on quit
* src/PageView.py: added on_delete method called on quit * src/PageView.py: added on_delete method called on quit

View File

@ -126,9 +126,6 @@ class GadgetWindow(ManagedWindow.ManagedWindow):
self.gadget.mainframe.reparent(self.gadget.parent) self.gadget.mainframe.reparent(self.gadget.parent)
# FIXME: need to pack as it was, not just stick it in # FIXME: need to pack as it was, not just stick it in
ManagedWindow.ManagedWindow.close(self, *args) ManagedWindow.ManagedWindow.close(self, *args)
# The save can stay here because GRAMPS doesn't run this method
# on exit, apparently:
self.gadget.viewpage.save()
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -141,9 +138,12 @@ class Gadget(object):
self.data = {} self.data = {}
self.link_cursor = gtk.gdk.Cursor(gtk.gdk.LEFT_PTR) self.link_cursor = gtk.gdk.Cursor(gtk.gdk.LEFT_PTR)
self.standard_cursor = gtk.gdk.Cursor(gtk.gdk.XTERM) self.standard_cursor = gtk.gdk.Cursor(gtk.gdk.XTERM)
self.gui = gui # links to each other:
self.gui = gui # plugin gadget has link to gui
gui.pui = self # gui has link to plugin ui
self.dbstate = gui.dbstate self.dbstate = gui.dbstate
self.init() self.init()
self.on_load()
self.dbstate.connect('database-changed', self._db_changed) self.dbstate.connect('database-changed', self._db_changed)
self.dbstate.connect('active-changed', self.active_changed) self.dbstate.connect('active-changed', self.active_changed)
self.gui.textview.connect('button-press-event', self.gui.textview.connect('button-press-event',
@ -151,6 +151,20 @@ class Gadget(object):
self.gui.textview.connect('motion-notify-event', self.gui.textview.connect('motion-notify-event',
self.on_motion) self.on_motion)
def on_load(self):
"""
Gadgets should override this to take care of loading previously
their special data.
"""
pass
def on_save(self):
"""
Gadgets should override this to take care of saving their
special data.
"""
pass
def active_changed(self, handle): def active_changed(self, handle):
pass pass
@ -346,9 +360,8 @@ class GuiGadget:
del self.viewpage.gadget_map[self.title] del self.viewpage.gadget_map[self.title]
del self.viewpage.frame_map[str(self.mainframe)] del self.viewpage.frame_map[str(self.mainframe)]
self.mainframe.destroy() self.mainframe.destroy()
self.viewpage.save()
def detach(self, save=True): def detach(self):
# hide buttons: # hide buttons:
self.gvclose.hide() self.gvclose.hide()
self.gvstate.hide() self.gvstate.hide()
@ -359,8 +372,6 @@ class GuiGadget:
# make a window, and attach it there # make a window, and attach it there
self.detached_window = GadgetWindow(self) self.detached_window = GadgetWindow(self)
self.state = "windowed" self.state = "windowed"
if save:
self.viewpage.save()
def set_state(self, state): def set_state(self, state):
self.state = state self.state = state
@ -379,7 +390,6 @@ class GuiGadget:
column = self.mainframe.get_parent() # column column = self.mainframe.get_parent() # column
expand,fill,padding,pack = column.query_child_packing(self.mainframe) expand,fill,padding,pack = column.query_child_packing(self.mainframe)
column.set_child_packing(self.mainframe,self.expand,fill,padding,pack) column.set_child_packing(self.mainframe,self.expand,fill,padding,pack)
self.viewpage.save()
def change_state(self, obj): def change_state(self, obj):
if self.state == "windowed": if self.state == "windowed":
@ -419,7 +429,6 @@ class GuiGadget:
""" """
return self.gvproperties return self.gvproperties
class MyScrolledWindow(gtk.ScrolledWindow): class MyScrolledWindow(gtk.ScrolledWindow):
def show_all(self): def show_all(self):
# first show them all: # first show them all:
@ -543,7 +552,7 @@ class MyGrampsView(PageView.PageView):
#if gadget.state == "minimized": # starts max, change to min it #if gadget.state == "minimized": # starts max, change to min it
# gadget.set_state("minimized") # minimize it # gadget.set_state("minimized") # minimize it
if gadget.state == "windowed": if gadget.state == "windowed":
gadget.detach(save=False) # don't save on this change gadget.detach()
cnt += 1 cnt += 1
def load_gadgets(self): def load_gadgets(self):
@ -653,7 +662,6 @@ class MyGrampsView(PageView.PageView):
else: else:
expand = False expand = False
self.columns[col].pack_start(gframe, expand=expand) self.columns[col].pack_start(gframe, expand=expand)
self.save()
return True return True
def define_actions(self): def define_actions(self):
@ -694,7 +702,6 @@ class MyGrampsView(PageView.PageView):
# place the gadgets back in the new columns # place the gadgets back in the new columns
self.place_gadgets() self.place_gadgets()
self.widget.show() self.widget.show()
self.save()
def add_gadget(self, obj): def add_gadget(self, obj):
name = obj.get_child().get_label() name = obj.get_child().get_label()
@ -732,7 +739,6 @@ class MyGrampsView(PageView.PageView):
if self._popup_xy != None: if self._popup_xy != None:
self.drop_widget(self.widget, gadget, self.drop_widget(self.widget, gadget,
self._popup_xy[0], self._popup_xy[1], 0) self._popup_xy[0], self._popup_xy[1], 0)
self.save()
def get_stock(self): def get_stock(self):
""" """
@ -777,3 +783,9 @@ class MyGrampsView(PageView.PageView):
return True return True
return False return False
def on_delete(self):
gadgets = [g for g in self.gadget_map.values()]
for gadget in gadgets:
# this is the only place where the gui runs user code directly
gadget.pui.on_save()
self.save()