From cc9dfa7781fafba8b9e24ce943946d6784597c74 Mon Sep 17 00:00:00 2001 From: jstebbins Date: Thu, 15 May 2014 09:19:19 +0000 Subject: LinGui: allow hh:mm:ss.ms input for P-to-P "Seconds" git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6191 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- gtk/src/callbacks.c | 59 +++++++++++++++++++++++++++++++++++++++++++ gtk/src/ghb.ui | 8 ++++++ gtk/src/hb-backend.c | 18 +++++++------ gtk/src/internal_defaults.xml | 4 +-- gtk/src/settings.c | 6 ++--- 5 files changed, 82 insertions(+), 13 deletions(-) (limited to 'gtk') diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index 192061c57..6a90f4903 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -1994,6 +1994,8 @@ ptop_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { gint title_id, titleindex; const hb_title_t * title; + gboolean numeric = TRUE; + GtkSpinButton *spin; ghb_widget_to_setting(ud->settings, widget); ghb_check_dependency(ud, widget, NULL); @@ -2004,6 +2006,14 @@ ptop_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud) if (title == NULL) return; + if (ghb_settings_combo_int(ud->settings, "PtoPType") == 1) + numeric = FALSE; + + spin = GTK_SPIN_BUTTON(GHB_WIDGET(ud->builder, "start_point")); + gtk_spin_button_set_numeric(spin, numeric); + spin = GTK_SPIN_BUTTON(GHB_WIDGET(ud->builder, "end_point")); + gtk_spin_button_set_numeric(spin, numeric); + gint duration = title->duration / 90000; if (ghb_settings_combo_int(ud->settings, "PtoPType") == 0) { @@ -2158,6 +2168,55 @@ vcodec_changed_cb(GtkWidget *widget, signal_user_data_t *ud) step, page, digits, inverted); } +G_MODULE_EXPORT gboolean +ptop_input_cb(GtkWidget *widget, gdouble *val, signal_user_data_t *ud) +{ + if (ghb_settings_combo_int(ud->settings, "PtoPType") != 1) + return FALSE; + + const gchar *text; + int result; + double ss = 0; + int hh = 0, mm = 0; + + text = gtk_entry_get_text(GTK_ENTRY(widget)); + result = sscanf(text, "%2d:%2d:%lf", &hh, &mm, &ss); + if (result <= 0) + return FALSE; + if (result == 1) + { + result = sscanf(text, "%lf", val); + return TRUE; + } + *val = hh * 3600 + mm * 60 + ss; + return TRUE; +} + +G_MODULE_EXPORT gboolean +ptop_output_cb(GtkWidget *widget, signal_user_data_t *ud) +{ + if (ghb_settings_combo_int(ud->settings, "PtoPType") != 1) + return FALSE; + + GtkAdjustment *adjustment; + gchar *text; + double value, ss; + int hh, mm; + + adjustment = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(widget)); + value = gtk_adjustment_get_value(adjustment); + hh = value / 3600; + value = value - hh * 3600; + mm = value / 60; + value = value - mm * 60; + ss = value; + text = g_strdup_printf ("%02d:%02d:%05.2f", hh, mm, ss); + gtk_entry_set_text(GTK_ENTRY(widget), text); + g_free (text); + + return TRUE; +} + G_MODULE_EXPORT void start_point_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui index 45bc0266c..1f3d26118 100644 --- a/gtk/src/ghb.ui +++ b/gtk/src/ghb.ui @@ -1191,6 +1191,7 @@ This is often the feature title of a DVD. + 10 True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -1198,7 +1199,10 @@ This is often the feature title of a DVD. False False adjustment1 + True + + False @@ -1220,6 +1224,7 @@ This is often the feature title of a DVD. + 10 True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -1227,7 +1232,10 @@ This is often the feature title of a DVD. False False adjustment2 + True + + False diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index b54c9fc32..5a1c2bcc9 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -4338,15 +4338,15 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, int titleindex) } if (!job->start_at_preview) { - gint start, end; gint num_chapters = hb_list_count(title->list_chapter); - gint duration = title->duration / 90000; + double duration = title->duration / 90000; job->chapter_markers = FALSE; job->chapter_start = 1; job->chapter_end = num_chapters; if (ghb_settings_combo_int(js, "PtoPType") == 0) { + gint start, end; start = ghb_settings_get_int(js, "start_point"); end = ghb_settings_get_int(js, "end_point"); job->chapter_start = MIN( num_chapters, start ); @@ -4355,18 +4355,20 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, int titleindex) } if (ghb_settings_combo_int(js, "PtoPType") == 1) { - start = ghb_settings_get_int(js, "start_point"); - end = ghb_settings_get_int(js, "end_point"); - job->pts_to_start = (int64_t)MIN(duration-1, start) * 90000; - job->pts_to_stop = (int64_t)MAX(start+1, end) * 90000 - - job->pts_to_start; + double start, end; + start = ghb_settings_get_double(js, "start_point"); + end = ghb_settings_get_double(js, "end_point"); + job->pts_to_start = (int64_t)(MIN(duration, start) * 90000); + job->pts_to_stop = (int64_t)(MAX(start, end) * 90000) - + job->pts_to_start; } if (ghb_settings_combo_int(js, "PtoPType") == 2) { + gint start, end; start = ghb_settings_get_int(js, "start_point"); end = ghb_settings_get_int(js, "end_point"); gint64 max_frames; - max_frames = (gint64)duration * title->rate / title->rate_base; + max_frames = (gint64)(duration * title->rate / title->rate_base); job->frame_to_start = (int64_t)MIN(max_frames-1, start-1); job->frame_to_stop = (int64_t)MAX(start, end-1) - job->frame_to_start; diff --git a/gtk/src/internal_defaults.xml b/gtk/src/internal_defaults.xml index c057e00f9..9d76d2b32 100644 --- a/gtk/src/internal_defaults.xml +++ b/gtk/src/internal_defaults.xml @@ -44,7 +44,7 @@ dest_file new_video.mp4 end_point - 100 + 100 MetaName MetaArtist @@ -88,7 +88,7 @@ single_title 1 start_point - 1 + 1 start_frame -1 title_no diff --git a/gtk/src/settings.c b/gtk/src/settings.c index cd2d21eb6..6e965f42e 100644 --- a/gtk/src/settings.c +++ b/gtk/src/settings.c @@ -301,9 +301,9 @@ ghb_widget_value(GtkWidget *widget) } else if (type == GTK_TYPE_SPIN_BUTTON) { - gint ival; - ival = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); - value = ghb_int64_value_new(ival); + double val; + val = gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget)); + value = ghb_double_value_new(val); } else if (type == GTK_TYPE_SCALE) { -- cgit v1.2.3