diff options
author | jstebbins <[email protected]> | 2014-05-15 09:19:19 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2014-05-15 09:19:19 +0000 |
commit | cc9dfa7781fafba8b9e24ce943946d6784597c74 (patch) | |
tree | bc1295aa7dfd5e950f7ba7d996b5808d8717eb0d /gtk/src/callbacks.c | |
parent | 95d5a9b0988d64f8a8e061a8fbb4e02b0375b8c3 (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
Diffstat (limited to 'gtk/src/callbacks.c')
-rw-r--r-- | gtk/src/callbacks.c | 59 |
1 files changed, 59 insertions, 0 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) { |