conduit r1844 - in trunk: . conduit/gtkui conduit/modules/GConfModule
- From: jstowers svn gnome org
- To: svn-commits-list gnome org
- Subject: conduit r1844 - in trunk: . conduit/gtkui conduit/modules/GConfModule
- Date: Thu, 29 Jan 2009 00:13:46 +0000 (UTC)
Author: jstowers
Date: Thu Jan 29 00:13:46 2009
New Revision: 1844
URL: http://svn.gnome.org/viewvc/conduit?rev=1844&view=rev
Log:
2009-01-29 John Stowers <john stowers gmail com>
* conduit/gtkui/SimpleConfigurator.py: Add ability
to attach userdata to callbacks. Also return the
result of the dialog.
* conduit/modules/GConfModule/GConfModule.py:
Generalise the GConfSettings module to
group settings into categories, and add the ability to
selectively sync those settings.
Modified:
trunk/ChangeLog
trunk/conduit/gtkui/SimpleConfigurator.py
trunk/conduit/modules/GConfModule/GConfModule.py
Modified: trunk/conduit/gtkui/SimpleConfigurator.py
==============================================================================
--- trunk/conduit/gtkui/SimpleConfigurator.py (original)
+++ trunk/conduit/gtkui/SimpleConfigurator.py Thu Jan 29 00:13:46 2009
@@ -18,6 +18,7 @@
"Widget" : gtk.TextView,
"Callback" : function,
"InitialValue" : value or function
+ "UserData" : tuple of additional args to callback (optional)
}
]
@@ -80,16 +81,18 @@
"""
log.debug("OK Clicked")
for w in self.widgetInstances:
+ args = w["UserData"]
+
#FIXME: This seems hackish
if isinstance(w["Widget"], gtk.Entry):
- w["Callback"](w["Widget"].get_text())
+ w["Callback"](w["Widget"].get_text(), *args)
elif isinstance(w["Widget"], gtk.CheckButton):
- w["Callback"](w["Widget"].get_active())
+ w["Callback"](w["Widget"].get_active(), *args)
elif w["Kind"] == "list":
- w["Callback"](w["Widget"].get_active(), w["Widget"].get_active_text())
+ w["Callback"](w["Widget"].get_active(), w["Widget"].get_active_text(), *args)
else:
# Just return the widget, so the caller should know what to do with this
- w["Callback"](w["Widget"])
+ w["Callback"](w["Widget"], *args)
self.dialog.destroy()
@@ -118,6 +121,7 @@
run
"""
resp = self.dialog.run()
+ return resp == gtk.RESPONSE_OK
def build_child(self):
"""
@@ -166,14 +170,20 @@
#gtk.CheckButton has its label built in
label = None
widget.set_label(l["Name"])
- widget.set_active(bool(l["InitialValue"]))
+ widget.set_active(bool(l["InitialValue"]))
+
+ if "UserData" in l:
+ args = l["UserData"]
+ else:
+ args = ()
#FIXME: There must be a better way to do this but we need some way
#to identify the widget *instance* when we save the values from it
self.widgetInstances.append({
"Widget" : widget,
"Kind" : kind,
- "Callback" : l["Callback"]
+ "Callback" : l["Callback"],
+ "UserData" : args
})
table = self.customSettings
Modified: trunk/conduit/modules/GConfModule/GConfModule.py
==============================================================================
--- trunk/conduit/modules/GConfModule/GConfModule.py (original)
+++ trunk/conduit/modules/GConfModule/GConfModule.py Thu Jan 29 00:13:46 2009
@@ -18,28 +18,27 @@
}
class GConfTwoWay(DataProvider.TwoWay, AutoSync.AutoSync):
- _name_ = _("GConf Settings")
- _description_ = _("Synchronize your desktop preferences")
+ _name_ = _("Application Settings")
+ _description_ = _("Synchronize your application settings")
_category_ = conduit.dataproviders.CATEGORY_MISC
_module_type_ = "twoway"
_in_type_ = "setting"
_out_type_ = "setting"
_icon_ = "preferences-desktop"
- _configurable_ = False
+ _configurable_ = True
- DEFAULT_WHITELIST = [
- '/apps/metacity/*',
- '/desktop/gnome/applications/*',
- '/desktop/gnome/background/*',
- '/desktop/gnome/interface/*',
- '/desktop/gnome/url-handlers/*'
- ]
+ WHITELIST = {
+ "Metacity" : ('/apps/metacity/*',),
+ "Nautilus" : ('/apps/nautilus/*',),
+ "Preferred Applications" : ('/desktop/gnome/applications/*'),
+ "Desktop Interface" : ('/desktop/gnome/interface/*',)
+ }
def __init__(self, *args):
DataProvider.TwoWay.__init__(self)
AutoSync.AutoSync.__init__(self)
- self.whitelist = self.DEFAULT_WHITELIST
+ self.sections = []
self.awaitingChanges = {}
self.gconf = gconf.client_get_default()
@@ -47,9 +46,10 @@
self.gconf.notify_add('/', self._on_change)
def _in_the_list(self, key):
- for pattern in self.whitelist:
- if fnmatch.fnmatch(key, pattern):
- return True
+ for section in self.sections:
+ for pattern in self.WHITELIST[section]:
+ if fnmatch.fnmatch(key, pattern):
+ return True
return False
def _get_all(self, path):
@@ -133,15 +133,40 @@
#the change wasnt from us
self.handle_modified(entry.key)
- def refresh(self):
- pass
+ def is_configured(self, isSource, isTwoWay):
+ return len(self.sections) > 0
+
+ def configure( self, window ):
+ import gtk
+ import conduit.gtkui.SimpleConfigurator as SimpleConfigurator
+
+ sections = []
+ def check_active(active, sectionName):
+ if active:
+ sections.append(sectionName)
+
+ items = []
+ for n in self.WHITELIST:
+ item = {
+ "Name" : "%s Settings" % n,
+ "Kind" : "check",
+ "Callback" : check_active,
+ "InitialValue" : n in self.sections,
+ "UserData" : (n,)
+ }
+ items.append(item)
+ dialog = SimpleConfigurator.SimpleConfigurator(window, "Applications to Synchronize", items)
+ if dialog.run():
+ self.sections = sections
def get_all(self):
""" loop through all gconf keys and see which ones match our whitelist """
+ DataProvider.TwoWay.get_all(self)
return self._get_all("/")
def get(self, uid):
""" Get a Setting object based on UID (key path) """
+ DataProvider.TwoWay.get(self, uid)
node = self.gconf.get(uid)
if not node:
log.debug("Could not find uid %s" % uid)
@@ -154,13 +179,10 @@
return s
def get_configuration(self):
- return {"whitelist" : self.whitelist}
+ return {"sections" : self.sections}
- def set_configuration(self, config):
- self.whitelist = config.get("whitelist",self.DEFAULT_WHITELIST)
- log.debug("%s" % self.whitelist)
-
def put(self, setting, overwrite, uid=None):
+ DataProvider.TwoWay.put(self, setting, overwrite, uid)
log.debug("Saving value in Gconf: %s=%s" % (setting.key, setting.value))
self._to_gconf(setting.key, setting.value)
if uid == None:
@@ -168,6 +190,7 @@
return self.get(uid).get_rid()
def delete(self, uid):
+ DataProvider.TwoWay.delete(self, uid)
self.gconf.unset(uid)
def get_UID(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]