[vinagre/plugin] Added last-protocol property to VinagrePrefs object.
- From: Jonh Wendell <jwendell src gnome org>
- To: svn-commits-list gnome org
- Subject: [vinagre/plugin] Added last-protocol property to VinagrePrefs object.
- Date: Wed, 22 Jul 2009 19:57:56 +0000 (UTC)
commit 9970038f9439ef3d3596613e6ca76f0a6d48f0df
Author: Jonh Wendell <jwendell gnome org>
Date: Wed Jul 22 13:17:10 2009 -0300
Added last-protocol property to VinagrePrefs object.
This property holds the last protocol used in connect dialog.
vinagre/vinagre-prefs.c | 60 +++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 55 insertions(+), 5 deletions(-)
---
diff --git a/vinagre/vinagre-prefs.c b/vinagre/vinagre-prefs.c
index 4b74539..35fe003 100644
--- a/vinagre/vinagre-prefs.c
+++ b/vinagre/vinagre-prefs.c
@@ -37,6 +37,7 @@
#define VM_WINDOW_WIDTH VINAGRE_BASE_KEY "/window_width"
#define VM_WINDOW_HEIGHT VINAGRE_BASE_KEY "/window_height"
#define VM_SIDE_PANEL_SIZE VINAGRE_BASE_KEY "/side_panel_size"
+#define VM_LAST_PROTOCOL VINAGRE_BASE_KEY "/last_protocol"
#define VINAGRE_PLUGINS_DIR VINAGRE_BASE_KEY "/plugins"
#define VM_ACTIVE_PLUGINS VINAGRE_PLUGINS_DIR "/active-plugins"
@@ -61,7 +62,8 @@ enum
PROP_SIDE_PANEL_SIZE,
PROP_SHOW_ACCELS,
PROP_HISTORY_SIZE,
- PROP_ACTIVE_PLUGINS
+ PROP_ACTIVE_PLUGINS,
+ PROP_LAST_PROTOCOL
};
G_DEFINE_TYPE (VinagrePrefs, vinagre_prefs, G_TYPE_OBJECT);
@@ -127,6 +129,31 @@ vinagre_prefs_get_int (VinagrePrefs *prefs, const gchar* key, gint def)
return def;
}
+static const gchar *
+vinagre_prefs_get_string (VinagrePrefs *prefs, const gchar *key, const gchar *def)
+{
+ GError* error = NULL;
+ GConfValue* val;
+
+ val = gconf_client_get (prefs->priv->gconf_client, key, &error);
+
+ if (val != NULL)
+ {
+ const gchar *retval = def;
+
+ g_return_val_if_fail (error == NULL, retval);
+
+ if (val->type == GCONF_VALUE_STRING)
+ retval = gconf_value_get_string (val);
+
+ gconf_value_free (val);
+
+ return retval;
+ }
+ else
+ return def;
+}
+
static GSList *
vinagre_prefs_get_list (VinagrePrefs *prefs, const gchar* key)
{
@@ -136,25 +163,34 @@ vinagre_prefs_get_list (VinagrePrefs *prefs, const gchar* key)
NULL);
}
-static void
+static void
vinagre_prefs_set_bool (VinagrePrefs *prefs, const gchar* key, gboolean value)
{
g_return_if_fail (gconf_client_key_is_writable (
prefs->priv->gconf_client, key, NULL));
-
+
gconf_client_set_bool (prefs->priv->gconf_client, key, value, NULL);
}
-static void
+static void
vinagre_prefs_set_int (VinagrePrefs *prefs, const gchar* key, gint value)
{
g_return_if_fail (gconf_client_key_is_writable (
prefs->priv->gconf_client, key, NULL));
-
+
gconf_client_set_int (prefs->priv->gconf_client, key, value, NULL);
}
static void
+vinagre_prefs_set_string (VinagrePrefs *prefs, const gchar *key, const gchar *value)
+{
+ g_return_if_fail (gconf_client_key_is_writable (
+ prefs->priv->gconf_client, key, NULL));
+
+ gconf_client_set_string (prefs->priv->gconf_client, key, value, NULL);
+}
+
+static void
vinagre_prefs_set_list (VinagrePrefs *prefs, const gchar* key, GSList *list)
{
g_return_if_fail (gconf_client_key_is_writable (
@@ -253,6 +289,9 @@ vinagre_prefs_set_property (GObject *object, guint prop_id, const GValue *value,
case PROP_ACTIVE_PLUGINS:
vinagre_prefs_set_list (prefs, VM_ACTIVE_PLUGINS, g_value_get_pointer (value));
break;
+ case PROP_LAST_PROTOCOL:
+ vinagre_prefs_set_string (prefs, VM_LAST_PROTOCOL, g_value_get_string (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -302,6 +341,9 @@ vinagre_prefs_get_property (GObject *object, guint prop_id, GValue *value, GPara
case PROP_ACTIVE_PLUGINS:
g_value_set_pointer (value, vinagre_prefs_get_list (prefs, VM_ACTIVE_PLUGINS));
break;
+ case PROP_LAST_PROTOCOL:
+ g_value_set_string (value, vinagre_prefs_get_string (prefs, VM_LAST_PROTOCOL, NULL));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -423,6 +465,14 @@ vinagre_prefs_class_init (VinagrePrefsClass *klass)
"The list of active plugins",
G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_LAST_PROTOCOL,
+ g_param_spec_string ("last-protocol",
+ "Last Protocol",
+ "The last protocol used in connect dialog",
+ NULL,
+ G_PARAM_READWRITE));
+
}
/* Preferences dialog */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]