From 1db9254b719e35b96dbc2281ef608dd945debeef Mon Sep 17 00:00:00 2001 From: John Stebbins Date: Fri, 22 Dec 2017 10:13:21 -0800 Subject: [PATCH] LinGui: add preset "Save As" option Adds "Save As" menu option and "Save New Preset" button. Preset "Save" menu option behaviour changes to to only allow updating the current preset. --- gtk/src/ghb.m4 | 36 ++++++++++++++++++++++++++++++++++++ gtk/src/main.c | 3 +++ gtk/src/presets.c | 41 ++++++++++++++++++++++++++++++----------- 3 files changed, 69 insertions(+), 11 deletions(-) diff --git a/gtk/src/ghb.m4 b/gtk/src/ghb.m4 index e17e723ee..d6cdd99db 100644 --- a/gtk/src/ghb.m4 +++ b/gtk/src/ghb.m4 @@ -128,6 +128,15 @@ conjunction with the "Forced" option. app.preset-save + + + Save _As + True + False + True + app.preset-save-as + + _Delete @@ -931,6 +940,15 @@ libx264 authors: app.preset-save + + + Save _As + True + False + True + app.preset-save-as + + _Delete @@ -1564,6 +1582,7 @@ This is often the feature title of a DVD. False 10 + <u><i>Modified</i></u> True @@ -1589,6 +1608,23 @@ This is often the feature title of a DVD. 3 + + + Save New Preset + True + True + Reload the encoding settings for the currently selected preset. + Modifications will be discarded. + True + end + app.preset-save-as + + + False + True + 4 + + 2 diff --git a/gtk/src/main.c b/gtk/src/main.c index 5046f0e4c..592a98029 100644 --- a/gtk/src/main.c +++ b/gtk/src/main.c @@ -863,6 +863,8 @@ show_activity_action_cb(GSimpleAction *action, GVariant *value, gpointer ud); G_MODULE_EXPORT void preset_save_action_cb(GSimpleAction *action, GVariant *param, gpointer ud); G_MODULE_EXPORT void +preset_save_as_action_cb(GSimpleAction *action, GVariant *param, gpointer ud); +G_MODULE_EXPORT void preset_remove_action_cb(GSimpleAction *action, GVariant *param, gpointer ud); G_MODULE_EXPORT void preset_default_action_cb(GSimpleAction *action, GVariant *param, gpointer ud); @@ -906,6 +908,7 @@ static void map_actions(GApplication * app, signal_user_data_t * ud) { "show-activity", NULL, NULL, "false", show_activity_action_cb }, { "preset-save", preset_save_action_cb }, + { "preset-save-as", preset_save_as_action_cb }, { "preset-remove", preset_remove_action_cb }, { "preset-default", preset_default_action_cb }, { "preset-export", preset_export_action_cb }, diff --git a/gtk/src/presets.c b/gtk/src/presets.c index 3978e444c..565de81e8 100644 --- a/gtk/src/presets.c +++ b/gtk/src/presets.c @@ -2066,9 +2066,7 @@ preset_export_action_cb(GSimpleAction *action, GVariant *param, hb_value_free(&dict); } -G_MODULE_EXPORT void -preset_save_action_cb(GSimpleAction *action, GVariant *param, - signal_user_data_t *ud) +static void preset_save_action(signal_user_data_t *ud, gboolean as) { const char * category = NULL; const gchar * name; @@ -2078,6 +2076,7 @@ preset_save_action_cb(GSimpleAction *action, GVariant *param, int width, height; gboolean autoscale; GtkWidget * dialog; + GtkWidget * widget; GtkEntry * entry; GtkTextView * tv; GhbValue * dict; @@ -2150,6 +2149,12 @@ preset_save_action_cb(GSimpleAction *action, GVariant *param, dialog = GHB_WIDGET(ud->builder, "preset_save_dialog"); entry = GTK_ENTRY(GHB_WIDGET(ud->builder, "PresetName")); gtk_entry_set_text(entry, name); + + widget = GHB_WIDGET(ud->builder, "PresetName"); + gtk_widget_set_sensitive(widget, as); + widget = GHB_WIDGET(ud->builder, "PresetCategory"); + gtk_widget_set_sensitive(widget, as); + response = gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_hide(dialog); if (response == GTK_RESPONSE_OK) @@ -2179,6 +2184,20 @@ preset_save_action_cb(GSimpleAction *action, GVariant *param, } } +G_MODULE_EXPORT void +preset_save_action_cb(GSimpleAction *action, GVariant *param, + signal_user_data_t *ud) +{ + preset_save_action(ud, FALSE); +} + +G_MODULE_EXPORT void +preset_save_as_action_cb(GSimpleAction *action, GVariant *param, + signal_user_data_t *ud) +{ + preset_save_action(ud, TRUE); +} + static void preset_save_set_ok_sensitive(signal_user_data_t *ud) { @@ -2704,19 +2723,19 @@ presets_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_ } if (!ghb_dict_get_bool(dict, "Folder")) { - GtkLabel * label; GSimpleAction * action; GtkWidget * widget; set_preset_menu_button_label(ud, path); - label = GTK_LABEL(GHB_WIDGET(ud->builder, - "preset_selection_modified_label")); - gtk_label_set_markup(label, ""); action = G_SIMPLE_ACTION(g_action_map_lookup_action( G_ACTION_MAP(ud->app), "preset-reload")); g_simple_action_set_enabled(action, FALSE); + widget = GHB_WIDGET(ud->builder, "preset_selection_modified_label"); + gtk_widget_set_visible(widget, FALSE); widget = GHB_WIDGET(ud->builder, "preset_selection_reload"); gtk_widget_set_visible(widget, FALSE); + widget = GHB_WIDGET(ud->builder, "preset_save_new"); + gtk_widget_set_visible(widget, FALSE); } free(path); } @@ -2727,7 +2746,6 @@ ghb_clear_presets_selection(signal_user_data_t *ud) { GtkTreeView * treeview; GtkTreeSelection * selection; - GtkLabel * label; GSimpleAction * action; GtkWidget * widget; @@ -2737,15 +2755,16 @@ ghb_clear_presets_selection(signal_user_data_t *ud) gtk_tree_selection_unselect_all(selection); ghb_dict_set_bool(ud->settings, "preset_modified", TRUE); - label = GTK_LABEL(GHB_WIDGET(ud->builder, - "preset_selection_modified_label")); - gtk_label_set_markup(label, "Modified"); action = G_SIMPLE_ACTION(g_action_map_lookup_action(G_ACTION_MAP(ud->app), "preset-reload")); g_simple_action_set_enabled(action, TRUE); + widget = GHB_WIDGET(ud->builder, "preset_selection_modified_label"); + gtk_widget_set_visible(widget, TRUE); widget = GHB_WIDGET(ud->builder, "preset_selection_reload"); gtk_widget_set_visible(widget, TRUE); + widget = GHB_WIDGET(ud->builder, "preset_save_new"); + gtk_widget_set_visible(widget, TRUE); } G_MODULE_EXPORT void -- 2.40.0