From: phantomjinx <pha...@us...> - 2012-02-11 10:35:32
|
commit c2e3add8940eb78a2b74b375667c140089880921 Author: phantomjinx <p.g...@ph...> Date: Mon Jan 2 21:21:27 2012 +0000 Refactor sjcd plugin codebase for use in gtkpod * sj-main.c * Most refactoring to return the gtk vbox rather than displaying a window independently. .gitignore | 5 + configure.ac | 57 + plugins/sjcd/.gitignore | 2 + plugins/sjcd/Makefile.am | 25 +- plugins/sjcd/TODO | 3 + plugins/sjcd/data/Makefile.am | 25 + ....gschema.xml => org.gtkpod.sjcd.gschema.xml.in} | 2 +- plugins/sjcd/data/rhythmbox.gep | 4 +- plugins/sjcd/libjuicer/Makefile.am | 10 +- plugins/sjcd/libjuicer/rb-gst-media-types.c | 13 +- plugins/sjcd/libjuicer/sj-metadata-musicbrainz3.c | 2 +- plugins/sjcd/plugin.c | 21 +- plugins/sjcd/plugin.h | 3 +- plugins/sjcd/sj-about.c | 89 - plugins/sjcd/sj-about.h | 30 - plugins/sjcd/sj-extracting.c | 107 +- plugins/sjcd/sj-gsettings.diff | 3836 -------------------- plugins/sjcd/sj-main.c | 341 +-- plugins/sjcd/sj-main.h | 6 +- plugins/sjcd/sj-play.c | 663 ---- plugins/sjcd/sj-play.h | 60 - plugins/sjcd/sj-prefs.c | 41 +- plugins/sjcd/sjcd.xml | 545 ++-- plugins/sjcd/sound-juicer.h | 20 +- 24 files changed, 528 insertions(+), 5382 deletions(-) --- diff --git a/.gitignore b/.gitignore index 99016a6..69a4aa7 100644 --- a/.gitignore +++ b/.gitignore @@ -94,6 +94,7 @@ version /data/glade/playlist_display.xml /data/glade/mserv.xml /data/glade/clarity.xml +/data/glade/sjcd.xml /data/ui/details_editor.ui /data/ui/coverweb.ui @@ -109,3 +110,7 @@ version /data/ui/media_player.ui /data/ui/mserv.ui /data/ui/clarity.ui +/data/ui/sjcd.ui + +/data/rhythmbox.gep + diff --git a/configure.ac b/configure.ac index 2909ebf..4c99269 100644 --- a/configure.ac +++ b/configure.ac @@ -97,6 +97,7 @@ PKG_CHECK_MODULES(WEBKIT, [webkitgtk-3.0 >= 1.3], [have_webkit="yes"], [have_web PKG_CHECK_MODULES(GSTREAMER, gstreamer-0.10 >= 0.10.25 gstreamer-interfaces-0.10 >= 0.10.25, [have_gstreamer="yes"], [have_gstreamer="no"]) PKG_CHECK_MODULES(VORBISFILE, vorbisfile >= 1.3.1, [have_vorbis="yes"], [have_vorbis="no"]) PKG_CHECK_MODULES(FLAC, flac >= 1.2.1, [have_flac="yes"], [have_flac="no"]) +PKG_CHECK_MODULES(SOUND_JUICER, libcanberra-gtk3 libbrasero-media3 >= 3.0, [have_sj="yes"], [have_sj="no"]) GTK_CLEANLINESS_FLAGS="-DG_DISABLE_SINGLE_INCLUDES -DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_SINGLE_INCLUDES -DGSEAL_ENABLE" @@ -322,6 +323,58 @@ fi AM_CONDITIONAL(HAVE_PLUGIN_FILETYPE_M4A, test "x$have_m4a" = "xyes") +dnl Checks for sjcd plugin +dnl ------------------------------------------------------------- +have_sjcd="no" + +AC_ARG_ENABLE(plugin-sjcd, + AS_HELP_STRING([--disable-plugin-sjcd],[Disable sound juicer plugin for extracting tracks from cd]), + [ if test "$enableval" = "no"; then + user_disabled_sjcd=1 + fi ], + [ user_disabled_sjcd=0 ]) +AC_MSG_CHECKING(if sjcd plugin is disabled) +if test "$user_disabled_sjcd" = 1; then + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) + AC_MSG_CHECKING(sjcd plugin dependencies) + if test "x$have_gstreamer" = "xyes" -a "x$have_sj" = "xyes"; then + AC_MSG_RESULT(yes) + have_sjcd="yes" + + dnl Checks for components of gstreamer + if test "x$have_gstreamer" = "xyes"; then + AM_GST_ELEMENT_CHECK(vorbisenc,,AC_MSG_WARN([The 'vorbisenc' element was not found. This will cause encoding to Ogg Vorbis to fail.])) + AM_GST_ELEMENT_CHECK(flacenc,,AC_MSG_WARN([The 'flacenc' element was not found. This will cause encoding to FLAC to fail.])) + AM_GST_ELEMENT_CHECK(wavenc,,AC_MSG_WARN([The 'wavenc' element was not found. This will cause encoding to Wave to fail.])) + AM_GST_ELEMENT_CHECK(giosink,,AC_MSG_WARN([The 'giosink' element was not found. This will cause Sound Juicer to fail at runtime.])) + fi + else + AC_MSG_RESULT(no) + fi +fi + +if test "x$have_sjcd" = "xyes" ; then + dnl musicbrainz 3 is deprecated so may not be included + dnl will probably need replacing faily soon + + PKG_CHECK_MODULES(MUSICBRAINZ3, libmusicbrainz3 >= 3.0.2, [have_mb3="yes"], [have_mb3="no"]) + AM_CONDITIONAL(HAVE_MUSICBRAINZ3, [test "x$have_mb3" = "xyes"]) + if test "x$have_mb3" = "xyes" ; then + AC_DEFINE([HAVE_MUSICBRAINZ3], 1, [Whether libmusicbrainz3 is available]) + else + AC_MSG_WARN([libmusicbrainz3 needs to be available for sound-juicer to build]) + have_sjcd="no" + fi +fi + +AM_CONDITIONAL(HAVE_PLUGIN_SJCD, [test "x$have_sjcd" = "xyes"]) +if test "x$have_sjcd" = "xyes"; then + AC_DEFINE(HAVE_PLUGIN_SJCD, 1, [Define if you have sound juicer support]) +fi + + # Check that we have endian.h AC_CHECK_HEADERS(endian.h, have_endian=yes, have_endian=no) if test "x$have_endian" = "xno"; then @@ -558,6 +611,9 @@ plugins/clarity/icons/hicolor/48x48/Makefile plugins/clarity/icons/hicolor/48x48/places/Makefile plugins/clarity/icons/hicolor/240x240/Makefile plugins/clarity/icons/hicolor/240x240/places/Makefile +plugins/sjcd/Makefile +plugins/sjcd/data/Makefile +plugins/sjcd/libjuicer/Makefile ]) AC_OUTPUT @@ -585,6 +641,7 @@ echo " M4A File Type .....: $have_m4a" echo " Flac File Type .....: $have_flac" echo " Ogg File Type .....: $have_vorbis" echo " Clarity Display Widget .....: $have_clarity" +echo " Sound Juicer Widget .....: $have_sjcd" echo " Support for cover download .....: $have_curl" diff --git a/plugins/sjcd/.gitignore b/plugins/sjcd/.gitignore new file mode 100644 index 0000000..7c65047 --- /dev/null +++ b/plugins/sjcd/.gitignore @@ -0,0 +1,2 @@ +data/org.gtkpod.sjcd.gschema.valid +data/org.gtkpod.sjcd.gschema.xml diff --git a/plugins/sjcd/Makefile.am b/plugins/sjcd/Makefile.am index f6c19c0..fcf3373 100644 --- a/plugins/sjcd/Makefile.am +++ b/plugins/sjcd/Makefile.am @@ -16,6 +16,8 @@ sjcd_pixmaps_DATA = sjcd_plugindir = $(gtkpod_plugin_dir) sjcd_plugin_DATA = +if HAVE_PLUGIN_SJCD + SUBDIRS = data libjuicer include ../plugins.mk @@ -26,14 +28,33 @@ plugin_lib = lib$(plugin_name).so plugin_LTLIBRARIES = libsjcd.la # Plugin sources -libsjcd_la_SOURCES = plugin.c plugin.h +libsjcd_la_SOURCES = plugin.c plugin.h \ + sj-main.c sj-main.h \ + sound-juicer.h \ + sj-prefs.c sj-prefs.h \ + sj-extracting.c sj-extracting.h \ + sj-inhibit.c sj-inhibit.h \ + sj-genres.c sj-genres.h \ + egg-play-preview.c egg-play-preview.h \ + bacon-message-connection.c bacon-message-connection.h +libsjcd_la_CFLAGS = -I$(top_srcdir)/plugins/$(plugin_name)/libjuicer \ + $(GSTREAMER_CFLAGS) \ + $(SOUND_JUICER_CFLAGS) \ + $(MUSICBRAINZ3_CFLAGS) + libsjcd_la_LDFLAGS = $(GTKPOD_PLUGIN_LDFLAGS) # Plugin dependencies libsjcd_la_LIBADD = \ + $(top_srcdir)/plugins/$(plugin_name)/libjuicer/libjuicer.la \ $(GTKPOD_LIBS) \ - $(LIBANJUTA_LIBS) + $(LIBANJUTA_LIBS) \ + $(GSTREAMER_LIBS) \ + $(SOUND_JUICER_LIBS) \ + $(MUSICBRAINZ3_LIBS) + +endif EXTRA_DIST = \ $(plugin_file).in \ diff --git a/plugins/sjcd/TODO b/plugins/sjcd/TODO new file mode 100644 index 0000000..07f20ee --- /dev/null +++ b/plugins/sjcd/TODO @@ -0,0 +1,3 @@ +Add library dependencies to configure.ac + - brasero-devel.rpm + diff --git a/plugins/sjcd/data/Makefile.am b/plugins/sjcd/data/Makefile.am new file mode 100644 index 0000000..5f2a768 --- /dev/null +++ b/plugins/sjcd/data/Makefile.am @@ -0,0 +1,25 @@ +profilesdir = $(pkgdatadir)/data +profiles_DATA = rhythmbox.gep + +# gsettings_SCHEMAS is a list of all the schemas you want to install +schema_in_files = org.gtkpod.sjcd.gschema.xml.in +gsettings_SCHEMAS = $(schema_in_files:.gschema.xml.in=.gschema.xml) + +# include the appropriate makefile rules for schema handling +@INTLTOOL_XML_NOMERGE_RULE@ +@GSETTINGS_RULES@ + +EXTRA_DIST = \ + $(profiles_DATA) \ + $(schema_in_files) + +CLEANFILES = $(gsettings_SCHEMAS) + +all-local: create-data-links + +# Creating symbolic links in plugin root directory +create-data-links: + if [ ! -e $(top_srcdir)/data/$(profiles_DATA) ]; then \ + $(LN_S) `pwd`/$(profiles_DATA) $(top_srcdir)/data/$(profiles_DATA); \ + fi; + diff --git a/plugins/sjcd/data/org.gnome.SoundJuicer.gschema.xml b/plugins/sjcd/data/org.gtkpod.sjcd.gschema.xml.in similarity index 98% rename from plugins/sjcd/data/org.gnome.SoundJuicer.gschema.xml rename to plugins/sjcd/data/org.gtkpod.sjcd.gschema.xml.in index 461abff..0814038 100644 --- a/plugins/sjcd/data/org.gnome.SoundJuicer.gschema.xml +++ b/plugins/sjcd/data/org.gtkpod.sjcd.gschema.xml.in @@ -1,6 +1,6 @@ <?xml version="1.0"?> <schemalist> - <schema id="org.gnome.SoundJuicer" path="/apps/sound-juicer/"> + <schema id="org.gtkpod.sjcd" path="/apps/gtkpod/sjcd/"> <key name="device" type="s"> <default>''</default> <summary>The CD to extract from.</summary> diff --git a/plugins/sjcd/data/rhythmbox.gep b/plugins/sjcd/data/rhythmbox.gep index 6383d96..a800f9b 100644 --- a/plugins/sjcd/data/rhythmbox.gep +++ b/plugins/sjcd/data/rhythmbox.gep @@ -1,7 +1,7 @@ [GStreamer Encoding Target] -name = rhythmbox +name = gtkpod category = muh -description = Common encoding profiles for Rhythmbox +description = Common encoding profiles for gtkpod [profile-mp3] name = mp3 diff --git a/plugins/sjcd/libjuicer/Makefile.am b/plugins/sjcd/libjuicer/Makefile.am index 9ab4701..dceb8fa 100644 --- a/plugins/sjcd/libjuicer/Makefile.am +++ b/plugins/sjcd/libjuicer/Makefile.am @@ -24,19 +24,15 @@ libjuicer_la_CPPFLAGS = \ libjuicer_la_CFLAGS = \ $(WARN_CFLAGS) \ + $(SOUND_JUICER_CFLAGS) \ $(MUSICBRAINZ3_CFLAGS) \ $(GSTREAMER_CFLAGS) \ - $(BURN_CFLAGS) \ - $(UI_CFLAGS) \ - $(CDIO_CFLAGS) \ $(AM_CFLAGS) libjuicer_la_LIBADD = \ + $(SOUND_JUICER_LIBS) \ $(MUSICBRAINZ3_LIBS) \ - $(GSTREAMER_LIBS) \ - $(BURN_LIBS) \ - $(UI_LIBS) \ - $(CDIO_LIBS) + $(GSTREAMER_LIBS) libjuicer_la_LDFLAGS = \ -export-dynamic \ diff --git a/plugins/sjcd/libjuicer/rb-gst-media-types.c b/plugins/sjcd/libjuicer/rb-gst-media-types.c index e87b013..6b0bc78 100644 --- a/plugins/sjcd/libjuicer/rb-gst-media-types.c +++ b/plugins/sjcd/libjuicer/rb-gst-media-types.c @@ -27,6 +27,8 @@ #include "config.h" +#include "libgtkpod/directories.h" + #include <memory.h> #include <gst/pbutils/encoding-target.h> @@ -34,8 +36,6 @@ #include "rb-gst-media-types.h" -#define SOURCE_ENCODING_TARGET_FILE "../data/rhythmbox.gep" -#define INSTALLED_ENCODING_TARGET_FILE DATADIR"/sound-juicer/rhythmbox.gep" static GstEncodingTarget *default_target = NULL; char * @@ -201,15 +201,10 @@ GstEncodingTarget * rb_gst_get_default_encoding_target () { if (default_target == NULL) { - char *target_file; + gchar *target_file; GError *error = NULL; - if (g_file_test (SOURCE_ENCODING_TARGET_FILE, - G_FILE_TEST_EXISTS) != FALSE) { - target_file = SOURCE_ENCODING_TARGET_FILE; - } else { - target_file = INSTALLED_ENCODING_TARGET_FILE; - } + target_file = g_build_filename(get_data_dir(), "rhythmbox.gep", NULL); default_target = gst_encoding_target_load_from_file (target_file, &error); if (default_target == NULL) { diff --git a/plugins/sjcd/libjuicer/sj-metadata-musicbrainz3.c b/plugins/sjcd/libjuicer/sj-metadata-musicbrainz3.c index 3bcb3cf..f43f72b 100644 --- a/plugins/sjcd/libjuicer/sj-metadata-musicbrainz3.c +++ b/plugins/sjcd/libjuicer/sj-metadata-musicbrainz3.c @@ -425,7 +425,7 @@ static void sj_metadata_musicbrainz3_finalize (GObject *object) { SjMetadataMusicbrainz3Private *priv; - + priv = GET_PRIVATE (object); if (priv->mb != NULL) { diff --git a/plugins/sjcd/plugin.c b/plugins/sjcd/plugin.c index 8d24d6c..08bfaf3 100644 --- a/plugins/sjcd/plugin.c +++ b/plugins/sjcd/plugin.c @@ -34,6 +34,7 @@ #include "libgtkpod/gtkpod_app_iface.h" #include "libgtkpod/directories.h" #include "plugin.h" +#include "sj-main.h" /* Parent class. Part of standard class definition */ static gpointer parent_class; @@ -45,7 +46,11 @@ static gboolean activate_plugin(AnjutaPlugin *plugin) { AnjutaUI *ui; GtkActionGroup* action_group; - sjcd_plugin = (SjCdPlugin*) plugin; + /* Prepare the icons for the playlist */ +// register_icon_path(get_plugin_dir(), "sjcd"); +// register_stock_icon(PREFERENCE_ICON, PREFERENCE_ICON_STOCK_ID); + + sjcd_plugin = (SJCDPlugin*) plugin; ui = anjuta_shell_get_ui(plugin->shell, NULL); /* Add actions */ @@ -58,14 +63,18 @@ static gboolean activate_plugin(AnjutaPlugin *plugin) { sjcd_plugin->uiid = anjuta_ui_merge(ui, uipath); g_free(uipath); + sjcd_plugin->sj_view = sj_create_sound_juicer(); + gtk_widget_show_all(sjcd_plugin->sj_view); + // Add widget directly as scrolling is handled internally by the widget + anjuta_shell_add_widget(plugin->shell, sjcd_plugin->sj_view, "SJCDPlugin", _(" Sound Juicer"), NULL, ANJUTA_SHELL_PLACEMENT_TOP, NULL); + + return TRUE; /* FALSE if activation failed */ } static gboolean deactivate_plugin(AnjutaPlugin *plugin) { AnjutaUI *ui; - destroy_sjcd(); - ui = anjuta_shell_get_ui(plugin->shell, NULL); /* Unmerge UI */ @@ -79,7 +88,7 @@ static gboolean deactivate_plugin(AnjutaPlugin *plugin) { } static void sjcd_plugin_instance_init(GObject *obj) { - SjCdPlugin *plugin = (SjCdPlugin*) obj; + SJCDPlugin *plugin = (SJCDPlugin*) obj; plugin->uiid = 0; plugin->action_group = NULL; } @@ -93,8 +102,8 @@ static void sjcd_plugin_class_init(GObjectClass *klass) { plugin_class->deactivate = deactivate_plugin; } -ANJUTA_PLUGIN_BEGIN (SjCdPlugin, sjcd_plugin); +ANJUTA_PLUGIN_BEGIN (SJCDPlugin, sjcd_plugin); ANJUTA_PLUGIN_END; -ANJUTA_SIMPLE_PLUGIN (SjCdPlugin, sjcd_plugin) +ANJUTA_SIMPLE_PLUGIN (SJCDPlugin, sjcd_plugin) ; diff --git a/plugins/sjcd/plugin.h b/plugins/sjcd/plugin.h index f957c92..6e85e0b 100644 --- a/plugins/sjcd/plugin.h +++ b/plugins/sjcd/plugin.h @@ -42,8 +42,7 @@ typedef struct _SJCDPluginClass SJCDPluginClass; struct _SJCDPlugin { AnjutaPlugin parent; gint uiid; - GtkWidget *sj_window; - GtkWidget *sj_instance; + GtkWidget *sj_view; GtkActionGroup *action_group; }; diff --git a/plugins/sjcd/sj-extracting.c b/plugins/sjcd/sj-extracting.c index 0622a0e..53f26d4 100644 --- a/plugins/sjcd/sj-extracting.c +++ b/plugins/sjcd/sj-extracting.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2003 Ross Burton <ro...@bu...> * * Sound Juicer - sj-extracting.c @@ -24,6 +24,9 @@ #include <config.h> #endif +// TODO Remove this and replace dialogs with gtkpod dialogs +#include "libgtkpod/gtkpod_app_iface.h" + #include "sound-juicer.h" #include <sys/time.h> @@ -42,7 +45,6 @@ #include "sj-error.h" #include "sj-extracting.h" #include "sj-util.h" -#include "sj-play.h" #include "sj-inhibit.h" #include "sj-genres.h" #include "egg-play-preview.h" @@ -195,12 +197,12 @@ find_next (void) { do { gboolean extract = FALSE; - + gtk_tree_model_get (GTK_TREE_MODEL (track_store), ¤t, COLUMN_EXTRACT, &extract, -1); - + if (extract) return TRUE; - + } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (track_store), ¤t)); return FALSE; } @@ -235,31 +237,30 @@ cleanup (void) /* TODO: find out why GTK+ needs this to work (see #364371) */ gtk_button_set_label (GTK_BUTTON (extract_button), _("Extract")); gtk_button_set_label (GTK_BUTTON (extract_button), SJ_STOCK_EXTRACT); - + /* Clear the Status bar */ gtk_statusbar_push (GTK_STATUSBAR (status_bar), 0, ""); /* Clear the progress bar */ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 0); gtk_widget_hide (progress_bar); - + gtk_widget_set_sensitive (play_button, TRUE); gtk_widget_set_sensitive (title_entry, TRUE); gtk_widget_set_sensitive (artist_entry, TRUE); gtk_widget_set_sensitive (genre_entry, TRUE); gtk_widget_set_sensitive (year_entry, TRUE); gtk_widget_set_sensitive (disc_number_entry, TRUE); - /* Enabling the Menuitem */ + /* Enabling the Menuitem */ gtk_widget_set_sensitive (play_menuitem, TRUE); gtk_widget_set_sensitive (extract_menuitem, TRUE); gtk_widget_set_sensitive (reread_menuitem, TRUE); gtk_widget_set_sensitive (select_all_menuitem, TRUE); gtk_widget_set_sensitive (deselect_all_menuitem, TRUE); - + /*Enable the Extract column and Make the Title and Artist column Editable*/ g_object_set (G_OBJECT (toggle_renderer), "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, NULL); g_object_set (G_OBJECT (title_renderer), "editable", TRUE, NULL); g_object_set (G_OBJECT (artist_renderer), "editable", TRUE, NULL); - g_signal_handlers_unblock_by_func (track_listview, on_tracklist_row_activate, NULL); } @@ -273,7 +274,7 @@ check_file_size (GFile *uri) GFileInfo *gfile_info; GError *error = NULL; goffset size; - + gfile_info = g_file_query_info (uri, G_FILE_ATTRIBUTE_STANDARD_SIZE, 0, NULL, &error); @@ -299,7 +300,7 @@ check_file_size (GFile *uri) static gboolean confirm_overwrite_existing_file (GFile *uri, int *overwrite_mode, goffset info_size) -{ +{ OverwriteDialogResponse ret; GtkWidget *dialog; GtkWidget *play_preview; @@ -307,7 +308,7 @@ confirm_overwrite_existing_file (GFile *uri, int *overwrite_mode, goffset info_s display_name = g_file_get_parse_name (uri); size = g_format_size_for_display (info_size); - dialog = gtk_message_dialog_new (GTK_WINDOW (main_window), GTK_DIALOG_MODAL, + dialog = gtk_message_dialog_new (GTK_WINDOW (gtkpod_app), GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, _("A file with the same name exists")); @@ -457,13 +458,13 @@ pop_and_extract (int *overwrite_mode) /* Update the state stock image */ gtk_list_store_set (track_store, ¤t, COLUMN_STATE, STATE_EXTRACTING, -1); - + /* Update the progress bars */ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), CLAMP ((float)current_duration / (float)total_duration, 0.0, 1.0)); /* Set the Treelist focus to the item to be extracted */ - GtkTreePath* path = gtk_tree_model_get_path(GTK_TREE_MODEL (track_store), ¤t); + GtkTreePath* path = gtk_tree_model_get_path(GTK_TREE_MODEL (track_store), ¤t); gtk_tree_view_set_cursor(GTK_TREE_VIEW (track_listview), path, NULL, TRUE); gtk_tree_path_free(path); @@ -472,7 +473,7 @@ pop_and_extract (int *overwrite_mode) if (error) { goto error; } else - successful_extract = TRUE; + successful_extract = TRUE; goto local_cleanup; error: successful_extract = FALSE; @@ -514,11 +515,11 @@ update_speed_progress (SjExtractor *extractor, float speed, int eta) char *eta_str; if (eta >= 0) { - eta_str = g_strdup_printf (_("Estimated time left: %d:%02d (at %0.1f\303\227)"), eta / 60, eta % 60, speed); + eta_str = g_strdup_printf (_("Estimated time left: %d:%02d (at %0.1f\303\227)"), eta / 60, eta % 60, speed); } else { - eta_str = g_strdup (_("Estimated time left: unknown")); + eta_str = g_strdup (_("Estimated time left: unknown")); } - + gtk_statusbar_push (GTK_STATUSBAR (status_bar), 0, eta_str); g_free (eta_str); } @@ -545,7 +546,7 @@ on_progress_cb (SjExtractor *extractor, const int seconds, gpointer data) gettimeofday(&time, NULL); taken = time.tv_sec + (time.tv_usec / 1000000.0) - - (before.time.tv_sec + (before.time.tv_usec / 1000000.0)); + - (before.time.tv_sec + (before.time.tv_usec / 1000000.0)); if (taken >= 4) { before.taken += taken; before.ripped += current_duration + seconds - before.seconds; @@ -593,7 +594,7 @@ base_finder (char *path, char **ret) static gboolean on_main_window_focus_in (GtkWidget * widget, GdkEventFocus * event, gpointer data) { - gtk_window_set_urgency_hint (GTK_WINDOW (main_window), FALSE); + gtk_window_set_urgency_hint (GTK_WINDOW (gtkpod_app), FALSE); return FALSE; } @@ -604,21 +605,21 @@ static void finished_actions (void) { /* Trigger a sound effect */ - ca_gtk_play_for_widget (main_window, 0, + ca_gtk_play_for_widget (GTK_WIDGET(gtkpod_app), 0, CA_PROP_EVENT_ID, "complete-media-rip", CA_PROP_EVENT_DESCRIPTION, _("CD rip complete"), NULL); - + /* Trigger glowing effect after copy */ - g_signal_connect (G_OBJECT (main_window), "focus-in-event", + g_signal_connect (G_OBJECT (gtkpod_app), "focus-in-event", G_CALLBACK (on_main_window_focus_in), NULL); - gtk_window_set_urgency_hint (GTK_WINDOW (main_window), TRUE); + gtk_window_set_urgency_hint (GTK_WINDOW (gtkpod_app), TRUE); /* Maybe eject */ if (eject_finished && successful_extract) { brasero_drive_eject (drive, FALSE, NULL); } - + /* Maybe open the target directory */ if (open_finished) { char *base = NULL; @@ -650,7 +651,7 @@ on_completion_cb (SjExtractor *extractor, gpointer data) /* Uncheck the Extract check box */ gtk_list_store_set (track_store, ¤t, COLUMN_EXTRACT, FALSE, -1); } - + gtk_tree_model_get (GTK_TREE_MODEL (track_store), ¤t, COLUMN_DETAILS, &track, -1); @@ -664,7 +665,7 @@ on_completion_cb (SjExtractor *extractor, gpointer data) g_object_unref (temp_file); g_object_unref (new_file); - + if (error) { on_error_cb (NULL, error, NULL); g_error_free (error); @@ -679,10 +680,6 @@ on_completion_cb (SjExtractor *extractor, gpointer data) current.stamp = 0; finished_actions (); cleanup (); - - if (autostart) { - gtk_main_quit (); - } } } @@ -695,7 +692,7 @@ on_error_cb (SjExtractor *extractor, GError *error, gpointer data) GtkWidget *dialog; /* Display a nice dialog */ - dialog = gtk_message_dialog_new (GTK_WINDOW (main_window), 0, + dialog = gtk_message_dialog_new (GTK_WINDOW (gtkpod_app), 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", _("Sound Juicer could not extract this CD.")); @@ -720,7 +717,7 @@ on_progress_cancel_clicked (GtkWidget *button, gpointer user_data) GError *error = NULL; sj_extractor_cancel_extract (extractor); - + gtk_tree_model_get (GTK_TREE_MODEL (track_store), ¤t, COLUMN_DETAILS, &track, -1); @@ -743,16 +740,13 @@ G_MODULE_EXPORT void on_extract_activate (GtkWidget *button, gpointer user_data) { char *reason; - - /* first make sure we're not playing, we cannot share the resource */ - stop_playback (); - + /* If extracting, then cancel the extract */ if (extracting) { on_progress_cancel_clicked (NULL, NULL); return; } - + /* Populate the pending list */ current.stamp = 0; total_extracting = 0; @@ -784,22 +778,22 @@ on_extract_activate (GtkWidget *button, gpointer user_data) track_listview = GET_WIDGET ("track_listview"); progress_bar = GET_WIDGET ("progress_bar"); status_bar = GET_WIDGET ("status_bar"); - + play_menuitem = GET_WIDGET ("play_menuitem"); extract_menuitem = GET_WIDGET ("extract_menuitem"); reread_menuitem = GET_WIDGET ("re-read"); select_all_menuitem = GET_WIDGET ("select_all"); deselect_all_menuitem = GET_WIDGET ("deselect_all"); - + initialised = TRUE; } - + /* Change the label to Stop while extracting*/ /* TODO: find out why GTK+ needs this to work (see #364371) */ gtk_button_set_label (GTK_BUTTON (extract_button), _("Stop")); gtk_button_set_label (GTK_BUTTON (extract_button), GTK_STOCK_STOP); gtk_widget_show (progress_bar); - + /* Reset the progress dialog */ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 0); update_speed_progress (NULL, 0.0, -1); @@ -812,27 +806,26 @@ on_extract_activate (GtkWidget *button, gpointer user_data) gtk_widget_set_sensitive (year_entry, FALSE); gtk_widget_set_sensitive (disc_number_entry, FALSE); - /* Disable the menuitems in the main menu*/ + /* Disable the menuitems in the main menu*/ gtk_widget_set_sensitive (play_menuitem, FALSE); gtk_widget_set_sensitive (extract_menuitem, FALSE); gtk_widget_set_sensitive (reread_menuitem, FALSE); gtk_widget_set_sensitive (select_all_menuitem, FALSE); gtk_widget_set_sensitive (deselect_all_menuitem, FALSE); - + /* Disable the Extract column */ g_object_set (G_OBJECT (toggle_renderer), "mode", GTK_CELL_RENDERER_MODE_INERT, NULL); g_object_set (G_OBJECT (title_renderer), "editable", FALSE, NULL); g_object_set (G_OBJECT (artist_renderer), "editable", FALSE, NULL); - g_signal_handlers_block_by_func (track_listview, on_tracklist_row_activate, NULL); if (! brasero_drive_lock (drive, _("Extracting audio from CD"), &reason)) { g_warning ("Could not lock drive: %s", reason); g_free (reason); } - + cookie = sj_inhibit (g_get_application_name (), _("Extracting audio from CD"), - GDK_WINDOW_XID(gtk_widget_get_window (main_window))); + GDK_WINDOW_XID(gtk_widget_get_window (GTK_WIDGET(gtkpod_app)))); /* Save the genre */ save_genre (genre_entry); @@ -856,7 +849,7 @@ on_extract_activate (GtkWidget *button, gpointer user_data) * shell-friendly. This involves removing [?*\ ] and replacing with '_'. Also * any leading periods are removed so that the files don't end up being hidden. * - * This function doesn't change the input, and returns an allocated + * This function doesn't change the input, and returns an allocated * string. */ static char* @@ -868,11 +861,11 @@ sanitize_path (const char* str, const char* filesystem_type) /* Skip leading periods, otherwise files disappear... */ while (*str == '.') str++; - + s = g_strdup(str); /* Replace path seperators with a hyphen */ g_strdelimit (s, "/", '-'); - + /* filesystem specific sanitizing */ if (filesystem_type) { if ((strcmp (filesystem_type, "vfat") == 0) || @@ -880,7 +873,7 @@ sanitize_path (const char* str, const char* filesystem_type) g_strdelimit (s, "\\:*?\"<>|", ' '); } } - + if (strip_chars) { /* Replace separators with a hyphen */ g_strdelimit (s, "\\:|", '-'); @@ -928,7 +921,7 @@ filepath_parse_pattern (const char* pattern, const TrackDetails *track) if (pattern == NULL || pattern[0] == 0) return g_strdup (" "); - + fs_info = g_file_query_filesystem_info (base_uri, G_FILE_ATTRIBUTE_FILESYSTEM_TYPE, NULL, NULL); if (fs_info) { @@ -973,7 +966,7 @@ filepath_parse_pattern (const char* pattern, const TrackDetails *track) break; case 'y': if (track->album->release_date && g_date_valid(track->album->release_date)) { - tmp = g_strdup_printf ("%d", g_date_get_year (track->album->release_date)); + tmp = g_strdup_printf ("%d", g_date_get_year (track->album->release_date)); string = sanitize_path (tmp, filesystem_type); g_free (tmp); } @@ -1080,7 +1073,7 @@ filepath_parse_pattern (const char* pattern, const TrackDetails *track) default: g_string_append (s, "%d"); p += 2; - + g_string_append_unichar (s, g_utf8_get_char (p)); p = g_utf8_next_char (p); go_next = FALSE; @@ -1102,8 +1095,8 @@ filepath_parse_pattern (const char* pattern, const TrackDetails *track) if (go_next) ++p; } - - g_free (filesystem_type); + + g_free (filesystem_type); str = s->str; g_string_free (s, FALSE); diff --git a/plugins/sjcd/sj-main.c b/plugins/sjcd/sj-main.c index 75d25ca..a40f03b 100644 --- a/plugins/sjcd/sj-main.c +++ b/plugins/sjcd/sj-main.c @@ -25,6 +25,10 @@ #include <config.h> #endif +#include "libgtkpod/gtkpod_app_iface.h" +#include "libgtkpod/directories.h" +#include "libgtkpod/misc.h" + #include "sound-juicer.h" #include <string.h> @@ -40,7 +44,6 @@ #include "bacon-message-connection.h" #include "rb-gst-media-types.h" -#include "sj-about.h" #include "sj-metadata-getter.h" #include "sj-extractor.h" #include "sj-structures.h" @@ -48,7 +51,6 @@ #include "sj-util.h" #include "sj-main.h" #include "sj-prefs.h" -#include "sj-play.h" #include "sj-genres.h" gboolean on_delete_event (GtkWidget *widget, GdkEvent *event, gpointer user_data); @@ -70,12 +72,12 @@ SjExtractor *extractor; GSettings *sj_settings; -GtkWidget *main_window; +static GtkWidget *vbox1; static GtkWidget *message_area_eventbox; static GtkWidget *title_entry, *artist_entry, *duration_label, *genre_entry, *year_entry, *disc_number_entry; -static GtkWidget *track_listview, *extract_button, *play_button; +static GtkWidget *track_listview, *extract_button; static GtkWidget *status_bar; -static GtkWidget *extract_menuitem, *play_menuitem, *next_menuitem, *prev_menuitem, *select_all_menuitem, *deselect_all_menuitem; +static GtkWidget *extract_menuitem, *select_all_menuitem, *deselect_all_menuitem; static GtkWidget *submit_menuitem; static GtkWidget *duplicate, *eject; GtkListStore *track_store; @@ -99,112 +101,14 @@ static gint no_of_tracks_selected; static AlbumDetails *current_album; static char *current_submit_url = NULL; -gboolean autostart = FALSE, autoplay = FALSE; - -static guint debug_flags = 0; - #define DEFAULT_PARANOIA 4 #define RAISE_WINDOW "raise-window" -#define SOURCE_BUILDER "../data/sound-juicer.ui" -#define INSTALLED_BUILDER DATADIR"/sound-juicer/sound-juicer.ui" - -void -sj_stock_init (void) -{ - static gboolean initialized = FALSE; - static GtkIconFactory *sj_icon_factory = NULL; - - static const GtkStockItem sj_stock_items[] = - { - { SJ_STOCK_EXTRACT, N_("E_xtract"), GDK_CONTROL_MASK, GDK_KEY_Return, NULL } - }; - - if (initialized) - return; - - sj_icon_factory = gtk_icon_factory_new (); - - gtk_icon_factory_add (sj_icon_factory, SJ_STOCK_EXTRACT, gtk_icon_factory_lookup_default (GTK_STOCK_CDROM)); - - gtk_icon_factory_add_default (sj_icon_factory); - - gtk_stock_add_static (sj_stock_items, G_N_ELEMENTS (sj_stock_items)); - - initialized = TRUE; -} - -void -sj_main_set_title (const char* detail) -{ - if (detail == NULL) { - gtk_window_set_title (GTK_WINDOW (main_window), _("Sound Juicer")); - } else { - char *s = g_strdup_printf ("%s - %s", detail, _("Sound Juicer")); - gtk_window_set_title (GTK_WINDOW (main_window), s); - g_free (s); - } -} - -void sj_debug (SjDebugDomain domain, const gchar* format, ...) -{ - va_list args; - gchar *string; - - if (debug_flags & domain) { - va_start (args, format); - string = g_strdup_vprintf (format, args); - va_end (args); - g_printerr ("%s", string); - g_free (string); - } -} - -static void sj_debug_init (void) -{ - const char *str; - const GDebugKey debug_keys[] = { - { "cd", DEBUG_CD }, - { "metadata", DEBUG_METADATA }, - { "playing", DEBUG_PLAYING }, - { "extracting", DEBUG_EXTRACTING } - }; - - str = g_getenv ("SJ_DEBUG"); - if (str) { - debug_flags = g_parse_debug_string (str, debug_keys, G_N_ELEMENTS (debug_keys)); - } -} +#define SJCD_SCHEMA "org.gtkpod.sjcd" static void error_on_start (GError *error) { - GtkWidget *dialog; - dialog = gtk_message_dialog_new_with_markup (NULL, 0, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - "<b>%s</b>\n\n%s: %s.\n%s", - _("Could not start Sound Juicer"), - _("Reason"), - error->message, - _("Please consult the documentation for assistance.")); - gtk_dialog_run (GTK_DIALOG (dialog)); -} - -/** - * Clicked Quit - */ -G_MODULE_EXPORT void on_quit_activate (GtkMenuItem *item, gpointer user_data) -{ - if (on_delete_event (NULL, NULL, NULL) == FALSE) { - gtk_main_quit (); - } -} - -/** - * Destroy signal Callback - */ -G_MODULE_EXPORT void on_destroy_signal (GtkMenuItem *item, gpointer user_data) -{ - gtk_main_quit (); + gtkpod_statusbar_message("Could not start sound juicer because %s", error->message); + g_error_free(error); } /** @@ -212,9 +116,6 @@ G_MODULE_EXPORT void on_destroy_signal (GtkMenuItem *item, gpointer user_data) */ G_MODULE_EXPORT void on_eject_activate (GtkMenuItem *item, gpointer user_data) { - /* first make sure we're not playing */ - stop_playback (); - brasero_drive_eject (drive, FALSE, NULL); } @@ -224,7 +125,7 @@ G_MODULE_EXPORT gboolean on_delete_event (GtkWidget *widget, GdkEvent *event, gp GtkWidget *dialog; int response; - dialog = gtk_message_dialog_new (GTK_WINDOW (main_window), GTK_DIALOG_MODAL, + dialog = gtk_message_dialog_new (GTK_WINDOW (gtkpod_app), GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, _("You are currently extracting a CD. Do you want to quit now or continue?")); @@ -455,9 +356,6 @@ static void update_ui_for_album (AlbumDetails *album) char* duration_text; total_no_of_tracks=0; - /* Really really make sure we don't have a playing title */ - sj_main_set_title (NULL); - if (album == NULL) { gtk_list_store_clear (track_store); gtk_entry_set_text (GTK_ENTRY (title_entry), ""); @@ -471,14 +369,10 @@ static void update_ui_for_album (AlbumDetails *album) gtk_widget_set_sensitive (genre_entry, FALSE); gtk_widget_set_sensitive (year_entry, FALSE); gtk_widget_set_sensitive (disc_number_entry, FALSE); - gtk_widget_set_sensitive (play_button, FALSE); - gtk_widget_set_sensitive (play_menuitem, FALSE); gtk_widget_set_sensitive (extract_button, FALSE); gtk_widget_set_sensitive (extract_menuitem, FALSE); gtk_widget_set_sensitive (select_all_menuitem, FALSE); gtk_widget_set_sensitive (deselect_all_menuitem, FALSE); - gtk_widget_set_sensitive (prev_menuitem, FALSE); - gtk_widget_set_sensitive (next_menuitem, FALSE); set_duplication (FALSE); set_message_area (message_area_eventbox, NULL); @@ -513,14 +407,10 @@ static void update_ui_for_album (AlbumDetails *album) gtk_widget_set_sensitive (genre_entry, TRUE); gtk_widget_set_sensitive (year_entry, TRUE); gtk_widget_set_sensitive (disc_number_entry, TRUE); - gtk_widget_set_sensitive (play_button, TRUE); - gtk_widget_set_sensitive (play_menuitem, TRUE); gtk_widget_set_sensitive (extract_button, TRUE); gtk_widget_set_sensitive (extract_menuitem, TRUE); gtk_widget_set_sensitive (select_all_menuitem, FALSE); gtk_widget_set_sensitive (deselect_all_menuitem, TRUE); - gtk_widget_set_sensitive (prev_menuitem, FALSE); - gtk_widget_set_sensitive (next_menuitem, FALSE); set_duplication (TRUE); for (l = album->tracks; l; l=g_list_next (l)) { @@ -618,7 +508,7 @@ AlbumDetails* multiple_album_dialog(GList *albums) dialog = GET_WIDGET ("multiple_dialog"); g_assert (dialog != NULL); - gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (main_window)); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (gtkpod_app)); albums_listview = GET_WIDGET ("albums_listview"); ok_button = GET_WIDGET ("ok_button"); @@ -696,7 +586,7 @@ static void baseuri_changed_cb (GSettings *settings, gchar *key, gpointer user_d g_free (value); /* TODO: sanity check the URI somewhat */ } - + /** * The GSettings key for the directory pattern changed */ @@ -707,7 +597,7 @@ static void path_pattern_changed_cb (GSettings *settings, gchar *key, gpointer u path_pattern = g_settings_get_string (settings, key); /* TODO: sanity check the pattern */ } - + /** * The GSettings key for the filename pattern changed */ @@ -718,7 +608,7 @@ static void file_pattern_changed_cb (GSettings *settings, gchar *key, gpointer u file_pattern = g_settings_get_string (settings, key); /* TODO: sanity check the pattern */ } - + /** * The GSettings key for the paranoia mode has changed */ @@ -731,7 +621,7 @@ static void paranoia_changed_cb (GSettings *settings, gchar *key, gpointer user_ sj_extractor_set_paranoia (extractor, value); } } - + /** * The GSettings key for the strip characters option changed */ @@ -740,7 +630,7 @@ static void strip_changed_cb (GSettings *settings, gchar *key, gpointer user_dat g_assert (strcmp (key, SJ_SETTINGS_STRIP) == 0); strip_chars = g_settings_get_boolean (settings, key); } - + /** * The GSettings key for the eject when finished option changed */ @@ -749,7 +639,7 @@ static void eject_changed_cb (GSettings *settings, gchar *key, gpointer user_dat g_assert (strcmp (key, SJ_SETTINGS_EJECT) == 0); eject_finished = g_settings_get_boolean (settings, key); } - + /** * The GSettings key for the open when finished option changed */ @@ -758,14 +648,14 @@ static void open_changed_cb (GSettings *settings, gchar *key, gpointer user_data g_assert (strcmp (key, SJ_SETTINGS_OPEN) == 0); open_finished = g_settings_get_boolean (settings, key); } - + /** * The GSettings key for audio volume changes */ static void audio_volume_changed_cb (GSettings *settings, gchar *key, gpointer user_data) { g_assert (strcmp (key, SJ_SETTINGS_AUDIO_VOLUME) == 0); - + GtkWidget *volb = GET_WIDGET ("volume_button"); gtk_scale_button_set_value (GTK_SCALE_BUTTON (volb), g_settings_get_double (settings, key)); } @@ -773,17 +663,17 @@ static void audio_volume_changed_cb (GSettings *settings, gchar *key, gpointer u static void metadata_cb (SjMetadataGetter *m, GList *albums, GError *error) { - gboolean realized = gtk_widget_get_realized (main_window); + gboolean realized = gtk_widget_get_realized (GTK_WIDGET(gtkpod_app)); if (realized) - gdk_window_set_cursor (gtk_widget_get_window (main_window), NULL); + gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET(gtkpod_app)), NULL); /* Clear the statusbar message */ gtk_statusbar_pop(GTK_STATUSBAR(status_bar), 0); if (error && !(error->code == SJ_ERROR_CD_NO_MEDIA)) { GtkWidget *dialog; - dialog = gtk_message_dialog_new_with_markup (realized ? GTK_WINDOW (main_window) : NULL, 0, + dialog = gtk_message_dialog_new_with_markup (realized ? GTK_WINDOW (gtkpod_app) : NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "<b>%s</b>\n\n%s\n%s: %s", @@ -825,15 +715,6 @@ metadata_cb (SjMetadataGetter *m, GList *albums, GError *error) albums = NULL; } update_ui_for_album (current_album); - - if (autostart) { - g_signal_emit_by_name (extract_button, "activate", NULL); - autostart = FALSE; - } - if (autoplay) { - g_signal_emit_by_name (play_button, "activate", NULL); - autoplay = FALSE; - } } static gboolean @@ -861,48 +742,45 @@ static void reread_cd (gboolean ignore_no_media) { /* TODO: remove ignore_no_media? */ GError *error = NULL; - GdkCursor *cursor; - GdkWindow *window; - gboolean realized = gtk_widget_get_realized (main_window); - - window = gtk_widget_get_window (main_window); - - /* Make sure nothing is playing */ - stop_playback (); - - /* Set watch cursor */ - if (realized) { - cursor = gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (main_window)), GDK_WATCH); - gdk_window_set_cursor (window, cursor); - gdk_cursor_unref (cursor); - gdk_display_sync (gtk_widget_get_display (GTK_WIDGET (main_window))); - } +// GdkCursor *cursor; +// GdkWindow *window; + gboolean realized = gtk_widget_get_realized (GTK_WIDGET(gtkpod_app)); +// +// window = gtk_widget_get_window (GTK_WIDGET(gtkpod_app)); +// +// /* Set watch cursor */ +// if (realized) { +// cursor = gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (gtkpod_app)), GDK_WATCH); +// gdk_window_set_cursor (window, cursor); +// gdk_cursor_unref (cursor); +// gdk_display_sync (gtk_widget_get_display (GTK_WIDGET (gtkpod_app))); +// } /* Set statusbar message */ gtk_statusbar_push(GTK_STATUSBAR(status_bar), 0, _("Retrieving track listing...please wait.")); - if (!drive) - sj_debug (DEBUG_CD, "Attempting to re-read NULL drive\n"); - g_free (current_submit_url); current_submit_url = NULL; gtk_widget_set_sensitive (submit_menuitem, FALSE); if (!is_audio_cd (drive)) { - sj_debug (DEBUG_CD, "Media is not an audio CD\n"); update_ui_for_album (NULL); + // TODO Use gtkpod statusbar instead gtk_statusbar_pop(GTK_STATUSBAR(status_bar), 0); - if (realized) - gdk_window_set_cursor (window, NULL); +// if (realized) +// gdk_window_set_cursor (window, NULL); return; } sj_metadata_getter_list_albums (metadata, &error); if (error && !(error->code == SJ_ERROR_CD_NO_MEDIA && ignore_no_media)) { + //TODO + // Change dialog to be gtkpod dialog + GtkWidget *dialog; - dialog = gtk_message_dialog_new (realized ? GTK_WINDOW (main_window) : NULL, 0, + dialog = gtk_message_dialog_new (realized ? GTK_WINDOW (gtkpod_app) : NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", _("Could not read the CD")); @@ -929,7 +807,6 @@ media_added_cb (BraseroMediumMonitor *drive, /* FIXME: recover? */ } - sj_debug (DEBUG_CD, "Media added to device %s\n", brasero_drive_get_device (brasero_medium_get_drive (medium))); reread_cd (TRUE); } @@ -942,11 +819,6 @@ media_removed_cb (BraseroMediumMonitor *drive, /* FIXME: recover? */ } - /* first make sure we're not playing */ - stop_playback (); - - sj_debug (DEBUG_CD, "Media removed from device %s\n", brasero_drive_get_device (brasero_medium_get_drive (medium))); - stop_ui_hack (); update_ui_for_album (NULL); } @@ -969,7 +841,7 @@ set_drive_from_device (const char *device) GtkWidget *dialog; char *message; message = g_strdup_printf (_("Sound Juicer could not use the CD-ROM device '%s'"), device); - dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (main_window), + dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (gtkpod_app), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, @@ -1001,7 +873,7 @@ set_device (const char* device, gboolean ignore_no_media) error = g_strerror (errno); message = g_strdup_printf (_("Sound Juicer could not access the CD-ROM device '%s'"), device); - dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (main_window), + dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (gtkpod_app), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, @@ -1094,7 +966,7 @@ static void device_changed_cb (GSettings *settings, gchar *key, gpointer user_da if (device == NULL) { #ifndef IGNORE_MISSING_CD GtkWidget *dialog; - dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (main_window), + dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (gtkpod_app), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, @@ -1115,7 +987,7 @@ static void device_changed_cb (GSettings *settings, gchar *key, gpointer user_da static void profile_changed_cb (GSettings *settings, gchar *key, gpointer user_data) { GstEncodingProfile *profile; - const char *media_type; + gchar *media_type; g_assert (strcmp (key, SJ_SETTINGS_AUDIO_PROFILE) == 0); media_type = g_settings_get_string (settings, key); @@ -1129,7 +1001,7 @@ static void profile_changed_cb (GSettings *settings, gchar *key, gpointer user_d GtkWidget *dialog; int response; - dialog = gtk_message_dialog_new (GTK_WINDOW (main_window), + dialog = gtk_message_dialog_new (GTK_WINDOW (gtkpod_app), GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, @@ -1178,7 +1050,7 @@ static void http_proxy_enable_changed_cb (GSettings *settings, gchar *key, gpoin g_assert (strcmp (key, SJ_SETTINGS_HTTP_PROXY_ENABLE) == 0); http_proxy_setup (settings); } - + /** * The GSettings key for the HTTP proxy changed. */ @@ -1187,7 +1059,7 @@ static void http_proxy_changed_cb (GSettings *settings, gchar *key, gpointer use g_assert (strcmp (key, SJ_SETTINGS_HTTP_PROXY) == 0); http_proxy_setup (settings); } - + /** * The GSettings key for the HTTP proxy port changed. */ @@ -1216,7 +1088,7 @@ G_MODULE_EXPORT void on_submit_activate (GtkWidget *menuitem, gpointer user_data if (!gtk_show_uri (NULL, current_submit_url, GDK_CURRENT_TIME, &error)) { GtkWidget *dialog; - dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (main_window), + dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (gtkpod_app), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, @@ -1467,7 +1339,7 @@ G_MODULE_EXPORT void on_contents_activate(GtkWidget *button, gpointer user_data) if (error) { GtkWidget *dialog; - dialog = gtk_message_dialog_new (GTK_WINDOW (main_window), + dialog = gtk_message_dialog_new (GTK_WINDOW (gtkpod_app), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, @@ -1488,7 +1360,7 @@ on_message_received (const char *message, gpointer user_data) if (message == NULL) return; if (strcmp (RAISE_WINDOW, message) == 0) { - gtk_window_present (GTK_WINDOW (main_window)); + gtk_window_present (GTK_WINDOW (gtkpod_app)); } } @@ -1549,7 +1421,7 @@ G_MODULE_EXPORT void on_duplicate_activate (GtkWidget *button, gpointer user_dat if (!g_spawn_command_line_async (g_strconcat ("brasero -c ", device, NULL), &error)) { GtkWidget *dialog; - dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (main_window), + dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (gtkpod_app), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, @@ -1575,56 +1447,22 @@ static void set_duplication(gboolean enabled) } } -int main (int argc, char **argv) +GtkWidget *sj_create_sound_juicer() { + gchar *glade_path; + GtkWidget *w; GError *error = NULL; GtkTreeSelection *selection; char *device = NULL, **uris = NULL; - GOptionContext *ctx; - const GOptionEntry entries[] = { - { "auto-start", 'a', 0, G_OPTION_ARG_NONE, &autostart, N_("Start extracting immediately"), NULL }, - { "play", 'p', 0, G_OPTION_ARG_NONE, &autoplay, N_("Start playing immediately"), NULL}, - { "device", 'd', 0, G_OPTION_ARG_FILENAME, &device, N_("What CD device to read"), N_("DEVICE") }, - { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &uris, N_("URI to the CD device to read"), NULL }, - { NULL } - }; GSettings *http_settings; - if (!g_thread_supported ()) g_thread_init (NULL); - - bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - textdomain (GETTEXT_PACKAGE); - - g_set_application_name (_("Sound Juicer")); g_setenv ("PULSE_PROP_media.role", "music", TRUE); - ctx = g_option_context_new (N_("- Extract music from your CDs")); - g_option_context_add_main_entries (ctx, entries, GETTEXT_PACKAGE); - g_option_context_set_translation_domain(ctx, GETTEXT_PACKAGE); - g_option_context_add_group (ctx, gtk_get_option_group (TRUE)); - g_option_context_add_group (ctx, gst_init_get_option_group ()); - g_option_context_add_group (ctx, brasero_media_get_option_group ()); - g_option_context_set_ignore_unknown_options (ctx, TRUE); - - g_option_context_parse (ctx, &argc, &argv, &error); - if (error != NULL) { - g_printerr ("Error parsing options: %s", error->message); - exit (1); - } - g_option_context_free (ctx); - - sj_debug_init (); - - sj_stock_init (); - - gtk_window_set_default_icon_name ("sound-juicer"); - connection = bacon_message_connection_new ("sound-juicer"); if (bacon_message_connection_get_is_server (connection) == FALSE) { bacon_message_connection_send (connection, RAISE_WINDOW); bacon_message_connection_free (connection); - exit (0); + return NULL; } else { bacon_message_connection_set_callback (connection, on_message_received, NULL); } @@ -1634,10 +1472,10 @@ int main (int argc, char **argv) metadata = sj_metadata_getter_new (); g_signal_connect (metadata, "metadata", G_CALLBACK (metadata_cb), NULL); - sj_settings = g_settings_new ("org.gnome.SoundJuicer"); + sj_settings = g_settings_new (SJCD_SCHEMA); if (sj_settings == NULL) { g_warning (_("Could not create GSettings object.\n")); - exit (1); + return NULL; } g_signal_connect (sj_settings, "changed::"SJ_SETTINGS_DEVICE, @@ -1673,22 +1511,18 @@ int main (int argc, char **argv) g_signal_connect (http_settings, "changed::"SJ_SETTINGS_HTTP_PROXY_PORT, (GCallback)http_proxy_port_changed_cb, NULL); - builder = gtk_builder_new (); - if (g_file_test (SOURCE_BUILDER, G_FILE_TEST_EXISTS) != FALSE) { - gtk_builder_add_from_file (builder, SOURCE_BUILDER, &error); - } else { - gtk_builder_add_from_file (builder, INSTALLED_BUILDER, &error); - } - - if (error != NULL) { - error_on_start (error); - g_error_free (error); - exit (1); - } + glade_path = g_build_filename(get_glade_dir(), "sjcd.xml", NULL); + builder = gtkpod_builder_xml_new(glade_path); + g_free(glade_path); gtk_builder_connect_signals (builder, NULL); - main_window = GET_WIDGET ("main_window"); + w = GET_WIDGET ("main_window"); + vbox1 = GET_WIDGET ("vbox1"); + g_object_ref(vbox1); + gtk_container_remove(GTK_CONTAINER(w), vbox1); + gtk_widget_destroy(w); + message_area_eventbox = GET_WIDGET ("message_area_eventbox"); select_all_menuitem = GET_WIDGET ("select_all"); deselect_all_menuitem = GET_WIDGET ("deselect_all"); @@ -1702,35 +1536,10 @@ int main (int argc, char **argv) track_listview = GET_WIDGET ("track_listview"); extract_button = GET_WIDGET ("extract_button"); extract_menuitem = GET_WIDGET ("extract_menuitem"); - play_button = GET_WIDGET ("play_button"); - play_menuitem = GET_WIDGET ("play_menuitem"); - next_menuitem = GET_WIDGET ("next_track_menuitem"); - prev_menuitem = GET_WIDGET ("previous_track_menuitem"); status_bar = GET_WIDGET ("status_bar"); duplicate = GET_WIDGET ("duplicate_menuitem"); eject = GET_WIDGET ("eject"); - { /* ensure that the play/pause button's size is constant */ - GtkWidget *fake_button1, *fake_button2; - GtkSizeGroup *size_group; - - size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - - fake_button1 = gtk_button_new_from_stock (GTK_STOCK_MEDIA_PLAY); - gtk_size_group_add_widget (size_group, fake_button1); - g_signal_connect_swapped (play_button, "destroy", - G_CALLBACK (gtk_widget_destroy), - fake_button1); - - fake_button2 = gtk_button_new_from_stock (GTK_STOCK_MEDIA_PAUSE); - gtk_size_group_add_widget (size_group, fake_button2); - g_signal_connect_swapped (play_button, "destroy", - G_CALLBACK (gtk_widget_destroy), - fake_button2); - - gtk_size_group_add_widget (size_group, play_button); - g_object_unref (G_OBJECT (size_group)); - } setup_genre_entry (genre_entry); @@ -1797,13 +1606,11 @@ int main (int argc, char **argv) error = sj_extractor_get_new_error (extractor); if (error) { error_on_start (error); - exit (1); + return NULL; } update_ui_for_album (NULL); - sj_play_init (); - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (track_listview)); gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); @@ -1856,17 +1663,13 @@ int main (int argc, char **argv) if (sj_extractor_supports_encoding (&error) == FALSE) { error_on_start (error); - return 0; + return NULL; } /* Set whether duplication of a cd is available using the brasero tool */ gtk_widget_set_sensitive (duplicate, FALSE); duplication_enabled = is_cd_duplication_available(); - /*gconf_bridge_bind_window_size(gconf_bridge_get(), GCONF_WINDOW, GTK_WINDOW (main_window)); */ - gtk_widget_show (main_window); - gtk_main (); - g_object_unref (base_uri); g_object_unref (metadata); g_object_unref (extractor); @@ -1874,5 +1677,5 @@ int main (int argc, char **argv) g_object_unref (http_settings); brasero_media_library_stop (); - return 0; + return vbox1; } diff --git a/plugins/sjcd/sj-main.h b/plugins/sjcd/sj-main.h index 9f3e971..1d91cbf 100644 --- a/plugins/sjcd/sj-main.h +++ b/plugins/sjcd/sj-main.h @@ -1,4 +1,4 @@ -/* +/* * Sound Juicer - sj-main.h * * This program is free software; you can redistribute it and/or modify @@ -22,9 +22,9 @@ #define SJ_MAIN_H #include <gtk/gtk.h> -#include "sj-structures.h" +#include "libjuicer/sj-structures.h" -void sj_stock_init (void); +GtkWidget *sj_create_sound_juicer(); G_MODULE_EXPORT void on_quit_activate (GtkMenuItem *item, gpointer user_data); G_MODULE_EXPORT void on_destroy_activate (GtkMenuItem *item, gpointer user_data); diff --git a/plugins/sjcd/sj-prefs.c b/plugins/sjcd/sj-prefs.c index 8a20231..726c5c5 100644 --- a/plugins/sjcd/sj-prefs.c +++ b/plugins/sjcd/sj-prefs.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2003 Ross Burton <ro...@bu...> * * Sound Juicer - sj-about.c @@ -24,9 +24,13 @@ #include <config.h> #endif +// TODO need to remove when replacing the prefs to gtkpod prefs +#include "libgtkpod/gtkpod_app_iface.h" + #include "sound-juicer.h" #include <string.h> +#include <gst/pbutils/encoding-profile.h> #include <gtk/gtk.h> #include <brasero-drive-selection.h> @@ -36,7 +40,6 @@ #include "sj-prefs.h" extern GtkBuilder *builder; -extern GtkWidget *main_window; static GtkWidget *audio_profile; static GtkWidget *cd_option, *path_option, *file_option, *basepath_fcb, *check_strip, *check_eject, *check_open; @@ -80,13 +83,13 @@ void prefs_profile_changed (GtkWidget *widget, gpointer user_data) model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); /* Handle the change being to unselect a profile */ - if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter)) { - char *media_type; - gtk_tree_model_get (GTK_TREE_MODEL (model), &iter, + if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter)) { + char *media_type; + gtk_tree_model_get (GTK_TREE_MODEL (model), &iter, 0, &media_type, -1); - g_settings_set_string (sj_settings, SJ_SETTINGS_AUDIO_PROFILE, media_type); - g_free (media_type); - } + g_settings_set_string (sj_settings, SJ_SETTINGS_AUDIO_PROFILE, media_type); + g_free (media_type); + } } /** @@ -121,14 +124,14 @@ void show_help (GtkWindow *parent) G_MODULE_EXPORT void prefs_base_folder_changed (GtkWidget *chooser, gpointer user_data) { char *new_uri, *current_uri; - + current_uri = g_settings_get_string (sj_settings, SJ_SETTINGS_BASEURI); - new_uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (chooser)); + new_uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (chooser)); if (current_uri == NULL || strcmp(current_uri, new_uri) != 0) { g_settings_set_string (sj_settings, SJ_SETTINGS_BASEURI, new_uri); } - + g_free (new_uri); g_free (current_uri); } @@ -222,9 +225,9 @@ static void baseuri_changed_cb (GSettings *settings, gchar *key, gpointer user_ g_object_unref (dir); } else { current_uri = gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (basepath_fcb)); - if (current_uri == NULL || strcmp (current_uri, base_uri) != 0) + if (current_uri == NULL || strcmp (current_uri, base_uri) != 0) gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (basepath_fcb), base_uri); - + } } @@ -257,7 +260,7 @@ static void pattern_label_update (void) NULL, /* track ID */ NULL, /* artist ID */ }; - + g_object_get (extractor, "profile", &profile, NULL); /* It's possible the profile isn't set, in which case do nothing */ if (!profile) { @@ -294,7 +297,7 @@ static void pattern_label_update (void) "</i></small>", NULL); g_free (example); g_free (media_type); - + gtk_label_set_markup (GTK_LABEL (path_example_label), format); g_free (format); } @@ -320,7 +323,7 @@ static void file_pattern_changed_cb (GSettings *settings, gchar *key, gpointer u int i = 0; g_return_if_fail (strcmp (key, SJ_SETTINGS_FILE_PATTERN) == 0); - + value = g_settings_get_string (settings, key); while (file_patterns[i].pattern && strcmp(file_patterns[i].pattern, value) != 0) { i++; @@ -386,7 +389,7 @@ static void populate_pattern_combo (GtkComboBox *combo, const FilePattern *patte { GtkListStore *store; int i; - + store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); for (i = 0; patterns[i].pattern; ++i) { GtkTreeIter iter; @@ -461,7 +464,7 @@ G_MODULE_EXPORT void on_edit_preferences_cb (GtkMenuItem *item, gpointer user_da g_assert (prefs_dialog != NULL); g_object_add_weak_pointer (G_OBJECT (prefs_dialog), (gpointer)&prefs_dialog); - gtk_window_set_transient_for (GTK_WINDOW (prefs_dialog), GTK_WINDOW (main_window)); + gtk_window_set_transient_for (GTK_WINDOW (prefs_dialog), GTK_WINDOW (gtkpod_app)); group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); for (i = 0; i < G_N_ELEMENTS (labels); i++) { @@ -521,7 +524,7 @@ G_MODULE_EXPORT void on_edit_preferences_cb (GtkMenuItem *item, gpointer user_da (GCallback)file_pattern_changed_cb, NULL); g_signal_connect (G_OBJECT (sj_settings), "changed::"SJ_SETTINGS_STRIP, (GCallback)strip_changed_cb, NULL); - + g_signal_connect (extractor, "notify::profile", pattern_label_update, NULL); baseuri_changed_cb (sj_settings, SJ_SETTINGS_BASEURI, NULL); diff --git a/plugins/sjcd/sjcd.xml b/plugins/sjcd/sjcd.xml index 12de20c..c8024c7 100644 --- a/plugins/sjcd/sjcd.xml +++ b/plugins/sjcd/sjcd.xml @@ -1,124 +1,99 @@ -<?xml version="1.0"?> +<?xml version="1.0" encoding="UTF-8"?> <interface> <requires lib="gtk+" version="2.16"/> - <!-- interface-naming-policy project-wide --> <object class="GtkWindow" id="main_window"> <property name="width_request">500</property> <property name="height_request">420</property> + <property name="can_focus">Fal... [truncated message content] |