summaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2014-05-06 17:03:33 +0000
committerjstebbins <[email protected]>2014-05-06 17:03:33 +0000
commit974cae15854b3b8525caa1a3d3ca4e3b72329460 (patch)
tree9834547204cec1fc2f9b163941f4087509492281 /gtk
parent4279c5bc891880d13c6fc31d07b3277f1a8962df (diff)
LinGui: improved auto destination naming
Allows auto name template like WinGui git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6174 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk')
-rw-r--r--gtk/src/callbacks.c141
-rw-r--r--gtk/src/ghb.ui44
-rw-r--r--gtk/src/internal_defaults.xml8
-rw-r--r--gtk/src/makedeps.py3
4 files changed, 130 insertions, 66 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c
index 4c77c1670..9d28532ee 100644
--- a/gtk/src/callbacks.c
+++ b/gtk/src/callbacks.c
@@ -571,50 +571,100 @@ set_destination_settings(signal_user_data_t *ud, GValue *settings)
extension = get_extension(ud, settings);
g_debug("set_destination_settings");
- if (ghb_settings_get_boolean(ud->prefs, "use_source_name"))
+ if (ghb_settings_get_boolean(ud->prefs, "auto_name"))
{
GString *str = g_string_new("");
- gchar *vol_name;
- gint title;
+ gchar *p;
+ gchar *template;
- vol_name = ghb_settings_get_string(settings, "volume_label");
- g_string_append_printf(str, "%s", vol_name);
- title = ghb_settings_get_int(settings, "title_no");
- if (title >= 0)
+ p = template = ghb_settings_get_string(ud->prefs, "auto_name_template");
+ while (*p)
{
- if (ghb_settings_get_boolean(ud->prefs, "title_no_in_destination"))
+ if (!strncmp(p, "{source}", strlen("{source}")))
{
-
- g_string_append_printf(str, " - %d", title+1);
+ gchar *vol_name;
+ vol_name = ghb_settings_get_string(settings, "volume_label");
+ g_string_append_printf(str, "%s", vol_name);
+ g_free(vol_name);
+ p += strlen("{source}");
}
- if (ghb_settings_combo_int(settings, "PtoPType") == 0 &&
- ghb_settings_get_boolean(ud->prefs, "chapters_in_destination"))
+ else if (!strncmp(p, "{title}", strlen("{title}")))
{
- gint start, end;
-
- if (!ghb_settings_get_boolean(
- ud->prefs, "title_no_in_destination"))
+ gint title = ghb_settings_get_int(settings, "title_no");
+ if (title >= 0)
+ g_string_append_printf(str, "%d", title+1);
+ p += strlen("{title}");
+ }
+ else if (!strncmp(p, "{chapters}", strlen("{chapters}")))
+ {
+ if (ghb_settings_combo_int(settings, "PtoPType") == 0)
{
- g_string_append_printf(str, " -");
+ gint start, end;
+ start = ghb_settings_get_int(settings, "start_point");
+ end = ghb_settings_get_int(settings, "end_point");
+ if (start == end)
+ g_string_append_printf(str, "%d", start);
+ else
+ g_string_append_printf(str, "%d-%d", start, end);
}
- start = ghb_settings_get_int(settings, "start_point");
- end = ghb_settings_get_int(settings, "end_point");
- if (start == end)
- g_string_append_printf(str, " Ch %d", start);
- else
- g_string_append_printf(str, " Ch %d-%d", start, end);
+ p += strlen("{chapters}");
+ }
+ else if (!strncmp(p, "{time}", strlen("{time}")))
+ {
+ char st[6];
+ struct tm *lt;
+ time_t t = time(NULL);
+ lt = localtime(&t);
+ st[0] = 0;
+ strftime(st, 6, "%R", lt);
+ g_string_append_printf(str, "%s", st);
+ p += strlen("{time}");
+ }
+ else if (!strncmp(p, "{date}", strlen("{date}")))
+ {
+ char dt[11];
+ struct tm *lt;
+ time_t t = time(NULL);
+ lt = localtime(&t);
+ dt[0] = 0;
+ strftime(dt, 11, "%F", lt);
+ g_string_append_printf(str, "%s", dt);
+ p += strlen("{date}");
+ }
+ else if (!strncmp(p, "{quality}", strlen("{quality}")))
+ {
+ if (ghb_settings_get_boolean(settings, "vquality_type_constant"))
+ {
+ gint vcodec;
+ const char *vqname;
+ double vquality;
+ vcodec = ghb_settings_video_encoder_codec(settings, "VideoEncoder");
+ vqname = hb_video_quality_get_name(vcodec);
+ vquality = ghb_settings_get_double(settings, "VideoQualitySlider");
+ g_string_append_printf(str, "%s%.3g", vqname, vquality);
+ }
+ p += strlen("{quality}");
+ }
+ else if (!strncmp(p, "{bitrate}", strlen("{bitrate}")))
+ {
+ if (ghb_settings_get_boolean(settings, "vquality_type_bitrate"))
+ {
+ int vbitrate;
+ vbitrate = ghb_settings_get_int(settings, "VideoAvgBitrate");
+ g_string_append_printf(str, "%dkbps", vbitrate);
+ }
+ p += strlen("{bitrate}");
+ }
+ else
+ {
+ g_string_append_printf(str, "%c", *p);
+ p++;
}
}
g_string_append_printf(str, ".%s", extension);
filename = g_string_free(str, FALSE);
ghb_settings_set_string(settings, "dest_file", filename);
- g_free(vol_name);
- g_free(filename);
- }
- else
- {
- filename = g_strdup_printf("new_video.%s", extension);
- ghb_settings_set_string(settings, "dest_file", filename);
+ g_free(template);
g_free(filename);
}
}
@@ -2029,6 +2079,26 @@ chapter_markers_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
}
G_MODULE_EXPORT void
+vquality_type_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+ ghb_widget_to_setting(ud->settings, widget);
+ ghb_check_dependency(ud, widget, NULL);
+ ghb_clear_presets_selection(ud);
+ ghb_live_reset(ud);
+ set_destination(ud);
+}
+
+G_MODULE_EXPORT void
+vbitrate_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+ ghb_widget_to_setting(ud->settings, widget);
+ ghb_check_dependency(ud, widget, NULL);
+ ghb_clear_presets_selection(ud);
+ ghb_live_reset(ud);
+ set_destination(ud);
+}
+
+G_MODULE_EXPORT void
vquality_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
ghb_widget_to_setting(ud->settings, widget);
@@ -2056,6 +2126,7 @@ vquality_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
gdouble val = gtk_range_get_value(GTK_RANGE(widget));
val = ((int)((val + step / 2) / step)) * step;
gtk_range_set_value(GTK_RANGE(widget), val);
+ set_destination(ud);
}
G_MODULE_EXPORT void
@@ -2100,10 +2171,7 @@ start_point_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
if (start > end)
ghb_ui_update(ud, "end_point", ghb_int_value(start));
ghb_check_dependency(ud, widget, NULL);
- if (ghb_settings_get_boolean(ud->prefs, "chapters_in_destination"))
- {
- set_destination(ud);
- }
+ set_destination(ud);
widget = GHB_WIDGET (ud->builder, "ChapterMarkers");
// End may have been changed above, get it again
end = ghb_settings_get_int(ud->settings, "end_point");
@@ -2143,10 +2211,7 @@ end_point_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
if (start > end)
ghb_ui_update(ud, "start_point", ghb_int_value(end));
ghb_check_dependency(ud, widget, NULL);
- if (ghb_settings_get_boolean(ud->prefs, "chapters_in_destination"))
- {
- set_destination(ud);
- }
+ set_destination(ud);
widget = GHB_WIDGET (ud->builder, "ChapterMarkers");
// Start may have been changed above, get it again
start = ghb_settings_get_int(ud->settings, "start_point");
diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui
index f1a0e3327..628afe470 100644
--- a/gtk/src/ghb.ui
+++ b/gtk/src/ghb.ui
@@ -2324,7 +2324,7 @@ These encoders do not have a lossless mode.</property>
<property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
- <signal name="toggled" handler="setting_widget_changed_cb" swapped="no"/>
+ <signal name="toggled" handler="vquality_type_changed_cb" swapped="no"/>
</object>
<packing>
<property name="top_attach">1</property>
@@ -2348,7 +2348,7 @@ to limit instantaneous bitrate, look into x264's vbv-bufsize and vbv-maxrate set
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<property name="group">vquality_type_constant</property>
- <signal name="toggled" handler="setting_widget_changed_cb" swapped="no"/>
+ <signal name="toggled" handler="vquality_type_changed_cb" swapped="no"/>
</object>
<packing>
<property name="top_attach">2</property>
@@ -2370,7 +2370,7 @@ to limit instantaneous bitrate, look into x264's vbv-bufsize and vbv-maxrate set
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
<property name="adjustment">adjustment3</property>
- <signal name="value-changed" handler="setting_widget_changed_cb" swapped="no"/>
+ <signal name="value-changed" handler="vbitrate_changed_cb" swapped="no"/>
</object>
<packing>
<property name="top_attach">2</property>
@@ -5991,7 +5991,7 @@ You can edit these and add additional options.</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkCheckButton" id="use_source_name">
+ <object class="GtkCheckButton" id="auto_name">
<property name="label" translatable="yes">Use automatic naming (uses modified source name)</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -6012,20 +6012,20 @@ You can edit these and add additional options.</property>
<property name="can_focus">False</property>
<property name="left_padding">18</property>
<child>
- <object class="GtkBox" id="vbox29">
- <property name="orientation">vertical</property>
+ <object class="GtkBox" id="autoname_box">
+ <property name="orientation">horizontal</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="spacing">4</property>
+ <property name="margin_right">8</property>
<child>
- <object class="GtkCheckButton" id="chapters_in_destination">
- <property name="label" translatable="yes">Add chapters to destination name</property>
+ <object class="GtkLabel" id="auto_name_template_label">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="xalign">0</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="pref_changed_cb" swapped="no"/>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Auto-Name Template</property>
+ <property name="use_markup">True</property>
+
+ <property name="xalign">1</property>
</object>
<packing>
<property name="expand">False</property>
@@ -6034,15 +6034,17 @@ You can edit these and add additional options.</property>
</packing>
</child>
<child>
- <object class="GtkCheckButton" id="title_no_in_destination">
- <property name="label" translatable="yes">Add title # to destination name</property>
+ <object class="GtkEntry" id="auto_name_template">
+ <property name="tooltip_text" translatable="yes">Available Options: {source} {title} {chapters} {date} {time} {quality} {bitrate}</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="xalign">0</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="pref_changed_cb" swapped="no"/>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="activates_default">True</property>
+ <property name="width_chars">40</property>
+ <property name="truncate_multiline">True</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <signal name="changed" handler="pref_changed_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
diff --git a/gtk/src/internal_defaults.xml b/gtk/src/internal_defaults.xml
index a126b8373..bcf8f9963 100644
--- a/gtk/src/internal_defaults.xml
+++ b/gtk/src/internal_defaults.xml
@@ -149,14 +149,10 @@
<true />
<key>allow_tweaks</key>
<false />
- <key>title_no_in_destination</key>
- <false />
<key>last_update_check</key>
<integer>0</integer>
<key>check_updates</key>
<string>weekly</string>
- <key>chapters_in_destination</key>
- <false />
<key>default_source</key>
<string>/dev/dvd</string>
<key>ExportDirectory</key>
@@ -199,8 +195,10 @@
<true />
<key>UseM4v</key>
<true />
- <key>use_source_name</key>
+ <key>auto_name</key>
<true />
+ <key>auto_name_template</key>
+ <string>{source}</string>
<key>update_skip_version</key>
<integer>0</integer>
<key>VideoQualityGranularity</key>
diff --git a/gtk/src/makedeps.py b/gtk/src/makedeps.py
index 331e0cf77..248b1864f 100644
--- a/gtk/src/makedeps.py
+++ b/gtk/src/makedeps.py
@@ -67,8 +67,7 @@ dep_map = (
DepEntry("x264_trellis", "x264_psy_trell", "0", True, False),
DepEntry("x264UseAdvancedOptions", "x264VideoSettingsTable", "TRUE", True, False),
DepEntry("x264UseAdvancedOptions", "x264_tab", "FALSE", True, False),
- DepEntry("use_source_name", "chapters_in_destination", "TRUE", False, False),
- DepEntry("use_source_name", "title_no_in_destination", "TRUE", False, False),
+ DepEntry("auto_name", "autoname_box", "TRUE", False, False),
)
def main():