summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2014-05-15 09:19:19 +0000
committerjstebbins <[email protected]>2014-05-15 09:19:19 +0000
commitcc9dfa7781fafba8b9e24ce943946d6784597c74 (patch)
treebc1295aa7dfd5e950f7ba7d996b5808d8717eb0d
parent95d5a9b0988d64f8a8e061a8fbb4e02b0375b8c3 (diff)
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
-rw-r--r--gtk/src/callbacks.c59
-rw-r--r--gtk/src/ghb.ui8
-rw-r--r--gtk/src/hb-backend.c18
-rw-r--r--gtk/src/internal_defaults.xml4
-rw-r--r--gtk/src/settings.c6
5 files changed, 82 insertions, 13 deletions
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.</property>
</child>
<child>
<object class="GtkSpinButton" id="start_point">
+ <property name="width-chars">10</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@@ -1198,7 +1199,10 @@ This is often the feature title of a DVD.</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
<property name="adjustment">adjustment1</property>
+ <property name="numeric">True</property>
<signal name="value-changed" handler="start_point_changed_cb" swapped="no"/>
+ <signal name="output" handler="ptop_output_cb" swapped="no"/>
+ <signal name="input" handler="ptop_input_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
@@ -1220,6 +1224,7 @@ This is often the feature title of a DVD.</property>
</child>
<child>
<object class="GtkSpinButton" id="end_point">
+ <property name="width-chars">10</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@@ -1227,7 +1232,10 @@ This is often the feature title of a DVD.</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
<property name="adjustment">adjustment2</property>
+ <property name="numeric">True</property>
<signal name="value-changed" handler="end_point_changed_cb" swapped="no"/>
+ <signal name="output" handler="ptop_output_cb" swapped="no"/>
+ <signal name="input" handler="ptop_input_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
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 @@
<key>dest_file</key>
<string>new_video.mp4</string>
<key>end_point</key>
- <integer>100</integer>
+ <real>100</real>
<key>MetaName</key>
<string></string>
<key>MetaArtist</key>
@@ -88,7 +88,7 @@
<key>single_title</key>
<integer>1</integer>
<key>start_point</key>
- <integer>1</integer>
+ <real>1</real>
<key>start_frame</key>
<integer>-1</integer>
<key>title_no</key>
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)
{