[vinagre] gsettings: complete migration gconf -> gsettings
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vinagre] gsettings: complete migration gconf -> gsettings
- Date: Wed, 23 Feb 2011 16:23:02 +0000 (UTC)
commit 255986ee62a9deec960141d225ea4a636398a82d
Author: Marc-André Lureau <marcandre lureau redhat com>
Date: Wed Feb 23 15:36:32 2011 +0100
gsettings: complete migration gconf -> gsettings
https://bugzilla.gnome.org/show_bug.cgi?id=625895
configure.ac | 9 --
vinagre/vinagre-plugins-engine.c | 32 ++----
vinagre/vinagre-prefs.c | 270 ++++++--------------------------------
vinagre/vinagre-prefs.h | 4 +-
vinagre/vinagre-window.c | 9 +-
5 files changed, 59 insertions(+), 265 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index c8742e0..8a5a9f1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,7 +73,6 @@ GNOME_DOC_INIT
GLIB_REQUIRED=2.25.11
GTK_REQUIRED=2.99.3
-GCONF_REQUIRED=2.16.0
GTHREAD_REQUIRED=2.0.0
GTK_VNC_REQUIRED=0.4.3
AVAHI_REQUIRED=0.6.26
@@ -104,7 +103,6 @@ PKG_CHECK_MODULES(VINAGRE, \
gio-2.0 >= $GLIB_REQUIRED \
gio-unix-2.0 >= $GLIB_REQUIRED \
gtk+-3.0 >= $GTK_REQUIRED \
- gconf-2.0 >= $GCONF_REQUIRED \
gthread-2.0 >= $GTHREAD_REQUIRED \
gnome-keyring-1 \
libxml-2.0 >= $XML_REQUIRED \
@@ -217,13 +215,6 @@ if test "x$enable_applet" = "xyes";then
fi
AM_CONDITIONAL(APPLET, test "x$enable_applet" = "xyes")
-dnl ================================================================
-dnl GConf related settings
-dnl ================================================================
-
-AC_PATH_PROG(GCONFTOOL, gconftool-2)
-AM_GCONF_SOURCE_2
-
GLIB_GSETTINGS
dnl Check for bind in libsocket (needed on Solaris)
diff --git a/vinagre/vinagre-plugins-engine.c b/vinagre/vinagre-plugins-engine.c
index 75c4f19..7c7ccff 100644
--- a/vinagre/vinagre-plugins-engine.c
+++ b/vinagre/vinagre-plugins-engine.c
@@ -48,31 +48,22 @@ VinagrePluginsEngine *default_engine = NULL;
static void
vinagre_plugins_engine_load_extensions (VinagrePluginsEngine *engine)
{
- GSList *plugins, *l;
- gchar **loaded_plugins;
- gint i;
+ GStrv plugins;
g_object_get (vinagre_prefs_get_default (),
"active-plugins", &plugins,
NULL);
- loaded_plugins = g_new0 (gchar *, g_slist_length (plugins) + 1);
- i = 0;
- for (l = plugins; l; l = l->next)
- loaded_plugins[i++] = (l->data);
-
engine->priv->loading_plugin_list = TRUE;
- peas_engine_set_loaded_plugins (PEAS_ENGINE (engine),
- (const gchar **) loaded_plugins);
+ peas_engine_set_loaded_plugins (PEAS_ENGINE (engine), (const gchar **)plugins);
engine->priv->loading_plugin_list = FALSE;
- g_strfreev (loaded_plugins);
- g_slist_free (plugins);
+ g_strfreev (plugins);
}
static void
vinagre_plugins_engine_extension_added (PeasExtensionSet *extensions,
- PeasPluginInfo *info,
- PeasExtension *exten,
+ PeasPluginInfo *info,
+ PeasExtension *exten,
VinagrePluginsEngine *engine)
{
PeasExtension *previous_ext;
@@ -97,7 +88,7 @@ vinagre_plugins_engine_extension_added (PeasExtensionSet *extensions,
static void
vinagre_plugins_engine_extension_removed (PeasExtensionSet *extensions,
PeasPluginInfo *info,
- PeasExtension *exten,
+ PeasExtension *exten,
VinagrePluginsEngine *engine)
{
const gchar *protocol = NULL;
@@ -190,23 +181,18 @@ static void
save_plugin_list (VinagrePluginsEngine *engine)
{
gchar **loaded_plugins;
- GSList *plugins = NULL;
- gint i;
loaded_plugins = peas_engine_get_loaded_plugins (PEAS_ENGINE (engine));
- for (i = 0; loaded_plugins[i]; i++)
- plugins = g_slist_prepend (plugins, loaded_plugins[i]);
g_object_set (vinagre_prefs_get_default (),
- "active-plugins", plugins,
+ "active-plugins", loaded_plugins,
NULL);
g_strfreev (loaded_plugins);
- g_slist_free (plugins);
}
static void
-vinagre_plugins_engine_load_plugin (PeasEngine *engine,
+vinagre_plugins_engine_load_plugin (PeasEngine *engine,
PeasPluginInfo *info)
{
VinagrePluginsEngine *vengine = VINAGRE_PLUGINS_ENGINE (engine);
@@ -295,7 +281,7 @@ vinagre_plugins_engine_get_default (void)
*/
VinagreProtocol *
vinagre_plugins_engine_get_plugin_by_protocol (VinagrePluginsEngine *engine,
- const gchar *protocol)
+ const gchar *protocol)
{
g_return_val_if_fail (VINAGRE_IS_PLUGINS_ENGINE (engine), NULL);
diff --git a/vinagre/vinagre-prefs.c b/vinagre/vinagre-prefs.c
index d9ce37e..78286b1 100644
--- a/vinagre/vinagre-prefs.c
+++ b/vinagre/vinagre-prefs.c
@@ -18,23 +18,21 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <gconf/gconf-client.h>
#include <glib/gi18n.h>
#include "vinagre-prefs.h"
#include "vinagre-utils.h"
-#define VINAGRE_BASE_KEY "/apps/vinagre"
-#define VM_ALWAYS_SHOW_TABS VINAGRE_BASE_KEY "/always_show_tabs"
-#define VM_SHOW_ACCELS VINAGRE_BASE_KEY "/show_accels"
-#define VM_HISTORY_SIZE VINAGRE_BASE_KEY "/history_size"
-#define VM_ALWAYS_ENABLE_LISTENING VINAGRE_BASE_KEY "/always_enable_listening"
-#define VM_SHARED_FLAG VINAGRE_BASE_KEY "/shared_flag"
-#define VINAGRE_PLUGINS_DIR VINAGRE_BASE_KEY "/plugins"
-#define VM_ACTIVE_PLUGINS VINAGRE_PLUGINS_DIR "/active-plugins"
+#define VINAGRE_SCHEMA_NAME "org.gnome.Vinagre"
+#define VM_ALWAYS_SHOW_TABS "always-show-tabs"
+#define VM_SHOW_ACCELS "show-accels"
+#define VM_HISTORY_SIZE "history-size"
+#define VM_ALWAYS_ENABLE_LISTENING "always-enable-listening"
+#define VM_SHARED_FLAG "shared-flag"
+#define VM_ACTIVE_PLUGINS "active-plugins"
struct _VinagrePrefsPrivate
{
- GConfClient *gconf_client;
+ GSettings *gsettings;
};
/* Properties */
@@ -42,8 +40,6 @@ enum
{
PROP_0,
PROP_SHARED_FLAG,
- PROP_ALWAYS_SHOW_TABS,
- PROP_SHOW_ACCELS,
PROP_HISTORY_SIZE,
PROP_ACTIVE_PLUGINS,
PROP_LAST_PROTOCOL,
@@ -64,123 +60,21 @@ vinagre_prefs_get_default (void)
{
if (G_UNLIKELY (!prefs_singleton))
prefs_singleton = VINAGRE_PREFS (g_object_new (VINAGRE_TYPE_PREFS,
- NULL));
+ NULL));
return prefs_singleton;
}
-static gboolean
-vinagre_prefs_get_bool (VinagrePrefs *prefs, const gchar* key, gboolean def)
-{
- GError* error = NULL;
- GConfValue* val;
-
- val = gconf_client_get (prefs->priv->gconf_client, key, &error);
-
- if (val != NULL)
- {
- gboolean retval = def;
-
- g_return_val_if_fail (error == NULL, retval);
-
- if (val->type == GCONF_VALUE_BOOL)
- retval = gconf_value_get_bool (val);
-
- gconf_value_free (val);
-
- return retval;
- }
- else
- return def;
-}
-
-static gboolean
-vinagre_prefs_get_int (VinagrePrefs *prefs, const gchar* key, gint def)
-{
- GError* error = NULL;
- GConfValue* val;
-
- val = gconf_client_get (prefs->priv->gconf_client, key, &error);
-
- if (val != NULL)
- {
- gint retval = def;
-
- g_return_val_if_fail (error == NULL, retval);
-
- if (val->type == GCONF_VALUE_INT)
- retval = gconf_value_get_int (val);
-
- gconf_value_free (val);
-
- return retval;
- }
- else
- return def;
-}
-
-static GSList *
-vinagre_prefs_get_list (VinagrePrefs *prefs, const gchar* key)
-{
- return gconf_client_get_list (prefs->priv->gconf_client,
- key,
- GCONF_VALUE_STRING,
- NULL);
-}
-
-static void
-vinagre_prefs_set_bool (VinagrePrefs *prefs, const gchar* key, gboolean value)
-{
- GError *error = NULL;
-
- if (!gconf_client_set_bool (prefs->priv->gconf_client, key, value, &error))
- {
- g_warning ("Setting key %s failed: %s", key, error->message);
- g_error_free (error);
- }
-}
-
-static void
-vinagre_prefs_set_int (VinagrePrefs *prefs, const gchar* key, gint value)
-{
- GError *error = NULL;
-
- if (!gconf_client_set_int (prefs->priv->gconf_client, key, value, &error))
- {
- g_warning ("Setting key %s failed: %s", key, error->message);
- g_error_free (error);
- }
-}
-
-static void
-vinagre_prefs_set_list (VinagrePrefs *prefs, const gchar* key, GSList *list)
-{
- GError *error = NULL;
-
- if (!gconf_client_set_list (prefs->priv->gconf_client, key,
- GCONF_VALUE_STRING, list,
- &error))
- {
- g_warning ("Setting key %s failed: %s", key, error->message);
- g_error_free (error);
- }
-}
-
-static void
-vinagre_prefs_always_show_tabs_notify (GConfClient *client,
- guint cnx_id,
- GConfEntry *entry,
- VinagrePrefs *prefs)
+/**
+ * vinagre_prefs_get_default_gsettings:
+ *
+ * Return value: (transfer none):
+ */
+GSettings *
+vinagre_prefs_get_default_gsettings (void)
{
- g_object_notify (G_OBJECT (prefs), "always-show-tabs");
-}
+ VinagrePrefs *pref = vinagre_prefs_get_default ();
-static void
-vinagre_prefs_show_accels_notify (GConfClient *client,
- guint cnx_id,
- GConfEntry *entry,
- VinagrePrefs *prefs)
-{
- g_object_notify (G_OBJECT (prefs), "show-accels");
+ return pref->priv->gsettings;
}
static void
@@ -188,23 +82,10 @@ vinagre_prefs_init (VinagrePrefs *prefs)
{
prefs->priv = G_TYPE_INSTANCE_GET_PRIVATE (prefs, VINAGRE_TYPE_PREFS, VinagrePrefsPrivate);
- prefs->priv->gconf_client = gconf_client_get_default ();
- if (prefs->priv->gconf_client == NULL)
+ prefs->priv->gsettings = g_settings_new (VINAGRE_SCHEMA_NAME);
+ if (prefs->priv->gsettings == NULL)
g_critical (_("Cannot initialize preferences manager."));
- gconf_client_add_dir (prefs->priv->gconf_client,
- VINAGRE_BASE_KEY,
- GCONF_CLIENT_PRELOAD_ONELEVEL,
- NULL);
-
- gconf_client_notify_add (prefs->priv->gconf_client,
- VM_ALWAYS_SHOW_TABS,
- (GConfClientNotifyFunc) vinagre_prefs_always_show_tabs_notify,
- prefs, NULL, NULL);
- gconf_client_notify_add (prefs->priv->gconf_client,
- VM_SHOW_ACCELS,
- (GConfClientNotifyFunc) vinagre_prefs_show_accels_notify,
- prefs, NULL, NULL);
}
static void
@@ -215,22 +96,16 @@ vinagre_prefs_set_property (GObject *object, guint prop_id, const GValue *value,
switch (prop_id)
{
case PROP_SHARED_FLAG:
- vinagre_prefs_set_bool (prefs, VM_SHARED_FLAG, g_value_get_boolean (value));
- break;
- case PROP_ALWAYS_SHOW_TABS:
- vinagre_prefs_set_bool (prefs, VM_ALWAYS_SHOW_TABS, g_value_get_boolean (value));
- break;
- case PROP_SHOW_ACCELS:
- vinagre_prefs_set_bool (prefs, VM_SHOW_ACCELS, g_value_get_boolean (value));
+ g_settings_set_boolean (prefs->priv->gsettings, VM_SHARED_FLAG, g_value_get_boolean (value));
break;
case PROP_HISTORY_SIZE:
- vinagre_prefs_set_int (prefs, VM_HISTORY_SIZE, g_value_get_int (value));
+ g_settings_set_int (prefs->priv->gsettings, VM_HISTORY_SIZE, g_value_get_int (value));
break;
case PROP_ACTIVE_PLUGINS:
- vinagre_prefs_set_list (prefs, VM_ACTIVE_PLUGINS, g_value_get_pointer (value));
+ g_settings_set_strv (prefs->priv->gsettings, VM_ACTIVE_PLUGINS, g_value_get_boxed (value));
break;
case PROP_ALWAYS_ENABLE_LISTENING:
- vinagre_prefs_set_bool (prefs, VM_ALWAYS_ENABLE_LISTENING, g_value_get_boolean (value));
+ g_settings_set_boolean (prefs->priv->gsettings, VM_ALWAYS_ENABLE_LISTENING, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -246,22 +121,16 @@ vinagre_prefs_get_property (GObject *object, guint prop_id, GValue *value, GPara
switch (prop_id)
{
case PROP_SHARED_FLAG:
- g_value_set_boolean (value, vinagre_prefs_get_bool (prefs, VM_SHARED_FLAG, TRUE));
- break;
- case PROP_ALWAYS_SHOW_TABS:
- g_value_set_boolean (value, vinagre_prefs_get_bool (prefs, VM_ALWAYS_SHOW_TABS, FALSE));
- break;
- case PROP_SHOW_ACCELS:
- g_value_set_boolean (value, vinagre_prefs_get_bool (prefs, VM_SHOW_ACCELS, TRUE));
+ g_value_set_boolean (value, g_settings_get_boolean (prefs->priv->gsettings, VM_SHARED_FLAG));
break;
case PROP_HISTORY_SIZE:
- g_value_set_int (value, vinagre_prefs_get_int (prefs, VM_HISTORY_SIZE, 15));
+ g_value_set_int (value, g_settings_get_int (prefs->priv->gsettings, VM_HISTORY_SIZE));
break;
case PROP_ACTIVE_PLUGINS:
- g_value_set_pointer (value, vinagre_prefs_get_list (prefs, VM_ACTIVE_PLUGINS));
+ g_value_set_boxed (value, g_settings_get_strv (prefs->priv->gsettings, VM_ACTIVE_PLUGINS));
break;
case PROP_ALWAYS_ENABLE_LISTENING:
- g_value_set_boolean (value, vinagre_prefs_get_bool (prefs, VM_ALWAYS_ENABLE_LISTENING, FALSE));
+ g_value_set_boolean (value, g_settings_get_boolean (prefs->priv->gsettings, VM_ALWAYS_ENABLE_LISTENING));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -274,13 +143,10 @@ vinagre_prefs_dispose (GObject *object)
{
VinagrePrefs *prefs = VINAGRE_PREFS (object);
- if (prefs->priv->gconf_client)
+ if (prefs->priv->gsettings)
{
- gconf_client_remove_dir (prefs->priv->gconf_client,
- VINAGRE_BASE_KEY,
- NULL);
- g_object_unref (prefs->priv->gconf_client);
- prefs->priv->gconf_client = NULL;
+ g_object_unref (prefs->priv->gsettings);
+ prefs->priv->gsettings = NULL;
}
G_OBJECT_CLASS (vinagre_prefs_parent_class)->dispose (object);
@@ -304,35 +170,22 @@ vinagre_prefs_class_init (VinagrePrefsClass *klass)
"Shared Flag",
"Whether we should share the remote connection",
TRUE,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_ALWAYS_SHOW_TABS,
- g_param_spec_boolean ("always-show-tabs",
- "Always show tabs",
- "Whether we should show the tabs even when there is ony one active connection",
- FALSE,
- G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_SHOW_ACCELS,
- g_param_spec_boolean ("show-accels",
- "Show menu accelerators",
- "Whether we should show the menu accelerators (keyboard shortcuts)",
- FALSE,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class,
PROP_HISTORY_SIZE,
g_param_spec_int ("history-size",
"History size",
"Max number of items in history dropdown entry",
0, G_MAXINT, 15,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class,
PROP_ACTIVE_PLUGINS,
- g_param_spec_pointer ("active-plugins",
- "Active plugins",
- "The list of active plugins",
- G_PARAM_READWRITE));
+ g_param_spec_boxed ("active-plugins",
+ "Active plugins",
+ "The list of active plugins",
+ G_TYPE_STRV,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class,
PROP_ALWAYS_ENABLE_LISTENING,
@@ -340,7 +193,7 @@ vinagre_prefs_class_init (VinagrePrefsClass *klass)
"Always enable listening",
"Whether we always should listen for reverse connections",
FALSE,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
/* Preferences dialog */
@@ -354,20 +207,6 @@ typedef struct {
} VinagrePrefsDialog;
static void
-vinagre_prefs_dialog_setup (VinagrePrefsDialog *dialog)
-{
- gboolean show_accels, show_tabs;
-
- g_object_get (vinagre_prefs_get_default (),
- "show-accels", &show_accels,
- "always-show-tabs", &show_tabs,
- NULL);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->show_accels), show_accels);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->show_tabs), show_tabs);
-}
-
-static void
vinagre_prefs_dialog_response (GtkDialog *d, gint response_id, VinagrePrefsDialog *dialog)
{
if (response_id > 0)
@@ -382,26 +221,11 @@ vinagre_prefs_dialog_response (GtkDialog *d, gint response_id, VinagrePrefsDialo
dialog = NULL;
}
-static void
-vinagre_prefs_dialog_show_tabs_cb (VinagrePrefsDialog *dialog)
-{
- g_object_set (vinagre_prefs_get_default (),
- "always-show-tabs", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->show_tabs)),
- NULL);
-}
-
-static void
-vinagre_prefs_dialog_show_accels_cb (VinagrePrefsDialog *dialog)
-{
- g_object_set (vinagre_prefs_get_default (),
- "show-accels", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->show_accels)),
- NULL);
-}
-
void
vinagre_prefs_dialog_show (VinagreWindow *window)
{
VinagrePrefsDialog *dialog;
+ VinagrePrefs *pref;
dialog = g_new (VinagrePrefsDialog, 1);
@@ -413,23 +237,15 @@ vinagre_prefs_dialog_show (VinagreWindow *window)
dialog->show_tabs = GTK_WIDGET (gtk_builder_get_object (dialog->xml, "always_show_tabs_check"));
dialog->show_accels = GTK_WIDGET (gtk_builder_get_object (dialog->xml, "show_accels_check"));
- vinagre_prefs_dialog_setup (dialog);
+ pref = vinagre_prefs_get_default ();
+ g_settings_bind (pref->priv->gsettings, "always-show-tabs", dialog->show_tabs, "active", G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (pref->priv->gsettings, "show-accels", dialog->show_accels, "active", G_SETTINGS_BIND_DEFAULT);
g_signal_connect (dialog->dialog,
"response",
G_CALLBACK (vinagre_prefs_dialog_response),
dialog);
- g_signal_connect_swapped (dialog->show_tabs,
- "toggled",
- G_CALLBACK (vinagre_prefs_dialog_show_tabs_cb),
- dialog);
-
- g_signal_connect_swapped (dialog->show_accels,
- "toggled",
- G_CALLBACK (vinagre_prefs_dialog_show_accels_cb),
- dialog);
-
gtk_widget_show_all (dialog->dialog);
}
/* vim: set ts=8: */
diff --git a/vinagre/vinagre-prefs.h b/vinagre/vinagre-prefs.h
index ae7827a..5340e56 100644
--- a/vinagre/vinagre-prefs.h
+++ b/vinagre/vinagre-prefs.h
@@ -50,9 +50,11 @@ struct _VinagrePrefs
GType vinagre_prefs_get_type (void) G_GNUC_CONST;
-VinagrePrefs *vinagre_prefs_get_default (void);
+VinagrePrefs * vinagre_prefs_get_default (void);
+GSettings * vinagre_prefs_get_default_gsettings (void);
void vinagre_prefs_dialog_show (VinagreWindow *window);
+
G_END_DECLS
#endif /* _VINAGRE_PREFS_H_ */
diff --git a/vinagre/vinagre-window.c b/vinagre/vinagre-window.c
index d1561bd..31fef8a 100644
--- a/vinagre/vinagre-window.c
+++ b/vinagre/vinagre-window.c
@@ -314,9 +314,8 @@ show_hide_accels (VinagreWindow *window)
{
gboolean show_accels;
- g_object_get (vinagre_prefs_get_default (),
- "show-accels", &show_accels,
- NULL);
+ show_accels = g_settings_get_boolean (vinagre_prefs_get_default_gsettings (), "show-accels");
+
g_object_set (gtk_settings_get_default (),
"gtk-enable-accels", show_accels,
"gtk-enable-mnemonics", show_accels,
@@ -472,8 +471,8 @@ create_menu_bar_and_toolbar (VinagreWindow *window,
G_CALLBACK (recent_manager_changed),
window);
- g_signal_connect_swapped (vinagre_prefs_get_default (),
- "notify::show-accels",
+ g_signal_connect_swapped (vinagre_prefs_get_default_gsettings (),
+ "changed::show-accels",
G_CALLBACK (show_hide_accels),
window);
show_hide_accels (window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]