[vino: 16/17] Completed GConf to GSettings port.



commit fa444b5ea3d173836a9bf0e17c62404146be8092
Author: Chris Kühl <chrisk openismus com>
Date:   Fri Feb 18 12:34:56 2011 +0100

    Completed GConf to GSettings port.

 capplet/vino-preferences.c                         |   82 ++++++++++++++---
 capplet/vino-preferences.ui                        |    7 +-
 common/Makefile.am                                 |   15 +++-
 ...o.gschema.xml => org.gnome.Vino.gschema.xml.in} |   97 +++++++++----------
 configure.in                                       |    7 +-
 tools/vino-passwd.c                                |   36 +++-----
 6 files changed, 147 insertions(+), 97 deletions(-)
---
diff --git a/capplet/vino-preferences.c b/capplet/vino-preferences.c
index 9a035de..c6bf19e 100644
--- a/capplet/vino-preferences.c
+++ b/capplet/vino-preferences.c
@@ -170,6 +170,55 @@ set_password (const GValue       *value,
                                   TRUE, g_free, base64);
 }
 
+typedef enum
+{
+  VINO_ICON_VISIBILITY_NEVER,
+  VINO_ICON_VISIBILITY_ALWAYS,
+  VINO_ICON_VISIBILITY_CLIENT
+} VinoIconVisibility;
+
+static gboolean
+get_icon_visibility (GValue   *value,
+                     GVariant *variant,
+                     gpointer  user_data)
+{
+  const char *setting;
+  char *name;
+
+  setting = g_variant_get_string (variant, NULL);
+
+  g_object_get (user_data, "name", &name, NULL);
+
+  /* If the button name matches the setting, it should be active. */
+  if (g_strcmp0 (name, setting) == 0)
+      g_value_set_boolean (value, TRUE);
+
+  g_free (name);
+
+  return TRUE;
+}
+
+static GVariant *
+set_icon_visibility (const GValue       *value,
+                     const GVariantType *type,
+                     gpointer            user_data)
+{
+  GVariant *variant = NULL;
+  char *name;
+
+  /* Don't act unless the button has been activated (turned ON). */
+  if (!g_value_get_boolean (value))
+    return NULL;
+
+  /* GtkToggleButton *button = GTK_TOGGLE_BUTTON(user_data); */
+  g_object_get (user_data, "name", &name, NULL);
+  variant = g_variant_new_string (name);
+
+  g_free (name);
+
+  return variant;
+}
+
 static void
 vino_preferences_dialog_response (GtkWidget *widget,
                                   gint       response,
@@ -293,20 +342,23 @@ vino_preferences_connect_ui (VinoPreferences *app,
     GSettingsBindGetMapping  get_mapping;
     GSettingsBindSetMapping  set_mapping;
   } bindings[] = {
-    { "enabled",                "allowed_toggle",        "active"                                                           },
+    { "enabled",                "allowed_toggle",        "active",    G_SETTINGS_BIND_DEFAULT, NULL,                NULL                },
+
+    { "enabled",                "control_settings",      "sensitive", G_SETTINGS_BIND_GET,     NULL,                NULL                },
+    { "view-only",              "view_only_toggle",      "active",    G_SETTINGS_BIND_DEFAULT, get_inverted,        set_inverted        },
 
-    { "enabled",                "control_settings",      "sensitive",       G_SETTINGS_BIND_GET                             },
-    { "view-only",              "view_only_toggle",      "active",          0,                   get_inverted, set_inverted },
+    { "enabled",                "security_settings",     "sensitive", G_SETTINGS_BIND_GET,     NULL,                NULL                },
+    { "prompt-enabled",         "prompt_enabled_toggle", "active",    G_SETTINGS_BIND_DEFAULT, NULL,                NULL                },
+    { "authentication-methods", "password_toggle",       "active",    G_SETTINGS_BIND_DEFAULT, get_authtype,        set_authtype        },
+    { "authentication-methods", "password_box",          "sensitive", G_SETTINGS_BIND_GET,     get_authtype,        NULL                },
+    { "vnc-password",           "password_entry",        "text",      G_SETTINGS_BIND_DEFAULT, get_password,        set_password        },
+    { "use-upnp",               "use_upnp_toggle",       "active",    G_SETTINGS_BIND_DEFAULT, NULL,                NULL                },
 
-    { "enabled",                "security_settings",     "sensitive",       G_SETTINGS_BIND_GET                             },
-    { "prompt-enabled",         "prompt_enabled_toggle", "active",                                                          },
-    { "authentication-methods", "password_toggle",       "active",          0,                   get_authtype, set_authtype },
-    { "authentication-methods", "password_box",          "sensitive",       G_SETTINGS_BIND_GET, get_authtype               },
-    { "vnc-password",           "password_entry",        "text",            0,                   get_password, set_password },
-    { "use-upnp",               "use_upnp_toggle",       "active",                                                          },
+    { "enabled",                "notification_settings", "sensitive", G_SETTINGS_BIND_GET,     NULL,                NULL                },
 
-    { "enabled",                "notification_settings", "sensitive",       G_SETTINGS_BIND_GET                             },
-    { "icon-visibility",        "icon_always_radio",     "settings-active",                                                 }
+    { "icon-visibility",        "icon_always_radio",     "active",    G_SETTINGS_BIND_DEFAULT, get_icon_visibility, set_icon_visibility },
+    { "icon-visibility",        "icon_client_radio",     "active",    G_SETTINGS_BIND_DEFAULT, get_icon_visibility, set_icon_visibility },
+    { "icon-visibility",        "icon_never_radio",      "active",    G_SETTINGS_BIND_DEFAULT, get_icon_visibility, set_icon_visibility }
   };
   GSettings *settings;
   gpointer window;
@@ -315,14 +367,16 @@ vino_preferences_connect_ui (VinoPreferences *app,
   settings = g_settings_new ("org.gnome.Vino");
 
   for (i = 0; i < G_N_ELEMENTS (bindings); i++)
+  {
+    GObject *object =  gtk_builder_get_object (builder, bindings[i].name);
     g_settings_bind_with_mapping (settings, bindings[i].setting,
-                                  gtk_builder_get_object (builder,
-                                                          bindings[i].name),
+                                  object,
                                   bindings[i].property,
                                   bindings[i].flags,
                                   bindings[i].get_mapping,
                                   bindings[i].set_mapping,
-                                  NULL, NULL);
+                                  object, NULL);
+  }
 
   window = gtk_builder_get_object (builder, "vino_dialog");
   g_signal_connect (window, "response",
diff --git a/capplet/vino-preferences.ui b/capplet/vino-preferences.ui
index fa1f582..470e940 100644
--- a/capplet/vino-preferences.ui
+++ b/capplet/vino-preferences.ui
@@ -10,7 +10,6 @@
     <property name="window_position">center-on-parent</property>
     <property name="icon_name">preferences-desktop-remote-desktop</property>
     <property name="type_hint">dialog</property>
-    <property name="has_separator">False</property>
     <child internal-child="vbox">
       <object class="GtkVBox" id="dialog-vbox1">
         <property name="visible">True</property>
@@ -315,7 +314,7 @@
                         <property name="spacing">3</property>
                         <child>
                           <object class="VinoRadioButton" id="icon_always_radio">
-                            <property name='settings-name'>always</property>
+                            <property name='name'>always</property>
                             <property name="label" translatable="yes">Al_ways display an icon</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
@@ -330,7 +329,7 @@
                         </child>
                         <child>
                           <object class="VinoRadioButton" id="icon_client_radio">
-                            <property name='settings-name'>client</property>
+                            <property name='name'>client</property>
                             <property name="label" translatable="yes">_Only display an icon when there is someone connected</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
@@ -346,7 +345,7 @@
                         </child>
                         <child>
                           <object class="VinoRadioButton" id="icon_never_radio">
-                            <property name='settings-name'>never</property>
+                            <property name='name'>never</property>
                             <property name="label" translatable="yes">_Never display an icon</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
diff --git a/common/Makefile.am b/common/Makefile.am
index 0a272c1..f41f682 100644
--- a/common/Makefile.am
+++ b/common/Makefile.am
@@ -5,6 +5,19 @@ EXTRA_DIST = \
 	vino-keyring.h			\
 	vino-keyring.c
 
-gsettings_SCHEMAS = org.gnome.Vino.gschema.xml
+# GSettings schemas, enum files and conversion file
+gsettings_ENUM_NAMESPACE = org.gnome.Vino
+gsettings_ENUM_FILES = $(top_srcdir)/capplet/vino-preferences.c
+wgsettings_in_file = org.gnome.Vino.gschema.xml.in
+gsettings_SCHEMAS = $(gsettings_in_file:.xml.in=.xml)
 
+ INTLTOOL_XML_NOMERGE_RULE@
 @GSETTINGS_RULES@
+
+dist_noinst_DATA = \
+	$(gsettings_in_file)
+
+CLEANFILES = \
+	$(gsettings_SCHEMAS)
+
+MAINTAINERCLEANFILES = $(gsettings_SCHEMAS:.xml=.valid)
\ No newline at end of file
diff --git a/common/org.gnome.Vino.gschema.xml b/common/org.gnome.Vino.gschema.xml.in
similarity index 70%
rename from common/org.gnome.Vino.gschema.xml
rename to common/org.gnome.Vino.gschema.xml.in
index da1888c..30a47c0 100644
--- a/common/org.gnome.Vino.gschema.xml
+++ b/common/org.gnome.Vino.gschema.xml.in
@@ -1,80 +1,80 @@
 <schemalist>
   <schema id='org.gnome.Vino' path='/desktop/gnome/remote-access/'>
     <key name='enabled' type='b'>
-      <summary>Enable remote desktop access</summary>
-      <description>
+      <_summary>Enable remote desktop access</_summary>
+      <_description>
         If true, allows remote access to the desktop via the RFB
         protocol. Users on remote machines may then connect to the
-        desktop using a vncviewer.  </description>
+        desktop using a vncviewer.  </_description>
       <default>false</default>
     </key>
 
     <key name='prompt-enabled' type='b'>
-      <summary>Prompt the user before completing a connection</summary>
-      <description>
+      <_summary>Prompt the user before completing a connection</_summary>
+      <_description>
         If true, remote users accessing the desktop are not allowed
         access until the user on the host machine approves the
         connection.  Recommended especially when access is not password
         protected.
-      </description>
+      </_description>
       <default>true</default>
     </key>
 
     <key name='view-only' type='b'>
-      <summary>Only allow remote users to view the desktop</summary>
-      <description>
+      <_summary>Only allow remote users to view the desktop</_summary>
+      <_description>
         If true, remote users accessing the desktop are only allowed to
         view the desktop. Remote users will not be able to use the mouse
         or keyboard.
-      </description>
+      </_description>
       <default>false</default>
     </key>
 
     <key name='network-interface' type='s'>
-      <summary>Network interface for listening</summary>
-      <description>
+      <_summary>Network interface for listening</_summary>
+      <_description>
         If not set, the server will listen on all network interfaces.
 
         Set this if you want that accept connections only from some
         specific network interface. eg: eth0, wifi0, lo, ...
-      </description>
+      </_description>
       <default>''</default>
     </key>
 
     <key name='use-alternative-port' type='b'>
-      <summary>Listen an alternative port</summary>
-      <description>
+      <_summary>Listen an alternative port</_summary>
+      <_description>
         If true, the server will listen to another port, instead of the
         default (5900). The port must be specified in the
         'alternative-port' key.
-      </description>
+      </_description>
       <default>false</default>
     </key>
 
     <key name='alternative-port' type='q'>
-      <summary>Alternative port number</summary>
-      <description>
+      <_summary>Alternative port number</_summary>
+      <_description>
         The port which the server will listen to if the
         'use-alternative-port' key is set to true.  Valid values are in
         the range from 5000 to 50000.
-      </description>
+      </_description>
       <default>5900</default>
     </key>
 
     <key name='require-encryption' type='b'>
-      <summary>Require encryption</summary>
-      <description>
+      <_summary>Require encryption</_summary>
+      <_description>
         If true, remote users accessing the desktop are required to
         support encryption. It is highly recommended that you use a
         client which supports encryption unless the intervening network
         is trusted.
-      </description>
+      </_description>
       <default>false</default>
     </key>
 
     <key name='authentication-methods' type='as'>
-      <summary>Allowed authentication methods</summary>
-      <description>
+      <_summary>Allowed authentication methods</_summary>
+      <_description>
         Lists the authentication methods with which remote users may
         access the desktop.
 
@@ -82,7 +82,7 @@
         remote user to be prompted for a password (the password is
         specified by the vnc-password key) before connecting and "none"
         which allows any remote user to connect.
-      </description>
+      </_description>
       <choices>
         <choice value='none'/>
         <choice value='vnc'/>
@@ -91,79 +91,74 @@
     </key>
 
     <key name='vnc-password' type='s'>
-      <summary>Password required for "vnc" authentication</summary>
-      <description>
+      <_summary>Password required for "vnc" authentication</_summary>
+      <_description>
         The password which the remote user will be prompted for if the
         "vnc" authentication method is used. The password specified by
         the key is base64 encoded.
 
         The special value of 'keyring' (which is not valid base64) means
         that the password is stored in the GNOME keyring.
-      </description>
+      </_description>
       <default>'keyring'</default>
     </key>
 
     <key name='mailto' type='s'>
-      <summary>E-mail address to which the remote desktop URL should be sent</summary>
-      <description>
+      <_summary>E-mail address to which the remote desktop URL should be sent</_summary>
+      <_description>
         This key specifies the e-mail address to which the remote
         desktop URL should be sent if the user clicks on the URL in the
         Remote Desktop preferences dialog.
-      </description>
+      </_description>
       <default>''</default>
     </key>
 
     <key name='lock-screen-on-disconnect' type='b'>
-      <summary>Lock the screen when last user disconnect</summary>
-      <description>
+      <_summary>Lock the screen when last user disconnect</_summary>
+      <_description>
         If true, screen will be locked after the last remote client
         disconnect.
-      </description>
+      </_description>
       <default>false</default>
     </key>
 
-    <key name='icon-visibility' type='s'>
-      <summary>When the status icon should be shown</summary>
-      <description>
+    <key name='icon-visibility' enum="org.gnome.Vino.VinoIconVisibility">
+      <_summary>When the status icon should be shown</_summary>
+      <_description>
         This key controls the behavior of the status icon. There are
         three options: "always" - The icon will be always there;
         "client" - You will see the icon only when there is someone
         connected, this is the default behavior; "never" - Never shows
         the icon.
-      </description>
-      <choices>
-        <choice value='never'/>
-        <choice value='always'/>
-        <choice value='client'/>
-      </choices>
+      </_description>
       <default>'client'</default>
     </key>
 
     <key name='disable-background' type='b'>
-      <summary>When true, disable the background on receive valid session</summary>
-      <description>
+      <_summary>When true, disable the background on receive valid session</_summary>
+      <_description>
         When true, disable the background on receive valid session
-      </description>
+      </_description>
       <default>false</default>
     </key>
 
     <key name='use-upnp' type='b'>
-      <summary>Whether we should use UPNP to forward the port in routers</summary>
-      <description>
+      <_summary>Whether we should use UPNP to forward the port in routers</_summary>
+      <_description>
         If true, we will use UPNP protocol to automatically forward the
         port used by vino in the router.
-      </description>
+      </_description>
       <default>false</default>
     </key>
 
     <key name='disable-xdamage' type='b'>
-      <summary>Whether we should disable the XDamage extension of X.org</summary>
-      <description>
+      <_summary>Whether we should disable the XDamage extension of X.org</_summary>
+      <_description>
         If true, we will not use the XDamage extension of X.org. This
         extension does not work properly on some video drivers when
         using 3D effects.  Disabling it will make vino work on these
         environments with a slower rendering as side effect.
-      </description>
+      </_description>
       <default>false</default>
     </key>
   </schema>
diff --git a/configure.in b/configure.in
index 8e4e035..38ef967 100644
--- a/configure.in
+++ b/configure.in
@@ -33,16 +33,17 @@ AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
 
 GTK_VERSION=2.99.0
 GLIB_VERSION=2.17.0
+GIO_VERSION=2.26
 DBUS_VERSION=1.2.3
 SOUP_VERSION=2.24.0
 TELEPATHY_GLIB_VERSION=0.11.6
 NETWORKMANAGER_VERSION=0.7
 
-PKG_CHECK_MODULES(VINO_SERVER, glib-2.0 >= $GLIB_VERSION gtk+-x11-3.0 >= $GTK_VERSION)
+PKG_CHECK_MODULES(VINO_SERVER, glib-2.0 >= $GLIB_VERSION gio-unix-2.0 gtk+-x11-3.0 >= $GTK_VERSION)
 
-PKG_CHECK_MODULES(VINO_CAPPLET, glib-2.0 >= $GLIB_VERSION gtk+-3.0 >= $GTK_VERSION libsoup-2.4 >= $SOUP_VERSION)
+PKG_CHECK_MODULES(VINO_CAPPLET, glib-2.0 >= $GLIB_VERSION gio-2.0 >= GIO_VERSION gtk+-3.0 >= $GTK_VERSION libsoup-2.4 >= $SOUP_VERSION)
 
-PKG_CHECK_MODULES(VINO_TOOLS, glib-2.0 >= $GLIB_VERSION gobject-2.0 >= $GLIB_VERSION gnome-keyring-1)
+PKG_CHECK_MODULES(VINO_TOOLS, glib-2.0 >= $GLIB_VERSION gio-2.0 >= GIO_VERSION gobject-2.0 >= $GLIB_VERSION gnome-keyring-1)
 
 # EGG stuff
 PKG_CHECK_MODULES(EGG, gtk+-3.0 >= $GTK_VERSION)
diff --git a/tools/vino-passwd.c b/tools/vino-passwd.c
index c5a8801..91f5f48 100644
--- a/tools/vino-passwd.c
+++ b/tools/vino-passwd.c
@@ -35,15 +35,15 @@
 
 #include <glib.h>
 #include <glib/gi18n.h>
-#include <gconf/gconf-client.h>
+#include <gio/gio.h>
 
 #ifdef VINO_ENABLE_KEYRING
 #include <gnome-keyring.h>
 #endif
 
-#define VINO_PREFS_DIR			"/desktop/gnome/remote_access"
-#define VINO_PREFS_VNC_PASSWORD		VINO_PREFS_DIR "/vnc_password"
-#define VINO_PASSWORD_MAXLEN		8
+#define VINO_PREFS_SCHEMA       "org.gnome.Vino"
+#define VINO_PREFS_VNC_PASSWORD "vnc-password"
+#define VINO_PASSWORD_MAXLEN	8
 
 static gboolean
 vino_passwd_set_password_in_keyring (const char *password)
@@ -71,7 +71,7 @@ vino_passwd_set_password_in_keyring (const char *password)
 }
 
 static void
-vino_passwd_set_password (GConfClient *conf, 
+vino_passwd_set_password (GSettings *settings,
                           const char *password)
 {
   gchar *password_b64;
@@ -80,7 +80,7 @@ vino_passwd_set_password (GConfClient *conf,
     return;
 
   password_b64 = g_base64_encode ((guchar *) password, strlen (password));
-  gconf_client_set_string (conf, VINO_PREFS_VNC_PASSWORD, password_b64, NULL);
+  g_settings_set_string (settings, VINO_PREFS_VNC_PASSWORD, password_b64);
   g_free (password_b64);
 }
 
@@ -148,7 +148,7 @@ vino_passwd_read (char *buff,
 }
 
 static int
-vino_passwd_change (GConfClient *conf)
+vino_passwd_change (GSettings *settings)
 {
   gchar password1[VINO_PASSWORD_MAXLEN + 1];
   gchar password2[VINO_PASSWORD_MAXLEN + 1];
@@ -163,7 +163,7 @@ vino_passwd_change (GConfClient *conf)
 
   if (g_str_equal (password1, password2))
     {
-      vino_passwd_set_password (conf, password1);
+      vino_passwd_set_password (settings, password1);
       g_print (_("vino-passwd: password updated successfully.\n"));
       return 0;
     }
@@ -175,23 +175,12 @@ vino_passwd_change (GConfClient *conf)
     }
 }
 
-static void
-gconf_error_handle (GConfClient *client, GError *error)
-{
-  g_print (_("Error while communicating with GConf. Are you logged into a GNOME session?"));
-  g_print ("\n");
-  g_print (_("Error message:"));
-  g_print ("\n\n%s\n\n", error->message);
-
-  exit (1);
-}
-
 int 
 main(int argc, char *argv[])
 {
   gboolean       opt_version = FALSE;
   GError         *error      = NULL;
-  GConfClient    *conf       = NULL;
+  GSettings      *settings   = NULL;
   GOptionContext *context    = NULL;  
   
   const GOptionEntry entries[] = 
@@ -228,11 +217,10 @@ main(int argc, char *argv[])
    }
 
   g_type_init ();
-  gconf_client_set_global_default_error_handler (gconf_error_handle);
-  conf = gconf_client_get_default ();
+  settings = g_settings_new (VINO_PREFS_SCHEMA);
 
-  if (gconf_client_key_is_writable (conf, VINO_PREFS_VNC_PASSWORD, NULL))
-    return vino_passwd_change (conf);
+  if (g_settings_is_writable (settings, VINO_PREFS_VNC_PASSWORD))
+    return vino_passwd_change (settings);
   else
     {
       g_printerr (_("ERROR: You do not have enough permissions to change Vino password.\n"));



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