OSDN Git Service

LinGui: add "Quit HandBrake" option to "When Done" options
authorjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Tue, 12 Oct 2010 22:58:01 +0000 (22:58 +0000)
committerjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Tue, 12 Oct 2010 22:58:01 +0000 (22:58 +0000)
Thanks to mxttie for the patch.

git-svn-id: svn://localhost/HandBrake/trunk@3600 b64f7644-9d1e-0410-96f1-a4d463321fa5

gtk/src/callbacks.c
gtk/src/hb-backend.c

index 2fb880f..a964cf8 100644 (file)
@@ -1974,9 +1974,32 @@ typedef struct
        const gchar *msg;
        const gchar *action;
        gint timeout;
+       signal_user_data_t *ud;
 } countdown_t;
 
 static gboolean
+quit_cb(countdown_t *cd)
+{
+       gchar *str;
+
+       cd->timeout--;
+       if (cd->timeout == 0)
+       {
+               ghb_hb_cleanup(FALSE);
+               prune_logs(cd->ud);
+
+               gtk_widget_destroy (GTK_WIDGET(cd->dlg));
+               gtk_main_quit();
+               return FALSE;
+       }
+       str = g_strdup_printf("%s\n\n%s in %d seconds ...", 
+                                                       cd->msg, cd->action, cd->timeout);
+       gtk_message_dialog_set_markup(cd->dlg, str);
+       g_free(str);
+       return TRUE;
+}
+
+static gboolean
 shutdown_cb(countdown_t *cd)
 {
        gchar *str;
@@ -1984,6 +2007,9 @@ shutdown_cb(countdown_t *cd)
        cd->timeout--;
        if (cd->timeout == 0)
        {
+               ghb_hb_cleanup(FALSE);
+               prune_logs(cd->ud);
+
                ghb_shutdown_gsm();
                gtk_main_quit();
                return FALSE;
@@ -2021,6 +2047,7 @@ ghb_countdown_dialog(
        const gchar *action, 
        const gchar *cancel, 
        GSourceFunc action_func,
+       signal_user_data_t *ud,
        gint timeout)
 {
        GtkWidget *dialog;
@@ -2031,6 +2058,7 @@ ghb_countdown_dialog(
        cd.msg = message;
        cd.action = action;
        cd.timeout = timeout;
+       cd.ud = ud;
 
        // Toss up a warning dialog
        dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
@@ -4852,7 +4880,7 @@ ghb_notify_done(signal_user_data_t *ud)
                        ghb_countdown_dialog(GTK_MESSAGE_WARNING, 
                                "Your encode is complete.",
                                "Shutting down the computer", 
-                               "Cancel", (GSourceFunc)shutdown_cb, 60);
+                               "Cancel", (GSourceFunc)shutdown_cb, ud, 60);
                }
        }
        if (ghb_settings_combo_int(ud->settings, "WhenComplete") == 2)
@@ -4862,7 +4890,14 @@ ghb_notify_done(signal_user_data_t *ud)
                        ghb_countdown_dialog(GTK_MESSAGE_WARNING, 
                                "Your encode is complete.",
                                "Putting computer to sleep", 
-                               "Cancel", (GSourceFunc)suspend_cb, 60);
+                               "Cancel", (GSourceFunc)suspend_cb, ud, 60);
                }
        }
+       if (ghb_settings_combo_int(ud->settings, "WhenComplete") == 4)
+       {
+               ghb_countdown_dialog(GTK_MESSAGE_WARNING, 
+                                                       "Your encode is complete.",
+                                                       "Quiting Handbrake", 
+                                                       "Cancel", (GSourceFunc)quit_cb, ud, 60);
+       }
 }
index 6f44ecf..eb6e233 100644 (file)
@@ -86,6 +86,7 @@ static options_map_t d_when_complete_opts[] =
 {
        {"Do Nothing",            "nothing",  0, "0"},
        {"Show Notification",     "notify",   1, "1"},
+       {"Quit Handbrake",        "quit",     4, "4"},
        {"Put Computer To Sleep", "sleep",    2, "2"},
        {"Shutdown Computer",     "shutdown", 3, "3"},
 };