[goobox] ported to GSettings
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goobox] ported to GSettings
- Date: Thu, 2 Jun 2011 17:25:58 +0000 (UTC)
commit fe6b198abe25f1daeada2cf4b03e3fec19a227ef
Author: Paolo Bacchilega <paobac src gnome org>
Date: Thu Jun 2 17:06:37 2011 +0200
ported to GSettings
configure.ac | 14 +-
copy-n-paste/Makefile.am | 3 +-
copy-n-paste/eggdesktopfile.c | 87 +++-
copy-n-paste/eggdesktopfile.h | 8 +-
copy-n-paste/eggsmclient-private.h | 6 +
copy-n-paste/eggsmclient-xsmp.c | 17 +-
copy-n-paste/eggsmclient.c | 30 +-
data/Makefile.am | 45 +-
data/goobox.convert | 32 ++
data/goobox.schemas.in | 316 ------------
data/org.gnome.Goobox.gschema.xml.in | 165 +++++++
po/POTFILES.in | 4 -
src/Makefile.am | 1 -
src/actions.c | 71 ++-
src/dlg-extract.c | 2 -
src/dlg-preferences.c | 54 ++-
src/dlg-ripper.c | 24 +-
src/gnome-desktop-thumbnail.c | 882 ++++++++++++++++++++++-----------
src/gnome-desktop-thumbnail.h | 8 -
src/goo-player-info.c | 6 +-
src/goo-player.c | 160 +++---
src/goo-volume-tool-button.c | 2 +-
src/goo-window.c | 248 +++++-----
src/gtk-utils.c | 244 ++---------
src/gtk-utils.h | 11 +-
src/main.c | 10 +-
src/preferences.c | 262 ----------
src/preferences.h | 85 ++--
src/typedefs.h | 1 +
29 files changed, 1307 insertions(+), 1491 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 2515c97..4c7c101 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,19 +1,19 @@
+AC_PREREQ(2.61)
AC_INIT([goobox], [2.2.0], [http://bugzilla.gnome.org/enter_bug.cgi?product=goobox])
+AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz tar-ustar])
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
-GNOME_COMMON_INIT
-
+AC_CONFIG_SRCDIR([config.h.in])
+AC_CONFIG_HEADER([config.h])
AC_CONFIG_MACRO_DIR([m4])
-AC_CONFIG_HEADERS([config.h])
-AC_CONFIG_SRCDIR([configure.ac])
-
-AM_INIT_AUTOMAKE([1.9 foreign])
-m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
+GNOME_COMMON_INIT
AC_PROG_CXX
AM_PROG_LIBTOOL
GNOME_DOC_INIT
GNOME_COMPILE_WARNINGS([maximum])
GNOME_MAINTAINER_MODE_DEFINES
+GLIB_GSETTINGS
GLIB_REQUIRED=2.28
GTK_REQUIRED=3.0.0
diff --git a/copy-n-paste/Makefile.am b/copy-n-paste/Makefile.am
index 3846c85..d07144d 100644
--- a/copy-n-paste/Makefile.am
+++ b/copy-n-paste/Makefile.am
@@ -1,6 +1,7 @@
INCLUDES = -DGTK_DISABLE_DEPRECATED \
-DGDK_DISABLE_DEPRECATED \
- -DG_DISABLE_DEPRECATED
+ -DG_DISABLE_DEPRECATED \
+ -UGETTEXT_PACKAGE
noinst_LTLIBRARIES = libeggsmclient.la
diff --git a/copy-n-paste/eggdesktopfile.c b/copy-n-paste/eggdesktopfile.c
index 357e548..c59ff65 100644
--- a/copy-n-paste/eggdesktopfile.c
+++ b/copy-n-paste/eggdesktopfile.c
@@ -183,6 +183,8 @@ egg_desktop_file_new_from_key_file (GKeyFile *key_file,
}
else if (version_num > 1.0)
{
+ /* Translators: Version here is capitalized because it refers to a
+ * field in the desktop file */
g_set_error (error, EGG_DESKTOP_FILE_ERROR,
EGG_DESKTOP_FILE_ERROR_INVALID,
_("Unrecognized desktop file Version '%s'"), version);
@@ -431,6 +433,16 @@ egg_desktop_file_get_numeric (EggDesktopFile *desktop_file,
error);
}
+int
+egg_desktop_file_get_integer (EggDesktopFile *desktop_file,
+ const char *key,
+ GError **error)
+{
+ return g_key_file_get_integer (desktop_file->key_file,
+ EGG_DESKTOP_FILE_GROUP, key,
+ error);
+}
+
char **
egg_desktop_file_get_string_list (EggDesktopFile *desktop_file,
const char *key,
@@ -1274,8 +1286,8 @@ egg_desktop_file_launchv (EggDesktopFile *desktop_file,
out:
if (env)
{
- g_strfreev ((char **)env->pdata);
- g_ptr_array_free (env, FALSE);
+ g_ptr_array_foreach (env, (GFunc)g_free, NULL);
+ g_ptr_array_free (env, TRUE);
}
free_document_list (translated_documents);
@@ -1370,7 +1382,7 @@ egg_desktop_file_launch (EggDesktopFile *desktop_file,
{
g_set_error (error, EGG_DESKTOP_FILE_ERROR,
EGG_DESKTOP_FILE_ERROR_NOT_LAUNCHABLE,
- _("Can't pass document URIs to a 'Type=Link' desktop entry"));
+ _("Can't pass documents to this desktop element"));
return FALSE;
}
@@ -1386,6 +1398,8 @@ egg_desktop_file_launch (EggDesktopFile *desktop_file,
free_document_list (documents);
break;
+ case EGG_DESKTOP_FILE_TYPE_UNRECOGNIZED:
+ case EGG_DESKTOP_FILE_TYPE_DIRECTORY:
default:
g_set_error (error, EGG_DESKTOP_FILE_ERROR,
EGG_DESKTOP_FILE_ERROR_NOT_LAUNCHABLE,
@@ -1408,23 +1422,9 @@ egg_desktop_file_error_quark (void)
G_LOCK_DEFINE_STATIC (egg_desktop_file);
static EggDesktopFile *egg_desktop_file;
-/**
- * egg_set_desktop_file:
- * @desktop_file_path: path to the application's desktop file
- *
- * Creates an #EggDesktopFile for the application from the data at
- * @desktop_file_path. This will also call g_set_application_name()
- * with the localized application name from the desktop file, and
- * gtk_window_set_default_icon_name() or
- * gtk_window_set_default_icon_from_file() with the application's
- * icon. Other code may use additional information from the desktop
- * file.
- *
- * Note that for thread safety reasons, this function can only
- * be called once.
- **/
-void
-egg_set_desktop_file (const char *desktop_file_path)
+static void
+egg_set_desktop_file_internal (const char *desktop_file_path,
+ gboolean set_defaults)
{
GError *error = NULL;
@@ -1440,7 +1440,7 @@ egg_set_desktop_file (const char *desktop_file_path)
g_error_free (error);
}
- if (egg_desktop_file) {
+ if (set_defaults && egg_desktop_file != NULL) {
/* Set localized application name and default window icon */
if (egg_desktop_file->name)
g_set_application_name (egg_desktop_file->name);
@@ -1457,6 +1457,51 @@ egg_set_desktop_file (const char *desktop_file_path)
}
/**
+ * egg_set_desktop_file:
+ * @desktop_file_path: path to the application's desktop file
+ *
+ * Creates an #EggDesktopFile for the application from the data at
+ * @desktop_file_path. This will also call g_set_application_name()
+ * with the localized application name from the desktop file, and
+ * gtk_window_set_default_icon_name() or
+ * gtk_window_set_default_icon_from_file() with the application's
+ * icon. Other code may use additional information from the desktop
+ * file.
+ * See egg_set_desktop_file_without_defaults() for a variant of this
+ * function that does not set the application name and default window
+ * icon.
+ *
+ * Note that for thread safety reasons, this function can only
+ * be called once, and is mutually exclusive with calling
+ * egg_set_desktop_file_without_defaults().
+ **/
+void
+egg_set_desktop_file (const char *desktop_file_path)
+{
+ egg_set_desktop_file_internal (desktop_file_path, TRUE);
+}
+
+/**
+ * egg_set_desktop_file_without_defaults:
+ * @desktop_file_path: path to the application's desktop file
+ *
+ * Creates an #EggDesktopFile for the application from the data at
+ * @desktop_file_path.
+ * See egg_set_desktop_file() for a variant of this function that
+ * sets the application name and default window icon from the information
+ * in the desktop file.
+ *
+ * Note that for thread safety reasons, this function can only
+ * be called once, and is mutually exclusive with calling
+ * egg_set_desktop_file().
+ **/
+void
+egg_set_desktop_file_without_defaults (const char *desktop_file_path)
+{
+ egg_set_desktop_file_internal (desktop_file_path, FALSE);
+}
+
+/**
* egg_get_desktop_file:
*
* Gets the application's #EggDesktopFile, as set by
diff --git a/copy-n-paste/eggdesktopfile.h b/copy-n-paste/eggdesktopfile.h
index f8a3d3e..16c5426 100644
--- a/copy-n-paste/eggdesktopfile.h
+++ b/copy-n-paste/eggdesktopfile.h
@@ -127,6 +127,9 @@ gboolean egg_desktop_file_get_boolean (EggDesktopFile *desktop_file
double egg_desktop_file_get_numeric (EggDesktopFile *desktop_file,
const char *key,
GError **error);
+int egg_desktop_file_get_integer (EggDesktopFile *desktop_file,
+ const char *key,
+ GError **error);
char **egg_desktop_file_get_string_list (EggDesktopFile *desktop_file,
const char *key,
gsize *length,
@@ -150,8 +153,9 @@ typedef enum {
} EggDesktopFileError;
/* Global application desktop file */
-void egg_set_desktop_file (const char *desktop_file_path);
-EggDesktopFile *egg_get_desktop_file (void);
+void egg_set_desktop_file (const char *desktop_file_path);
+void egg_set_desktop_file_without_defaults (const char *desktop_file_path);
+EggDesktopFile *egg_get_desktop_file (void);
G_END_DECLS
diff --git a/copy-n-paste/eggsmclient-private.h b/copy-n-paste/eggsmclient-private.h
index ccb10bf..0c98eee 100644
--- a/copy-n-paste/eggsmclient-private.h
+++ b/copy-n-paste/eggsmclient-private.h
@@ -20,7 +20,13 @@
#ifndef __EGG_SM_CLIENT_PRIVATE_H__
#define __EGG_SM_CLIENT_PRIVATE_H__
+#include <gtk/gtk.h>
+
+#if !GTK_CHECK_VERSION(2,91,7) && !GTK_CHECK_VERSION(3,0,0)
+/* GTK+ 3 includes this automatically */
#include <gdkconfig.h>
+#endif
+
#include "eggsmclient.h"
G_BEGIN_DECLS
diff --git a/copy-n-paste/eggsmclient-xsmp.c b/copy-n-paste/eggsmclient-xsmp.c
index 1a56156..ec1b594 100644
--- a/copy-n-paste/eggsmclient-xsmp.c
+++ b/copy-n-paste/eggsmclient-xsmp.c
@@ -36,6 +36,7 @@
#include <X11/SM/SMlib.h>
#include <gdk/gdk.h>
+#include <gdk/gdkx.h>
#define EGG_TYPE_SM_CLIENT_XSMP (egg_sm_client_xsmp_get_type ())
#define EGG_SM_CLIENT_XSMP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_SM_CLIENT_XSMP, EggSMClientXSMP))
@@ -367,7 +368,11 @@ sm_client_xsmp_startup (EggSMClient *client,
free (ret_client_id);
gdk_threads_enter ();
+#if !GTK_CHECK_VERSION(2,91,7) && !GTK_CHECK_VERSION(3,0,0)
gdk_set_sm_client_id (xsmp->client_id);
+#else
+ gdk_x11_set_sm_client_id (xsmp->client_id);
+#endif
gdk_threads_leave ();
g_debug ("Got client ID \"%s\"", xsmp->client_id);
@@ -1052,13 +1057,13 @@ generate_command (char **restart_command, const char *client_id,
if (client_id)
{
- g_ptr_array_add (cmd, "--sm-client-id");
+ g_ptr_array_add (cmd, (char *)"--sm-client-id");
g_ptr_array_add (cmd, (char *)client_id);
}
if (state_file)
{
- g_ptr_array_add (cmd, "--sm-client-state-file");
+ g_ptr_array_add (cmd, (char *)"--sm-client-state-file");
g_ptr_array_add (cmd, (char *)state_file);
}
@@ -1141,7 +1146,7 @@ array_prop (const char *name, ...)
prop = g_new (SmProp, 1);
prop->name = (char *)name;
- prop->type = SmLISTofARRAY8;
+ prop->type = (char *)SmLISTofARRAY8;
vals = g_array_new (FALSE, FALSE, sizeof (SmPropValue));
@@ -1175,7 +1180,7 @@ ptrarray_prop (const char *name, GPtrArray *values)
prop = g_new (SmProp, 1);
prop->name = (char *)name;
- prop->type = SmLISTofARRAY8;
+ prop->type = (char *)SmLISTofARRAY8;
vals = g_array_new (FALSE, FALSE, sizeof (SmPropValue));
@@ -1205,7 +1210,7 @@ string_prop (const char *name, const char *value)
prop = g_new (SmProp, 1);
prop->name = (char *)name;
- prop->type = SmARRAY8;
+ prop->type = (char *)SmARRAY8;
prop->num_vals = 1;
prop->vals = g_new (SmPropValue, 1);
@@ -1230,7 +1235,7 @@ card8_prop (const char *name, unsigned char value)
prop = g_new (SmProp, 1);
prop->name = (char *)name;
- prop->type = SmCARD8;
+ prop->type = (char *)SmCARD8;
prop->num_vals = 1;
prop->vals = g_new (SmPropValue, 2);
diff --git a/copy-n-paste/eggsmclient.c b/copy-n-paste/eggsmclient.c
index 46af148..92be8a7 100644
--- a/copy-n-paste/eggsmclient.c
+++ b/copy-n-paste/eggsmclient.c
@@ -202,7 +202,8 @@ sm_client_post_parse_func (GOptionContext *context,
* use the same client id. */
g_unsetenv ("DESKTOP_AUTOSTART_ID");
- if (EGG_SM_CLIENT_GET_CLASS (client)->startup)
+ if (global_client_mode != EGG_SM_CLIENT_MODE_DISABLED &&
+ EGG_SM_CLIENT_GET_CLASS (client)->startup)
EGG_SM_CLIENT_GET_CLASS (client)->startup (client, sm_client_id);
return TRUE;
}
@@ -254,7 +255,6 @@ egg_sm_client_get_option_group (void)
NULL, NULL);
g_option_group_add_entries (group, entries);
g_option_group_set_parse_hooks (group, NULL, sm_client_post_parse_func);
- g_option_group_set_translation_domain (group, GETTEXT_PACKAGE);
return group;
}
@@ -266,9 +266,9 @@ egg_sm_client_get_option_group (void)
* Sets the "mode" of #EggSMClient as follows:
*
* %EGG_SM_CLIENT_MODE_DISABLED: Session management is completely
- * disabled. The application will not even connect to the session
- * manager. (egg_sm_client_get() will still return an #EggSMClient,
- * but it will just be a dummy object.)
+ * disabled, until the mode is changed again. The application will
+ * not even connect to the session manager. (egg_sm_client_get()
+ * will still return an #EggSMClient object.)
*
* %EGG_SM_CLIENT_MODE_NO_RESTART: The application will connect to
* the session manager (and thus will receive notification when the
@@ -278,12 +278,27 @@ egg_sm_client_get_option_group (void)
* %EGG_SM_CLIENT_MODE_NORMAL: The default. #EggSMCLient will
* function normally.
*
- * This must be called before the application's main loop begins.
+ * This must be called before the application's main loop begins and
+ * before any call to egg_sm_client_get(), unless the mode was set
+ * earlier to %EGG_SM_CLIENT_MODE_DISABLED and this call enables
+ * session management. Note that option parsing will call
+ * egg_sm_client_get().
**/
void
egg_sm_client_set_mode (EggSMClientMode mode)
{
+ EggSMClientMode old_mode = global_client_mode;
+
+ g_return_if_fail (global_client == NULL || global_client_mode == EGG_SM_CLIENT_MODE_DISABLED);
+ g_return_if_fail (!(global_client != NULL && mode == EGG_SM_CLIENT_MODE_DISABLED));
+
global_client_mode = mode;
+
+ if (global_client != NULL && old_mode == EGG_SM_CLIENT_MODE_DISABLED)
+ {
+ if (EGG_SM_CLIENT_GET_CLASS (global_client)->startup)
+ EGG_SM_CLIENT_GET_CLASS (global_client)->startup (global_client, sm_client_id);
+ }
}
/**
@@ -318,8 +333,7 @@ egg_sm_client_get (void)
{
if (!global_client)
{
- if (global_client_mode != EGG_SM_CLIENT_MODE_DISABLED &&
- !sm_client_disable)
+ if (!sm_client_disable)
{
#if defined (GDK_WINDOWING_WIN32)
global_client = egg_sm_client_win32_new ();
diff --git a/data/Makefile.am b/data/Makefile.am
index 2613b75..036d5c5 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -7,29 +7,34 @@ desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
@INTLTOOL_DESKTOP_RULE@
-schemadir = @GCONF_SCHEMA_FILE_DIR@
-schema_in_files = goobox.schemas.in
-schema_DATA = $(schema_in_files:.schemas.in=.schemas)
-
- INTLTOOL_SCHEMAS_RULE@
-
-if SCHEMAS_INSTALL
-install-data-local:
- GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(top_builddir)/data/$(schema_DATA)
-endif
-
-EXTRA_DIST = \
- goobox.schemas \
- goobox.schemas.in \
- $(desktop_in_in_files) \
- $(desktop_in_files) \
- $(desktop_DATA) \
+gsettingsschema_in_files = org.gnome.Goobox.gschema.xml.in
+gsettings_SCHEMAS = $(gsettingsschema_in_files:.xml.in=.xml)
+.PRECIOUS: $(gsettings_SCHEMAS)
+
+ INTLTOOL_XML_NOMERGE_RULE@
+
+ GSETTINGS_RULES@
+
+convertdir = $(datadir)/GConf/gsettings
+convert_DATA = goobox.convert
+
+EXTRA_DIST = \
+ $(gsettingsschema_in_files) \
+ $(desktop_in_in_files) \
+ $(desktop_in_files) \
+ $(desktop_DATA) \
$(icon_DATA)
-DISTCLEANFILES = \
- $(schema_DATA) \
- $(desktop_in_files) \
+DISTCLEANFILES = \
+ $(desktop_in_files) \
$(desktop_DATA)
+CLEANFILES = \
+ $(gsettings_SCHEMAS) \
+ $(NULL)
+
+dist-hook:
+ cd $(distdir); rm -f $(CLEANFILES)
+
-include $(top_srcdir)/git.mk
diff --git a/data/goobox.convert b/data/goobox.convert
new file mode 100644
index 0000000..307cbd1
--- /dev/null
+++ b/data/goobox.convert
@@ -0,0 +1,32 @@
+[org.gnome.Goobox.General]
+device = /apps/goobox/general/device
+volume = /apps/goobox/general/volume
+cover-path = /apps/goobox/general/cover_path
+use-sound-juicer = /apps/goobox/general/use_sound_juicer
+autoplay = /apps/goobox/general/autoplay
+
+[org.gnome.Goobox.UI]
+toolbar-style = /apps/goobox/ui/toolbar_style
+window-width = /apps/goobox/ui/window_width
+window-height = /apps/goobox/ui/window_height
+toolbar-visible = /apps/goobox/ui/toolbar_visible
+statusbar-visible = /apps/goobox/ui/statusbar_visible
+playlist-visible = /apps/goobox/ui/playlist_visible
+
+[org.gnome.Goobox.Playlist]
+play-all = /apps/goobox/playlist/play_all
+shuffle = /apps/goobox/playlist/shuffle
+repeat = /apps/goobox/playlist/repeat
+sort-method = /apps/goobox/playlist/sort_method
+sort-type = /apps/goobox/playlist/sort_type
+
+[org.gnome.Goobox.Ripper]
+destination = /apps/goobox/dialogs/extract/destination
+file-type = /apps/goobox/dialogs/extract/file_type
+save-playlist = /apps/goobox/dialogs/extract/save_playlist
+view-destination = /apps/goobox/dialogs/ripper/view_destination
+
+[org.gnome.Goobox.Encoder]
+ogg-quality = /apps/goobox/encoder/ogg_quality
+flac-compression = /apps/goobox/encoder/flac_compression
+mp3-quality = /apps/goobox/encoder/mp3_quality
diff --git a/data/org.gnome.Goobox.gschema.xml.in b/data/org.gnome.Goobox.gschema.xml.in
new file mode 100644
index 0000000..3eea184
--- /dev/null
+++ b/data/org.gnome.Goobox.gschema.xml.in
@@ -0,0 +1,165 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Goobox
+
+ Copyright © 2011 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+-->
+<schemalist>
+
+ <enum id="org.gnome.Goobox.ToolbarStyle">
+ <value nick="system" value="0"/>
+ <value nick="text-below" value="1"/>
+ <value nick="text-beside" value="2"/>
+ <value nick="icons-only" value="3"/>
+ </enum>
+
+ <enum id="org.gnome.Goobox.SortMethod">
+ <value nick="number" value="0"/>
+ <value nick="time" value="1"/>
+ <value nick="title" value="2"/>
+ </enum>
+
+ <enum id="org.gnome.Goobox.SortType">
+ <value nick="ascending" value="0"/>
+ <value nick="descending" value="1"/>
+ </enum>
+
+ <enum id="org.gnome.Goobox.FileFormat">
+ <value nick="ogg" value="0"/>
+ <value nick="flac" value="1"/>
+ <value nick="wave" value="2"/>
+ </enum>
+
+ <schema id="org.gnome.Goobox" path="/org/gnome/goobox/">
+ <child name="general" schema="org.gnome.Goobox.General"/>
+ <child name="ui" schema="org.gnome.Goobox.UI"/>
+ <child name="playlist" schema="org.gnome.Goobox.Playlist"/>
+ <child name="ripper" schema="org.gnome.Goobox.Ripper"/>
+ <child name="encoder" schema="org.gnome.Goobox.Encoder"/>
+ </schema>
+
+ <schema id="org.gnome.Goobox.General" path="/org/gnome/goobox/general/">
+ <key name="device" type="s">
+ <default>'/dev/cdrom'</default>
+ <_summary>Device path</_summary>
+ </key>
+ <key name="volume" type="i">
+ <default>100</default>
+ <_summary>Volume level</_summary>
+ </key>
+ <key name="cover-path" type="s">
+ <default>'~'</default>
+ <_summary>'Choose cover' location</_summary>
+ <_description>Default location for the 'Choose cover' dialog.</_description>
+ </key>
+ <key name="use-sound-juicer" type="b">
+ <default>false</default>
+ <_summary>Use Sound Juicer to rip discs</_summary>
+ </key>
+ <key name="autoplay" type="b">
+ <default>true</default>
+ <_summary>Autoplay</_summary>
+ <_description>Autoplay discs after insertion.</_description>
+ </key>
+ </schema>
+
+ <schema id="org.gnome.Goobox.UI" path="/org/gnome/goobox/ui/">
+ <key name="toolbar-style" enum="org.gnome.Goobox.ToolbarStyle">
+ <default>'system'</default>
+ <_summary>Toolbar style</_summary>
+ </key>
+ <key name="window-width" type="i">
+ <default>200</default>
+ <_summary>Window width</_summary>
+ </key>
+ <key name="window-height" type="i">
+ <default>400</default>
+ <_summary>Window height</_summary>
+ </key>
+ <key name="toolbar-visible" type="b">
+ <default>true</default>
+ <_summary>Toolbar visibility</_summary>
+ </key>
+ <key name="statusbar-visible" type="b">
+ <default>false</default>
+ <_summary>Statusbar visibility</_summary>
+ </key>
+ <key name="playlist-visible" type="b">
+ <default>true</default>
+ <_summary>Playlist visibility</_summary>
+ </key>
+ </schema>
+
+ <schema id="org.gnome.Goobox.Playlist" path="/org/gnome/goobox/playlist/">
+ <key name="play-all" type="b">
+ <default>true</default>
+ <_summary>Play all tracks</_summary>
+ </key>
+ <key name="shuffle" type="b">
+ <default>false</default>
+ <_summary>Shuffle playlist</_summary>
+ </key>
+ <key name="repeat" type="b">
+ <default>false</default>
+ <_summary>Restart when finished</_summary>
+ </key>
+ <key name="sort-method" enum="org.gnome.Goobox.SortMethod">
+ <default>'number'</default>
+ <_summary>Playlist sort method</_summary>
+ </key>
+ <key name="sort-type" enum="org.gnome.Goobox.SortType">
+ <default>'ascending'</default>
+ <_summary>Playlist sort type</_summary>
+ </key>
+ </schema>
+
+ <schema id="org.gnome.Goobox.Ripper" path="/org/gnome/goobox/ripper/">
+ <key name="destination" type="s">
+ <default>''</default>
+ <_summary>Extraction folder</_summary>
+ </key>
+ <key name="file-type" enum="org.gnome.Goobox.FileFormat">
+ <default>'ogg'</default>
+ <_summary>File type</_summary>
+ <_description>Possible values are: ogg, flac, mp3, wave.</_description>
+ </key>
+ <key name="save-playlist" type="b">
+ <default>true</default>
+ <_summary>Save the playlist</_summary>
+ <_description>Save the playlist of the extracted tracks.</_description>
+ </key>
+ <key name="view-destination" type="b">
+ <default>false</default>
+ <_summary>View the destination</_summary>
+ </key>
+ </schema>
+
+ <schema id="org.gnome.Goobox.Encoder" path="/org/gnome/goobox/encoder/">
+ <key name="ogg-quality" type="d">
+ <default>0.5</default>
+ <_summary>OGG files quality</_summary>
+ </key>
+ <key name="flac-compression" type="i">
+ <default>5</default>
+ <_summary>FLAC files quality</_summary>
+ </key>
+ <key name="mp3-quality" type="i">
+ <default>4</default>
+ <_summary>MP3 files quality</_summary>
+ </key>
+ </schema>
+
+</schemalist>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index f04791e..be1c5cc 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -8,7 +8,6 @@ copy-n-paste/eggsmclient.h
copy-n-paste/eggsmclient-private.h
copy-n-paste/eggsmclient-xsmp.c
data/goobox.desktop.in.in
-data/goobox.schemas.in
[type: gettext/glade]data/ui/cover-chooser.ui
[type: gettext/glade]data/ui/extract.ui
[type: gettext/glade]data/ui/format-options.ui
@@ -29,8 +28,6 @@ src/dlg-properties.c
src/dlg-properties.h
src/dlg-ripper.c
src/dlg-ripper.h
-src/gconf-utils.c
-src/gconf-utils.h
src/gio-utils.c
src/gio-utils.h
src/glib-utils.c
@@ -62,7 +59,6 @@ src/main.c
src/main.h
src/metadata.c
src/metadata.h
-src/preferences.c
src/preferences.h
src/track-info.c
src/track-info.h
diff --git a/src/Makefile.am b/src/Makefile.am
index cb3130e..9feb4b9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -73,7 +73,6 @@ goobox_SOURCES = \
main.h \
metadata.c \
metadata.h \
- preferences.c \
preferences.h \
track-info.c \
track-info.h \
diff --git a/src/actions.c b/src/actions.c
index 2cf58a2..f07a65a 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -184,7 +184,12 @@ void
activate_action_view_toolbar (GtkAction *action,
gpointer data)
{
- eel_gconf_set_boolean (PREF_UI_TOOLBAR, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
+ GSettings *settings;
+
+ settings = g_settings_new (GOOBOX_SCHEMA_UI);
+ g_settings_set_boolean (settings, PREF_UI_TOOLBAR, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
+
+ g_object_unref (settings);
}
@@ -192,7 +197,12 @@ void
activate_action_view_statusbar (GtkAction *action,
gpointer data)
{
- eel_gconf_set_boolean (PREF_UI_STATUSBAR, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
+ GSettings *settings;
+
+ settings = g_settings_new (GOOBOX_SCHEMA_UI);
+ g_settings_set_boolean (settings, PREF_UI_STATUSBAR, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
+
+ g_object_unref (settings);
}
@@ -200,7 +210,12 @@ void
activate_action_play_all (GtkAction *action,
gpointer data)
{
- eel_gconf_set_boolean (PREF_PLAYLIST_PLAYALL, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
+ GSettings *settings;
+
+ settings = g_settings_new (GOOBOX_SCHEMA_PLAYLIST);
+ g_settings_set_boolean (settings, PREF_PLAYLIST_PLAYALL, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
+
+ g_object_unref (settings);
}
@@ -208,7 +223,12 @@ void
activate_action_repeat (GtkAction *action,
gpointer data)
{
- eel_gconf_set_boolean (PREF_PLAYLIST_REPEAT, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
+ GSettings *settings;
+
+ settings = g_settings_new (GOOBOX_SCHEMA_PLAYLIST);
+ g_settings_set_boolean (settings, PREF_PLAYLIST_REPEAT, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
+
+ g_object_unref (settings);
}
@@ -216,7 +236,12 @@ void
activate_action_shuffle (GtkAction *action,
gpointer data)
{
- eel_gconf_set_boolean (PREF_PLAYLIST_SHUFFLE, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
+ GSettings *settings;
+
+ settings = g_settings_new (GOOBOX_SCHEMA_PLAYLIST);
+ g_settings_set_boolean (settings, PREF_PLAYLIST_SHUFFLE, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
+
+ g_object_unref (settings);
}
@@ -245,18 +270,18 @@ exec_external_app (GdkScreen *screen,
if (! g_shell_parse_argv (command_line, NULL, &argv, error))
return FALSE;
- retval = gdk_spawn_on_screen (screen,
- NULL,
- argv,
- NULL,
- G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
- NULL,
- NULL,
- &child_pid,
- error);
- g_strfreev (argv);
+ retval = g_spawn_async (NULL,
+ argv,
+ NULL,
+ G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
+ NULL,
+ NULL,
+ &child_pid,
+ error);
g_child_watch_add (child_pid, external_app_watch_func, data);
+ g_strfreev (argv);
+
return retval;
}
@@ -294,9 +319,15 @@ activate_action_extract (GtkAction *action,
gpointer data)
{
GooWindow *window = data;
+ GSettings *settings;
+ gboolean use_sound_juicer;
GError *error = NULL;
- if (! preferences_get_use_sound_juicer ()) {
+ settings = g_settings_new (GOOBOX_SCHEMA_GENERAL);
+ use_sound_juicer = g_settings_get_boolean (settings, PREF_GENERAL_USE_SJ);
+ g_object_unref (settings);
+
+ if (! use_sound_juicer) {
dlg_extract (window);
return;
}
@@ -321,9 +352,15 @@ activate_action_extract_selected (GtkAction *action,
gpointer data)
{
GooWindow *window = data;
+ GSettings *settings;
+ gboolean use_sound_juicer;
GError *error = NULL;
- if (! preferences_get_use_sound_juicer ()) {
+ settings = g_settings_new (GOOBOX_SCHEMA_GENERAL);
+ use_sound_juicer = g_settings_get_boolean (settings, PREF_GENERAL_USE_SJ);
+ g_object_unref (settings);
+
+ if (! use_sound_juicer) {
dlg_extract_selected (window);
return;
}
diff --git a/src/dlg-extract.c b/src/dlg-extract.c
index 29d061e..1ac0775 100644
--- a/src/dlg-extract.c
+++ b/src/dlg-extract.c
@@ -149,8 +149,6 @@ dlg_extract_ask (GooWindow *window)
data->selected_tracks = goo_window_get_tracks (window, TRUE);
data->player = g_object_ref (goo_window_get_player (window));
- eel_gconf_preload_cache ("/apps/goobox/dialogs/extract", GCONF_CLIENT_PRELOAD_ONELEVEL);
-
/* Get the widgets. */
data->dialog = GET_WIDGET ("extract_dialog");
diff --git a/src/dlg-preferences.c b/src/dlg-preferences.c
index 69736ec..0738e68 100644
--- a/src/dlg-preferences.c
+++ b/src/dlg-preferences.c
@@ -25,13 +25,13 @@
#include <gtk/gtk.h>
#include <gst/gst.h>
#include "goo-window.h"
+#include "glib-utils.h"
#include "gtk-utils.h"
#include "preferences.h"
#include "typedefs.h"
+
#define N_VALUES 10
-#define DEFAULT_OGG_QUALITY 0.5
-#define DEFAULT_FLAC_COMPRESSION 5
#define GET_WIDGET(x) _gtk_builder_get_widget (data->builder, (x))
@@ -49,6 +49,8 @@ static int flac_compression[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
typedef struct {
GooWindow *window;
GtkBuilder *builder;
+ GSettings *settings_general;
+ GSettings *settings_ripper;
GtkWidget *dialog;
GtkWidget *drive_selector;
GtkWidget *filetype_combobox;
@@ -66,11 +68,11 @@ apply_button_clicked_cb (GtkWidget *widget,
BraseroDrive *drive;
destination = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (GET_WIDGET ("destination_filechooserbutton")));
- eel_gconf_set_uri (PREF_EXTRACT_DESTINATION, destination);
+ g_settings_set_string (data->settings_ripper, PREF_RIPPER_DESTINATION, destination);
- pref_set_file_format (gtk_combo_box_get_active (GTK_COMBO_BOX (data->filetype_combobox)));
- eel_gconf_set_boolean (PREF_EXTRACT_SAVE_PLAYLIST, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("save_playlist_checkbutton"))));
- eel_gconf_set_boolean (PREF_GENERAL_AUTOPLAY, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("autoplay_checkbutton"))));
+ g_settings_set_enum (data->settings_ripper, PREF_RIPPER_FILETYPE, gtk_combo_box_get_active (GTK_COMBO_BOX (data->filetype_combobox)));
+ g_settings_set_boolean (data->settings_ripper, PREF_RIPPER_SAVE_PLAYLIST, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("save_playlist_checkbutton"))));
+ g_settings_set_boolean (data->settings_general, PREF_GENERAL_AUTOPLAY, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("autoplay_checkbutton"))));
/**/
@@ -78,7 +80,7 @@ apply_button_clicked_cb (GtkWidget *widget,
if (drive == NULL)
return;
- eel_gconf_set_string (PREF_GENERAL_DEVICE, brasero_drive_get_device (drive));
+ g_settings_set_string (data->settings_general, PREF_GENERAL_DEVICE, brasero_drive_get_device (drive));
goo_window_set_drive (data->window, drive);
g_object_unref (drive);
@@ -92,6 +94,8 @@ dialog_destroy_cb (GtkWidget *widget,
apply_button_clicked_cb (widget, data);
data->window->preferences_dialog = NULL;
+ _g_object_unref (data->settings_general);
+ _g_object_unref (data->settings_ripper);
g_object_unref (data->builder);
g_free (data);
}
@@ -180,8 +184,8 @@ dlg_preferences (GooWindow *window)
data = g_new0 (DialogData, 1);
data->window = window;
data->builder = _gtk_builder_new_from_file ("preferences.ui", "");
-
- eel_gconf_preload_cache ("/apps/goobox/general", GCONF_CLIENT_PRELOAD_ONELEVEL);
+ data->settings_general = g_settings_new (GOOBOX_SCHEMA_GENERAL);
+ data->settings_ripper = g_settings_new (GOOBOX_SCHEMA_RIPPER);
/* Get the widgets. */
@@ -190,7 +194,7 @@ dlg_preferences (GooWindow *window)
/* Set widgets data. */
- if (preferences_get_use_sound_juicer ()) {
+ if (g_settings_get_boolean (data->settings_general, PREF_GENERAL_USE_SJ)) {
GtkWidget *notebook;
GtkWidget *encoder_page;
@@ -226,7 +230,7 @@ dlg_preferences (GooWindow *window)
/**/
- destination = eel_gconf_get_uri (PREF_EXTRACT_DESTINATION, "");
+ destination = g_settings_get_string (data->settings_ripper, PREF_RIPPER_DESTINATION);
if ((destination == NULL) || (strcmp (destination, "") == 0))
destination = g_filename_to_uri (g_get_user_special_dir (G_USER_DIRECTORY_MUSIC), NULL, NULL);
if (destination == NULL)
@@ -270,8 +274,7 @@ dlg_preferences (GooWindow *window)
if (encoder != NULL)
gst_object_unref (GST_OBJECT (encoder));
- file_format = pref_get_file_format ();
-
+ file_format = g_settings_get_enum (data->settings_ripper, PREF_RIPPER_FILETYPE);
find_first_available = (((file_format == GOO_FILE_FORMAT_OGG) && !ogg_encoder)
|| ((file_format == GOO_FILE_FORMAT_FLAC) && !flac_encoder)
|| ((file_format == GOO_FILE_FORMAT_WAVE) && !wave_encoder));
@@ -294,8 +297,8 @@ dlg_preferences (GooWindow *window)
set_description_label (data, "flac_description_label", _("Free Lossless Audio Codec (FLAC) is an open source codec that compresses but does not degrade audio quality."));
set_description_label (data, "wave_description_label", _("WAV+PCM is a lossless format that holds uncompressed, raw pulse-code modulated (PCM) audio."));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("save_playlist_checkbutton")), eel_gconf_get_boolean (PREF_EXTRACT_SAVE_PLAYLIST, TRUE));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("autoplay_checkbutton")), eel_gconf_get_boolean (PREF_GENERAL_AUTOPLAY, TRUE));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("save_playlist_checkbutton")), g_settings_get_boolean (data->settings_ripper, PREF_RIPPER_SAVE_PLAYLIST));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("autoplay_checkbutton")), g_settings_get_boolean (data->settings_general, PREF_GENERAL_AUTOPLAY));
/**/
@@ -344,7 +347,7 @@ dlg_preferences (GooWindow *window)
typedef struct {
GooFileFormat format;
int value;
-
+ GSettings *settings_encoder;
GtkBuilder *builder;
GtkWidget *dialog;
GtkWidget *f_quality_label;
@@ -356,6 +359,7 @@ static void
format_dialog_destroy_cb (GtkWidget *widget,
FormatDialogData *data)
{
+ g_object_unref (data->settings_encoder);
g_object_unref (data->builder);
g_free (data);
}
@@ -367,10 +371,10 @@ format_dialog_ok_button_clicked_cb (GtkWidget *widget,
{
switch (data->format) {
case GOO_FILE_FORMAT_OGG:
- eel_gconf_set_float (PREF_ENCODER_OGG_QUALITY, (float) data->value / 10.0);
+ g_settings_set_double (data->settings_encoder, PREF_ENCODER_OGG_QUALITY, (float) data->value / 10.0);
break;
case GOO_FILE_FORMAT_FLAC:
- eel_gconf_set_integer (PREF_ENCODER_FLAC_COMPRESSION, flac_compression[data->value]);
+ g_settings_set_int (data->settings_encoder, PREF_ENCODER_FLAC_COMPRESSION, flac_compression[data->value]);
break;
default:
break;
@@ -400,17 +404,18 @@ find_index (int a[], int v)
static int
-get_current_value (GooFileFormat format)
+get_current_value (FormatDialogData *data,
+ GooFileFormat format)
{
- int index = 0;
- int value;
+ int index = 0;
+ int value;
switch (format) {
case GOO_FILE_FORMAT_OGG:
- index = (int) (eel_gconf_get_float (PREF_ENCODER_OGG_QUALITY, DEFAULT_OGG_QUALITY) * 10.0 + 0.05);
+ index = (int) (g_settings_get_double (data->settings_encoder, PREF_ENCODER_OGG_QUALITY) * 10.0 + 0.05);
break;
case GOO_FILE_FORMAT_FLAC:
- value = eel_gconf_get_integer (PREF_ENCODER_FLAC_COMPRESSION, DEFAULT_FLAC_COMPRESSION);
+ value = g_settings_get_int (data->settings_encoder, PREF_ENCODER_FLAC_COMPRESSION);
index = find_index (flac_compression, value);
break;
default:
@@ -437,6 +442,7 @@ dlg_format (DialogData *preferences_data,
data = g_new0 (FormatDialogData, 1);
data->format = format;
+ data->settings_encoder = g_settings_new (GOOBOX_SCHEMA_ENCODER);
data->builder = _gtk_builder_new_from_file ("format-options.ui", "");
data->dialog = GET_WIDGET ("format_dialog");
@@ -465,7 +471,7 @@ dlg_format (DialogData *preferences_data,
g_free (text);
}
- data->value = get_current_value (format);
+ data->value = get_current_value (data, format);
gtk_range_set_value (GTK_RANGE (GET_WIDGET ("quality_scale")), scale_value (data->value));
switch (format) {
diff --git a/src/dlg-ripper.c b/src/dlg-ripper.c
index 5777e56..729b464 100644
--- a/src/dlg-ripper.c
+++ b/src/dlg-ripper.c
@@ -33,12 +33,9 @@
#define TOC_OFFSET 150
-#define GLADE_RIPPER_FILE "ripper_dialog.glade"
#define DESTINATION_PERMISSIONS 0755
#define PLS_PERMISSIONS 0644
#define UPDATE_DELAY 400
-#define DEFAULT_OGG_QUALITY 0.5
-#define DEFAULT_FLAC_COMPRESSION 5
#define BUFFER_SIZE 1024
#define GET_WIDGET(x) _gtk_builder_get_widget (data->builder, (x))
@@ -72,6 +69,8 @@ typedef struct {
double prev_remaining_time;
GtkBuilder *builder;
+ GSettings *settings_ripper;
+ GSettings *settings_encoder;
GtkWidget *dialog;
} DialogData;
@@ -113,7 +112,9 @@ dialog_destroy_cb (GtkWidget *widget,
g_free (data->destination);
_g_object_unref (data->current_file);
track_list_free (data->tracks);
- g_object_unref (data->builder);
+ _g_object_unref (data->builder);
+ _g_object_unref (data->settings_encoder);
+ _g_object_unref (data->settings_ripper);
g_free (data);
}
@@ -275,7 +276,7 @@ create_pipeline (DialogData *data)
case GOO_FILE_FORMAT_OGG:
data->ext = "ogg";
data->encoder = gst_element_factory_make (OGG_ENCODER, "encoder");
- ogg_quality = eel_gconf_get_float (PREF_ENCODER_OGG_QUALITY, DEFAULT_OGG_QUALITY);
+ ogg_quality = g_settings_get_double (data->settings_encoder, PREF_ENCODER_OGG_QUALITY);
g_object_set (data->encoder,
"quality", ogg_quality,
NULL);
@@ -285,7 +286,7 @@ create_pipeline (DialogData *data)
case GOO_FILE_FORMAT_FLAC:
data->ext = "flac";
data->encoder = data->container = gst_element_factory_make (FLAC_ENCODER, "encoder");
- flac_compression = eel_gconf_get_integer (PREF_ENCODER_FLAC_COMPRESSION, DEFAULT_FLAC_COMPRESSION);
+ flac_compression = g_settings_get_double (data->settings_encoder, PREF_ENCODER_FLAC_COMPRESSION);
g_object_set (data->encoder,
"quality", flac_compression,
NULL);
@@ -446,7 +447,7 @@ done_dialog_response_cb (GtkDialog *dialog,
gtk_widget_destroy (GTK_WIDGET (dialog));
- if ((button_number == GTK_RESPONSE_OK) && eel_gconf_get_boolean (PREF_RIPPER_VIEW_DISTINATION, FALSE)) {
+ if ((button_number == GTK_RESPONSE_OK) && g_settings_get_boolean (data->settings_ripper, PREF_RIPPER_VIEW_DISTINATION)) {
GFile *folder;
GError *error = NULL;
@@ -578,7 +579,7 @@ rip_current_track (DialogData *data)
if (data->current_track == NULL) {
GtkWidget *d;
- if (eel_gconf_get_boolean (PREF_EXTRACT_SAVE_PLAYLIST, TRUE))
+ if (g_settings_get_boolean (data->settings_ripper, PREF_RIPPER_SAVE_PLAYLIST))
save_playlist (data);
data->ripping = FALSE;
@@ -590,6 +591,7 @@ rip_current_track (DialogData *data)
_("Tracks extracted successfully"),
GTK_STOCK_OK,
_("_View destination folder"),
+ data->settings_ripper,
PREF_RIPPER_VIEW_DISTINATION);
g_signal_connect (G_OBJECT (d), "response",
@@ -726,15 +728,17 @@ dlg_ripper (GooWindow *window,
data = g_new0 (DialogData, 1);
data->window = window;
+ data->settings_ripper = g_settings_new (GOOBOX_SCHEMA_RIPPER);
+ data->settings_encoder = g_settings_new (GOOBOX_SCHEMA_ENCODER);
data->builder = _gtk_builder_new_from_file ("ripper.ui", "");
data->dialog = GET_WIDGET ("ripper_dialog");
- data->destination = eel_gconf_get_uri (PREF_EXTRACT_DESTINATION, "");
+ data->destination = g_settings_get_string (data->settings_ripper, PREF_RIPPER_DESTINATION);
if ((data->destination == NULL) || (strcmp (data->destination, "") == 0))
data->destination = g_filename_to_uri (g_get_user_special_dir (G_USER_DIRECTORY_MUSIC), NULL, NULL);
if (data->destination == NULL)
data->destination = g_filename_to_uri (g_get_home_dir (), NULL, NULL);
data->drive = g_object_ref (goo_player_get_drive (player));
- data->format = pref_get_file_format ();
+ data->format = g_settings_get_enum (data->settings_ripper, PREF_RIPPER_FILETYPE);
data->album = goo_player_get_album (player);
if (tracks != NULL)
data->tracks = track_list_dup (tracks);
diff --git a/src/gnome-desktop-thumbnail.c b/src/gnome-desktop-thumbnail.c
index 5849ccf..2b2fda9 100644
--- a/src/gnome-desktop-thumbnail.c
+++ b/src/gnome-desktop-thumbnail.c
@@ -2,6 +2,7 @@
* gnome-thumbnail.c: Utilities for handling thumbnails
*
* Copyright (C) 2002 Red Hat, Inc.
+ * Copyright (C) 2010 Carlos Garcia Campos <carlosgc gnome org>
*
* This file is part of the Gnome Library.
*
@@ -46,16 +47,22 @@
#define SECONDS_BETWEEN_STATS 10
struct _GnomeDesktopThumbnailFactoryPrivate {
- char *application;
GnomeDesktopThumbnailSize size;
GMutex *lock;
- GHashTable *scripts_hash;
- guint thumbnailers_notify;
- guint reread_scheduled;
+ GList *thumbnailers;
+ GHashTable *mime_types_map;
+ GList *monitors;
+
+ GSettings *settings;
+ gboolean loaded : 1;
+ gboolean disabled : 1;
+ gchar **disabled_types;
};
+static const char *appname = "gnome-thumbnail-factory";
+
static void gnome_desktop_thumbnail_factory_init (GnomeDesktopThumbnailFactory *factory);
static void gnome_desktop_thumbnail_factory_class_init (GnomeDesktopThumbnailFactoryClass *class);
@@ -64,6 +71,9 @@ G_DEFINE_TYPE (GnomeDesktopThumbnailFactory,
G_TYPE_OBJECT)
#define parent_class gnome_desktop_thumbnail_factory_parent_class
+#define GNOME_DESKTOP_THUMBNAIL_FACTORY_GET_PRIVATE(object) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((object), GNOME_DESKTOP_TYPE_THUMBNAIL_FACTORY, GnomeDesktopThumbnailFactoryPrivate))
+
typedef struct {
gint width;
gint height;
@@ -74,22 +84,190 @@ typedef struct {
#define LOAD_BUFFER_SIZE 4096
+#define THUMBNAILER_ENTRY_GROUP "Thumbnailer Entry"
+#define THUMBNAILER_EXTENSION ".thumbnailer"
+
+typedef struct {
+ volatile gint ref_count;
+
+ gchar *path;
+
+ gchar *try_exec;
+ gchar *command;
+ gchar **mime_types;
+} Thumbnailer;
+
+static Thumbnailer *
+thumbnailer_ref (Thumbnailer *thumb)
+{
+ g_return_val_if_fail (thumb != NULL, NULL);
+ g_return_val_if_fail (thumb->ref_count > 0, NULL);
+
+ g_atomic_int_inc (&thumb->ref_count);
+ return thumb;
+}
+
+static void
+thumbnailer_unref (Thumbnailer *thumb)
+{
+ g_return_if_fail (thumb != NULL);
+ g_return_if_fail (thumb->ref_count > 0);
+
+ if (g_atomic_int_dec_and_test (&thumb->ref_count))
+ {
+ g_free (thumb->path);
+ g_free (thumb->try_exec);
+ g_free (thumb->command);
+ g_strfreev (thumb->mime_types);
+
+ g_slice_free (Thumbnailer, thumb);
+ }
+}
+
+static Thumbnailer *
+thumbnailer_load (Thumbnailer *thumb)
+{
+ GKeyFile *key_file;
+ GError *error = NULL;
+
+ key_file = g_key_file_new ();
+ if (!g_key_file_load_from_file (key_file, thumb->path, 0, &error))
+ {
+ g_warning ("Failed to load thumbnailer from \"%s\": %s\n", thumb->path, error->message);
+ g_error_free (error);
+ thumbnailer_unref (thumb);
+ g_key_file_free (key_file);
+
+ return NULL;
+ }
+
+ if (!g_key_file_has_group (key_file, THUMBNAILER_ENTRY_GROUP))
+ {
+ g_warning ("Invalid thumbnailer: missing group \"%s\"\n", THUMBNAILER_ENTRY_GROUP);
+ thumbnailer_unref (thumb);
+ g_key_file_free (key_file);
+
+ return NULL;
+ }
+
+ thumb->command = g_key_file_get_string (key_file, THUMBNAILER_ENTRY_GROUP, "Exec", NULL);
+ if (!thumb->command)
+ {
+ g_warning ("Invalid thumbnailer: missing Exec key\n");
+ thumbnailer_unref (thumb);
+ g_key_file_free (key_file);
+
+ return NULL;
+ }
+
+ thumb->mime_types = g_key_file_get_string_list (key_file, THUMBNAILER_ENTRY_GROUP, "MimeType", NULL, NULL);
+ if (!thumb->mime_types)
+ {
+ g_warning ("Invalid thumbnailer: missing MimeType key\n");
+ thumbnailer_unref (thumb);
+ g_key_file_free (key_file);
+
+ return NULL;
+ }
+
+ thumb->try_exec = g_key_file_get_string (key_file, THUMBNAILER_ENTRY_GROUP, "TryExec", NULL);
+
+ g_key_file_free (key_file);
+
+ return thumb;
+}
+
+static Thumbnailer *
+thumbnailer_reload (Thumbnailer *thumb)
+{
+ g_return_val_if_fail (thumb != NULL, NULL);
+
+ g_free (thumb->command);
+ thumb->command = NULL;
+ g_strfreev (thumb->mime_types);
+ thumb->mime_types = NULL;
+ g_free (thumb->try_exec);
+ thumb->try_exec = NULL;
+
+ return thumbnailer_load (thumb);
+}
+
+static Thumbnailer *
+thumbnailer_new (const gchar *path)
+{
+ Thumbnailer *thumb;
+
+ thumb = g_slice_new0 (Thumbnailer);
+ thumb->ref_count = 1;
+ thumb->path = g_strdup (path);
+
+ return thumbnailer_load (thumb);
+}
+
+static gboolean
+thumbnailer_try_exec (Thumbnailer *thumb)
+{
+ gchar *path;
+ gboolean retval;
+
+ if (G_UNLIKELY (!thumb))
+ return FALSE;
+
+ /* TryExec is optinal, but Exec isn't, so we assume
+ * the thumbnailer can be run when TryExec is not present
+ */
+ if (!thumb->try_exec)
+ return TRUE;
+
+ path = g_find_program_in_path (thumb->try_exec);
+ retval = path != NULL;
+ g_free (path);
+
+ return retval;
+}
+
+static gpointer
+init_thumbnailers_dirs (gpointer data)
+{
+ const gchar * const *data_dirs;
+ gchar **thumbs_dirs;
+ guint i, length;
+
+ data_dirs = g_get_system_data_dirs ();
+ length = g_strv_length ((char **) data_dirs);
+
+ thumbs_dirs = g_new (gchar *, length + 2);
+ thumbs_dirs[0] = g_build_filename (g_get_user_data_dir (), "thumbnailers", NULL);
+ for (i = 0; i < length; i++)
+ thumbs_dirs[i + 1] = g_build_filename (data_dirs[i], "thumbnailers", NULL);
+ thumbs_dirs[length + 1] = NULL;
+
+ return thumbs_dirs;
+}
+
+static const gchar * const *
+get_thumbnailers_dirs (void)
+{
+ static GOnce once_init = G_ONCE_INIT;
+ return g_once (&once_init, init_thumbnailers_dirs, NULL);
+}
+
static void
-size_prepared_cb (GdkPixbufLoader *loader,
+size_prepared_cb (GdkPixbufLoader *loader,
int width,
int height,
gpointer data)
{
SizePrepareContext *info = data;
-
+
g_return_if_fail (width > 0 && height > 0);
-
+
info->input_width = width;
info->input_height = height;
-
+
if (width < info->width && height < info->height) return;
-
- if (info->preserve_aspect_ratio &&
+
+ if (info->preserve_aspect_ratio &&
(info->width > 0 || info->height > 0)) {
if (info->width < 0)
{
@@ -115,7 +293,7 @@ size_prepared_cb (GdkPixbufLoader *loader,
if (info->height > 0)
height = info->height;
}
-
+
gdk_pixbuf_loader_set_size (loader, width, height);
}
@@ -129,22 +307,48 @@ _gdk_pixbuf_new_from_uri_at_scale (const char *uri,
char buffer[LOAD_BUFFER_SIZE];
gsize bytes_read;
GdkPixbufLoader *loader;
- GdkPixbuf *pixbuf;
+ GdkPixbuf *pixbuf;
GdkPixbufAnimation *animation;
GdkPixbufAnimationIter *iter;
gboolean has_frame;
SizePrepareContext info;
GFile *file;
+ GFileInfo *file_info;
GInputStream *input_stream;
g_return_val_if_fail (uri != NULL, NULL);
+ input_stream = NULL;
+
file = g_file_new_for_uri (uri);
- input_stream = G_INPUT_STREAM (g_file_read (file, NULL, NULL));
+ /* First see if we can get an input stream via preview::icon */
+ file_info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_PREVIEW_ICON,
+ G_FILE_QUERY_INFO_NONE,
+ NULL, /* GCancellable */
+ NULL); /* return location for GError */
+ if (file_info != NULL) {
+ GObject *object;
+
+ object = g_file_info_get_attribute_object (file_info,
+ G_FILE_ATTRIBUTE_PREVIEW_ICON);
+ if (object != NULL && G_IS_LOADABLE_ICON (object)) {
+ input_stream = g_loadable_icon_load (G_LOADABLE_ICON (object),
+ 0, /* size */
+ NULL, /* return location for type */
+ NULL, /* GCancellable */
+ NULL); /* return location for GError */
+ }
+ g_object_unref (file_info);
+ }
+
if (input_stream == NULL) {
- g_object_unref (file);
- return NULL;
+ input_stream = G_INPUT_STREAM (g_file_read (file, NULL, NULL));
+ if (input_stream == NULL) {
+ g_object_unref (file);
+ return NULL;
+ }
}
loader = gdk_pixbuf_loader_new ();
@@ -152,7 +356,7 @@ _gdk_pixbuf_new_from_uri_at_scale (const char *uri,
info.width = width;
info.height = height;
info.input_width = info.input_height = 0;
- info.preserve_aspect_ratio = preserve_aspect_ratio;
+ info.preserve_aspect_ratio = preserve_aspect_ratio;
g_signal_connect (loader, "size-prepared", G_CALLBACK (size_prepared_cb), &info);
}
@@ -224,31 +428,27 @@ gnome_desktop_thumbnail_factory_finalize (GObject *object)
{
GnomeDesktopThumbnailFactory *factory;
GnomeDesktopThumbnailFactoryPrivate *priv;
- GConfClient *client;
-
+
factory = GNOME_DESKTOP_THUMBNAIL_FACTORY (object);
priv = factory->priv;
- g_free (priv->application);
- priv->application = NULL;
-
- if (priv->reread_scheduled != 0) {
- g_source_remove (priv->reread_scheduled);
- priv->reread_scheduled = 0;
- }
+ if (priv->thumbnailers)
+ {
+ g_list_free_full (priv->thumbnailers, (GDestroyNotify)thumbnailer_unref);
+ priv->thumbnailers = NULL;
+ }
- if (priv->thumbnailers_notify != 0) {
- client = gconf_client_get_default ();
- gconf_client_notify_remove (client, priv->thumbnailers_notify);
- priv->thumbnailers_notify = 0;
- g_object_unref (client);
- }
+ if (priv->mime_types_map)
+ {
+ g_hash_table_destroy (priv->mime_types_map);
+ priv->mime_types_map = NULL;
+ }
- if (priv->scripts_hash)
+ if (priv->monitors)
{
- g_hash_table_destroy (priv->scripts_hash);
- priv->scripts_hash = NULL;
+ g_list_free_full (priv->monitors, (GDestroyNotify)g_object_unref);
+ priv->monitors = NULL;
}
if (priv->lock)
@@ -257,173 +457,313 @@ gnome_desktop_thumbnail_factory_finalize (GObject *object)
priv->lock = NULL;
}
- g_free (priv);
- factory->priv = NULL;
+ if (priv->disabled_types)
+ {
+ g_strfreev (priv->disabled_types);
+ priv->disabled_types = NULL;
+ }
+
+ if (priv->settings)
+ {
+ g_object_unref (priv->settings);
+ priv->settings = NULL;
+ }
if (G_OBJECT_CLASS (parent_class)->finalize)
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
-/* Must be called on main thread */
-static GHashTable *
-read_scripts (void)
+/* These should be called with the lock held */
+static void
+gnome_desktop_thumbnail_factory_register_mime_types (GnomeDesktopThumbnailFactory *factory,
+ Thumbnailer *thumb)
{
- GHashTable *scripts_hash;
- GConfClient *client;
- GSList *subdirs, *l;
- char *subdir, *enable, *escape, *commandkey, *command, *mimetype;
-
- client = gconf_client_get_default ();
+ GnomeDesktopThumbnailFactoryPrivate *priv = factory->priv;
+ gint i;
- if (gconf_client_get_bool (client,
- "/desktop/gnome/thumbnailers/disable_all",
- NULL))
+ for (i = 0; thumb->mime_types[i]; i++)
{
- g_object_unref (G_OBJECT (client));
- return NULL;
+ if (!g_hash_table_lookup (priv->mime_types_map, thumb->mime_types[i]))
+ g_hash_table_insert (priv->mime_types_map,
+ g_strdup (thumb->mime_types[i]),
+ thumbnailer_ref (thumb));
}
+}
- scripts_hash = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free, g_free);
+static void
+gnome_desktop_thumbnail_factory_add_thumbnailer (GnomeDesktopThumbnailFactory *factory,
+ Thumbnailer *thumb)
+{
+ GnomeDesktopThumbnailFactoryPrivate *priv = factory->priv;
+ gnome_desktop_thumbnail_factory_register_mime_types (factory, thumb);
+ priv->thumbnailers = g_list_prepend (priv->thumbnailers, thumb);
+}
- subdirs = gconf_client_all_dirs (client, "/desktop/gnome/thumbnailers", NULL);
+static gboolean
+gnome_desktop_thumbnail_factory_is_disabled (GnomeDesktopThumbnailFactory *factory,
+ const gchar *mime_type)
+{
+ GnomeDesktopThumbnailFactoryPrivate *priv = factory->priv;
+ guint i;
- for (l = subdirs; l != NULL; l = l->next)
- {
- subdir = l->data;
+ if (priv->disabled)
+ return TRUE;
- enable = g_strdup_printf ("%s/enable", subdir);
- if (gconf_client_get_bool (client,
- enable,
- NULL))
- {
- commandkey = g_strdup_printf ("%s/command", subdir);
- command = gconf_client_get_string (client, commandkey, NULL);
- g_free (commandkey);
-
- if (command != NULL) {
- mimetype = strrchr (subdir, '/');
- if (mimetype != NULL)
- {
- mimetype++; /* skip past slash */
-
- /* Convert '@' to slash in mimetype */
- escape = strchr (mimetype, '@');
- if (escape != NULL)
- *escape = '/';
-
- /* Convert any remaining '@' to '+' in mimetype */
- while ((escape = strchr (mimetype, '@')) != NULL)
- *escape = '+';
-
- g_hash_table_insert (scripts_hash,
- g_strdup (mimetype), command);
- }
- else
- {
- g_free (command);
- }
- }
- }
- g_free (enable);
+ if (!priv->disabled_types)
+ return FALSE;
- g_free (subdir);
+ for (i = 0; priv->disabled_types[i]; i++)
+ {
+ if (g_strcmp0 (priv->disabled_types[i], mime_type) == 0)
+ return TRUE;
}
- g_slist_free(subdirs);
-
- g_object_unref (G_OBJECT (client));
+ return FALSE;
+}
- return scripts_hash;
+static gboolean
+remove_thumbnailer_from_mime_type_map (gchar *key,
+ Thumbnailer *value,
+ gchar *path)
+{
+ return (strcmp (value->path, path) == 0);
}
-/* Must be called on main thread */
static void
-gnome_desktop_thumbnail_factory_reread_scripts (GnomeDesktopThumbnailFactory *factory)
+update_or_create_thumbnailer (GnomeDesktopThumbnailFactory *factory,
+ const gchar *path)
{
GnomeDesktopThumbnailFactoryPrivate *priv = factory->priv;
- GHashTable *scripts_hash;
-
- scripts_hash = read_scripts ();
+ GList *l;
+ Thumbnailer *thumb;
+ gboolean found = FALSE;
g_mutex_lock (priv->lock);
- if (priv->scripts_hash != NULL)
- g_hash_table_destroy (priv->scripts_hash);
+ for (l = priv->thumbnailers; l && !found; l = g_list_next (l))
+ {
+ thumb = (Thumbnailer *)l->data;
+
+ if (strcmp (thumb->path, path) == 0)
+ {
+ found = TRUE;
+
+ /* First remove the mime_types associated to this thumbnailer */
+ g_hash_table_foreach_remove (priv->mime_types_map,
+ (GHRFunc)remove_thumbnailer_from_mime_type_map,
+ (gpointer)path);
+ if (!thumbnailer_reload (thumb))
+ priv->thumbnailers = g_list_delete_link (priv->thumbnailers, l);
+ else
+ gnome_desktop_thumbnail_factory_register_mime_types (factory, thumb);
+ }
+ }
- priv->scripts_hash = scripts_hash;
+ if (!found)
+ {
+ thumb = thumbnailer_new (path);
+ if (thumb)
+ gnome_desktop_thumbnail_factory_add_thumbnailer (factory, thumb);
+ }
g_mutex_unlock (priv->lock);
}
-static gboolean
-reread_idle_callback (gpointer user_data)
+static void
+remove_thumbnailer (GnomeDesktopThumbnailFactory *factory,
+ const gchar *path)
{
- GnomeDesktopThumbnailFactory *factory = user_data;
GnomeDesktopThumbnailFactoryPrivate *priv = factory->priv;
-
- gnome_desktop_thumbnail_factory_reread_scripts (factory);
+ GList *l;
+ Thumbnailer *thumb;
g_mutex_lock (priv->lock);
- priv->reread_scheduled = 0;
+
+ for (l = priv->thumbnailers; l; l = g_list_next (l))
+ {
+ thumb = (Thumbnailer *)l->data;
+
+ if (strcmp (thumb->path, path) == 0)
+ {
+ priv->thumbnailers = g_list_delete_link (priv->thumbnailers, l);
+ g_hash_table_foreach_remove (priv->mime_types_map,
+ (GHRFunc)remove_thumbnailer_from_mime_type_map,
+ (gpointer)path);
+ thumbnailer_unref (thumb);
+
+ break;
+ }
+ }
+
g_mutex_unlock (priv->lock);
+}
- return FALSE;
+static void
+thumbnailers_directory_changed (GFileMonitor *monitor,
+ GFile *file,
+ GFile *other_file,
+ GFileMonitorEvent event_type,
+ GnomeDesktopThumbnailFactory *factory)
+{
+ gchar *path;
+
+ switch (event_type)
+ {
+ case G_FILE_MONITOR_EVENT_CREATED:
+ case G_FILE_MONITOR_EVENT_CHANGED:
+ case G_FILE_MONITOR_EVENT_DELETED:
+ path = g_file_get_path (file);
+ if (!g_str_has_suffix (path, THUMBNAILER_EXTENSION))
+ {
+ g_free (path);
+ return;
+ }
+
+ if (event_type == G_FILE_MONITOR_EVENT_DELETED)
+ remove_thumbnailer (factory, path);
+ else
+ update_or_create_thumbnailer (factory, path);
+
+ g_free (path);
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+gnome_desktop_thumbnail_factory_load_thumbnailers (GnomeDesktopThumbnailFactory *factory)
+{
+ GnomeDesktopThumbnailFactoryPrivate *priv = factory->priv;
+ const gchar * const *dirs;
+ guint i;
+
+ if (priv->loaded)
+ return;
+
+ dirs = get_thumbnailers_dirs ();
+ for (i = 0; dirs[i]; i++)
+ {
+ const gchar *path = dirs[i];
+ GDir *dir;
+ GFile *dir_file;
+ GFileMonitor *monitor;
+ const gchar *dirent;
+
+ dir = g_dir_open (path, 0, NULL);
+ if (!dir)
+ continue;
+
+ /* Monitor dir */
+ dir_file = g_file_new_for_path (path);
+ monitor = g_file_monitor_directory (dir_file,
+ G_FILE_MONITOR_NONE,
+ NULL, NULL);
+ if (monitor)
+ {
+ g_signal_connect (monitor, "changed",
+ G_CALLBACK (thumbnailers_directory_changed),
+ factory);
+ priv->monitors = g_list_prepend (priv->monitors, monitor);
+ }
+ g_object_unref (dir_file);
+
+ while ((dirent = g_dir_read_name (dir)))
+ {
+ Thumbnailer *thumb;
+ gchar *filename;
+
+ if (!g_str_has_suffix (dirent, THUMBNAILER_EXTENSION))
+ continue;
+
+ filename = g_build_filename (path, dirent, NULL);
+ thumb = thumbnailer_new (filename);
+ g_free (filename);
+
+ if (thumb)
+ gnome_desktop_thumbnail_factory_add_thumbnailer (factory, thumb);
+ }
+
+ g_dir_close (dir);
+ }
+
+ priv->loaded = TRUE;
}
static void
-schedule_reread (GConfClient* client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
+external_thumbnailers_disabled_all_changed_cb (GSettings *settings,
+ const gchar *key,
+ GnomeDesktopThumbnailFactory *factory)
{
- GnomeDesktopThumbnailFactory *factory = user_data;
GnomeDesktopThumbnailFactoryPrivate *priv = factory->priv;
g_mutex_lock (priv->lock);
- if (priv->reread_scheduled == 0)
+ priv->disabled = g_settings_get_boolean (priv->settings, "disable-all");
+ if (priv->disabled)
{
- priv->reread_scheduled = g_idle_add (reread_idle_callback,
- factory);
+ g_strfreev (priv->disabled_types);
+ priv->disabled_types = NULL;
+ }
+ else
+ {
+ priv->disabled_types = g_settings_get_strv (priv->settings, "disable");
+ gnome_desktop_thumbnail_factory_load_thumbnailers (factory);
}
g_mutex_unlock (priv->lock);
}
+static void
+external_thumbnailers_disabled_changed_cb (GSettings *settings,
+ const gchar *key,
+ GnomeDesktopThumbnailFactory *factory)
+{
+ GnomeDesktopThumbnailFactoryPrivate *priv = factory->priv;
+
+ g_mutex_lock (priv->lock);
+
+ if (priv->disabled)
+ return;
+ g_strfreev (priv->disabled_types);
+ priv->disabled_types = g_settings_get_strv (priv->settings, "disable");
+
+ g_mutex_unlock (priv->lock);
+}
static void
gnome_desktop_thumbnail_factory_init (GnomeDesktopThumbnailFactory *factory)
{
- GConfClient *client;
GnomeDesktopThumbnailFactoryPrivate *priv;
-
- factory->priv = g_new0 (GnomeDesktopThumbnailFactoryPrivate, 1);
+
+ factory->priv = GNOME_DESKTOP_THUMBNAIL_FACTORY_GET_PRIVATE (factory);
priv = factory->priv;
priv->size = GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL;
- priv->application = g_strdup ("gnome-thumbnail-factory");
-
- priv->scripts_hash = NULL;
-
+
+ priv->mime_types_map = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ (GDestroyNotify)g_free,
+ (GDestroyNotify)thumbnailer_unref);
+
priv->lock = g_mutex_new ();
- gnome_desktop_thumbnail_factory_reread_scripts (factory);
-
- client = gconf_client_get_default ();
- gconf_client_add_dir (client,
- "/desktop/gnome",
- GCONF_CLIENT_PRELOAD_NONE, NULL);
-
- priv->thumbnailers_notify = gconf_client_notify_add (client, "/desktop/gnome/thumbnailers",
- schedule_reread, factory, NULL,
- NULL);
-
- g_object_unref (G_OBJECT (client));
+ priv->settings = g_settings_new ("org.gnome.desktop.thumbnailers");
+ priv->disabled = g_settings_get_boolean (priv->settings, "disable-all");
+ if (!priv->disabled)
+ priv->disabled_types = g_settings_get_strv (priv->settings, "disable");
+ g_signal_connect (priv->settings, "changed::disable-all",
+ G_CALLBACK (external_thumbnailers_disabled_all_changed_cb),
+ factory);
+ g_signal_connect (priv->settings, "changed::disable",
+ G_CALLBACK (external_thumbnailers_disabled_changed_cb),
+ factory);
+
+ if (!priv->disabled)
+ gnome_desktop_thumbnail_factory_load_thumbnailers (factory);
}
static void
@@ -432,8 +772,10 @@ gnome_desktop_thumbnail_factory_class_init (GnomeDesktopThumbnailFactoryClass *c
GObjectClass *gobject_class;
gobject_class = G_OBJECT_CLASS (class);
-
+
gobject_class->finalize = gnome_desktop_thumbnail_factory_finalize;
+
+ g_type_class_add_private (class, sizeof (GnomeDesktopThumbnailFactoryPrivate));
}
/**
@@ -443,7 +785,7 @@ gnome_desktop_thumbnail_factory_class_init (GnomeDesktopThumbnailFactoryClass *c
* Creates a new #GnomeDesktopThumbnailFactory.
*
* This function must be called on the main thread.
- *
+ *
* Return value: a new #GnomeDesktopThumbnailFactory
*
* Since: 2.2
@@ -452,11 +794,11 @@ GnomeDesktopThumbnailFactory *
gnome_desktop_thumbnail_factory_new (GnomeDesktopThumbnailSize size)
{
GnomeDesktopThumbnailFactory *factory;
-
+
factory = g_object_new (GNOME_DESKTOP_TYPE_THUMBNAIL_FACTORY, NULL);
-
+
factory->priv->size = size;
-
+
return factory;
}
@@ -498,7 +840,7 @@ gnome_desktop_thumbnail_factory_lookup (GnomeDesktopThumbnailFactory *factory,
g_assert (digest_len == 16);
file = g_strconcat (g_checksum_get_string (checksum), ".png", NULL);
-
+
path = g_build_filename (g_get_home_dir (),
".thumbnails",
(priv->size == GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL)?"normal":"large",
@@ -562,7 +904,7 @@ gnome_desktop_thumbnail_factory_has_valid_failed_thumbnail (GnomeDesktopThumbnai
path = g_build_filename (g_get_home_dir (),
".thumbnails/fail",
- factory->priv->application,
+ appname,
file,
NULL);
g_free (file);
@@ -584,38 +926,49 @@ gnome_desktop_thumbnail_factory_has_valid_failed_thumbnail (GnomeDesktopThumbnai
static gboolean
mimetype_supported_by_gdk_pixbuf (const char *mime_type)
{
- guint i;
- static GHashTable *formats_hash = NULL;
+ guint i;
+ static gsize formats_hash = 0;
+ gchar *key;
+ gboolean result;
- if (!formats_hash) {
- GSList *formats, *list;
+ if (g_once_init_enter (&formats_hash)) {
+ GSList *formats, *list;
+ GHashTable *hash;
- formats_hash = g_hash_table_new (g_str_hash, g_str_equal);
+ hash = g_hash_table_new_full (g_str_hash,
+ (GEqualFunc) g_content_type_equals,
+ g_free, NULL);
- formats = gdk_pixbuf_get_formats ();
- list = formats;
+ formats = gdk_pixbuf_get_formats ();
+ list = formats;
- while (list) {
- GdkPixbufFormat *format = list->data;
- gchar **mime_types;
+ while (list) {
+ GdkPixbufFormat *format = list->data;
+ gchar **mime_types;
- mime_types = gdk_pixbuf_format_get_mime_types (format);
+ mime_types = gdk_pixbuf_format_get_mime_types (format);
- for (i = 0; mime_types[i] != NULL; i++)
- g_hash_table_insert (formats_hash,
- (gpointer) g_strdup (mime_types[i]),
- GUINT_TO_POINTER (1));
+ for (i = 0; mime_types[i] != NULL; i++)
+ g_hash_table_insert (hash,
+ (gpointer) g_content_type_from_mime_type (mime_types[i]),
+ GUINT_TO_POINTER (1));
- g_strfreev (mime_types);
- list = list->next;
- }
- g_slist_free (formats);
- }
+ g_strfreev (mime_types);
+ list = list->next;
+ }
+ g_slist_free (formats);
- if (g_hash_table_lookup (formats_hash, mime_type))
- return TRUE;
+ g_once_init_leave (&formats_hash, (gsize) hash);
+ }
- return FALSE;
+ key = g_content_type_from_mime_type (mime_type);
+ if (g_hash_table_lookup ((void*)formats_hash, key))
+ result = TRUE;
+ else
+ result = FALSE;
+ g_free (key);
+
+ return result;
}
/**
@@ -640,28 +993,40 @@ gnome_desktop_thumbnail_factory_can_thumbnail (GnomeDesktopThumbnailFactory *fac
const char *mime_type,
time_t mtime)
{
+ gboolean have_script = FALSE;
+
/* Don't thumbnail thumbnails */
if (uri &&
strncmp (uri, "file:/", 6) == 0 &&
strstr (uri, "/.thumbnails/") != NULL)
return FALSE;
+
+ if (!mime_type)
+ return FALSE;
- if (mime_type != NULL &&
- (mimetype_supported_by_gdk_pixbuf (mime_type) ||
- (factory->priv->scripts_hash != NULL &&
- g_hash_table_lookup (factory->priv->scripts_hash, mime_type))))
+ g_mutex_lock (factory->priv->lock);
+ if (!gnome_desktop_thumbnail_factory_is_disabled (factory, mime_type))
{
- return !gnome_desktop_thumbnail_factory_has_valid_failed_thumbnail (factory,
- uri,
- mtime);
+ Thumbnailer *thumb;
+
+ thumb = g_hash_table_lookup (factory->priv->mime_types_map, mime_type);
+ have_script = thumbnailer_try_exec (thumb);
}
+ g_mutex_unlock (factory->priv->lock);
+ if (have_script || mimetype_supported_by_gdk_pixbuf (mime_type))
+ {
+ return !gnome_desktop_thumbnail_factory_has_valid_failed_thumbnail (factory,
+ uri,
+ mtime);
+ }
+
return FALSE;
}
static char *
expand_thumbnailing_script (const char *script,
- const int size,
+ const int size,
const char *inuri,
const char *outfile)
{
@@ -671,7 +1036,7 @@ expand_thumbnailing_script (const char *script,
gboolean got_in;
str = g_string_new (NULL);
-
+
got_in = FALSE;
last = script;
while ((p = strchr (last, '%')) != NULL)
@@ -739,7 +1104,7 @@ expand_thumbnailing_script (const char *script,
*
* Usage of this function is threadsafe.
*
- * Return value: thumbnail pixbuf if thumbnailing succeeded, %NULL otherwise.
+ * Return value: (transfer full): thumbnail pixbuf if thumbnailing succeeded, %NULL otherwise.
*
* Since: 2.2
**/
@@ -762,7 +1127,7 @@ gnome_desktop_thumbnail_factory_generate_thumbnail (GnomeDesktopThumbnailFactory
g_return_val_if_fail (mime_type != NULL, NULL);
/* Doesn't access any volatile fields in factory, so it's threadsafe */
-
+
size = 128;
if (factory->priv->size == GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE)
size = 256;
@@ -770,15 +1135,22 @@ gnome_desktop_thumbnail_factory_generate_thumbnail (GnomeDesktopThumbnailFactory
pixbuf = NULL;
script = NULL;
- if (factory->priv->scripts_hash != NULL)
- script = g_hash_table_lookup (factory->priv->scripts_hash, mime_type);
+ g_mutex_lock (factory->priv->lock);
+ if (!gnome_desktop_thumbnail_factory_is_disabled (factory, mime_type))
+ {
+ Thumbnailer *thumb;
+ thumb = g_hash_table_lookup (factory->priv->mime_types_map, mime_type);
+ if (thumb)
+ script = g_strdup (thumb->command);
+ }
+ g_mutex_unlock (factory->priv->lock);
+
if (script)
{
int fd;
- GError *error = NULL;
- fd = g_file_open_tmp (".gnome_desktop_thumbnail.XXXXXX", &tmpname, &error);
+ fd = g_file_open_tmp (".gnome_desktop_thumbnail.XXXXXX", &tmpname, NULL);
if (fd != -1)
{
@@ -795,8 +1167,10 @@ gnome_desktop_thumbnail_factory_generate_thumbnail (GnomeDesktopThumbnailFactory
g_free (expanded_script);
g_unlink(tmpname);
+ g_free (tmpname);
}
- g_free (tmpname);
+
+ g_free (script);
}
/* Fall back to gdk-pixbuf */
@@ -812,7 +1186,7 @@ gnome_desktop_thumbnail_factory_generate_thumbnail (GnomeDesktopThumbnailFactory
"gnome-original-height"));
}
}
-
+
if (pixbuf == NULL)
return NULL;
@@ -825,7 +1199,7 @@ gnome_desktop_thumbnail_factory_generate_thumbnail (GnomeDesktopThumbnailFactory
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
-
+
if (width > size || height > size)
{
const gchar *orig_width, *orig_height;
@@ -844,11 +1218,11 @@ gnome_desktop_thumbnail_factory_generate_thumbnail (GnomeDesktopThumbnailFactory
if (orig_height != NULL) {
gdk_pixbuf_set_option (scaled, "tEXt::Thumb::Image::Height", orig_height);
}
-
+
g_object_unref (pixbuf);
pixbuf = scaled;
}
-
+
if (original_width > 0) {
g_snprintf (dimension, sizeof (dimension), "%i", original_width);
gdk_pixbuf_set_option (pixbuf, "tEXt::Thumb::Image::Width", dimension);
@@ -861,76 +1235,6 @@ gnome_desktop_thumbnail_factory_generate_thumbnail (GnomeDesktopThumbnailFactory
return pixbuf;
}
-
-gboolean
-gnome_desktop_thumbnail_factory_generate_thumbnail_async (GnomeDesktopThumbnailFactory *factory,
- const char *uri,
- const char *mime_type,
- GPid *pid,
- char **tmpname,
- GError **error)
-{
- gboolean retval = FALSE;
- int size;
- char *script;
- int fd;
- char *expanded_script;
- int argc;
- char **argv;
-
- g_return_val_if_fail (uri != NULL, FALSE);
- g_return_val_if_fail (mime_type != NULL, FALSE);
-
- size = 128;
- if (factory->priv->size == GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE)
- size = 256;
-
- script = NULL;
- if (factory->priv->scripts_hash != NULL)
- script = g_hash_table_lookup (factory->priv->scripts_hash, mime_type);
-
- if (script == NULL)
- return FALSE;
-
- fd = g_file_open_tmp (".gnome_desktop_thumbnail.XXXXXX", tmpname, error);
- if (fd == -1)
- return FALSE;
- close (fd);
-
- expanded_script = expand_thumbnailing_script (script, size, uri, *tmpname);
- if (g_shell_parse_argv (expanded_script, &argc, &argv, error))
- if (g_spawn_async (NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, pid, error))
- retval = TRUE;
-
- g_free (expanded_script);
-
- return retval;
-}
-
-
-GdkPixbuf *
-gnome_desktop_thumbnail_factory_load_from_tempfile (GnomeDesktopThumbnailFactory *factory,
- char **tmpname)
-{
- GdkPixbuf *pixbuf;
- GdkPixbuf *tmp_pixbuf;
-
- pixbuf = gdk_pixbuf_new_from_file (*tmpname, NULL);
- g_unlink (*tmpname);
- g_free (*tmpname);
- *tmpname = NULL;
-
- if (pixbuf == NULL)
- return NULL;
-
- tmp_pixbuf = gdk_pixbuf_apply_embedded_orientation (pixbuf);
- g_object_unref (pixbuf);
- pixbuf = tmp_pixbuf;
-
- return pixbuf;
-}
-
-
static gboolean
make_thumbnail_dirs (GnomeDesktopThumbnailFactory *factory)
{
@@ -960,7 +1264,7 @@ make_thumbnail_dirs (GnomeDesktopThumbnailFactory *factory)
g_free (thumbnail_dir);
g_free (image_dir);
-
+
return res;
}
@@ -993,7 +1297,7 @@ make_thumbnail_fail_dirs (GnomeDesktopThumbnailFactory *factory)
}
app_dir = g_build_filename (fail_dir,
- factory->priv->application,
+ appname,
NULL);
if (!g_file_test (app_dir, G_FILE_TEST_IS_DIR))
{
@@ -1004,7 +1308,7 @@ make_thumbnail_fail_dirs (GnomeDesktopThumbnailFactory *factory)
g_free (thumbnail_dir);
g_free (fail_dir);
g_free (app_dir);
-
+
return res;
}
@@ -1012,9 +1316,9 @@ make_thumbnail_fail_dirs (GnomeDesktopThumbnailFactory *factory)
/**
* gnome_desktop_thumbnail_factory_save_thumbnail:
* @factory: a #GnomeDesktopThumbnailFactory
- * @thumbnail: the thumbnail as a pixbuf
+ * @thumbnail: the thumbnail as a pixbuf
* @uri: the uri of a file
- * @original_mtime: the modification time of the original file
+ * @original_mtime: the modification time of the original file
*
* Saves @thumbnail at the right place. If the save fails a
* failed thumbnail is written.
@@ -1030,7 +1334,7 @@ gnome_desktop_thumbnail_factory_save_thumbnail (GnomeDesktopThumbnailFactory *fa
time_t original_mtime)
{
GnomeDesktopThumbnailFactoryPrivate *priv = factory->priv;
- char *path, *file, *dir;
+ char *path, *file;
char *tmp_path;
const char *width, *height;
int tmp_fd;
@@ -1048,14 +1352,12 @@ gnome_desktop_thumbnail_factory_save_thumbnail (GnomeDesktopThumbnailFactory *fa
file = g_strconcat (g_checksum_get_string (checksum), ".png", NULL);
- dir = g_build_filename (g_get_home_dir (),
- ".thumbnails",
- (priv->size == GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL)?"normal":"large",
- NULL);
-
- path = g_build_filename (dir,
+ path = g_build_filename (g_get_home_dir (),
+ ".thumbnails",
+ (priv->size == GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL)?"normal":"large",
file,
NULL);
+
g_free (file);
g_checksum_free (checksum);
@@ -1074,18 +1376,17 @@ gnome_desktop_thumbnail_factory_save_thumbnail (GnomeDesktopThumbnailFactory *fa
if (tmp_fd == -1)
{
gnome_desktop_thumbnail_factory_create_failed_thumbnail (factory, uri, original_mtime);
- g_free (dir);
g_free (tmp_path);
g_free (path);
return;
}
close (tmp_fd);
-
+
g_snprintf (mtime_str, 21, "%ld", original_mtime);
width = gdk_pixbuf_get_option (thumbnail, "tEXt::Thumb::Image::Width");
height = gdk_pixbuf_get_option (thumbnail, "tEXt::Thumb::Image::Height");
- if (width != NULL && height != NULL)
+ if (width != NULL && height != NULL)
saved_ok = gdk_pixbuf_save (thumbnail,
tmp_path,
"png", NULL,
@@ -1103,7 +1404,7 @@ gnome_desktop_thumbnail_factory_save_thumbnail (GnomeDesktopThumbnailFactory *fa
"tEXt::Thumb::MTime", mtime_str,
"tEXt::Software", "GNOME::ThumbnailFactory",
NULL);
-
+
if (saved_ok)
{
@@ -1115,7 +1416,6 @@ gnome_desktop_thumbnail_factory_save_thumbnail (GnomeDesktopThumbnailFactory *fa
gnome_desktop_thumbnail_factory_create_failed_thumbnail (factory, uri, original_mtime);
}
- g_free (dir);
g_free (path);
g_free (tmp_path);
}
@@ -1138,7 +1438,7 @@ gnome_desktop_thumbnail_factory_create_failed_thumbnail (GnomeDesktopThumbnailFa
const char *uri,
time_t mtime)
{
- char *path, *file, *dir;
+ char *path, *file;
char *tmp_path;
int tmp_fd;
char mtime_str[21];
@@ -1156,12 +1456,9 @@ gnome_desktop_thumbnail_factory_create_failed_thumbnail (GnomeDesktopThumbnailFa
file = g_strconcat (g_checksum_get_string (checksum), ".png", NULL);
- dir = g_build_filename (g_get_home_dir (),
- ".thumbnails/fail",
- factory->priv->application,
- NULL);
-
- path = g_build_filename (dir,
+ path = g_build_filename (g_get_home_dir (),
+ ".thumbnails/fail",
+ appname,
file,
NULL);
g_free (file);
@@ -1181,18 +1478,17 @@ gnome_desktop_thumbnail_factory_create_failed_thumbnail (GnomeDesktopThumbnailFa
if (tmp_fd == -1)
{
- g_free (dir);
g_free (tmp_path);
g_free (path);
return;
}
close (tmp_fd);
-
+
g_snprintf (mtime_str, 21, "%ld", mtime);
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 1, 1);
saved_ok = gdk_pixbuf_save (pixbuf,
tmp_path,
- "png", NULL,
+ "png", NULL,
"tEXt::Thumb::URI", uri,
"tEXt::Thumb::MTime", mtime_str,
"tEXt::Software", "GNOME::ThumbnailFactory",
@@ -1204,7 +1500,6 @@ gnome_desktop_thumbnail_factory_create_failed_thumbnail (GnomeDesktopThumbnailFa
g_rename(tmp_path, path);
}
- g_free (dir);
g_free (path);
g_free (tmp_path);
}
@@ -1219,8 +1514,7 @@ gnome_desktop_thumbnail_factory_create_failed_thumbnail (GnomeDesktopThumbnailFa
* Return value: A string with the MD5 digest of the uri string.
*
* Since: 2.2
- *
- * @Deprecated: 2.22: Use #GChecksum instead
+ * Deprecated: 2.22: Use #GChecksum instead
**/
char *
gnome_desktop_thumbnail_md5 (const char *uri)
@@ -1252,13 +1546,13 @@ gnome_desktop_thumbnail_path_for_uri (const char *uri,
md5 = gnome_desktop_thumbnail_md5 (uri);
file = g_strconcat (md5, ".png", NULL);
g_free (md5);
-
+
path = g_build_filename (g_get_home_dir (),
".thumbnails",
(size == GNOME_DESKTOP_THUMBNAIL_SIZE_NORMAL)?"normal":"large",
file,
NULL);
-
+
g_free (file);
return path;
@@ -1281,7 +1575,7 @@ gnome_desktop_thumbnail_has_uri (GdkPixbuf *pixbuf,
const char *uri)
{
const char *thumb_uri;
-
+
thumb_uri = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::URI");
if (!thumb_uri)
return FALSE;
@@ -1309,19 +1603,19 @@ gnome_desktop_thumbnail_is_valid (GdkPixbuf *pixbuf,
{
const char *thumb_uri, *thumb_mtime_str;
time_t thumb_mtime;
-
+
thumb_uri = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::URI");
if (!thumb_uri)
return FALSE;
if (strcmp (uri, thumb_uri) != 0)
return FALSE;
-
+
thumb_mtime_str = gdk_pixbuf_get_option (pixbuf, "tEXt::Thumb::MTime");
if (!thumb_mtime_str)
return FALSE;
thumb_mtime = atol (thumb_mtime_str);
if (mtime != thumb_mtime)
return FALSE;
-
+
return TRUE;
}
diff --git a/src/gnome-desktop-thumbnail.h b/src/gnome-desktop-thumbnail.h
index dfdc1af..8e68582 100644
--- a/src/gnome-desktop-thumbnail.h
+++ b/src/gnome-desktop-thumbnail.h
@@ -75,14 +75,6 @@ gboolean gnome_desktop_thumbnail_factory_can_thumbnail (GnomeDeskt
GdkPixbuf * gnome_desktop_thumbnail_factory_generate_thumbnail (GnomeDesktopThumbnailFactory *factory,
const char *uri,
const char *mime_type);
-gboolean gnome_desktop_thumbnail_factory_generate_thumbnail_async (GnomeDesktopThumbnailFactory *factory,
- const char *uri,
- const char *mime_type,
- GPid *pid,
- char **tmpname,
- GError **error);
-GdkPixbuf * gnome_desktop_thumbnail_factory_load_from_tempfile (GnomeDesktopThumbnailFactory *factory,
- char **tmpname);
void gnome_desktop_thumbnail_factory_save_thumbnail (GnomeDesktopThumbnailFactory *factory,
GdkPixbuf *thumbnail,
const char *uri,
diff --git a/src/goo-player-info.c b/src/goo-player-info.c
index 341a844..df8c0a6 100644
--- a/src/goo-player-info.c
+++ b/src/goo-player-info.c
@@ -98,9 +98,9 @@ goo_player_info_get_preferred_width (GtkWidget *widget,
GooPlayerInfo *info = GOO_PLAYER_INFO (widget);
if (info->priv->interactive)
- minimum_width = natural_width = MIN_WIDTH;
+ *minimum_width = *natural_width = MIN_WIDTH;
else
- minimum_width = natural_width = MIN_TOOLTIP_WIDTH;
+ *minimum_width = *natural_width = MIN_TOOLTIP_WIDTH;
}
@@ -347,7 +347,7 @@ goo_player_info_construct (GooPlayerInfo *info)
priv->total_time = NULL;
priv->update_id = 0;
- gtk_widget_set_can_focus (info, FALSE);
+ gtk_widget_set_can_focus (GTK_WIDGET (info), FALSE);
gtk_box_set_spacing (GTK_BOX (info), SPACING);
gtk_box_set_homogeneous (GTK_BOX (info), FALSE);
diff --git a/src/goo-player.c b/src/goo-player.c
index 3c9c3b0..050d1d2 100644
--- a/src/goo-player.c
+++ b/src/goo-player.c
@@ -52,14 +52,14 @@ struct _GooPlayerPrivate {
gboolean is_busy;
gboolean audio_cd;
gboolean hibernate;
-
+
GstElement *pipeline;
GstElement *source;
GstPad *source_pad;
GstElement *audio_volume;
GstFormat track_format;
GstFormat sector_format;
-
+
char *discid;
AlbumInfo *album;
TrackInfo *current_track;
@@ -147,11 +147,11 @@ pipeline_bus_message_cb (GstBus *bus,
}
g_idle_add (player_done_cb, user_data);
break;
-
+
default:
break;
}
-
+
return TRUE;
}
@@ -166,7 +166,7 @@ update_progress_cb (gpointer user_data)
g_source_remove (self->priv->update_progress_id);
self->priv->update_progress_id = 0;
}
-
+
if ((self->priv->current_track == NULL)
|| ! gst_pad_query_position (self->priv->source_pad,
&self->priv->sector_format,
@@ -209,15 +209,15 @@ create_pipeline (GooPlayer *self)
audioconvert = gst_element_factory_make ("audioconvert", "convert");
audioresample = gst_element_factory_make ("audioresample", "resample");
self->priv->audio_volume = gst_element_factory_make ("volume", "volume");
-
+
queue = gst_element_factory_make ("queue", "queue");
g_object_set (queue,
"min-threshold-time", (guint64) 200 * GST_MSECOND,
"max-size-time", (guint64) 2 * GST_SECOND,
NULL);
-
- sink = gst_element_factory_make ("gconfaudiosink", "sink");
-
+
+ sink = gst_element_factory_make ("gsettingsaudiosink", "sink");
+
gst_bin_add_many (GST_BIN (self->priv->pipeline),
self->priv->source,
queue,
@@ -237,9 +237,9 @@ create_pipeline (GooPlayer *self)
self->priv->track_format = gst_format_get_by_nick ("track");
self->priv->sector_format = gst_format_get_by_nick ("sector");
self->priv->source_pad = gst_element_get_pad (self->priv->source, "src");
-
+
gst_bus_add_watch (gst_pipeline_get_bus (GST_PIPELINE (self->priv->pipeline)),
- pipeline_bus_message_cb,
+ pipeline_bus_message_cb,
self);
}
@@ -267,13 +267,13 @@ goo_player_set_state (GooPlayer *self,
self->priv->state = state;
if (notify)
g_signal_emit (G_OBJECT (self),
- goo_player_signals[STATE_CHANGED],
+ goo_player_signals[STATE_CHANGED],
0,
NULL);
}
-static void
+static void
goo_player_class_init (GooPlayerClass *class)
{
GObjectClass *gobject_class;
@@ -290,7 +290,7 @@ goo_player_class_init (GooPlayerClass *class)
G_STRUCT_OFFSET (GooPlayerClass, start),
NULL, NULL,
g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE,
+ G_TYPE_NONE,
1,
G_TYPE_INT);
goo_player_signals[DONE] =
@@ -332,7 +332,7 @@ goo_player_class_init (GooPlayerClass *class)
}
-static void
+static void
goo_player_init (GooPlayer *self)
{
self->priv = GOO_PLAYER_GET_PRIVATE_DATA (self);
@@ -351,16 +351,16 @@ goo_player_init (GooPlayer *self)
}
-static void
+static void
goo_player_finalize (GObject *object)
{
GooPlayer *self;
g_return_if_fail (object != NULL);
g_return_if_fail (GOO_IS_PLAYER (object));
-
+
self = GOO_PLAYER (object);
-
+
g_mutex_lock (self->priv->yes_or_no);
self->priv->exiting = TRUE;
g_mutex_unlock (self->priv->yes_or_no);
@@ -427,7 +427,7 @@ static void
notify_action_start (GooPlayer *self)
{
g_signal_emit (G_OBJECT (self),
- goo_player_signals[START],
+ goo_player_signals[START],
0,
self->priv->action,
NULL);
@@ -474,13 +474,13 @@ set_cd_metadata_from_rdf (GooPlayer *self,
albums = get_album_list (mb);
if (albums != NULL) {
AlbumInfo *first_album = albums->data;
-
- /* FIXME: ask the user which album to use if the query
+
+ /* FIXME: ask the user which album to use if the query
* returned more than one album. */
-
+
goo_player_set_album (self, first_album);
album_list_free (albums);
- }
+ }
mb_Delete (mb);
}
@@ -497,20 +497,20 @@ get_cached_rdf_path (GooPlayer *self)
static void
-save_rdf_to_cache (GooPlayer *player,
+save_rdf_to_cache (GooPlayer *player,
const char *rdf)
{
char *path;
char *dir;
GError *error = NULL;
-
+
if (rdf == NULL)
return;
-
+
path = get_cached_rdf_path (player);
if (path == NULL)
return;
-
+
if (g_file_test (path, G_FILE_TEST_EXISTS)) {
g_free (path);
return;
@@ -523,7 +523,7 @@ save_rdf_to_cache (GooPlayer *player,
debug (DEBUG_INFO, "%s\n", error->message);
g_clear_error (&error);
}
-
+
g_free (dir);
g_free (path);
}
@@ -535,19 +535,19 @@ read_cached_rdf (GooPlayer *self)
char *path;
char *rdf = NULL;
GError *error = NULL;
-
+
path = get_cached_rdf_path (self);
if (path == NULL)
return NULL;
-
+
if (! g_file_get_contents (path, &rdf, NULL, &error)) {
debug (DEBUG_INFO, "%s\n", error->message);
g_clear_error (&error);
rdf = NULL;
}
-
+
g_free (path);
-
+
return rdf;
}
@@ -558,12 +558,12 @@ check_get_cd_metadata (gpointer data)
GooPlayer *player = data;
gboolean done, exiting;
char *rdf;
-
+
/* Remove the check. */
g_source_remove (player->priv->check_id);
player->priv->check_id = 0;
-
+
/**/
g_mutex_lock (player->priv->yes_or_no);
@@ -578,42 +578,42 @@ check_get_cd_metadata (gpointer data)
}
if (! done) {
- player->priv->check_id = g_timeout_add (REFRESH_RATE,
- check_get_cd_metadata,
+ player->priv->check_id = g_timeout_add (REFRESH_RATE,
+ check_get_cd_metadata,
player);
return FALSE;
}
-
+
/**/
g_mutex_lock (player->priv->yes_or_no);
rdf = player->priv->rdf;
player->priv->rdf = NULL;
g_mutex_unlock (player->priv->yes_or_no);
-
- if (rdf != NULL) {
+
+ if (rdf != NULL) {
set_cd_metadata_from_rdf (player, rdf);
save_rdf_to_cache (player, rdf);
album_info_save_to_cache (player->priv->album, player->priv->discid);
g_free (rdf);
}
-
- return FALSE;
+
+ return FALSE;
}
-static void *
+static void *
get_cd_metadata (void *thread_data)
{
GooPlayer *player = thread_data;
musicbrainz_t mb;
char *rdf = NULL;
-
+
mb = mb_New ();
mb_UseUTF8 (mb, TRUE);
if (mb_Query (mb, MBQ_GetCDInfo)) {
int rdf_len;
-
+
rdf_len = mb_GetResultRDFLen (mb);
rdf = g_malloc (rdf_len + 1);
mb_GetResultRDF (mb, rdf, rdf_len);
@@ -639,12 +639,12 @@ check_get_cd_tracks (gpointer data)
gboolean done;
gboolean exiting;
char *rdf;
-
+
/* Remove the check. */
g_source_remove (player->priv->check_id);
player->priv->check_id = 0;
-
+
/**/
g_mutex_lock (player->priv->yes_or_no);
@@ -659,8 +659,8 @@ check_get_cd_tracks (gpointer data)
}
if (! done) {
- player->priv->check_id = g_timeout_add (REFRESH_RATE,
- check_get_cd_tracks,
+ player->priv->check_id = g_timeout_add (REFRESH_RATE,
+ check_get_cd_tracks,
player);
return FALSE;
}
@@ -670,7 +670,7 @@ check_get_cd_tracks (gpointer data)
goo_player_set_is_busy (player, FALSE);
gst_element_set_state (player->priv->pipeline, GST_STATE_NULL);
goo_player_set_state (player, GOO_PLAYER_STATE_STOPPED, TRUE);
-
+
action_done (player, GOO_PLAYER_ACTION_LIST);
destroy_pipeline (player, TRUE);
@@ -680,8 +680,8 @@ check_get_cd_tracks (gpointer data)
action_done (player, GOO_PLAYER_ACTION_METADATA);
return FALSE;
}
-
- rdf = read_cached_rdf (player);
+
+ rdf = read_cached_rdf (player);
if (rdf != NULL) {
set_cd_metadata_from_rdf (player, rdf);
g_free (rdf);
@@ -691,20 +691,20 @@ check_get_cd_tracks (gpointer data)
g_mutex_lock (player->priv->yes_or_no);
player->priv->thread = g_thread_create (get_cd_metadata, player, FALSE, NULL);
g_mutex_unlock (player->priv->yes_or_no);
-
+
player->priv->check_id = g_timeout_add (REFRESH_RATE, check_get_cd_metadata, player);
return FALSE;
}
-static void *
+static void *
get_cd_tracks (void *thread_data)
{
GooPlayer *player = thread_data;
GList *tracks = NULL;
musicbrainz_t mb;
-
+
if (player->priv->pipeline != NULL)
gst_element_set_state (player->priv->pipeline, GST_STATE_PAUSED);
@@ -717,25 +717,25 @@ get_cd_tracks (void *thread_data)
if (mb_Query (mb, MBQ_GetCDTOC)) {
char data[256];
int n_tracks, i;
-
+
mb_GetResultData(mb, MBE_TOCGetCDIndexId, data, sizeof (data));
- player->priv->discid = g_strdup (data);
+ player->priv->discid = g_strdup (data);
debug (DEBUG_INFO, "==> [MB] DISC ID: %s\n", player->priv->discid);
-
+
debug (DEBUG_INFO, "==> [MB] FIRST TRACK: %d\n", mb_GetResultInt (mb, MBE_TOCGetFirstTrack));
-
+
n_tracks = mb_GetResultInt (mb, MBE_TOCGetLastTrack);
debug (DEBUG_INFO, "==> [MB] LAST TRACK: %d\n", n_tracks);
-
+
for (i = 0; i < n_tracks; i++) {
gint64 from_sector;
gint64 n_sectors;
-
+
from_sector = mb_GetResultInt1 (mb, MBE_TOCGetTrackSectorOffset, i + 2);
n_sectors = mb_GetResultInt1 (mb, MBE_TOCGetTrackNumSectors, i + 2);
-
+
debug (DEBUG_INFO, "==> [MB] Track %d: [%"G_GINT64_FORMAT", %"G_GINT64_FORMAT"]\n", i, from_sector, from_sector + n_sectors);
-
+
tracks = g_list_prepend (tracks, track_info_new (i, from_sector, from_sector + n_sectors));
}
}
@@ -744,7 +744,7 @@ get_cd_tracks (void *thread_data)
tracks = g_list_reverse (tracks);
album_info_set_tracks (player->priv->album, tracks);
track_list_free (tracks);
-
+
g_mutex_lock (player->priv->yes_or_no);
player->priv->thread = NULL;
g_mutex_unlock (player->priv->yes_or_no);
@@ -817,15 +817,15 @@ goo_player_list (GooPlayer *player)
player->priv->action = GOO_PLAYER_ACTION_LIST;
player->priv->state = GOO_PLAYER_STATE_LISTING;
notify_action_start (player);
-
+
goo_player_empty_list (player);
goo_player_set_is_busy (player, TRUE);
create_pipeline (player);
-
+
g_mutex_lock (player->priv->yes_or_no);
player->priv->thread = g_thread_create (get_cd_tracks, player, FALSE, NULL);
g_mutex_unlock (player->priv->yes_or_no);
-
+
player->priv->check_id = g_timeout_add (REFRESH_RATE, check_get_cd_tracks, player);
}
@@ -838,7 +838,7 @@ get_track (GooPlayer *player,
for (scan = player->priv->album->tracks; scan; scan = scan->next) {
TrackInfo *track = scan->data;
-
+
if (track->number == n)
return track;
}
@@ -852,7 +852,7 @@ goo_player_seek_track (GooPlayer *player,
int n)
{
int track_n;
-
+
if (goo_player_get_is_busy (player))
return;
@@ -875,26 +875,26 @@ goo_player_seek_track (GooPlayer *player,
track_n = CLAMP (n, 0, player->priv->album->n_tracks - 1);
player->priv->current_track_n = track_n;
-
+
debug (DEBUG_INFO, "seek to track %d\n", track_n);
-
+
player->priv->current_track = get_track (player, player->priv->current_track_n);
-
+
g_return_if_fail (player->priv->current_track != NULL);
if (! gst_element_seek (player->priv->pipeline,
- 1.0,
+ 1.0,
player->priv->track_format,
GST_SEEK_FLAG_FLUSH,
GST_SEEK_TYPE_SET,
- track_n,
+ track_n,
GST_SEEK_TYPE_SET,
track_n + 1))
{
g_warning ("seek failed");
}
gst_element_get_state (player->priv->pipeline, NULL, NULL, -1);
-
+
action_done (player, GOO_PLAYER_ACTION_SEEK_SONG);
goo_player_play (player);
}
@@ -919,12 +919,12 @@ goo_player_skip_to (GooPlayer *player,
gst_element_set_state (player->priv->pipeline, GST_STATE_PAUSED);
gst_element_seek (player->priv->pipeline,
- 1.0,
+ 1.0,
GST_FORMAT_TIME,
GST_SEEK_FLAG_FLUSH,
- GST_SEEK_TYPE_SET,
+ GST_SEEK_TYPE_SET,
G_GINT64_CONSTANT (1000000000) * seconds,
- GST_SEEK_TYPE_NONE,
+ GST_SEEK_TYPE_NONE,
0);
gst_element_get_state (player->priv->pipeline, NULL, NULL, -1);
gst_element_set_state (player->priv->pipeline, GST_STATE_PLAYING);
@@ -977,10 +977,10 @@ void
goo_player_play (GooPlayer *player)
{
if (goo_player_get_is_busy (player))
- return;
+ return;
if (player->priv->state == GOO_PLAYER_STATE_PLAYING)
return;
-
+
player->priv->action = GOO_PLAYER_ACTION_PLAY;
notify_action_start (player);
@@ -1017,7 +1017,7 @@ goo_player_pause (GooPlayer *player)
gst_element_set_state (player->priv->pipeline, GST_STATE_PAUSED);
goo_player_set_state (GOO_PLAYER (player), GOO_PLAYER_STATE_PAUSED, TRUE);
-
+
action_done (player, GOO_PLAYER_ACTION_PAUSE);
}
diff --git a/src/goo-volume-tool-button.c b/src/goo-volume-tool-button.c
index e606d18..369b76d 100644
--- a/src/goo-volume-tool-button.c
+++ b/src/goo-volume-tool-button.c
@@ -397,7 +397,7 @@ popup_win_event_cb (GtkWidget *widget,
int x, y, w, h;
gdk_window_get_geometry (gtk_widget_get_window (button->priv->popup_win),
- &x, &y, &w, &h, NULL);
+ &x, &y, &w, &h);
if ((event->button.x < 0)
|| (event->button.x > w)
diff --git a/src/goo-window.c b/src/goo-window.c
index 6435e25..7a38fae 100644
--- a/src/goo-window.c
+++ b/src/goo-window.c
@@ -50,13 +50,9 @@
#include "icons/pixbufs.h"
#define ICON_GTK_SIZE GTK_ICON_SIZE_LARGE_TOOLBAR
-#define GCONF_NOTIFICATIONS 6
#define FILES_TO_PROCESS_AT_ONCE 500
-#define DEFAULT_WIN_WIDTH 200
-#define DEFAULT_WIN_HEIGHT 400
#define HIDE_TRACK_LIST N_("Hide _tracks")
#define SHOW_TRACK_LIST N_("Show _tracks")
-#define DEFAULT_VOLUME 100
#define PLAYER_CHECK_RATE 100
#define COVER_SIZE 80
#define IDLE_TIMEOUT 200
@@ -97,7 +93,10 @@ struct _GooWindowPrivate {
gint activity_ref; /* when > 0 some activity
* is present. */
GtkActionGroup *actions;
- guint cnxn_id[GCONF_NOTIFICATIONS];
+ GSettings *settings_general;
+ GSettings *settings_ui;
+ GSettings *settings_playlist;
+ GSettings *settings_encoder;
guint update_timeout_handle; /* update list timeout
* handle. */
@@ -226,7 +225,7 @@ window_update_sensitivity (GooWindow *window)
playing = state == GOO_PLAYER_STATE_PLAYING;
paused = state == GOO_PLAYER_STATE_PAUSED;
stopped = state == GOO_PLAYER_STATE_STOPPED;
- play_all = eel_gconf_get_boolean (PREF_PLAYLIST_PLAYALL, TRUE);
+ play_all = g_settings_get_boolean (window->priv->settings_playlist, PREF_PLAYLIST_PLAYALL);
audio_cd = (! error) && (goo_player_get_discid (window->priv->player) != NULL);
set_sensitive (window, "Play", audio_cd && !playing);
@@ -308,18 +307,16 @@ set_track_icon (GooWindow *window,
int track_number,
const char *stock_id)
{
-
- GtkTreeIter iter;
- GdkPixbuf *icon;
+ GtkTreeIter iter;
+ GdkPixbuf *icon;
if (!get_iter_from_track_number (window, track_number, &iter))
return;
if (stock_id != NULL)
- icon = gtk_widget_render_icon (GTK_WIDGET (window),
- stock_id,
- GTK_ICON_SIZE_MENU,
- NULL);
+ icon = gtk_widget_render_icon_pixbuf (GTK_WIDGET (window),
+ stock_id,
+ GTK_ICON_SIZE_MENU);
else
icon = create_void_icon (window);
gtk_list_store_set (window->priv->list_store, &iter,
@@ -444,14 +441,9 @@ static void
goo_window_finalize (GObject *object)
{
GooWindow *window = GOO_WINDOW (object);
- int i;
debug (DEBUG_INFO, "[FINALIZE]\n");
- for (i = 0; i < GCONF_NOTIFICATIONS; i++)
- if (window->priv->cnxn_id[i] != -1)
- eel_gconf_notification_remove (window->priv->cnxn_id[i]);
-
if (window->priv != NULL) {
#ifdef ENABLE_MEDIA_KEYS
if (window->priv->media_keys_proxy != NULL) {
@@ -467,10 +459,15 @@ goo_window_finalize (GObject *object)
/* Save preferences */
- eel_gconf_set_integer (PREF_GENERAL_VOLUME, (int) (goo_player_get_audio_volume (window->priv->player) * 100.0));
+ g_settings_set_int (window->priv->settings_general, PREF_GENERAL_VOLUME, (int) (goo_player_get_audio_volume (window->priv->player) * 100.0));
/**/
+ _g_object_unref (window->priv->settings_ui);
+ _g_object_unref (window->priv->settings_general);
+ _g_object_unref (window->priv->settings_playlist);
+ _g_object_unref (window->priv->settings_encoder);
+
g_object_unref (window->priv->list_store);
if (window->priv->next_timeout_handle != 0) {
@@ -639,8 +636,8 @@ static void
menu_item_deselect_cb (GtkMenuItem *proxy,
GooWindow *window)
{
- gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar),
- window->priv->help_message_cid);
+ gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar),
+ window->priv->help_message_cid);
}
@@ -661,8 +658,8 @@ disconnect_proxy_cb (GtkUIManager *manager,
static void
connect_proxy_cb (GtkUIManager *manager,
- GtkAction *action,
- GtkWidget *proxy,
+ GtkAction *action,
+ GtkWidget *proxy,
GooWindow *window)
{
if (GTK_IS_MENU_ITEM (proxy)) {
@@ -675,37 +672,38 @@ connect_proxy_cb (GtkUIManager *manager,
static void
-pref_view_toolbar_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
+pref_view_toolbar_changed (GSettings *settings,
+ const char *key,
+ gpointer user_data)
{
GooWindow *window = user_data;
+
g_return_if_fail (window != NULL);
- goo_window_set_toolbar_visibility (window, gconf_value_get_bool (gconf_entry_get_value (entry)));
+ goo_window_set_toolbar_visibility (window, g_settings_get_boolean (settings, key));
}
static void
-pref_view_statusbar_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
+pref_view_statusbar_changed (GSettings *settings,
+ const char *key,
+ gpointer user_data)
{
GooWindow *window = user_data;
- goo_window_set_statusbar_visibility (window, gconf_value_get_bool (gconf_entry_get_value (entry)));
+
+ g_return_if_fail (window != NULL);
+ goo_window_set_statusbar_visibility (window, g_settings_get_boolean (settings, key));
}
static void
-pref_view_playlist_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
+pref_view_playlist_changed (GSettings *settings,
+ const char *key,
+ gpointer user_data)
{
GooWindow *window = user_data;
+
g_return_if_fail (window != NULL);
- gtk_expander_set_expanded (GTK_EXPANDER (window->priv->list_expander), eel_gconf_get_boolean (PREF_UI_PLAYLIST, TRUE));
+ gtk_expander_set_expanded (GTK_EXPANDER (window->priv->list_expander), g_settings_get_boolean (settings, key));
}
@@ -852,9 +850,9 @@ play_next_track_in_playlist (GooWindow *window)
gboolean repeat;
GList *next = NULL;
- play_all = eel_gconf_get_boolean (PREF_PLAYLIST_PLAYALL, TRUE);
- shuffle = eel_gconf_get_boolean (PREF_PLAYLIST_SHUFFLE, FALSE);
- repeat = eel_gconf_get_boolean (PREF_PLAYLIST_REPEAT, FALSE);
+ play_all = g_settings_get_boolean (window->priv->settings_playlist, PREF_PLAYLIST_PLAYALL);
+ shuffle = g_settings_get_boolean (window->priv->settings_playlist, PREF_PLAYLIST_SHUFFLE);
+ repeat = g_settings_get_boolean (window->priv->settings_playlist, PREF_PLAYLIST_REPEAT);
next = window->priv->playlist;
@@ -879,10 +877,9 @@ play_next_track_in_playlist (GooWindow *window)
static void
-pref_playlist_playall_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
+pref_playlist_playall_changed (GSettings *settings,
+ const char *key,
+ gpointer user_data)
{
GooWindow *window = user_data;
gboolean play_all;
@@ -890,8 +887,8 @@ pref_playlist_playall_changed (GConfClient *client,
g_return_if_fail (window != NULL);
- play_all = eel_gconf_get_boolean (PREF_PLAYLIST_PLAYALL, TRUE);
- shuffle = eel_gconf_get_boolean (PREF_PLAYLIST_SHUFFLE, FALSE);
+ play_all = g_settings_get_boolean (window->priv->settings_playlist, PREF_PLAYLIST_PLAYALL);
+ shuffle = g_settings_get_boolean (window->priv->settings_playlist, PREF_PLAYLIST_SHUFFLE);
create_playlist (window, play_all, shuffle);
window_update_sensitivity (window);
@@ -901,24 +898,22 @@ pref_playlist_playall_changed (GConfClient *client,
static void
-pref_playlist_repeat_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
+pref_playlist_repeat_changed (GSettings *settings,
+ const char *key,
+ gpointer user_data)
{
GooWindow *window = user_data;
g_return_if_fail (window != NULL);
- set_active (window, "Repeat", eel_gconf_get_boolean (PREF_PLAYLIST_REPEAT, FALSE));
+ set_active (window, "Repeat", g_settings_get_boolean (window->priv->settings_playlist, PREF_PLAYLIST_REPEAT));
}
static void
-pref_playlist_shuffle_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
+pref_playlist_shuffle_changed (GSettings *settings,
+ const char *key,
+ gpointer user_data)
{
GooWindow *window = user_data;
gboolean play_all;
@@ -926,8 +921,8 @@ pref_playlist_shuffle_changed (GConfClient *client,
g_return_if_fail (window != NULL);
- play_all = eel_gconf_get_boolean (PREF_PLAYLIST_PLAYALL, TRUE);
- shuffle = eel_gconf_get_boolean (PREF_PLAYLIST_SHUFFLE, FALSE);
+ play_all = g_settings_get_boolean (window->priv->settings_playlist, PREF_PLAYLIST_PLAYALL);
+ shuffle = g_settings_get_boolean (window->priv->settings_playlist, PREF_PLAYLIST_SHUFFLE);
create_playlist (window, play_all, shuffle);
set_active (window, "Shuffle", shuffle);
@@ -937,11 +932,11 @@ pref_playlist_shuffle_changed (GConfClient *client,
static void
save_window_size (GooWindow *window)
{
- int w, h;
+ GdkWindow *w;
- gdk_drawable_get_size (gtk_widget_get_window (GTK_WIDGET (window)), &w, &h);
- eel_gconf_set_integer (PREF_UI_WINDOW_WIDTH, w);
- eel_gconf_set_integer (PREF_UI_WINDOW_HEIGHT, h);
+ w = gtk_widget_get_window (GTK_WIDGET (window));
+ g_settings_set_int (window->priv->settings_ui, PREF_UI_WINDOW_WIDTH, gdk_window_get_width (w));
+ g_settings_set_int (window->priv->settings_ui, PREF_UI_WINDOW_HEIGHT, gdk_window_get_height (w));
}
@@ -956,12 +951,13 @@ goo_window_unrealize (GtkWidget *widget)
/* save ui preferences. */
playlist_visible = gtk_expander_get_expanded (GTK_EXPANDER (window->priv->list_expander));
- eel_gconf_set_boolean (PREF_UI_PLAYLIST, playlist_visible);
+ g_settings_set_boolean (window->priv->settings_ui, PREF_UI_PLAYLIST, playlist_visible);
+
if (playlist_visible)
save_window_size (window);
- preferences_set_sort_method (window->priv->sort_method);
- preferences_set_sort_type (window->priv->sort_type);
+ g_settings_set_enum (window->priv->settings_playlist, PREF_PLAYLIST_SORT_METHOD, window->priv->sort_method);
+ g_settings_set_enum (window->priv->settings_playlist, PREF_PLAYLIST_SORT_TYPE, window->priv->sort_type);
GTK_WIDGET_CLASS (goo_window_parent_class)->unrealize (widget);
}
@@ -990,11 +986,11 @@ goo_window_show (GtkWidget *widget)
else
HideShow = FALSE;
- view_foobar = eel_gconf_get_boolean (PREF_UI_TOOLBAR, TRUE);
+ view_foobar = g_settings_get_boolean (window->priv->settings_ui, PREF_UI_TOOLBAR);
set_active (window, "ViewToolbar", view_foobar);
goo_window_set_toolbar_visibility (window, view_foobar);
- view_foobar = eel_gconf_get_boolean (PREF_UI_STATUSBAR, FALSE);
+ view_foobar = g_settings_get_boolean (window->priv->settings_ui, PREF_UI_STATUSBAR);
set_active (window, "ViewStatusbar", view_foobar);
goo_window_set_statusbar_visibility (window, view_foobar);
@@ -1636,7 +1632,7 @@ player_done_cb (GooPlayer *player,
goo_window_update_cover (window);
window_update_title (window);
set_current_track_icon (window, NULL);
- if (AutoPlay || eel_gconf_get_boolean (PREF_GENERAL_AUTOPLAY, TRUE)) {
+ if (AutoPlay || g_settings_get_boolean (window->priv->settings_general, PREF_GENERAL_AUTOPLAY)) {
AutoPlay = FALSE;
g_timeout_add (AUTOPLAY_DELAY, autoplay_cb, window);
}
@@ -1852,8 +1848,8 @@ sort_column_changed_cb (GtkTreeSortable *sortable,
state = goo_player_get_state (window->priv->player);
if ((state != GOO_PLAYER_STATE_PLAYING) && (state != GOO_PLAYER_STATE_PAUSED))
create_playlist (window,
- eel_gconf_get_boolean (PREF_PLAYLIST_PLAYALL, TRUE),
- eel_gconf_get_boolean (PREF_PLAYLIST_SHUFFLE, FALSE));
+ g_settings_get_boolean (window->priv->settings_playlist, PREF_PLAYLIST_PLAYALL),
+ g_settings_get_boolean (window->priv->settings_playlist, PREF_PLAYLIST_SHUFFLE));
}
@@ -1869,9 +1865,9 @@ update_ui_from_expander_state (GooWindow *window)
gtk_expander_set_label (expander, _(HIDE_TRACK_LIST));
if (gtk_widget_get_realized (GTK_WIDGET (window)))
gtk_window_resize (GTK_WINDOW (window),
- eel_gconf_get_integer (PREF_UI_WINDOW_WIDTH, DEFAULT_WIN_WIDTH),
- eel_gconf_get_integer (PREF_UI_WINDOW_HEIGHT, DEFAULT_WIN_HEIGHT));
- gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (window->priv->statusbar), TRUE);
+ g_settings_get_int (window->priv->settings_ui, PREF_UI_WINDOW_WIDTH),
+ g_settings_get_int (window->priv->settings_ui, PREF_UI_WINDOW_HEIGHT));
+ gtk_window_set_has_resize_grip (GTK_WINDOW (window), TRUE);
hints.max_height = -1;
hints.max_width = G_MAXINT;
@@ -1885,7 +1881,7 @@ update_ui_from_expander_state (GooWindow *window)
if (gtk_widget_get_realized (GTK_WIDGET (window)))
save_window_size (window);
- gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (window->priv->statusbar), FALSE);
+ gtk_window_set_has_resize_grip (GTK_WINDOW (window), FALSE);
gtk_expander_set_label (expander, _(SHOW_TRACK_LIST));
hints.max_height = -1;
@@ -1904,7 +1900,7 @@ list_expander_expanded_cb (GtkExpander *expander,
GooWindow *window)
{
update_ui_from_expander_state (window);
- eel_gconf_set_boolean (PREF_UI_PLAYLIST, gtk_expander_get_expanded (expander));
+ g_settings_set_boolean (window->priv->settings_ui, PREF_UI_PLAYLIST, gtk_expander_get_expanded (expander));
}
static void
@@ -1934,9 +1930,9 @@ player_info_cover_clicked_cb (GooPlayerInfo *info,
static void
window_sync_ui_with_preferences (GooWindow *window)
{
- set_active (window, "PlayAll", eel_gconf_get_boolean (PREF_PLAYLIST_PLAYALL, TRUE));
- set_active (window, "Repeat", eel_gconf_get_boolean (PREF_PLAYLIST_REPEAT, FALSE));
- set_active (window, "Shuffle", eel_gconf_get_boolean (PREF_PLAYLIST_SHUFFLE, FALSE));
+ set_active (window, "PlayAll", g_settings_get_boolean (window->priv->settings_playlist, PREF_PLAYLIST_PLAYALL));
+ set_active (window, "Repeat", g_settings_get_boolean (window->priv->settings_playlist, PREF_PLAYLIST_REPEAT));
+ set_active (window, "Shuffle", g_settings_get_boolean (window->priv->settings_playlist, PREF_PLAYLIST_SHUFFLE));
update_ui_from_expander_state (window);
}
@@ -2231,7 +2227,6 @@ goo_window_construct (GooWindow *window,
GtkWidget *hbox;
GtkWidget *expander;
GtkTreeSelection *selection;
- int i;
GtkActionGroup *actions;
GtkUIManager *ui;
GError *error = NULL;
@@ -2272,6 +2267,13 @@ goo_window_construct (GooWindow *window,
window->priv->playlist = NULL;
+ /* Create the settings objects */
+
+ window->priv->settings_general = g_settings_new (GOOBOX_SCHEMA_GENERAL);
+ window->priv->settings_ui = g_settings_new (GOOBOX_SCHEMA_UI);
+ window->priv->settings_playlist = g_settings_new (GOOBOX_SCHEMA_PLAYLIST);
+ window->priv->settings_encoder = g_settings_new (GOOBOX_SCHEMA_ENCODER);
+
/* Create the widgets. */
/* * File list. */
@@ -2300,8 +2302,8 @@ goo_window_construct (GooWindow *window,
COLUMN_TIME, time_column_sort_func,
NULL, NULL);
- window->priv->sort_method = preferences_get_sort_method ();
- window->priv->sort_type = preferences_get_sort_type ();
+ window->priv->sort_method = g_settings_get_enum (window->priv->settings_playlist, PREF_PLAYLIST_SORT_METHOD);
+ window->priv->sort_type = g_settings_get_enum (window->priv->settings_playlist, PREF_PLAYLIST_SORT_TYPE);
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (window->priv->list_store), get_column_from_sort_method (window->priv->sort_method), window->priv->sort_type);
@@ -2348,10 +2350,8 @@ goo_window_construct (GooWindow *window,
window->priv->ui = ui = gtk_ui_manager_new ();
- g_signal_connect (ui, "connect_proxy",
- G_CALLBACK (connect_proxy_cb), window);
- g_signal_connect (ui, "disconnect_proxy",
- G_CALLBACK (disconnect_proxy_cb), window);
+ g_signal_connect (ui, "connect_proxy", G_CALLBACK (connect_proxy_cb), window);
+ g_signal_connect (ui, "disconnect_proxy", G_CALLBACK (disconnect_proxy_cb), window);
gtk_ui_manager_insert_action_group (ui, actions, 0);
gtk_window_add_accel_group (GTK_WINDOW (window),
@@ -2441,12 +2441,12 @@ goo_window_construct (GooWindow *window,
/* Create the statusbar. */
window->priv->statusbar = gtk_statusbar_new ();
- gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (window->priv->statusbar), TRUE);
+ gtk_window_set_has_resize_grip (GTK_WINDOW (window), TRUE);
window->priv->help_message_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (window->priv->statusbar), "help_message");
window->priv->list_info_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (window->priv->statusbar), "list_info");
window->priv->progress_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (window->priv->statusbar), "progress");
gth_window_attach (GTH_WINDOW (window), window->priv->statusbar, GTH_WINDOW_STATUSBAR);
- gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (window->priv->statusbar), TRUE);
+ gtk_window_set_has_resize_grip (GTK_WINDOW (window), TRUE);
/**/
@@ -2475,7 +2475,7 @@ goo_window_construct (GooWindow *window,
window->priv->list_expander = expander = gtk_expander_new_with_mnemonic (_(HIDE_TRACK_LIST));
gtk_container_add (GTK_CONTAINER (window->priv->list_expander), scrolled_window);
- gtk_expander_set_expanded (GTK_EXPANDER (expander), FALSE /*eel_gconf_get_boolean (PREF_UI_PLAYLIST, TRUE)*/);
+ gtk_expander_set_expanded (GTK_EXPANDER (expander), FALSE /*g_settings_get_boolean (window->priv->settings_ui, PREF_UI_PLAYLIST)*/);
g_signal_connect (expander,
"notify::expanded",
G_CALLBACK (list_expander_expanded_cb),
@@ -2493,11 +2493,11 @@ goo_window_construct (GooWindow *window,
window_sync_ui_with_preferences (window);
gtk_window_set_default_size (GTK_WINDOW (window),
- eel_gconf_get_integer (PREF_UI_WINDOW_WIDTH, DEFAULT_WIN_WIDTH),
- eel_gconf_get_integer (PREF_UI_WINDOW_HEIGHT, DEFAULT_WIN_HEIGHT));
+ g_settings_get_int (window->priv->settings_ui, PREF_UI_WINDOW_WIDTH),
+ g_settings_get_int (window->priv->settings_ui, PREF_UI_WINDOW_HEIGHT));
goo_volume_tool_button_set_volume (GOO_VOLUME_TOOL_BUTTON (window->priv->volume_button),
- eel_gconf_get_integer (PREF_GENERAL_VOLUME, DEFAULT_VOLUME) / 100.0,
+ g_settings_get_int (window->priv->settings_general, PREF_GENERAL_VOLUME) / 100.0,
TRUE);
/* The status icon. */
@@ -2526,32 +2526,30 @@ goo_window_construct (GooWindow *window,
/* Add notification callbacks. */
- i = 0;
-
- window->priv->cnxn_id[i++] = eel_gconf_notification_add (
- PREF_UI_TOOLBAR,
- pref_view_toolbar_changed,
- window);
- window->priv->cnxn_id[i++] = eel_gconf_notification_add (
- PREF_UI_STATUSBAR,
- pref_view_statusbar_changed,
- window);
- window->priv->cnxn_id[i++] = eel_gconf_notification_add (
- PREF_UI_PLAYLIST,
- pref_view_playlist_changed,
- window);
- window->priv->cnxn_id[i++] = eel_gconf_notification_add (
- PREF_PLAYLIST_PLAYALL,
- pref_playlist_playall_changed,
- window);
- window->priv->cnxn_id[i++] = eel_gconf_notification_add (
- PREF_PLAYLIST_SHUFFLE,
- pref_playlist_shuffle_changed,
- window);
- window->priv->cnxn_id[i++] = eel_gconf_notification_add (
- PREF_PLAYLIST_REPEAT,
- pref_playlist_repeat_changed,
- window);
+ g_signal_connect (window->priv->settings_ui,
+ "changed::" PREF_UI_TOOLBAR,
+ G_CALLBACK (pref_view_toolbar_changed),
+ window);
+ g_signal_connect (window->priv->settings_ui,
+ "changed::" PREF_UI_STATUSBAR,
+ G_CALLBACK (pref_view_statusbar_changed),
+ window);
+ g_signal_connect (window->priv->settings_ui,
+ "changed::" PREF_UI_PLAYLIST,
+ G_CALLBACK (pref_view_playlist_changed),
+ window);
+ g_signal_connect (window->priv->settings_playlist,
+ "changed::" PREF_PLAYLIST_PLAYALL,
+ G_CALLBACK (pref_playlist_playall_changed),
+ window);
+ g_signal_connect (window->priv->settings_playlist,
+ "changed::" PREF_PLAYLIST_SHUFFLE,
+ G_CALLBACK (pref_playlist_shuffle_changed),
+ window);
+ g_signal_connect (window->priv->settings_playlist,
+ "changed::" PREF_PLAYLIST_REPEAT,
+ G_CALLBACK (pref_playlist_repeat_changed),
+ window);
/* Media keys*/
@@ -2567,9 +2565,13 @@ goo_window_new (BraseroDrive *drive)
GooWindow *window;
if (drive == NULL) {
- char *default_device;
+ GSettings *settings;
+ char *default_device;
+
+ settings = g_settings_new (GOOBOX_SCHEMA_GENERAL);
+ default_device = g_settings_get_string (settings, PREF_GENERAL_DEVICE);
+ g_object_unref (settings);
- default_device = eel_gconf_get_string (PREF_GENERAL_DEVICE, NULL);
if (default_device != NULL)
drive = main_get_drive_for_device (default_device);
if (drive == NULL)
@@ -2638,8 +2640,8 @@ goo_window_play (GooWindow *window)
gboolean play_all;
gboolean shuffle;
- play_all = eel_gconf_get_boolean (PREF_PLAYLIST_PLAYALL, TRUE);
- shuffle = eel_gconf_get_boolean (PREF_PLAYLIST_SHUFFLE, FALSE);
+ play_all = g_settings_get_boolean (window->priv->settings_playlist, PREF_PLAYLIST_PLAYALL);
+ shuffle = g_settings_get_boolean (window->priv->settings_playlist, PREF_PLAYLIST_SHUFFLE);
create_playlist (window, play_all, shuffle);
if (window->priv->current_track != NULL)
@@ -2969,7 +2971,7 @@ open_response_cb (GtkDialog *file_sel,
/* Save the folder */
folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (file_sel));
- eel_gconf_set_path (PREF_GENERAL_COVER_PATH, folder);
+ g_settings_set_string (window->priv->settings_general, PREF_GENERAL_COVER_PATH, folder);
g_free (folder);
/* Load the image. */
@@ -3008,7 +3010,7 @@ goo_window_pick_cover_from_disk (GooWindow *window)
gtk_file_chooser_set_use_preview_label (GTK_FILE_CHOOSER (file_sel), FALSE);
gtk_file_chooser_set_preview_widget_active (GTK_FILE_CHOOSER (file_sel), TRUE);
- path = eel_gconf_get_path (PREF_GENERAL_COVER_PATH, "~");
+ path = g_settings_get_string (window->priv->settings_general, PREF_GENERAL_COVER_PATH);
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (file_sel), path);
g_free (path);
diff --git a/src/gtk-utils.c b/src/gtk-utils.c
index e473ad7..b908930 100644
--- a/src/gtk-utils.c
+++ b/src/gtk-utils.c
@@ -24,6 +24,8 @@
#include <math.h>
#include <string.h>
#include "gtk-utils.h"
+#include "glib-utils.h"
+
#define REQUEST_ENTRY_WIDTH 220
@@ -99,7 +101,6 @@ _gtk_message_dialog_new (GtkWindow *parent,
d = gtk_dialog_new_with_buttons ("", parent, flags, NULL);
gtk_window_set_resizable (GTK_WINDOW (d), FALSE);
- gtk_dialog_set_has_separator (GTK_DIALOG (d), FALSE);
gtk_container_set_border_width (GTK_CONTAINER (d), 6);
gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (d))), 6);
gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (d))), 8);
@@ -191,7 +192,6 @@ _gtk_request_dialog_run (GtkWindow *parent,
d = gtk_dialog_new_with_buttons ("", parent, flags, NULL);
gtk_window_set_resizable (GTK_WINDOW (d), FALSE);
- gtk_dialog_set_has_separator (GTK_DIALOG (d), FALSE);
gtk_container_set_border_width (GTK_CONTAINER (d), 6);
gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (d))), 6);
gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (d))), 12);
@@ -291,7 +291,6 @@ _gtk_yesno_dialog_new (GtkWindow *parent,
d = gtk_dialog_new_with_buttons ("", parent, flags, NULL);
gtk_window_set_resizable (GTK_WINDOW (d), FALSE);
- gtk_dialog_set_has_separator (GTK_DIALOG (d), FALSE);
gtk_container_set_border_width (GTK_CONTAINER (d), 6);
gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (d))), 6);
gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (d))), 8);
@@ -342,105 +341,26 @@ _gtk_yesno_dialog_new (GtkWindow *parent,
}
-static void
-yesno__check_button_toggled_cb (GtkToggleButton *button,
- const char *gconf_key)
-{
- eel_gconf_set_boolean (gconf_key,
- ! gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)));
-}
+typedef struct {
+ GSettings *settings;
+ char *key;
+} DialogWithButtonData;
-GtkWidget*
-_gtk_yesno_dialog_with_checkbutton_new (GtkWindow *parent,
- GtkDialogFlags flags,
- const char *message,
- const char *no_button_text,
- const char *yes_button_text,
- const char *check_button_label,
- const char *gconf_key)
+static void
+dialog_with_button_data_free (DialogWithButtonData *data)
{
- GtkWidget *d;
- GtkWidget *label;
- GtkWidget *image;
- GtkWidget *hbox;
- GtkWidget *button;
- GtkWidget *check_button;
- char *stock_id = GTK_STOCK_DIALOG_QUESTION;
-
- d = gtk_dialog_new_with_buttons ("", parent, flags, NULL);
- gtk_window_set_resizable (GTK_WINDOW (d), FALSE);
-
- gtk_dialog_set_has_separator (GTK_DIALOG (d), FALSE);
- gtk_container_set_border_width (GTK_CONTAINER (d), 6);
- gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (d))), 6);
- gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (d))), 8);
-
- /* Add label and image */
-
- image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
-
- label = gtk_label_new (message);
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_label_set_selectable (GTK_LABEL (label), TRUE);
-
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
-
- gtk_box_pack_start (GTK_BOX (hbox), image,
- FALSE, FALSE, 0);
-
- gtk_box_pack_start (GTK_BOX (hbox), label,
- TRUE, TRUE, 0);
-
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (d))),
- hbox,
- FALSE, FALSE, 0);
-
- /* Add checkbutton */
-
- check_button = gtk_check_button_new_with_mnemonic (check_button_label);
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (d))),
- check_button,
- FALSE, FALSE, 0);
- gtk_widget_show (check_button);
-
- gtk_widget_show_all (hbox);
-
- /* Add buttons */
-
- button = create_button (GTK_STOCK_CANCEL, no_button_text);
- gtk_dialog_add_action_widget (GTK_DIALOG (d),
- button,
- GTK_RESPONSE_CANCEL);
-
- /**/
-
- button = create_button (GTK_STOCK_OK, yes_button_text);
- gtk_dialog_add_action_widget (GTK_DIALOG (d),
- button,
- GTK_RESPONSE_YES);
-
- /**/
-
- gtk_dialog_set_default_response (GTK_DIALOG (d), GTK_RESPONSE_YES);
-
- g_signal_connect (G_OBJECT (check_button),
- "toggled",
- G_CALLBACK (yesno__check_button_toggled_cb),
- (gpointer) gconf_key);
-
- return d;
+ _g_object_unref (data->settings);
+ g_free (data->key);
+ g_free (data);
}
static void
-ok__check_button_toggled_cb (GtkToggleButton *button,
- const char *gconf_key)
+ok__check_button_toggled_cb (GtkToggleButton *button,
+ DialogWithButtonData *data)
{
- eel_gconf_set_boolean (gconf_key,
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)));
+ g_settings_set_boolean (data->settings, data->key, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)));
}
@@ -450,7 +370,8 @@ _gtk_ok_dialog_with_checkbutton_new (GtkWindow *parent,
const char *message,
const char *ok_button_text,
const char *check_button_label,
- const char *gconf_key)
+ GSettings *settings,
+ const char *key)
{
GtkWidget *d;
GtkWidget *label;
@@ -460,6 +381,7 @@ _gtk_ok_dialog_with_checkbutton_new (GtkWindow *parent,
GtkWidget *check_button;
char *stock_id = GTK_STOCK_DIALOG_INFO;
char *escaped_message, *markup_text;
+ DialogWithButtonData *data;
d = gtk_dialog_new_with_buttons ("", parent, flags, NULL);
gtk_window_set_resizable (GTK_WINDOW (d), FALSE);
@@ -501,8 +423,7 @@ _gtk_ok_dialog_with_checkbutton_new (GtkWindow *parent,
FALSE, FALSE, 0);
gtk_widget_show (check_button);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
- eel_gconf_get_boolean (gconf_key, FALSE));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), g_settings_get_boolean (settings, key));
gtk_widget_show_all (hbox);
@@ -517,122 +438,16 @@ _gtk_ok_dialog_with_checkbutton_new (GtkWindow *parent,
gtk_dialog_set_default_response (GTK_DIALOG (d), GTK_RESPONSE_YES);
- g_signal_connect (G_OBJECT (check_button),
- "toggled",
- G_CALLBACK (ok__check_button_toggled_cb),
- (gpointer) gconf_key);
-
- return d;
-}
-
-
-GtkWidget*
-_gtk_message_dialog_with_checkbutton_new (GtkWindow *parent,
- GtkDialogFlags flags,
- const char *stock_id,
- const char *message,
- const char *secondary_message,
- const char *gconf_key,
- const char *check_button_label,
- const char *first_button_text,
- ...)
-{
- GtkWidget *d;
- GtkWidget *label;
- GtkWidget *image;
- GtkWidget *hbox;
- GtkWidget *check_button;
- va_list args;
- const char *text;
- int response_id;
- char *escaped_message, *markup_text;
-
- g_return_val_if_fail (message != NULL, NULL);
-
- if (stock_id == NULL)
- stock_id = GTK_STOCK_DIALOG_INFO;
-
- d = gtk_dialog_new_with_buttons ("", parent, flags, NULL);
- gtk_window_set_resizable (GTK_WINDOW (d), FALSE);
-
- gtk_dialog_set_has_separator (GTK_DIALOG (d), FALSE);
- gtk_container_set_border_width (GTK_CONTAINER (d), 6);
- gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (d))), 6);
- gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (d))), 8);
-
- /* Add label and image */
-
- image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
-
- label = gtk_label_new ("");
-
- escaped_message = g_markup_escape_text (message, -1);
- if (secondary_message != NULL) {
- char *escaped_secondary_message = g_markup_escape_text (secondary_message, -1);
- markup_text = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
- escaped_message,
- escaped_secondary_message);
- g_free (escaped_secondary_message);
- } else
- markup_text = g_strdup (escaped_message);
- gtk_label_set_markup (GTK_LABEL (label), markup_text);
- g_free (markup_text);
- g_free (escaped_message);
-
- gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_label_set_selectable (GTK_LABEL (label), TRUE);
-
- hbox = gtk_hbox_new (FALSE, 6);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
-
- gtk_box_pack_start (GTK_BOX (hbox), image,
- FALSE, FALSE, 0);
-
- gtk_box_pack_start (GTK_BOX (hbox), label,
- TRUE, TRUE, 0);
-
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (d))),
- hbox,
- FALSE, FALSE, 0);
-
- gtk_widget_show_all (hbox);
-
- /* Add checkbutton */
-
- check_button = gtk_check_button_new_with_mnemonic (check_button_label);
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (d))),
- check_button,
- FALSE, FALSE, 0);
- gtk_widget_show (check_button);
-
- /* Add buttons */
-
- if (first_button_text == NULL)
- return d;
-
- va_start (args, first_button_text);
+ data = g_new0 (DialogWithButtonData, 1);
+ data->settings = g_object_ref (settings);
+ data->key = g_strdup (key);
- text = first_button_text;
- response_id = va_arg (args, gint);
-
- while (text != NULL) {
- gtk_dialog_add_button (GTK_DIALOG (d), text, response_id);
-
- text = va_arg (args, gchar*);
- if (text == NULL)
- break;
- response_id = va_arg (args, int);
- }
-
- va_end (args);
-
- gtk_dialog_set_default_response (GTK_DIALOG (d), GTK_RESPONSE_YES);
+ g_object_set_data_full (G_OBJECT (d), "settings-data", data, (GDestroyNotify) dialog_with_button_data_free);
g_signal_connect (G_OBJECT (check_button),
"toggled",
- G_CALLBACK (yesno__check_button_toggled_cb),
- (gpointer) gconf_key);
+ G_CALLBACK (ok__check_button_toggled_cb),
+ data);
return d;
}
@@ -1053,13 +868,13 @@ _gtk_combo_box_new_with_texts (const char *first_text,
va_list args;
const char *text;
- combo_box = gtk_combo_box_new_text ();
+ combo_box = gtk_combo_box_text_new ();
va_start (args, first_text);
text = first_text;
while (text != NULL) {
- gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), text);
+ gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo_box), NULL, text);
text = va_arg (args, const char *);
}
@@ -1081,7 +896,7 @@ _gtk_combo_box_append_texts (GtkComboBox *combo_box,
text = first_text;
while (text != NULL) {
- gtk_combo_box_append_text (combo_box, text);
+ gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo_box), NULL, text);
text = va_arg (args, const char *);
}
@@ -1207,14 +1022,13 @@ _g_launch_command (GtkWidget *parent,
return;
}
- launch_context = gdk_app_launch_context_new ();
- gdk_app_launch_context_set_screen (launch_context, gtk_widget_get_screen (parent));
-
+ launch_context = gdk_display_get_app_launch_context (gtk_widget_get_display (parent));
if (! g_app_info_launch (app_info, files, G_APP_LAUNCH_CONTEXT (launch_context), &error)) {
_gtk_error_dialog_from_gerror_show(GTK_WINDOW (parent), _("Could not launch the application"), &error);
return;
}
+ g_object_unref (launch_context);
g_object_unref (app_info);
}
diff --git a/src/gtk-utils.h b/src/gtk-utils.h
index 1d50de7..300ee0b 100644
--- a/src/gtk-utils.h
+++ b/src/gtk-utils.h
@@ -59,20 +59,13 @@ GtkWidget* _gtk_yesno_dialog_new (GtkWindow *parent,
const char *no_button_text,
const char *yes_button_text);
GtkWidget*
-_gtk_yesno_dialog_with_checkbutton_new (GtkWindow *parent,
- GtkDialogFlags flags,
- const char *message,
- const char *no_button_text,
- const char *yes_button_text,
- const char *check_button_label,
- const char *gconf_key);
-GtkWidget*
_gtk_ok_dialog_with_checkbutton_new (GtkWindow *parent,
GtkDialogFlags flags,
const char *message,
const char *ok_button_text,
const char *check_button_label,
- const char *gconf_key);
+ GSettings *settings,
+ const char *key);
void
_gtk_error_dialog_from_gerror_run (GtkWindow *parent,
const char *title,
diff --git a/src/main.c b/src/main.c
index 29d1c8f..42bca76 100644
--- a/src/main.c
+++ b/src/main.c
@@ -54,7 +54,7 @@ enum {
COMMAND_EJECT_DISK,
COMMAND_HIDE_SHOW,
COMMAND_VOLUME_UP,
- COMMAND_vOLUME_DOWN,
+ COMMAND_VOLUME_DOWN,
COMMAND_QUIT,
COMMAND_PRESENT,
COMMAND_SET_DEVICE
@@ -222,7 +222,7 @@ unique_app_message_received_cb (UniqueApp *unique_app,
}
break;
- case COMMAND_vOLUME_DOWN:
+ case COMMAND_VOLUME_DOWN:
{
double volume;
@@ -300,7 +300,6 @@ static void
release_data (void)
{
_g_object_unref (application);
- eel_global_client_free ();
}
@@ -335,7 +334,7 @@ prepare_application (void)
"eject", COMMAND_EJECT_DISK,
"hide-show", COMMAND_HIDE_SHOW,
"volume-up", COMMAND_VOLUME_UP,
- "volume-down", COMMAND_vOLUME_DOWN,
+ "volume-down", COMMAND_VOLUME_DOWN,
"quit", COMMAND_QUIT,
"present", COMMAND_PRESENT,
"set-device", COMMAND_SET_DEVICE,
@@ -369,7 +368,7 @@ prepare_application (void)
else if (VolumeUp)
unique_app_send_message (application, COMMAND_VOLUME_UP, NULL);
else if (VolumeDown)
- unique_app_send_message (application, COMMAND_vOLUME_DOWN, NULL);
+ unique_app_send_message (application, COMMAND_VOLUME_DOWN, NULL);
else if (Quit)
unique_app_send_message (application, COMMAND_QUIT, NULL);
@@ -380,7 +379,6 @@ prepare_application (void)
g_set_application_name (_("CD Player"));
gtk_window_set_default_icon_name ("goobox");
goo_stock_init ();
- eel_gconf_monitor_add ("/apps/goobox");
g_signal_connect (application,
"message-received",
G_CALLBACK (unique_app_message_received_cb),
diff --git a/src/preferences.h b/src/preferences.h
index c267418..d443dd9 100644
--- a/src/preferences.h
+++ b/src/preferences.h
@@ -3,7 +3,7 @@
/*
* Goo
*
- * Copyright (C) 2004 Free Software Foundation, Inc.
+ * Copyright (C) 2004-2011 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,56 +24,39 @@
#define PREFERENCES_H
#include <gtk/gtk.h>
-#include "typedefs.h"
-#include "goo-window.h"
-#define PREF_GENERAL_DEVICE "/apps/goobox/general/device"
-#define PREF_GENERAL_VOLUME "/apps/goobox/general/volume"
-#define PREF_GENERAL_COVER_PATH "/apps/goobox/general/cover_path"
-#define PREF_GENERAL_USE_SJ "/apps/goobox/general/use_sound_juicer"
-#define PREF_GENERAL_AUTOPLAY "/apps/goobox/general/autoplay"
-
-#define PREF_UI_TOOLBAR "/apps/goobox/ui/toolbar_visible"
-#define PREF_UI_STATUSBAR "/apps/goobox/ui/statusbar_visible"
-#define PREF_UI_PLAYLIST "/apps/goobox/ui/playlist_visible"
-#define PREF_UI_WINDOW_WIDTH "/apps/goobox/ui/window_width"
-#define PREF_UI_WINDOW_HEIGHT "/apps/goobox/ui/window_height"
-
-#define PREF_PLAYLIST_PLAYALL "/apps/goobox/playlist/play_all"
-#define PREF_PLAYLIST_SHUFFLE "/apps/goobox/playlist/shuffle"
-#define PREF_PLAYLIST_REPEAT "/apps/goobox/playlist/repeat"
-#define PREF_PLAYLIST_SORT_METHOD "/apps/goobox/playlist/sort_method"
-#define PREF_PLAYLIST_SORT_TYPE "/apps/goobox/playlist/sort_type"
-
-#define PREF_EXTRACT_DESTINATION "/apps/goobox/dialogs/extract/destination"
-#define PREF_EXTRACT_FILETYPE "/apps/goobox/dialogs/extract/file_type"
-#define PREF_EXTRACT_SAVE_PLAYLIST "/apps/goobox/dialogs/extract/save_playlist"
-#define PREF_RIPPER_VIEW_DISTINATION "/apps/goobox/dialogs/ripper/view_destination"
-
-#define PREF_ENCODER_OGG_QUALITY "/apps/goobox/encoder/ogg_quality"
-#define PREF_ENCODER_FLAC_COMPRESSION "/apps/goobox/encoder/flac_compression"
-#
-#define PREF_DESKTOP_ICON_THEME "/desktop/gnome/file_views/icon_theme"
-#define PREF_DESKTOP_MENUS_HAVE_TEAROFF "/desktop/gnome/interface/menus_have_tearoff"
-#define PREF_DESKTOP_MENUBAR_DETACHABLE "/desktop/gnome/interface/menubar_detachable"
-#define PREF_DESKTOP_TOOLBAR_DETACHABLE "/desktop/gnome/interface/toolbar_detachable"
-
-void pref_util_save_window_geometry (GtkWindow *window,
- const char *dialog);
-
-void pref_util_restore_window_geometry (GtkWindow *window,
- const char *dialog);
-
-GooFileFormat pref_get_file_format (void);
-void pref_set_file_format (GooFileFormat value);
-
-
-WindowSortMethod preferences_get_sort_method (void);
-void preferences_set_sort_method (WindowSortMethod i_value);
-
-GtkSortType preferences_get_sort_type (void);
-void preferences_set_sort_type (GtkSortType i_value);
-
-gboolean preferences_get_use_sound_juicer (void);
+#define GOOBOX_SCHEMA "org.gnome.Goobox"
+#define GOOBOX_SCHEMA_GENERAL GOOBOX_SCHEMA ".General"
+#define GOOBOX_SCHEMA_UI GOOBOX_SCHEMA ".UI"
+#define GOOBOX_SCHEMA_PLAYLIST GOOBOX_SCHEMA ".Playlist"
+#define GOOBOX_SCHEMA_RIPPER GOOBOX_SCHEMA ".Ripper"
+#define GOOBOX_SCHEMA_ENCODER GOOBOX_SCHEMA ".Encoder"
+
+#define PREF_GENERAL_DEVICE "device"
+#define PREF_GENERAL_VOLUME "volume"
+#define PREF_GENERAL_COVER_PATH "cover-path"
+#define PREF_GENERAL_USE_SJ "use-sound-juicer"
+#define PREF_GENERAL_AUTOPLAY "autoplay"
+
+#define PREF_UI_TOOLBAR "toolbar-visible"
+#define PREF_UI_STATUSBAR "statusbar-visible"
+#define PREF_UI_PLAYLIST "playlist-visible"
+#define PREF_UI_WINDOW_WIDTH "window-width"
+#define PREF_UI_WINDOW_HEIGHT "window-height"
+
+#define PREF_PLAYLIST_PLAYALL "play-all"
+#define PREF_PLAYLIST_SHUFFLE "shuffle"
+#define PREF_PLAYLIST_REPEAT "repeat"
+#define PREF_PLAYLIST_SORT_METHOD "sort-method"
+#define PREF_PLAYLIST_SORT_TYPE "sort-type"
+
+#define PREF_RIPPER_DESTINATION "destination"
+#define PREF_RIPPER_FILETYPE "file-type"
+#define PREF_RIPPER_SAVE_PLAYLIST "save-playlist"
+#define PREF_RIPPER_VIEW_DISTINATION "view-destination"
+
+#define PREF_ENCODER_OGG_QUALITY "ogg-quality"
+#define PREF_ENCODER_FLAC_COMPRESSION "flac-compression"
+#define PREF_ENCODER_MP3_QUALITY "mp3-quality"
#endif /* PREFERENCES_H */
diff --git a/src/typedefs.h b/src/typedefs.h
index 4d4f46d..44c24f1 100644
--- a/src/typedefs.h
+++ b/src/typedefs.h
@@ -24,6 +24,7 @@
#define TYPEDEFS_H
#include <glib.h>
+#include <glib-object.h>
#define OGG_ENCODER "vorbisenc"
#define FLAC_ENCODER "flacenc"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]