[Planner Dev] Patch to add an abstraction layer between Planner and GConf



Hi,

Here is a patch to make an abstraction layer between the application and
GConf. The idea is to have planner-conf.h as a common header file and
planner-conf-gconf.c and planner-conf-windows.c that implements the
functions in the header file. At compile time either planner-conf-
gconf.c or planner-conf-windows.c is linked in to provide the
implementation of the functions.

The API mimics GConf and I've only added the functions needed so far,
for example:

gboolean foo = planner_conf_get_bool ("/general/last_dir", error);

So, keep in mind that you don't have to add "/apps/planner", that is
added within planner-conf-gconf.c.

So Richard, can I commit this?

Best Regards,
  Mikael Hallendal

-- 
Imendio HB, http://www.imendio.com/
? .ChangeLog.swp
? planner-gconf-abstraction.patch
? src/.Makefile.am.swp
? src/.planner-application.c.swp
? src/.planner-application.h.swp
? src/.planner-conf-gconf.c.swp
? src/.planner-conf.c.swp
? src/.planner-conf.h.swp
? src/.planner-gantt-chart.c.swp
? src/.planner-print-dialog.c.swp
? src/.planner-sql-plugin.c.swp
? src/.planner-task-view.c.swp
? src/.planner-window.c.swp
? src/.planner-xml-planner-plugin.c.swp
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/planner/ChangeLog,v
retrieving revision 1.213
diff -u -B -p -u -B -p -r1.213 ChangeLog
--- ChangeLog	6 Aug 2004 18:19:54 -0000	1.213
+++ ChangeLog	9 Aug 2004 00:22:30 -0000
@@ -1,3 +1,18 @@
+2004-08-09  Mikael Hallendal  <micke imendio com>
+
+	* src/Makefile.am: Added planner-conf.h and planner-conf-gconf.c
+	* src/planner-conf-gconf.c: Added
+	* src/planner-conf.h: Added
+	* src/planner-application.[ch]:
+	* src/planner-gantt-chart.c:
+	* src/planner-print-dialog.c:
+	* src/planner-sql-plugin.c:
+	* src/planner-task-view.c: 
+	* src/planner-window.c: 
+	* src/planner-xml-planner-plugin.c:
+	- Added GConf abstraction layer.
+	- Updated all places to use the GConf abstraction layer
+
 2004-08-06  Richard Hult  <richard imendio com>
 
 	* src/planner-window.c: Break some really long lines.
Index: src/Makefile.am
===================================================================
RCS file: /cvs/gnome/planner/src/Makefile.am,v
retrieving revision 1.23
diff -u -B -p -u -B -p -r1.23 Makefile.am
--- src/Makefile.am	6 Aug 2004 18:01:55 -0000	1.23
+++ src/Makefile.am	9 Aug 2004 00:22:31 -0000
@@ -28,6 +28,8 @@ planner_SOURCES = \
 	planner-application.h		\
 	planner-assignment-model.c	\
 	planner-assignment-model.h	\
+	planner-conf.h                  \
+	planner-conf-gconf.c            \
 	planner-calendar.c		\
 	planner-calendar-dialog.c	\
 	planner-calendar-dialog.h	\
Index: src/planner-application.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-application.c,v
retrieving revision 1.7
diff -u -B -p -u -B -p -r1.7 planner-application.c
--- src/planner-application.c	30 Jun 2004 16:36:10 -0000	1.7
+++ src/planner-application.c	9 Aug 2004 00:22:31 -0000
@@ -290,15 +290,3 @@ planner_application_get_recent_model (Pl
 	return app->priv->recent_model;
 }
 
-GConfClient *
-planner_application_get_gconf_client (void)
-{
-	static GConfClient *client;
-	
-	if (!client) {
-		client = gconf_client_get_default ();
-	}
-
-	return client;
-}
-
Index: src/planner-application.h
===================================================================
RCS file: /cvs/gnome/planner/src/planner-application.h,v
retrieving revision 1.5
diff -u -B -p -u -B -p -r1.5 planner-application.h
--- src/planner-application.h	5 Aug 2004 17:20:10 -0000	1.5
+++ src/planner-application.h	9 Aug 2004 00:22:31 -0000
@@ -24,7 +24,6 @@
 #ifndef __PLANNER_APPLICATION_H__
 #define __PLANNER_APPLICATION_H__
 
-#include <gconf/gconf-client.h>
 #include <libplanner/mrp-application.h>
 #include <libplanner/mrp-project.h>
 #include <libegg/recent-files/egg-recent-model.h>
@@ -57,7 +55,5 @@ PlannerApplication   *planner_applicatio
 GtkWidget       *     planner_application_new_window       (PlannerApplication *app);
 void                  planner_application_exit             (PlannerApplication *app);
 EggRecentModel  *     planner_application_get_recent_model (PlannerApplication *app);
-GConfClient     *     planner_application_get_gconf_client (void);
-
 
 #endif /* __PLANNER_APPLICATION_H__ */
Index: src/planner-conf-gconf.c
===================================================================
RCS file: src/planner-conf-gconf.c
diff -N src/planner-conf-gconf.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/planner-conf-gconf.c	9 Aug 2004 00:22:31 -0000
@@ -0,0 +1,160 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2004 Imendio HB
+ *
+ * This program 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.
+ *
+ * This program 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, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <gconf/gconf-client.h>
+
+#include "planner-conf.h"
+
+#define GCONF_PREFIX "/apps/planner"
+
+static GConfClient *  conf_get_gconf_client (void);
+static gchar *        conf_get_key          (const gchar *key);
+
+static GConfClient *
+conf_get_gconf_client (void)
+{
+	static GConfClient *client = NULL;
+
+	if (!client) {
+		client = gconf_client_get_default ();
+	}
+
+	return client;
+}
+
+static gchar *
+conf_get_key (const gchar *key)
+{
+	return g_strconcat (GCONF_PREFIX, key, NULL);
+}
+
+gboolean      
+planner_conf_dir_exists (const gchar *dir, GError **error)
+{
+	GConfClient *client;
+	gchar       *full_dir;
+	gboolean     ret_val;
+
+	client = conf_get_gconf_client ();
+	
+	full_dir = conf_get_key (dir);
+	ret_val = gconf_client_dir_exists (client, full_dir, error);
+	g_free (full_dir);
+
+	return ret_val;
+}
+
+gboolean    
+planner_conf_get_bool (const gchar *key, GError **error)
+{
+	GConfClient *client;
+	gchar       *full_key;
+	gboolean     ret_val;
+
+	client = conf_get_gconf_client ();
+	
+	full_key = conf_get_key (key);
+	ret_val = gconf_client_get_bool (client, full_key, error);
+	g_free (full_key);
+
+	return ret_val;
+}
+
+gchar *
+planner_conf_get_string (const gchar *key, GError **error)
+{
+	GConfClient *client;
+	gchar       *full_key;
+	gchar       *ret_val;
+
+	client = conf_get_gconf_client ();
+	
+	full_key = conf_get_key (key);
+	ret_val = gconf_client_get_string (client, full_key, error);
+	g_free (full_key);
+
+	return ret_val;
+}
+
+gint
+planner_conf_get_int (const gchar *key, GError **error)
+{
+	GConfClient *client;
+	gchar       *full_key;
+	gint         ret_val;
+
+	client = conf_get_gconf_client ();
+	
+	full_key = conf_get_key (key);
+	ret_val = gconf_client_get_int (client, full_key, error);
+	g_free (full_key);
+
+	return ret_val;
+}
+
+gboolean 
+planner_conf_set_bool (const gchar *key, gboolean value, GError **error)
+{
+	GConfClient *client;
+	gchar       *full_key;
+	gboolean     ret_val;
+
+	client = conf_get_gconf_client ();
+
+	full_key = conf_get_key (key);
+	ret_val = gconf_client_set_bool (client, full_key, value, error);
+	g_free (full_key);
+
+	return ret_val;
+}
+
+gboolean
+planner_conf_set_string (const gchar *key, const gchar *value, GError **error)
+{
+	GConfClient *client;
+	gchar       *full_key;
+	gboolean     ret_val;
+
+	client = conf_get_gconf_client ();
+	
+	full_key = conf_get_key (key);
+	ret_val = gconf_client_set_string (client, full_key, value, error);
+	g_free (full_key);
+
+	return ret_val;
+}
+
+gboolean
+planner_conf_set_int (const gchar *key, gint value, GError **error)
+{
+	GConfClient *client;
+	gchar       *full_key;
+	gboolean     ret_val;
+
+	client = conf_get_gconf_client ();
+	
+	full_key = conf_get_key (key);
+	ret_val = gconf_client_set_int (client, full_key, value, error);
+	g_free (full_key);
+
+	return ret_val;
+}
+
Index: src/planner-conf.h
===================================================================
RCS file: src/planner-conf.h
diff -N src/planner-conf.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/planner-conf.h	9 Aug 2004 00:22:31 -0000
@@ -0,0 +1,44 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2004 Imendio HB
+ *
+ * This program 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.
+ *
+ * This program 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, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __PLANNER_CONF_H__
+#define __PLANNER_CONF_H__
+
+gboolean      planner_conf_dir_exists    (const gchar     *dir,
+					  GError         **error);
+gboolean      planner_conf_get_bool      (const gchar     *key,
+					  GError         **error); 
+gchar *       planner_conf_get_string    (const gchar     *key,
+					  GError         **error);
+gint          planner_conf_get_int       (const gchar     *key,
+					  GError         **error);
+
+gboolean      planner_conf_set_bool      (const gchar     *key,
+					  gboolean         value,
+					  GError         **error);
+gboolean      planner_conf_set_string    (const gchar     *key,
+					  const gchar     *value,
+					  GError         **error);
+gboolean      planner_conf_set_int       (const gchar     *key,
+					  gint             value,
+					  GError         **error);
+
+#endif /* __PLANNER_CONF_H__ */
+
Index: src/planner-gantt-chart.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-gantt-chart.c,v
retrieving revision 1.14
diff -u -B -p -u -B -p -r1.14 planner-gantt-chart.c
--- src/planner-gantt-chart.c	2 Jul 2004 00:12:22 -0000	1.14
+++ src/planner-gantt-chart.c	9 Aug 2004 00:22:31 -0000
@@ -31,6 +31,7 @@
 #include <libgnome/gnome-i18n.h>
 #include <libplanner/mrp-task.h>
 #include "planner-marshal.h"
+#include "planner-conf.h"
 #include "planner-gantt-chart.h"
 #include "planner-gantt-header.h"
 #include "planner-gantt-background.h"
@@ -52,7 +53,7 @@
 /* Font width factor. */
 static gdouble f = 1.0;
 
-#define CRITICAL_PATH_KEY "/apps/planner/views/gantt_view/highlight_critical_path"
+#define CRITICAL_PATH_KEY "/views/gantt_view/highlight_critical_path"
 
 
 typedef struct _TreeNode TreeNode; 
@@ -320,7 +321,6 @@ static void
 gantt_chart_init (PlannerGanttChart *chart)
 {
 	PlannerGanttChartPriv *priv;
-	GConfClient           *gconf_client;
 	
 	gtk_widget_set_redraw_on_allocate (GTK_WIDGET (chart), FALSE);
 
@@ -374,9 +374,8 @@ gantt_chart_init (PlannerGanttChart *cha
 
 	priv->relation_hash = g_hash_table_new (NULL, NULL);
 
-	gconf_client = planner_application_get_gconf_client ();
-	priv->highlight_critical = gconf_client_get_bool (
-		gconf_client, CRITICAL_PATH_KEY, NULL);
+	priv->highlight_critical = planner_conf_get_bool (CRITICAL_PATH_KEY,
+							  NULL);
 }
 
 static void
@@ -1879,7 +1878,6 @@ planner_gantt_chart_set_highlight_critic
 						  gboolean           state)
 {
 	PlannerGanttChartPriv *priv;
-	GConfClient           *gconf_client;
 	
 	g_return_if_fail (PLANNER_IS_GANTT_CHART (chart));
 
@@ -1893,11 +1891,7 @@ planner_gantt_chart_set_highlight_critic
 	
 	gtk_widget_queue_draw (GTK_WIDGET (priv->canvas));
 
-	gconf_client = planner_application_get_gconf_client ();
-	gconf_client_set_bool (gconf_client,
-			       CRITICAL_PATH_KEY,
-			       state,
-			       NULL);
+	planner_conf_set_bool (CRITICAL_PATH_KEY, state, NULL);
 }
 
 gboolean
Index: src/planner-print-dialog.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-print-dialog.c,v
retrieving revision 1.5
diff -u -B -p -u -B -p -r1.5 planner-print-dialog.c
--- src/planner-print-dialog.c	17 Jun 2004 16:30:38 -0000	1.5
+++ src/planner-print-dialog.c	9 Aug 2004 00:22:31 -0000
@@ -36,6 +36,7 @@
 #include <libgnomeprintui/gnome-print-paper-selector.h>
 #include <libgnomeprintui/gnome-print-dialog.h>
 #include "planner-view.h"
+#include "planner-conf.h"
 #include "planner-print-dialog.h"
 
 #define PLANNER_PRINT_CONFIG_FILE "planner-print-config"
@@ -135,7 +136,6 @@ print_dialog_create_page (PlannerWindow 
 	GList       *buttons = NULL;
 	gchar       *str;
 	gboolean     state;
-	GConfClient *gconf_client;
 	
 	outer_vbox = gtk_vbox_new (FALSE, 4);
 	gtk_container_set_border_width (GTK_CONTAINER (outer_vbox), 8);
@@ -162,16 +162,14 @@ print_dialog_create_page (PlannerWindow 
 	g_object_set_data (G_OBJECT (dialog), "summary-button", w);
 */
 	
-	gconf_client = planner_application_get_gconf_client ();
-
 	for (l = views; l; l = l->next) {
 		w = gtk_check_button_new_with_label (planner_view_get_label (l->data));
 		gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 0);
 		g_object_set_data (G_OBJECT (w), "view", l->data);
 
-		str = g_strdup_printf ("/apps/planner/views/%s/print_enabled", 
+		str = g_strdup_printf ("/views/%s/print_enabled", 
 				       planner_view_get_name (l->data));
-		state = gconf_client_get_bool (gconf_client, str, NULL);
+		state = planner_conf_get_bool (str, NULL);
 		g_free (str);
 
 		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), state);
@@ -195,7 +193,6 @@ planner_print_dialog_get_print_selection
 	GList           *buttons, *l;
 	GList           *views = NULL;
 	PlannerView     *view;
-	GConfClient     *gconf_client;
 	gchar           *str;
 	PlannerWindow   *window;
 
@@ -209,8 +206,6 @@ planner_print_dialog_get_print_selection
 
 	window = g_object_get_data (G_OBJECT (dialog), "window");
 	
-	gconf_client = planner_application_get_gconf_client ();
-	
 	buttons = g_object_get_data (G_OBJECT (dialog), "buttons");
 	for (l = buttons; l; l = l->next) {
 		button = l->data;
@@ -221,10 +216,9 @@ planner_print_dialog_get_print_selection
 			views = g_list_prepend (views, view);
 		}
 
-		str = g_strdup_printf ("/apps/planner/views/%s/print_enabled", 
+		str = g_strdup_printf ("/views/%s/print_enabled", 
 				       planner_view_get_name (view));
-		gconf_client_set_bool (gconf_client,
-				       str,
+		planner_conf_set_bool (str, 
 				       gtk_toggle_button_get_active (button),
 				       NULL);
 		g_free (str);
Index: src/planner-sql-plugin.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-sql-plugin.c,v
retrieving revision 1.16
diff -u -B -p -u -B -p -r1.16 planner-sql-plugin.c
--- src/planner-sql-plugin.c	6 Aug 2004 18:01:55 -0000	1.16
+++ src/planner-sql-plugin.c	9 Aug 2004 00:22:31 -0000
@@ -30,7 +30,6 @@
 #include <libgnomeui/gnome-entry.h>
 #include <glade/glade.h>
 #include <gtk/gtk.h>
-#include <gconf/gconf-client.h>
 #include <libgda/libgda.h>
 #include "planner-window.h"
 #include "planner-application.h"
Index: src/planner-task-view.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-task-view.c,v
retrieving revision 1.15
diff -u -B -p -u -B -p -r1.15 planner-task-view.c
--- src/planner-task-view.c	5 Aug 2004 22:19:34 -0000	1.15
+++ src/planner-task-view.c	9 Aug 2004 00:22:31 -0000
@@ -42,6 +42,7 @@
 #include <libgnome/gnome-i18n.h>
 #include <libplanner/mrp-task.h>
 #include "planner-view.h"
+#include "planner-conf.h"
 #include "planner-cell-renderer-date.h"
 #include "planner-task-dialog.h"
 #include "planner-property-dialog.h"
@@ -138,14 +139,13 @@ static guint n_entries        = G_N_ELEM
 static guint n_toggle_entries = G_N_ELEMENTS (toggle_entries);
 
 
-#define CRITICAL_PATH_KEY "/apps/planner/views/task_view/highlight_critical_path"
+#define CRITICAL_PATH_KEY "/views/task_view/highlight_critical_path"
 
 G_MODULE_EXPORT void
 activate (PlannerView *view)
 {
 	PlannerViewPriv *priv;
 	gboolean         show_critical;
-	GConfClient     *gconf_client;
 	GError          *error = NULL;
 
 	priv = view->priv;
@@ -169,10 +169,7 @@ activate (PlannerView *view)
 
 	/* Set the initial UI state. */
 
-	gconf_client = planner_application_get_gconf_client ();
-	show_critical = gconf_client_get_bool (gconf_client,
-					       CRITICAL_PATH_KEY,
-					       NULL);
+	show_critical = planner_conf_get_bool (CRITICAL_PATH_KEY, NULL);
 
 	planner_task_tree_set_highlight_critical (PLANNER_TASK_TREE (priv->tree),
 						  show_critical);
@@ -489,7 +486,6 @@ task_view_highlight_critical_cb (GtkActi
 {
 	PlannerViewPriv *priv;
 	gboolean         state;
-	GConfClient     *gconf_client;
 	
 	priv = PLANNER_VIEW (data)->priv;
 
@@ -499,11 +495,7 @@ task_view_highlight_critical_cb (GtkActi
 		PLANNER_TASK_TREE (priv->tree),
 		state);
 
-	gconf_client = planner_application_get_gconf_client ();
-	gconf_client_set_bool (gconf_client,
-			       CRITICAL_PATH_KEY,
-			       state,
-			       NULL);
+	planner_conf_set_bool (CRITICAL_PATH_KEY, state, NULL);
 }
 
 static void 
Index: src/planner-window.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-window.c,v
retrieving revision 1.26
diff -u -B -p -u -B -p -r1.26 planner-window.c
--- src/planner-window.c	6 Aug 2004 18:19:54 -0000	1.26
+++ src/planner-window.c	9 Aug 2004 00:22:31 -0000
@@ -38,7 +38,6 @@
 #include <gtk/gtklabel.h>
 #include <gtk/gtkfilechooserdialog.h>
 #include <glade/glade.h>
-#include <gconf/gconf-client.h>
 #include <libgnome/gnome-help.h>
 #include <libgnome/gnome-i18n.h>
 #include <libgnomeui/gnome-about.h>
@@ -50,6 +49,7 @@
 #include <libplanner/mrp-project.h>
 #include <libegg/recent-files/egg-recent-view.h>
 #include "planner-marshal.h"
+#include "planner-conf.h"
 #include "planner-sidebar.h"
 #include "planner-window.h"
 #include "planner-view-loader.h"
@@ -187,13 +187,13 @@ static void window_connect_proxy_cb (Gtk
 				     PlannerWindow *window);
 
 
-#define GCONF_PATH                  "/apps/planner"
-#define GCONF_MAIN_WINDOW_DIR       "/apps/planner/ui"
-#define GCONF_MAIN_WINDOW_MAXIMIZED "/apps/planner/ui/main_window_maximized"
-#define GCONF_MAIN_WINDOW_WIDTH     "/apps/planner/ui/main_window_width"
-#define GCONF_MAIN_WINDOW_HEIGHT    "/apps/planner/ui/main_window_height"
-#define GCONF_MAIN_WINDOW_POS_X     "/apps/planner/ui/main_window_position_x"
-#define GCONF_MAIN_WINDOW_POS_Y     "/apps/planner/ui/main_window_position_y"
+#define CONF_MAIN_WINDOW_DIR       "/ui"
+#define CONF_MAIN_WINDOW_MAXIMIZED "/ui/main_window_maximized"
+#define CONF_MAIN_WINDOW_WIDTH     "/ui/main_window_width"
+#define CONF_MAIN_WINDOW_HEIGHT    "/ui/main_window_height"
+#define CONF_MAIN_WINDOW_POS_X     "/ui/main_window_position_x"
+#define CONF_MAIN_WINDOW_POS_Y     "/ui/main_window_position_y"
+#define CONF_MAIN_LAST_DIR         "/general/last_dir"
 
 #define VIEW_PATH "/menu/View/Views placeholder"
 #define VIEW_GROUP "view group"
@@ -672,16 +672,11 @@ static gchar *
 get_last_dir (PlannerWindow *window)
 {
 	PlannerWindowPriv *priv;
-	GConfClient       *gconf_client;
 	gchar             *last_dir;
 	
 	priv = window->priv;
 	
-	gconf_client = planner_application_get_gconf_client ();
-	
-	last_dir = gconf_client_get_string (gconf_client,
-					    GCONF_PATH "/general/last_dir",
-					    NULL);
+	last_dir = planner_conf_get_string (CONF_MAIN_LAST_DIR, NULL);
 	
 	if (last_dir == NULL) {
 		last_dir = g_strdup (g_get_home_dir ());
@@ -701,13 +696,10 @@ window_open_cb (GtkAction *action,
 	gchar             *filename = NULL;
 	gchar             *last_dir;
 	GtkWidget         *new_window;
-	GConfClient       *gconf_client;
 
 	window = PLANNER_WINDOW (data);
 	priv = window->priv;
 
-	gconf_client = planner_application_get_gconf_client ();
-
 	file_chooser = gtk_file_chooser_dialog_new (_("Open a file"),
 						    GTK_WINDOW (window),
 						    GTK_FILE_CHOOSER_ACTION_OPEN,
@@ -750,11 +742,9 @@ window_open_cb (GtkAction *action,
 		}
 		
 		last_dir = g_path_get_dirname (filename);
-		gconf_client_set_string (gconf_client,
-					 GCONF_PATH "/general/last_dir",
-					 last_dir,
-					 NULL);
+		planner_conf_set_string (CONF_MAIN_LAST_DIR, last_dir, NULL);
 		g_free (last_dir);
+
 		g_free (filename);		
 	}
 }
@@ -1343,13 +1333,10 @@ window_do_save_as (PlannerWindow *window
 	gint              response;
 	gchar            *filename = NULL;
 	gchar            *last_dir;
-	GConfClient      *gconf_client;
 	EggRecentItem    *item;
 
 	priv = window->priv;
 
-	gconf_client = planner_application_get_gconf_client ();
-
 	file_chooser = gtk_file_chooser_dialog_new (_("Save a file"),
 						    GTK_WINDOW (window),
 						    GTK_FILE_CHOOSER_ACTION_SAVE,
@@ -1429,11 +1416,9 @@ window_do_save_as (PlannerWindow *window
 		}
 
 		last_dir = g_path_get_dirname (filename);
-		gconf_client_set_string (gconf_client,
-					 GCONF_PATH "/general/last_dir",
-					 last_dir,
-					 NULL);
+		planner_conf_set_string (CONF_MAIN_LAST_DIR, last_dir, NULL);
 		g_free (last_dir);
+
 		g_free (filename);
 		
 		return TRUE;
@@ -1747,15 +1732,12 @@ planner_window_get_cmd_manager (PlannerW
 static void
 window_save_state (PlannerWindow *window)
 {
-	GConfClient       *gconf_client;
 	PlannerWindowPriv *priv;
 	GdkWindowState     state;
 	gboolean           maximized;
 
 	priv = window->priv;
 
-	gconf_client = planner_application_get_gconf_client ();
-
 	state = gdk_window_get_state (GTK_WIDGET (window)->window);
 	if (state & GDK_WINDOW_STATE_MAXIMIZED) {
 		maximized = TRUE;
@@ -1763,9 +1745,7 @@ window_save_state (PlannerWindow *window
 		maximized = FALSE;
 	}
 
-	gconf_client_set_bool (gconf_client,
-			       GCONF_MAIN_WINDOW_MAXIMIZED,
-			       maximized, NULL);
+	planner_conf_set_bool (CONF_MAIN_WINDOW_MAXIMIZED, maximized, NULL);
 
 	/* If maximized don't save the size and position */
 	if (!maximized) {
@@ -1773,27 +1753,18 @@ window_save_state (PlannerWindow *window
 		int x, y;
 
 		gtk_window_get_size (GTK_WINDOW (window), &width, &height);
-		gconf_client_set_int (gconf_client,
-				      GCONF_MAIN_WINDOW_WIDTH,
-				      width, NULL);
-		gconf_client_set_int (gconf_client,
-				      GCONF_MAIN_WINDOW_HEIGHT,
-				      height, NULL);
+		planner_conf_set_int (CONF_MAIN_WINDOW_WIDTH, width, NULL);
+		planner_conf_set_int (CONF_MAIN_WINDOW_HEIGHT, height, NULL);
 
 		gtk_window_get_position (GTK_WINDOW (window), &x, &y);
-		gconf_client_set_int (gconf_client,
-				      GCONF_MAIN_WINDOW_POS_X,
-				      x, NULL);
-		gconf_client_set_int (gconf_client,
-				      GCONF_MAIN_WINDOW_POS_Y,
-				      y, NULL);
+		planner_conf_set_int (CONF_MAIN_WINDOW_POS_X, x, NULL);
+		planner_conf_set_int (CONF_MAIN_WINDOW_POS_Y, y, NULL);
 	}
 }
 
 static void
 window_restore_state (PlannerWindow *window)
 {
-	GConfClient *gconf_client;
 	PlannerWindowPriv *priv;
 	gboolean exists;
 	gboolean maximized;
@@ -1801,36 +1772,28 @@ window_restore_state (PlannerWindow *win
 	int      x, y;
 
 	priv = window->priv;
-	gconf_client = planner_application_get_gconf_client ();
 
-	exists = gconf_client_dir_exists (gconf_client,
-					  GCONF_MAIN_WINDOW_DIR,
-					  NULL);
+	exists = planner_conf_dir_exists (CONF_MAIN_WINDOW_DIR, NULL);
 	
 	if (exists) {	
-		maximized = gconf_client_get_bool (gconf_client,
-						   GCONF_MAIN_WINDOW_MAXIMIZED,
+		maximized = planner_conf_get_bool (CONF_MAIN_WINDOW_MAXIMIZED,
 						   NULL);
 	
 		if (maximized) {
 			gtk_window_maximize (GTK_WINDOW (window));
 		} else {
-			width = gconf_client_get_int (gconf_client,
-						      GCONF_MAIN_WINDOW_WIDTH,
+			width = planner_conf_get_int (CONF_MAIN_WINDOW_WIDTH,
 						      NULL);
 		
-			height = gconf_client_get_int (gconf_client,
-						       GCONF_MAIN_WINDOW_HEIGHT,
+			height = planner_conf_get_int (CONF_MAIN_WINDOW_HEIGHT,
 						       NULL);
 		
 			gtk_window_set_default_size (GTK_WINDOW (window), 
 						     width, height);
 
-			x = gconf_client_get_int (gconf_client,
-						  GCONF_MAIN_WINDOW_POS_X,
+			x = planner_conf_get_int (CONF_MAIN_WINDOW_POS_X,
 						  NULL);
-			y = gconf_client_get_int (gconf_client,
-						  GCONF_MAIN_WINDOW_POS_Y,
+			y = planner_conf_get_int (CONF_MAIN_WINDOW_POS_Y,
 						  NULL);
 
 			gtk_window_move (GTK_WINDOW (window), x, y);
Index: src/planner-xml-planner-plugin.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-xml-planner-plugin.c,v
retrieving revision 1.6
diff -u -B -p -u -B -p -r1.6 planner-xml-planner-plugin.c
--- src/planner-xml-planner-plugin.c	6 Aug 2004 18:01:55 -0000	1.6
+++ src/planner-xml-planner-plugin.c	9 Aug 2004 00:22:31 -0000
@@ -28,6 +28,7 @@
 #include <glade/glade.h>
 #include <gtk/gtk.h>
 #include <libgnome/gnome-i18n.h>
+#include "planner-conf.h"
 #include "planner-window.h"
 #include "planner-plugin.h"
 
@@ -62,14 +63,9 @@ static guint n_action_entries = G_N_ELEM
 static gchar *
 get_last_dir (void)
 {
-	GConfClient *gconf_client;
 	gchar       *last_dir;
 	
-	gconf_client = planner_application_get_gconf_client ();
-	
-	last_dir = gconf_client_get_string (gconf_client,
-					    GCONF_PATH "/general/last_dir",
-					    NULL);
+	last_dir = planner_conf_get_string ("/general/last_dir", NULL);
 	
 	if (last_dir == NULL) {
 		last_dir = g_strdup (g_get_home_dir ());
@@ -99,7 +95,6 @@ xml_planner_plugin_export (GtkAction    
 	const gchar       *filename = NULL;
 	gchar             *real_filename;
 	gchar             *last_dir;
-	GConfClient       *gconf_client; 
 
 	file_sel = gtk_file_selection_new (_("Export"));
 
@@ -161,14 +156,10 @@ xml_planner_plugin_export (GtkAction    
 		g_warning ("Error while export to Planner XML: %s", error->message);
 	}
 
-	gconf_client = planner_application_get_gconf_client ();
-	
 	last_dir = g_path_get_dirname (real_filename);
-	gconf_client_set_string (gconf_client,
-				 GCONF_PATH "/general/last_dir",
-				 last_dir,
-				 NULL);
+	planner_conf_set_string ("/general/last_dir", last_dir, NULL);
 	g_free (last_dir);
+
 	g_free (real_filename);
 
 	gtk_widget_destroy (file_sel);


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