From 22edf1cc7787c5f021bc89395d411e978c8ebd7d Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Mon, 24 Nov 2008 03:02:42 +0000 Subject: [PATCH] Contribution from Craig J. Anderson: Add availability update to GuiStringOption and GuiBooleanOption. svn: r11339 --- src/PluginUtils/_GuiOptions.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/PluginUtils/_GuiOptions.py b/src/PluginUtils/_GuiOptions.py index 7a5f87cb4..1b42cfae7 100644 --- a/src/PluginUtils/_GuiOptions.py +++ b/src/PluginUtils/_GuiOptions.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2008 Craig J. Anderson # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -168,12 +169,22 @@ class GuiStringOption(gtk.Entry): self.connect('changed', self.__text_changed) tooltip.set_tip(self, self.__option.get_help()) + self.__option.connect('avail-changed', self.__update_avail) + self.__update_avail() + def __text_changed(self, obj): # IGNORE:W0613 - obj is unused """ Handle the change of the value. """ self.__option.set_value( self.get_text() ) + def __update_avail(self): + """ + Update the availability (sensitivity) of this widget. + """ + avail = self.__option.get_available() + self.set_sensitive(avail) + #------------------------------------------------------------------------- # # GuiColourOption class @@ -304,13 +315,23 @@ class GuiBooleanOption(gtk.CheckButton): self.set_active(self.__option.get_value()) self.connect('toggled', self.__value_changed) tooltip.set_tip(self, self.__option.get_help()) - + + self.__option.connect('avail-changed', self.__update_avail) + self.__update_avail() + def __value_changed(self, obj): # IGNORE:W0613 - obj is unused """ Handle the change of the value. """ self.__option.set_value( self.get_active() ) + def __update_avail(self): + """ + Update the availability (sensitivity) of this widget. + """ + avail = self.__option.get_available() + self.set_sensitive(avail) + #------------------------------------------------------------------------- # # GuiEnumeratedListOption class