[vinagre] Use XDG_CACHE_HOME to store window size, panel state, etc.



commit 763adc737257c4818c141c07703ae9b06059cfb0
Author: Jonh Wendell <jwendell gnome org>
Date:   Fri Jan 29 11:46:34 2010 -0300

    Use XDG_CACHE_HOME to store window size, panel state, etc.
    
    Closes #583210.

 po/POTFILES.in                |    1 +
 vinagre/Makefile.am           |    3 +
 vinagre/vinagre-cache-prefs.c |  151 +++++++++++++++++++++++++++++++++++++++++
 vinagre/vinagre-cache-prefs.h |   42 +++++++++++
 vinagre/vinagre-commands.c    |   19 +++---
 vinagre/vinagre-connect.c     |    5 +-
 vinagre/vinagre-main.c        |    3 +
 vinagre/vinagre-prefs.c       |  128 +----------------------------------
 vinagre/vinagre-window.c      |   40 ++++-------
 9 files changed, 227 insertions(+), 165 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 2bd24ed..295f225 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -26,6 +26,7 @@ vinagre/vinagre-bookmarks.c
 vinagre/vinagre-bookmarks-migration.c
 vinagre/vinagre-bookmarks-tree.c
 vinagre/vinagre-bookmarks-ui.c
+vinagre/vinagre-cache-prefs.c
 vinagre/vinagre-commands.c
 vinagre/vinagre-connect.c
 vinagre/vinagre-connection.c
diff --git a/vinagre/Makefile.am b/vinagre/Makefile.am
index c91d079..844a91a 100644
--- a/vinagre/Makefile.am
+++ b/vinagre/Makefile.am
@@ -55,6 +55,7 @@ INST_H_FILES = \
   vinagre-window.h \
   vinagre-dnd.h \
   vinagre-ssh.h \
+  vinagre-cache-prefs.h \
   $(NULL)
 
 headerdir = $(prefix)/include/vinagre- VINAGRE_API_VERSION@/vinagre
@@ -96,6 +97,7 @@ handwritten_sources = \
   vinagre-spinner.c \
   pty_open.c \
   vinagre-ssh.c \
+  vinagre-cache-prefs.c \
   $(NULL)
 
 libvinagre_la_SOURCES = \
@@ -195,6 +197,7 @@ vinagre_applet_SOURCES =					\
 	vinagre-marshal.h vinagre-marshal.c \
 	pty_open.h pty_open.c \
 	vinagre-ssh.h vinagre-ssh.c \
+	vinagre-cache-prefs.h vinagre-cache-prefs.c \
 	$(NULL)
 
 if AVAHI
diff --git a/vinagre/vinagre-cache-prefs.c b/vinagre/vinagre-cache-prefs.c
new file mode 100644
index 0000000..65f8db5
--- /dev/null
+++ b/vinagre/vinagre-cache-prefs.c
@@ -0,0 +1,151 @@
+/*
+ * vinagre-cache-prefs.c
+ * This file is part of vinagre
+ *
+ * Copyright (C) Jonh Wendell 2010 <wendell bani com br>
+ *
+ * vinagre-prefs.c is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * vinagre-prefs.c is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib/gi18n.h>
+#include "vinagre-cache-prefs.h"
+
+static GKeyFile *keyfile = NULL;
+static char* filename = NULL;
+
+void
+vinagre_cache_prefs_init (void)
+{
+  keyfile = g_key_file_new ();
+  filename = g_build_filename (g_get_user_cache_dir (),
+                               "vinagre",
+                               "vinagre-prefs-cache.ini",
+                               NULL);
+
+  g_key_file_load_from_file (keyfile, filename, 0, NULL);
+}
+
+static void
+save_file (void)
+{
+  GError *error = NULL;
+  gchar *data = g_key_file_to_data (keyfile, NULL, NULL);
+  gchar *dir = g_build_filename (g_get_user_cache_dir (), "vinagre", NULL);
+
+  g_mkdir_with_parents (dir, 0775);
+
+  if (!g_file_set_contents (filename,
+			    data,
+			    -1,
+			    &error))
+    {
+      g_warning (_("Error while saving preferences: %s"), error ? error->message: _("Unknown error"));
+      g_clear_error (&error);
+    }
+
+  g_free (data);
+  g_free (dir);
+}
+
+void
+vinagre_cache_prefs_finalize (void)
+{
+  g_return_if_fail (keyfile != NULL);
+
+  save_file ();
+
+  g_key_file_free (keyfile);
+  keyfile = NULL;
+
+  g_free (filename);
+  filename = NULL;
+}
+
+gboolean
+vinagre_cache_prefs_get_boolean (const gchar *group, const gchar *key, gboolean default_value)
+{
+  gboolean result;
+  GError *error = NULL;
+
+  g_return_val_if_fail (keyfile != NULL, FALSE);
+
+  result = g_key_file_get_boolean (keyfile, group, key, &error);
+  if (error)
+    {
+      result = default_value;
+      g_error_free (error);
+    }
+
+  return result;
+}
+
+void
+vinagre_cache_prefs_set_boolean (const gchar *group, const gchar *key, gboolean value)
+{
+  g_return_if_fail (keyfile != NULL);
+
+  g_key_file_set_boolean (keyfile, group, key, value);
+}
+
+gchar *
+vinagre_cache_prefs_get_string (const gchar *group, const gchar *key, const gchar *default_value)
+{
+  gchar *result;
+  GError *error = NULL;
+
+  g_return_val_if_fail (keyfile != NULL, NULL);
+
+  result = g_key_file_get_string (keyfile, group, key, &error);
+  if (error)
+    {
+      result = g_strdup (default_value);
+      g_error_free (error);
+    }
+
+  return result;
+}
+
+void
+vinagre_cache_prefs_set_string (const gchar *group, const gchar *key, const gchar *value)
+{
+  g_return_if_fail (keyfile != NULL);
+
+  g_key_file_set_string (keyfile, group, key, value);
+}
+
+gint
+vinagre_cache_prefs_get_integer (const gchar *group, const gchar *key, gint default_value)
+{
+  gint result;
+  GError *error = NULL;
+
+  g_return_val_if_fail (keyfile != NULL, 0);
+
+  result = g_key_file_get_integer (keyfile, group, key, &error);
+  if (error)
+    {
+      result = default_value;
+      g_error_free (error);
+    }
+
+  return result;
+}
+
+void
+vinagre_cache_prefs_set_integer (const gchar *group, const gchar *key, gint value)
+{
+  g_return_if_fail (keyfile != NULL);
+
+  g_key_file_set_integer (keyfile, group, key, value);
+}
diff --git a/vinagre/vinagre-cache-prefs.h b/vinagre/vinagre-cache-prefs.h
new file mode 100644
index 0000000..1047e29
--- /dev/null
+++ b/vinagre/vinagre-cache-prefs.h
@@ -0,0 +1,42 @@
+/*
+ * vinagre-cache-prefs.h
+ * This file is part of vinagre
+ *
+ * Copyright (C) Jonh Wendell 2010 <wendell bani com br>
+ *
+ * vinagre-prefs.c is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * vinagre-prefs.c is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _VINAGRE_CACHE_PREFS_H_
+#define _VINAGRE_CACHE_PREFS_H_
+
+G_BEGIN_DECLS
+
+#include <glib.h>
+
+void vinagre_cache_prefs_init (void);
+void vinagre_cache_prefs_finalize (void);
+
+gboolean vinagre_cache_prefs_get_boolean (const gchar *group, const gchar *key, gboolean default_value);
+void     vinagre_cache_prefs_set_boolean (const gchar *group, const gchar *key, gboolean value);
+
+gchar *  vinagre_cache_prefs_get_string (const gchar *group, const gchar *key, const gchar *default_value);
+void     vinagre_cache_prefs_set_string (const gchar *group, const gchar *key, const gchar *value);
+
+gint     vinagre_cache_prefs_get_integer (const gchar *group, const gchar *key, gint default_value);
+void     vinagre_cache_prefs_set_integer (const gchar *group, const gchar *key, gint value);
+
+G_END_DECLS
+
+#endif /* _VINAGRE_CACHE_PREFS_H_ */
diff --git a/vinagre/vinagre-commands.c b/vinagre/vinagre-commands.c
index 0309ae5..5f38981 100644
--- a/vinagre/vinagre-commands.c
+++ b/vinagre/vinagre-commands.c
@@ -38,6 +38,7 @@
 #include "vinagre-fav.h"
 #include "vinagre-window-private.h"
 #include "vinagre-prefs.h"
+#include "vinagre-cache-prefs.h"
 #include "vinagre-plugin.h"
 #include "vinagre-plugin-info.h"
 #include "vinagre-plugin-info-priv.h"
@@ -247,9 +248,9 @@ vinagre_cmd_view_show_toolbar	(GtkAction     *action,
 
   vinagre_utils_toggle_widget_visible (window->priv->toolbar);
 
-  g_object_set (vinagre_prefs_get_default (),
-		"toolbar-visible", GTK_WIDGET_VISIBLE (window->priv->toolbar),
-		NULL);
+  vinagre_cache_prefs_set_boolean ("window",
+				   "toolbar-visible",
+				   GTK_WIDGET_VISIBLE (window->priv->toolbar));
 }
 
 void
@@ -260,9 +261,9 @@ vinagre_cmd_view_show_statusbar	(GtkAction     *action,
 
   vinagre_utils_toggle_widget_visible (window->priv->statusbar);
 
-  g_object_set (vinagre_prefs_get_default (),
-		"statusbar-visible", GTK_WIDGET_VISIBLE (window->priv->statusbar),
-		NULL);
+  vinagre_cache_prefs_set_boolean ("window",
+				   "statusbar-visible",
+				   GTK_WIDGET_VISIBLE (window->priv->statusbar));
 }
 
 void
@@ -273,9 +274,9 @@ vinagre_cmd_view_show_fav_panel	(GtkAction     *action,
 
   vinagre_utils_toggle_widget_visible (window->priv->fav_panel);
 
-  g_object_set (vinagre_prefs_get_default (),
-		"side-panel-visible", GTK_WIDGET_VISIBLE (window->priv->fav_panel),
-		NULL);
+  vinagre_cache_prefs_set_boolean ("window",
+				   "side-panel-visible",
+				   GTK_WIDGET_VISIBLE (window->priv->fav_panel));
 }
 
 void
diff --git a/vinagre/vinagre-connect.c b/vinagre/vinagre-connect.c
index a5599bd..8f270f0 100644
--- a/vinagre/vinagre-connect.c
+++ b/vinagre/vinagre-connect.c
@@ -35,6 +35,7 @@
 #include "vinagre-utils.h"
 #include "vinagre-bookmarks.h"
 #include "vinagre-prefs.h"
+#include "vinagre-cache-prefs.h"
 #include "vinagre-plugins-engine.h"
 #include "vinagre-plugin.h"
 
@@ -133,7 +134,7 @@ setup_protocol (VinagreConnectDialog *dialog)
 
   dialog->protocol_store = gtk_list_store_new (N_PROTOCOLS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_OBJECT, G_TYPE_OBJECT);
   plugins = vinagre_plugin_engine_get_plugins_by_protocol (vinagre_plugins_engine_get_default ());
-  g_object_get (vinagre_prefs_get_default (), "last-protocol", &last_protocol, NULL);
+  last_protocol = vinagre_cache_prefs_get_string ("connection", "last-protocol", NULL);
 
   g_hash_table_iter_init (&hash_iter, plugins);
   selected = 0;
@@ -438,7 +439,7 @@ VinagreConnection *vinagre_connect (VinagreWindow *window)
 			  PROTOCOL_PLUGIN, &plugin,
 		      -1);
 
-      g_object_set (vinagre_prefs_get_default (), "last-protocol", protocol, NULL);
+      vinagre_cache_prefs_set_string ("connection", "last-protocol", protocol);
       g_free (protocol);
 
       conn = vinagre_plugin_new_connection (plugin);
diff --git a/vinagre/vinagre-main.c b/vinagre/vinagre-main.c
index 380f7b6..4f6f3bf 100644
--- a/vinagre/vinagre-main.c
+++ b/vinagre/vinagre-main.c
@@ -34,6 +34,7 @@
 #include "vinagre-app.h"
 #include "vinagre-utils.h"
 #include "vinagre-prefs.h"
+#include "vinagre-cache-prefs.h"
 #include "vinagre-bacon.h"
 #include "vinagre-plugins-engine.h"
 #include "vinagre-plugin-info.h"
@@ -201,6 +202,7 @@ int main (int argc, char **argv) {
 
   vinagre_bacon_start (servers, new_window);
 
+  vinagre_cache_prefs_init ();
   app = vinagre_app_get_default ();
   window = vinagre_app_create_window (app, NULL);
   gtk_widget_show (GTK_WIDGET(window));
@@ -228,6 +230,7 @@ int main (int argc, char **argv) {
 #endif
   g_object_unref (vinagre_bookmarks_get_default ());
   g_object_unref (vinagre_prefs_get_default ());
+  vinagre_cache_prefs_finalize ();
 #ifdef VINAGRE_ENABLE_AVAHI
   g_object_unref (vinagre_mdns_get_default ());
 #endif
diff --git a/vinagre/vinagre-prefs.c b/vinagre/vinagre-prefs.c
index 05b75e4..ab16b06 100644
--- a/vinagre/vinagre-prefs.c
+++ b/vinagre/vinagre-prefs.c
@@ -25,20 +25,10 @@
 
 #define VINAGRE_BASE_KEY		"/apps/vinagre"
 #define VM_ALWAYS_SHOW_TABS		VINAGRE_BASE_KEY "/always_show_tabs"
-#define VM_SHARED_FLAG			VINAGRE_BASE_KEY "/shared_flag"
-#define VM_TOOLBAR_VISIBLE	 	VINAGRE_BASE_KEY "/toolbar_visible"
-#define VM_STATUSBAR_VISIBLE		VINAGRE_BASE_KEY "/statusbar_visible"
-#define VM_SIDE_PANEL_VISIBLE		VINAGRE_BASE_KEY "/side_pane_visible"
 #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_WINDOW_STATE			VINAGRE_BASE_KEY "/window_state"
-#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 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"
 
@@ -53,13 +43,6 @@ enum
   PROP_0,
   PROP_SHARED_FLAG,
   PROP_ALWAYS_SHOW_TABS,
-  PROP_TOOLBAR_VISIBLE,
-  PROP_STATUSBAR_VISIBLE,
-  PROP_SIDE_PANEL_VISIBLE,
-  PROP_WINDOW_STATE,
-  PROP_WINDOW_WIDTH,
-  PROP_WINDOW_HEIGHT,
-  PROP_SIDE_PANEL_SIZE,
   PROP_SHOW_ACCELS,
   PROP_HISTORY_SIZE,
   PROP_ACTIVE_PLUGINS,
@@ -241,7 +224,6 @@ vinagre_prefs_init (VinagrePrefs *prefs)
 			   VM_SHOW_ACCELS,
                            (GConfClientNotifyFunc) vinagre_prefs_show_accels_notify,
                            prefs, NULL, NULL);
-
 }
 
 static void
@@ -257,27 +239,6 @@ vinagre_prefs_set_property (GObject *object, guint prop_id, const GValue *value,
       case PROP_ALWAYS_SHOW_TABS:
 	vinagre_prefs_set_bool (prefs, VM_ALWAYS_SHOW_TABS, g_value_get_boolean (value));
 	break;
-      case PROP_TOOLBAR_VISIBLE:
-	vinagre_prefs_set_bool (prefs, VM_TOOLBAR_VISIBLE, g_value_get_boolean (value));
-	break;
-      case PROP_STATUSBAR_VISIBLE:
-	vinagre_prefs_set_bool (prefs, VM_STATUSBAR_VISIBLE, g_value_get_boolean (value));
-	break;
-      case PROP_SIDE_PANEL_VISIBLE:
-	vinagre_prefs_set_bool (prefs, VM_SIDE_PANEL_VISIBLE, g_value_get_boolean (value));
-	break;
-      case PROP_WINDOW_STATE:
-	vinagre_prefs_set_int (prefs, VM_WINDOW_STATE, g_value_get_int (value));
-	break;
-      case PROP_WINDOW_WIDTH:
-	vinagre_prefs_set_int (prefs, VM_WINDOW_WIDTH, g_value_get_int (value));
-	break;
-      case PROP_WINDOW_HEIGHT:
-	vinagre_prefs_set_int (prefs, VM_WINDOW_HEIGHT, g_value_get_int (value));
-	break;
-      case PROP_SIDE_PANEL_SIZE:
-	vinagre_prefs_set_int (prefs, VM_SIDE_PANEL_SIZE, g_value_get_int (value));
-	break;
       case PROP_SHOW_ACCELS:
 	vinagre_prefs_set_bool (prefs, VM_SHOW_ACCELS, g_value_get_boolean (value));
 	break;
@@ -287,9 +248,6 @@ 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;
       case PROP_ALWAYS_ENABLE_LISTENING:
 	vinagre_prefs_set_bool (prefs, VM_ALWAYS_ENABLE_LISTENING, g_value_get_boolean (value));
 	break;
@@ -313,27 +271,6 @@ vinagre_prefs_get_property (GObject *object, guint prop_id, GValue *value, GPara
       case PROP_ALWAYS_SHOW_TABS:
 	g_value_set_boolean (value, vinagre_prefs_get_bool (prefs, VM_ALWAYS_SHOW_TABS, FALSE));
 	break;
-      case PROP_TOOLBAR_VISIBLE:
-	g_value_set_boolean (value, vinagre_prefs_get_bool (prefs, VM_TOOLBAR_VISIBLE, TRUE));
-	break;
-      case PROP_STATUSBAR_VISIBLE:
-	g_value_set_boolean (value, vinagre_prefs_get_bool (prefs, VM_STATUSBAR_VISIBLE, TRUE));
-	break;
-      case PROP_SIDE_PANEL_VISIBLE:
-	g_value_set_boolean (value, vinagre_prefs_get_bool (prefs, VM_SIDE_PANEL_VISIBLE, TRUE));
-	break;
-      case PROP_WINDOW_STATE:
-	g_value_set_int (value, vinagre_prefs_get_int (prefs, VM_WINDOW_STATE, 0));
-	break;
-      case PROP_WINDOW_WIDTH:
-	g_value_set_int (value, vinagre_prefs_get_int (prefs, VM_WINDOW_WIDTH, 650));
-	break;
-      case PROP_WINDOW_HEIGHT:
-	g_value_set_int (value, vinagre_prefs_get_int (prefs, VM_WINDOW_HEIGHT, 500));
-	break;
-      case PROP_SIDE_PANEL_SIZE:
-	g_value_set_int (value, vinagre_prefs_get_int (prefs, VM_SIDE_PANEL_SIZE, 200));
-	break;
       case PROP_SHOW_ACCELS:
 	g_value_set_boolean (value, vinagre_prefs_get_bool (prefs, VM_SHOW_ACCELS, TRUE));
 	break;
@@ -343,11 +280,6 @@ 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:
-	str = vinagre_prefs_get_string (prefs, VM_LAST_PROTOCOL, NULL);
-	g_value_set_string (value, str);
-	g_free (str);
-	break;
       case PROP_ALWAYS_ENABLE_LISTENING:
 	g_value_set_boolean (value, vinagre_prefs_get_bool (prefs, VM_ALWAYS_ENABLE_LISTENING, FALSE));
 	break;
@@ -402,55 +334,6 @@ vinagre_prefs_class_init (VinagrePrefsClass *klass)
 							 FALSE,
 							 G_PARAM_READWRITE));
   g_object_class_install_property (object_class,
-				   PROP_TOOLBAR_VISIBLE,
-				   g_param_spec_boolean ("toolbar-visible",
-							 "Toolbar Visibility",
-							 "Whether the toolbar is visible",
-							 TRUE,
-							 G_PARAM_READWRITE));
-  g_object_class_install_property (object_class,
-				   PROP_STATUSBAR_VISIBLE,
-				   g_param_spec_boolean ("statusbar-visible",
-							 "Statusbar Visibility",
-							 "Whether the statusbar is visible",
-							 TRUE,
-							 G_PARAM_READWRITE));
-  g_object_class_install_property (object_class,
-				   PROP_SIDE_PANEL_VISIBLE,
-				   g_param_spec_boolean ("side-panel-visible",
-							 "Side Panel Visibility",
-							 "Whether the side panel is visible",
-							 TRUE,
-							 G_PARAM_READWRITE));
-  g_object_class_install_property (object_class,
-				   PROP_WINDOW_STATE,
-				   g_param_spec_int ("window-state",
-						     "Window State",
-						     "Whether the window is maximised",
-						     G_MININT, G_MAXINT, 0,
-						     G_PARAM_READWRITE));
-  g_object_class_install_property (object_class,
-				   PROP_WINDOW_WIDTH,
-				   g_param_spec_int ("window-width",
-						     "Window Width",
-						     "The width of window",
-						     100, G_MAXINT, 650,
-						     G_PARAM_READWRITE));
-  g_object_class_install_property (object_class,
-				   PROP_WINDOW_HEIGHT,
-				   g_param_spec_int ("window-height",
-						     "Window Height",
-						     "The height of window",
-						     100, G_MAXINT, 500,
-						     G_PARAM_READWRITE));
-  g_object_class_install_property (object_class,
-				   PROP_SIDE_PANEL_SIZE,
-				   g_param_spec_int ("side-panel-size",
-						     "Side Panel Width",
-						     "The width of side panel",
-						     100, G_MAXINT, 200,
-						     G_PARAM_READWRITE));
-  g_object_class_install_property (object_class,
 				   PROP_SHOW_ACCELS,
 				   g_param_spec_boolean ("show-accels",
 							 "Show menu accelerators",
@@ -473,21 +356,12 @@ vinagre_prefs_class_init (VinagrePrefsClass *klass)
 							 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));
-
-  g_object_class_install_property (object_class,
 				   PROP_ALWAYS_ENABLE_LISTENING,
 				   g_param_spec_boolean ("always-enable-listening",
 							 "Always enable listening",
 							 "Whether we always should listen for reverse connections",
 							 FALSE,
 							 G_PARAM_READWRITE));
-
 }
 
 /* Preferences dialog */
diff --git a/vinagre/vinagre-window.c b/vinagre/vinagre-window.c
index 5e4a126..6e68969 100644
--- a/vinagre/vinagre-window.c
+++ b/vinagre/vinagre-window.c
@@ -34,6 +34,7 @@
 #include "vinagre-notebook.h"
 #include "vinagre-fav.h"
 #include "vinagre-prefs.h"
+#include "vinagre-cache-prefs.h"
 #include "vinagre-utils.h"
 #include "vinagre-bookmarks.h"
 #include "vinagre-ui.h"
@@ -140,9 +141,7 @@ vinagre_window_state_event_cb (GtkWidget *widget,
   VinagreWindow *window = VINAGRE_WINDOW (widget);
 
   window->priv->window_state = event->new_window_state;
-  g_object_set (vinagre_prefs_get_default (),
-		"window-state", window->priv->window_state,
-		NULL);
+  vinagre_cache_prefs_set_integer ("window", "window-state", window->priv->window_state);
 
   if ((event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) == 0)
     return FALSE;
@@ -169,10 +168,8 @@ vinagre_window_configure_event (GtkWidget         *widget,
   window->priv->width  = event->width;
   window->priv->height = event->height;
 
-  g_object_set (vinagre_prefs_get_default (),
-		"window-width", window->priv->width,
-		"window-height", window->priv->height,
-		NULL);
+  vinagre_cache_prefs_set_integer ("window", "window-width", window->priv->width);
+  vinagre_cache_prefs_set_integer ("window", "window-height", window->priv->height);
 
   return GTK_WIDGET_CLASS (vinagre_window_parent_class)->configure_event (widget, event);
 }
@@ -476,9 +473,7 @@ fav_panel_size_allocate (GtkWidget     *widget,
 {
   window->priv->side_panel_size = allocation->width;
   if (window->priv->side_panel_size > 0)
-    g_object_set (vinagre_prefs_get_default (),
-		  "side-panel-size", window->priv->side_panel_size,
-		  NULL);
+    vinagre_cache_prefs_set_integer ("window", "side-panel-size", window->priv->side_panel_size);
 }
 
 static void
@@ -626,9 +621,7 @@ create_side_panel (VinagreWindow *window)
 		   FALSE, 
 		   FALSE);
 
-  g_object_get (vinagre_prefs_get_default (),
-		"side-panel-size", &(window->priv->side_panel_size),
-		NULL);
+  window->priv->side_panel_size = vinagre_cache_prefs_get_integer ("window", "side-panel-size", 200);
   gtk_paned_set_position (GTK_PANED (window->priv->hpaned), window->priv->side_panel_size);
 
   g_signal_connect (window->priv->fav_panel,
@@ -640,42 +633,35 @@ create_side_panel (VinagreWindow *window)
 static void
 init_widgets_visibility (VinagreWindow *window)
 {
-  GdkWindowState state;
-  gint w, h;
   GtkAction *action;
   gboolean visible;
-  VinagrePrefs *prefs = vinagre_prefs_get_default ();
 
   /* side panel visibility */
   action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
 					"ViewSidePanel");
-  g_object_get (prefs, "side-panel-visible", &visible, NULL);
+  visible = vinagre_cache_prefs_get_boolean ("window", "side-panel-visible", TRUE);
   if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
     gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
 
   /* toolbar visibility */
   action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
 					"ViewToolbar");
-  g_object_get (prefs, "toolbar-visible", &visible, NULL);
+  visible = vinagre_cache_prefs_get_boolean ("window", "toolbar-visible", TRUE);
   if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
     gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
 
   /* statusbar visibility */
   action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
 					"ViewStatusbar");
-  g_object_get (prefs, "statusbar-visible", &visible, NULL);
+  visible = vinagre_cache_prefs_get_boolean ("window", "statusbar-visible", TRUE);
   if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
     gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
 
-  g_object_get (prefs,
-		"window-state", &state,
-		"window-width", &w,
-		"window-height", &h,
-		NULL);
-
-  gtk_window_set_default_size (GTK_WINDOW (window), w, h);
+  gtk_window_set_default_size (GTK_WINDOW (window),
+			       vinagre_cache_prefs_get_integer ("window", "window-width", 650),
+			       vinagre_cache_prefs_get_integer ("window", "window-height", 500));
 
-  if ((state & GDK_WINDOW_STATE_MAXIMIZED) != 0)
+  if ((vinagre_cache_prefs_get_integer ("window", "window-state", 0) & GDK_WINDOW_STATE_MAXIMIZED) != 0)
     gtk_window_maximize (GTK_WINDOW (window));
   else
     gtk_window_unmaximize (GTK_WINDOW (window));



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