[nautilus-actions] Call na_gsettings_migrate() if we have both GSettings and GConf
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Call na_gsettings_migrate() if we have both GSettings and GConf
- Date: Wed, 19 Jan 2011 21:47:25 +0000 (UTC)
commit 40b3b6615d17177c2bde70d0bcd770e10f8a336a
Author: Pierre Wieser <pwieser trychlos org>
Date: Sun Jan 2 21:40:52 2011 +0100
Call na_gsettings_migrate() if we have both GSettings and GConf
ChangeLog | 10 ++++
configure.ac | 3 +
src/core/Makefile.am | 7 +++
src/core/na-gsettings-migrate.c | 106 +++++++++++++++++++++++++++++++++++++++
src/core/na-gsettings-migrate.h | 42 +++++++++++++++
src/core/na-pivot.c | 8 +++
6 files changed, 176 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 549d91b..175657a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -135,6 +135,16 @@
2011-01-03 Pierre Wieser <pwieser trychlos org>
+ * configure.ac: Define a conditional if we have both GSettings and GConf.
+
+ * src/core/na-gsettings-migrate.c:
+ * src/core/na-gsettings-migrate.h: New files.
+
+ * src/core/Makefile.am: Updated accordingly.
+
+ * src/core/na-pivot.c (instance_constructed):
+ Call na_gsettings_migrate() if we have both GSettings and GConf.
+
* configure.ac:
- Define HAVE_GSETTINGS variable.
- Define HAVE_GCONF variable.
diff --git a/configure.ac b/configure.ac
index 00a2c18..db2614b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -158,6 +158,9 @@ PKG_CHECK_EXISTS([glib-2.0 >= 2.26],[have_gsettings="yes"],[have_gsettings="no"]
AC_MSG_RESULT([${have_gsettings}])
AC_DEFINE_UNQUOTED([HAVE_GSETTINGS],[ test "x${have_gsettings}" = "xyes"],[Whether we compile against a recent enough GIO])
+# As of N-A 3.0.6, GConf is always enabled
+AM_CONDITIONAL([HAVE_GSETTINGS_AND_GCONF], [test "x${have_gsettings}" = "xyes"])
+
# check for gtk-doc
# Starting with gtk-doc 1.15, multiple source dirs are directly handled
# by gtk-doc.make
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index c83d289..715e126 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -100,6 +100,13 @@ libna_core_la_SOURCES = \
na-tokens.h \
$(NULL)
+if HAVE_GSETTINGS_AND_GCONF
+libna_core_la_SOURCES += \
+ na-gsettings-migrate.c \
+ na-gsettings-migrate.h \
+ $(NULL)
+endif
+
libna_core_la_LIBADD = \
$(NAUTILUS_ACTIONS_LIBS) \
$(NULL)
diff --git a/src/core/na-gsettings-migrate.c b/src/core/na-gsettings-migrate.c
new file mode 100644
index 0000000..17a77c7
--- /dev/null
+++ b/src/core/na-gsettings-migrate.c
@@ -0,0 +1,106 @@
+/*
+ * Nautilus-Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009, 2010, 2011 Pierre Wieser and others (see AUTHORS)
+ *
+ * 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 Library; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Frederic Ruaudel <grumz grumz net>
+ * Rodrigo Moya <rodrigo gnome-db org>
+ * Pierre Wieser <pwieser trychlos org>
+ * ... and many others (see AUTHORS)
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "na-gsettings-migrate.h"
+
+static void migrate_configurations( const NAPivot *pivot, GConfClient *gconf );
+static void migrate_io_providers( const NAPivot *pivot, GConfClient *gconf );
+static void migrate_preferences( const NAPivot *pivot, GConfClient *gconf );
+
+/*
+ * This function is called at NAPivot construction, after plugins have been
+ * loaded. As both GConf and GSettings are enabled, it is time to migrate
+ * runtime parameters and existing NAObjectItem objects if this does not have
+ * already done.
+ */
+void
+na_pivot_gsettings_migrate( const NAPivot *pivot )
+{
+ static const gchar *thisfn = "na_pivot_gsettings_migrate";
+ GConfClient *gconf_client;
+ GSList *root, *ir;
+ const gchar *bname;
+
+ gconf_client = gconf_client_get_default();
+ if( !gconf_client ){
+ return;
+ }
+
+ /* root is the first level of subdirectories:
+ * configurations, io-providers and preferences
+ */
+ root = na_gconf_utils_get_subdirs( gconf_client, IPREFS_GCONF_BASEDIR );
+
+ if( root && g_slist_length( root )){
+ for( ir = root ; ir ; ir = ir->next ){
+
+ const gchar *branch = ( const gchar * ) ir->data;
+ bname = g_path_get_basename( branch );
+
+ if( !strcmp( bname, "configurations" )){
+ migrate_configurations( pivot, gconf_client );
+
+ } else if( !strcmp( bname, "io-providers")){
+ migrate_io_providers( pivot, gconf_client );
+
+ } else if( !strcmp( bname, "preferences")){
+ migrate_preferences( pivot, gconf_client );
+
+ } else {
+ g_warning( "%s: unknown branch: %s", thisfn, branch );
+ }
+
+ g_free( bname );
+ }
+
+ na_core_utils_slist_free( root );
+ }
+
+ g_object_unref( gconf_client );
+}
+
+static void
+migrate_configurations( const NAPivot *pivot, GConfClient *gconf )
+{
+}
+
+static void
+migrate_io_providers( const NAPivot *pivot, GConfClient *gconf )
+{
+}
+
+static void
+migrate_preferences( const NAPivot *pivot, GConfClient *gconf )
+{
+}
diff --git a/src/core/na-gsettings-migrate.h b/src/core/na-gsettings-migrate.h
new file mode 100644
index 0000000..c9aaf85
--- /dev/null
+++ b/src/core/na-gsettings-migrate.h
@@ -0,0 +1,42 @@
+/*
+ * Nautilus-Actions
+ * A Nautilus extension which offers configurable context menu actions.
+ *
+ * Copyright (C) 2005 The GNOME Foundation
+ * Copyright (C) 2006, 2007, 2008 Frederic Ruaudel and others (see AUTHORS)
+ * Copyright (C) 2009, 2010, 2011 Pierre Wieser and others (see AUTHORS)
+ *
+ * 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 Library; see the file COPYING. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Frederic Ruaudel <grumz grumz net>
+ * Rodrigo Moya <rodrigo gnome-db org>
+ * Pierre Wieser <pwieser trychlos org>
+ * ... and many others (see AUTHORS)
+ */
+
+#ifndef __CORE_NA_GSETTINGS_MIGRATE_H__
+#define __CORE_NA_GSETTINGS_MIGRATE_H__
+
+#include "na-pivot.h"
+
+G_BEGIN_DECLS
+
+void na_gsettings_migrate( const NAPivot *pivot );
+
+G_END_DECLS
+
+#endif /* __CORE_NA_GSETTINGS_MIGRATE_H__ */
diff --git a/src/core/na-pivot.c b/src/core/na-pivot.c
index 5d193d8..dce44c7 100644
--- a/src/core/na-pivot.c
+++ b/src/core/na-pivot.c
@@ -43,6 +43,10 @@
#include "na-module.h"
#include "na-pivot.h"
+#ifdef HAVE_GSETTINGS && HAVE_GCONF
+#include "na-gsettings-migrate.h"
+#endif
+
/* private class data
*/
struct _NAPivotClassPrivate {
@@ -235,6 +239,10 @@ instance_constructed( GObject *object )
self->private->modules = na_module_load_modules();
+#ifdef HAVE_GSETTINGS && HAVE_GCONF
+ na_gsettings_migrate( self );
+#endif
+
monitor_runtime_preferences( self );
/* force class initialization and io-factory registration
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]