[totem] Fix the Jamendo plugin's preferences dialogue



commit 9d086e27d2de84cccc99e768e08c3108b738c619
Author: Philip Withnall <philip tecnocode co uk>
Date:   Fri Dec 17 14:41:15 2010 +0000

    Fix the Jamendo plugin's preferences dialogue
    
    This is due to the fact that bgo#637335 is now fixed.

 src/plugins/jamendo/jamendo.py |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/src/plugins/jamendo/jamendo.py b/src/plugins/jamendo/jamendo.py
index e45eba2..374803c 100644
--- a/src/plugins/jamendo/jamendo.py
+++ b/src/plugins/jamendo/jamendo.py
@@ -143,9 +143,12 @@ class JamendoPlugin(gobject.GObject, Peas.Activatable, PeasGtk.Configurable):
         format = self.settings.get_enum ('format')
         num_per_page = self.settings.get_value ('num-per-page').get_uint32 ()
 
+        # Set up the "format" combo box. We can't use g_settings_bind() here, as it won't automatically convert between enums and ints. To do so,
+        # we'd need to use g_settings_bind_with_mapping(), but that isn't introspectable. We have to handle the binding manually.
         combo = builder.get_object('preferred_format_combo')
         combo.set_active(format)
-        self.settings.bind ('format', combo, 'active', Gio.SettingsBindFlags.DEFAULT)
+        combo.connect ('changed', self.on_format_combo_changed)
+        self.settings.connect ('changed::format', self.on_format_setting_changed, combo)
 
         spinbutton = builder.get_object('album_num_spinbutton')
         spinbutton.set_value(num_per_page)
@@ -153,6 +156,18 @@ class JamendoPlugin(gobject.GObject, Peas.Activatable, PeasGtk.Configurable):
 
         return config_widget
 
+    def on_format_combo_changed (self, combo):
+        """
+        Called when the "format" preference combo box value is changed.
+        """
+        self.settings.set_enum ('format', combo.get_active ())
+
+    def on_format_setting_changed (self, settings, key, combo):
+        """
+        Called for the "format" preference combo box when the corresponding GSettings value is changed.
+        """
+        combo.set_active (self.settings.get_enum ('format'))
+
     def on_format_changed (self, settings, key):
         JamendoService.AUDIO_FORMAT = self.settings.get_enum ('format')
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]