diff options
author | jstebbins <[email protected]> | 2009-07-01 16:42:01 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2009-07-01 16:42:01 +0000 |
commit | 3a895bbe29848224b45de3d71b3731495cf702a6 (patch) | |
tree | 749a04971a0d54f06477439c2a2cec1a5001fc29 | |
parent | a6d90a25504ab669fb9d32301841e699e6f6c717 (diff) |
LinGui: modify pause/resume button appearance
when encoding show "Pause" with pause icon
when paused, show "Resume" with play icon
also improve how I'm handling play/stop toolbar button and menu options
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2654 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | gtk/src/callbacks.c | 26 | ||||
-rw-r--r-- | gtk/src/ghb.ui | 37 | ||||
-rw-r--r-- | gtk/src/hb-backend.c | 6 | ||||
-rw-r--r-- | gtk/src/queuehandler.c | 123 | ||||
-rw-r--r-- | gtk/src/queuehandler.h | 2 |
5 files changed, 108 insertions, 86 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index 59c29a3f5..2eddda904 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -2242,11 +2242,18 @@ ghb_backend_events(signal_user_data_t *ud) GtkTreeView *treeview; GtkTreeStore *store; GtkTreeIter iter; - static gint working = 0; - static gboolean work_started = FALSE; + static gint prev_scan_state = 0; + static gint prev_queue_state = 0; ghb_track_status(); ghb_get_status(&status); + if (prev_scan_state != status.scan.state || + prev_queue_state != status.queue.state) + { + ghb_queue_buttons_grey(ud); + prev_scan_state = status.scan.state; + prev_queue_state = status.queue.state; + } 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 && @@ -2313,7 +2320,6 @@ ghb_backend_events(signal_user_data_t *ud) gtk_label_set_text(label, "None"); } ghb_clear_scan_state(GHB_STATE_SCANDONE); - ghb_queue_buttons_grey(ud, work_started); if (ghb_queue_edit_settings) { gint jstatus; @@ -2334,11 +2340,6 @@ ghb_backend_events(signal_user_data_t *ud) { // 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); } @@ -2355,13 +2356,10 @@ ghb_backend_events(signal_user_data_t *ud) } else if (status.queue.state & GHB_STATE_WORKING) { + static gint working = 0; + // 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) { @@ -2398,8 +2396,6 @@ ghb_backend_events(signal_user_data_t *ud) { gint qstatus; - work_started = FALSE; - ghb_queue_buttons_grey(ud, FALSE); index = find_queue_job(ud->queue, status.queue.unique_id, &js); treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "queue_list")); store = GTK_TREE_STORE(gtk_tree_view_get_model(treeview)); diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui index 874e2dd27..420102674 100644 --- a/gtk/src/ghb.ui +++ b/gtk/src/ghb.ui @@ -355,15 +355,6 @@ </object> </child> <child> - <object class="GtkAction" id="queue_stop_menu"> - <property name="sensitive">False</property> - <property name="icon-name">hb-stop</property> - <property name="name">queue_stop_menu</property> - <property name="label" translatable="yes">S_top Queue</property> - <signal handler="queue_stop_clicked_cb" name="activate"/> - </object> - </child> - <child> <object class="GtkAction" id="menuitem3"> <property name="name">menuitem3</property> <property name="label" translatable="yes">_View</property> @@ -447,7 +438,6 @@ <menuitem action="queue_add_menu"/> <menuitem action="queue_start_menu"/> <menuitem action="queue_pause_menu"/> - <menuitem action="queue_stop_menu"/> </menu> <menu action="menuitem3"> <menuitem action="hbfd"/> @@ -525,20 +515,6 @@ </packing> </child> <child> - <object class="GtkToolButton" id="queue_stop1"> - <property name="visible">False</property> - <property name="sensitive">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="tooltip-text" translatable="yes">Stop Encoding</property> - <property name="label" translatable="yes">Stop</property> - <property name="icon_name">hb-stop</property> - <signal handler="queue_stop_clicked_cb" name="clicked"/> - </object> - <packing> - <property name="expand">False</property> - </packing> - </child> - <child> <object class="GtkToolButton" id="queue_pause1"> <property name="visible">True</property> <property name="sensitive">False</property> @@ -4758,19 +4734,6 @@ no-dct-decimate=0:cabac=1</property> </packing> </child> <child> - <object class="GtkToolButton" id="queue_stop"> - <property name="visible">True</property> - <property name="sensitive">False</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="label" translatable="yes">Stop</property> - <property name="icon_name">hb-stop</property> - <signal handler="queue_stop_clicked_cb" name="clicked"/> - </object> - <packing> - <property name="expand">False</property> - </packing> - </child> - <child> <object class="GtkToolButton" id="queue_edit"> <property name="visible">True</property> <property name="sensitive">False</property> diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index eca539e56..c37006fa9 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -4491,11 +4491,13 @@ ghb_pause_queue() if( s.state == HB_STATE_PAUSED ) { - hb_resume( h_queue ); + hb_status.queue.state &= ~GHB_STATE_PAUSED; + hb_resume( h_queue ); } else { - hb_pause( h_queue ); + hb_status.queue.state |= GHB_STATE_PAUSED; + hb_pause( h_queue ); } } diff --git a/gtk/src/queuehandler.c b/gtk/src/queuehandler.c index 6f6e0cbaa..f3640a9e7 100644 --- a/gtk/src/queuehandler.c +++ b/gtk/src/queuehandler.c @@ -1017,47 +1017,108 @@ queue_drag_cb( } void -ghb_queue_buttons_grey(signal_user_data_t *ud, gboolean working) +ghb_queue_buttons_grey(signal_user_data_t *ud) { GtkWidget *widget; GtkAction *action; gint queue_count; gint titleindex; - gboolean title_ok; + gint queue_state, scan_state; + gboolean show_start, show_stop, paused; queue_count = ghb_array_len(ud->queue); titleindex = ghb_settings_combo_int(ud->settings, "title"); - title_ok = (titleindex >= 0); + + queue_state = ghb_get_queue_state(); + scan_state = ghb_get_scan_state(); + + show_stop = queue_state & + (GHB_STATE_WORKING | GHB_STATE_SCANNING | GHB_STATE_MUXING); + show_start = !(scan_state & GHB_STATE_SCANNING) && + (titleindex >= 0 || queue_count > 0); + + + paused = queue_state & GHB_STATE_PAUSED; widget = GHB_WIDGET (ud->builder, "queue_start1"); - gtk_widget_set_sensitive (widget, !working && (title_ok || queue_count)); - if (working) + if (show_stop) { - gtk_widget_hide (widget); - widget = GHB_WIDGET (ud->builder, "queue_stop1"); - gtk_widget_show (widget); + gtk_widget_set_sensitive (widget, TRUE); + gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-stop"); + gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Stop"); } else { - widget = GHB_WIDGET (ud->builder, "queue_stop1"); - gtk_widget_hide (widget); - widget = GHB_WIDGET (ud->builder, "queue_start1"); - gtk_widget_show (widget); + gtk_widget_set_sensitive (widget, show_start); + gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-play"); + gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Start"); } 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"); - gtk_action_set_sensitive (action, !working && (title_ok || queue_count)); + if (show_stop) + { + gtk_widget_set_sensitive (widget, TRUE); + gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-stop"); + gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Stop"); + } + else + { + gtk_widget_set_sensitive (widget, show_start); + gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-play"); + gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Start"); + } widget = GHB_WIDGET (ud->builder, "queue_pause1"); - gtk_widget_set_sensitive (widget, working); + if (paused) + { + gtk_widget_set_sensitive (widget, show_stop); + gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-play"); + gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Resume"); + } + else + { + gtk_widget_set_sensitive (widget, show_stop); + gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-pause"); + gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Pause"); + } widget = GHB_WIDGET (ud->builder, "queue_pause2"); - gtk_widget_set_sensitive (widget, working); + if (paused) + { + gtk_widget_set_sensitive (widget, show_stop); + gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-play"); + gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Resume"); + } + else + { + gtk_widget_set_sensitive (widget, show_stop); + gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-pause"); + gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Pause"); + } + + action = GHB_ACTION (ud->builder, "queue_start_menu"); + if (show_stop) + { + gtk_action_set_sensitive (action, TRUE); + gtk_action_set_icon_name(action, "hb-stop"); + gtk_action_set_label(action, "S_top Queue"); + } + else + { + gtk_action_set_sensitive (action, show_start); + gtk_action_set_icon_name(action, "hb-play"); + gtk_action_set_label(action, "_Start Queue"); + } action = GHB_ACTION (ud->builder, "queue_pause_menu"); - gtk_action_set_sensitive (action, working); - widget = GHB_WIDGET (ud->builder, "queue_stop"); - gtk_widget_set_sensitive (widget, working); - action = GHB_ACTION (ud->builder, "queue_stop_menu"); - gtk_action_set_sensitive (action, working); + if (paused) + { + gtk_action_set_sensitive (action, show_start); + gtk_action_set_icon_name(action, "hb-play"); + gtk_action_set_label(action, "_Resume Queue"); + } + else + { + gtk_action_set_sensitive (action, show_stop); + gtk_action_set_icon_name(action, "hb-pause"); + gtk_action_set_label(action, "_Pause Queue"); + } } G_MODULE_EXPORT void @@ -1084,6 +1145,14 @@ queue_start_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) gint status; gint state; + state = ghb_get_queue_state(); + if (state & (GHB_STATE_WORKING | GHB_STATE_SCANNING | GHB_STATE_MUXING)) + { + ud->cancel_encode = TRUE; + ghb_cancel_encode(NULL); + return; + } + count = ghb_array_len(ud->queue); for (ii = 0; ii < count; ii++) { @@ -1103,7 +1172,6 @@ queue_start_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) if (!queue_add(ud)) return; } - state = ghb_get_queue_state(); if (state == GHB_STATE_IDLE) { // Add the first pending queue item and start @@ -1112,13 +1180,6 @@ queue_start_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) } G_MODULE_EXPORT void -queue_stop_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) -{ - ud->cancel_encode = TRUE; - ghb_cancel_encode(NULL); -} - -G_MODULE_EXPORT void queue_pause_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) { ghb_pause_queue(); @@ -1182,7 +1243,7 @@ ghb_reload_queue(signal_user_data_t *ud) ghb_settings_set_int(settings, "job_status", GHB_QUEUE_PENDING); add_to_queue_list(ud, settings, NULL); } - ghb_queue_buttons_grey(ud, FALSE); + ghb_queue_buttons_grey(ud); } else { diff --git a/gtk/src/queuehandler.h b/gtk/src/queuehandler.h index bf1677baf..8ff454af5 100644 --- a/gtk/src/queuehandler.h +++ b/gtk/src/queuehandler.h @@ -28,7 +28,7 @@ #include <gtk/gtk.h> #include "settings.h" -void ghb_queue_buttons_grey(signal_user_data_t *ud, gboolean working); +void ghb_queue_buttons_grey(signal_user_data_t *ud); gboolean ghb_reload_queue(signal_user_data_t *ud); #endif // _QUEUEHANDLER_H_ |