OSDN Git Service

LinGui: clean up hb status handling. mostly just moving things around.
authorjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sun, 3 Aug 2008 19:47:34 +0000 (19:47 +0000)
committerjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sun, 3 Aug 2008 19:47:34 +0000 (19:47 +0000)
git-svn-id: svn://localhost/HandBrake/trunk@1602 b64f7644-9d1e-0410-96f1-a4d463321fa5

gtk/src/callbacks.c
gtk/src/ghb.glade
gtk/src/ghb.ui
gtk/src/hb-backend.c
gtk/src/hb-backend.h
gtk/src/main.c
gtk/src/settings.h
gtk/src/standard_presets
gtk/todo

index 78b393b..752b4de 100644 (file)
@@ -29,7 +29,6 @@
 #include "hb-backend.h"
 #include "ghb-dvd.h"
 
-extern gboolean ghb_autostart;
 static void update_chapter_list(signal_user_data_t *ud);
 static void clear_audio_list(signal_user_data_t *ud);
 static GList* dvd_device_list();
@@ -301,8 +300,9 @@ expand_tilde(const gchar *path)
 void
 on_quit1_activate(GtkMenuItem *quit, signal_user_data_t *ud)
 {
+       gint state = ghb_get_state();
        g_debug("on_quit1_activate ()\n");
-    if (ud->state & GHB_STATE_WORKING)
+    if (state & GHB_STATE_WORKING)
     {
         if (cancel_encode("Closing HandBrake will terminate encoding.\n"))
         {
@@ -600,7 +600,6 @@ do_scan(signal_user_data_t *ud, const gchar *filename)
                        path = ghb_settings_get_string( ud->settings, "source");
                        gtk_progress_bar_set_fraction (progress, 0);
                        gtk_progress_bar_set_text (progress, "Scanning ...");
-                       ud->state |= GHB_STATE_SCANNING;
                        ghb_hb_cleanup(TRUE);
                        ghb_backend_scan (path, 0);
                }
@@ -793,8 +792,9 @@ window_destroy_event_cb(GtkWidget *widget, GdkEvent *event, signal_user_data_t *
 gboolean
 window_delete_event_cb(GtkWidget *widget, GdkEvent *event, signal_user_data_t *ud)
 {
+       gint state = ghb_get_state();
        g_debug("window_delete_event_cb ()\n");
-    if (ud->state & GHB_STATE_WORKING)
+    if (state & GHB_STATE_WORKING)
     {
         if (cancel_encode("Closing HandBrake will terminate encoding.\n"))
         {
@@ -869,7 +869,15 @@ show_title_info(signal_user_data_t *ud, ghb_title_info_t *tinfo)
        gchar *text;
 
        widget = GHB_WIDGET (ud->builder, "title_duration");
-       text = g_strdup_printf ("%02d:%02d:%02d", tinfo->hours, tinfo->minutes, tinfo->seconds);
+       if (tinfo->duration != 0)
+       {
+               text = g_strdup_printf ("%02d:%02d:%02d", tinfo->hours, 
+                               tinfo->minutes, tinfo->seconds);
+       }
+       else
+       {
+               text = g_strdup_printf ("Unknown");
+       }
        gtk_label_set_text (GTK_LABEL(widget), text);
        g_free(text);
        widget = GHB_WIDGET (ud->builder, "source_dimensions");
@@ -2580,39 +2588,13 @@ queue_buttons_grey(signal_user_data_t *ud, gboolean working)
 
 void queue_start_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud);
 
-static gint autostart_timeout = -1;
-
-gboolean
-autostart_timer_cb(gpointer data)
+static void
+ghb_backend_events(signal_user_data_t *ud)
 {
-       GtkWidget *widget;
+       ghb_status_t status;
+       gchar *status_str;
        GtkProgressBar *progress;
-       signal_user_data_t *ud = (signal_user_data_t*)data;
-       
-       if (autostart_timeout < 0) return FALSE;
-       gchar *remaining = g_strdup_printf("Encoding will start in %d second%c",
-                                                                          (autostart_timeout-1) / 40 + 1, autostart_timeout <= 40 ? ' ':'s');
-       progress = GTK_PROGRESS_BAR(GHB_WIDGET (ud->builder, "autostart_countdown"));
-       gtk_progress_bar_set_fraction (progress, (gdouble)autostart_timeout / 800);
-       gtk_progress_bar_set_text(progress, remaining);
-       g_free(remaining);
-       autostart_timeout--;
-       if (autostart_timeout == 0)
-       {
-               widget = GHB_WIDGET(ud->builder, "autostart_dialog");
-               gtk_widget_hide(widget);
-               queue_start_clicked_cb(NULL, ud);
-               return FALSE;
-       }
-       return TRUE;
-}
-
-gboolean
-ghb_timer_cb(gpointer data)
-{
-       static gint ticks = 0;
        gint titleindex;
-       gint unique_id;
        job_settings_t *js;
        static gint current_id = -1;
        gint index;
@@ -2621,25 +2603,83 @@ ghb_timer_cb(gpointer data)
        GtkTreeIter iter;
        static gint working = 0;
        static gboolean work_started = FALSE;
+       
+       ghb_track_status();
+       ghb_get_status(&status);
+       progress = GTK_PROGRESS_BAR(GHB_WIDGET (ud->builder, "progressbar"));
+       if (status.state & GHB_STATE_SCANNING)
+       {
+               status_str = g_strdup_printf ("Scanning title %d of %d...", 
+                                                                 status.title_cur, status.title_count );
+               gtk_progress_bar_set_text (progress, status_str);
+               g_free(status_str);
+               if (status.title_count > 0)
+               {
+                       gtk_progress_bar_set_fraction (progress, 
+                               (gdouble)status.title_cur / status.title_count);
+               }
+       }
+       else if (status.state & GHB_STATE_SCANDONE)
+       {
+               status_str = g_strdup_printf ("Scan done"); 
+               gtk_progress_bar_set_text (progress, status_str);
+               g_free(status_str);
+               gtk_progress_bar_set_fraction (progress, 1.0);
 
-       signal_user_data_t *ud = (signal_user_data_t*)data;
-       switch (ghb_backend_events (ud, &unique_id))
+               ghb_title_info_t tinfo;
+                       
+               ghb_update_ui_combo_box(ud->builder, "title", 0, FALSE);
+               titleindex = ghb_longest_title();
+               ghb_ui_update_int(ud, "title", titleindex);
+
+               // Are there really any titles.
+               if (!ghb_get_title_info(&tinfo, titleindex))
+               {
+                       GtkProgressBar *progress;
+                       progress = GTK_PROGRESS_BAR(GHB_WIDGET (ud->builder, "progressbar"));
+                       gtk_progress_bar_set_fraction (progress, 0);
+                       gtk_progress_bar_set_text (progress, "No Source");
+               }
+               ghb_clear_state(GHB_STATE_SCANDONE);
+               queue_buttons_grey(ud, (0 != (status.state & GHB_STATE_WORKING)));
+       }
+       else if (status.state & GHB_STATE_WORKING)
        {
-        case GHB_EVENT_WORKING:
-        {
-                       if (!work_started)
-                       {
-                               work_started = TRUE;
-                               queue_buttons_grey(ud, TRUE);
-                       }
-                       if (unique_id != current_id)
-                       {
-                               index = find_queue_item(ud->queue, current_id, &js);
+               if(status.seconds > -1)
+               {
+                       status_str= g_strdup_printf(
+                               "Encoding: task %d of %d, %.2f %%"
+                               " (%.2f fps, avg %.2f fps, ETA %02dh%02dm%02ds)",
+                               status.job_cur, status.job_count, 
+                               100.0 * status.progress,
+                               status.rate_cur, status.rate_avg, status.hours, 
+                               status.minutes, status.seconds );
+               }
+               else
+               {
+                       status_str= g_strdup_printf(
+                               "Encoding: task %d of %d, %.2f %%",
+                               status.job_cur, status.job_count, 
+                               100.0 * status.progress );
+               }
+               gtk_progress_bar_set_text (progress, status_str);
+               gtk_progress_bar_set_fraction (progress, status.progress);
+               g_free(status_str);
+       }
+       else if (status.state & GHB_STATE_WORKDONE)
+       {
+               work_started = FALSE;
+               queue_buttons_grey(ud, FALSE);
+               index = find_queue_item(ud->queue, current_id, &js);
+               treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "queue_list"));
+               store = GTK_TREE_STORE(gtk_tree_view_get_model(treeview));
+               switch( status.error )
+               {
+                       case GHB_ERROR_NONE:
+                               gtk_progress_bar_set_text( progress, "Rip done!" );
                                if (js != NULL)
                                {
                                        js->status = GHB_QUEUE_DONE;
-                                       treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "queue_list"));
-                                       store = GTK_TREE_STORE(gtk_tree_view_get_model(treeview));
                                        gchar *path = g_strdup_printf ("%d", index);
                                        if (gtk_tree_model_get_iter_from_string ( GTK_TREE_MODEL(store), &iter, path))
                                        {
@@ -2647,38 +2687,56 @@ ghb_timer_cb(gpointer data)
                                        }
                                        g_free(path);
                                }
-
-                               index = find_queue_item(ud->queue, unique_id, &js);
+                               break;
+                       case GHB_ERROR_CANCELED:
+                               gtk_progress_bar_set_text( progress, "Rip canceled." );
                                if (js != NULL)
                                {
-                                       js->status = GHB_QUEUE_RUNNING;
-                                       current_id = unique_id;
+                                       js->status = GHB_QUEUE_CANCELED;
+                                       gchar *path = g_strdup_printf ("%d", index);
+                                       if (gtk_tree_model_get_iter_from_string ( GTK_TREE_MODEL(store), &iter, path))
+                                       {
+                                               gtk_tree_store_set(store, &iter, 0, "hb-canceled", -1);
+                                       }
+                                       g_free(path);
                                }
-                       }
-                       index = find_queue_item(ud->queue, unique_id, &js);
-                       if (index >= 0)
-                       {
-                               gchar working_icon[] = "hb-working0";
-                               working_icon[10] = '0' + working;
-                               working = (working+1) % 6;
-                               treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "queue_list"));
-                               store = GTK_TREE_STORE(gtk_tree_view_get_model(treeview));
-                               gchar *path = g_strdup_printf ("%d", index);
-                               if (gtk_tree_model_get_iter_from_string ( GTK_TREE_MODEL(store), &iter, path))
+                               break;
+                       default:
+                               gtk_progress_bar_set_text( progress, "Rip failed.");
+                               if (js != NULL)
                                {
-                                       gtk_tree_store_set(store, &iter, 0, working_icon, -1);
+                                       js->status = GHB_QUEUE_CANCELED;
+                                       gchar *path = g_strdup_printf ("%d", index);
+                                       if (gtk_tree_model_get_iter_from_string ( GTK_TREE_MODEL(store), &iter, path))
+                                       {
+                                               gtk_tree_store_set(store, &iter, 0, "hb-canceled", -1);
+                                       }
+                                       g_free(path);
                                }
-                               g_free(path);
-                       }
-        } break;
-        case GHB_EVENT_PAUSED:
-        {
-               } break;
-        case GHB_EVENT_WORK_DONE:
-        {
-                       ud->state &= ~GHB_STATE_WORKING;
-                       work_started = FALSE;
-                       queue_buttons_grey(ud, FALSE);
+               }
+               current_id = -1;
+               gtk_progress_bar_set_fraction (progress, 1.0);
+               ghb_clear_state(GHB_STATE_WORKDONE);
+       }
+       else if (status.state & GHB_STATE_PAUSED)
+       {
+               status_str = g_strdup_printf ("Paused"); 
+               gtk_progress_bar_set_text (progress, status_str);
+               g_free(status_str);
+       }
+       else if (status.state & GHB_STATE_MUXING)
+       {
+               gtk_progress_bar_set_text(progress, "Muxing: this may take awhile...");
+       }
+       if (status.state & GHB_STATE_WORKING)
+       {
+               if (!work_started)
+               {
+                       work_started = TRUE;
+                       queue_buttons_grey(ud, TRUE);
+               }
+               if (status.unique_id != current_id)
+               {
                        index = find_queue_item(ud->queue, current_id, &js);
                        if (js != NULL)
                        {
@@ -2692,97 +2750,38 @@ ghb_timer_cb(gpointer data)
                                }
                                g_free(path);
                        }
-                       current_id = -1;
-                       if (ghb_autostart)
-                       {
-                               ghb_hb_cleanup(FALSE);
-                               gtk_main_quit();
-                       }
-        } break;
-        case GHB_EVENT_WORK_CANCELED:
-        {
-                       work_started = FALSE;
-                       queue_buttons_grey(ud, FALSE);
-                       index = find_queue_item(ud->queue, current_id, &js);
+
+                       index = find_queue_item(ud->queue, status.unique_id, &js);
                        if (js != NULL)
                        {
-                               js->status = GHB_QUEUE_CANCELED;
-                               treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "queue_list"));
-                               store = GTK_TREE_STORE(gtk_tree_view_get_model(treeview));
-                               gchar *path = g_strdup_printf ("%d", index);
-                               if (gtk_tree_model_get_iter_from_string ( GTK_TREE_MODEL(store), &iter, path))
-                               {
-                                       gtk_tree_store_set(store, &iter, 0, "hb-canceled", -1);
-                               }
-                               g_free(path);
-                       }
-                       current_id = -1;
-        } break;
-               case GHB_EVENT_SCAN_DONE:
-               {
-                       ghb_title_info_t tinfo;
-                       
-                       ud->state &= ~GHB_STATE_SCANNING;
-                       ghb_update_ui_combo_box(ud->builder, "title", 0, FALSE);
-                       titleindex = ghb_longest_title();
-                       ghb_ui_update_int(ud, "title", titleindex);
-                       queue_buttons_grey(ud, FALSE);
-
-                       // Are there really any titles.
-                       if (ghb_get_title_info(&tinfo, titleindex))
-                       {
-                               if (ghb_autostart)
-                               {
-                                       GtkWidget *widget;
-                                       
-                                       gint title = ghb_settings_get_int(ud->settings, "title");
-                                       gint start_chapter = ghb_settings_get_int(ud->settings, "start_chapter");
-                                       gint end_chapter = ghb_settings_get_int(ud->settings, "end_chapter");
-                                       gboolean pass2 = ghb_settings_get_bool(ud->settings, "two_pass");
-                                       const gchar *vol_name = ghb_settings_get_string(ud->settings, "volume_label");
-                                       if (vol_name == NULL)
-                                               vol_name = "No Title";
-                                       const gchar *vcodec = ghb_settings_get_option(ud->settings, "video_codec");
-                                       const gchar *container = ghb_settings_get_option(ud->settings, "container");
-                                       const gchar *acodec = ghb_settings_get_option(ud->settings, "audio_codec");
-                                       const gchar *dest = ghb_settings_get_string(ud->settings, "destination");
-                                       const gchar *preset = ghb_settings_get_string(ud->settings, "preset");
-                                       gchar *info = g_strdup_printf 
-                                               (
-                                                "<big><b>%s</b></big> (Title %d, Chapters %d through %d, %d Video %s)"
-                                                "\n<b>Preset:</b> %s"
-                                                "\n<b>Format:</b> %s Container, %s Video + %s Audio"
-                                                "\n<b>Destination:</b> %s",
-                                                vol_name, title+1, start_chapter, end_chapter, 
-                                                pass2 ? 2:1, pass2 ? "Passes":"Pass",
-                                                preset, container, vcodec, acodec, dest);
-
-                                       widget = GHB_WIDGET (ud->builder, "autostart_summary");
-                                       gtk_label_set_markup (GTK_LABEL(widget), info);
-                                       g_free(info);
-                                       widget = GHB_WIDGET(ud->builder, "autostart_dialog");
-                                       gtk_widget_show_now(widget);
-                                       g_timeout_add (25, autostart_timer_cb, (gpointer)ud);
-                                       autostart_timeout = 800;
-                               }
+                               js->status = GHB_QUEUE_RUNNING;
+                               current_id = status.unique_id;
                        }
-                       else
-                       {
-                               GtkProgressBar *progress;
-                               progress = GTK_PROGRESS_BAR(GHB_WIDGET (ud->builder, "progressbar"));
-                               gtk_progress_bar_set_fraction (progress, 0);
-                               gtk_progress_bar_set_text (progress, "No Source");
-                       }
-               } break;
-               default:
+               }
+               index = find_queue_item(ud->queue, status.unique_id, &js);
+               if (index >= 0)
                {
-                       if (work_started)
+                       gchar working_icon[] = "hb-working0";
+                       working_icon[10] = '0' + working;
+                       working = (working+1) % 6;
+                       treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "queue_list"));
+                       store = GTK_TREE_STORE(gtk_tree_view_get_model(treeview));
+                       gchar *path = g_strdup_printf ("%d", index);
+                       if (gtk_tree_model_get_iter_from_string ( GTK_TREE_MODEL(store), &iter, path))
                        {
-                               work_started = FALSE;
-                               queue_buttons_grey(ud, FALSE);
+                               gtk_tree_store_set(store, &iter, 0, working_icon, -1);
                        }
-               } break;
+                       g_free(path);
+               }
        }
+}
+
+gboolean
+ghb_timer_cb(gpointer data)
+{
+       signal_user_data_t *ud = (signal_user_data_t*)data;
+
+       ghb_backend_events(ud);
        if (update_default_destination)
        {
                const gchar *dest = ghb_settings_get_string(ud->settings, "destination");
@@ -2800,43 +2799,9 @@ ghb_timer_cb(gpointer data)
                set_preview_image (ud);
                update_preview = FALSE;
        }
-       if (ticks == 3 && ghb_autostart)
-       {
-               // Make sure this doesn't happen twice
-               const gchar *source = ghb_settings_get_string(ud->settings, "source");
-               if (update_source_label(ud, source))
-               {
-                       GtkProgressBar *progress;
-                       progress = GTK_PROGRESS_BAR(GHB_WIDGET (ud->builder, "progressbar"));
-                       const gchar *path = ghb_settings_get_string( ud->settings, "source");
-                       gtk_progress_bar_set_fraction (progress, 0);
-                       gtk_progress_bar_set_text (progress, "Scanning ...");
-                       ud->state |= GHB_STATE_SCANNING;
-                       ghb_hb_cleanup(TRUE);
-                       ghb_backend_scan (path, 0);
-               }
-       }
-       ticks++;
        return TRUE;
 }
 
-void
-autostart_ok_cb(GtkWidget *widget, signal_user_data_t *ud)
-{
-       widget = GHB_WIDGET(ud->builder, "autostart_dialog");
-       gtk_widget_hide(widget);
-       queue_start_clicked_cb(NULL, ud);
-       autostart_timeout = -1;
-}
-
-void
-autostart_cancel_cb(GtkWidget *widget, signal_user_data_t *ud)
-{
-       widget = GHB_WIDGET(ud->builder, "autostart_dialog");
-       gtk_widget_hide(widget);
-       autostart_timeout = -1;
-}
-
 gboolean
 ghb_log_cb(GIOChannel *source, GIOCondition cond, gpointer data)
 {
@@ -3157,7 +3122,6 @@ queue_start_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
                if (!queue_add(ud))
                        return;
        }
-       ud->state |= GHB_STATE_WORKING;
        ghb_start_queue();
 }
 
@@ -3344,9 +3308,18 @@ void
 drive_changed_cb(GVolumeMonitor *gvm, GDrive *gd, signal_user_data_t *ud)
 {
        gchar *device;
+       gint state = ghb_get_state();
+       static gboolean first_time = TRUE;
 
        if (ud->current_dvd_device == NULL) return;
-       if (ud->state != GHB_STATE_IDLE) return;
+       // A drive change event happens when the program initially starts
+       // and I don't want to automatically scan at that time.
+       if (first_time)
+       {
+               first_time = FALSE;
+               return;
+       }
+       if (state != GHB_STATE_IDLE) return;
        device = g_drive_get_identifier(gd, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
        
        // DVD insertion detected.  Scan it.
@@ -3359,13 +3332,11 @@ drive_changed_cb(GVolumeMonitor *gvm, GDrive *gd, signal_user_data_t *ud)
                        gtk_progress_bar_set_text (progress, "Scanning ...");
                        gtk_progress_bar_set_fraction (progress, 0);
                        update_source_label(ud, device);
-                       ud->state |= GHB_STATE_SCANNING;
                        ghb_hb_cleanup(TRUE);
                        ghb_backend_scan(device, 0);
                }
                else
                {
-                       ud->state |= GHB_STATE_SCANNING;
                        ghb_hb_cleanup(TRUE);
                        ghb_backend_scan("/dev/null", 0);
                }
index f433d7b..d305995 100644 (file)
@@ -4376,119 +4376,4 @@ the other to maintain the video's original aspect ratio.</property>
       </widget>
     </child>
   </widget>
-  <widget class="GtkDialog" id="autostart_dialog">
-    <property name="border_width">5</property>
-    <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
-    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
-    <property name="has_separator">False</property>
-    <child internal-child="vbox">
-      <widget class="GtkVBox" id="dialog-vbox2">
-        <property name="visible">True</property>
-        <property name="spacing">2</property>
-        <child>
-          <widget class="GtkVBox" id="vbox43">
-            <property name="visible">True</property>
-            <child>
-              <widget class="GtkVBox" id="vbox44">
-                <property name="visible">True</property>
-                <child>
-                  <widget class="GtkHBox" id="hbox57">
-                    <property name="visible">True</property>
-                    <child>
-                      <widget class="GtkImage" id="image7">
-                        <property name="visible">True</property>
-                        <property name="stock">gtk-dialog-question</property>
-                        <property name="icon_size">6</property>
-                      </widget>
-                      <packing>
-                        <property name="expand">False</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <widget class="GtkLabel" id="label88">
-                        <property name="visible">True</property>
-                        <property name="label" translatable="yes">Encoding with the settings below will proceed unless canceled.</property>
-                        <property name="wrap">True</property>
-                        <property name="width_chars">35</property>
-                      </widget>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="position">1</property>
-                      </packing>
-                    </child>
-                  </widget>
-                  <packing>
-                    <property name="expand">False</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkLabel" id="autostart_summary">
-                    <property name="visible">True</property>
-                    <property name="xalign">0</property>
-                    <property name="yalign">0</property>
-                    <property name="xpad">32</property>
-                    <property name="ypad">16</property>
-                    <property name="use_markup">True</property>
-                    <property name="wrap_mode">PANGO_WRAP_CHAR</property>
-                  </widget>
-                  <packing>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-              </widget>
-            </child>
-            <child>
-              <widget class="GtkProgressBar" id="autostart_countdown">
-                <property name="visible">True</property>
-                <property name="orientation">GTK_PROGRESS_RIGHT_TO_LEFT</property>
-                <property name="text" translatable="yes"></property>
-              </widget>
-              <packing>
-                <property name="expand">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </widget>
-          <packing>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child internal-child="action_area">
-          <widget class="GtkHButtonBox" id="dialog-action_area2">
-            <property name="visible">True</property>
-            <property name="layout_style">GTK_BUTTONBOX_END</property>
-            <child>
-              <widget class="GtkButton" id="button1">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="label" translatable="yes">gtk-ok</property>
-                <property name="use_stock">True</property>
-                <property name="response_id">0</property>
-                <signal name="clicked" handler="autostart_ok_cb"/>
-              </widget>
-            </child>
-            <child>
-              <widget class="GtkButton" id="button2">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="label" translatable="yes">gtk-cancel</property>
-                <property name="use_stock">True</property>
-                <property name="response_id">0</property>
-                <signal name="clicked" handler="autostart_cancel_cb"/>
-              </widget>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </widget>
-          <packing>
-            <property name="expand">False</property>
-            <property name="pack_type">GTK_PACK_END</property>
-          </packing>
-        </child>
-      </widget>
-    </child>
-  </widget>
 </glade-interface>
index fc540c5..4d7b03f 100644 (file)
@@ -4718,121 +4718,4 @@ libxvidcore authors:
       </object>
     </child>
   </object>
-  <object class="GtkDialog" id="autostart_dialog">
-    <property name="border_width">5</property>
-    <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
-    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
-    <property name="has_separator">False</property>
-    <child internal-child="vbox">
-      <object class="GtkVBox" id="dialog-vbox2">
-        <property name="visible">True</property>
-        <property name="spacing">2</property>
-        <child>
-          <object class="GtkVBox" id="vbox43">
-            <property name="visible">True</property>
-            <child>
-              <object class="GtkVBox" id="vbox44">
-                <property name="visible">True</property>
-                <child>
-                  <object class="GtkHBox" id="hbox57">
-                    <property name="visible">True</property>
-                    <child>
-                      <object class="GtkImage" id="image7">
-                        <property name="visible">True</property>
-                        <property name="stock">gtk-dialog-question</property>
-                        <property name="icon_size">6</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkLabel" id="label88">
-                        <property name="visible">True</property>
-                        <property name="label" translatable="yes">Encoding with the settings below will proceed unless canceled.</property>
-                        <property name="wrap">True</property>
-                        <property name="width_chars">35</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="position">1</property>
-                      </packing>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="autostart_summary">
-                    <property name="visible">True</property>
-                    <property name="xalign">0</property>
-                    <property name="yalign">0</property>
-                    <property name="xpad">32</property>
-                    <property name="ypad">16</property>
-                    <property name="use_markup">True</property>
-                    <property name="wrap_mode">PANGO_WRAP_CHAR</property>
-                  </object>
-                  <packing>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-              </object>
-            </child>
-            <child>
-              <object class="GtkProgressBar" id="autostart_countdown">
-                <property name="visible">True</property>
-                <property name="orientation">GTK_PROGRESS_RIGHT_TO_LEFT</property>
-                <property name="text" translatable="yes"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child internal-child="action_area">
-          <object class="GtkHButtonBox" id="dialog-action_area2">
-            <property name="visible">True</property>
-            <property name="layout_style">GTK_BUTTONBOX_END</property>
-            <child>
-              <object class="GtkButton" id="button1">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="label" translatable="yes">gtk-ok</property>
-                <property name="use_stock">True</property>
-                <signal handler="autostart_ok_cb" name="clicked"/>
-              </object>
-            </child>
-            <child>
-              <object class="GtkButton" id="button2">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="label" translatable="yes">gtk-cancel</property>
-                <property name="use_stock">True</property>
-                <signal handler="autostart_cancel_cb" name="clicked"/>
-              </object>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="pack_type">GTK_PACK_END</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-    <action-widgets>
-      <action-widget response="0">button1</action-widget>
-      <action-widget response="0">button2</action-widget>
-    </action-widgets>
-  </object>
 </interface>
index 4707660..4ed94d0 100644 (file)
@@ -565,35 +565,6 @@ search_rates(hb_rate_t *rates, gint rate, gint count)
        return -1;
 }
 
-#if 0
-const gchar*
-ghb_get_rate_string(gint rate, gint type)
-{
-       gint index;
-       
-       switch (type)
-       {
-               case GHB_FRAMERATE:
-               {
-                       index = search_rates(hb_video_rates, rate, hb_video_rates_count);
-                       if (index >= 0) return hb_video_rates[index].string;
-               } break;
-               case GHB_AUDIO_BITRATE:
-               {
-                       rate /= 1000;
-                       index = search_rates(hb_audio_bitrates, rate, hb_audio_bitrates_count);
-                       if (index >= 0) return hb_audio_bitrates[index].string;
-               } break;
-               case GHB_AUDIO_SAMPLERATE:
-               {
-                       index = search_rates(hb_audio_rates, rate, hb_audio_rates_count);
-                       if (index >= 0) return hb_audio_rates[index].string;
-               } break;
-       }
-       return NULL;
-}
-#endif
-
 static gboolean find_combo_item_by_int(GtkTreeModel *store, gint value, GtkTreeIter *iter);
 
 static GtkListStore*
@@ -1064,8 +1035,15 @@ title_opts_set(GtkBuilder *builder, const gchar *name)
                gchar *option;
                
                title = (hb_title_t*)hb_list_item(list, ii);
-               option  = g_strdup_printf ("%d - %02dh%02dm%02ds",
-                       title->index, title->hours, title->minutes, title->seconds);
+               if (title->duration != 0)
+               {
+                       option  = g_strdup_printf ("%d - %02dh%02dm%02ds",
+                               title->index, title->hours, title->minutes, title->seconds);
+               }
+               else
+               {
+                       option  = g_strdup_printf ("%d - Unknown Length", title->index);
+               }
                gtk_list_store_append(store, &iter);
                gtk_list_store_set(store, &iter, 
                                                   0, option, 
@@ -1123,24 +1101,6 @@ audio_rate_opts_add(GtkBuilder *builder, const gchar *name, gint rate)
        return FALSE;
 }
 
-#if 0
-static gboolean
-audio_rate_opts_remove(GtkBuilder *builder, const gchar *name, gint rate)
-{
-       GtkTreeIter iter;
-       GtkListStore *store;
-       
-       g_debug("audio_rate_opts_remove ()\n");
-       store = get_combo_box_store(builder, name);
-       if (find_combo_item_by_int(GTK_TREE_MODEL(store), rate, &iter))
-       {
-               gtk_list_store_remove (store, &iter);
-               return TRUE;
-       }
-       return FALSE;
-}
-#endif
-
 void
 audio_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex)
 {
@@ -1667,15 +1627,44 @@ ghb_backend_scan(const gchar *path, gint titleindex)
 {
     hb_scan( h, path, titleindex );
        hb_status.state |= GHB_STATE_SCANNING;
+       // initialize count and cur to something that won't cause FPE
+       // when computing progress
+       hb_status.title_count = 1;
+       hb_status.title_cur = 0;
 }
 
-static void 
-track_state()
+gint
+ghb_get_state()
+{
+       return hb_status.state;
+}
+
+void
+ghb_clear_state(gint state)
+{
+       hb_status.state &= ~state;
+}
+
+void
+ghb_set_state(gint state)
+{
+       hb_status.state |= state;
+}
+
+void
+ghb_get_status(ghb_status_t *status)
+{
+       memcpy(status, &hb_status, sizeof(ghb_status_t));
+}
+
+void 
+ghb_track_status()
 {
     hb_state_t s;
        static gint scan_complete_count = 0;
        gint scans;
 
+       if (h == NULL) return;
     hb_get_state( h, &s );
        scans = hb_get_scancount(h);
        if (scans > scan_complete_count)
@@ -1741,6 +1730,15 @@ track_state()
                        hb_status.state &= ~GHB_STATE_MUXING;
                        hb_status.state &= ~GHB_STATE_PAUSED;
                        hb_status.state &= ~GHB_STATE_WORKING;
+                       switch (p.error)
+                       {
+                       case HB_ERROR_NONE:
+                               hb_status.error = GHB_ERROR_NONE;
+                       case HB_ERROR_CANCELED:
+                               hb_status.error = GHB_ERROR_CANCELED;
+                       default:
+                               hb_status.error = GHB_ERROR_FAIL;
+                       }
                        hb_status.error = p.error;
                        // Delete all remaining jobs of this encode.
                        // An encode can be composed of multiple associated jobs.
@@ -1754,90 +1752,6 @@ track_state()
     }
 }
 
-gint
-ghb_backend_events(signal_user_data_t *ud, gint *unique_id)
-{
-       gchar *status;
-       GtkProgressBar *progress;
-       
-       if (h == NULL) return GHB_EVENT_NONE;
-       track_state();
-       progress = GTK_PROGRESS_BAR(GHB_WIDGET (ud->builder, "progressbar"));
-       *unique_id = hb_status.unique_id;
-       if (hb_status.state & GHB_STATE_SCANNING)
-       {
-               status = g_strdup_printf ("Scanning title %d of %d...", 
-                                                                 hb_status.title_cur, hb_status.title_count );
-               gtk_progress_bar_set_text (progress, status);
-               g_free(status);
-               gtk_progress_bar_set_fraction (progress, 
-                       (gdouble)hb_status.title_cur / hb_status.title_count);
-       }
-       else if (hb_status.state & GHB_STATE_SCANDONE)
-       {
-               status = g_strdup_printf ("Scan done"); 
-               gtk_progress_bar_set_text (progress, status);
-               g_free(status);
-               gtk_progress_bar_set_fraction (progress, 1.0);
-               hb_status.state &= ~GHB_STATE_SCANDONE;
-               return GHB_EVENT_SCAN_DONE;
-       }
-       else if (hb_status.state & GHB_STATE_WORKING)
-       {
-               if(hb_status.seconds > -1)
-               {
-                       status= g_strdup_printf(
-                               "Encoding: task %d of %d, %.2f %%"
-                               " (%.2f fps, avg %.2f fps, ETA %02dh%02dm%02ds)",
-                               hb_status.job_cur, hb_status.job_count, 
-                               100.0 * hb_status.progress,
-                               hb_status.rate_cur, hb_status.rate_avg, hb_status.hours, 
-                               hb_status.minutes, hb_status.seconds );
-               }
-               else
-               {
-                       status= g_strdup_printf(
-                               "Encoding: task %d of %d, %.2f %%",
-                               hb_status.job_cur, hb_status.job_count, 
-                               100.0 * hb_status.progress );
-               }
-               gtk_progress_bar_set_text (progress, status);
-               gtk_progress_bar_set_fraction (progress, hb_status.progress);
-               g_free(status);
-               return GHB_EVENT_WORKING;
-       }
-       else if (hb_status.state & GHB_STATE_WORKDONE)
-       {
-               switch( hb_status.error )
-               {
-                       case HB_ERROR_NONE:
-                               gtk_progress_bar_set_text( progress, "Rip done!" );
-                               break;
-                       case HB_ERROR_CANCELED:
-                               gtk_progress_bar_set_text( progress, "Rip canceled." );
-                               return GHB_EVENT_WORK_CANCELED;
-                               break;
-                       default:
-                               gtk_progress_bar_set_text( progress, "Rip failed.");
-               }
-               gtk_progress_bar_set_fraction (progress, 1.0);
-               hb_status.state &= ~GHB_STATE_WORKDONE;
-               return GHB_EVENT_WORK_DONE;
-       }
-       else if (hb_status.state & GHB_STATE_PAUSED)
-       {
-               status = g_strdup_printf ("Paused"); 
-               gtk_progress_bar_set_text (progress, status);
-               g_free(status);
-               return GHB_EVENT_PAUSED;
-       }
-       else if (hb_status.state & GHB_STATE_MUXING)
-       {
-               gtk_progress_bar_set_text(progress, "Muxing: this may take awhile...");
-       }
-       return GHB_EVENT_NONE;
-}
-
 gboolean
 ghb_get_title_info(ghb_title_info_t *tinfo, gint titleindex)
 {
@@ -1871,6 +1785,8 @@ ghb_get_title_info(ghb_title_info_t *tinfo, gint titleindex)
        tinfo->hours = title->hours;
        tinfo->minutes = title->minutes;
        tinfo->seconds = title->seconds;
+       tinfo->duration = title->duration;
+g_message("duration %ld", title->duration);
        return TRUE;
 }
 
index 486c7b2..d5a65af 100644 (file)
 
 enum
 {
-       GHB_EVENT_NONE,
-       GHB_EVENT_SCAN_DONE,
-       GHB_EVENT_WORKING,
-       GHB_EVENT_PAUSED,
-       GHB_EVENT_WORK_DONE,
-       GHB_EVENT_WORK_CANCELED
+       GHB_ERROR_NONE,
+       GHB_ERROR_CANCELED,
+       GHB_ERROR_FAIL,
 };
 
 typedef struct ghb_status_s
 {
        gint state;
+
+       // SCANNING
        gint title_count;
        gint title_cur;
+
+       // WORKING
        gint unique_id;
        gint job_cur;
        gint job_count;
@@ -63,6 +64,7 @@ typedef struct
        gint hours;
        gint minutes;
        gint seconds;
+       gint64 duration;
 } ghb_title_info_t;
 
 typedef struct
@@ -86,7 +88,11 @@ void ghb_start_queue();
 void ghb_stop_queue();
 void ghb_pause_queue();
 
-gint ghb_backend_events(signal_user_data_t *ud, gint *unique_id);
+gint ghb_get_state();
+void ghb_clear_state(gint state);
+void ghb_set_state(gint state);
+void ghb_get_status(ghb_status_t *status);
+void ghb_track_status();
 void ghb_backend_scan(const gchar *path, gint titleindex);
 gboolean ghb_get_title_info(ghb_title_info_t *tinfo, gint titleindex);
 void ghb_set_scale(signal_user_data_t *ud, gint mode);
index d9352a1..0d5ffad 100644 (file)
@@ -429,13 +429,11 @@ typedef struct
        gchar *iconname;
 } icon_map_t;
 
-gboolean ghb_autostart;
 static gchar *dvd_device = NULL;
 static gchar *arg_preset = NULL;
 
 static GOptionEntry entries[] = 
 {
-       { "autostart", 'a', 0, G_OPTION_ARG_NONE, &ghb_autostart, "Automatically scan and start encoding", NULL },
        { "device", 'd', 0, G_OPTION_ARG_FILENAME, &dvd_device, "The device or file to encode", NULL },
        { "preset", 'p', 0, G_OPTION_ARG_STRING, &arg_preset, "The preset values to use for encoding", NULL },
        { NULL }
@@ -500,7 +498,6 @@ main (int argc, char *argv[])
        gtk_icon_theme_append_search_path (theme, "./icons");
        
        ud = g_malloc(sizeof(signal_user_data_t));
-       ud->state = GHB_STATE_START;
        ud->debug = FALSE;
        g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, debug_log_handler, ud);
        ud->settings = ghb_settings_new();
@@ -568,10 +565,6 @@ main (int argc, char *argv[])
                // Source overridden from command line option
                ghb_settings_set_string(ud->settings, "source", dvd_device);
        }
-       if (ghb_autostart)
-       {
-               ghb_hbfd(ud, TRUE);
-       }
        // Start timer for monitoring libhb status, 500ms
        g_timeout_add (500, ghb_timer_cb, (gpointer)ud);
        // Everything should be go-to-go.  Lets rock!
index 0578860..1610078 100644 (file)
@@ -31,7 +31,6 @@ GObject* debug_get_object(GtkBuilder *b, const gchar *n);
 enum
 {
        GHB_STATE_IDLE          = 0x00,
-       GHB_STATE_START         = 0x01,
        GHB_STATE_SCANNING      = 0x02,
        GHB_STATE_SCANDONE      = 0x04,
        GHB_STATE_WORKING       = 0x08,
@@ -42,7 +41,6 @@ enum
 
 typedef struct
 {
-       gint state;
        gchar *current_dvd_device;
        gboolean debug;
        gboolean dont_clear_presets;
index ebd7cce..5bd4107 100755 (executable)
@@ -29,6 +29,7 @@ keep_aspect=enable
 deinterlace=none
 detelecine=enable
 denoise=none
+decomb=disable
 variable_frame_rate=disable
 deblock=disable
 pref_audio_codec1=faac
@@ -68,6 +69,7 @@ keep_aspect=enable
 deinterlace=slower
 detelecine=disable
 denoise=none
+decomb=disable
 variable_frame_rate=disable
 deblock=disable
 pref_audio_codec1=faac
@@ -101,6 +103,7 @@ keep_aspect=enable
 deinterlace=none
 detelecine=disable
 denoise=none
+decomb=disable
 variable_frame_rate=disable
 deblock=disable
 pref_audio_codec1=faac
@@ -144,6 +147,7 @@ keep_aspect=enable
 deinterlace=none
 detelecine=disable
 denoise=none
+decomb=disable
 variable_frame_rate=disable
 deblock=disable
 pref_audio_codec1=ac3
@@ -170,6 +174,7 @@ keep_aspect=enable
 deinterlace=none
 detelecine=disable
 denoise=none
+decomb=disable
 variable_frame_rate=disable
 deblock=disable
 pref_audio_codec1=faac
@@ -210,6 +215,7 @@ keep_aspect=enable
 deinterlace=none
 detelecine=disable
 denoise=none
+decomb=disable
 variable_frame_rate=disable
 deblock=disable
 pref_audio_codec1=faac
@@ -235,6 +241,7 @@ keep_aspect=enable
 deinterlace=none
 detelecine=disable
 denoise=none
+decomb=disable
 variable_frame_rate=disable
 deblock=disable
 pref_audio_codec1=faac
@@ -271,6 +278,7 @@ keep_aspect=enable
 deinterlace=none
 detelecine=disable
 denoise=none
+decomb=disable
 variable_frame_rate=disable
 deblock=disable
 pref_audio_codec1=ac3
@@ -309,6 +317,7 @@ keep_aspect=enable
 deinterlace=none
 detelecine=disable
 denoise=none
+decomb=disable
 variable_frame_rate=disable
 deblock=disable
 pref_audio_codec1=ac3
@@ -348,6 +357,7 @@ keep_aspect=enable
 deinterlace=none
 detelecine=disable
 denoise=none
+decomb=disable
 variable_frame_rate=disable
 deblock=disable
 pref_audio_codec1=ac3
@@ -383,6 +393,7 @@ keep_aspect=enable
 deinterlace=none
 detelecine=disable
 denoise=none
+decomb=disable
 variable_frame_rate=disable
 deblock=disable
 pref_audio_codec1=faac
@@ -418,6 +429,7 @@ keep_aspect=enable
 deinterlace=none
 detelecine=disable
 denoise=none
+decomb=disable
 variable_frame_rate=disable
 deblock=disable
 pref_audio_codec1=faac
@@ -452,6 +464,7 @@ keep_aspect=enable
 deinterlace=none
 detelecine=disable
 denoise=none
+decomb=disable
 variable_frame_rate=disable
 deblock=disable
 pref_audio_codec1=faac
@@ -482,6 +495,7 @@ keep_aspect=enable
 deinterlace=none
 detelecine=disable
 denoise=none
+decomb=disable
 variable_frame_rate=disable
 deblock=disable
 pref_audio_codec1=faac
@@ -509,6 +523,7 @@ keep_aspect=enable
 deinterlace=none
 detelecine=disable
 denoise=none
+decomb=disable
 variable_frame_rate=disable
 deblock=disable
 pref_audio_codec1=faac
@@ -537,6 +552,7 @@ keep_aspect=enable
 deinterlace=none
 detelecine=disable
 denoise=none
+decomb=disable
 variable_frame_rate=disable
 deblock=disable
 pref_audio_codec1=faac
@@ -575,6 +591,7 @@ keep_aspect=enable
 deinterlace=none
 detelecine=disable
 denoise=none
+decomb=disable
 variable_frame_rate=disable
 deblock=disable
 pref_audio_codec1=faac
@@ -615,6 +632,7 @@ keep_aspect=enable
 deinterlace=slower
 detelecine=disable
 denoise=weak
+decomb=disable
 variable_frame_rate=disable
 deblock=disable
 pref_audio_codec1=faac
index 747acb3..5448bdf 100644 (file)
--- a/gtk/todo
+++ b/gtk/todo
@@ -52,10 +52,12 @@ X - clean up hb.XXXXX turds in /tmp.  it seems many linux distros don't clean
     /tmp so this shite piles up.
 X - add detailed help. added link to HandBrake Guide
 X - add preferences dialog to give access to some settings
+X - force m4v when ac3+mp4
+X - prevent optimized mp4s from having ac3
+? - prevent optimized mp4s from having chapters
+X - move vfr to video tab?
+P - submitted patch - job cancel patch
+P - submitted patch - preview corruption padding patch
+preview using vlc?
 add ability to delete builtin presets and restore them
 add ability to drag-n-drop presets to reorder them
-force m4v when x264+ac3+mp4
-preview using vlc?
-move vfr to video tab?
-P - submitted patch - job cancel patch
-P - submitted patch - preview correption padding patch