From: phantomjinx <pha...@us...> - 2011-10-30 20:55:26
|
commit 9b0e21fb9601cb93454bf43ce8572a7ede99f6f1 Author: phantomjinx <p.g...@ph...> Date: Sat Oct 29 00:02:54 2011 +0100 Update the progress bar when saving a database * file_itunesdb.c * increments the progress bar while saving the itdb. Fixes 3411435 - Progress bar on copying files libgtkpod/file_itunesdb.c | 32 +++++++++++++++++++++++++++----- libgtkpod/gtkpod_app_iface.c | 4 ++++ 2 files changed, 31 insertions(+), 5 deletions(-) --- diff --git a/libgtkpod/file_itunesdb.c b/libgtkpod/file_itunesdb.c index 767cf4c..28cc997 100644 --- a/libgtkpod/file_itunesdb.c +++ b/libgtkpod/file_itunesdb.c @@ -1583,6 +1583,7 @@ static gboolean transfer_tracks(iTunesDB *itdb, TransferData *td) { static gboolean gp_write_itdb(iTunesDB *itdb) { gchar *cfgdir; gboolean success = TRUE; + gchar *statusmsg = NULL; ExtraiTunesDBData *eitdb; Playlist *mpl; TransferData *transferdata; @@ -1641,7 +1642,6 @@ static gboolean gp_write_itdb(iTunesDB *itdb) { block_widgets(); transferdata = transfer_data_new(); - gtkpod_statusbar_reset_progress(100); if ((itdb->usertype & GP_ITDB_TYPE_IPOD) && !get_offline(itdb)) { const gchar *mountpoint = itdb_get_mountpoint(itdb); @@ -1671,11 +1671,15 @@ static gboolean gp_write_itdb(iTunesDB *itdb) { success = delete_files(itdb, transferdata); } - if (success) { - gtkpod_statusbar_message(_("Now writing database '%s'. Please wait..."), mpl->name); + while (widgets_blocked && gtk_events_pending()) + gtk_main_iteration(); - while (widgets_blocked && gtk_events_pending()) - gtk_main_iteration(); + statusmsg = g_strdup_printf(_("Now writing database '%s'. Please wait..."), mpl->name); + gtkpod_statusbar_reset_progress(100); + + if (success) { + /* Removed deleted files and transferred tracks */ + gtkpod_statusbar_increment_progress_ticks(50, statusmsg); } for (it = itdb->tracks; it != NULL; it = it->next) { @@ -1767,6 +1771,11 @@ static gboolean gp_write_itdb(iTunesDB *itdb) { } } + if (success) { + /* Written database now write extended info */ + gtkpod_statusbar_increment_progress_ticks(30, statusmsg); + } + if (success && get_offline(itdb) && (itdb->usertype & GP_ITDB_TYPE_IPOD)) { /* write to cfgdir */ GError *error = NULL; if (!itdb_write_file(itdb, eitdb->offline_filename, &error)) { /* an error occurred */ @@ -1803,6 +1812,11 @@ static gboolean gp_write_itdb(iTunesDB *itdb) { gp_track_validate_entries((Itdb_Track *) it->data); } + if (success) { + /* Written extended info now write photo db */ + gtkpod_statusbar_increment_progress_ticks(10, statusmsg); + } + /* If the ipod supports photos and the photo_data_changed * flag has been set to true then wrtie the photo database */ @@ -1821,6 +1835,14 @@ static gboolean gp_write_itdb(iTunesDB *itdb) { } } + if (success) { + /* Everything done saving */ + gtkpod_statusbar_increment_progress_ticks(10, statusmsg); + } + + if (statusmsg) + g_free(statusmsg); + /* indicate that files and/or database is saved */ if (success) { data_unchanged(itdb); diff --git a/libgtkpod/gtkpod_app_iface.c b/libgtkpod/gtkpod_app_iface.c index 6c579e1..d0af9fc 100644 --- a/libgtkpod/gtkpod_app_iface.c +++ b/libgtkpod/gtkpod_app_iface.c @@ -179,6 +179,10 @@ void gtkpod_statusbar_reset_progress(gint total) { GTKPOD_APP_GET_INTERFACE (gtkpod_app)->statusbar_reset_progress(gtkpod_app, total); } +/** + * Increments the current progress bar value by the + * given number of ticks. + */ void gtkpod_statusbar_increment_progress_ticks(gint ticks, gchar* text) { g_return_if_fail (GTKPOD_IS_APP(gtkpod_app)); GTKPOD_APP_GET_INTERFACE (gtkpod_app)->statusbar_increment_progress_ticks(gtkpod_app, ticks, text); |