commit d31d80052fe8f59eca63b0e899e7f1840aa6e0f6 Author: phantomjinx <p.g.richard...@phantomjinx.co.uk> Date: Sat Jan 28 00:39:21 2012 +0000
Import tracks once sjcd has ripped them * bacon-message-connection files not necessary since a flashing application is not required. * sj-extractor.c * documentation recommends using gst_bus_timed_pop_filtered instead of gt_bus_poll * sj-main.c * Remove unneeded callbacks * sj-extracing.c * Remove remaining play button references as not used and generating warnings * add import_files_to_itdb function to take the files ripped by sjcd and import them into the selected itdb plugins/sjcd/Makefile.am | 5 +- plugins/sjcd/bacon-message-connection.c | 400 ------------------------------- plugins/sjcd/bacon-message-connection.h | 43 ---- plugins/sjcd/libjuicer/sj-extractor.c | 2 +- plugins/sjcd/sj-extracting.c | 163 ++++++++----- plugins/sjcd/sj-main.c | 34 --- plugins/sjcd/sound-juicer.h | 5 - 7 files changed, 105 insertions(+), 547 deletions(-) --- diff --git a/plugins/sjcd/Makefile.am b/plugins/sjcd/Makefile.am index f5aa0e6..c09a249 100644 --- a/plugins/sjcd/Makefile.am +++ b/plugins/sjcd/Makefile.am @@ -35,9 +35,8 @@ libsjcd_la_SOURCES = plugin.c plugin.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 - + egg-play-preview.c egg-play-preview.h + libsjcd_la_CFLAGS = -I$(top_srcdir)/plugins/$(plugin_name)/libjuicer \ $(GSTREAMER_CFLAGS) \ $(BRASERO_CFLAGS) \ diff --git a/plugins/sjcd/libjuicer/sj-extractor.c b/plugins/sjcd/libjuicer/sj-extractor.c index 320b4c9..1083bf1 100644 --- a/plugins/sjcd/libjuicer/sj-extractor.c +++ b/plugins/sjcd/libjuicer/sj-extractor.c @@ -621,7 +621,7 @@ sj_extractor_extract_track (SjExtractor *extractor, const TrackDetails *track, G if (state_ret == GST_STATE_CHANGE_FAILURE) { GstMessage *msg; - msg = gst_bus_poll (GST_ELEMENT_BUS (priv->pipeline), GST_MESSAGE_ERROR, 0); + msg = gst_bus_timed_pop_filtered(GST_ELEMENT_BUS (priv->pipeline), 0, GST_MESSAGE_ERROR); if (msg) { gst_message_parse_error (msg, error, NULL); gst_message_unref (msg); diff --git a/plugins/sjcd/sj-extracting.c b/plugins/sjcd/sj-extracting.c index 953ee75..fc33449 100644 --- a/plugins/sjcd/sj-extracting.c +++ b/plugins/sjcd/sj-extracting.c @@ -24,8 +24,10 @@ #include <config.h> #endif -// TODO Remove this and replace dialogs with gtkpod dialogs #include "libgtkpod/gtkpod_app_iface.h" +#include "libgtkpod/gp_itdb.h" +#include "libgtkpod/misc.h" +#include "libgtkpod/misc_track.h" #include "sound-juicer.h" @@ -87,10 +89,10 @@ static gboolean successful_extract = FALSE; static GtkWidget *progress_bar, *status_bar; /** The widgets in the main UI */ -static GtkWidget *extract_button, *play_button, *title_entry, *artist_entry, *genre_entry, *year_entry, *disc_number_entry, *track_listview; +static GtkWidget *extract_button, *title_entry, *artist_entry, *genre_entry, *year_entry, *disc_number_entry, *track_listview; /** The menuitem in the main menu */ -static GtkWidget *extract_menuitem, *play_menuitem, *reread_menuitem, *select_all_menuitem, *deselect_all_menuitem; +static GtkWidget *extract_menuitem, *reread_menuitem, *select_all_menuitem, *deselect_all_menuitem; static GtkTreeIter current; @@ -101,6 +103,11 @@ static GtkTreeIter current; static GList *paths = NULL; /** + * A list of files we have extracted. + */ +static GList *files = NULL; + +/** * The total number of tracks we are extracting. */ static int total_extracting; @@ -428,6 +435,8 @@ pop_and_extract (int *overwrite_mode) /* Save the directory name for later */ paths = g_list_append (paths, directory); + /* Save the file name for later */ + files = g_list_append(files, g_file_get_path(file)); goffset file_size; file_size = check_file_size (file); @@ -557,43 +566,95 @@ on_progress_cb (SjExtractor *extractor, const int seconds, gpointer data) } } -/** - * A list foreach function which will find the deepest common directory in a - * list of filenames. - * @param path the path in this iteration - * @param ret a char** to the deepest common path - */ -static void -base_finder (char *path, char **ret) +static gboolean +import_files_to_itdb(gpointer *data) { - if (*ret == NULL) { - /* If no common directory so far, this must be it. */ - *ret = g_strdup (path); - return; - } else { - /* Urgh */ - char *i, *j, *marker; - i = marker = path; - j = *ret; - while (*i == *j) { - if (*i == G_DIR_SEPARATOR) marker = i; - if (*i == 0) { - marker = i; - break; - } - i = g_utf8_next_char (i); - j = g_utf8_next_char (j); + GList *file_list = files; + gchar *statusmsg; + iTunesDB *itdb; + GError *error = NULL; + gboolean result = TRUE; /* Result of file adding */ + GString *errors = g_string_new(""); + + itdb = gp_get_selected_itdb(); + if (!itdb) { + gtkpod_warning(_("%d were ripped from the CD but no repository was selected. Please import them manually."), g_list_length(files)); + g_string_free(errors, TRUE); + g_list_free_full(files, g_free); + return TRUE; } - g_free (*ret); - *ret = g_strndup (path, marker - path + 1); - } -} -static gboolean -on_main_window_focus_in (GtkWidget * widget, GdkEventFocus * event, gpointer data) -{ - gtk_window_set_urgency_hint (GTK_WINDOW (gtkpod_app), FALSE); - return FALSE; + block_widgets(); + + gtkpod_statusbar_busy_push(); + + gtkpod_statusbar_reset_progress(g_list_length(files)); + + while(file_list) { + gchar *file = file_list->data; + statusmsg = g_strdup_printf(_("Importing file '%s'. Please wait..."), file); + error = NULL; + + result &= add_track_by_filename(itdb, file, NULL, FALSE, NULL, NULL, &error); + if (error) { + gchar *buf = g_strdup_printf(_("%s\n"), error->message); + g_string_append(errors, buf); + g_free(buf); + g_error_free(error); + error = NULL; + } + + gtkpod_statusbar_increment_progress_ticks(1, statusmsg); + + file_list = file_list->next; + } + + gtkpod_statusbar_busy_pop(); + + release_widgets(); + + /* Final save of remaining added tracks */ + gp_save_itdb(itdb); + + /* clear log of non-updated tracks */ + display_non_updated((void *) -1, NULL); + + /* display log of updated tracks */ + display_updated(NULL, NULL); + + /* display log of detected duplicates */ + gp_duplicate_remove(NULL, NULL); + + /* Set the itdb's playlist as the selected - updates the display */ + gtkpod_set_current_playlist(itdb_playlist_mpl(itdb)); + + /* Were all files successfully added? */ + if (!result) { + if (errors->len > 0) { + gtkpod_confirmation(-1, /* gint id, */ + TRUE, /* gboolean modal, */ + _("File Addition Errors"), /* title */ + _("Some files were not added successfully"), /* label */ + errors->str, /* scrolled text */ + NULL, 0, NULL, /* option 1 */ + NULL, 0, NULL, /* option 2 */ + TRUE, /* gboolean confirm_again, */ + "show_file_addition_errors",/* confirm_again_key,*/ + CONF_NULL_HANDLER, /* ConfHandler ok_handler,*/ + NULL, /* don't show "Apply" button */ + NULL, /* cancel_handler,*/ + NULL, /* gpointer user_data1,*/ + NULL); /* gpointer user_data2,*/ + } + else { + gtkpod_warning(_("Some tracks failed to be added but no errors were reported.")); + } + } + + g_string_free(errors, TRUE); + g_list_free_full(files, g_free); + + return TRUE; } /** @@ -602,33 +663,14 @@ on_main_window_focus_in (GtkWidget * widget, GdkEventFocus * event, gpointer dat static void finished_actions (void) { - /* Trigger a sound effect */ - 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 (gtkpod_app), "focus-in-event", - G_CALLBACK (on_main_window_focus_in), NULL); - 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; - - /* Find the deepest common directory. */ - g_list_foreach (paths, (GFunc)base_finder, &base); - - gtk_show_uri (NULL, base, GDK_CURRENT_TIME, NULL); - - g_free (base); - } + gdk_threads_enter(); + import_files_to_itdb(NULL); + gdk_threads_leave(); } /** @@ -767,7 +809,6 @@ on_extract_activate (GtkWidget *button, gpointer user_data) g_signal_connect (extractor, "error", G_CALLBACK (on_error_cb), NULL); extract_button = GET_WIDGET ("extract_button"); - play_button = GET_WIDGET ("play_button"); title_entry = GET_WIDGET ("title_entry"); artist_entry = GET_WIDGET ("artist_entry"); genre_entry = GET_WIDGET ("genre_entry"); @@ -777,7 +818,6 @@ on_extract_activate (GtkWidget *button, gpointer user_data) 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"); @@ -819,6 +859,7 @@ on_extract_activate (GtkWidget *button, gpointer user_data) g_free (reason); } + // TODO cookie = sj_inhibit (g_get_application_name (), _("Extracting audio from CD"), GDK_WINDOW_XID(gtk_widget_get_window (GTK_WIDGET(gtkpod_app)))); diff --git a/plugins/sjcd/sj-main.c b/plugins/sjcd/sj-main.c index 4604008..5ac4330 100644 --- a/plugins/sjcd/sj-main.c +++ b/plugins/sjcd/sj-main.c @@ -42,7 +42,6 @@ #include <brasero-volume.h> #include <gst/gst.h> -#include "bacon-message-connection.h" #include "rb-gst-media-types.h" #include "sj-metadata-getter.h" #include "sj-extractor.h" @@ -79,7 +78,6 @@ static GtkWidget *extract_menuitem, *select_all_menuitem, *deselect_all_menuitem static GtkWidget *submit_menuitem; static GtkWidget *duplicate, *eject; GtkListStore *track_store; -static BaconMessageConnection *connection; GtkCellRenderer *toggle_renderer, *title_renderer, *artist_renderer; GtkWidget *current_message_area; @@ -90,7 +88,6 @@ GFile *base_uri; BraseroDrive *drive = NULL; gboolean strip_chars; gboolean eject_finished; -gboolean open_finished; gboolean extracting = FALSE; static gboolean duplication_enabled; @@ -640,15 +637,6 @@ static void eject_changed_cb (GSettings *settings, gchar *key, gpointer user_dat eject_finished = g_settings_get_boolean (settings, key); } - /** - * The GSettings key for the open when finished option changed - */ -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); -} - static void metadata_cb (SjMetadataGetter *m, GList *albums, GError *error) { @@ -1343,16 +1331,6 @@ G_MODULE_EXPORT void on_contents_activate(GtkWidget *button, gpointer user_data) } } -static void -on_message_received (const char *message, gpointer user_data) -{ - if (message == NULL) - return; - if (strcmp (RAISE_WINDOW, message) == 0) { - gtk_window_present (GTK_WINDOW (gtkpod_app)); - } -} - /** * Performs various checks to ensure CD duplication is available. * If this is found TRUE is returned, otherwise FALSE is returned. @@ -1449,15 +1427,6 @@ GtkWidget *sj_create_sound_juicer() sj_stock_init(); - 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); - return NULL; - } else { - bacon_message_connection_set_callback (connection, on_message_received, NULL); - } - brasero_media_library_start (); metadata = sj_metadata_getter_new (); @@ -1473,8 +1442,6 @@ GtkWidget *sj_create_sound_juicer() (GCallback)device_changed_cb, NULL); g_signal_connect (sj_settings, "changed::"SJ_SETTINGS_EJECT, (GCallback)eject_changed_cb, NULL); - g_signal_connect (sj_settings, "changed::"SJ_SETTINGS_OPEN, - (GCallback)open_changed_cb, NULL); g_signal_connect (sj_settings, "changed::"SJ_SETTINGS_BASEURI, (GCallback)baseuri_changed_cb, NULL); g_signal_connect (sj_settings, "changed::"SJ_SETTINGS_STRIP, @@ -1611,7 +1578,6 @@ GtkWidget *sj_create_sound_juicer() paranoia_changed_cb (sj_settings, SJ_SETTINGS_PARANOIA, NULL); strip_changed_cb (sj_settings, SJ_SETTINGS_STRIP, NULL); eject_changed_cb (sj_settings, SJ_SETTINGS_EJECT, NULL); - open_changed_cb (sj_settings, SJ_SETTINGS_OPEN, NULL); if (device == NULL && uris == NULL) { /* FIXME: this should set the device gsettings key to a meaningful * value if it's empty (which is the case until the user changes it in diff --git a/plugins/sjcd/sound-juicer.h b/plugins/sjcd/sound-juicer.h index e079987..4657375 100644 --- a/plugins/sjcd/sound-juicer.h +++ b/plugins/sjcd/sound-juicer.h @@ -114,11 +114,6 @@ extern gboolean strip_chars; extern gboolean eject_finished; /** - * If the destination folder should be opened when the rip has finished. - */ -extern gboolean open_finished; - -/** * Toggle, Title and Artist Renderers */ extern GtkCellRenderer *toggle_renderer, *title_renderer, *artist_renderer; ------------------------------------------------------------------------------ Virtualization & Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ _______________________________________________ gtkpod-cvs2 mailing list gtkpod-cvs2@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2