From cbd96d9ae28fc3f8763ffbeb8ff80ae9905b1902 Mon Sep 17 00:00:00 2001 From: John Stebbins Date: Sat, 23 Dec 2017 12:29:23 -0800 Subject: LinGui: add option to make new preset default in "Save As" --- gtk/src/ghb.m4 | 21 +++++++++++++++++++-- gtk/src/presets.c | 18 +++++++++++++++--- 2 files changed, 34 insertions(+), 5 deletions(-) (limited to 'gtk') diff --git a/gtk/src/ghb.m4 b/gtk/src/ghb.m4 index 0baf542a8..3b1e64816 100644 --- a/gtk/src/ghb.m4 +++ b/gtk/src/ghb.m4 @@ -8863,6 +8863,23 @@ Uncheck this if you want to allow changing each title's settings independently.< 0 + + + Default Preset + True + True + False + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Make this the default Preset when HandBrake starts + start + 12 + True + + + + 1 + + True @@ -8989,7 +9006,7 @@ Setting this to 0 means there is no maximum height. True True - 1 + 2 @@ -9027,7 +9044,7 @@ Setting this to 0 means there is no maximum height. True True 10 - 2 + 3 diff --git a/gtk/src/presets.c b/gtk/src/presets.c index 7d7a3f67d..0f0315c3a 100644 --- a/gtk/src/presets.c +++ b/gtk/src/presets.c @@ -1833,7 +1833,7 @@ ghb_presets_load(signal_user_data_t *ud) static void settings_save(signal_user_data_t *ud, const char * category, - const char *name, const char * desc) + const char *name, const char * desc, gboolean set_def) { GhbValue * preset, * new_preset; gboolean def = FALSE; @@ -1885,6 +1885,14 @@ settings_save(signal_user_data_t *ud, const char * category, } else { + // Check if the new preset is also the new default preset + if (set_def) + { + ghb_dict_set_bool(new_preset, "Default", set_def); + ghb_presets_list_clear_default(ud); + hb_presets_clear_default(); + } + // Adding a new preset // Append to the folder int index = hb_preset_append(folder_path, new_preset); @@ -2167,7 +2175,7 @@ static void preset_save_action(signal_user_data_t *ud, gboolean as) height = ghb_dict_get_int(ud->settings, "PictureHeight"); autoscale = ghb_dict_get_bool(ud->settings, "autoscale"); - + ghb_ui_update(ud, "PresetSetDefault", ghb_boolean_value(FALSE)); ghb_ui_update(ud, "PictureWidthEnable", ghb_boolean_value(!autoscale)); ghb_ui_update(ud, "PictureHeightEnable", ghb_boolean_value(!autoscale)); @@ -2232,6 +2240,8 @@ static void preset_save_action(signal_user_data_t *ud, gboolean as) gtk_widget_set_sensitive(widget, as); widget = GHB_WIDGET(ud->builder, "PresetCategory"); gtk_widget_set_sensitive(widget, as); + widget = GHB_WIDGET(ud->builder, "PresetSetDefault"); + gtk_widget_set_visible(widget, as); response = gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_hide(dialog); @@ -2240,6 +2250,7 @@ static void preset_save_action(signal_user_data_t *ud, gboolean as) GtkTextBuffer * buffer; GtkTextIter start, end; char * desc; + gboolean def; // save the preset name = gtk_entry_get_text(entry); @@ -2257,7 +2268,8 @@ static void preset_save_action(signal_user_data_t *ud, gboolean as) buffer = gtk_text_view_get_buffer(tv); gtk_text_buffer_get_bounds(buffer, &start, &end); desc = gtk_text_buffer_get_text(buffer, &start, &end, FALSE); - settings_save(ud, category, name, desc); + def = ghb_dict_get_bool(ud->settings, "PresetSetDefault"); + settings_save(ud, category, name, desc, def); free(desc); } } -- cgit v1.2.3