diff options
author | jstebbins <[email protected]> | 2014-05-15 10:45:36 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2014-05-15 10:45:36 +0000 |
commit | 9ac66c0b787847fae383671ec1533e099cde7999 (patch) | |
tree | bde2e804191934ce9c0f2f2550d00ae06c386970 /gtk/src | |
parent | cc9dfa7781fafba8b9e24ce943946d6784597c74 (diff) |
LinGui: add "Reload" and "Reload All" toolbar buttons to queue window
This allow reseting queue entries to the pending status so that they
make be re-encoded.
I'm not sure when a user might use these, but I have had many occasions where
I wish I had this capability during debugging and testing.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6192 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk/src')
-rw-r--r-- | gtk/src/callbacks.c | 3 | ||||
-rw-r--r-- | gtk/src/ghb.ui | 36 | ||||
-rw-r--r-- | gtk/src/queuehandler.c | 105 | ||||
-rw-r--r-- | gtk/src/settings.h | 1 |
4 files changed, 144 insertions, 1 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index 6a90f4903..46200f0a2 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -3281,9 +3281,10 @@ ghb_backend_events(signal_user_data_t *ud) qstatus = GHB_QUEUE_CANCELED; status_icon = "hb-stop"; break; + case GHB_ERROR_FAIL: default: gtk_label_set_text (work_status, _("Encode Failed.")); - qstatus = GHB_QUEUE_CANCELED; + qstatus = GHB_QUEUE_FAIL; status_icon = "hb-stop"; } if (js != NULL) diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui index 1f3d26118..e1a9fc3d2 100644 --- a/gtk/src/ghb.ui +++ b/gtk/src/ghb.ui @@ -7457,6 +7457,42 @@ Setting this to 0 means there is no maximum height.</property> <property name="homogeneous">True</property> </packing> </child> + <child> + <object class="GtkToolButton" id="queue_reload"> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">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="is_important">True</property> + <property name="label" translatable="yes">Reload</property> + <property name="icon_name">view-refresh</property> + <property name="tooltip_text" translatable="yes">Mark selected queue entry as pending. +Resets the queue job to pending and ready to run again.</property> + <signal name="clicked" handler="queue_reload_clicked_cb" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + <child> + <object class="GtkToolButton" id="queue_reload_all"> + <property name="visible">True</property> + <property name="sensitive">True</property> + <property name="can_focus">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="is_important">True</property> + <property name="label" translatable="yes">Reload All</property> + <property name="icon_name">view-refresh</property> + <property name="tooltip_text" translatable="yes">Mark all queue entries as pending. +Resets all queue jobs to pending and ready to run again.</property> + <signal name="clicked" handler="queue_reload_all_clicked_cb" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> </object> <packing> <property name="expand">False</property> diff --git a/gtk/src/queuehandler.c b/gtk/src/queuehandler.c index 76ae59c07..60b783294 100644 --- a/gtk/src/queuehandler.c +++ b/gtk/src/queuehandler.c @@ -39,6 +39,8 @@ queue_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_t { GtkWidget *widget = GHB_WIDGET (ud->builder, "queue_edit"); gtk_widget_set_sensitive (widget, TRUE); + widget = GHB_WIDGET (ud->builder, "queue_reload"); + gtk_widget_set_sensitive (widget, TRUE); if (gtk_tree_model_iter_parent (store, &piter, &iter)) { GtkTreePath *path; @@ -56,6 +58,8 @@ queue_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_t { GtkWidget *widget = GHB_WIDGET (ud->builder, "queue_edit"); gtk_widget_set_sensitive (widget, FALSE); + widget = GHB_WIDGET (ud->builder, "queue_reload"); + gtk_widget_set_sensitive (widget, FALSE); } } @@ -141,6 +145,7 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) case GHB_QUEUE_PENDING: status_icon = "hb-source"; break; + case GHB_QUEUE_FAIL: case GHB_QUEUE_CANCELED: status_icon = "hb-stop"; break; @@ -653,6 +658,106 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) g_string_free(str, TRUE); } +void +ghb_update_status(signal_user_data_t *ud, int status, int index) +{ + const char *status_icon; + switch (status) + { + case GHB_QUEUE_PENDING: + status_icon = "hb-source"; + break; + case GHB_QUEUE_FAIL: + case GHB_QUEUE_CANCELED: + status_icon = "hb-stop"; + break; + case GHB_QUEUE_DONE: + status_icon = "hb-complete"; + break; + default: + status_icon = "hb-source"; + break; + } + int count = ghb_array_len(ud->queue); + if (index < 0 || index >= count) + { + // invalid index + return; + } + + GValue *settings; + settings = ghb_array_get_nth(ud->queue, index); + if (settings == NULL) // should never happen + return; + + if (ghb_settings_get_int(settings, "job_status") == GHB_QUEUE_RUNNING) + return; // Never change the status of currently running jobs + + GtkTreeView *treeview; + GtkTreeModel *store; + GtkTreeIter iter; + + treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "queue_list")); + store = gtk_tree_view_get_model(treeview); + gchar *path = g_strdup_printf ("%d", index); + if (gtk_tree_model_get_iter_from_string(store, &iter, path)) + { + gtk_tree_store_set(GTK_TREE_STORE(store), &iter, 1, status_icon, -1); + } + g_free(path); + + ghb_settings_set_int(settings, "job_status", status); +} + +void +ghb_update_all_status(signal_user_data_t *ud, int status) +{ + int count, ii; + + count = ghb_array_len(ud->queue); + for (ii = 0; ii < count; ii++) + { + ghb_update_status(ud, status, ii); + } +} + +G_MODULE_EXPORT void +queue_reload_all_clicked_cb(GtkWidget *widget, signal_user_data_t *ud) +{ + ghb_update_all_status(ud, GHB_QUEUE_PENDING); +} + +G_MODULE_EXPORT void +queue_reload_clicked_cb(GtkWidget *widget, signal_user_data_t *ud) +{ + GtkTreeView *treeview; + GtkTreeSelection *selection; + GtkTreeModel *store; + GtkTreeIter iter; + gint row; + gint *indices; + + g_debug("queue_key_press_cb ()"); + treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "queue_list")); + store = gtk_tree_view_get_model(treeview); + selection = gtk_tree_view_get_selection (treeview); + if (gtk_tree_selection_get_selected(selection, &store, &iter)) + { + GtkTreePath *treepath; + + treepath = gtk_tree_model_get_path (store, &iter); + // Find the entry in the queue + indices = gtk_tree_path_get_indices (treepath); + row = indices[0]; + // Can only free the treepath After getting what I need from + // indices since this points into treepath somewhere. + gtk_tree_path_free (treepath); + if (row < 0) return; + if (row >= ghb_array_len(ud->queue)) return; + ghb_update_status(ud, GHB_QUEUE_PENDING, row); + } +} + static gboolean validate_settings(signal_user_data_t *ud, GValue *settings, gint batch) { diff --git a/gtk/src/settings.h b/gtk/src/settings.h index 4066ad26f..67f49e5df 100644 --- a/gtk/src/settings.h +++ b/gtk/src/settings.h @@ -81,6 +81,7 @@ enum GHB_QUEUE_PENDING, GHB_QUEUE_RUNNING, GHB_QUEUE_CANCELED, + GHB_QUEUE_FAIL, GHB_QUEUE_DONE, }; |