[gnac/gnac-gsettings] Started to port Gnac to GSettings (trac ticket #35)
- From: Benoît Dupasquier <bdupasqu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnac/gnac-gsettings] Started to port Gnac to GSettings (trac ticket #35)
- Date: Tue, 12 Oct 2010 15:09:27 +0000 (UTC)
commit b9432a5fc864ba7d9416b99b1eb2c9d2cabfcfeb
Author: Benoît Dupasquier <bdupasqu src gnome org>
Date: Tue Oct 12 16:02:32 2010 +0100
Started to port Gnac to GSettings (trac ticket #35)
.gitignore | 1 -
configure.ac | 16 +---
data/Makefile.am | 43 ++------
data/gnac.schemas.in | 105 -----------------
data/org.gnome.gnac.gschema.xml.in | 61 ++++++++++
m4/intltool.m4 | 2 +-
po/POTFILES.in | 3 +-
src/Makefile.am | 2 -
src/gnac-gconf.c | 207 ----------------------------------
src/gnac-gconf.h | 82 -------------
src/gnac-main.c | 44 +++++---
src/gnac-main.h | 17 +++
src/gnac-options.c | 3 +-
src/gnac-prefs.c | 88 ++++++++------
src/gnac-ui.c | 4 +-
src/gnac-ui.h | 1 -
src/profiles/gnac-profiles-manager.c | 10 +-
17 files changed, 181 insertions(+), 508 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..3a4147f 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])
@@ -82,7 +78,6 @@ AC_SUBST(GLIB_LIBS)
dnl Find the UI libraries
PKG_CHECK_MODULES(UI, [
- gconf-2.0
gtk+-2.0 >= 2.14
libxml-2.0
])
@@ -128,13 +123,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..4678a4c 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,12 @@ 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/org.gnome.gnac.gschema.xml.in b/data/org.gnome.gnac.gschema.xml.in
new file mode 100644
index 0000000..d218040
--- /dev/null
+++ b/data/org.gnome.gnac.gschema.xml.in
@@ -0,0 +1,61 @@
+<schemalist>
+
+ <schema id="org.gnome.Gnac" path="/apps/gnac/">
+ <child name="display" schema="org.gnome.Gnac.display" />
+ <child name="conversion" schema="org.gnome.Gnac.conversion" />
+ </schema>
+
+ <schema id="org.gnome.Gnac.ui" path="/apps/gnac/ui/">
+ <key name="tray-icon" type="b">
+ <default>false</default>
+ <_summary>Display a notification icon during the conversion</_summary>
+ </key>
+ </schema>
+
+ <schema id="org.gnome.Gnac.conversion" path="/apps/gnac/conversion/">
+ <key name="folder-hierarchy" type="i">
+ <default>0</default>
+ <_summary>Folder hierarchy</_summary>
+ </key>
+
+ <key name="folder-hierarchy-pattern" type="s">
+ <default>''</default>
+ <_summary>Folder hierarchy pattern</_summary>
+ </key>
+
+ <key name="rename-pattern" type="i">
+ <default>0</default>
+ <_summary>Output filename</_summary>
+ </key>
+
+ <key name="rename-pattern-pattern" type="s">
+ <default>'%f'</default>
+ <_summary>Output filename pattern</_summary>
+ </key>
+
+ <key name="folder-type" type="i">
+ <default>0</default>
+ <_summary>Folder type</_summary>
+ </key>
+
+ <key name="destination-directory" type="s">
+ <default>'current-directory'</default>
+ <_summary>Output directory</_summary>
+ </key>
+
+ <key name="clear-sources" type="b">
+ <default>false</default>
+ <_summary>Delete original files after conversion</_summary>
+ </key>
+
+ <key name="strip-special" type="b">
+ <default>false</default>
+ <_summary>Strip special characters</_summary>
+ </key>
+
+ <key name="last-used-profile" type="s">
+ <default>'CD Quality, Lossy'</default>
+ <_summary>Last used profile</_summary>
+ </key>
+ </schema>
+</schemalist>
diff --git a/m4/intltool.m4 b/m4/intltool.m4
index 122d773..839e855 100644
--- a/m4/intltool.m4
+++ b/m4/intltool.m4
@@ -172,7 +172,7 @@ IT_PO_SUBDIR([po])
AC_DEFUN([IT_PO_SUBDIR],
[AC_PREREQ([2.53])dnl We use ac_top_srcdir inside AC_CONFIG_COMMANDS.
dnl
-dnl The following CONFIG_COMMANDS should be exetuted at the very end
+dnl The following CONFIG_COMMANDS should be executed at the very end
dnl of config.status.
AC_CONFIG_COMMANDS_PRE([
AC_CONFIG_COMMANDS([$1/stamp-it], [
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 e1a33d0..28eb0dd 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"
@@ -54,6 +53,8 @@
#include "profiles/gnac-profiles-utils.h"
+GSettings *settings_ui;
+GSettings *settings;
static LibgnacConverter *converter;
static gboolean conversion_errors = FALSE;
@@ -99,7 +100,9 @@ gnac_change_state(GnacState new_state)
switch (state) {
case GNAC_AUDIO_EMPTY_STATE:
gnac_bars_on_row_deleted();
- if (gnac_gconf_get_boolean(GNAC_GCONF_TRAY_ICON)) gnac_ui_hide_trayicon();
+ if (g_settings_get_boolean(settings_ui, GNAC_KEY_TRAY_ICON)) {
+ gnac_ui_hide_trayicon();
+ }
gnac_ui_show_progress(FALSE);
gnac_ui_show_pause(FALSE);
gnac_bars_on_convert_stop();
@@ -123,7 +126,7 @@ gnac_change_state(GnacState new_state)
case GNAC_AUDIO_READY_STATE:
remember_overwrite = FALSE;
gnac_bars_on_row_inserted();
- if (gnac_gconf_get_boolean(GNAC_GCONF_TRAY_ICON) &&
+ if (g_settings_get_boolean(settings_ui, GNAC_KEY_TRAY_ICON) &&
gtk_window_has_toplevel_focus(
GTK_WINDOW(gnac_ui_get_widget("main_window"))))
{
@@ -148,7 +151,9 @@ gnac_change_state(GnacState new_state)
break;
case GNAC_AUDIO_CONVERT_STATE:
- if (gnac_gconf_get_boolean(GNAC_GCONF_TRAY_ICON)) gnac_ui_show_trayicon();
+ if (g_settings_get_boolean(settings_ui, GNAC_KEY_TRAY_ICON)) {
+ gnac_ui_show_trayicon();
+ }
gnac_file_list_hide_visual_bar();
gnac_ui_show_progress(TRUE);
gnac_ui_show_pause(TRUE);
@@ -390,7 +395,7 @@ gnac_confirm_exit(void)
gint response;
GtkWidget *dialog;
- has_trayicon = gnac_gconf_get_boolean(GNAC_GCONF_TRAY_ICON);
+ has_trayicon = g_settings_get_boolean(settings_ui, GNAC_KEY_TRAY_ICON);
/* disable stop/resume and quit from trayicon's menu */
if (has_trayicon) gnac_ui_trayicon_menu_activate(FALSE);
@@ -485,7 +490,6 @@ gnac_on_ui_destroy_cb(GtkWidget *widget,
if (converter) g_object_unref(converter);
if (metadata) g_object_unref(metadata);
- gnac_gconf_destroy();
gnac_properties_destroy();
gnac_prefs_destroy();
gnac_profiles_destroy();
@@ -651,7 +655,7 @@ gnac_on_converter_file_started_cb(LibgnacConverter *converter,
return;
}
- if (gnac_gconf_get_boolean(GNAC_GCONF_TRAY_ICON)) {
+ if (g_settings_get_boolean(settings_ui, GNAC_KEY_TRAY_ICON)) {
gnac_ui_trayicon_tooltip_update(input);
}
}
@@ -665,7 +669,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);
@@ -835,17 +839,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);
@@ -877,7 +885,10 @@ gnac_on_ui_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);
+ if (!g_settings_set_string(settings, GNAC_KEY_LAST_USED_PROFILE, profile_name)) {
+ g_printerr("Failed to set key %s to %s\n",
+ GNAC_KEY_LAST_USED_PROFILE, profile_name);
+ }
}
@@ -1013,6 +1024,8 @@ main(gint argc,
{
if (!g_thread_supported()) g_thread_init(NULL);
+ g_type_init();
+
#ifdef ENABLE_NLS
/* Internationalization */
bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR);
@@ -1023,6 +1036,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 98d19c2..818f28a 100644
--- a/src/gnac-main.h
+++ b/src/gnac-main.h
@@ -31,6 +31,20 @@
#include "libgnac-converter.h"
+#define GNAC_SCHEMA_UI "org.gnome.Gnac.ui"
+#define GNAC_KEY_TRAY_ICON "tray-icon"
+
+#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
typedef enum {
@@ -43,6 +57,9 @@ typedef enum {
GNAC_PLUGIN_INSTALL_STATE
} GnacState;
+extern GSettings *settings;
+extern GSettings *settings_ui;
+
void
gnac_add_file(GFile *file);
diff --git a/src/gnac-options.c b/src/gnac-options.c
index 7386c83..1efee12 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,7 +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);
+ g_settings_set_string(settings, GNAC_KEY_LAST_USED_PROFILE, value);
libgnac_debug("profile \"%s\" selected", value);
return TRUE;
}
diff --git a/src/gnac-prefs.c b/src/gnac-prefs.c
index 94dcd33..5ba5080 100644
--- a/src/gnac-prefs.c
+++ b/src/gnac-prefs.c
@@ -30,7 +30,7 @@
#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"
@@ -194,7 +194,7 @@ gnac_prefs_set_selected_mode(void)
static void
-gnac_prefs_gconf_retrieve(void)
+gnac_prefs_retrieve_settings(void)
{
gchar *str;
GtkComboBox *combo;
@@ -207,24 +207,24 @@ gnac_prefs_gconf_retrieve(void)
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));
+ g_settings_get_boolean(settings_ui, GNAC_KEY_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));
+ g_settings_get_boolean(settings, GNAC_KEY_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));
+ g_settings_get_boolean(settings, GNAC_KEY_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 +235,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 +250,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 +263,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);
@@ -317,7 +317,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 +344,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,7 +366,7 @@ 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]);
}
@@ -376,8 +376,10 @@ 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)));
+ if (!g_settings_set_boolean(settings_ui, GNAC_KEY_TRAY_ICON,
+ gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))) {
+ g_printerr("failed to set key\n");
+ }
}
@@ -386,8 +388,8 @@ 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, "");
+ g_settings_set_int(settings, GNAC_KEY_FOLDER_TYPE, FOLDER_CURRENT);
+ g_settings_set_string(settings, GNAC_KEY_DESTINATION_DIRECTORY, "");
}
@@ -395,7 +397,7 @@ void
gnac_prefs_erase_source_toggled(GtkWidget *widget,
gpointer data)
{
- gnac_gconf_set_boolean(GNAC_GCONF_CLEAR_SOURCE,
+ g_settings_set_boolean(settings, GNAC_KEY_CLEAR_SOURCE,
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
}
@@ -404,7 +406,7 @@ void
gnac_prefs_strip_special_toggled(GtkWidget *widget,
gpointer data)
{
- gnac_gconf_set_boolean(GNAC_GCONF_STRIP_SPECIAL,
+ g_settings_set_boolean(settings, GNAC_KEY_STRIP_SPECIAL,
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
gnac_prefs_update_example_label(widget, data);
}
@@ -415,8 +417,8 @@ gnac_prefs_subfolder_radio_toggled(GtkWidget *widget,
gpointer data)
{
gnac_prefs_set_subfolder_mode();
- gnac_gconf_set_int(GNAC_GCONF_FOLDER_TYPE, FOLDER_SUBDIRECTORY);
- gnac_gconf_set_string(GNAC_GCONF_DESTINATION_DIRECTORY,
+ g_settings_set_int(settings, GNAC_KEY_FOLDER_TYPE, FOLDER_SUBDIRECTORY);
+ g_settings_set_string(settings, GNAC_KEY_DESTINATION_DIRECTORY,
gnac_prefs_entry_get_text("subfolder_entry"));
}
@@ -425,7 +427,7 @@ void
gnac_prefs_subfolder_editing_done(GtkWidget *widget,
gpointer data)
{
- gnac_gconf_set_string(GNAC_GCONF_DESTINATION_DIRECTORY,
+ g_settings_set_string(settings, GNAC_KEY_DESTINATION_DIRECTORY,
gtk_entry_get_text(GTK_ENTRY(widget)));
}
@@ -434,13 +436,17 @@ void
gnac_prefs_selected_radio_toggled(GtkWidget *widget,
gpointer data)
{
+ gchar *uri;
GtkWidget *filechooserbutton;
filechooserbutton = GTK_WIDGET(gtk_builder_get_object(gnac_prefs_builder,
"filechooserbutton"));
gnac_prefs_set_selected_mode();
- gnac_gconf_set_int(GNAC_GCONF_FOLDER_TYPE, FOLDER_SELECTED);
- gnac_gconf_set_string(GNAC_GCONF_DESTINATION_DIRECTORY,
- gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(filechooserbutton)));
+ g_settings_set_int(settings, GNAC_KEY_FOLDER_TYPE, FOLDER_SELECTED);
+ uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(filechooserbutton));
+ if (uri) {
+ g_settings_set_string(settings, GNAC_KEY_DESTINATION_DIRECTORY, uri);
+ g_free(uri);
+ }
}
@@ -448,11 +454,15 @@ void
gnac_prefs_selected_uri_changed(GtkWidget *widget,
gpointer data)
{
+ gchar *uri;
GtkWidget *filechooserbutton;
filechooserbutton = GTK_WIDGET(gtk_builder_get_object(gnac_prefs_builder,
"filechooserbutton"));
- gnac_gconf_set_string(GNAC_GCONF_DESTINATION_DIRECTORY,
- gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(filechooserbutton)));
+ uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(filechooserbutton));
+ if (uri) {
+ g_settings_set_string(settings, GNAC_KEY_DESTINATION_DIRECTORY, uri);
+ g_free(uri);
+ }
}
@@ -476,7 +486,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);
+ g_settings_set_string(settings, GNAC_KEY_RENAME_PATTERN_PATTERN, pattern_filename);
}
if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) != 0)
@@ -485,7 +495,7 @@ 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);
+ g_settings_set_string(settings, GNAC_KEY_FOLDER_HIERARCHY_PATTERN, pattern_folder);
pattern = g_strdup_printf("%s/%s", pattern_folder, pattern_filename);
}
else
@@ -499,7 +509,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());
@@ -571,10 +581,11 @@ 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);
-
- g_free(pattern);
+ g_settings_set_int(settings, GNAC_KEY_RENAME_PATTERN, active);
+ if (pattern) {
+ g_settings_set_string(settings, GNAC_KEY_RENAME_PATTERN_PATTERN, pattern);
+ g_free(pattern);
+ }
}
@@ -605,10 +616,11 @@ 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);
-
- g_free(pattern);
+ g_settings_set_int(settings, GNAC_KEY_FOLDER_HIERARCHY, active);
+ if (pattern) {
+ g_settings_set_string(settings, GNAC_KEY_FOLDER_HIERARCHY_PATTERN, pattern);
+ g_free(pattern);
+ }
}
diff --git a/src/gnac-ui.c b/src/gnac-ui.c
index 21618fc..4dd2a1c 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-stock-items.h"
@@ -589,7 +588,7 @@ gnac_ui_new(void)
G_CALLBACK(gnac_on_ui_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);
@@ -922,6 +921,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();
}
diff --git a/src/gnac-ui.h b/src/gnac-ui.h
index 035ed9d..e0761e3 100644
--- a/src/gnac-ui.h
+++ b/src/gnac-ui.h
@@ -26,7 +26,6 @@
#ifndef GNAC_UI_H
#define GNAC_UI_H
-#include <gconf/gconf-client.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
diff --git a/src/profiles/gnac-profiles-manager.c b/src/profiles/gnac-profiles-manager.c
index 980f2d6..7ec1c8b 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"
@@ -304,10 +303,13 @@ gnac_profiles_mgr_list_profiles(void)
if (profile) {
const gchar *name = (profile->generic)->name;
gchar *count_str = g_strdup_printf("%u", count);
- g_print("\t%2s) %s\n", g_str_equal(name,
- gnac_gconf_get_string(GNAC_GCONF_LAST_USED_PROFILE)) ?
- "*" : count_str, name);
+ gchar *last_used_profile = g_settings_get_string(settings,
+ GNAC_KEY_LAST_USED_PROFILE);
+ g_print("\t%2s) %s\n",
+ ((count == 0 && !last_used_profile) ||
+ g_str_equal(name, last_used_profile)) ? "*" : count_str, name);
count++;
+ g_free(last_used_profile);
g_free(count_str);
}
/* Cleanup */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]