From dcb86432b4506b1a70221ab4d2b321345d3eee01 Mon Sep 17 00:00:00 2001 From: jstebbins Date: Tue, 30 Jun 2009 22:54:18 +0000 Subject: LinGui: several ui improvements - Add separate progress bar for source scan (similar to mac ui) - When working replace start button with stop button on main window. - Add status field that shows number of pending queue items on main window. - add some white space and remove a couple more frames - add subtitle scan pass information to progress bar git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2651 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- gtk/src/callbacks.c | 250 +++++++++++++++++++++++++++++++------------------ gtk/src/callbacks.h | 1 + gtk/src/ghb.ui | 187 ++++++++++++++++++++++++++++-------- gtk/src/hb-backend.c | 2 + gtk/src/queuehandler.c | 15 +++ 5 files changed, 323 insertions(+), 132 deletions(-) diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index 4d02add03..59c29a3f5 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -857,6 +857,20 @@ source_dialog_extra_widgets( extern GValue *ghb_queue_edit_settings; static gchar *last_scan_file = NULL; +static void +show_scan_progress(signal_user_data_t *ud) +{ + GtkProgressBar *progress; + GtkLabel *label; + + progress = GTK_PROGRESS_BAR(GHB_WIDGET(ud->builder, "scan_prog")); + gtk_progress_bar_set_fraction (progress, 0); + gtk_widget_show(GTK_WIDGET(progress)); + + label = GTK_LABEL(GHB_WIDGET(ud->builder, "source_title")); + gtk_label_set_text( label, "Scanning ..." ); +} + void ghb_do_scan( signal_user_data_t *ud, @@ -892,14 +906,13 @@ ghb_do_scan( ghb_settings_set_string(ud->settings, "source", filename); if (update_source_label(ud, filename)) { - GtkProgressBar *progress; - progress = GTK_PROGRESS_BAR(GHB_WIDGET(ud->builder, "progressbar")); gchar *path; + gint preview_count; + + show_scan_progress(ud); path = ghb_settings_get_string( ud->settings, "source"); - gtk_progress_bar_set_fraction (progress, 0); - gtk_progress_bar_set_text (progress, "Scanning ..."); prune_logs(ud); - gint preview_count; + preview_count = ghb_settings_get_int(ud->settings, "preview_count"); ghb_backend_scan(path, titlenum, preview_count); g_free(path); @@ -2017,6 +2030,42 @@ queue_scan(signal_user_data_t *ud, GValue *js) g_free(path); } +static gint +queue_pending_count(GValue *queue) +{ + gint nn, ii, count; + GValue *js; + gint status; + + nn = 0; + count = ghb_array_len(queue); + for (ii = 0; ii < count; ii++) + { + + js = ghb_array_get_nth(queue, ii); + status = ghb_settings_get_int(js, "job_status"); + if (status == GHB_QUEUE_PENDING) + { + nn++; + } + } + return nn; +} + +void +ghb_update_pending(signal_user_data_t *ud) +{ + GtkLabel *label; + gint pending; + gchar *str; + + label = GTK_LABEL(GHB_WIDGET(ud->builder, "pending_status")); + pending = queue_pending_count(ud->queue); + str = g_strdup_printf("%d encode(s) pending in the queue", pending); + gtk_label_set_text(label, str); + g_free(str); +} + GValue* ghb_start_next_job(signal_user_data_t *ud, gboolean find_first) { @@ -2024,8 +2073,12 @@ ghb_start_next_job(signal_user_data_t *ud, gboolean find_first) gint count, ii, jj; GValue *js; gint status; + GtkWidget *prog; g_debug("start_next_job"); + prog = GHB_WIDGET(ud->builder, "progressbar"); + gtk_widget_show(prog); + count = ghb_array_len(ud->queue); if (find_first) { // Start the first pending item in the queue @@ -2040,6 +2093,7 @@ ghb_start_next_job(signal_user_data_t *ud, gboolean find_first) current = ii; ghb_inhibit_gpm(); queue_scan(ud, js); + ghb_update_pending(ud); return js; } } @@ -2064,6 +2118,7 @@ ghb_start_next_job(signal_user_data_t *ud, gboolean find_first) current = jj; ghb_inhibit_gpm(); queue_scan(ud, js); + ghb_update_pending(ud); return js; } } @@ -2080,12 +2135,15 @@ ghb_start_next_job(signal_user_data_t *ud, gboolean find_first) current = ii; ghb_inhibit_gpm(); queue_scan(ud, js); + ghb_update_pending(ud); return js; } } // Nothing found ghb_uninhibit_gpm(); ghb_notify_done(ud); + ghb_update_pending(ud); + gtk_widget_hide(prog); return NULL; } @@ -2119,26 +2177,36 @@ working_status_string(signal_user_data_t *ud, ghb_instance_status_t *status) gint qcount; gint index; GValue *js; + gboolean subtitle_scan = FALSE; - if (status->job_count > 1) - { - task_str = g_strdup_printf("pass %d of %d, ", - status->job_cur, status->job_count); - } - else - { - task_str = g_strdup(""); - } qcount = ghb_array_len(ud->queue); if (qcount > 1) { index = find_queue_job(ud->queue, status->unique_id, &js); job_str = g_strdup_printf("job %d of %d, ", index+1, qcount); + subtitle_scan = ghb_settings_get_boolean(js, "subtitle_scan"); } else { job_str = g_strdup(""); } + if (status->job_count > 1) + { + if (status->job_cur == 1 && subtitle_scan) + { + task_str = g_strdup_printf("pass %d (subtitle scan) of %d, ", + status->job_cur, status->job_count); + } + else + { + task_str = g_strdup_printf("pass %d of %d, ", + status->job_cur, status->job_count); + } + } + else + { + task_str = g_strdup(""); + } if(status->seconds > -1) { status_str= g_strdup_printf( @@ -2167,6 +2235,7 @@ ghb_backend_events(signal_user_data_t *ud) ghb_status_t status; gchar *status_str; GtkProgressBar *progress; + GtkLabel *work_status; gint titleindex; GValue *js; gint index; @@ -2179,6 +2248,7 @@ ghb_backend_events(signal_user_data_t *ud) ghb_track_status(); ghb_get_status(&status); progress = GTK_PROGRESS_BAR(GHB_WIDGET (ud->builder, "progressbar")); + work_status = GTK_LABEL(GHB_WIDGET (ud->builder, "work_status")); if (status.scan.state == GHB_STATE_IDLE && status.queue.state == GHB_STATE_IDLE) { @@ -2194,6 +2264,12 @@ ghb_backend_events(signal_user_data_t *ud) // Then handle the status of the queue if (status.scan.state & GHB_STATE_SCANNING) { + GtkProgressBar *scan_prog; + GtkLabel *label; + + scan_prog = GTK_PROGRESS_BAR(GHB_WIDGET (ud->builder, "scan_prog")); + label = GTK_LABEL(GHB_WIDGET (ud->builder, "source_title")); + if (status.scan.title_cur == 0) { status_str = g_strdup ("Scanning..."); @@ -2203,20 +2279,26 @@ ghb_backend_events(signal_user_data_t *ud) status_str = g_strdup_printf ("Scanning title %d of %d...", status.scan.title_cur, status.scan.title_count ); } - gtk_progress_bar_set_text (progress, status_str); + gtk_label_set_text (label, status_str); g_free(status_str); if (status.scan.title_count > 0) { - gtk_progress_bar_set_fraction (progress, + gtk_progress_bar_set_fraction (scan_prog, (gdouble)status.scan.title_cur / status.scan.title_count); } } else if (status.scan.state & GHB_STATE_SCANDONE) { - status_str = g_strdup_printf ("Scan done"); - gtk_progress_bar_set_text (progress, status_str); - g_free(status_str); - gtk_progress_bar_set_fraction (progress, 1.0); + gchar *source; + GtkProgressBar *scan_prog; + GtkLabel *label; + + source = ghb_settings_get_string(ud->settings, "source"); + update_source_label(ud, source); + + scan_prog = GTK_PROGRESS_BAR(GHB_WIDGET (ud->builder, "scan_prog")); + gtk_progress_bar_set_fraction (scan_prog, 1.0); + gtk_widget_hide(GTK_WIDGET(scan_prog)); ghb_title_info_t tinfo; @@ -2224,13 +2306,11 @@ ghb_backend_events(signal_user_data_t *ud) titleindex = ghb_longest_title(); ghb_ui_update(ud, "title", ghb_int64_value(titleindex)); + label = GTK_LABEL(GHB_WIDGET (ud->builder, "source_title")); // Are there really any titles. if (!ghb_get_title_info(&tinfo, titleindex)) { - GtkProgressBar *progress; - progress = GTK_PROGRESS_BAR(GHB_WIDGET (ud->builder, "progressbar")); - gtk_progress_bar_set_fraction (progress, 0); - gtk_progress_bar_set_text (progress, "No Source"); + gtk_label_set_text(label, "None"); } ghb_clear_scan_state(GHB_STATE_SCANDONE); ghb_queue_buttons_grey(ud, work_started); @@ -2249,11 +2329,17 @@ ghb_backend_events(signal_user_data_t *ud) ghb_queue_edit_settings = NULL; } } - else if (status.queue.state & GHB_STATE_SCANNING) + + if (status.queue.state & GHB_STATE_SCANNING) { - status_str = g_strdup_printf ("Scanning ..."); - gtk_progress_bar_set_text (progress, status_str); - g_free(status_str); + // This needs to be in scanning and working since scanning + // happens fast enough that it can be missed + if (!work_started) + { + work_started = TRUE; + ghb_queue_buttons_grey(ud, TRUE); + } + gtk_label_set_text (work_status, "Scanning ..."); gtk_progress_bar_set_fraction (progress, 0); } else if (status.queue.state & GHB_STATE_SCANDONE) @@ -2261,17 +2347,50 @@ ghb_backend_events(signal_user_data_t *ud) ghb_clear_queue_state(GHB_STATE_SCANDONE); usleep(2000000); submit_job(ud->current_job); + ghb_update_pending(ud); } else if (status.queue.state & GHB_STATE_PAUSED) { - status_str = g_strdup_printf ("Paused"); - gtk_progress_bar_set_text (progress, status_str); - g_free(status_str); + gtk_label_set_text (work_status, "Paused"); } else if (status.queue.state & GHB_STATE_WORKING) { + // This needs to be in scanning and working since scanning + // happens fast enough that it can be missed + if (!work_started) + { + work_started = TRUE; + ghb_queue_buttons_grey(ud, TRUE); + } + index = find_queue_job(ud->queue, status.queue.unique_id, &js); + if (status.queue.unique_id != 0 && index >= 0) + { + gchar working_icon[] = "hb-working0"; + working_icon[10] = '0' + working; + working = (working+1) % 6; + treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "queue_list")); + store = GTK_TREE_STORE(gtk_tree_view_get_model(treeview)); + gchar *path = g_strdup_printf ("%d", index); + if (gtk_tree_model_get_iter_from_string( + GTK_TREE_MODEL(store), &iter, path)) + { + gtk_tree_store_set(store, &iter, 0, working_icon, -1); + } + g_free(path); + } + GtkLabel *label; + gchar *status_str; + status_str = working_status_string(ud, &status.queue); - gtk_progress_bar_set_text (progress, status_str); + label = GTK_LABEL(GHB_WIDGET(ud->builder, "queue_status")); + gtk_label_set_text (label, status_str); +#if !GTK_CHECK_VERSION(2, 16, 0) + GtkStatusIcon *si; + + si = GTK_STATUS_ICON(GHB_OBJECT(ud->builder, "hb_status")); + gtk_status_icon_set_tooltip(si, status_str); +#endif + gtk_label_set_text (work_status, status_str); gtk_progress_bar_set_fraction (progress, status.queue.progress); g_free(status_str); } @@ -2289,7 +2408,7 @@ ghb_backend_events(signal_user_data_t *ud) switch( status.queue.error ) { case GHB_ERROR_NONE: - gtk_progress_bar_set_text( progress, "Rip done!" ); + gtk_label_set_text (work_status, "Rip Done!"); qstatus = GHB_QUEUE_DONE; if (js != NULL) { @@ -2303,7 +2422,7 @@ ghb_backend_events(signal_user_data_t *ud) } break; case GHB_ERROR_CANCELED: - gtk_progress_bar_set_text( progress, "Rip canceled." ); + gtk_label_set_text (work_status, "Rip Canceled."); qstatus = GHB_QUEUE_CANCELED; if (js != NULL) { @@ -2317,7 +2436,7 @@ ghb_backend_events(signal_user_data_t *ud) } break; default: - gtk_progress_bar_set_text( progress, "Rip failed."); + gtk_label_set_text (work_status, "Rip Failed."); qstatus = GHB_QUEUE_CANCELED; if (js != NULL) { @@ -2343,6 +2462,7 @@ ghb_backend_events(signal_user_data_t *ud) { ghb_uninhibit_gpm(); ud->current_job = NULL; + gtk_widget_hide(GTK_WIDGET(progress)); } if (js) ghb_settings_set_int(js, "job_status", qstatus); @@ -2357,57 +2477,9 @@ ghb_backend_events(signal_user_data_t *ud) } else if (status.queue.state & GHB_STATE_MUXING) { - gtk_progress_bar_set_text(progress, "Muxing: this may take awhile..."); - } - if (status.queue.state & GHB_STATE_SCANNING) - { - // This needs to be in scanning and working since scanning - // happens fast enough that it can be missed - if (!work_started) - { - work_started = TRUE; - ghb_queue_buttons_grey(ud, TRUE); - } + gtk_label_set_text (work_status, "Muxing: This may take a while..."); } - if (status.queue.state & GHB_STATE_WORKING) - { - // This needs to be in scanning and working since scanning - // happens fast enough that it can be missed - if (!work_started) - { - work_started = TRUE; - ghb_queue_buttons_grey(ud, TRUE); - } - index = find_queue_job(ud->queue, status.queue.unique_id, &js); - if (status.queue.unique_id != 0 && index >= 0) - { - gchar working_icon[] = "hb-working0"; - working_icon[10] = '0' + working; - working = (working+1) % 6; - treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "queue_list")); - store = GTK_TREE_STORE(gtk_tree_view_get_model(treeview)); - gchar *path = g_strdup_printf ("%d", index); - if (gtk_tree_model_get_iter_from_string( - GTK_TREE_MODEL(store), &iter, path)) - { - gtk_tree_store_set(store, &iter, 0, working_icon, -1); - } - g_free(path); - } - GtkLabel *label; - gchar *status_str; - status_str = working_status_string(ud, &status.queue); - label = GTK_LABEL(GHB_WIDGET(ud->builder, "queue_status")); - gtk_label_set_text (label, status_str); -#if !GTK_CHECK_VERSION(2, 16, 0) - GtkStatusIcon *si; - - si = GTK_STATUS_ICON(GHB_OBJECT(ud->builder, "hb_status")); - gtk_status_icon_set_tooltip(si, status_str); -#endif - g_free(status_str); - } if (status.scan.state & GHB_STATE_WORKING) { GtkProgressBar *live_progress; @@ -3263,10 +3335,7 @@ handle_media_change(const gchar *device, gboolean insert, signal_user_data_t *ud if (ud->current_dvd_device != NULL && strcmp(device, ud->current_dvd_device) == 0) { - GtkProgressBar *progress; - progress = GTK_PROGRESS_BAR(GHB_WIDGET (ud->builder, "progressbar")); - gtk_progress_bar_set_text (progress, "Scanning ..."); - gtk_progress_bar_set_fraction (progress, 0); + show_scan_progress(ud); update_source_label(ud, device); gint preview_count; preview_count = ghb_settings_get_int(ud->settings, "preview_count"); @@ -3366,10 +3435,7 @@ drive_changed_cb(GVolumeMonitor *gvm, GDrive *gd, signal_user_data_t *ud) } if (g_drive_has_media(gd)) { - GtkProgressBar *progress; - progress = GTK_PROGRESS_BAR(GHB_WIDGET (ud->builder, "progressbar")); - gtk_progress_bar_set_text (progress, "Scanning ..."); - gtk_progress_bar_set_fraction (progress, 0); + show_scan_progress(ud); update_source_label(ud, device); gint preview_count; preview_count = ghb_settings_get_int(ud->settings, "preview_count"); diff --git a/gtk/src/callbacks.h b/gtk/src/callbacks.h index ad0bf18a4..6134bef91 100644 --- a/gtk/src/callbacks.h +++ b/gtk/src/callbacks.h @@ -61,6 +61,7 @@ void wm_drive_changed(MSG *msg, signal_user_data_t *ud); gpointer ghb_cache_volnames(signal_user_data_t *ud); void ghb_volname_cache_init(void); void ghb_update_destination_extension(signal_user_data_t *ud); +void ghb_update_pending(signal_user_data_t *ud); #endif // _CALLBACKS_H_ diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui index 6e1e34db1..874e2dd27 100644 --- a/gtk/src/ghb.ui +++ b/gtk/src/ghb.ui @@ -471,6 +471,7 @@ True + False HandBrake 500 400 @@ -523,6 +524,20 @@ False + + + False + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Stop Encoding + Stop + hb-stop + + + + False + + True @@ -608,40 +623,76 @@ True - + True - 0 - GTK_SHADOW_NONE + 6 + 12 + 12 + 6 + 0 + 1 - + True - 12 - 6 - 6 + 6 - + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 6 - + + True + <b>Source:</b> + True + + + False + 0 + + + + + 240 True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 + 0 + None + + + False + 1 + + + + + True + 1 + 0 - - True + + 10 + False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - + - - - - - - + + 2 + + + + False + 0 + + + + + True + 6 + 6 True @@ -823,26 +874,16 @@ - - 1 - + + False + 1 + - - - True - <b>Source</b> - True - - - - False - 0 - @@ -1029,6 +1070,14 @@ False + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + 12 + 12 + True @@ -3316,27 +3365,72 @@ no-dct-decimate=0:cabac=1 + + + False 1 + - - 1 + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 4 + 4 + 12 + 12 + 0.0 + 1.0 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + 0 + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + 0 + + + + + True + 1 + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + False + 1 + + + + 2 - - 20 + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - + 12 + 12 + 6 + + + 10 + False + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + False @@ -3348,12 +3442,20 @@ no-dct-decimate=0:cabac=1 False + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 6 + 6 + False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 0 - out + none @@ -3371,6 +3473,7 @@ no-dct-decimate=0:cabac=1 True GTK_POLICY_AUTOMATIC GTK_POLICY_AUTOMATIC + etched-in 206 @@ -3503,10 +3606,14 @@ no-dct-decimate=0:cabac=1 + + + 1 + 2 diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index 1edabda50..526a9cf8d 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -4187,6 +4187,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex) gint subtitle; gboolean force, burned, def, one_burned = FALSE; + ghb_settings_set_boolean(js, "subtitle_scan", FALSE); subtitle_list = ghb_settings_get_value(js, "subtitle_list"); count = ghb_array_len(subtitle_list); for (ii = 0; ii < count; ii++) @@ -4251,6 +4252,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex) job->select_subtitle_config.force = force; job->select_subtitle_config.default_track = def; job->indepth_scan = 1; + ghb_settings_set_boolean(js, "subtitle_scan", TRUE); } else if (subtitle >= 0) { diff --git a/gtk/src/queuehandler.c b/gtk/src/queuehandler.c index d32cbcf2f..6f6e0cbaa 100644 --- a/gtk/src/queuehandler.c +++ b/gtk/src/queuehandler.c @@ -737,6 +737,7 @@ queue_add(signal_user_data_t *ud) ghb_array_append(ud->queue, settings); add_to_queue_list(ud, settings, NULL); ghb_save_queue(ud->queue); + ghb_update_pending(ud); return TRUE; } @@ -801,6 +802,7 @@ queue_remove_clicked_cb(GtkWidget *widget, gchar *path, signal_user_data_t *ud) { gtk_tree_path_free (treepath); } + ghb_update_pending(ud); } static gint @@ -1029,6 +1031,19 @@ ghb_queue_buttons_grey(signal_user_data_t *ud, gboolean working) widget = GHB_WIDGET (ud->builder, "queue_start1"); gtk_widget_set_sensitive (widget, !working && (title_ok || queue_count)); + if (working) + { + gtk_widget_hide (widget); + widget = GHB_WIDGET (ud->builder, "queue_stop1"); + gtk_widget_show (widget); + } + else + { + widget = GHB_WIDGET (ud->builder, "queue_stop1"); + gtk_widget_hide (widget); + widget = GHB_WIDGET (ud->builder, "queue_start1"); + gtk_widget_show (widget); + } widget = GHB_WIDGET (ud->builder, "queue_start2"); gtk_widget_set_sensitive (widget, !working && (title_ok || queue_count)); action = GHB_ACTION (ud->builder, "queue_start_menu"); -- cgit v1.2.3