--- magnifierPrefs.py	2010-08-01 11:01:01.000000000 +0200
+++ magnifierPrefs-gsettings.py	2010-08-01 11:21:58.000000000 +0200
@@ -20,28 +20,26 @@
 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
 import gtk
-import gconf
+import gio
 import dbus
 
 ScreenPosition = \
     { "NONE": 0, "FULL_SCREEN": 1, "TOP_HALF": 2, "BOTTOM_HALF": 3, "LEFT_HALF": 4, "RIGHT_HALF": 5, "DOCKED": 6 };
 MouseTrackingMode = { "NONE": 0, "CENTERED": 1, "PUSH": 2, "PROPORTIONAL": 3 };
 
-A11Y_MAG_PREFS_DIR    = "/desktop/gnome/accessibility/magnifier";
-
-SHOW_KEY              = A11Y_MAG_PREFS_DIR + "/show_magnifier";
-SCREEN_POSITION_KEY   = A11Y_MAG_PREFS_DIR + "/screen_position";
-MAG_FACTOR_KEY        = A11Y_MAG_PREFS_DIR + "/mag_factor";
-LENS_MODE_KEY         = A11Y_MAG_PREFS_DIR + "/lens_mode";
-CLAMP_MODE_KEY        = A11Y_MAG_PREFS_DIR + "/scroll_at_edges";
-MOUSE_MODE_KEY        = A11Y_MAG_PREFS_DIR + "/mouse_tracking";
-
-CROSSHAIRS_SHOW_KEY         = A11Y_MAG_PREFS_DIR + "/show_cross_hairs";
-CROSSHAIRS_CLIP_KEY         = A11Y_MAG_PREFS_DIR + "/cross_hairs_clip";
-CROSSHAIRS_COLOR_KEY        = A11Y_MAG_PREFS_DIR + "/cross_hairs_color";
-CROSSHAIRS_THICKNESS_KEY    = A11Y_MAG_PREFS_DIR + "/cross_hairs_thickness";
-CROSSHAIRS_OPACITY_KEY      = A11Y_MAG_PREFS_DIR + "/cross_hairs_opacity";
-CROSSHAIRS_LENGTH_KEY       = A11Y_MAG_PREFS_DIR + "/cross_hairs_length";
+SHOW_KEY              = "show-magnifier";
+SCREEN_POSITION_KEY   = "screen-position";
+MAG_FACTOR_KEY        = "mag-factor";
+LENS_MODE_KEY         = "lens-mode";
+CLAMP_MODE_KEY        = "scroll-at-edges";
+MOUSE_MODE_KEY        = "mouse-tracking";
+
+CROSSHAIRS_SHOW_KEY         = "show-cross-hairs";
+CROSSHAIRS_CLIP_KEY         = "cross-hairs-clip";
+CROSSHAIRS_COLOR_KEY        = "cross-hairs-color";
+CROSSHAIRS_THICKNESS_KEY    = "cross-hairs-thickness";
+CROSSHAIRS_OPACITY_KEY      = "cross-hairs-opacity";
+CROSSHAIRS_LENGTH_KEY       = "cross-hairs-length";
 
 DEFAULT_CROSSHAIRS_COLOR = "#ff0000";   # red
 DEFAULT_CROSSHAIRS_OPACITY = 169;       # 66%
@@ -71,9 +69,8 @@
             print "Can't get dbus connection to Magnifier";
             self.zoomRegionProxy = None;
                         
-        gConf = gconf.client_get_default();
-        gConf.add_dir(A11Y_MAG_PREFS_DIR, gconf.CLIENT_PRELOAD_NONE);
-        self.gConfClient = gConf;
+        settings = gio.Settings("org.gnome.accessibility.magnifier");
+        self.settings = settings;
 
         # Set the widgets according to the current stored gconf values (if any).
         # Show/hide magnifier toggle ...
@@ -84,7 +81,7 @@
         
         # ... Mouse tracking mode combobox ...
         mouseTrackingComboBox = builder.get_object("mouseTrackingCombo");
-        aSetting = gConf.get_int(MOUSE_MODE_KEY);
+        aSetting = settings.get_enum(MOUSE_MODE_KEY);
         if (aSetting >= MouseTrackingMode["NONE"] and aSetting <= ["MouseTrackingMode.PROPORTIONAL"]):
             mouseTrackingComboBox.set_active(aSetting);
         else:
@@ -93,7 +90,7 @@
 
         # ... Screen position combobox ...
         screenPosComboBox = builder.get_object("screenPositionCombo");
-        aSetting = gConf.get_int(SCREEN_POSITION_KEY);
+        aSetting = settings.get_enum(SCREEN_POSITION_KEY);
         if (ScreenPosition["FULL_SCREEN"] <= aSetting <= ScreenPosition["DOCKED"]):
             screenPosComboBox.set_active(aSetting - 1);
         else:
@@ -103,17 +100,17 @@
 
         # ... Magnification factor slider ...
         magSlider = builder.get_object("magFactorSlider");
-        aSetting = gConf.get_float(MAG_FACTOR_KEY);
+        aSetting = settings.get_double(MAG_FACTOR_KEY);
         if (aSetting == 0.0):
             magSlider.set_value(2.0);
-            gConf.set_float(MAG_FACTOR_KEY, 2.0);
+            settings.set_double(MAG_FACTOR_KEY, 2.0);
         else:
             magSlider.set_value(aSetting);
         magSlider.connect("value-changed", self.doMagnification, self);
         
         # ... Lens mode checkbox ...
         lensMode = builder.get_object("moveableLensCheckbox");
-        aSetting = gConf.get_bool(LENS_MODE_KEY);
+        aSetting = settings.get_boolean(LENS_MODE_KEY);
         gConf.set_bool(LENS_MODE_KEY, aSetting);
         lensMode.set_active(aSetting);
         lensMode.connect("clicked", self.doLensMode, self);
@@ -127,46 +124,46 @@
         
         # ... Cross hairs: show/hide ...
         showCrosshairsMode = builder.get_object("xHairsShowHide");
-        aSetting = gConf.get_bool(CROSSHAIRS_SHOW_KEY);
-        gConf.set_bool(CROSSHAIRS_SHOW_KEY, aSetting);
+        aSetting = settings.get_boolean(CROSSHAIRS_SHOW_KEY);
+        settings.set_boolean(CROSSHAIRS_SHOW_KEY, aSetting);
         showCrosshairsMode.set_active(aSetting);
         showCrosshairsMode.connect("clicked", self.doShowCrosshairs, self);
         
         # ... Cross hairs: color ...
         crosshairsColor = builder.get_object("xHairsPicker");
-        aSetting = gConf.get_string(CROSSHAIRS_COLOR_KEY);
+        aSetting = settings.get_string(CROSSHAIRS_COLOR_KEY);
         if aSetting == None:
             aSetting = DEFAULT_CROSSHAIRS_COLOR;
-        gConf.set_string(CROSSHAIRS_COLOR_KEY, aSetting);
+        settings.set_string(CROSSHAIRS_COLOR_KEY, aSetting);
         crosshairsColor.set_color(gtk.gdk.Color(aSetting));
         crosshairsColor.connect("color-set", self.doCrosshairsColor, self);
 
         # ... Cross hairs: opacity ...
         crosshairsOpacity = builder.get_object("xHairsOpacitySlider");
-        aSetting = gConf.get_int(CROSSHAIRS_OPACITY_KEY);
-        gConf.set_int(CROSSHAIRS_OPACITY_KEY, aSetting);
+        aSetting = settings.get_int(CROSSHAIRS_OPACITY_KEY);
+        settings.set_int(CROSSHAIRS_OPACITY_KEY, aSetting);
         aSetting = aSetting / float(CROSSHAIRS_OPACITY_RANGE);
         crosshairsOpacity.set_value(aSetting);
         crosshairsOpacity.connect("value-changed", self.doCrosshairsOpacity, self);
 
         # ... Cross hairs: thickness ...
         crosshairsThickness = builder.get_object("xHairsThicknessSpinner");
-        aSetting = gConf.get_int(CROSSHAIRS_THICKNESS_KEY);
-        gConf.set_int(CROSSHAIRS_THICKNESS_KEY, aSetting);
+        aSetting = settings.get_int(CROSSHAIRS_THICKNESS_KEY);
+        settings.set_int(CROSSHAIRS_THICKNESS_KEY, aSetting);
         crosshairsThickness.set_value(aSetting);
         crosshairsThickness.connect("value-changed", self.doCrosshairsThickness, self);
 
         # ... Cross hairs: clip ...
         clipCrosshairsMode = builder.get_object("xHairsClipCheckbox");
-        aSetting = gConf.get_bool(CROSSHAIRS_CLIP_KEY);
-        gConf.set_bool(CROSSHAIRS_CLIP_KEY, aSetting);
+        aSetting = settings.get_bool(CROSSHAIRS_CLIP_KEY);
+        settings.set_bool(CROSSHAIRS_CLIP_KEY, aSetting);
         clipCrosshairsMode.set_active(aSetting);
         clipCrosshairsMode.connect("clicked", self.doCrosshairsClip, self);
 
         # ... Cross hairs: length
         crosshairsLength = builder.get_object("xHairsLengthSlider");
-        aSetting = gConf.get_int(CROSSHAIRS_LENGTH_KEY);
-        gConf.set_int(CROSSHAIRS_LENGTH_KEY, aSetting);
+        aSetting = settings.get_int(CROSSHAIRS_LENGTH_KEY);
+        settings.set_int(CROSSHAIRS_LENGTH_KEY, aSetting);
         crosshairsLength.set_value(aSetting);
         crosshairsLength.connect("value-changed", self.doCrosshairsLength, self);        
 
@@ -178,8 +175,8 @@
         closeButton.connect("clicked", lambda button: mainWindow.destroy());
         
         # Listen for changes that other processes might make to the mag
-        # GConf settings.
-#        gConf.notify_add(A11Y_MAG_PREFS_DIR, self.handleGConfChanges, self);
+        # GSettings.
+#        settings.connect("changed", self.handleSettingsChanges, self);
 
                 
         mainWindow.show_all();
@@ -203,10 +200,10 @@
     # Handlers for the widgets in the preferences dialog.
     #        
     def doShowHide(self, toggleButton, event):
-        self.gConfClient.set_bool(SHOW_KEY, toggleButton.get_active());
+        self.settings.set_boolean(SHOW_KEY, toggleButton.get_active());
         
     def doMouseTracking(self, combobox, event):
-        self.gConfClient.set_int(MOUSE_MODE_KEY, combobox.get_active());
+        self.settings.set_enum(MOUSE_MODE_KEY, combobox.get_active());
      
     def doScreenPosition(self, combobox, event):
         position = combobox.get_active() + 1;
@@ -217,15 +214,15 @@
                     aZoomRegion.moveResize(self._dockedViewPort);
                 except:
                     pass;
-        self.gConfClient.set_int(SCREEN_POSITION_KEY, combobox.get_active() + 1);
+        self.settings.set_enum(SCREEN_POSITION_KEY, combobox.get_active() + 1);
 
     def doMagnification(self, slider, event):
-        self.gConfClient.set_float(MAG_FACTOR_KEY, slider.get_value());
+        self.settings.set_double(MAG_FACTOR_KEY, slider.get_value());
     
     def doLensMode(self, checkbox, event):
         lensMode = checkbox.get_active();
         position = self.screenPosComboBox.get_active() + 1;
-        self.gConfClient.set_bool(LENS_MODE_KEY, lensMode);
+        self.settings.set_boolean(LENS_MODE_KEY, lensMode);
         if not lensMode and position == ScreenPosition["DOCKED"]:
             if self.zoomRegionProxy != None:
                 try:
@@ -234,10 +231,10 @@
                     pass;            
 
     def doClampScrolling(self, checkbox, event):
-        self.gConfClient.set_bool(CLAMP_MODE_KEY, checkbox.get_active());
+        self.settings.set_boolean(CLAMP_MODE_KEY, checkbox.get_active());
     
     def doShowCrosshairs(self, checkbox, event):
-        self.gConfClient.set_bool(CROSSHAIRS_SHOW_KEY, checkbox.get_active());
+        self.settings.set_boolean(CROSSHAIRS_SHOW_KEY, checkbox.get_active());
     
     def doCrosshairsColor(self, colorButton, event):
         # colorVal is in the form "#rrrrggggbbbb".  Convert to "#rrggbb".
@@ -246,25 +243,25 @@
         cVal += colorVal[1:3];      # red
         cVal += colorVal[5:7];      # green
         cVal += colorVal[9:11];     # blue
-        self.gConfClient.set_string(CROSSHAIRS_COLOR_KEY, cVal);
+        self.settings.set_string(CROSSHAIRS_COLOR_KEY, cVal);
 
     def doCrosshairsOpacity(self, opacitySlider, event):
         opacity = int(opacitySlider.get_value() * CROSSHAIRS_OPACITY_RANGE);
-        self.gConfClient.set_int(CROSSHAIRS_OPACITY_KEY, opacity);
+        self.settings.set_int(CROSSHAIRS_OPACITY_KEY, opacity);
     
     def doCrosshairsThickness(self, thicknessSpinner, event):
-        self.gConfClient.set_int(CROSSHAIRS_THICKNESS_KEY, int(thicknessSpinner.get_value()));
+        self.settings.set_int(CROSSHAIRS_THICKNESS_KEY, int(thicknessSpinner.get_value()));
 
     def doCrosshairsClip(self, checkbox, event):
-        self.gConfClient.set_bool(CROSSHAIRS_CLIP_KEY, checkbox.get_active());
+        self.settings.set_boolean(CROSSHAIRS_CLIP_KEY, checkbox.get_active());
  
     def doCrosshairsLength(self, lengthSlider, event):
-        self.gConfClient.set_int(CROSSHAIRS_LENGTH_KEY, int(lengthSlider.get_value()));
+        self.settings.set_int(CROSSHAIRS_LENGTH_KEY, int(lengthSlider.get_value()));
 
-    # Handle changes that GConf notifies us about.
+    # Handle changes that GSettings notifies us about.
     #
-#    def handleGConfChanges(self, gConfClient, connectId, gConfEntry, self2):
-#        print gConfEntry.get_key();
+#    def handleSettingsChanges(self, settings, key):
+#        print settings.get(key);
     
 magPrefsUI = MagPrefsUI();
 gtk.main();
