summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoss Burton <rburton@src.gnome.org>2004-11-20 12:54:26 +0000
committerRoss Burton <rburton@src.gnome.org>2004-11-20 12:54:26 +0000
commit8b82df353c0b225ec20be191f658e9af000d7031 (patch)
tree6270a5931c875deef080cffdfbe209aa736368da /src
parent05488c6a503335ec5cc836d7acf39dd2afbe8115 (diff)
Merge the profile branch, start work on SJ2
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rw-r--r--src/sj-extracting.c27
-rw-r--r--src/sj-extractor.c189
-rw-r--r--src/sj-extractor.h13
-rw-r--r--src/sj-main.c92
-rw-r--r--src/sj-prefs.c86
-rw-r--r--src/sound-juicer.h2
7 files changed, 125 insertions, 288 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 483dd09..95e95bc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -13,7 +13,7 @@ AM_CPPFLAGS = \
-DPIXMAPDIR=\""$(datadir)/pixmaps"\" \
-DPKGDATADIR=\""$(datadir)/sound-juicer"\" \
@MUSICBRAINZ_CFLAGS@ @GSTREAMER_CFLAGS@ \
- @UI_CFLAGS@ @HAL_CFLAGS@
+ @MEDIA_PROFILES_CFLAGS@ @UI_CFLAGS@ @HAL_CFLAGS@
# We always build Sound Juicer
@@ -45,7 +45,7 @@ sound_juicer_SOURCES = \
$(BACONFILES) \
$(MARSHALFILES)
-sound_juicer_LDFLAGS = @MUSICBRAINZ_LIBS@ @GSTREAMER_LIBS@ @UI_LIBS@ @HAL_LIBS@
+sound_juicer_LDFLAGS = @MUSICBRAINZ_LIBS@ @MEDIA_PROFILES_LIBS@ @GSTREAMER_LIBS@ @UI_LIBS@ @HAL_LIBS@
#
diff --git a/src/sj-extracting.c b/src/sj-extracting.c
index 4da16de..ab4ab8b 100644
--- a/src/sj-extracting.c
+++ b/src/sj-extracting.c
@@ -106,30 +106,13 @@ static Progress before;
static char*
build_filename (const TrackDetails *track)
{
- char *realfile, *realpath, *filename, *extension, *path;
- EncoderFormat format;
+ char *realfile, *realpath, *filename, *path;
+ GMAudioProfile *profile;
realpath = filepath_parse_pattern (path_pattern, track);
realfile = filepath_parse_pattern (file_pattern, track);
- g_object_get (extractor, "format", &format, NULL);
- switch (format) {
- case SJ_FORMAT_VORBIS:
- extension = ".ogg";
- break;
- case SJ_FORMAT_MPEG:
- extension = ".mp3";
- break;
- case SJ_FORMAT_FLAC:
- extension = ".flac";
- break;
- case SJ_FORMAT_WAVE:
- extension = ".wav";
- break;
- default:
- g_free (realpath);
- g_free (realfile);
- g_return_val_if_reached (NULL);
- }
- filename = g_strconcat (realfile, extension, NULL);
+ g_object_get (extractor, "profile", &profile, NULL);
+ filename = g_strdup_printf("%s.%s", realfile,
+ gm_audio_profile_get_extension(profile));
path = g_build_filename (base_path, realpath, filename, NULL);
g_free (realpath);
realpath = g_filename_from_utf8 (path, -1, NULL, NULL, NULL);
diff --git a/src/sj-extractor.c b/src/sj-extractor.c
index 8d0d545..f911822 100644
--- a/src/sj-extractor.c
+++ b/src/sj-extractor.c
@@ -28,33 +28,18 @@
#include <glib/gtypes.h>
#include <glib-object.h>
#include <gst/gst.h>
+#include <gst/gconf/gconf.h>
#include <libgnome/gnome-i18n.h>
+#include <profiles/gnome-media-profiles.h>
#include "sj-extractor.h"
#include "sj-structures.h"
#include "sj-error.h"
#include "sj-util.h"
-GType
-encoding_format_get_type (void)
-{
- static GType etype = 0;
- if (etype == 0) {
- static const GEnumValue values[] = {
- { SJ_FORMAT_VORBIS, "VORBIS", "Ogg Vorbis" },
- { SJ_FORMAT_MPEG, "MPEG", "MPEG" },
- { SJ_FORMAT_FLAC, "FLAC", "FLAC" },
- { SJ_FORMAT_WAVE, "WAVE", "Wave" },
- { 0, NULL, NULL }
- };
- etype = g_enum_register_static ("EncodingFormat", values);
- }
- return etype;
-}
-
/* Properties */
enum {
PROP_0,
- PROP_FORMAT,
+ PROP_PROFILE,
};
/* Signals */
@@ -67,10 +52,10 @@ enum {
static int sje_table_signals[LAST_SIGNAL] = { 0 };
-#define DEFAULT_ENCODING_FORMAT SJ_FORMAT_VORBIS
+#define DEFAULT_AUDIO_PROFILE_NAME "cdlossy"
struct SjExtractorPrivate {
- EncoderFormat format;
+ GMAudioProfile *profile;
gboolean rebuild_pipeline;
GstElement *pipeline;
GstElement *cdparanoia, *encoder, *filesink;
@@ -136,11 +121,9 @@ static void sj_extractor_class_init (SjExtractorClass *klass)
object_class->finalize = sj_extractor_finalize;
/* Properties */
- g_object_class_install_property (object_class, PROP_FORMAT,
- g_param_spec_enum ("format", _("Encoding format"), _("The format to write the encoded audio in"),
- encoding_format_get_type(),
- DEFAULT_ENCODING_FORMAT, G_PARAM_READWRITE));
-
+ g_object_class_install_property (object_class, PROP_PROFILE,
+ g_param_spec_pointer("profile", _("Gnome Audio Profile"), _("The Gnome Audio Profile used for encoding audio"), G_PARAM_READWRITE));
+
/* Signals */
sje_table_signals[PROGRESS] =
g_signal_new ("progress",
@@ -172,7 +155,7 @@ static void sj_extractor_class_init (SjExtractorClass *klass)
static void sj_extractor_instance_init (SjExtractor *extractor)
{
extractor->priv = g_new0 (SjExtractorPrivate, 1);
- extractor->priv->format = DEFAULT_ENCODING_FORMAT;
+ extractor->priv->profile = gm_audio_profile_lookup(DEFAULT_AUDIO_PROFILE_NAME);
extractor->priv->rebuild_pipeline = TRUE;
}
@@ -181,8 +164,8 @@ static void sj_extractor_set_property (GObject *object, guint property_id,
{
SjExtractorPrivate *priv = (SjExtractorPrivate*)SJ_EXTRACTOR(object)->priv;
switch (property_id) {
- case PROP_FORMAT:
- priv->format = g_value_get_enum (value);
+ case PROP_PROFILE:
+ priv->profile = (GMAudioProfile *) g_value_get_pointer (value);
priv->rebuild_pipeline = TRUE;
break;
default:
@@ -195,8 +178,8 @@ static void sj_extractor_get_property (GObject *object, guint property_id,
{
SjExtractorPrivate *priv = (SjExtractorPrivate*)SJ_EXTRACTOR(object)->priv;
switch (property_id) {
- case PROP_FORMAT:
- g_value_set_enum (value, priv->format);
+ case PROP_PROFILE:
+ g_value_set_pointer (value, priv->profile);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -243,33 +226,17 @@ static GstElement* build_encoder (SjExtractor *extractor)
{
SjExtractorPrivate *priv;
GstElement *element = NULL;
+ char *pipeline;
+
g_return_val_if_fail (SJ_IS_EXTRACTOR (extractor), NULL);
priv = (SjExtractorPrivate*)extractor->priv;
- switch (priv->format) {
- case SJ_FORMAT_VORBIS:
- element = gst_element_factory_make ("vorbisenc", "encoder");
- g_object_set (G_OBJECT (element), "quality", 0.6, NULL);
- priv->encoder_name = "vorbis";
- break;
- case SJ_FORMAT_MPEG:
- element = gst_element_factory_make ("lame", "encoder");
- priv->encoder_name = "lame";
- break;
- case SJ_FORMAT_FLAC:
- element = gst_element_factory_make ("flacenc", "encoder");
- priv->encoder_name = "flacenc";
- break;
- case SJ_FORMAT_WAVE:
- element = gst_element_factory_make ("wavenc", "encoder");
- priv->encoder_name = "wavenc";
- break;
- default:
- g_return_val_if_reached (NULL);
- }
+
+ pipeline = g_strdup_printf ("audioconvert ! %s", gm_audio_profile_get_pipeline (priv->profile));
+ element = gst_gconf_render_bin_from_description (pipeline);
+ g_free(pipeline);
return element;
}
-#if defined(GSTREAMER_0_8)
static void error_cb (GstElement *element, GObject *arg, GError *err, gchar *arg2, gpointer user_data)
{
SjExtractor *extractor = SJ_EXTRACTOR (user_data);
@@ -277,19 +244,6 @@ static void error_cb (GstElement *element, GObject *arg, GError *err, gchar *arg
sje_table_signals[ERROR],
0, err);
}
-#elif defined(GSTREAMER_0_6)
-static void error_cb (GstElement *element, GObject *arg, gchar *arg2, gpointer user_data)
-{
- SjExtractor *extractor = SJ_EXTRACTOR (user_data);
- GError *error = NULL;
- g_set_error (&error,
- SJ_ERROR, SJ_ERROR_INTERNAL_ERROR,
- arg2);
- g_signal_emit (G_OBJECT (extractor),
- sje_table_signals[ERROR],
- 0, error);
-}
-#endif
static void build_pipeline (SjExtractor *extractor)
{
@@ -436,10 +390,6 @@ void sj_extractor_set_paranoia (SjExtractor *extractor, const int paranoia_mode)
void sj_extractor_extract_track (SjExtractor *extractor, const TrackDetails *track, const char* path, GError **error)
{
GstEvent *event;
-#ifndef HAVE_GST_GSTTAGINTERFACE_H
- GstCaps *caps;
- char *tracknumber;
-#endif
static GstFormat format = GST_FORMAT_TIME;
gint64 nanos;
SjExtractorPrivate *priv;
@@ -471,43 +421,41 @@ void sj_extractor_extract_track (SjExtractor *extractor, const TrackDetails *tra
g_object_set (G_OBJECT (priv->filesink), "location", path, NULL);
/* Set the metadata */
- /* TODO; this works with Vorbis and MP3 and will work with FLAC when the
- property is added. Wave ... news not so good. */
-#ifdef HAVE_GST_GSTTAGINTERFACE_H
- if (GST_IS_TAG_SETTER (priv->encoder)) {
- gst_tag_setter_add (GST_TAG_SETTER (priv->encoder),
- GST_TAG_MERGE_REPLACE_ALL,
- GST_TAG_TITLE, track->title,
- GST_TAG_ARTIST, track->artist,
- GST_TAG_TRACK_NUMBER, track->number,
- GST_TAG_TRACK_COUNT, track->album->number,
- GST_TAG_ALBUM, track->album->title,
- GST_TAG_COMMENT, _("Ripped with Sound Juicer"),
- NULL);
- if (track->genre != LAST_GENRE) {
- gst_tag_setter_add (GST_TAG_SETTER (priv->encoder),
- /* TODO: is APPEND right? */
- GST_TAG_MERGE_APPEND,
- GST_TAG_GENRE, sj_genre_name (track->genre),
- NULL);
+ {
+ GList *elts = NULL, *elt = NULL;
+ gboolean taggable = FALSE;
+ if (GST_IS_BIN (priv->encoder)) {
+ elts = (GList *) gst_bin_get_list(GST_BIN (priv->encoder));
+ } else {
+ elts = g_list_append (elts, priv->encoder);
+ }
+
+ for (elt = elts; elt; elt = elt->next) {
+ if (GST_IS_TAG_SETTER (elt->data)) {
+ gst_tag_setter_add (GST_TAG_SETTER (elt->data),
+ GST_TAG_MERGE_REPLACE_ALL,
+ GST_TAG_TITLE, track->title,
+ GST_TAG_ARTIST, track->artist,
+ GST_TAG_TRACK_NUMBER, track->number,
+ GST_TAG_TRACK_COUNT, track->album->number,
+ GST_TAG_ALBUM, track->album->title,
+ GST_TAG_ENCODER, _("Sound Juicer"),
+ GST_TAG_ENCODER_VERSION, VERSION,
+ NULL);
+ if (track->genre != LAST_GENRE) {
+ gst_tag_setter_add (GST_TAG_SETTER (elt->data),
+ /* TODO: is APPEND right? */
+ GST_TAG_MERGE_APPEND,
+ GST_TAG_GENRE, sj_genre_name (track->genre),
+ NULL);
+ }
+ taggable = TRUE;
+ }
+ }
+ if (!taggable) {
+ g_warning ("Couldn't find an encoding element with tag support");
}
- } else {
- g_warning ("The current encoding element doesn't have tag support");
}
-#else
- tracknumber = g_strdup_printf("%d/%d", track->number, track->album->number);
- caps = GST_CAPS_NEW ("soundjuicer_metadata",
- "application/x-gst-metadata",
- "title", GST_PROPS_STRING (track->title),
- "artist", GST_PROPS_STRING (track->artist),
- "tracknum", GST_PROPS_STRING (tracknumber),
- "tracknumber", GST_PROPS_STRING (tracknumber),
- "album", GST_PROPS_STRING (track->album->title),
- "comment", GST_PROPS_STRING(_("Ripped with Sound Juicer"))
- );
- g_object_set (G_OBJECT (priv->encoder), "metadata", caps, NULL);
- g_free (tracknumber);
-#endif /* HAVE_GST_GSTTAGINTERFACE_H */
/* Let's get ready to rumble! */
gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
@@ -576,32 +524,21 @@ gboolean sj_extractor_supports_encoding (GError **error)
return TRUE;
}
-gboolean sj_extractor_supports_format (EncoderFormat format)
+gboolean sj_extractor_supports_profile (GMAudioProfile *profile)
{
GstElement *element = NULL;
-
- switch (format) {
- case SJ_FORMAT_VORBIS:
- element = gst_element_factory_make ("vorbisenc", "encoder");
- break;
- case SJ_FORMAT_MPEG:
- element = gst_element_factory_make ("lame", "encoder");
- break;
- case SJ_FORMAT_FLAC:
- element = gst_element_factory_make ("flacenc", "encoder");
- break;
- case SJ_FORMAT_WAVE:
- element = gst_element_factory_make ("wavenc", "encoder");
- break;
- default:
- g_return_val_if_reached (FALSE);
- }
-
+ GError *error = NULL;
+ char *pipeline;
+
+ pipeline = g_strdup_printf ("audioconvert ! %s", gm_audio_profile_get_pipeline (profile));
+ element = gst_parse_launch (pipeline, &error);
+ /* TODO: check error */
+ g_free(pipeline);
if (element) {
- g_object_unref (element);
+ gst_object_unref (GST_OBJECT (element));
return TRUE;
+ } else {
+ return FALSE;
}
-
- return FALSE;
}
diff --git a/src/sj-extractor.h b/src/sj-extractor.h
index 9874a42..da10013 100644
--- a/src/sj-extractor.h
+++ b/src/sj-extractor.h
@@ -25,20 +25,11 @@
#include <glib/gmacros.h>
#include <glib-object.h>
+#include <profiles/audio-profile.h>
#include "sj-structures.h"
G_BEGIN_DECLS
-typedef enum {
- SJ_FORMAT_VORBIS,
- SJ_FORMAT_MPEG,
- SJ_FORMAT_FLAC,
- SJ_FORMAT_WAVE,
- SJ_NUMBER_FORMATS
-} EncoderFormat;
-
-GType encoding_format_get_type (void);
-
#define SJ_TYPE_EXTRACTOR (sj_extractor_get_type ())
#define SJ_EXTRACTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SJ_TYPE_EXTRACTOR, SjExtractor))
#define SJ_EXTRACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SJ_TYPE_EXTRACTOR, SjExtractorClass))
@@ -78,7 +69,7 @@ void sj_extractor_extract_track (SjExtractor *extractor, const TrackDetails *tra
void sj_extractor_cancel_extract (SjExtractor *extractor);
-gboolean sj_extractor_supports_format (EncoderFormat format);
+gboolean sj_extractor_supports_profile (GMAudioProfile *profile);
gboolean sj_extractor_supports_encoding (GError **error);
diff --git a/src/sj-main.c b/src/sj-main.c
index 53611c4..ccb9858 100644
--- a/src/sj-main.c
+++ b/src/sj-main.c
@@ -31,6 +31,7 @@
#include <gconf/gconf-client.h>
#include <libgnome/gnome-help.h>
#include <libgnomeui/gnome-ui-init.h>
+#include <profiles/gnome-media-profiles.h>
#include <gst/gst.h>
#include "sj-about.h"
@@ -603,69 +604,33 @@ void device_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, g
}
}
-/**
- * The /apps/sound-juicer/format key has changed.
- */
-void format_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
+void profile_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
{
- char* value;
- GEnumValue* enumvalue;
- int i;
- int format;
- gboolean any_support = FALSE;
- gboolean supported[SJ_NUMBER_FORMATS];
-
- g_assert (strcmp (entry->key, GCONF_FORMAT) == 0);
+ GMAudioProfile *profile;
+
+ g_assert (strcmp (entry->key, GCONF_AUDIO_PROFILE) == 0);
if (!entry->value) return;
- value = g_ascii_strup (gconf_value_get_string (entry->value), -1);
- /* TODO: this line is pretty convoluted */
- enumvalue = g_enum_get_value_by_name (g_type_class_peek (encoding_format_get_type()), value);
- if (enumvalue == NULL) {
- /* g_warning (_("Unknown format %s"), value); */
- format = 0;
- } else {
- format = enumvalue->value;
- }
- g_free (value);
-
- g_object_set (extractor, "format", format, NULL);
-
- for (i = 0; i < SJ_NUMBER_FORMATS; i++) {
- supported[i] = sj_extractor_supports_format (i);
- if (supported[i]) {
- any_support = TRUE;
- }
- }
-
- if (any_support == FALSE) {
- GError *err = NULL;
-
- g_set_error (&err, SJ_ERROR, SJ_ERROR_INTERNAL_ERROR,
- _("Cannot find any suitable encoders"));
- error_on_start (err);
- exit (1);
- }
+ profile = gm_audio_profile_lookup(gconf_value_get_string (entry->value));
+ if (profile != NULL)
+ g_object_set(extractor, "profile", profile, NULL);
- /* Popup the prefs for the user to change the encoder */
- for (i = 0; i <= SJ_NUMBER_FORMATS; i++) {
- if (supported[i] == FALSE && format == i) {
- GtkWidget *dialog;
- int response;
-
- dialog = gtk_message_dialog_new (GTK_WINDOW (main_window),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_NONE,
- _("The currently selected encoder is not available on your installation."));
- gtk_dialog_add_button (GTK_DIALOG (dialog), "gtk-quit", GTK_RESPONSE_REJECT);
- gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Change the encoder"), GTK_RESPONSE_ACCEPT);
- response = gtk_dialog_run (GTK_DIALOG (dialog));
- if (response == GTK_RESPONSE_ACCEPT) {
- gtk_widget_destroy (dialog);
- on_edit_preferences_cb (NULL, NULL);
- } else {
- gtk_main_quit ();
- }
+ if (profile == NULL || !sj_extractor_supports_profile(profile)) {
+ GtkWidget *dialog;
+ int response;
+
+ dialog = gtk_message_dialog_new (GTK_WINDOW (main_window),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE,
+ _("The currently selected audio profile is not available on your installation."));
+ gtk_dialog_add_button (GTK_DIALOG (dialog), "gtk-quit", GTK_RESPONSE_REJECT);
+ gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Change Profile"), GTK_RESPONSE_ACCEPT);
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+ if (response == GTK_RESPONSE_ACCEPT) {
+ gtk_widget_destroy (dialog);
+ on_edit_preferences_cb (NULL, NULL);
+ } else {
+ gtk_main_quit ();
}
}
}
@@ -968,7 +933,7 @@ int main (int argc, char **argv)
gconf_client_notify_add (gconf_client, GCONF_EJECT, eject_changed_cb, NULL, NULL, NULL);
gconf_client_notify_add (gconf_client, GCONF_BASEPATH, basepath_changed_cb, NULL, NULL, NULL);
gconf_client_notify_add (gconf_client, GCONF_STRIP, strip_changed_cb, NULL, NULL, NULL);
- gconf_client_notify_add (gconf_client, GCONF_FORMAT, format_changed_cb, NULL, NULL, NULL);
+ gconf_client_notify_add (gconf_client, GCONF_AUDIO_PROFILE, profile_changed_cb, NULL, NULL, NULL);
gconf_client_notify_add (gconf_client, GCONF_PARANOIA, paranoia_changed_cb, NULL, NULL, NULL);
gconf_client_notify_add (gconf_client, GCONF_PATH_PATTERN, path_pattern_changed_cb, NULL, NULL, NULL);
gconf_client_notify_add (gconf_client, GCONF_FILE_PATTERN, file_pattern_changed_cb, NULL, NULL, NULL);
@@ -977,6 +942,9 @@ int main (int argc, char **argv)
gconf_client_notify_add (gconf_client, GCONF_HTTP_PROXY, http_proxy_changed_cb, NULL, NULL, NULL);
gconf_client_notify_add (gconf_client, GCONF_HTTP_PROXY_PORT, http_proxy_port_changed_cb, NULL, NULL, NULL);
+ /* init gnome-media-profiles */
+ gnome_media_profiles_init (NULL);
+
glade_init ();
glade = glade_xml_new (DATADIR"/sound-juicer/sound-juicer.glade", NULL, NULL);
g_assert (glade != NULL);
@@ -1066,7 +1034,7 @@ int main (int argc, char **argv)
basepath_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_BASEPATH, NULL, TRUE, NULL), NULL);
path_pattern_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_PATH_PATTERN, NULL, TRUE, NULL), NULL);
file_pattern_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_FILE_PATTERN, NULL, TRUE, NULL), NULL);
- format_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_FORMAT, NULL, TRUE, NULL), NULL);
+ profile_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_AUDIO_PROFILE, NULL, TRUE, NULL), NULL);
paranoia_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_PARANOIA, NULL, TRUE, NULL), NULL);
strip_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_STRIP, NULL, TRUE, NULL), NULL);
eject_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_EJECT, NULL, TRUE, NULL), NULL);
diff --git a/src/sj-prefs.c b/src/sj-prefs.c
index d46d8ac..68bc044 100644
--- a/src/sj-prefs.c
+++ b/src/sj-prefs.c
@@ -27,6 +27,7 @@
#include <glade/glade-xml.h>
#include <gconf/gconf-client.h>
#include <libgnome/gnome-help.h>
+#include <profiles/gnome-media-profiles.h>
#include "sj-extracting.h"
#include "cd-drive.h"
#include "bacon-cd-selection.h"
@@ -34,8 +35,7 @@
extern GladeXML *glade;
extern GtkWidget *main_window;
-/* Store the toggle buttons pertaining to the format */
-static GtkWidget *format_widgets[SJ_NUMBER_FORMATS];
+static GtkWidget *audio_profile;
static GtkWidget *prefs_dialog;
static GtkWidget *cd_option, *path_option, *file_option, *basepath_label, *check_strip, *check_eject;
static GtkWidget *path_example_label;
@@ -110,6 +110,14 @@ void prefs_eject_toggled (GtkToggleButton *togglebutton, gpointer user_data)
NULL);
}
+void prefs_profile_changed (GtkWidget *widget, gpointer user_data)
+{
+ GMAudioProfile *profile;
+ profile = gm_audio_profile_choose_get_active (widget);
+ gconf_client_set_string (gconf_client, GCONF_AUDIO_PROFILE,
+ gm_audio_profile_get_id (profile), NULL);
+}
+
/**
* Show the gnome help browser
*/
@@ -192,31 +200,6 @@ void prefs_strip_toggled (GtkToggleButton *togglebutton, gpointer user_data)
NULL);
}
-/**
- * One of the format toggle buttons in the prefs dialog has been
- * toggled.
- */
-void on_format_toggled (GtkToggleButton *togglebutton,
- gpointer user_data)
-{
- const char* format;
- if (!gtk_toggle_button_get_active (togglebutton)) {
- return;
- }
- if (GTK_WIDGET (togglebutton) == format_widgets[SJ_FORMAT_VORBIS]) {
- format = "vorbis";
- } else if (GTK_WIDGET(togglebutton) == format_widgets[SJ_FORMAT_MPEG]) {
- format = "mpeg";
- } else if (GTK_WIDGET(togglebutton) == format_widgets[SJ_FORMAT_FLAC]) {
- format = "flac";
- } else if (GTK_WIDGET(togglebutton) == format_widgets[SJ_FORMAT_WAVE]) {
- format = "wave";
- } else {
- return;
- }
- gconf_client_set_string (gconf_client, GCONF_FORMAT, format, NULL); /* TODO: GError */
-}
-
static void device_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
{
g_return_if_fail (strcmp (entry->key, GCONF_DEVICE) == 0);
@@ -231,37 +214,13 @@ static void device_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *e
}
}
-static void format_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
+static void audio_profile_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
{
- char* value;
- GEnumValue* enumvalue;
- int format;
- int i;
-
- g_return_if_fail (strcmp (entry->key, GCONF_FORMAT) == 0);
-
+ const char *value;
+ g_return_if_fail (strcmp (entry->key, GCONF_AUDIO_PROFILE) == 0);
if (!entry->value) return;
- g_return_if_fail (entry->value->type == GCONF_VALUE_STRING);
- value = g_ascii_strup (gconf_value_get_string (entry->value), -1);
- /* TODO: this line is pretty convoluted */
- enumvalue = g_enum_get_value_by_name (g_type_class_peek (encoding_format_get_type()), value);
- /* Fallback on vorbis if it's not found */
- if (enumvalue == NULL) {
- /* g_warning (_("Unknown format %s"), value); */
- format = 0;
- } else {
- format = enumvalue->value;
- }
- g_free (value);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (format_widgets[format]), TRUE);
-
- for (i = 0; i < SJ_NUMBER_FORMATS; i++) {
- gboolean supported;
-
- supported = sj_extractor_supports_format (i);
- gtk_widget_set_sensitive (format_widgets[i], supported);
- }
+ value = gconf_value_get_string (entry->value);
+ gm_audio_profile_choose_set_active (audio_profile, value);
}
static void basepath_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data)
@@ -368,6 +327,7 @@ static void path_pattern_changed_cb (GConfClient *client, guint cnxn_id, GConfEn
char *value;
int i = 0;
g_return_if_fail (strcmp (entry->key, GCONF_PATH_PATTERN) == 0);
+ g_return_if_fail (entry->value->type == GCONF_VALUE_STRING);
if (entry->value == NULL) {
value = g_strdup (path_patterns[0].pattern);
@@ -387,9 +347,10 @@ static void file_pattern_changed_cb (GConfClient *client, guint cnxn_id, GConfEn
{
char *value;
int i = 0;
-
+
g_return_if_fail (strcmp (entry->key, GCONF_FILE_PATTERN) == 0);
-
+ g_return_if_fail (entry->value->type == GCONF_VALUE_STRING);
+
if (entry->value == NULL) {
value = g_strdup (file_patterns[0].pattern);
} else if (entry->value->type == GCONF_VALUE_STRING) {
@@ -438,10 +399,7 @@ void on_edit_preferences_cb (GtkMenuItem *item, gpointer user_data)
basepath_label = glade_xml_get_widget (glade, "path_label");
path_option = glade_xml_get_widget (glade, "path_option");
file_option = glade_xml_get_widget (glade, "file_option");
- format_widgets[SJ_FORMAT_VORBIS] = glade_xml_get_widget (glade, "format_vorbis");
- format_widgets[SJ_FORMAT_MPEG] = glade_xml_get_widget (glade, "format_mpeg");
- format_widgets[SJ_FORMAT_FLAC] = glade_xml_get_widget (glade, "format_flac");
- format_widgets[SJ_FORMAT_WAVE] = glade_xml_get_widget (glade, "format_wave");
+ audio_profile = glade_xml_get_widget (glade, "audio_profile");
check_strip = glade_xml_get_widget (glade, "check_strip");
check_eject = glade_xml_get_widget (glade, "check_eject");
path_example_label = glade_xml_get_widget (glade, "path_example_label");
@@ -454,7 +412,7 @@ void on_edit_preferences_cb (GtkMenuItem *item, gpointer user_data)
/* Connect to GConf to update the UI */
gconf_client_notify_add (gconf_client, GCONF_DEVICE, device_changed_cb, NULL, NULL, NULL);
gconf_client_notify_add (gconf_client, GCONF_BASEPATH, basepath_changed_cb, NULL, NULL, NULL);
- gconf_client_notify_add (gconf_client, GCONF_FORMAT, format_changed_cb, NULL, NULL, NULL);
+ gconf_client_notify_add (gconf_client, GCONF_AUDIO_PROFILE, audio_profile_changed_cb, NULL, NULL, NULL);
gconf_client_notify_add (gconf_client, GCONF_STRIP, strip_changed_cb, NULL, NULL, NULL);
gconf_client_notify_add (gconf_client, GCONF_EJECT, eject_changed_cb, NULL, NULL, NULL);
gconf_client_notify_add (gconf_client, GCONF_PATH_PATTERN, path_pattern_changed_cb, NULL, NULL, NULL);
@@ -462,7 +420,7 @@ void on_edit_preferences_cb (GtkMenuItem *item, gpointer user_data)
}
basepath_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_BASEPATH, NULL, TRUE, NULL), NULL);
device_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_DEVICE, NULL, TRUE, NULL), NULL);
- format_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_FORMAT, NULL, TRUE, NULL), NULL);
+ audio_profile_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_AUDIO_PROFILE, NULL, TRUE, NULL), NULL);
strip_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_STRIP, NULL, TRUE, NULL), NULL);
eject_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_EJECT, NULL, TRUE, NULL), NULL);
file_pattern_changed_cb (gconf_client, -1, gconf_client_get_entry (gconf_client, GCONF_FILE_PATTERN, NULL, TRUE, NULL), NULL);
diff --git a/src/sound-juicer.h b/src/sound-juicer.h
index 0be2b91..2da8ecc 100644
--- a/src/sound-juicer.h
+++ b/src/sound-juicer.h
@@ -121,7 +121,7 @@ extern gboolean autostart;
#define GCONF_BASEPATH GCONF_ROOT "/base_path"
#define GCONF_FILE_PATTERN GCONF_ROOT "/file_pattern"
#define GCONF_PATH_PATTERN GCONF_ROOT "/path_pattern"
-#define GCONF_FORMAT GCONF_ROOT "/format"
+#define GCONF_AUDIO_PROFILE GCONF_ROOT "/audio_profile"
#define GCONF_PARANOIA GCONF_ROOT "/paranoia"
#define GCONF_STRIP GCONF_ROOT "/strip-special"
#define GCONF_MUSICBRAINZ_SERVER GCONF_ROOT "/musicbrainz_server"