]> granicus.if.org Git - handbrake/commitdiff
LinGui: modify pause/resume button appearance
authorjstebbins <jstebbins.hb@gmail.com>
Wed, 1 Jul 2009 16:42:01 +0000 (16:42 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Wed, 1 Jul 2009 16:42:01 +0000 (16:42 +0000)
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

gtk/src/callbacks.c
gtk/src/ghb.ui
gtk/src/hb-backend.c
gtk/src/queuehandler.c
gtk/src/queuehandler.h

index 59c29a3f5c808199ac078d0755ea40ca2b259e4c..2eddda904b3ad84ada3561467a70a771b0dcac46 100644 (file)
@@ -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));
index 874e2dd275a7bb79c3ef9216a1f5cd38f995c1d5..4201026741158f9f803ac729ed8607bad850f898 100644 (file)
             <signal handler="queue_pause_clicked_cb" name="activate"/>
           </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>
           <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"/>
                 <property name="expand">False</property>
               </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>
@@ -4757,19 +4733,6 @@ no-dct-decimate=0:cabac=1</property>
                 <property name="expand">False</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>
index eca539e560c46fb635399ace3a5fd046ce13325f..c37006fa985c4e3a34f787500588bb0da9ce98a0 100644 (file)
@@ -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 );
     }
 }
 
index 6f6e0cbaa36d1e8cd020299daac31d3b431f0a9d..f3640a9e79259beccb28a01c00ba84ccec81b6f1 100644 (file)
@@ -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
@@ -1111,13 +1179,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)
 {
@@ -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
                {
index bf1677baf5a7c4949e95c19752399e7813305f89..8ff454af5db7bd9b594025c86bc62ff8c33190aa 100644 (file)
@@ -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_