OSDN Git Service

LinGui: update decomb filter string validation.
[handbrake-jp/handbrake-jp-git.git] / gtk / src / callbacks.c
index 59c29a3..54a5d0c 100644 (file)
@@ -1886,6 +1886,22 @@ ghb_message_dialog(GtkMessageType type, const gchar *message, const gchar *no, c
        return TRUE;
 }
 
+void
+ghb_error_dialog(GtkMessageType type, const gchar *message, const gchar *cancel)
+{
+       GtkWidget *dialog;
+       GtkResponseType response;
+                       
+       // Toss up a warning dialog
+       dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
+                                                       type, GTK_BUTTONS_NONE,
+                                                       "%s", message);
+       gtk_dialog_add_buttons( GTK_DIALOG(dialog), 
+                                                  cancel, GTK_RESPONSE_CANCEL, NULL);
+       response = gtk_dialog_run(GTK_DIALOG(dialog));
+       gtk_widget_destroy (dialog);
+}
+
 gboolean
 ghb_cancel_encode(const gchar *extra_msg)
 {
@@ -2180,11 +2196,14 @@ working_status_string(signal_user_data_t *ud, ghb_instance_status_t *status)
        gboolean subtitle_scan = FALSE;
 
        qcount = ghb_array_len(ud->queue);
+       index = find_queue_job(ud->queue, status->unique_id, &js);
+       if (js != NULL)
+       {
+               subtitle_scan = ghb_settings_get_boolean(js, "subtitle_scan");
+       }
        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
        {
@@ -2242,11 +2261,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 +2339,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 +2359,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 +2375,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 +2415,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));
@@ -3301,10 +3316,14 @@ ghb_is_cd(GDrive *gd)
        LibHalDriveType dtype;
 
        device = g_drive_get_identifier(gd, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
+       if (device == NULL)
+               return FALSE;
        halDrive = libhal_drive_from_device_file (hal_ctx, device);
+       g_free(device);
+       if (halDrive == NULL)
+               return FALSE;
        dtype = libhal_drive_get_type(halDrive);
        libhal_drive_free(halDrive);
-       g_free(device);
        return (dtype == LIBHAL_DRIVE_TYPE_CDROM);
 #else
        return FALSE;