summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2011-08-06 16:07:16 +0200
committerChristophe Fergeau <cfergeau@redhat.com>2014-01-23 16:15:33 +0100
commit60c940d69785697ea1c45f05963aa7d2ba3dbfe5 (patch)
tree61235643f5646671b862e67c5652733147945555
parent06d072b548209d69d259672fec46a1d74bbe9aad (diff)
Port SoundJuicer to gsettings
Including reviews/contributions from Gert Michael Kulyk and Phillip Wood. https://bugzilla.gnome.org/show_bug.cgi?id=625897
-rw-r--r--configure.ac13
-rw-r--r--data/Makefile.am20
-rw-r--r--data/sound-juicer.schemas.in220
-rw-r--r--libjuicer/sj-metadata-musicbrainz5.c47
-rw-r--r--po/POTFILES.in2
-rw-r--r--sound-juicer.spec.in13
-rw-r--r--src/Makefile.am2
-rw-r--r--src/gconf-bridge.c1246
-rw-r--r--src/gconf-bridge.h116
-rw-r--r--src/sj-main.c364
-rw-r--r--src/sj-play.c2
-rw-r--r--src/sj-prefs.c138
-rw-r--r--src/sound-juicer.h44
-rw-r--r--tests/mb-test.c11
14 files changed, 246 insertions, 1992 deletions
diff --git a/configure.ac b/configure.ac
index 97e3cbd..c49b83c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,6 +33,7 @@ GNOME_DEBUG_CHECK
GNOME_MAINTAINER_MODE_DEFINES
GTK_REQUIRED=3.2.0
+GLIB_GSETTINGS
AC_CHECK_FUNC(socket,,[AC_CHECK_LIB(socket,socket)])
@@ -40,7 +41,7 @@ AC_CHECK_FUNC(socket,,[AC_CHECK_LIB(socket,socket)])
GNOME_DOC_INIT
# Find GLib and GObject
-PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.32 gthread-2.0 gobject-2.0)
+PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.32 gthread-2.0 gobject-2.0 gio-2.0)
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
@@ -56,7 +57,7 @@ LIBS="$LIBS $BURN_LIBS"
# LIBS="$oldlibs"
# Find the UI libraries
-PKG_CHECK_MODULES(UI, gtk+-3.0 >= $GTK_REQUIRED gconf-2.0 gio-2.0 gmodule-export-2.0 libcanberra-gtk3)
+PKG_CHECK_MODULES(UI, gtk+-3.0 >= $GTK_REQUIRED gio-2.0 gmodule-export-2.0 libcanberra-gtk3)
AC_SUBST(UI_CFLAGS)
AC_SUBST(UI_LIBS)
@@ -93,14 +94,6 @@ PKG_CHECK_MODULES(GIO, gio-2.0)
AC_SUBST(GIO_CFLAGS)
AC_SUBST(GIO_LIBS)
-# 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
-
-
# Optionally enable G* deprecations
AC_MSG_CHECKING([whether to enable deprecation warnings])
AC_ARG_ENABLE([deprecations],
diff --git a/data/Makefile.am b/data/Makefile.am
index b752400..8ca00d0 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -6,11 +6,6 @@ desktop_in_files = sound-juicer.desktop.in.in
desktop_DATA = $(desktop_in_files:.desktop.in.in=.desktop)
@INTLTOOL_DESKTOP_RULE@
-schemadir = $(GCONF_SCHEMA_FILE_DIR)
-schema_in_files = sound-juicer.schemas.in
-schema_DATA = $(schema_in_files:.schemas.in=.schemas)
-@INTLTOOL_SCHEMAS_RULE@
-
profilesdir = $(datadir)/sound-juicer
dist_profiles_DATA = rhythmbox.gep
@@ -62,27 +57,14 @@ uninstall-icons:
install-data-local: install-icons
install-data-hook: update-icon-cache
-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 ;\
- echo "*****************************************************"; \
- echo "Installation of schemas failed, install them manually"; \
- echo "*****************************************************";)
- @true
-endif
uninstall-local: uninstall-icons
uninstall-hook: update-icon-cache
CLEANFILES = \
- $(desktop_DATA) \
- $(schema_DATA)
+ $(desktop_DATA)
EXTRA_DIST = \
- $(schema_in_files) \
$(man1_MANS) \
$(icons)
diff --git a/data/sound-juicer.schemas.in b/data/sound-juicer.schemas.in
deleted file mode 100644
index 038363a..0000000
--- a/data/sound-juicer.schemas.in
+++ /dev/null
@@ -1,220 +0,0 @@
-<?xml version="1.0"?>
-
-<gconfschemafile>
- <schemalist>
-
- <schema>
- <key>/schemas/apps/sound-juicer/device</key>
- <applyto>/apps/sound-juicer/device</applyto>
- <type>string</type>
- <owner>sound-juicer</owner>
- <locale name="C">
- <!-- No default, NULL will query the machine -->
- <short>The CD to extract from.</short>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/sound-juicer/eject</key>
- <applyto>/apps/sound-juicer/eject</applyto>
- <type>bool</type>
- <owner>sound-juicer</owner>
- <default>false</default>
- <locale name="C">
- <short>Whether to eject the CD when finished extracting.</short>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/sound-juicer/open_completed</key>
- <applyto>/apps/sound-juicer/open_completed</applyto>
- <type>bool</type>
- <owner>sound-juicer</owner>
- <default>false</default>
- <locale name="C">
- <short>Whether to open the target directory when finished extracting.</short>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/sound-juicer/base_uri</key>
- <applyto>/apps/sound-juicer/base_uri</applyto>
- <type>string</type>
- <owner>sound-juicer</owner>
- <locale name="C">
- <!-- No default, NULL will use $HOME -->
- <short>The URI to save the extracted music to.</short>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/sound-juicer/base_path</key>
- <applyto>/apps/sound-juicer/base_path</applyto>
- <type>string</type>
- <owner>sound-juicer</owner>
- <locale name="C">
- <!-- No default, NULL will use $HOME -->
- <short>The local directory to save the extracted music to (deprecated, use base_uri)</short>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/sound-juicer/path_pattern</key>
- <applyto>/apps/sound-juicer/path_pattern</applyto>
- <type>string</type>
- <owner>sound-juicer</owner>
- <default>%aa/%at</default>
- <locale name="C">
- <short>The directory structure for the files</short>
- <long>
- %at -- album title
- %aT -- album title (lowercase)
- %aa -- album artist
- %aA -- album artist (lowercase)
- %as -- album artist (sortable)
- %aS -- album artist (sortable lowercase)
- %ac -- album composer
- %aC -- album composer (lowercase)
- %ap -- album composer (sortable)
- %aP -- album composer (sortable lowercase)
- %ay -- album year
- %tt -- track title
- %tT -- track title (lowercase)
- %ta -- track artist
- %tA -- track artist (lowercase)
- %ts -- track artist (sortable)
- %tS -- track artist (sortable lowercase)
- %tc -- track composer
- %tC -- track composer (lowercase)
- %tp -- track composer (sortable)
- %tP -- track composer (sortable lowercase)
- </long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/sound-juicer/file_pattern</key>
- <applyto>/apps/sound-juicer/file_pattern</applyto>
- <type>string</type>
- <owner>sound-juicer</owner>
- <default>%dn - %tt</default>
- <locale name="C">
- <short>The name pattern for files</short>
- <long>
- Do not specify an extension.
- %at -- album title
- %aT -- album title (lowercase)
- %aa -- album artist
- %aA -- album artist (lowercase)
- %as -- album artist (sortable)
- %aS -- album artist (sortable lowercase)
- %ac -- album composer
- %aC -- album composer (lowercase)
- %ap -- album composer (sortable)
- %aP -- album composer (sortable lowercase)
- %tn -- track number (i.e 8)
- %tN -- track number, zero padded (i.e 08)
- %tt -- track title
- %tT -- track title (lowercase)
- %ta -- track artist
- %tA -- track artist (lowercase)
- %ts -- track artist (sortable)
- %tS -- track artist (sortable lowercase)
- %tc -- track composer
- %tC -- track composer (lowercase)
- %tp -- track composer (sortable)
- %tP -- track composer (sortable lowercase)
- %dn -- disc and track number, track zero padded (i.e Disk 2 - 06, or 06)
- %dN -- condensed disc and track number, zero padded (i.e d02t06, or 06)
- </long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/sound-juicer/paranoia</key>
- <applyto>/apps/sound-juicer/paranoia</applyto>
- <type>int</type>
- <owner>sound-juicer</owner>
- <default>8</default>
- <locale name="C">
- <short>The paranoia mode to use</short>
- <long>
- Paranoia mode: 0) disable 2) fragment 4) overlap 8) scratch 16) repair 255) full
- </long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/sound-juicer/strip-special</key>
- <applyto>/apps/sound-juicer/strip-special</applyto>
- <type>bool</type>
- <owner>sound-juicer</owner>
- <default>false</default>
- <locale name="C">
- <short>If to strip special characters from filenames</short>
- <long>
- If enabled, special characters such as space, wildcards and
- backslashes will be removed from the output filename.
- </long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/sound-juicer/musicbrainz_server</key>
- <applyto>/apps/sound-juicer/musicbrainz_server</applyto>
- <type>string</type>
- <owner>sound-juicer</owner>
- <!-- No default, NULL will use library default -->
- <locale name="C">
- <short>The MusicBrainz server to use</short>
- <long>
- If specified, this value will override the default MusicBrainz
- server.
- </long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/sound-juicer/audio_profile</key>
- <applyto>/apps/sound-juicer/audio_profile</applyto>
- <type>string</type>
- <owner>sound-juicer</owner>
- <default>cdlossy</default>
- <locale name="C">
- <short>(obsolete) Audio Profile with which to encode</short>
- <long>
- This key used to store the GNOME Audio Profile with which to encode.
- This has been superseded by GStreamer encoding profiles, which are
- configured using the audio_profile_media_type key.
- </long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/sound-juicer/audio_profile_media_type</key>
- <applyto>/apps/sound-juicer/audio_profile_media_type</applyto>
- <type>string</type>
- <owner>sound-juicer</owner>
- <default>audio/x-vorbis</default>
- <locale name="C">
- <short>Media type to encode to</short>
- <long>
- The GStreamer media type to encode to.
- </long>
- </locale>
- </schema>
-
-
- <schema>
- <key>/schemas/apps/sound-juicer/volume</key>
- <applyto>/apps/sound-juicer/volume</applyto>
- <type>float</type>
- <owner>sound-juicer</owner>
- <default>1.0</default>
- <locale name="C">
- <short>Audio volume</short>
- </locale>
- </schema>
-
- </schemalist>
-</gconfschemafile>
diff --git a/libjuicer/sj-metadata-musicbrainz5.c b/libjuicer/sj-metadata-musicbrainz5.c
index 86d906a..bd546e3 100644
--- a/libjuicer/sj-metadata-musicbrainz5.c
+++ b/libjuicer/sj-metadata-musicbrainz5.c
@@ -26,9 +26,9 @@
#include <string.h>
#include <stdlib.h>
+#include <gio/gio.h>
#include <glib.h>
#include <glib-object.h>
-#include <gconf/gconf-client.h>
#include <discid/discid.h>
#include <musicbrainz5/mb5_c.h>
@@ -50,13 +50,13 @@
#define discid_read_sparse(disc, dev, i) discid_read(disc, dev)
#endif
-#define GCONF_MUSICBRAINZ_SERVER "/apps/sound-juicer/musicbrainz_server"
-#define GCONF_PROXY_USE_PROXY "/system/http_proxy/use_http_proxy"
-#define GCONF_PROXY_HOST "/system/http_proxy/host"
-#define GCONF_PROXY_PORT "/system/http_proxy/port"
-#define GCONF_PROXY_USE_AUTHENTICATION "/system/http_proxy/use_authentication"
-#define GCONF_PROXY_USERNAME "/system/http_proxy/authentication_user"
-#define GCONF_PROXY_PASSWORD "/system/http_proxy/authentication_password"
+#define SJ_SETTINGS_PROXY_USE_PROXY "use_http_proxy"
+#define SJ_SETTINGS_PROXY_HOST "host"
+#define SJ_SETTINGS_PROXY_PORT "port"
+#define SJ_SETTINGS_PROXY_USE_AUTHENTICATION "use-authentication"
+#define SJ_SETTINGS_PROXY_USERNAME "authentication-user"
+#define SJ_SETTINGS_PROXY_PASSWORD "authentication-password"
+
#define SJ_MUSICBRAINZ_USER_AGENT "libjuicer-"VERSION
typedef struct {
@@ -657,52 +657,41 @@ metadata_interface_init (gpointer g_iface, gpointer iface_data)
static void
sj_metadata_musicbrainz5_init (SjMetadataMusicbrainz5 *self)
{
- GConfClient *gconf_client;
- gchar *server_name;
+ GSettings *settings;
SjMetadataMusicbrainz5Private *priv;
priv = GET_PRIVATE (self);
- gconf_client = gconf_client_get_default ();
-
- server_name = gconf_client_get_string (gconf_client, GCONF_MUSICBRAINZ_SERVER, NULL);
-
- if (server_name && (*server_name == '\0')) {
- g_free (server_name);
- server_name = NULL;
- }
-
- priv->mb = mb5_query_new (SJ_MUSICBRAINZ_USER_AGENT, server_name, 0);
- g_free (server_name);
-
+ settings = g_settings_new ("org.gnome.system.proxy.http");
/* Set the HTTP proxy */
- if (gconf_client_get_bool (gconf_client, GCONF_PROXY_USE_PROXY, NULL)) {
+ if (g_settings_get_boolean (settings, SJ_SETTINGS_PROXY_USE_PROXY)) {
char *proxy_host;
int port;
- proxy_host = gconf_client_get_string (gconf_client, GCONF_PROXY_HOST, NULL);
+ proxy_host = g_settings_get_string (settings, SJ_SETTINGS_PROXY_HOST);
mb5_query_set_proxyhost (priv->mb, proxy_host);
g_free (proxy_host);
- port = gconf_client_get_int (gconf_client, GCONF_PROXY_PORT, NULL);
+ port = g_settings_get_int (settings, SJ_SETTINGS_PROXY_PORT);
mb5_query_set_proxyport (priv->mb, port);
- if (gconf_client_get_bool (gconf_client, GCONF_PROXY_USE_AUTHENTICATION, NULL)) {
+ if (g_settings_get_boolean (settings, SJ_SETTINGS_PROXY_USE_AUTHENTICATION)) {
char *username, *password;
- username = gconf_client_get_string (gconf_client, GCONF_PROXY_USERNAME, NULL);
+ username = g_settings_get_string (settings, SJ_SETTINGS_PROXY_USERNAME);
mb5_query_set_proxyusername (priv->mb, username);
g_free (username);
- password = gconf_client_get_string (gconf_client, GCONF_PROXY_PASSWORD, NULL);
+ password = g_settings_get_string (settings, SJ_SETTINGS_PROXY_PASSWORD);
mb5_query_set_proxypassword (priv->mb, password);
g_free (password);
}
}
- g_object_unref (gconf_client);
+ g_object_unref (settings);
+ priv->mb = mb5_query_new (SJ_MUSICBRAINZ_USER_AGENT, NULL, 0);
}
static void
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 6f59d83..03926a3 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -2,7 +2,6 @@
# Please keep this file sorted alphabetically.
[encoding: UTF-8]
data/sound-juicer.desktop.in.in
-data/sound-juicer.schemas.in
[type: gettext/glade]data/sound-juicer.ui
[type: gettext/glade]data/sound-juicer-menu.ui
libjuicer/sj-error.c
@@ -13,7 +12,6 @@ libjuicer/sj-metadata-gvfs.c
libjuicer/sj-structures.c
libjuicer/sj-util.c
src/egg-play-preview.c
-src/gconf-bridge.c
src/sj-about.c
src/sj-extracting.c
src/sj-genres.c
diff --git a/sound-juicer.spec.in b/sound-juicer.spec.in
index 4c3e4ff..d2f7420 100644
--- a/sound-juicer.spec.in
+++ b/sound-juicer.spec.in
@@ -10,13 +10,11 @@ Requires: libmusicbrainz >= 2.0.1
Requires: libgnomeui >= 2.0.0
Requires: glib2 >= 2.0.0
Requires: gstreamer >= 0.8.0
-Requires: GConf2 >= 2.0.0
Requires: gstreamer-plugins-base >= 0.7.2
BuildRequires: libmusicbrainz-devel >= 2.0.1
BuildRequires: libgnomeui-devel >= 2.0.0
BuildRequires: glib2-devel >= 2.0.0
BuildRequires: gstreamer-devel >= 0.8.0
-BuildRequires: GConf2-devel >= 2.0.0
BuildRequires: scrollkeeper >= @SCROLLKEEPER_BUILD_REQUIRED@
%description
@@ -31,9 +29,7 @@ GStreamer-based CD ripping tool. Saves audio CDs to Ogg Vorbis or FLAC.
make
-export GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL=1;
%makeinstall
-unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL
# Clean out bad files
rm -rf $RPM_BUILD_ROOT%{_localstatedir}/scrollkeeper
@@ -45,19 +41,10 @@ rm -rf $RPM_BUILD_ROOT/usr/share/icons/hicolor/icon-theme.cache
%clean
[ -n "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != / ] && rm -rf $RPM_BUILD_ROOT
-%preun
-export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`
-gconftool-2 --makefile-uninstall-rule %{_sysconfdir}/gconf/schemas/sound-juicer.schemas > /dev/null
-
-%post
-export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`
-gconftool-2 --makefile-install-rule %{_sysconfdir}/gconf/schemas/sound-juicer.schemas > /dev/null
-
%files -f sound-juicer.lang
%defattr(-, root, root)
%doc AUTHORS COPYING ChangeLog INSTALL README NEWS
%{_bindir}/sound-juicer
-%{_sysconfdir}/gconf/schemas/sound-juicer.schemas
%{_datadir}/sound-juicer
%{_datadir}/applications/sound-juicer.desktop
%{_datadir}/icons/hicolor/16x16
diff --git a/src/Makefile.am b/src/Makefile.am
index dbb1734..37b2d9c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -16,8 +16,6 @@ sound_juicer_SOURCES = \
sj-inhibit.c \
sj-genres.h \
sj-genres.c \
- gconf-bridge.h \
- gconf-bridge.c \
egg-play-preview.c \
egg-play-preview.h
diff --git a/src/gconf-bridge.c b/src/gconf-bridge.c
deleted file mode 100644
index 25f192f..0000000
--- a/src/gconf-bridge.c
+++ /dev/null
@@ -1,1246 +0,0 @@
-/*
- * (C) 2005 OpenedHand Ltd.
- *
- * Author: Jorn Baayen <jorn@openedhand.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-
-#include <glib/gi18n-lib.h>
-#include <gtk/gtk.h>
-#include <string.h>
-
-#include "gconf-bridge.h"
-
-struct _GConfBridge {
- GConfClient *client;
-
- GHashTable *bindings;
-};
-
-/* The data structures for the different kinds of bindings */
-typedef enum {
- BINDING_PROP,
- BINDING_WINDOW,
- BINDING_LIST_STORE
-} BindingType;
-
-typedef struct {
- BindingType type;
- guint id;
-
- gboolean delayed_mode;
-
- char *key;
- guint val_notify_id;
- GSList *val_changes; /* List of changes made to GConf value,
- that have not received change notification
- yet. */
-
- GObject *object;
- GParamSpec *prop;
- gulong prop_notify_id;
-
- guint sync_timeout_id; /* Used in delayed mode */
-} PropBinding;
-
-typedef struct {
- BindingType type;
- guint id;
-
- gboolean bind_size;
- gboolean bind_pos;
-
- char *key_prefix;
-
- GtkWindow *window;
- gulong configure_event_id;
- gulong unmap_id;
- guint sync_timeout_id;
-} WindowBinding;
-
-typedef struct {
- BindingType type;
- guint id;
-
- char *key;
- guint val_notify_id;
- GSList *val_changes; /* List of changes made to GConf value,
- that have not received change notification
- yet. */
-
- GtkListStore *list_store;
- guint row_inserted_id;
- guint row_changed_id;
- guint row_deleted_id;
- guint rows_reordered_id;
-
- guint sync_idle_id;
-} ListStoreBinding;
-
-/* Some trickery to be able to treat the data structures generically */
-typedef union {
- BindingType type;
-
- PropBinding prop_binding;
- WindowBinding window_binding;
- ListStoreBinding list_store_binding;
-} Binding;
-
-/* Function prototypes */
-static void
-unbind (Binding *binding);
-
-#if !HAVE_DECL_GCONF_VALUE_COMPARE /* Not in headers in GConf < 2.13 */
-int gconf_value_compare (const GConfValue *value_a,
- const GConfValue *value_b);
-#endif
-
-static GConfBridge *bridge = NULL; /* Global GConfBridge object */
-
-/* Free up all resources allocated by the GConfBridge. Called on exit. */
-static void
-destroy_bridge (void)
-{
- g_hash_table_destroy (bridge->bindings);
- g_object_unref (bridge->client);
-
- g_free (bridge);
-}
-
-/**
- * gconf_bridge_get
- *
- * Returns the #GConfBridge. This is a singleton object.
- *
- * Return value: The #GConfBridge.
- **/
-GConfBridge *
-gconf_bridge_get (void)
-{
- if (bridge)
- return bridge;
-
- gconf_bridge_install_default_error_handler ();
-
- bridge = g_new (GConfBridge, 1);
-
- bridge->client = gconf_client_get_default ();
- bridge->bindings = g_hash_table_new_full (NULL, NULL, NULL,
- (GDestroyNotify) unbind);
-
- g_atexit (destroy_bridge);
-
- return bridge;
-}
-
-/**
- * gconf_bridge_get_client
- * @bridge: A #GConfBridge
- *
- * Returns the #GConfClient used by @bridge. This is the same #GConfClient
- * as returned by gconf_client_get_default().
- *
- * Return value: A #GConfClient.
- **/
-GConfClient *
-gconf_bridge_get_client (GConfBridge *bridge)
-{
- g_return_val_if_fail (bridge != NULL, NULL);
-
- return bridge->client;
-}
-
-/* Generate an ID for a new binding */
-static guint
-new_id (void)
-{
- static guint id_counter = 0;
-
- id_counter++;
-
- return id_counter;
-}
-
-/*
- * Property bindings
- */
-
-/* Syncs a value from GConf to an object property */
-static void
-prop_binding_sync_pref_to_prop (PropBinding *binding,
- GConfValue *pref_value)
-{
- GValue src_value, value;
-
- /* Make sure we don't enter an infinite synchronizing loop */
- g_signal_handler_block (binding->object, binding->prop_notify_id);
-
- memset (&src_value, 0, sizeof (GValue));
-
- /* First, convert GConfValue to GValue */
- switch (pref_value->type) {
- case GCONF_VALUE_STRING:
- g_value_init (&src_value, G_TYPE_STRING);
- g_value_set_string (&src_value,
- gconf_value_get_string (pref_value));
- break;
- case GCONF_VALUE_INT:
- g_value_init (&src_value, G_TYPE_INT);
- g_value_set_int (&src_value,
- gconf_value_get_int (pref_value));
- break;
- case GCONF_VALUE_BOOL:
- g_value_init (&src_value, G_TYPE_BOOLEAN);
- g_value_set_boolean (&src_value,
- gconf_value_get_bool (pref_value));
- break;
- case GCONF_VALUE_FLOAT:
- g_value_init (&src_value, G_TYPE_FLOAT);
- g_value_set_float (&src_value,
- gconf_value_get_float (pref_value));
- break;
- default:
- g_warning ("prop_binding_sync_pref_to_prop: Unhandled value "
- "type '%d'.\n", pref_value->type);
-
- return;
- }
-
- /* Then convert to the type expected by the object, if necessary */
- memset (&value, 0, sizeof (GValue));
- g_value_init (&value,
- G_PARAM_SPEC_VALUE_TYPE (binding->prop));
-
- if (src_value.g_type != value.g_type) {
- if (!g_value_transform (&src_value, &value)) {
- g_warning ("prop_binding_sync_pref_to_prop: Failed to "
- "transform a \"%s\" to a \"%s\".",
- g_type_name (src_value.g_type),
- g_type_name (value.g_type));
-
- goto done;
- }
-
- g_object_set_property (binding->object,
- binding->prop->name, &value);
- } else {
- g_object_set_property (binding->object,
- binding->prop->name, &src_value);
- }
-
-done:
- g_value_unset (&src_value);
- g_value_unset (&value);
-
- g_signal_handler_unblock (binding->object, binding->prop_notify_id);
-}
-
-/* Syncs an object property to GConf */
-static void
-prop_binding_sync_prop_to_pref (PropBinding *binding)
-{
- GValue value;
- GConfValue *gconf_value;
-
- memset (&value, 0, sizeof (GValue));
-
- g_value_init (&value,
- G_PARAM_SPEC_VALUE_TYPE (binding->prop));
- g_object_get_property (binding->object,
- binding->prop->name,
- &value);
-
- switch (value.g_type) {
- case G_TYPE_STRING:
- gconf_value = gconf_value_new (GCONF_VALUE_STRING);
- gconf_value_set_string (gconf_value,
- g_value_get_string (&value));
- break;
- case G_TYPE_INT:
- gconf_value = gconf_value_new (GCONF_VALUE_INT);
- gconf_value_set_int (gconf_value,
- g_value_get_int (&value));
- break;
- case G_TYPE_UINT:
- gconf_value = gconf_value_new (GCONF_VALUE_INT);
- gconf_value_set_int (gconf_value,
- g_value_get_uint (&value));
- break;
- case G_TYPE_LONG:
- gconf_value = gconf_value_new (GCONF_VALUE_INT);
- gconf_value_set_int (gconf_value,
- g_value_get_long (&value));
- break;
- case G_TYPE_ULONG:
- gconf_value = gconf_value_new (GCONF_VALUE_INT);
- gconf_value_set_int (gconf_value,
- g_value_get_ulong (&value));
- break;
- case G_TYPE_INT64:
- gconf_value = gconf_value_new (GCONF_VALUE_INT);
- gconf_value_set_int (gconf_value,
- g_value_get_int64 (&value));
- break;
- case G_TYPE_UINT64:
- gconf_value = gconf_value_new (GCONF_VALUE_INT);
- gconf_value_set_int (gconf_value,
- g_value_get_uint64 (&value));
- break;
- case G_TYPE_CHAR:
- gconf_value = gconf_value_new (GCONF_VALUE_INT);
- gconf_value_set_int (gconf_value,
- g_value_get_char (&value));
- break;
- case G_TYPE_UCHAR:
- gconf_value = gconf_value_new (GCONF_VALUE_INT);
- gconf_value_set_int (gconf_value,
- g_value_get_uchar (&value));
- break;
- case G_TYPE_ENUM:
- gconf_value = gconf_value_new (GCONF_VALUE_INT);
- gconf_value_set_int (gconf_value,
- g_value_get_enum (&value));
- break;
- case G_TYPE_BOOLEAN:
- gconf_value = gconf_value_new (GCONF_VALUE_BOOL);
- gconf_value_set_bool (gconf_value,
- g_value_get_boolean (&value));
- break;
- case G_TYPE_DOUBLE:
- gconf_value = gconf_value_new (GCONF_VALUE_FLOAT);
-#ifdef HAVE_CORBA_GCONF
- /* FIXME we cast to a float explicitly as CORBA GConf
- * uses doubles in its API, but treats them as floats
- * when transporting them over CORBA. See #322837 */
- gconf_value_set_float (gconf_value,
- (float) g_value_get_double (&value));
-#else
- gconf_value_set_float (gconf_value,
- g_value_get_double (&value));
-#endif
- break;
- case G_TYPE_FLOAT:
- gconf_value = gconf_value_new (GCONF_VALUE_FLOAT);
- gconf_value_set_float (gconf_value,
- g_value_get_float (&value));
- break;
- default:
- if (g_type_is_a (value.g_type, G_TYPE_ENUM)) {
- gconf_value = gconf_value_new (GCONF_VALUE_INT);
- gconf_value_set_int (gconf_value,
- g_value_get_enum (&value));
- } else {
- g_warning ("prop_binding_sync_prop_to_pref: "
- "Unhandled value type '%s'.\n",
- g_type_name (value.g_type));
-
- goto done;
- }
-
- break;
- }
-
- /* Set to GConf */
- gconf_client_set (bridge->client, binding->key, gconf_value, NULL);
-
- /* Store until change notification comes in, so that we are able
- * to ignore it */
- binding->val_changes = g_slist_append (binding->val_changes,
- gconf_value);
-
-done:
- g_value_unset (&value);
-}
-
-/* Called when a GConf value bound to an object property has changed */
-static void
-prop_binding_pref_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
-{
- GConfValue *gconf_value;
- PropBinding *binding;
- GSList *l;
-
- gconf_value = gconf_entry_get_value (entry);
- if (!gconf_value)
- return; /* NULL means that the value has been unset */
-
- binding = (PropBinding *) user_data;
-
- /* Check that this notification is not caused by sync_prop_to_pref() */
- l = g_slist_find_custom (binding->val_changes,
- gconf_value,
- (GCompareFunc) gconf_value_compare);
- if (l) {
- gconf_value_free (l->data);
-
- binding->val_changes = g_slist_delete_link
- (binding->val_changes, l);
-
- return;
- }
-
- prop_binding_sync_pref_to_prop (binding, gconf_value);
-}
-
-/* Performs a scheduled prop-to-pref sync for a prop binding in
- * delay mode */
-static gboolean
-prop_binding_perform_scheduled_sync (PropBinding *binding)
-{
- prop_binding_sync_prop_to_pref (binding);
-
- binding->sync_timeout_id = 0;
-
- g_object_unref (binding->object);
-
- return FALSE;
-}
-
-#define PROP_BINDING_SYNC_DELAY 100 /* Delay for bindings with "delayed"
- set to TRUE, in ms */
-
-/* Called when an object property has changed */
-static void
-prop_binding_prop_changed (GObject *object,
- GParamSpec *param_spec,
- PropBinding *binding)
-{
- if (binding->delayed_mode) {
- /* Just schedule a sync */
- if (binding->sync_timeout_id == 0) {
- /* We keep a reference on the object as long as
- * we haven't synced yet to make sure we don't
- * lose any data */
- g_object_ref (binding->object);
-
- binding->sync_timeout_id =
- g_timeout_add
- (PROP_BINDING_SYNC_DELAY,
- (GSourceFunc)
- prop_binding_perform_scheduled_sync,
- binding);
- }
- } else {
- /* Directly sync */
- prop_binding_sync_prop_to_pref (binding);
- }
-}
-
-/* Called when an object is destroyed */
-static void
-prop_binding_object_destroyed (gpointer user_data,
- GObject *where_the_object_was)
-{
- PropBinding *binding;
-
- binding = (PropBinding *) user_data;
- binding->object = NULL; /* Don't do anything with the object
- at unbind() */
-
- g_hash_table_remove (bridge->bindings,
- GUINT_TO_POINTER (binding->id));
-}
-
-/**
- * gconf_bridge_bind_property_full
- * @bridge: A #GConfBridge
- * @key: A GConf key to be bound
- * @object: A #GObject
- * @prop: The property of @object to be bound
- * @delayed_sync: TRUE if there should be a delay between property changes
- * and syncs to GConf. Set to TRUE when binding to a rapidly-changing
- * property, for example the "value" property on a #GtkAdjustment.
- *
- * Binds @key to @prop, causing them to have the same value at all times.
- *
- * The types of @key and @prop should be compatible. Floats and doubles, and
- * ints, uints, longs, unlongs, int64s, uint64s, chars, uchars and enums
- * can be matched up. Booleans and strings can only be matched to their
- * respective types.
- *
- * On calling this function the current value of @key will be set to @prop.
- *
- * Return value: The ID of the new binding.
- **/
-guint
-gconf_bridge_bind_property_full (GConfBridge *bridge,
- const char *key,
- GObject *object,
- const char *prop,
- gboolean delayed_sync)
-{
- GParamSpec *pspec;
- PropBinding *binding;
- char *signal;
- GConfValue *val;
-
- g_return_val_if_fail (bridge != NULL, 0);
- g_return_val_if_fail (key != NULL, 0);
- g_return_val_if_fail (G_IS_OBJECT (object), 0);
- g_return_val_if_fail (prop != NULL, 0);
-
- /* First, try to fetch the propertys GParamSpec off the object */
- pspec = g_object_class_find_property
- (G_OBJECT_GET_CLASS (object), prop);
- if (G_UNLIKELY (pspec == NULL)) {
- g_warning ("gconf_bridge_bind_property_full: A property \"%s\" "
- "was not found. Please make sure you are passing "
- "the right property name.", prop);
-
- return 0;
- }
-
- /* GParamSpec found: All good, create new binding. */
- binding = g_new (PropBinding, 1);
-
- binding->type = BINDING_PROP;
- binding->id = new_id ();
- binding->delayed_mode = delayed_sync;
- binding->val_changes = NULL;
- binding->key = g_strdup (key);
- binding->object = object;
- binding->prop = pspec;
- binding->sync_timeout_id = 0;
-
- /* Watch GConf key */
- binding->val_notify_id =
- gconf_client_notify_add (bridge->client, key,
- prop_binding_pref_changed,
- binding, NULL, NULL);
-
- /* Connect to property change notifications */
- signal = g_strconcat ("notify::", prop, NULL);
- binding->prop_notify_id =
- g_signal_connect (object, signal,
- G_CALLBACK (prop_binding_prop_changed),
- binding);
- g_free (signal);
-
- /* Sync object to value from GConf, if set */
- val = gconf_client_get (bridge->client, key, NULL);
- if (val) {
- prop_binding_sync_pref_to_prop (binding, val);
- gconf_value_free (val);
- }
-
- /* Handle case where watched object gets destroyed */
- g_object_weak_ref (object,
- prop_binding_object_destroyed, binding);
-
- /* Insert binding */
- g_hash_table_insert (bridge->bindings,
- GUINT_TO_POINTER (binding->id), binding);
-
- /* Done */
- return binding->id;
-}
-
-/* Unbinds a property binding */
-static void
-prop_binding_unbind (PropBinding *binding)
-{
- if (binding->delayed_mode && binding->sync_timeout_id > 0) {
- /* Perform any scheduled syncs */
- g_source_remove (binding->sync_timeout_id);
-
- /* The object will still be around as we have
- * a reference */
- prop_binding_perform_scheduled_sync (binding);
- }
-
- gconf_client_notify_remove (bridge->client,
- binding->val_notify_id);
- g_free (binding->key);
-
- while (binding->val_changes) {
- gconf_value_free (binding->val_changes->data);
-
- binding->val_changes = g_slist_delete_link
- (binding->val_changes, binding->val_changes);
- }
-
- /* The object might have been destroyed .. */
- if (binding->object) {
- g_signal_handler_disconnect (binding->object,
- binding->prop_notify_id);
-
- g_object_weak_unref (binding->object,
- prop_binding_object_destroyed, binding);
- }
-}
-
-/*
- * Window bindings
- */
-
-/* Performs a scheduled dimensions-to-prefs sync for a window binding */
-static gboolean
-window_binding_perform_scheduled_sync (WindowBinding *binding)
-{
- if (binding->bind_size) {
- int width, height;
- char *key;
- GdkWindowState state;
-
- state = gdk_window_get_state (gtk_widget_get_window (GTK_WIDGET (binding->window)));
-
- if (state & GDK_WINDOW_STATE_MAXIMIZED) {
- key = g_strconcat (binding->key_prefix, "_maximized", NULL);
- gconf_client_set_bool (bridge->client, key, TRUE, NULL);
- g_free (key);
- } else {
- gtk_window_get_size (binding->window, &width, &height);
-
- key = g_strconcat (binding->key_prefix, "_width", NULL);
- gconf_client_set_int (bridge->client, key, width, NULL);
- g_free (key);
-
- key = g_strconcat (binding->key_prefix, "_height", NULL);
- gconf_client_set_int (bridge->client, key, height, NULL);
- g_free (key);
-
- key = g_strconcat (binding->key_prefix, "_maximized", NULL);
- gconf_client_set_bool (bridge->client, key, FALSE, NULL);
- g_free (key);
- }
- }
-
- if (binding->bind_pos) {
- int x, y;
- char *key;
-
- gtk_window_get_position (binding->window, &x, &y);
-
- key = g_strconcat (binding->key_prefix, "_x", NULL);
- gconf_client_set_int (bridge->client, key, x, NULL);
- g_free (key);
-
- key = g_strconcat (binding->key_prefix, "_y", NULL);
- gconf_client_set_int (bridge->client, key, y, NULL);
- g_free (key);
- }
-
- binding->sync_timeout_id = 0;
-
- return FALSE;
-}
-
-#define WINDOW_BINDING_SYNC_DELAY 1000 /* Delay before syncing new window
- dimensions to GConf, in ms */
-
-/* Called when the window han been resized or moved */
-static gboolean
-window_binding_configure_event_cb (GtkWindow *window,
- GdkEventConfigure *event,
- WindowBinding *binding)
-{
- /* Schedule a sync */
- if (binding->sync_timeout_id == 0) {
- binding->sync_timeout_id =
- g_timeout_add (WINDOW_BINDING_SYNC_DELAY,
- (GSourceFunc)
- window_binding_perform_scheduled_sync,
- binding);
- }
-
- return FALSE;
-}
-
-/* Called when the window state is being changed */
-static gboolean
-window_binding_state_event_cb (GtkWindow *window,
- GdkEventWindowState *event,
- WindowBinding *binding)
-{
- window_binding_perform_scheduled_sync (binding);
-
- return FALSE;
-}
-
-/* Called when the window is being unmapped */
-static gboolean
-window_binding_unmap_cb (GtkWindow *window,
- WindowBinding *binding)
-{
- /* Force sync */
- if (binding->sync_timeout_id > 0)
- g_source_remove (binding->sync_timeout_id);
-
- window_binding_perform_scheduled_sync (binding);
-
- return FALSE;
-}
-
-/* Called when a window is destroyed */
-static void
-window_binding_window_destroyed (gpointer user_data,
- GObject *where_the_object_was)
-{
- WindowBinding *binding;
-
- binding = (WindowBinding *) user_data;
- binding->window = NULL; /* Don't do anything with the window
- at unbind() */
-
- g_hash_table_remove (bridge->bindings,
- GUINT_TO_POINTER (binding->id));
-}
-
-/**
- * gconf_bridge_bind_window
- * @bridge: A #GConfBridge
- * @key_prefix: The prefix of the GConf keys
- * @window: A #GtkWindow
- * @bind_size: TRUE to bind the size of @window
- * @bind_pos: TRUE to bind the position of @window
- *
- * On calling this function @window will be resized to the values
- * specified by "@key_prefix<!-- -->_width" and "@key_prefix<!-- -->_height"
- * and maximixed if "@key_prefix<!-- -->_maximized is TRUE if
- * @bind_size is TRUE, and moved to the values specified by
- * "@key_prefix<!-- -->_x" and "@key_prefix<!-- -->_y" if @bind_pos is TRUE.
- * The respective GConf values will be updated when the window is resized
- * and/or moved.
- *
- * Return value: The ID of the new binding.
- **/
-guint
-gconf_bridge_bind_window (GConfBridge *bridge,
- const char *key_prefix,
- GtkWindow *window,
- gboolean bind_size,
- gboolean bind_pos)
-{
- WindowBinding *binding;
-
- g_return_val_if_fail (bridge != NULL, 0);
- g_return_val_if_fail (key_prefix != NULL, 0);
- g_return_val_if_fail (GTK_IS_WINDOW (window), 0);
-
- /* Create new binding. */
- binding = g_new (WindowBinding, 1);
-
- binding->type = BINDING_WINDOW;
- binding->id = new_id ();
- binding->bind_size = bind_size;
- binding->bind_pos = bind_pos;
- binding->key_prefix = g_strdup (key_prefix);
- binding->window = window;
- binding->sync_timeout_id = 0;
-
- /* Set up GConf keys & sync window to GConf values */
- if (bind_size) {
- char *key;
- GConfValue *width_val, *height_val, *maximized_val;
-
- key = g_strconcat (key_prefix, "_width", NULL);
- width_val = gconf_client_get (bridge->client, key, NULL);
- g_free (key);
-
- key = g_strconcat (key_prefix, "_height", NULL);
- height_val = gconf_client_get (bridge->client, key, NULL);
- g_free (key);
-
- key = g_strconcat (key_prefix, "_maximized", NULL);
- maximized_val = gconf_client_get (bridge->client, key, NULL);
- g_free (key);
-
- if (width_val && height_val) {
- gtk_window_resize (window,
- gconf_value_get_int (width_val),
- gconf_value_get_int (height_val));
-
- gconf_value_free (width_val);
- gconf_value_free (height_val);
- } else if (width_val) {
- gconf_value_free (width_val);
- } else if (height_val) {
- gconf_value_free (height_val);
- }
-
- if (maximized_val) {
- if (gconf_value_get_bool (maximized_val)) {
- gtk_window_maximize (window);
- }
- gconf_value_free (maximized_val);
- }
- }
-
- if (bind_pos) {
- char *key;
- GConfValue *x_val, *y_val;
-
- key = g_strconcat (key_prefix, "_x", NULL);
- x_val = gconf_client_get (bridge->client, key, NULL);
- g_free (key);
-
- key = g_strconcat (key_prefix, "_y", NULL);
- y_val = gconf_client_get (bridge->client, key, NULL);
- g_free (key);
-
- if (x_val && y_val) {
- gtk_window_move (window,
- gconf_value_get_int (x_val),
- gconf_value_get_int (y_val));
-
- gconf_value_free (x_val);
- gconf_value_free (y_val);
- } else if (x_val) {
- gconf_value_free (x_val);
- } else if (y_val) {
- gconf_value_free (y_val);
- }
- }
-
- /* Connect to window size change notifications */
- binding->configure_event_id =
- g_signal_connect (window,
- "configure-event",
- G_CALLBACK
- (window_binding_configure_event_cb),
- binding);
-
- binding->configure_event_id =
- g_signal_connect (window,
- "window_state_event",
- G_CALLBACK
- (window_binding_state_event_cb),
- binding);
- binding->unmap_id =
- g_signal_connect (window,
- "unmap",
- G_CALLBACK (window_binding_unmap_cb),
- binding);
-
- /* Handle case where window gets destroyed */
- g_object_weak_ref (G_OBJECT (window),
- window_binding_window_destroyed, binding);
-
- /* Insert binding */
- g_hash_table_insert (bridge->bindings,
- GUINT_TO_POINTER (binding->id), binding);
-
- /* Done */
- return binding->id;
-}
-
-/* Unbinds a window binding */
-static void
-window_binding_unbind (WindowBinding *binding)
-{
- if (binding->sync_timeout_id > 0)
- g_source_remove (binding->sync_timeout_id);
-
- g_free (binding->key_prefix);
-
- /* The window might have been destroyed .. */
- if (binding->window) {
- g_signal_handler_disconnect (binding->window,
- binding->configure_event_id);
- g_signal_handler_disconnect (binding->window,
- binding->unmap_id);
-
- g_object_weak_unref (G_OBJECT (binding->window),
- window_binding_window_destroyed, binding);
- }
-}
-
-/*
- * List store bindings
- */
-
-/* Fills a GtkListStore with the string list from @value */
-static void
-list_store_binding_sync_pref_to_store (ListStoreBinding *binding,
- GConfValue *value)
-{
- GSList *list, *l;
- GtkTreeIter iter;
-
- /* Make sure we don't enter an infinite synchronizing loop */
- g_signal_handler_block (binding->list_store,
- binding->row_inserted_id);
- g_signal_handler_block (binding->list_store,
- binding->row_deleted_id);
-
- gtk_list_store_clear (binding->list_store);
-
- list = gconf_value_get_list (value);
- for (l = list; l; l = l->next) {
- GConfValue *l_value;
- const char *string;
-
- l_value = (GConfValue *) l->data;
- string = gconf_value_get_string (l_value);
-
- gtk_list_store_insert_with_values (binding->list_store,
- &iter, -1,
- 0, string,
- -1);
- }
-
- g_signal_handler_unblock (binding->list_store,
- binding->row_inserted_id);
- g_signal_handler_unblock (binding->list_store,
- binding->row_deleted_id);
-}
-
-/* Sets a GConf value to the contents of a GtkListStore */
-static gboolean
-list_store_binding_sync_store_to_pref (ListStoreBinding *binding)
-{
- GtkTreeModel *tree_model;
- GtkTreeIter iter;
- GSList *list;
- int res;
- GConfValue *gconf_value;
-
- tree_model = GTK_TREE_MODEL (binding->list_store);
-
- /* Build list */
- list = NULL;
- res = gtk_tree_model_get_iter_first (tree_model, &iter);
- while (res) {
- char *string;
- GConfValue *tmp_value;
-
- gtk_tree_model_get (tree_model, &iter,
- 0, &string, -1);
-
- tmp_value = gconf_value_new (GCONF_VALUE_STRING);
- gconf_value_set_string (tmp_value, string);
-
- list = g_slist_append (list, tmp_value);
-
- res = gtk_tree_model_iter_next (tree_model, &iter);
- }
-
- /* Create value */
- gconf_value = gconf_value_new (GCONF_VALUE_LIST);
- gconf_value_set_list_type (gconf_value, GCONF_VALUE_STRING);
- gconf_value_set_list_nocopy (gconf_value, list);
-
- /* Set */
- gconf_client_set (bridge->client, binding->key, gconf_value, NULL);
-
- /* Store until change notification comes in, so that we are able
- * to ignore it */
- binding->val_changes = g_slist_append (binding->val_changes,
- gconf_value);
-
- binding->sync_idle_id = 0;
-
- g_object_unref (binding->list_store);
-
- return FALSE;
-}
-
-/* Pref changed: sync */
-static void
-list_store_binding_pref_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
-{
- GConfValue *gconf_value;
- ListStoreBinding *binding;
- GSList *l;
-
- gconf_value = gconf_entry_get_value (entry);
- if (!gconf_value)
- return; /* NULL means that the value has been unset */
-
- binding = (ListStoreBinding *) user_data;
-
- /* Check that this notification is not caused by
- * sync_store_to_pref() */
- l = g_slist_find_custom (binding->val_changes,
- gconf_value,
- (GCompareFunc) gconf_value_compare);
- if (l) {
- gconf_value_free (l->data);
-
- binding->val_changes = g_slist_delete_link
- (binding->val_changes, l);
-
- return;
- }
-
- list_store_binding_sync_pref_to_store (binding, gconf_value);
-}
-
-/* Called when an object is destroyed */
-static void
-list_store_binding_store_destroyed (gpointer user_data,
- GObject *where_the_object_was)
-{
- ListStoreBinding *binding;
-
- binding = (ListStoreBinding *) user_data;
- binding->list_store = NULL; /* Don't do anything with the store
- at unbind() */
-
- g_hash_table_remove (bridge->bindings,
- GUINT_TO_POINTER (binding->id));
-}
-
-/* List store changed: Sync */
-static void
-list_store_binding_store_changed_cb (ListStoreBinding *binding)
-{
- if (binding->sync_idle_id == 0) {
- g_object_ref (binding->list_store);
-
- binding->sync_idle_id = g_idle_add
- ((GSourceFunc) list_store_binding_sync_store_to_pref,
- binding);
- }
-}
-
-/**
- * gconf_bridge_bind_string_list_store
- * @bridge: A #GConfBridge
- * @key: A GConf key to be bound
- * @list_store: A #GtkListStore
- *
- * On calling this function single string column #GtkListStore @list_store
- * will be kept synchronized with the GConf string list value pointed to by
- * @key. On calling this function @list_store will be populated with the
- * strings specified by the value of @key.
- *
- * Return value: The ID of the new binding.
- **/
-guint
-gconf_bridge_bind_string_list_store (GConfBridge *bridge,
- const char *key,
- GtkListStore *list_store)
-{
- GtkTreeModel *tree_model;
- gboolean have_one_column, is_string_column;
- ListStoreBinding *binding;
- GConfValue *val;
-
- g_return_val_if_fail (bridge != NULL, 0);
- g_return_val_if_fail (key != NULL, 0);
- g_return_val_if_fail (GTK_IS_LIST_STORE (list_store), 0);
-
- /* Check list store suitability */
- tree_model = GTK_TREE_MODEL (list_store);
- have_one_column = (gtk_tree_model_get_n_columns (tree_model) == 1);
- is_string_column = (gtk_tree_model_get_column_type
- (tree_model, 0) == G_TYPE_STRING);
- if (G_UNLIKELY (!have_one_column || !is_string_column)) {
- g_warning ("gconf_bridge_bind_string_list_store: Only "
- "GtkListStores with exactly one string column are "
- "supported.");
-
- return 0;
- }
-
- /* Create new binding. */
- binding = g_new (ListStoreBinding, 1);
-
- binding->type = BINDING_LIST_STORE;
- binding->id = new_id ();
- binding->key = g_strdup (key);
- binding->val_changes = NULL;
- binding->list_store = list_store;
- binding->sync_idle_id = 0;
-
- /* Watch GConf key */
- binding->val_notify_id =
- gconf_client_notify_add (bridge->client, key,
- list_store_binding_pref_changed,
- binding, NULL, NULL);
-
- /* Connect to ListStore change notifications */
- binding->row_inserted_id =
- g_signal_connect_swapped (list_store, "row-inserted",
- G_CALLBACK
- (list_store_binding_store_changed_cb),
- binding);
- binding->row_changed_id =
- g_signal_connect_swapped (list_store, "row-inserted",
- G_CALLBACK
- (list_store_binding_store_changed_cb),
- binding);
- binding->row_deleted_id =
- g_signal_connect_swapped (list_store, "row-inserted",
- G_CALLBACK
- (list_store_binding_store_changed_cb),
- binding);
- binding->rows_reordered_id =
- g_signal_connect_swapped (list_store, "row-inserted",
- G_CALLBACK
- (list_store_binding_store_changed_cb),
- binding);
-
- /* Sync object to value from GConf, if set */
- val = gconf_client_get (bridge->client, key, NULL);
- if (val) {
- list_store_binding_sync_pref_to_store (binding, val);
- gconf_value_free (val);
- }
-
- /* Handle case where watched object gets destroyed */
- g_object_weak_ref (G_OBJECT (list_store),
- list_store_binding_store_destroyed, binding);
-
- /* Insert binding */
- g_hash_table_insert (bridge->bindings,
- GUINT_TO_POINTER (binding->id), binding);
-
- /* Done */
- return binding->id;
-}
-
-/* Unbinds a list store binding */
-static void
-list_store_binding_unbind (ListStoreBinding *binding)
-{
- /* Perform any scheduled syncs */
- if (binding->sync_idle_id > 0) {
- g_source_remove (binding->sync_idle_id);
-
- /* The store will still be around as we added a reference */
- list_store_binding_sync_store_to_pref (binding);
- }
-
- g_free (binding->key);
-
- while (binding->val_changes) {
- gconf_value_free (binding->val_changes->data);
-
- binding->val_changes = g_slist_delete_link
- (binding->val_changes, binding->val_changes);
- }
-
- /* The store might have been destroyed .. */
- if (binding->list_store) {
- g_signal_handler_disconnect (binding->list_store,
- binding->row_inserted_id);
- g_signal_handler_disconnect (binding->list_store,
- binding->row_changed_id);
- g_signal_handler_disconnect (binding->list_store,
- binding->row_deleted_id);
- g_signal_handler_disconnect (binding->list_store,
- binding->rows_reordered_id);
-
- g_object_weak_unref (G_OBJECT (binding->list_store),
- list_store_binding_store_destroyed,
- binding);
- }
-}
-
-/*
- * Generic unbinding
- */
-
-/* Unbinds a binding */
-static void
-unbind (Binding *binding)
-{
- /* Call specialized unbinding function */
- switch (binding->type) {
- case BINDING_PROP:
- prop_binding_unbind ((PropBinding *) binding);
- break;
- case BINDING_WINDOW:
- window_binding_unbind ((WindowBinding *) binding);
- break;
- case BINDING_LIST_STORE:
- list_store_binding_unbind ((ListStoreBinding *) binding);
- break;
- default:
- g_warning ("Unknown binding type '%d'\n", binding->type);
- break;
- }
-
- g_free (binding);
-}
-
-/**
- * gconf_bridge_unbind
- * @bridge: A #GConfBridge
- * @binding_id: The ID of the binding to be removed
- *
- * Removes the binding with ID @binding_id.
- **/
-void
-gconf_bridge_unbind (GConfBridge *bridge,
- guint binding_id)
-{
- g_return_if_fail (bridge != NULL);
- g_return_if_fail (binding_id > 0);
-
- /* This will trigger the hash tables value destruction
- * function, which will take care of further cleanup */
- g_hash_table_remove (bridge->bindings,
- GUINT_TO_POINTER (binding_id));
-}
-
-/*
- * Error handling
- */
-
-/* This is the same dialog as used in eel */
-static void
-error_handler (GConfClient *client,
- GError *error)
-{
- static gboolean shown_dialog = FALSE;
-
- g_warning ("GConf error:\n %s", error->message);
-
- if (!shown_dialog) {
- GtkWidget *dlg;
-
- dlg = gtk_message_dialog_new (NULL, 0,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_OK,
- _("GConf error: %s"),
- error->message);
-
- gtk_message_dialog_format_secondary_text
- (GTK_MESSAGE_DIALOG (dlg),
- _("All further errors shown only on terminal."));
- gtk_window_set_title (GTK_WINDOW (dlg), "");
-
- gtk_dialog_run (GTK_DIALOG (dlg));
-
- gtk_widget_destroy (dlg);
-
- shown_dialog = TRUE;
- }
-}
-
-/**
- * gconf_bridge_install_default_error_handler
- *
- * Sets up the default error handler. Any unhandled GConf errors will
- * automatically be handled by presenting the user an error dialog.
- **/
-void
-gconf_bridge_install_default_error_handler (void)
-{
- gconf_client_set_global_default_error_handler (error_handler);
-}
diff --git a/src/gconf-bridge.h b/src/gconf-bridge.h
deleted file mode 100644
index 7edd247..0000000
--- a/src/gconf-bridge.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * (C) 2005 OpenedHand Ltd.
- *
- * Author: Jorn Baayen <jorn@openedhand.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __GCONF_BRIDGE_H__
-#define __GCONF_BRIDGE_H__
-
-#include <gconf/gconf-client.h>
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-void gconf_bridge_install_default_error_handler (void);
-
-typedef struct _GConfBridge GConfBridge;
-
-GConfBridge *gconf_bridge_get (void);
-
-GConfClient *gconf_bridge_get_client (GConfBridge *bridge);
-
-guint gconf_bridge_bind_property_full (GConfBridge *bridge,
- const char *key,
- GObject *object,
- const char *prop,
- gboolean delayed_sync);
-
-/**
- * gconf_bridge_bind_property
- * @bridge: A #GConfBridge
- * @key: A GConf key to be bound
- * @object: A #GObject
- * @prop: The property of @object to be bound
- *
- * Binds @key to @prop without delays, causing them to have the same value at all times. See
- * #gconf_bridge_bind_property_full for more details.
- *
- **/
-#define gconf_bridge_bind_property(bridge, key, object, prop) \
- gconf_bridge_bind_property_full ((bridge), (key), \
- (object), (prop), FALSE)
-
-/**
- * gconf_bridge_bind_property_delayed
- * @bridge: A #GConfBridge
- * @key: A GConf key to be bound
- * @object: A #GObject
- * @prop: The property of @object to be bound
- *
- * Binds @key to @prop with a delay, causing them to have the same value at all
- * times. See #gconf_bridge_bind_property_full for more details.
- **/
-#define gconf_bridge_bind_property_delayed(bridge, key, object, prop) \
- gconf_bridge_bind_property_full ((bridge), (key), \
- (object), (prop), TRUE)
-
-guint gconf_bridge_bind_window (GConfBridge *bridge,
- const char *key_prefix,
- GtkWindow *window,
- gboolean bind_size,
- gboolean bind_pos);
-
-/**
- * gconf_bridge_bind_window_size
- * @bridge: A #GConfBridge
- * @key_prefix: The prefix of the GConf keys
- * @window: A #GtkWindow
- *
- * On calling this function @window will be resized to the values specified by
- * "@key_prefix<!-- -->_width" and "@key_prefix<!-- -->_height". The respective
- * GConf values will be updated when the window is resized. See
- * #gconf_bridge_bind_window for more details.
- **/
-#define gconf_bridge_bind_window_size(bridge, key_prefix, window) \
- gconf_bridge_bind_window ((bridge), (key_prefix), (window), TRUE, FALSE)
-
-/**
- * gconf_bridge_bind_window_pos
- * @bridge: A #GConfBridge
- * @key_prefix: The prefix of the GConf keys
- * @window: A #GtkWindow
- *
- * On calling this function @window will be moved to the values specified by
- * "@key_prefix<!-- -->_x" and "@key_prefix<!-- -->_y". The respective GConf
- * values will be updated when the window is moved. See
- * #gconf_bridge_bind_window for more details.
- **/
-#define gconf_bridge_bind_window_pos(bridge, key_prefix, window) \
- gconf_bridge_bind_window ((bridge), (key_prefix), (window), FALSE, TRUE)
-
-guint gconf_bridge_bind_string_list_store (GConfBridge *bridge,
- const char *key,
- GtkListStore *list_store);
-
-void gconf_bridge_unbind (GConfBridge *bridge,
- guint binding_id);
-
-G_END_DECLS
-
-#endif /* __GCONF_BRIDGE_H__ */
diff --git a/src/sj-main.c b/src/sj-main.c
index ea5016e..33df6f8 100644
--- a/src/sj-main.c
+++ b/src/sj-main.c
@@ -35,13 +35,11 @@
#include <gdk/gdkkeysyms.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
-#include <gconf/gconf-client.h>
#include <brasero-medium-selection.h>
#include <brasero-volume.h>
#include <gst/gst.h>
#include <gst/pbutils/encoding-profile.h>
-#include "gconf-bridge.h"
#include "rb-gst-media-types.h"
#include "sj-about.h"
#include "sj-metadata.h"
@@ -71,7 +69,8 @@ GtkBuilder *builder;
SjMetadataGetter *metadata;
SjExtractor *extractor;
-GConfClient *gconf_client;
+GSettings *sj_settings;
+GSettings *http_settings;
GtkWidget *main_window;
static GtkWidget *message_area_eventbox;
@@ -1070,128 +1069,96 @@ AlbumDetails* multiple_album_dialog(GList *albums)
}
/**
- * The GConf key for the base path changed
+ * The GSettings key for the base path changed
*/
-static void baseuri_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
+static void baseuri_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
{
- g_assert (strcmp (entry->key, GCONF_BASEURI) == 0);
+ gchar *value;
+ g_assert (strcmp (key, SJ_SETTINGS_BASEURI) == 0);
if (base_uri) {
g_object_unref (base_uri);
}
- if (entry->value == NULL) {
+ value = g_settings_get_string (settings, key);
+ if (sj_str_is_empty (value)) {
base_uri = sj_get_default_music_directory ();
} else {
- base_uri = g_file_new_for_uri (gconf_value_get_string (entry->value));
+ base_uri = g_file_new_for_uri (value);
}
+ g_free (value);
/* TODO: sanity check the URI somewhat */
}
/**
- * The GConf key for the directory pattern changed
+ * The GSettings key for the directory pattern changed
*/
-static void path_pattern_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
+static void path_pattern_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
{
- g_assert (strcmp (entry->key, GCONF_PATH_PATTERN) == 0);
-
- if (path_pattern)
- g_free (path_pattern);
-
- if (entry->value == NULL) {
- /* TODO: this value and the value in sj-prefs need to be in one place */
- path_pattern = g_strdup ("%aa/%at");
- } else {
- path_pattern = g_strdup (gconf_value_get_string (entry->value));
- }
+ g_assert (strcmp (key, SJ_SETTINGS_PATH_PATTERN) == 0);
+ g_free (path_pattern);
+ path_pattern = g_settings_get_string (settings, key);
/* TODO: sanity check the pattern */
}
/**
- * The GConf key for the filename pattern changed
+ * The GSettings key for the filename pattern changed
*/
-static void file_pattern_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
+static void file_pattern_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
{
- g_assert (strcmp (entry->key, GCONF_FILE_PATTERN) == 0);
-
- if (file_pattern)
- g_free (file_pattern);
-
- if (entry->value == NULL) {
- /* TODO: this value and the value in sj-prefs need to be in one place */
- file_pattern = g_strdup ("%tN-%tt");
- } else {
- file_pattern = g_strdup (gconf_value_get_string (entry->value));
- }
+ g_assert (strcmp (key, SJ_SETTINGS_FILE_PATTERN) == 0);
+ g_free (file_pattern);
+ file_pattern = g_settings_get_string (settings, key);
/* TODO: sanity check the pattern */
}
/**
- * The GConf key for the paranoia mode has changed
+ * The GSettings key for the paranoia mode has changed
*/
-static void paranoia_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
+static void paranoia_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
{
- g_assert (strcmp (entry->key, GCONF_PARANOIA) == 0);
- if (entry->value == NULL) {
- sj_extractor_set_paranoia (extractor, DEFAULT_PARANOIA);
- } else {
- int value = gconf_value_get_int (entry->value);
- if (value == 0 || value == 2 || value == 4 || value == 8 || value == 16 || value == 255) {
- sj_extractor_set_paranoia (extractor, value);
- }
+ int value;
+ g_assert (strcmp (key, SJ_SETTINGS_PARANOIA) == 0);
+ value = g_settings_get_enum (settings, key);
+ if (value == 0 || value == 2 || value == 4 || value == 8 || value == 16 || value == 255) {
+ sj_extractor_set_paranoia (extractor, value);
}
}
/**
- * The GConf key for the strip characters option changed
+ * The GSettings key for the strip characters option changed
*/
-static void strip_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
+static void strip_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
{
- g_assert (strcmp (entry->key, GCONF_STRIP) == 0);
- if (entry->value == NULL) {
- strip_chars = FALSE;
- } else {
- strip_chars = gconf_value_get_bool (entry->value);
- }
+ g_assert (strcmp (key, SJ_SETTINGS_STRIP) == 0);
+ strip_chars = g_settings_get_boolean (settings, key);
}
/**
- * The GConf key for the eject when finished option changed
+ * The GSettings key for the eject when finished option changed
*/
-static void eject_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
+static void eject_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
{
- g_assert (strcmp (entry->key, GCONF_EJECT) == 0);
- if (entry->value == NULL) {
- eject_finished = FALSE;
- } else {
- eject_finished = gconf_value_get_bool (entry->value);
- }
+ g_assert (strcmp (key, SJ_SETTINGS_EJECT) == 0);
+ eject_finished = g_settings_get_boolean (settings, key);
}
/**
- * The GConf key for the open when finished option changed
+ * The GSettings key for the open when finished option changed
*/
-static void open_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
+static void open_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
{
- g_assert (strcmp (entry->key, GCONF_OPEN) == 0);
- if (entry->value == NULL) {
- open_finished = FALSE;
- } else {
- open_finished = gconf_value_get_bool (entry->value);
- }
+ g_assert (strcmp (key, SJ_SETTINGS_OPEN) == 0);
+ open_finished = g_settings_get_boolean (settings, key);
}
/**
- * The GConf key for audio volume changes
+ * The GSettings key for audio volume changes
*/
-static void audio_volume_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
+static void audio_volume_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
{
- g_assert (strcmp (entry->key, GCONF_AUDIO_VOLUME) == 0);
+ g_assert (strcmp (key, SJ_SETTINGS_AUDIO_VOLUME) == 0);
GtkWidget *volb = GET_WIDGET ("volume_button");
- if (entry->value == NULL) {
- gtk_scale_button_set_value (GTK_SCALE_BUTTON (volb), 1.0);
- } else {
- gtk_scale_button_set_value (GTK_SCALE_BUTTON (volb), gconf_value_get_float (entry->value));
- }
+ gtk_scale_button_set_value (GTK_SCALE_BUTTON (volb), g_settings_get_double (settings, key));
}
static void
@@ -1506,15 +1473,17 @@ prefs_get_default_device (void)
}
/**
- * The GConf key for the device changed
+ * The GSettings key for the device changed
*/
-static void device_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
+static void device_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
{
const char *device;
+ char *value;
gboolean ignore_no_media = GPOINTER_TO_INT (user_data);
- g_assert (strcmp (entry->key, GCONF_DEVICE) == 0);
+ g_assert (strcmp (key, SJ_SETTINGS_DEVICE) == 0);
- if (entry->value == NULL || !cd_drive_exists (gconf_value_get_string (entry->value))) {
+ value = g_settings_get_string (settings, key);
+ if (!cd_drive_exists (value)) {
device = prefs_get_default_device();
if (device == NULL) {
#ifndef IGNORE_MISSING_CD
@@ -1532,20 +1501,21 @@ static void device_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *e
#endif
}
} else {
- device = gconf_value_get_string (entry->value);
+ device = value;
}
set_device (device, ignore_no_media);
+ g_free (value);
}
-static void profile_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
+static void profile_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
{
GstEncodingProfile *profile;
- const char *media_type;
+ char *media_type;
- g_assert (strcmp (entry->key, GCONF_AUDIO_PROFILE_MEDIA_TYPE) == 0);
- if (!entry->value) return;
- media_type = gconf_value_get_string (entry->value);
+ g_assert (strcmp (key, SJ_SETTINGS_AUDIO_PROFILE) == 0);
+ media_type = g_settings_get_string (settings, key);
profile = rb_gst_get_encoding_profile (media_type);
+ g_free (media_type);
if (profile != NULL)
g_object_set (extractor, "profile", profile, NULL);
@@ -1578,50 +1548,47 @@ static void profile_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *
* Configure the http proxy
*/
static void
-http_proxy_setup (GConfClient *client)
+http_proxy_setup (GSettings *settings)
{
- if (!gconf_client_get_bool (client, GCONF_HTTP_PROXY_ENABLE, NULL)) {
+ if (!g_settings_get_boolean (settings, SJ_SETTINGS_HTTP_PROXY_ENABLE)) {
sj_metadata_getter_set_proxy (metadata, NULL);
} else {
char *host;
int port;
- host = gconf_client_get_string (client, GCONF_HTTP_PROXY, NULL);
+ host = g_settings_get_string (settings, SJ_SETTINGS_HTTP_PROXY);
sj_metadata_getter_set_proxy (metadata, host);
g_free (host);
- port = gconf_client_get_int (client, GCONF_HTTP_PROXY_PORT, NULL);
+ port = g_settings_get_int (settings, SJ_SETTINGS_HTTP_PROXY_PORT);
sj_metadata_getter_set_proxy_port (metadata, port);
}
}
/**
- * The GConf key for the HTTP proxy being enabled changed.
+ * The GSettings key for the HTTP proxy being enabled changed.
*/
-static void http_proxy_enable_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
+static void http_proxy_enable_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
{
- g_assert (strcmp (entry->key, GCONF_HTTP_PROXY_ENABLE) == 0);
- if (entry->value == NULL) return;
- http_proxy_setup (client);
+ g_assert (strcmp (key, SJ_SETTINGS_HTTP_PROXY_ENABLE) == 0);
+ http_proxy_setup (settings);
}
/**
- * The GConf key for the HTTP proxy changed.
+ * The GSettings key for the HTTP proxy changed.
*/
-static void http_proxy_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
+static void http_proxy_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
{
- g_assert (strcmp (entry->key, GCONF_HTTP_PROXY) == 0);
- if (entry->value == NULL) return;
- http_proxy_setup (client);
+ g_assert (strcmp (key, SJ_SETTINGS_HTTP_PROXY) == 0);
+ http_proxy_setup (settings);
}
/**
- * The GConf key for the HTTP proxy port changed.
+ * The GSettings key for the HTTP proxy port changed.
*/
-static void http_proxy_port_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
+static void http_proxy_port_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
{
- g_assert (strcmp (entry->key, GCONF_HTTP_PROXY_PORT) == 0);
- if (entry->value == NULL) return;
- http_proxy_setup (client);
+ g_assert (strcmp (key, SJ_SETTINGS_HTTP_PROXY_PORT) == 0);
+ http_proxy_setup (settings);
}
/**
@@ -1953,28 +1920,6 @@ static void on_contents_activate(GSimpleAction *action, GVariant *parameter, gpo
}
}
-static void
-upgrade_gconf (void)
-{
- char *s;
- s = gconf_client_get_string (gconf_client, GCONF_BASEURI, NULL);
- if (s != NULL) {
- g_free (s);
- } else {
- GFile *gfile;
- char *uri;
- s = gconf_client_get_string (gconf_client, GCONF_BASEPATH, NULL);
- if (s == NULL)
- return;
- gfile = g_file_new_for_path (s);
- uri = g_file_get_uri (gfile);
- g_free (s);
- g_object_unref (gfile);
- gconf_client_set_string (gconf_client, GCONF_BASEURI, uri, NULL);
- g_free (uri);
- }
-}
-
/**
* Performs various checks to ensure CD duplication is available.
* If this is found TRUE is returned, otherwise FALSE is returned.
@@ -2050,29 +1995,37 @@ startup_cb (GApplication *app, gpointer user_data)
metadata = sj_metadata_getter_new ();
g_signal_connect (metadata, "metadata", G_CALLBACK (metadata_cb), NULL);
- gconf_client = gconf_client_get_default ();
- if (gconf_client == NULL) {
- g_warning (_("Could not create GConf client.\n"));
- exit (1);
- }
-
- upgrade_gconf ();
-
- gconf_client_add_dir (gconf_client, GCONF_ROOT, GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);
- gconf_client_notify_add (gconf_client, GCONF_DEVICE, device_changed_cb, NULL, NULL, NULL);
- gconf_client_notify_add (gconf_client, GCONF_EJECT, eject_changed_cb, NULL, NULL, NULL);
- gconf_client_notify_add (gconf_client, GCONF_OPEN, open_changed_cb, NULL, NULL, NULL);
- gconf_client_notify_add (gconf_client, GCONF_BASEURI, baseuri_changed_cb, NULL, NULL, NULL);
- gconf_client_notify_add (gconf_client, GCONF_STRIP, strip_changed_cb, NULL, NULL, NULL);
- gconf_client_notify_add (gconf_client, GCONF_AUDIO_PROFILE_MEDIA_TYPE, profile_changed_cb, NULL, NULL, NULL);
- gconf_client_notify_add (gconf_client, GCONF_PARANOIA, paranoia_changed_cb, NULL, NULL, NULL);
- gconf_client_notify_add (gconf_client, GCONF_PATH_PATTERN, path_pattern_changed_cb, NULL, NULL, NULL);
- gconf_client_notify_add (gconf_client, GCONF_FILE_PATTERN, file_pattern_changed_cb, NULL, NULL, NULL);
- gconf_client_notify_add (gconf_client, GCONF_AUDIO_VOLUME, audio_volume_changed_cb, NULL, NULL, NULL);
- gconf_client_add_dir (gconf_client, GCONF_PROXY_ROOT, GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);
- gconf_client_notify_add (gconf_client, GCONF_HTTP_PROXY_ENABLE, http_proxy_enable_changed_cb, NULL, NULL, NULL);
- gconf_client_notify_add (gconf_client, GCONF_HTTP_PROXY, http_proxy_changed_cb, NULL, NULL, NULL);
- gconf_client_notify_add (gconf_client, GCONF_HTTP_PROXY_PORT, http_proxy_port_changed_cb, NULL, NULL, NULL);
+ sj_settings = g_settings_new ("org.gnome.SoundJuicer");
+
+ g_signal_connect (sj_settings, "changed::"SJ_SETTINGS_DEVICE,
+ (GCallback)device_changed_cb, NULL);
+ g_signal_connect (sj_settings, "changed::"SJ_SETTINGS_EJECT,
+ (GCallback)eject_changed_cb, NULL);
+ g_signal_connect (sj_settings, "changed::"SJ_SETTINGS_OPEN,
+ (GCallback)open_changed_cb, NULL);
+ g_signal_connect (sj_settings, "changed::"SJ_SETTINGS_BASEURI,
+ (GCallback)baseuri_changed_cb, NULL);
+ g_signal_connect (sj_settings, "changed::"SJ_SETTINGS_STRIP,
+ (GCallback)strip_changed_cb, NULL);
+ g_signal_connect (sj_settings, "changed::"SJ_SETTINGS_AUDIO_PROFILE,
+ (GCallback)profile_changed_cb, NULL);
+ g_signal_connect (sj_settings, "changed::"SJ_SETTINGS_PARANOIA,
+ (GCallback)paranoia_changed_cb, NULL);
+ g_signal_connect (sj_settings, "changed::"SJ_SETTINGS_PATH_PATTERN,
+ (GCallback)path_pattern_changed_cb, NULL);
+ g_signal_connect (sj_settings, "changed::"SJ_SETTINGS_FILE_PATTERN,
+ (GCallback)file_pattern_changed_cb, NULL);
+ g_signal_connect (sj_settings, "changed::"SJ_SETTINGS_AUDIO_VOLUME,
+ (GCallback)audio_volume_changed_cb, NULL);
+
+ http_settings = g_settings_new ("org.gnome.system.proxy.http");
+
+ g_signal_connect (http_settings, "changed::"SJ_SETTINGS_HTTP_PROXY_ENABLE,
+ (GCallback)http_proxy_enable_changed_cb, NULL);
+ g_signal_connect (http_settings, "changed::"SJ_SETTINGS_HTTP_PROXY,
+ (GCallback)http_proxy_changed_cb, NULL);
+ g_signal_connect (http_settings, "changed::"SJ_SETTINGS_HTTP_PROXY_PORT,
+ (GCallback)http_proxy_port_changed_cb, NULL);
g_action_map_add_action_entries (G_ACTION_MAP (app),
app_entries, G_N_ELEMENTS (app_entries),
@@ -2299,80 +2252,40 @@ startup_cb (GApplication *app, gpointer user_data)
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (track_listview));
gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
- {
- GConfEntry *entry;
- http_proxy_setup (gconf_client);
-
- entry = gconf_client_get_entry (gconf_client, GCONF_BASEURI, NULL, TRUE, NULL);
- baseuri_changed_cb (gconf_client, -1, entry, NULL);
- gconf_entry_unref (entry);
-
- entry = gconf_client_get_entry (gconf_client, GCONF_PATH_PATTERN, NULL, TRUE, NULL);
- path_pattern_changed_cb (gconf_client, -1, entry, NULL);
- gconf_entry_unref (entry);
-
- entry = gconf_client_get_entry (gconf_client, GCONF_FILE_PATTERN, NULL, TRUE, NULL);
- file_pattern_changed_cb (gconf_client, -1, entry, NULL);
- gconf_entry_unref (entry);
-
- entry = gconf_client_get_entry (gconf_client, GCONF_AUDIO_PROFILE_MEDIA_TYPE, NULL, TRUE, NULL);
- profile_changed_cb (gconf_client, -1, entry, NULL);
- gconf_entry_unref (entry);
-
- entry = gconf_client_get_entry (gconf_client, GCONF_PARANOIA, NULL, TRUE, NULL);
- paranoia_changed_cb (gconf_client, -1, entry, NULL);
- gconf_entry_unref (entry);
-
- entry = gconf_client_get_entry (gconf_client, GCONF_STRIP, NULL, TRUE, NULL);
- strip_changed_cb (gconf_client, -1, entry, NULL);
- gconf_entry_unref (entry);
-
- entry = gconf_client_get_entry (gconf_client, GCONF_EJECT, NULL, TRUE, NULL);
- eject_changed_cb (gconf_client, -1, entry, NULL);
- gconf_entry_unref (entry);
-
- entry = gconf_client_get_entry (gconf_client, GCONF_OPEN, NULL, TRUE, NULL);
- open_changed_cb (gconf_client, -1, entry, NULL);
- gconf_entry_unref (entry);
-
- entry = gconf_client_get_entry (gconf_client, GCONF_AUDIO_VOLUME, NULL, TRUE, NULL);
- audio_volume_changed_cb (gconf_client, -1, entry, NULL);
- gconf_entry_unref (entry);
-
- if (device == NULL && uris == NULL) {
- entry = gconf_client_get_entry (gconf_client, GCONF_DEVICE, NULL, TRUE, NULL);
- device_changed_cb (gconf_client, -1, entry, GINT_TO_POINTER (TRUE));
- gconf_entry_unref (entry);
- } else {
- if (device) {
-#ifdef __sun
- if (strstr(device, "/dev/dsk/") != NULL ) {
- device = g_strdup_printf("/dev/rdsk/%s", device + strlen("/dev/dsk/"));
- }
-#endif
- set_device (device, TRUE);
+ http_proxy_setup (http_settings);
+ baseuri_changed_cb (sj_settings, SJ_SETTINGS_BASEURI, NULL);
+ path_pattern_changed_cb (sj_settings, SJ_SETTINGS_PATH_PATTERN, NULL);
+ file_pattern_changed_cb (sj_settings, SJ_SETTINGS_FILE_PATTERN, NULL);
+ profile_changed_cb (sj_settings, SJ_SETTINGS_AUDIO_PROFILE, NULL);
+ paranoia_changed_cb (sj_settings, SJ_SETTINGS_PARANOIA, NULL);
+ strip_changed_cb (sj_settings, SJ_SETTINGS_STRIP, NULL);
+ eject_changed_cb (sj_settings, SJ_SETTINGS_EJECT, NULL);
+ open_changed_cb (sj_settings, SJ_SETTINGS_OPEN, NULL);
+ audio_volume_changed_cb (sj_settings, SJ_SETTINGS_AUDIO_VOLUME, NULL);
+ if (device == NULL && uris == NULL) {
+ /* FIXME: this should set the device gsettings key to a meaningful
+ * value if it's empty (which is the case until the user changes it in
+ * the prefs)
+ */
+ device_changed_cb (sj_settings, SJ_SETTINGS_DEVICE, NULL);
+ } else {
+ if (device)
+ set_device (device, TRUE);
+ else {
+ char *d;
+
+ /* Mash up the CDDA URIs into a device path */
+ if (g_str_has_prefix (uris[0], "cdda://")) {
+ gint len;
+ d = g_strdup_printf ("/dev/%s%c", uris[0] + strlen ("cdda://"), '\0');
+ /* Take last '/' out of path, or set_device thinks it is part of the device name */
+ len = strlen (d);
+ if (d[len - 1] == '/')
+ d [len - 1] = '\0';
+ set_device (d, TRUE);
+ g_free (d);
} else {
- char *d;
-
- /* Mash up the CDDA URIs into a device path */
- if (g_str_has_prefix (uris[0], "cdda://")) {
- gint len;
-#ifdef __sun
- d = g_strdup_printf ("/dev/rdsk/%s", uris[0] + strlen ("cdda://"));
-#else
- d = g_strdup_printf ("/dev/%s%c", uris[0] + strlen ("cdda://"), '\0');
-#endif
- /* Take last '/' out of path, or set_device thinks it is part of the device name */
- len = strlen (d);
- if (d[len - 1] == '/')
- d [len - 1] = '\0';
- set_device (d, TRUE);
- g_free (d);
- } else {
- entry = gconf_client_get_entry (gconf_client, GCONF_DEVICE, NULL, TRUE, NULL);
- device_changed_cb (gconf_client, -1, entry, GINT_TO_POINTER (TRUE));
- gconf_entry_unref (entry);
- }
+ device_changed_cb (sj_settings, SJ_SETTINGS_DEVICE, NULL);
}
}
}
@@ -2386,7 +2299,7 @@ startup_cb (GApplication *app, gpointer user_data)
set_action_enabled ("duplicate", FALSE);
duplication_enabled = is_cd_duplication_available();
- gconf_bridge_bind_window_size(gconf_bridge_get(), GCONF_WINDOW, GTK_WINDOW (main_window));
+ /*gconf_bridge_bind_window_size(gconf_bridge_get(), GCONF_WINDOW, GTK_WINDOW (main_window));*/
gtk_application_add_window (GTK_APPLICATION (app), GTK_WINDOW (main_window));
gtk_widget_show (main_window);
@@ -2463,7 +2376,8 @@ int main (int argc, char **argv)
g_object_unref (base_uri);
g_object_unref (metadata);
g_object_unref (extractor);
- g_object_unref (gconf_client);
+ g_object_unref (sj_settings);
+ g_object_unref (http_settings);
brasero_media_library_stop ();
return status;
diff --git a/src/sj-play.c b/src/sj-play.c
index 1deff8c..b4c83fc 100644
--- a/src/sj-play.c
+++ b/src/sj-play.c
@@ -532,7 +532,7 @@ on_volume_changed (GtkWidget * volb, gdouble value, gpointer data)
vol = value;
if (pipeline)
g_object_set (G_OBJECT (pipeline), "volume", vol, NULL);
- gconf_client_set_float (gconf_client, GCONF_AUDIO_VOLUME, vol, NULL);
+ g_settings_set_double (sj_settings, SJ_SETTINGS_AUDIO_VOLUME, vol);
}
static gboolean
diff --git a/src/sj-prefs.c b/src/sj-prefs.c
index 7ce30af..bdc2333 100644
--- a/src/sj-prefs.c
+++ b/src/sj-prefs.c
@@ -29,12 +29,10 @@
#include <string.h>
#include <gst/pbutils/encoding-profile.h>
#include <gtk/gtk.h>
-#include <gconf/gconf-client.h>
#include <brasero-drive-selection.h>
#include "rb-gst-media-types.h"
#include "sj-util.h"
-#include "gconf-bridge.h"
#include "sj-extracting.h"
#include "sj-prefs.h"
@@ -95,8 +93,7 @@ void prefs_profile_changed (GtkWidget *widget, gpointer user_data)
char *media_type;
gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
0, &media_type, -1);
- gconf_client_set_string (gconf_client, GCONF_AUDIO_PROFILE_MEDIA_TYPE,
- media_type, NULL);
+ g_settings_set_string (sj_settings, SJ_SETTINGS_AUDIO_PROFILE, media_type);
g_free (media_type);
}
}
@@ -134,11 +131,11 @@ G_MODULE_EXPORT void prefs_base_folder_changed (GtkWidget *chooser, gpointer use
{
char *new_uri, *current_uri;
- current_uri = gconf_client_get_string (gconf_client, GCONF_BASEURI, NULL);
+ current_uri = g_settings_get_string (sj_settings, SJ_SETTINGS_BASEURI);
new_uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (chooser));
if (current_uri == NULL || strcmp(current_uri, new_uri) != 0) {
- gconf_client_set_string (gconf_client, GCONF_BASEURI, new_uri, NULL);
+ g_settings_set_string (sj_settings, SJ_SETTINGS_BASEURI, new_uri);
}
g_free (new_uri);
@@ -155,7 +152,7 @@ void prefs_path_option_changed (GtkComboBox *combo, gpointer user_data)
pattern = path_patterns[active].pattern;
if (pattern) {
- gconf_client_set_string (gconf_client, GCONF_PATH_PATTERN, pattern, NULL);
+ g_settings_set_string (sj_settings, SJ_SETTINGS_PATH_PATTERN, pattern);
}
}
@@ -169,7 +166,7 @@ G_MODULE_EXPORT void prefs_file_option_changed (GtkComboBox *combo, gpointer use
pattern = file_patterns[active].pattern;
if (pattern) {
- gconf_client_set_string (gconf_client, GCONF_FILE_PATTERN, pattern, NULL);
+ g_settings_set_string (sj_settings, SJ_SETTINGS_FILE_PATTERN, pattern);
}
}
@@ -200,17 +197,16 @@ sj_audio_profile_chooser_set_active (GtkWidget *chooser, const char *profile)
}
}
-static void audio_profile_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
+static void audio_profile_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
{
- const char *value;
- g_return_if_fail (strcmp (entry->key, GCONF_AUDIO_PROFILE_MEDIA_TYPE) == 0);
- if (!entry->value) return;
- value = gconf_value_get_string (entry->value);
-
+ char *value;
+ g_return_if_fail (strcmp (key, SJ_SETTINGS_AUDIO_PROFILE) == 0);
+ value = g_settings_get_string (settings, key);
sj_audio_profile_chooser_set_active (audio_profile, value);
+ g_free (value);
}
-static void baseuri_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
+static void baseuri_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
{
/*
* The conflict between separation of the prefs and the main window,
@@ -220,11 +216,9 @@ static void baseuri_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *
* into sj-utils?
*/
const char* base_uri, *current_uri;
- g_return_if_fail (strcmp (entry->key, GCONF_BASEURI) == 0);
+ g_return_if_fail (strcmp (key, SJ_SETTINGS_BASEURI) == 0);
- base_uri = NULL;
- if (entry->value != NULL)
- base_uri = gconf_value_get_string (entry->value);
+ base_uri = g_settings_get_string (settings, key);
if (base_uri == NULL || base_uri[0] == '\0') {
GFile *dir;
@@ -236,7 +230,6 @@ static void baseuri_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *
g_free (dir_uri);
g_object_unref (dir);
} else {
- g_return_if_fail (entry->value->type == GCONF_VALUE_STRING);
current_uri = gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (basepath_fcb));
if (current_uri == NULL || strcmp (current_uri, base_uri) != 0)
gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (basepath_fcb), base_uri);
@@ -285,11 +278,11 @@ static void pattern_label_update (void)
gst_encoding_profile_unref (profile);
/* TODO: sucky. Replace with get-gconf-key-with-default mojo */
- file_pattern = gconf_client_get_string (gconf_client, GCONF_FILE_PATTERN, NULL);
+ file_pattern = g_settings_get_string (sj_settings, SJ_SETTINGS_FILE_PATTERN);
if (file_pattern == NULL) {
file_pattern = g_strdup(file_patterns[0].pattern);
}
- path_pattern = gconf_client_get_string (gconf_client, GCONF_PATH_PATTERN, NULL);
+ path_pattern = g_settings_get_string (sj_settings, SJ_SETTINGS_PATH_PATTERN);
if (path_pattern == NULL) {
path_pattern = g_strdup(path_patterns[0].pattern);
}
@@ -317,18 +310,13 @@ static void pattern_label_update (void)
g_free (format);
}
-static void path_pattern_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
+static void path_pattern_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
{
char *value;
int i = 0;
- g_return_if_fail (strcmp (entry->key, GCONF_PATH_PATTERN) == 0);
+ g_return_if_fail (strcmp (key, SJ_SETTINGS_PATH_PATTERN) == 0);
- if (entry->value == NULL) {
- value = g_strdup (path_patterns[0].pattern);
- } else if (entry->value->type == GCONF_VALUE_STRING) {
- value = g_strdup (gconf_value_get_string (entry->value));
- } else
- return;
+ value = g_settings_get_string (settings, key);
while (path_patterns[i].pattern && strcmp(path_patterns[i].pattern, value) != 0) {
i++;
}
@@ -337,19 +325,15 @@ static void path_pattern_changed_cb (GConfClient *client, guint cnxn_id, GConfEn
pattern_label_update ();
}
-static void file_pattern_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
+static void file_pattern_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
{
char *value;
int i = 0;
- g_return_if_fail (strcmp (entry->key, GCONF_FILE_PATTERN) == 0);
+ g_return_if_fail (strcmp (key, SJ_SETTINGS_FILE_PATTERN) == 0);
+
+ value = g_settings_get_string (settings, key);
- if (entry->value == NULL) {
- value = g_strdup (file_patterns[0].pattern);
- } else if (entry->value->type == GCONF_VALUE_STRING) {
- value = g_strdup (gconf_value_get_string (entry->value));
- } else
- return;
while (file_patterns[i].pattern && strcmp(file_patterns[i].pattern, value) != 0) {
i++;
}
@@ -359,50 +343,51 @@ static void file_pattern_changed_cb (GConfClient *client, guint cnxn_id, GConfEn
}
/**
- * Default device changed (either GConf key or the widget)
+ * Default device changed (either GSettings key or the widget)
*/
-static void device_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
+static void device_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
{
- g_return_if_fail (strcmp (entry->key, GCONF_DEVICE) == 0);
-
- if (entry->value == NULL)
- return;
+ BraseroDrive *drive;
+ BraseroMediumMonitor *monitor;
+ char *value;
- if (entry->value->type == GCONF_VALUE_STRING) {
- BraseroDrive *drive;
- BraseroMediumMonitor *monitor;
+ g_return_if_fail (strcmp (key, SJ_SETTINGS_DEVICE) == 0);
+ value = g_settings_get_string (settings, key);
+ if ((value != NULL) && (*value != '\0')) {
monitor = brasero_medium_monitor_get_default ();
- drive = brasero_medium_monitor_get_drive (monitor, gconf_value_get_string (entry->value));
+ drive = brasero_medium_monitor_get_drive (monitor, value);
brasero_drive_selection_set_active (BRASERO_DRIVE_SELECTION (cd_option), drive);
g_object_unref (drive);
g_object_unref (monitor);
+ } else {
+ /* FIXME: see the FIXME in sj-main.c around one of the
+ * device_changed_cb calls for a way to fix this
+ */
+ g_warn_if_reached();
}
+ g_free (value);
}
static void prefs_drive_changed (BraseroDriveSelection *selection, BraseroDrive *drive, gpointer user_data)
{
if (drive)
- gconf_client_set_string (gconf_client, GCONF_DEVICE, brasero_drive_get_device (drive), NULL);
+ g_settings_set_string (sj_settings, SJ_SETTINGS_DEVICE, brasero_drive_get_device (drive));
else
- gconf_client_set_string (gconf_client, GCONF_DEVICE, NULL, NULL);
+ g_settings_set_string (sj_settings, SJ_SETTINGS_DEVICE, NULL);
}
/**
- * The GConf key for the strip characters option changed
+ * The GSettings key for the strip characters option changed
*/
-static void strip_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
+static void strip_changed_cb (GSettings *settings, gchar *key, gpointer user_data)
{
/* NOTE that strip_changed_cb in sj-main.c will also be called, and will also update
the global value strip_chars - but which function will get called first?
Make sure strip_chars is up to date BEFORE calling pattern_label_update */
- g_return_if_fail (strcmp (entry->key, GCONF_STRIP) == 0);
+ g_return_if_fail (strcmp (key, SJ_SETTINGS_STRIP) == 0);
- if (entry->value == NULL) {
- strip_chars = FALSE;
- } else {
- strip_chars = gconf_value_get_bool (entry->value);
- }
+ strip_chars = g_settings_get_boolean (settings, key);
pattern_label_update ();
}
@@ -482,7 +467,6 @@ void show_preferences_dialog ()
guint i;
GtkSizeGroup *group;
GtkWidget *box;
- GConfBridge *bridge = gconf_bridge_get ();
prefs_dialog = GET_WIDGET ("prefs_dialog");
box = GET_WIDGET ("hack_hbox");
@@ -533,24 +517,30 @@ void show_preferences_dialog ()
g_signal_connect (cd_option, "drive-changed", G_CALLBACK (prefs_drive_changed), NULL);
- /* Connect to GConf to update the UI */
- gconf_bridge_bind_property (bridge, GCONF_EJECT, G_OBJECT (check_eject), "active");
- gconf_bridge_bind_property (bridge, GCONF_OPEN, G_OBJECT (check_open), "active");
- gconf_bridge_bind_property (bridge, GCONF_STRIP, G_OBJECT (check_strip), "active");
- gconf_client_notify_add (gconf_client, GCONF_DEVICE, device_changed_cb, NULL, NULL, NULL);
- gconf_client_notify_add (gconf_client, GCONF_BASEURI, baseuri_changed_cb, NULL, NULL, NULL);
- gconf_client_notify_add (gconf_client, GCONF_AUDIO_PROFILE_MEDIA_TYPE, audio_profile_changed_cb, NULL, NULL, NULL);
- gconf_client_notify_add (gconf_client, GCONF_PATH_PATTERN, path_pattern_changed_cb, NULL, NULL, NULL);
- gconf_client_notify_add (gconf_client, GCONF_FILE_PATTERN, file_pattern_changed_cb, NULL, NULL, NULL);
- gconf_client_notify_add (gconf_client, GCONF_STRIP, strip_changed_cb, NULL, NULL, NULL);
+ /* Connect to GSettings to update the UI */
+ g_settings_bind (sj_settings, SJ_SETTINGS_EJECT, G_OBJECT (check_eject), "active", G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (sj_settings, SJ_SETTINGS_OPEN, G_OBJECT (check_open), "active", G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (sj_settings, SJ_SETTINGS_STRIP, G_OBJECT (check_strip), "active", G_SETTINGS_BIND_DEFAULT);
+ g_signal_connect (G_OBJECT (sj_settings), "changed::"SJ_SETTINGS_DEVICE,
+ (GCallback)device_changed_cb, NULL);
+ g_signal_connect (G_OBJECT (sj_settings), "changed::"SJ_SETTINGS_BASEURI,
+ (GCallback)baseuri_changed_cb, NULL);
+ g_signal_connect (G_OBJECT (sj_settings), "changed::"SJ_SETTINGS_AUDIO_PROFILE,
+ (GCallback)audio_profile_changed_cb, NULL);
+ g_signal_connect (G_OBJECT (sj_settings), "changed::"SJ_SETTINGS_PATH_PATTERN,
+ (GCallback)path_pattern_changed_cb, NULL);
+ g_signal_connect (G_OBJECT (sj_settings), "changed::"SJ_SETTINGS_FILE_PATTERN,
+ (GCallback)file_pattern_changed_cb, NULL);
+ g_signal_connect (G_OBJECT (sj_settings), "changed::"SJ_SETTINGS_STRIP,
+ (GCallback)strip_changed_cb, NULL);
g_signal_connect (extractor, "notify::profile", pattern_label_update, NULL);
- baseuri_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_BASEURI, NULL, TRUE, NULL), NULL);
- audio_profile_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_AUDIO_PROFILE_MEDIA_TYPE, NULL, TRUE, NULL), NULL);
- file_pattern_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_FILE_PATTERN, NULL, TRUE, NULL), NULL);
- path_pattern_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_PATH_PATTERN, NULL, TRUE, NULL), NULL);
- device_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_DEVICE, NULL, TRUE, NULL), NULL);
+ baseuri_changed_cb (sj_settings, SJ_SETTINGS_BASEURI, NULL);
+ audio_profile_changed_cb (sj_settings, SJ_SETTINGS_AUDIO_PROFILE, NULL);
+ file_pattern_changed_cb (sj_settings, SJ_SETTINGS_FILE_PATTERN, NULL);
+ path_pattern_changed_cb (sj_settings, SJ_SETTINGS_PATH_PATTERN, NULL);
+ device_changed_cb (sj_settings, SJ_SETTINGS_DEVICE, NULL);
g_signal_connect (GTK_DIALOG (prefs_dialog), "response", G_CALLBACK (on_response), NULL);
diff --git a/src/sound-juicer.h b/src/sound-juicer.h
index a91dad9..224d37e 100644
--- a/src/sound-juicer.h
+++ b/src/sound-juicer.h
@@ -25,15 +25,14 @@
#include <glib/gi18n.h>
#include <brasero-medium-selection.h>
-#include <gconf/gconf-client.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
#include "sj-extractor.h"
/**
- * A GConf client
+ * A GSettings object
*/
-extern GConfClient *gconf_client;
+extern GSettings *sj_settings;
/**
* The main window
@@ -141,27 +140,24 @@ extern GtkCellRenderer *toggle_renderer, *title_renderer, *artist_renderer, *com
void sj_debug (SjDebugDomain domain, const gchar* format, ...);
/**
- * GConf key names
- */
-#define GCONF_ROOT "/apps/sound-juicer"
-#define GCONF_DEVICE GCONF_ROOT "/device"
-#define GCONF_EJECT GCONF_ROOT "/eject"
-#define GCONF_OPEN GCONF_ROOT "/open_completed"
-#define GCONF_BASEPATH GCONF_ROOT "/base_path"
-#define GCONF_BASEURI GCONF_ROOT "/base_uri"
-#define GCONF_FILE_PATTERN GCONF_ROOT "/file_pattern"
-#define GCONF_PATH_PATTERN GCONF_ROOT "/path_pattern"
-#define GCONF_AUDIO_PROFILE GCONF_ROOT "/audio_profile"
-#define GCONF_AUDIO_PROFILE_MEDIA_TYPE GCONF_ROOT "/audio_profile_media_type"
-#define GCONF_PARANOIA GCONF_ROOT "/paranoia"
-#define GCONF_STRIP GCONF_ROOT "/strip-special"
-#define GCONF_WINDOW GCONF_ROOT "/window"
-#define GCONF_AUDIO_VOLUME GCONF_ROOT "/volume"
-
-#define GCONF_PROXY_ROOT "/system/http_proxy"
-#define GCONF_HTTP_PROXY_ENABLE GCONF_PROXY_ROOT "/use_http_proxy"
-#define GCONF_HTTP_PROXY GCONF_PROXY_ROOT "/host"
-#define GCONF_HTTP_PROXY_PORT GCONF_PROXY_ROOT "/port"
+ * GSettings key names
+ */
+#define SJ_SETTINGS_DEVICE "device"
+#define SJ_SETTINGS_EJECT "eject"
+#define SJ_SETTINGS_OPEN "open-completed"
+#define SJ_SETTINGS_BASEPATH "base-path"
+#define SJ_SETTINGS_BASEURI "base-uri"
+#define SJ_SETTINGS_FILE_PATTERN "file-pattern"
+#define SJ_SETTINGS_PATH_PATTERN "path-pattern"
+#define SJ_SETTINGS_AUDIO_PROFILE "audio-profile"
+#define SJ_SETTINGS_PARANOIA "paranoia"
+#define SJ_SETTINGS_STRIP "strip-special"
+#define SJ_SETTINGS_WINDOW "window"
+#define SJ_SETTINGS_AUDIO_VOLUME "volume"
+
+#define SJ_SETTINGS_HTTP_PROXY_ENABLE "enabled"
+#define SJ_SETTINGS_HTTP_PROXY "host"
+#define SJ_SETTINGS_HTTP_PROXY_PORT "port"
/* TODO: need to add a SjWindow object or something */
void sj_main_set_title (const char* detail);
diff --git a/tests/mb-test.c b/tests/mb-test.c
index dc3031d..b4a1ec3 100644
--- a/tests/mb-test.c
+++ b/tests/mb-test.c
@@ -1,14 +1,11 @@
#include "config.h"
#include <brasero-medium-monitor.h>
#include <glib.h>
-#include <gconf/gconf-client.h>
#include <stdlib.h>
#include "sj-structures.h"
#include "sj-metadata.h"
#include "sj-metadata-getter.h"
-#define GCONF_ROOT "/apps/sound-juicer"
-
static const char *
source_to_str (MetadataSource source)
{
@@ -93,25 +90,17 @@ int main (int argc, char** argv)
{
SjMetadataGetter *metadata;
GMainLoop *loop;
- GConfClient *gconf_client;
GError *error = NULL;
BraseroMediumMonitor *monitor;
g_type_init ();
- gconf_client = gconf_client_get_default ();
- if (gconf_client == NULL) {
- g_warning ("Could not create GConf client.\n");
- exit (1);
- }
-
/* Make sure probing of the various media have settled before going on */
monitor = brasero_medium_monitor_get_default ();
while (brasero_medium_monitor_is_probing (monitor))
g_usleep (G_USEC_PER_SEC/10);
g_object_unref (G_OBJECT (monitor));
- gconf_client_add_dir (gconf_client, GCONF_ROOT, GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);
metadata = sj_metadata_getter_new ();