Fixed missing expand option on gramplets; added connect/disconnect signal handling; removed signal to update status bar when gramplet doesn't do anything
svn: r13428
This commit is contained in:
parent
2ed1159e89
commit
bb99cd20b1
@ -85,6 +85,7 @@ def GET_AVAILABLE_GRAMPLETS(name):
|
||||
"tname": gplug.name,
|
||||
"version": gplug.version,
|
||||
"height": gplug.height,
|
||||
"expand": gplug.expand,
|
||||
"title": gplug.gramplet_title,
|
||||
"content": gplug.gramplet,
|
||||
"detached_width": gplug.detached_width,
|
||||
|
@ -36,6 +36,7 @@ class Gramplet(object):
|
||||
self._generator = None
|
||||
self._need_to_update = False
|
||||
self.option_dict = {}
|
||||
self._signal = {}
|
||||
self.option_order = []
|
||||
# links to each other:
|
||||
self.gui = gui # plugin gramplet has link to gui
|
||||
@ -45,15 +46,16 @@ class Gramplet(object):
|
||||
self.init()
|
||||
self.on_load()
|
||||
self.build_options()
|
||||
self.dbstate.connect('database-changed', self._db_changed)
|
||||
self.dbstate.connect('active-changed', self._active_changed)
|
||||
self.gui.textview.connect('button-press-event',
|
||||
self.connect(self.dbstate, "database-changed", self._db_changed)
|
||||
self.connect(self.dbstate, "active-changed", self._active_changed)
|
||||
self.connect(self.gui.textview, "button-press-event",
|
||||
self.gui.on_button_press)
|
||||
self.gui.textview.connect('motion-notify-event',
|
||||
self.connect(self.gui.textview, "motion-notify-event",
|
||||
self.gui.on_motion)
|
||||
if self.dbstate.active: # already changed
|
||||
self._db_changed(self.dbstate.db)
|
||||
self._active_changed(self.dbstate.active.handle)
|
||||
self.post_init()
|
||||
|
||||
def init(self): # once, constructor
|
||||
"""
|
||||
@ -62,6 +64,9 @@ class Gramplet(object):
|
||||
"""
|
||||
pass
|
||||
|
||||
def post_init(self):
|
||||
pass
|
||||
|
||||
def build_options(self):
|
||||
"""
|
||||
External constructor for developers to put code for building
|
||||
@ -336,3 +341,14 @@ class Gramplet(object):
|
||||
|
||||
def save_options(self):
|
||||
pass
|
||||
|
||||
def connect(self, signal_obj, signal, method):
|
||||
id = signal_obj.connect(signal, method)
|
||||
self._signal[signal] = (id, signal_obj)
|
||||
|
||||
def disconnect(self, signal):
|
||||
if signal in self._signal:
|
||||
(id, signal_obj) = self._signal[signal]
|
||||
signal_obj.disconnect(id)
|
||||
else:
|
||||
raise AttributeError("unknown signal: '%s'" % signal)
|
||||
|
@ -84,6 +84,9 @@ class AgeOnDateGramplet(Gramplet):
|
||||
self.gui.get_container_widget().add_with_viewport(vbox)
|
||||
vbox.show_all()
|
||||
|
||||
def post_init(self):
|
||||
self.disconnect("active-changed")
|
||||
|
||||
def run(self, obj):
|
||||
"""
|
||||
Method that is run when you click the Run button.
|
||||
|
@ -43,6 +43,9 @@ class CalendarGramplet(Gramplet):
|
||||
self.gui.get_container_widget().add_with_viewport(self.gui.calendar)
|
||||
self.gui.calendar.show()
|
||||
|
||||
def post_init(self):
|
||||
self.disconnect("active-changed")
|
||||
|
||||
def double_click(self, obj):
|
||||
# bring up events on this day
|
||||
year, month, day = self.gui.calendar.get_date()
|
||||
|
@ -38,3 +38,6 @@ class FAQGramplet(Gramplet):
|
||||
self.render_text("Draft of a <a wiki='FAQ'>Frequently Asked Questions</a> Gramplet\n\n")
|
||||
self.render_text(" 1. <a href='http://bugs.gramps-project.org/'>Test 1</a>\n")
|
||||
self.render_text(" 2. <a href='http://gramps-project.org//'>Test 2</a>\n")
|
||||
|
||||
def post_init(self):
|
||||
self.disconnect("active-changed")
|
||||
|
@ -58,6 +58,9 @@ class PythonGramplet(Gramplet):
|
||||
self.set_text("Python %s\n%s " % (sys.version, self.prompt))
|
||||
self.gui.textview.connect('key-press-event', self.on_key_press)
|
||||
|
||||
def post_init(self):
|
||||
self.disconnect("active-changed")
|
||||
|
||||
def format_exception(self, max_tb_level=10):
|
||||
retval = ''
|
||||
cla, exc, trbk = sys.exc_info()
|
||||
|
@ -41,6 +41,9 @@ class TODOGramplet(Gramplet):
|
||||
def on_load(self):
|
||||
self.load_data_to_text()
|
||||
|
||||
def post_init(self):
|
||||
self.disconnect("active-changed")
|
||||
|
||||
def on_save(self):
|
||||
self.gui.data = [] # clear out old data
|
||||
self.save_text_to_data()
|
||||
|
Loading…
Reference in New Issue
Block a user