[fusion-commits] Compizconfig Settings Manager in Python: Changes to 'master' (980ea27cbef0459a5493664ff97f018c6453d644)

crdlb at server.opencompositing.org crdlb at server.opencompositing.org
Thu Mar 27 02:29:53 CET 2008


New commits:
commit 980ea27cbef0459a5493664ff97f018c6453d644
Author: Christopher Williams <christopherw at verizon.net>
Date:   Wed Mar 26 21:24:20 2008 -0400

    Make MatchButton and FileButton widgets directly manipulate and activate the StringSetting's Entry


 ccm/Settings.py |   30 +++++++++---------------------
 ccm/Widgets.py  |   16 +++++++++++-----
 2 files changed, 20 insertions(+), 26 deletions(-)


Modified: fusion/compizconfig/ccsm/ccm/Settings.py
===================================================================
--- fusion/compizconfig/ccsm/ccm/Settings.py
+++ fusion/compizconfig/ccsm/ccm/Settings.py
@@ -182,33 +182,21 @@ class StringSetting(Setting):
 class MatchSetting(StringSetting):
     def _Init(self):
         StringSetting._Init(self)
-        self.MatchButton = MatchButton(self.Get)
-        self.MatchButton.connect('changed', self.MatchChanged)
-
+        self.MatchButton = MatchButton(self.Entry)
         self.Box.pack_start(self.MatchButton, False, False)
 
-    def _Read(self):
-        self.Entry.set_text(self.Get())
-        self.MatchButton.set_match(self.Get())
-
-    def MatchChanged(self, widget, match):
-        self.Entry.set_text(match)
-        self.Setting.Plugin.Context.Write()
-
-    def _Changed(self):
-        StringSetting._Changed(self)
-        self.MatchButton.set_match(self.Get())
-
 class FileStringSetting(StringSetting):
+
     def __init__(self, setting, List=False, isImage=False, isDirectory=False):
+        self.isImage = isImage
+        self.isDirectory = isDirectory
         StringSetting.__init__(self, setting, List=List)
-        fileButton = FileButton(setting.Plugin.Context, isDirectory, isImage)
-        fileButton.connect('changed', self.SetFileName)
-        self.Box.pack_start(fileButton, False, False)
 
-    def SetFileName(self, widget, filename):
-        self.Entry.set_text(filename)
-        self.Changed()
+    def _Init(self):
+        StringSetting._Init(self)
+        self.FileButton = FileButton(self.Setting.Plugin.Context, self.Entry,
+            self.isDirectory, self.isImage)
+        self.Box.pack_start(self.FileButton, False, False)
 
 class EnumSetting(Setting):
 

Modified: fusion/compizconfig/ccsm/ccm/Widgets.py
===================================================================
--- fusion/compizconfig/ccsm/ccm/Widgets.py
+++ fusion/compizconfig/ccsm/ccm/Widgets.py
@@ -958,11 +958,12 @@ class MatchButton(gtk.Button):
 
     match   = None
 
-    def __init__ (self, match = None):
+    def __init__ (self, entry = None):
         '''Prepare widget'''
         super (MatchButton, self).__init__ ()
 
-        self.match = match
+        self.entry = entry
+        self.match = entry.get_text()
 
         self.add (Image (name = gtk.STOCK_ADD, type = ImageStock,
                          size = gtk.ICON_SIZE_BUTTON))
@@ -970,7 +971,8 @@ class MatchButton(gtk.Button):
 
     def set_match (self, value):
         self.match = value
-        self.emit ("changed", self.match)
+        self.entry.set_text(value)
+        self.entry.activate()
 
     def get_xprop (self, regexp, proc = "xprop"):
         proc = os.popen (proc)
@@ -1038,6 +1040,8 @@ class MatchButton(gtk.Button):
     def run_edit_dialog (self, widget):
         '''Run dialog to generate a match'''
 
+        self.match = self.entry.get_text ()
+
         dlg = gtk.Dialog (_("Edit match"))
         dlg.set_position (gtk.WIN_POS_CENTER_ON_PARENT)
         dlg.set_transient_for (self.get_parent ().get_toplevel ())
@@ -1109,9 +1113,10 @@ class FileButton (gtk.Button):
     _image     = False
     _path      = ""
 
-    def __init__ (self, context, directory=False, image=False, path=""):
+    def __init__ (self, context, entry, directory=False, image=False, path=""):
         gtk.Button.__init__ (self)
 
+        self._entry = entry
         self._directory = directory
         self._context = context
         self._image = image
@@ -1124,7 +1129,8 @@ class FileButton (gtk.Button):
 
     def set_path (self, value):
         self._path = value
-        self.emit ("changed", self._path)
+        self._entry.set_text (value)
+        self._entry.activate ()
 
     def create_filter(self):
         filter = gtk.FileFilter ()


More information about the commits mailing list