[gnac/devel] Merged branch 'gnac-gsettings'



commit 0efe545692ae22ce539a067b3b4a2df64ff6f57a
Author: Benoît Dupasquier <bdupasqu src gnome org>
Date:   Fri Jan 21 15:34:32 2011 +0000

    Merged branch 'gnac-gsettings'

 .gitignore                           |    1 -
 configure.ac                         |   24 +---
 data/Makefile.am                     |   40 ++-----
 data/gnac.schemas.in                 |  115 -------------------
 data/ui/gnac-pref-window.xml         |    2 -
 po/POTFILES.in                       |    3 +-
 src/Makefile.am                      |    2 -
 src/gnac-gconf.c                     |  208 ----------------------------------
 src/gnac-gconf.h                     |   83 --------------
 src/gnac-main.c                      |   68 ++++++++++--
 src/gnac-main.h                      |   30 +++++
 src/gnac-options.c                   |    4 +-
 src/gnac-prefs.c                     |  111 ++++++++----------
 src/gnac-prefs.h                     |    8 --
 src/gnac-ui.c                        |   26 +++--
 src/gnac-ui.h                        |    7 +-
 src/profiles/gnac-profiles-manager.c |   13 +-
 17 files changed, 187 insertions(+), 558 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 17f87f9..7e17a9a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,7 +30,6 @@ po/stamp-it
 src/.deps/
 stamp-h1
 data/gnac.desktop
-data/gnac.schemas
 data/profiles/*.xml
 data/profiles/default/*.xml
 po/.intltool-merge-cache
diff --git a/configure.ac b/configure.ac
index 9e75fb9..9650eba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -56,12 +56,8 @@ IT_PROG_INTLTOOL([0.40.6])
 AM_GNU_GETTEXT_VERSION([0.17])
 AM_GLIB_GNU_GETTEXT
 
-dnl Check for gconftool-2
-AC_PATH_PROG([GCONFTOOL], [gconftool-2], [no])
-if test "$GCONFTOOL" = "no"; then
-  AC_MSG_ERROR([gconftool-2 executable not found in your path - should be installed with GConf])
-fi
-AM_GCONF_SOURCE_2
+dnl Check for GSettings macros
+GLIB_GSETTINGS
 
 GNOME_COMMON_INIT
 GNOME_DOC_INIT([0.17.2])
@@ -71,20 +67,21 @@ GNOME_CXX_WARNINGS([yes])
 GNOME_MAINTAINER_MODE_DEFINES
 
 dnl Find GLib and GObject
+GIO_REQUIRED=2.25.0
 PKG_CHECK_MODULES(GLIB, [
-  gio-2.0
+  gio-2.0 >= $GIO_REQUIRED
   glib-2.0 
   gobject-2.0 
   gthread-2.0
+  libxml-2.0
 ])
 AC_SUBST(GLIB_CFLAGS)
 AC_SUBST(GLIB_LIBS)
 
 dnl Find the UI libraries
+GTK_REQUIRED=2.14
 PKG_CHECK_MODULES(UI, [
-  gconf-2.0 
-  gtk+-2.0 >= 2.14
-  libxml-2.0
+  gtk+-2.0 >= $GTK_REQUIRED
 ])
 AC_SUBST(UI_CFLAGS)
 AC_SUBST(UI_LIBS)
@@ -128,13 +125,6 @@ AM_GST_ELEMENT_CHECK(wavpackenc, , AC_MSG_WARN([The 'wavpackenc' element was not
 AM_GST_ELEMENT_CHECK(faac, , AC_MSG_WARN([The 'faac' element was not found. This will cause encoding to AAC to fail.]))
 AM_GST_ELEMENT_CHECK(lame, , AC_MSG_WARN([The 'lame' element was not found. This will cause encoding to MP3 to fail.]))
 
-dnl Find how and where to put the GConf schemas
-AC_PATH_PROG(GCONFTOOL, gconftool-2, no)
-if test "$GCONFTOOL" = "no"; then
-  AC_MSG_ERROR([gconftool-2 executable not found in your path - should be installed with GConf])
-fi
-AM_GCONF_SOURCE_2
-
 dnl Optionnaly enable G* deprecations
 AC_MSG_CHECKING([Wether to enable deprecation warnings])
 AC_ARG_ENABLE([deprecation],
diff --git a/data/Makefile.am b/data/Makefile.am
index 9ef582d..89d26bb 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -8,14 +8,14 @@ desktop_in_files = gnac.desktop.in.in
 desktop_DATA     = $(desktop_in_files:.desktop.in.in=.desktop)
 @INTLTOOL_DESKTOP_RULE@
 
-schemadir       = $(GCONF_SCHEMA_FILE_DIR)
-schema_in_files = gnac.schemas.in
-schema_DATA     = $(schema_in_files:.schemas.in=.schemas)
- INTLTOOL_SCHEMAS_RULE@
+gsettings_in_file = org.gnome.gnac.gschema.xml.in
+gsettings_SCHEMAS = $(gsettings_in_file:.xml.in=.xml)
+ INTLTOOL_XML_NOMERGE_RULE@
+ GSETTINGS_RULES@
 
 update_desktop_database = update-desktop-database 2>&1 > /dev/null
 
-install-data-local: install-schemas postinstall
+install-data-local: postinstall
 
 postinstall:
 	@-if test -z "$(DESTDIR)"; then \
@@ -31,35 +31,15 @@ remove-gnac-dir:
 		rmdir "$(configdir)"; \
 	fi
 
-install-schemas:
-if GCONF_SCHEMAS_INSTALL
-	@-if test -z "$(DESTDIR)" ; then \
-		for p in $(schema_DATA) ; do \
-			GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $$p 2>&1 > /dev/null; \
-		done \
-	fi || echo "Installation of schemas failed, install them manually";
-	@true
-endif
-
-uninstall-schemas:
-if GCONF_SCHEMAS_INSTALL
-	@-if test -z "$(DESTDIR)" ; then \
-		for p in $(schema_DATA) ; do \
-			GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-uninstall-rule $(schemadir)/$$p 2>&1 > /dev/null; \
-			rm -f $(schemadir)/$$p; \
-		done \
-	fi
-	@true
-endif
-
-uninstall-local: remove-gnac-dir uninstall-schemas
+uninstall-local: remove-gnac-dir
 
 CLEANFILES = \
 	$(desktop_DATA)
 
 DISTCLEANFILES = \
-	$(schema_DATA)
+	$(desktop_DATA) \
+	$(gsettings_SCHEMAS)
 
 EXTRA_DIST = \
-	$(schema_in_files) \
-	$(desktop_DATA)
+	$(desktop_DATA) \
+	$(gsettings_in_file)
diff --git a/data/ui/gnac-pref-window.xml b/data/ui/gnac-pref-window.xml
index c68b27e..3fc6481 100644
--- a/data/ui/gnac-pref-window.xml
+++ b/data/ui/gnac-pref-window.xml
@@ -113,7 +113,6 @@
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
                                 <property name="draw_indicator">True</property>
-                                <signal name="toggled" handler="gnac_prefs_tray_icon_toggled"/>
                               </object>
                               <packing>
                                 <property name="y_options">GTK_FILL</property>
@@ -335,7 +334,6 @@
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">False</property>
                                 <property name="draw_indicator">True</property>
-                                <signal name="toggled" handler="gnac_prefs_erase_source_toggled"/>
                               </object>
                               <packing>
                                 <property name="position">2</property>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index e1a50fa..caa6077 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -2,7 +2,7 @@
 # Please keep this file sorted alphabetically.
 [encoding: UTF-8]
 data/gnac.desktop.in.in
-data/gnac.schemas.in
+data/org.gnome.gnac.gschema.xml.in
 [type: gettext/glade]data/ui/gnac-pref-window.xml
 [type: gettext/glade]data/ui/gnac-properties-window.xml
 [type: gettext/glade]data/ui/gnac.xml
@@ -41,7 +41,6 @@ src/profiles/gnac-profiles-manager.c
 src/profiles/gnac-profiles-properties.c
 src/profiles/formats/gnac-profiles-unknown.c
 src/gnac-bars.c
-src/gnac-gconf.c
 src/gnac-main.c
 src/gnac-options.c
 src/gnac-playlist.c
diff --git a/src/Makefile.am b/src/Makefile.am
index febc7fc..2214cfd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,8 +9,6 @@ gnac_SOURCES = \
 	gnac-main.c \
 	gnac-file-list.h \
 	gnac-file-list.c \
-	gnac-gconf.c \
-	gnac-gconf.h \
 	gnac-options.c \
 	gnac-options.h \
 	gnac-playlist.c \
diff --git a/src/gnac-main.c b/src/gnac-main.c
index 4d95c77..4fce393 100644
--- a/src/gnac-main.c
+++ b/src/gnac-main.c
@@ -36,7 +36,6 @@
 
 #include "gnac-bars.h"
 #include "gnac-file-list.h"
-#include "gnac-gconf.h"
 #include "gnac-main.h"
 #include "gnac-options.h"
 #include "gnac-playlist.h"
@@ -68,6 +67,8 @@ guint             nb_files_added;
 GnacState state      = GNAC_AUDIO_EMPTY_STATE;
 GnacState prev_state = GNAC_AUDIO_EMPTY_STATE;
 
+GSettings *settings;
+
 LibgnacConverter *converter;
 LibgnacMetadata  *metadata;
 
@@ -330,6 +331,49 @@ gnac_add_file(GFile *file)
 }
 
 
+gboolean
+gnac_settings_set_boolean(const gchar *key,
+                          gboolean     value)
+{
+  return gnac_settings_set(key, g_variant_new_boolean(value));
+}
+
+
+gboolean
+gnac_settings_set_int(const gchar *key,
+                      gint         value)
+{
+  return gnac_settings_set(key, g_variant_new_int32(value));
+}
+
+
+gboolean
+gnac_settings_set_string(const gchar *key,
+                         const gchar *value)
+{
+  if (!value) return FALSE;
+  return gnac_settings_set(key, g_variant_new_string(value));
+}
+
+
+gboolean
+gnac_settings_set(const gchar *key,
+                  GVariant    *value)
+{
+  gboolean ret;
+  gchar *val_str;
+  val_str = g_variant_print(value, FALSE);
+  ret = g_settings_set_value(settings, key, value);
+  if (!ret) {
+    libgnac_debug("Failed to set key \"%s\" to \"%s\"", key, val_str);
+  } else {
+    libgnac_debug("Key \"%s\" set to \"%s\"", key, val_str);
+  }
+  g_free(val_str);
+  return ret;
+}
+
+
 G_GNUC_NORETURN void
 gnac_exit(gint status)
 {
@@ -385,7 +429,6 @@ gnac_on_ui_destroy_cb(GtkWidget *widget,
   if (converter) g_object_unref(converter);
   if (metadata) g_object_unref(metadata);
 
-  gnac_gconf_destroy();
   gnac_ui_destroy();
 
   /* only call 'gtk_main_quit' if the main loop is running */
@@ -552,7 +595,7 @@ gnac_on_converter_file_completed_cb(LibgnacConverter *converter,
   GError *error = NULL;
   
   /* Delete source if selected */
-  if (gnac_gconf_get_boolean(GNAC_GCONF_CLEAR_SOURCE))
+  if (g_settings_get_boolean(settings, GNAC_KEY_CLEAR_SOURCE))
   {
     file = g_file_new_for_uri(uri);
     g_file_trash(file, NULL, &error);
@@ -723,17 +766,21 @@ gnac_on_ui_convert_cb(GtkWidget *widget,
       gchar *folder_hierarchy;
       gchar *folder_path;
       gchar *rename_pattern;
-      folder_hierarchy = gnac_gconf_get_string(GNAC_GCONF_FOLDER_HIERARCHY_PATTERN),
-      folder_path = gnac_gconf_get_string(GNAC_GCONF_DESTINATION_DIRECTORY);
-      rename_pattern = gnac_gconf_get_string(GNAC_GCONF_RENAME_PATTERN_PATTERN);
+      folder_hierarchy = g_settings_get_string(settings,
+          GNAC_KEY_FOLDER_HIERARCHY_PATTERN),
+      folder_path = g_settings_get_string(settings,
+          GNAC_KEY_DESTINATION_DIRECTORY);
+      rename_pattern = g_settings_get_string(settings,
+          GNAC_KEY_RENAME_PATTERN_PATTERN);
       g_object_set(G_OBJECT(converter),
           "extension", gnac_profiles_get_extension(),
           "folder-hierarchy", folder_hierarchy,
           "folder-path", folder_path,
-          "folder-type", gnac_gconf_get_int(GNAC_GCONF_FOLDER_TYPE), 
+          "folder-type", g_settings_get_int(settings, GNAC_KEY_FOLDER_TYPE),
           "audio-description", gnac_profiles_get_pipeline(),
           "rename-pattern", rename_pattern,
-          "strip-special", gnac_gconf_get_boolean(GNAC_GCONF_STRIP_SPECIAL),
+          "strip-special", g_settings_get_boolean(settings,
+              GNAC_KEY_STRIP_SPECIAL),
           NULL);
       libgnac_converter_start(converter, &error);
       g_free(folder_path);
@@ -787,6 +834,8 @@ main(gint    argc,
 {
   if (!g_thread_supported()) g_thread_init(NULL);
 
+  g_type_init();
+
   #ifdef ENABLE_NLS
     /* Internationalization */
     bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR);
@@ -797,6 +846,9 @@ main(gint    argc,
   /* Set a name for the application */
   g_set_application_name(PACKAGE_NAME);
 
+  /* Initialisation of gsettings */
+  settings = g_settings_new(GNAC_SCHEMA);
+
   /* Parse command line arguments */
   gnac_options_init(argc, argv);
 
diff --git a/src/gnac-main.h b/src/gnac-main.h
index 477ee69..9fd0cbf 100644
--- a/src/gnac-main.h
+++ b/src/gnac-main.h
@@ -31,6 +31,17 @@
 
 #include "libgnac-converter.h"
 
+#define GNAC_SCHEMA "org.gnome.Gnac.conversion"
+#define GNAC_KEY_CLEAR_SOURCE "clear-sources"
+#define GNAC_KEY_DESTINATION_DIRECTORY "destination-directory"
+#define GNAC_KEY_FOLDER_HIERARCHY "folder-hierarchy"
+#define GNAC_KEY_FOLDER_HIERARCHY_PATTERN "folder-hierarchy-pattern"
+#define GNAC_KEY_FOLDER_TYPE "folder-type"
+#define GNAC_KEY_LAST_USED_PROFILE "last-used-profile"
+#define GNAC_KEY_RENAME_PATTERN "rename-pattern"
+#define GNAC_KEY_RENAME_PATTERN_PATTERN "rename-pattern-pattern"
+#define GNAC_KEY_STRIP_SPECIAL "strip-special"
+
 G_BEGIN_DECLS
 
 extern LibgnacConverter *converter;
@@ -45,6 +56,9 @@ typedef enum {
   GNAC_PLUGIN_INSTALL_STATE
 } GnacState;
 
+extern GSettings *settings;
+extern GSettings *settings_ui;
+
 void
 gnac_add_file(GFile *file);
 
@@ -61,6 +75,22 @@ void
 gnac_on_ui_pause_cb(GtkWidget *widget, 
                     gpointer   data);
 
+gboolean
+gnac_settings_set_boolean(const gchar *key,
+                          gboolean     value);
+
+gboolean
+gnac_settings_set_int(const gchar *key,
+                      gint         value);
+
+gboolean
+gnac_settings_set_string(const gchar *key,
+                         const gchar *value);
+
+gboolean
+gnac_settings_set(const gchar *key,
+                  GVariant    *value);
+
 G_GNUC_NORETURN void
 gnac_exit(gint status);
 
diff --git a/src/gnac-options.c b/src/gnac-options.c
index 88c6549..f89dbe1 100644
--- a/src/gnac-options.c
+++ b/src/gnac-options.c
@@ -29,7 +29,6 @@
 
 #include <glib/gi18n.h>
 
-#include "gnac-gconf.h"
 #include "gnac-main.h"
 #include "gnac-options.h"
 #include "libgnac-debug.h"
@@ -103,8 +102,7 @@ gnac_options_audio_profile_cb(const gchar  *option_name,
                               gpointer      data,
                               GError      **error)
 {
-  gnac_gconf_set_string(GNAC_GCONF_LAST_USED_PROFILE, value);
-  libgnac_debug("profile \"%s\" selected", value);
+  gnac_settings_set_string(GNAC_KEY_LAST_USED_PROFILE, value);
   return TRUE;
 }
 
diff --git a/src/gnac-prefs.c b/src/gnac-prefs.c
index fbaca15..799d41d 100644
--- a/src/gnac-prefs.c
+++ b/src/gnac-prefs.c
@@ -30,11 +30,12 @@
 #include <glib/gi18n.h>
 
 #include "gnac-file-list.h"
-#include "gnac-gconf.h"
+#include "gnac-main.h"
 #include "gnac-prefs.h"
 #include "gnac-properties.h"
 #include "gnac-ui.h"
 #include "gnac-utils.h"
+#include "libgnac-debug.h"
 #include "libgnac-output.h"
 #include "profiles/gnac-profiles.h"
 
@@ -194,7 +195,7 @@ gnac_prefs_set_selected_mode(void)
 
 
 static void
-gnac_prefs_gconf_retrieve(void)
+gnac_prefs_retrieve_settings(void)
 {
   gchar           *str;
   GtkComboBox     *combo;
@@ -203,28 +204,13 @@ gnac_prefs_gconf_retrieve(void)
   GtkWidget       *temp;
   gint folder_type;
 
-  /* notification icon */
-  check_button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(gnac_prefs_builder, 
-                                        "check_notification_icon")); 
-  gtk_toggle_button_set_active(check_button, 
-                  gnac_gconf_get_boolean(GNAC_GCONF_TRAY_ICON));
-  /* delete original files */
-  check_button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(gnac_prefs_builder, 
-                                        "erase_originals_checkbutton")); 
-  gtk_toggle_button_set_active(check_button, 
-                  gnac_gconf_get_boolean(GNAC_GCONF_CLEAR_SOURCE));
-  /* strip special characters */
-  check_button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(gnac_prefs_builder, 
-                                        "strip_special_checkbutton")); 
-  gtk_toggle_button_set_active(check_button, 
-                  gnac_gconf_get_boolean(GNAC_GCONF_STRIP_SPECIAL));
   /* output folder */
-  folder_type = gnac_gconf_get_int(GNAC_GCONF_FOLDER_TYPE);
+  folder_type = g_settings_get_int(settings, GNAC_KEY_FOLDER_TYPE);
   /* output filename combo */
   combo = GTK_COMBO_BOX(gtk_builder_get_object(gnac_prefs_builder,
                                         "output_filename_combo"));
   gtk_combo_box_set_active(combo, 
-                  gnac_gconf_get_int(GNAC_GCONF_RENAME_PATTERN));
+                  g_settings_get_int(settings, GNAC_KEY_RENAME_PATTERN));
   /* output filename entry */
   str = gnac_prefs_get_rename_pattern_as_str();
   entry = GTK_ENTRY(gtk_builder_get_object(gnac_prefs_builder,
@@ -235,7 +221,7 @@ gnac_prefs_gconf_retrieve(void)
   combo = GTK_COMBO_BOX(gtk_builder_get_object(gnac_prefs_builder,
                                         "folder_hierarchy_combo"));
   gtk_combo_box_set_active(combo, 
-                  gnac_gconf_get_int(GNAC_GCONF_FOLDER_HIERARCHY));
+                  g_settings_get_int(settings, GNAC_KEY_FOLDER_HIERARCHY));
   /* folder hierarchy entry */
   str = gnac_prefs_get_folder_hierarchy_as_str();
   entry = GTK_ENTRY(gtk_builder_get_object(gnac_prefs_builder,
@@ -250,7 +236,7 @@ gnac_prefs_gconf_retrieve(void)
                             gnac_prefs_builder, "subfolder_radiobutton"));
       temp = GTK_WIDGET(gtk_builder_get_object(gnac_prefs_builder, 
                             "subfolder_entry"));
-      str = gnac_gconf_get_string(GNAC_GCONF_DESTINATION_DIRECTORY); 
+      str = g_settings_get_string(settings, GNAC_KEY_DESTINATION_DIRECTORY);
       gtk_entry_set_text(GTK_ENTRY(temp), str);
       g_free(str);
       gtk_toggle_button_set_active(check_button, TRUE);
@@ -263,7 +249,7 @@ gnac_prefs_gconf_retrieve(void)
                             gnac_prefs_builder, "selected_radiobutton"));
       temp = GTK_WIDGET(gtk_builder_get_object(gnac_prefs_builder, 
                                                 "filechooserbutton"));
-      str = gnac_gconf_get_string(GNAC_GCONF_DESTINATION_DIRECTORY);
+      str = g_settings_get_string(settings, GNAC_KEY_DESTINATION_DIRECTORY);
       gtk_file_chooser_select_uri(GTK_FILE_CHOOSER(temp), str);
       g_free(str);
       gtk_toggle_button_set_active(check_button, TRUE);
@@ -286,6 +272,7 @@ GtkWidget *
 gnac_prefs_window_new(void)
 {
   GError *err = NULL;
+  GtkWidget *check_button;
   GtkWidget *prefs_window;
 
   gnac_prefs_builder = gtk_builder_new();
@@ -305,6 +292,21 @@ gnac_prefs_window_new(void)
   /* Set the parent */
   gtk_window_set_transient_for(GTK_WINDOW(prefs_window), 
                                GTK_WINDOW(gnac_ui_get_widget("main_window")));
+
+  /* GSettings binding */
+  check_button = GTK_WIDGET(gtk_builder_get_object(gnac_prefs_builder,
+      "check_notification_icon"));
+  g_settings_bind(settings_ui, GNAC_KEY_TRAY_ICON, check_button,
+      "active", G_SETTINGS_BIND_DEFAULT);
+  check_button = GTK_WIDGET(gtk_builder_get_object(gnac_prefs_builder,
+      "erase_originals_checkbutton"));
+  g_settings_bind(settings, GNAC_KEY_CLEAR_SOURCE, check_button,
+      "active", G_SETTINGS_BIND_DEFAULT);
+  check_button = GTK_WIDGET(gtk_builder_get_object(gnac_prefs_builder,
+      "strip_special_checkbutton"));
+  g_settings_bind(settings, GNAC_KEY_STRIP_SPECIAL, check_button,
+      "active", G_SETTINGS_BIND_DEFAULT);
+
   return prefs_window;
 }
 
@@ -317,7 +319,7 @@ gnac_prefs_window_show(void)
     gnac_prefs_window = gnac_prefs_window_new();
   }
 
-  gnac_prefs_gconf_retrieve();
+  gnac_prefs_retrieve_settings();
 
   /* always start with the general tab selected */
   notebook = GTK_WIDGET(gtk_builder_get_object(gnac_prefs_builder, "notebook"));
@@ -344,7 +346,7 @@ gnac_prefs_get_rename_pattern_as_str(void)
   }
   if (index == size)
   {
-    return gnac_gconf_get_string(GNAC_GCONF_RENAME_PATTERN_PATTERN);
+    return g_settings_get_string(settings, GNAC_KEY_RENAME_PATTERN_PATTERN);
   }
   return g_strdup(rename_pattern_default[index]);
 }
@@ -366,37 +368,19 @@ gnac_prefs_get_folder_hierarchy_as_str(void)
   }
   if (index == size)
   {
-    return gnac_gconf_get_string(GNAC_GCONF_FOLDER_HIERARCHY_PATTERN);
+    return g_settings_get_string(settings, GNAC_KEY_FOLDER_HIERARCHY_PATTERN);
   }
   return g_strdup(folder_hierarchy_default[index]);
 }
 
 
 void
-gnac_prefs_tray_icon_toggled(GtkWidget *widget,
-                             gpointer   data)
-{
-  gnac_gconf_set_boolean(GNAC_GCONF_TRAY_ICON, 
-    gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
-}
-
-
-void
 gnac_prefs_same_radio_toggled(GtkWidget *widget,
                               gpointer   data)
 {
   gnac_prefs_set_same_mode();
-  gnac_gconf_set_int(GNAC_GCONF_FOLDER_TYPE, FOLDER_CURRENT);
-  gnac_gconf_set_string(GNAC_GCONF_DESTINATION_DIRECTORY, "");
-}
-
-
-void
-gnac_prefs_erase_source_toggled(GtkWidget *widget,
-                                gpointer   data)
-{
-  gnac_gconf_set_boolean(GNAC_GCONF_CLEAR_SOURCE, 
-        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
+  gnac_settings_set_int(GNAC_KEY_FOLDER_TYPE, FOLDER_CURRENT);
+  gnac_settings_set_string(GNAC_KEY_DESTINATION_DIRECTORY, "");
 }
 
 
@@ -404,8 +388,6 @@ void
 gnac_prefs_strip_special_toggled(GtkWidget *widget,
                                  gpointer   data)
 {
-  gnac_gconf_set_boolean(GNAC_GCONF_STRIP_SPECIAL, 
-        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
   gnac_prefs_update_example_label(widget, data);
 }
 
@@ -414,10 +396,11 @@ void
 gnac_prefs_subfolder_radio_toggled(GtkWidget *widget,
                                    gpointer   data)
 { 
+  const gchar *subfolder;
   gnac_prefs_set_subfolder_mode();
-  gnac_gconf_set_int(GNAC_GCONF_FOLDER_TYPE, FOLDER_SUBDIRECTORY);
-  gnac_gconf_set_string(GNAC_GCONF_DESTINATION_DIRECTORY, 
-          gnac_prefs_entry_get_text("subfolder_entry"));
+  gnac_settings_set_int(GNAC_KEY_FOLDER_TYPE, FOLDER_SUBDIRECTORY);
+  subfolder = gnac_prefs_entry_get_text("subfolder_entry");
+  gnac_settings_set_string(GNAC_KEY_DESTINATION_DIRECTORY, subfolder);
 }
 
 
@@ -425,8 +408,9 @@ void
 gnac_prefs_subfolder_editing_done(GtkWidget *widget,
                                   gpointer   data)
 {
-  gnac_gconf_set_string(GNAC_GCONF_DESTINATION_DIRECTORY, 
-        gtk_entry_get_text(GTK_ENTRY(widget)));
+  const gchar *subfolder;
+  subfolder = gtk_entry_get_text(GTK_ENTRY(widget));
+  gnac_settings_set_string(GNAC_KEY_DESTINATION_DIRECTORY, subfolder);
 }
 
 
@@ -438,10 +422,10 @@ gnac_prefs_selected_radio_toggled(GtkWidget *widget,
   GtkWidget *filechooserbutton;
   filechooserbutton = GTK_WIDGET(gtk_builder_get_object(gnac_prefs_builder, 
                                                         "filechooserbutton"));
-  uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(filechooserbutton));
   gnac_prefs_set_selected_mode();
-  gnac_gconf_set_int(GNAC_GCONF_FOLDER_TYPE, FOLDER_SELECTED);
-  gnac_gconf_set_string(GNAC_GCONF_DESTINATION_DIRECTORY, uri);
+  gnac_settings_set_int(GNAC_KEY_FOLDER_TYPE, FOLDER_SELECTED);
+  uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(filechooserbutton));
+  gnac_settings_set_string(GNAC_KEY_DESTINATION_DIRECTORY, uri);
   g_free(uri);
 }
 
@@ -455,7 +439,7 @@ gnac_prefs_selected_uri_changed(GtkWidget *widget,
   filechooserbutton = GTK_WIDGET(gtk_builder_get_object(gnac_prefs_builder, 
                                                         "filechooserbutton"));
   uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(filechooserbutton));
-  gnac_gconf_set_string(GNAC_GCONF_DESTINATION_DIRECTORY, uri);
+  gnac_settings_set_string(GNAC_KEY_DESTINATION_DIRECTORY, uri);
   g_free(uri);
 }
 
@@ -480,7 +464,7 @@ gnac_prefs_update_example_label(GtkWidget *widget,
   pattern_filename = gnac_prefs_entry_get_text("output_filename_entry");
   if (pattern_filename && !g_str_equal(pattern_filename, ""))
   {
-    gnac_gconf_set_string(GNAC_GCONF_RENAME_PATTERN_PATTERN, pattern_filename);
+    gnac_settings_set_string(GNAC_KEY_RENAME_PATTERN_PATTERN, pattern_filename);
   }
 
   if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) != 0)
@@ -489,7 +473,8 @@ gnac_prefs_update_example_label(GtkWidget *widget,
     pattern_folder = gnac_prefs_entry_get_text("folder_hierarchy_entry");
     if (pattern_folder && !g_str_equal(pattern_folder, ""))
     {
-      gnac_gconf_set_string(GNAC_GCONF_FOLDER_HIERARCHY_PATTERN, pattern_folder);
+      gnac_settings_set_string(GNAC_KEY_FOLDER_HIERARCHY_PATTERN,
+          pattern_folder);
       pattern = g_strdup_printf("%s/%s", pattern_folder, pattern_filename);
     }
     else
@@ -503,7 +488,7 @@ gnac_prefs_update_example_label(GtkWidget *widget,
   }
 
   preview = libgnac_output_get_preview_from_pattern(pattern, 
-                  gnac_gconf_get_boolean(GNAC_GCONF_STRIP_SPECIAL));
+                  g_settings_get_boolean(settings, GNAC_KEY_STRIP_SPECIAL));
   clean_label = g_markup_printf_escaped("%s.%s",
                   preview, gnac_profiles_get_extension());
 
@@ -575,8 +560,8 @@ gnac_prefs_pattern_changed_cb(GtkWidget *widget,
 
   gtk_entry_set_text(GTK_ENTRY(filename_entry), pattern);
 
-  gnac_gconf_set_int(GNAC_GCONF_RENAME_PATTERN, active);
-  gnac_gconf_set_string(GNAC_GCONF_RENAME_PATTERN_PATTERN, pattern);
+  gnac_settings_set_int(GNAC_KEY_RENAME_PATTERN, active);
+  gnac_settings_set_string(GNAC_KEY_RENAME_PATTERN_PATTERN, pattern);
 
   g_free(pattern);
 }
@@ -609,8 +594,8 @@ gnac_prefs_folder_hierarchy_changed_cb(GtkWidget *widget,
 
   gtk_entry_set_text(GTK_ENTRY(folder_entry), pattern);
 
-  gnac_gconf_set_int(GNAC_GCONF_FOLDER_HIERARCHY, active);
-  gnac_gconf_set_string(GNAC_GCONF_FOLDER_HIERARCHY_PATTERN, pattern);
+  gnac_settings_set_int(GNAC_KEY_FOLDER_HIERARCHY, active);
+  gnac_settings_set_string(GNAC_KEY_FOLDER_HIERARCHY_PATTERN, pattern);
 
   g_free(pattern);
 }
diff --git a/src/gnac-prefs.h b/src/gnac-prefs.h
index ae55e72..31fc5d6 100644
--- a/src/gnac-prefs.h
+++ b/src/gnac-prefs.h
@@ -40,14 +40,6 @@ void
 gnac_prefs_window_hide(void);
 
 void
-gnac_prefs_tray_icon_toggled(GtkWidget *widget,
-                             gpointer   data);
-
-void
-gnac_prefs_erase_source_toggled(GtkWidget *widget,
-                                gpointer   data);
-
-void
 gnac_prefs_strip_special_toggled(GtkWidget *widget,
                                  gpointer   data);
 
diff --git a/src/gnac-ui.c b/src/gnac-ui.c
index ee6719b..76f041f 100644
--- a/src/gnac-ui.c
+++ b/src/gnac-ui.c
@@ -41,7 +41,6 @@
 
 #include "gnac-bars.h"
 #include "gnac-file-list.h"
-#include "gnac-gconf.h"
 #include "gnac-main.h"
 #include "gnac-options.h"
 #include "gnac-prefs.h"
@@ -56,6 +55,8 @@ extern GnacState state;
 extern guint nb_files_added;
 extern LibgnacMetadata *metadata;
 
+GSettings *settings_ui;
+
 static GSList         *filters;
 static GtkBuilder     *gnac_main_builder = NULL;
 static GtkFileFilter  *default_file_filter;
@@ -419,7 +420,7 @@ gnac_ui_on_profile_changed_cb(GtkComboBox *box,
 {
   const gchar *profile_name = NULL;
   profile_name = gnac_profiles_get_name();
-  gnac_gconf_set_string(GNAC_GCONF_LAST_USED_PROFILE, profile_name);
+  gnac_settings_set_string(GNAC_KEY_LAST_USED_PROFILE, profile_name);
 }
 
 
@@ -459,7 +460,7 @@ gnac_ui_show_toolbar(void)
 
   /* update toolbar's status */
   view_toolbar = GTK_TOGGLE_ACTION(gnac_ui_get_action("view_toolbar_item"));
-  visible = gnac_gconf_get_boolean(GNAC_GCONF_TOOLBAR_VISIBLE);
+  visible = g_settings_get_boolean(settings_ui, GNAC_KEY_TOOLBAR_VISIBLE);
   gtk_toggle_action_set_active(view_toolbar, visible);
   toolbar = gnac_ui_get_widget("main_toolbar");
   gtk_widget_set_visible(toolbar, visible);
@@ -650,7 +651,7 @@ gnac_ui_new(void)
       G_CALLBACK(gnac_ui_on_profile_changed_cb),
       NULL);
 
-  current_profile = gnac_gconf_get_string(GNAC_GCONF_LAST_USED_PROFILE);
+  current_profile = g_settings_get_string(settings, GNAC_KEY_LAST_USED_PROFILE);
   gnac_profiles_set_current_profile(current_profile);
   g_free(current_profile);
 
@@ -954,7 +955,7 @@ gnac_ui_on_view_toolbar_cb(GtkAction *action,
   toolbar = gnac_ui_get_widget("main_toolbar"),
   visible = !gtk_widget_get_visible(toolbar);
   gtk_widget_set_visible(toolbar, visible);
-  gnac_gconf_set_boolean(GNAC_GCONF_TOOLBAR_VISIBLE, visible);
+  g_settings_set_boolean(settings_ui, GNAC_KEY_TOOLBAR_VISIBLE, visible);
 }
 
 
@@ -1175,6 +1176,7 @@ gnac_ui_init_unique(void)
 void
 gnac_ui_init(void)
 {
+  settings_ui = g_settings_new(GNAC_SCHEMA_UI);
   gnac_ui_init_notify();
   gnac_ui_init_unique();
 }
@@ -1345,7 +1347,7 @@ gnac_ui_show_trayicon(void)
 {
   GtkWidget *main_window;
 
-  if (!gnac_gconf_get_boolean(GNAC_GCONF_TRAY_ICON)) return;
+  if (!g_settings_get_boolean(settings_ui, GNAC_KEY_TRAY_ICON)) return;
 
   main_window = gnac_ui_get_widget("main_window");
 
@@ -1373,7 +1375,11 @@ gnac_ui_hide_trayicon(void)
   GtkWidget *main_window;
   gboolean window_displayed;
 
-  if (!gnac_gconf_get_boolean(GNAC_GCONF_TRAY_ICON) || !trayicon) return;
+  if (!g_settings_get_boolean(settings_ui, GNAC_KEY_TRAY_ICON) ||
+      !trayicon)
+  {
+    return;
+  }
 
   main_window = gnac_ui_get_widget("main_window");
   g_object_get(main_window, "visible", &window_displayed, NULL);
@@ -1448,7 +1454,11 @@ gnac_ui_trayicon_tooltip_update(const gchar *tooltip)
 {
   GdkDisplay *display;
   
-  if (!gnac_gconf_get_boolean(GNAC_GCONF_TRAY_ICON) || !trayicon) return;
+  if (!g_settings_get_boolean(settings_ui, GNAC_KEY_TRAY_ICON) ||
+      !trayicon)
+  {
+    return;
+  }
 
   if (tooltip_path) {
     g_free(tooltip_path);
diff --git a/src/gnac-ui.h b/src/gnac-ui.h
index f991e9a..770b2a9 100644
--- a/src/gnac-ui.h
+++ b/src/gnac-ui.h
@@ -26,18 +26,23 @@
 #ifndef GNAC_UI_H
 #define GNAC_UI_H
 
-#include <gconf/gconf-client.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
 #include "gnac-options.h"
 
+#define GNAC_SCHEMA_UI "org.gnome.Gnac.ui"
+#define GNAC_KEY_TRAY_ICON "tray-icon"
+#define GNAC_KEY_TOOLBAR_VISIBLE "toolbar-visible"
+
 G_BEGIN_DECLS
 
 enum {
   TARGET_STRING
 };
 
+extern GSettings *settings_ui;
+
 void
 gnac_ui_set_progress_fraction(gdouble fraction);
 
diff --git a/src/profiles/gnac-profiles-manager.c b/src/profiles/gnac-profiles-manager.c
index 9f83e1f..ab66f34 100644
--- a/src/profiles/gnac-profiles-manager.c
+++ b/src/profiles/gnac-profiles-manager.c
@@ -32,7 +32,6 @@
 #include <glib/gi18n.h>
 #include <stdlib.h>
 
-#include "gnac-gconf.h"
 #include "gnac-main.h"
 #include "gnac-profiles-default.h"
 #include "gnac-profiles-manager.h"
@@ -256,7 +255,6 @@ gnac_profiles_mgr_list_profiles(void)
 {
   AudioProfileGeneric *profile;
   const gchar         *profile_file_name;
-  gchar               *last_profile;
   gchar               *profile_file_full_path;
   gchar               *profile_file_path;
   GError              *error = NULL;
@@ -292,7 +290,8 @@ gnac_profiles_mgr_list_profiles(void)
   g_print(_("Available audio profiles:"));
   g_print("\n\n");
 
-  last_profile = gnac_gconf_get_string(GNAC_GCONF_LAST_USED_PROFILE);
+  gchar *last_used_profile = g_settings_get_string(settings,
+      GNAC_KEY_LAST_USED_PROFILE);
 
   guint count = 0;
   while ((file_info = g_file_enumerator_next_file(files, NULL, NULL))) {
@@ -309,9 +308,9 @@ gnac_profiles_mgr_list_profiles(void)
         gchar *count_str = g_strdup_printf("%u", count);
         /* if last_used_profile is not set, assume the
          * first profile was last used */
-        g_print("\t%2s) %s\n", (((count == 0)
-            && (!last_profile || g_str_equal(last_profile, "")))
-            || g_str_equal(name, last_profile)) ? "*" : count_str, name);
+        g_print("\t%2s) %s\n",
+            ((count == 0 && !last_used_profile) ||
+            g_str_equal(name, last_used_profile)) ? "*" : count_str, name);
         count++;
         g_free(count_str);
       }
@@ -331,7 +330,7 @@ gnac_profiles_mgr_list_profiles(void)
   g_print("\n");
 
   /* Cleanup */
-  g_free(last_profile);
+  g_free(last_used_profile);
   g_object_unref(dir);
   g_file_enumerator_close(files, NULL, NULL);
   g_object_unref(files);



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