diff options
author | jstebbins <[email protected]> | 2009-11-25 21:14:44 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2009-11-25 21:14:44 +0000 |
commit | 009238a822971a933d0b7642fd04c15bf8e404a2 (patch) | |
tree | 0979d88ba5116f4ad7e41f55bc7f93a1a82040b9 /gtk | |
parent | 08483929dd5352012eb8b1f1143f138e3d5f19f0 (diff) |
batch file scanning and scan cancel
When a directory is specified as the source, first we attempt to open as a dvd,
then if that fails, we attempt to open each file in the directory as a stream
source. Since opening a large directory of files can take a really long time,
you can also now cancel a scan.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2980 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/src/callbacks.c | 92 | ||||
-rw-r--r-- | gtk/src/ghb.ui | 32 | ||||
-rw-r--r-- | gtk/src/hb-backend.c | 75 | ||||
-rw-r--r-- | gtk/src/hb-backend.h | 6 | ||||
-rw-r--r-- | gtk/src/marshalers.h | 4 | ||||
-rw-r--r-- | gtk/src/presets.c | 2 |
6 files changed, 172 insertions, 39 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index 532ac697c..fb319b297 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -900,7 +900,11 @@ start_scan( return; widget = GHB_WIDGET(ud->builder, "sourcetoolbutton"); - gtk_widget_set_sensitive(widget, FALSE); + gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-stop"); + gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Stop Scan"); + gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Stop Scan"); + //gtk_widget_set_sensitive(widget, FALSE); + action = GHB_ACTION(ud->builder, "source_action"); gtk_action_set_sensitive(action, FALSE); action = GHB_ACTION(ud->builder, "source_single_action"); @@ -936,14 +940,14 @@ ghb_do_scan( if (filename != NULL) { last_scan_file = g_strdup(filename); - ghb_settings_set_string(ud->settings, "source", filename); + ghb_settings_set_string(ud->settings, "scan_source", filename); if (update_source_label(ud, filename, TRUE)) { gchar *path; gint preview_count; show_scan_progress(ud); - path = ghb_settings_get_string( ud->settings, "source"); + path = ghb_settings_get_string( ud->settings, "scan_source"); prune_logs(ud); preview_count = ghb_settings_get_int(ud->settings, "preview_count"); @@ -964,7 +968,7 @@ update_source_name(gpointer data) GtkWidget *dialog; gchar *sourcename; - sourcename = ghb_settings_get_string(ud->settings, "source"); + sourcename = ghb_settings_get_string(ud->settings, "scan_source"); dialog = GHB_WIDGET(ud->builder, "source_dialog"); gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), sourcename); g_free(sourcename); @@ -981,7 +985,7 @@ do_source_dialog(GtkButton *button, gboolean single, signal_user_data_t *ud) gboolean checkbutton_active; g_debug("source_browse_clicked_cb ()"); - sourcename = ghb_settings_get_string(ud->settings, "source"); + sourcename = ghb_settings_get_string(ud->settings, "scan_source"); checkbutton_active = FALSE; if (g_file_test(sourcename, G_FILE_TEST_IS_DIR)) { @@ -1038,7 +1042,16 @@ do_source_dialog(GtkButton *button, gboolean single, signal_user_data_t *ud) G_MODULE_EXPORT void source_button_clicked_cb(GtkButton *button, signal_user_data_t *ud) { - do_source_dialog(button, FALSE, ud); + ghb_status_t status; + ghb_get_status(&status); + if (status.scan.state & GHB_STATE_SCANNING) + { + ghb_backend_scan_stop(); + } + else + { + do_source_dialog(button, FALSE, ud); + } } G_MODULE_EXPORT void @@ -1053,7 +1066,7 @@ dvd_source_activate_cb(GtkAction *action, signal_user_data_t *ud) const gchar *filename; gchar *sourcename; - sourcename = ghb_settings_get_string(ud->settings, "source"); + sourcename = ghb_settings_get_string(ud->settings, "scan_source"); filename = gtk_action_get_name(action); ghb_do_scan(ud, filename, 0, TRUE); if (strcmp(sourcename, filename) != 0) @@ -1309,25 +1322,51 @@ get_rate_string(gint rate_base, gint rate) rate_s = g_strdup_printf("%.6g", rate_f); return rate_s; } + +static void +update_title_duration(signal_user_data_t *ud) +{ + gint ti; + gint hh, mm, ss, start, end; + gchar *text; + GtkWidget *widget; + + ti = ghb_settings_combo_int(ud->settings, "title"); + widget = GHB_WIDGET (ud->builder, "title_duration"); + + start = ghb_settings_get_int(ud->settings, "start_chapter"); + end = ghb_settings_get_int(ud->settings, "end_chapter"); + ghb_part_duration(ti, start, end, &hh, &mm, &ss); + text = g_strdup_printf("%02d:%02d:%02d", hh, mm, ss); + gtk_label_set_text (GTK_LABEL(widget), text); + g_free(text); +} + static void show_title_info(signal_user_data_t *ud, ghb_title_info_t *tinfo) { GtkWidget *widget; gchar *text; - ud->dont_clear_presets = TRUE; - widget = GHB_WIDGET (ud->builder, "title_duration"); - if (tinfo->duration != 0) + ghb_settings_set_string(ud->settings, "source", tinfo->path); + if (tinfo->type == HB_STREAM_TYPE) { - text = g_strdup_printf ("%02d:%02d:%02d", tinfo->hours, - tinfo->minutes, tinfo->seconds); - } - else - { - text = g_strdup_printf ("Unknown"); + GtkWidget *widget = GHB_WIDGET (ud->builder, "source_title"); + if (tinfo->name != NULL && tinfo->name[0] != 0) + { + gtk_label_set_text (GTK_LABEL(widget), tinfo->name); + ghb_settings_set_string(ud->settings, "volume_label", tinfo->name); + set_destination(ud); + } + else + { + gchar *label = "No Title Found"; + gtk_label_set_text (GTK_LABEL(widget), label); + ghb_settings_set_string(ud->settings, "volume_label", label); + } } - gtk_label_set_text (GTK_LABEL(widget), text); - g_free(text); + ud->dont_clear_presets = TRUE; + update_title_duration(ud); widget = GHB_WIDGET (ud->builder, "source_dimensions"); text = g_strdup_printf ("%d x %d", tinfo->width, tinfo->height); gtk_label_set_text (GTK_LABEL(widget), text); @@ -1572,6 +1611,7 @@ start_chapter_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { gtk_widget_show(widget); } + update_title_duration(ud); } G_MODULE_EXPORT void @@ -1602,6 +1642,7 @@ end_chapter_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { gtk_widget_show(widget); } + update_title_duration(ud); } G_MODULE_EXPORT void @@ -2410,13 +2451,16 @@ ghb_backend_events(signal_user_data_t *ud) GtkAction *action; widget = GHB_WIDGET(ud->builder, "sourcetoolbutton"); - gtk_widget_set_sensitive(widget, TRUE); + gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(widget), "hb-source"); + gtk_tool_button_set_label(GTK_TOOL_BUTTON(widget), "Source"); + gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), "Choose Video Source"); + action = GHB_ACTION(ud->builder, "source_action"); gtk_action_set_sensitive(action, TRUE); action = GHB_ACTION(ud->builder, "source_single_action"); gtk_action_set_sensitive(action, TRUE); - source = ghb_settings_get_string(ud->settings, "source"); + source = ghb_settings_get_string(ud->settings, "scan_source"); update_source_label(ud, source, FALSE); scan_prog = GTK_PROGRESS_BAR(GHB_WIDGET (ud->builder, "scan_prog")); @@ -3546,7 +3590,7 @@ handle_media_change(const gchar *device, gboolean insert, signal_user_data_t *ud update_source_label(ud, device, TRUE); gint preview_count; preview_count = ghb_settings_get_int(ud->settings, "preview_count"); - ghb_settings_set_string(ud->settings, "source", device); + ghb_settings_set_string(ud->settings, "scan_source", device); start_scan(ud, device, 0, preview_count); } } @@ -3563,7 +3607,7 @@ handle_media_change(const gchar *device, gboolean insert, signal_user_data_t *ud { ghb_hb_cleanup(TRUE); prune_logs(ud); - ghb_settings_set_string(ud->settings, "source", "/dev/null"); + ghb_settings_set_string(ud->settings, "scan_source", "/dev/null"); start_scan(ud, "/dev/null", 0, 1); } } @@ -3650,7 +3694,7 @@ drive_changed_cb(GVolumeMonitor *gvm, GDrive *gd, signal_user_data_t *ud) update_source_label(ud, device, TRUE); gint preview_count; preview_count = ghb_settings_get_int(ud->settings, "preview_count"); - ghb_settings_set_string(ud->settings, "source", device); + ghb_settings_set_string(ud->settings, "scan_source", device); start_scan(ud, device, 0, preview_count); } } @@ -3658,7 +3702,7 @@ drive_changed_cb(GVolumeMonitor *gvm, GDrive *gd, signal_user_data_t *ud) { ghb_hb_cleanup(TRUE); prune_logs(ud); - ghb_settings_set_string(ud->settings, "source", "/dev/null"); + ghb_settings_set_string(ud->settings, "scan_source", "/dev/null"); start_scan(ud, "/dev/null", 0, 1); } } diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui index e599233ec..f01283308 100644 --- a/gtk/src/ghb.ui +++ b/gtk/src/ghb.ui @@ -671,7 +671,7 @@ <child> <object class="GtkVBox" id="vbox16"> <property name="visible">True</property> - <property name="spacing">6</property> + <property name="spacing">2</property> <child> <object class="GtkHBox" id="hbox54"> <property name="visible">True</property> @@ -726,12 +726,12 @@ </packing> </child> <child> - <object class="GtkAlignment" id="alignment65"> + <object class="GtkAlignment" id="alignment72"> <property name="visible">True</property> + <property name="top_padding">6</property> <property name="left_padding">6</property> - <property name="bottom_padding">6</property> <child> - <object class="GtkHBox" id="hbox5"> + <object class="GtkHBox" id="hbox8"> <property name="visible">True</property> <property name="spacing">4</property> <child> @@ -756,13 +756,30 @@ <property name="position">1</property> </packing> </child> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkAlignment" id="alignment65"> + <property name="visible">True</property> + <property name="left_padding">6</property> + <property name="bottom_padding">6</property> + <child> + <object class="GtkHBox" id="hbox5"> + <property name="visible">True</property> + <property name="spacing">4</property> <child> <object class="GtkAlignment" id="chapter_box"> <property name="visible">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="xalign">0</property> <property name="xscale">0</property> - <property name="left_padding">8</property> + <property name="left_padding">0</property> <child> <object class="GtkHBox" id="hbox4"> <property name="visible">True</property> @@ -918,7 +935,7 @@ </object> <packing> <property name="expand">False</property> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> </object> @@ -6558,6 +6575,7 @@ libx264 authors: <object class="GtkFileChooserDialog" id="source_dialog"> <property name="border_width">5</property> <property name="modal">True</property> + <property name="action">GTK_FILE_CHOOSER_ACTION_OPEN</property> <property name="type_hint">dialog</property> <property name="skip_taskbar_hint">True</property> <property name="skip_pager_hint">True</property> @@ -6610,7 +6628,7 @@ libx264 authors: </child> <child> <object class="GtkCheckButton" id="source_folder_flag"> - <property name="label" translatable="yes">Open VIDEO_TS folder</property> + <property name="label" translatable="yes">Open folder (DVD or batch)</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index 14db5b085..d0609836b 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -1759,14 +1759,32 @@ title_opts_set(GtkBuilder *builder, const gchar *name) for (ii = 0; ii < count; ii++) { title = (hb_title_t*)hb_list_item(list, ii); - if (title->duration != 0) + if (title->type == HB_STREAM_TYPE) { - titles[ii] = g_strdup_printf ("%d - %02dh%02dm%02ds", - title->index, title->hours, title->minutes, title->seconds); + if (title->duration != 0) + { + titles[ii] = g_strdup_printf ("%d - %02dh%02dm%02ds - %s", + title->index, title->hours, title->minutes, title->seconds, + title->name); + } + else + { + titles[ii] = g_strdup_printf ("%d - %s", + title->index, title->name); + } } else { - titles[ii] = g_strdup_printf ("%d - Unknown Length", title->index); + if (title->duration != 0) + { + titles[ii] = g_strdup_printf ("%d - %02dh%02dm%02ds", + title->index, title->hours, title->minutes, title->seconds); + } + else + { + titles[ii] = g_strdup_printf ("%d - Unknown Length", + title->index); + } } gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, @@ -2639,6 +2657,44 @@ ghb_build_x264opts_string(GValue *settings) } void +ghb_part_duration(gint tt, gint sc, gint ec, gint *hh, gint *mm, gint *ss) +{ + hb_list_t * list; + hb_title_t * title; + hb_chapter_t * chapter; + gint count, c; + gint64 duration; + + *hh = *mm = *ss = 0; + if (h_scan == NULL) return; + list = hb_get_titles( h_scan ); + title = (hb_title_t*)hb_list_item( list, tt ); + if (title == NULL) return; + + *hh = title->hours; + *mm = title->minutes; + *ss = title->seconds; + + count = hb_list_count(title->list_chapter); + if (sc > count) sc = count; + if (ec > count) ec = count; + + if (sc == 1 && ec == count) + return; + + duration = 0; + for (c = sc; c <= ec; c++) + { + chapter = hb_list_item(title->list_chapter, c-1); + duration += chapter->duration; + } + + *hh = duration / 90000 / 3600; + *mm = ((duration / 90000) % 3600) / 60; + *ss = (duration / 90000) % 60; +} + +void ghb_get_chapter_duration(gint ti, gint ii, gint *hh, gint *mm, gint *ss) { hb_list_t * list; @@ -2853,6 +2909,11 @@ ghb_backend_close() hb_close(&h_scan); } +void ghb_backend_scan_stop() +{ + hb_scan_stop( h_scan ); +} + void ghb_backend_scan(const gchar *path, gint titleindex, gint preview_count) { @@ -3085,8 +3146,9 @@ ghb_get_title_info(ghb_title_info_t *tinfo, gint titleindex) return FALSE; } - title = hb_list_item( list, titleindex ); + title = hb_list_item( list, titleindex ); if (title == NULL) return FALSE; // Bad titleindex + tinfo->index = titleindex; tinfo->width = title->width; tinfo->height = title->height; memcpy(tinfo->crop, title->crop, 4 * sizeof(int)); @@ -3107,6 +3169,9 @@ ghb_get_title_info(ghb_title_info_t *tinfo, gint titleindex) tinfo->duration = title->duration; tinfo->angle_count = title->angle_count; + tinfo->path = title->path; + tinfo->name = title->name; + tinfo->type = title->type; return TRUE; } diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h index ac5ea70c5..1ccb53eac 100644 --- a/gtk/src/hb-backend.h +++ b/gtk/src/hb-backend.h @@ -62,6 +62,10 @@ typedef struct typedef struct { + gchar *path; + gchar *name; + gint index; + gint type; gint width; gint height; gint crop[4]; @@ -120,12 +124,14 @@ gint ghb_get_queue_state(); void ghb_get_status(ghb_status_t *status); void ghb_track_status(void); void ghb_backend_scan(const gchar *path, gint titleindex, gint preview_count); +void ghb_backend_scan_stop(); void ghb_backend_queue_scan(const gchar *path, gint titleindex); gboolean ghb_get_title_info(ghb_title_info_t *tinfo, gint titleindex); void ghb_par_init(signal_user_data_t *ud); void ghb_set_scale(signal_user_data_t *ud, gint mode); GValue* ghb_get_chapters(gint titleindex); void ghb_get_chapter_duration(gint ti, gint ii, gint *hh, gint *mm, gint *ss); +void ghb_part_duration(gint tt, gint sc, gint ec, gint *hh, gint *mm, gint *ss); gint ghb_get_best_mix(gint titleindex, gint track, gint acodec, gint mix); gboolean ghb_ac3_in_audio_list(const GValue *audio_list); gboolean ghb_audio_is_passthru(gint acodec); diff --git a/gtk/src/marshalers.h b/gtk/src/marshalers.h index 1034f926d..a5ae52491 100644 --- a/gtk/src/marshalers.h +++ b/gtk/src/marshalers.h @@ -6,7 +6,7 @@ G_BEGIN_DECLS -/* VOID:STRING,STRING (marshalers.list:1) */ +/* VOID:STRING,STRING (/home/jstebbins/Source/HandBrake.batch/build.dbg/../gtk/src/marshalers.list:1) */ extern void ghb_marshal_VOID__STRING_STRING (GClosure *closure, GValue *return_value, guint n_param_values, @@ -14,7 +14,7 @@ extern void ghb_marshal_VOID__STRING_STRING (GClosure *closure, gpointer invocation_hint, gpointer marshal_data); -/* BOOLEAN:BOXED (marshalers.list:2) */ +/* BOOLEAN:BOXED (/home/jstebbins/Source/HandBrake.batch/build.dbg/../gtk/src/marshalers.list:2) */ extern void ghb_marshal_BOOLEAN__BOXED (GClosure *closure, GValue *return_value, guint n_param_values, diff --git a/gtk/src/presets.c b/gtk/src/presets.c index bac7bb895..687daba8f 100644 --- a/gtk/src/presets.c +++ b/gtk/src/presets.c @@ -1241,7 +1241,7 @@ ghb_prefs_to_ui(signal_user_data_t *ud) ghb_ui_update(ud, "hbfd", ghb_int64_value(0)); } gval = ghb_settings_get_value(ud->settings, "default_source"); - ghb_settings_set_value (ud->settings, "source", gval); + ghb_settings_set_value (ud->settings, "scan_source", gval); str = ghb_settings_get_string(ud->settings, "destination_dir"); ghb_ui_update(ud, "dest_dir", ghb_string_value(str)); |