diff options
author | John Stebbins <jstebbins.hb@gmail.com> | 2017-09-18 10:45:47 -0700 |
---|---|---|
committer | John Stebbins <jstebbins.hb@gmail.com> | 2017-11-06 08:19:49 -0800 |
commit | 296dea8e43c7f0bd8e6c564222c6bdd87c8b3f17 (patch) | |
tree | 8aa466d94101cdc1924cc8b0817953d7661459dd /gtk | |
parent | 1deba0d64c98dec881456867925d85434c030ae7 (diff) |
LinGui: add preset "modified" indicator and reset button
When a setting is modified, the word "Modified" appears next to the
preset selection menu button and the "Reset" button is enabled.
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/src/ghb.m4 | 30 | ||||
-rw-r--r-- | gtk/src/main.c | 51 | ||||
-rw-r--r-- | gtk/src/presets.c | 51 |
3 files changed, 100 insertions, 32 deletions
diff --git a/gtk/src/ghb.m4 b/gtk/src/ghb.m4 index 6ecd20ac8..c5e15731c 100644 --- a/gtk/src/ghb.m4 +++ b/gtk/src/ghb.m4 @@ -1584,6 +1584,36 @@ This is often the feature title of a DVD.</property> <property name="position">1</property> </packing> </child> + <child> + <object class="GtkLabel" id="preset_selection_modified_label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="width-chars">10</property> + <property name="label" translatable="yes"></property> + <property name="use_markup">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkButton" id="preset_selection_reset"> + <property name="label" translatable="yes">Reset</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="tooltip_text" translatable="yes">Reset the current title to default Preset values</property> + <property name="receives_default">True</property> + <property name="halign">end</property> + <property name="action-name">app.preset-reset</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">3</property> + </packing> + </child> </object> <packing> <property name="expand">False</property> diff --git a/gtk/src/main.c b/gtk/src/main.c index a452830bb..bcfdbed91 100644 --- a/gtk/src/main.c +++ b/gtk/src/main.c @@ -874,41 +874,44 @@ G_MODULE_EXPORT void guide_action_cb(GSimpleAction *action, GVariant *param, gpointer ud); G_MODULE_EXPORT void preset_select_action_cb(GSimpleAction *action, GVariant *param, gpointer ud); +G_MODULE_EXPORT void +preset_reset_action_cb(GSimpleAction *action, GVariant *param, gpointer ud); static void map_actions(GApplication * app, signal_user_data_t * ud) { const GActionEntry entries[] = { - { "source", source_action_cb }, - { "single", single_title_action_cb }, - { "destination", destination_action_cb }, - { "preferences", preferences_action_cb }, - { "quit", quit_action_cb }, - { "queue-add", queue_add_action_cb }, - { "queue-add-all", queue_add_all_action_cb }, - { "queue-start", queue_start_action_cb }, - { "queue-pause", queue_pause_action_cb }, - { "queue-save", queue_save_action_cb }, + { "source", source_action_cb }, + { "single", single_title_action_cb }, + { "destination", destination_action_cb }, + { "preferences", preferences_action_cb }, + { "quit", quit_action_cb }, + { "queue-add", queue_add_action_cb }, + { "queue-add-all", queue_add_all_action_cb }, + { "queue-start", queue_start_action_cb }, + { "queue-pause", queue_pause_action_cb }, + { "queue-save", queue_save_action_cb }, { "hbfd", NULL, - NULL, "false", hbfd_action_cb }, + NULL, "false", hbfd_action_cb }, { "show-presets", NULL, - NULL, "false", show_presets_action_cb }, + NULL, "false", show_presets_action_cb }, { "show-queue", NULL, - NULL, "false", show_queue_action_cb }, + NULL, "false", show_queue_action_cb }, { "show-preview", NULL, - NULL, "false", show_preview_action_cb }, + NULL, "false", show_preview_action_cb }, { "show-activity", NULL, - NULL, "false", show_activity_action_cb }, - { "preset-save", preset_save_action_cb }, - { "preset-remove", preset_remove_action_cb }, - { "preset-default", preset_default_action_cb }, - { "preset-folder", preset_folder_action_cb }, - { "preset-export", preset_export_action_cb }, - { "preset-import", preset_import_action_cb }, - { "presets-reload", presets_reload_action_cb }, - { "about", about_action_cb }, - { "guide", guide_action_cb }, + NULL, "false", show_activity_action_cb }, + { "preset-save", preset_save_action_cb }, + { "preset-remove", preset_remove_action_cb }, + { "preset-default", preset_default_action_cb }, + { "preset-folder", preset_folder_action_cb }, + { "preset-export", preset_export_action_cb }, + { "preset-import", preset_import_action_cb }, + { "presets-reload", presets_reload_action_cb }, + { "about", about_action_cb }, + { "guide", guide_action_cb }, { "preset-select", preset_select_action_cb, "s" }, + { "preset-reset", preset_reset_action_cb, }, }; g_action_map_add_action_entries(G_ACTION_MAP(app), entries, G_N_ELEMENTS(entries), ud); diff --git a/gtk/src/presets.c b/gtk/src/presets.c index 3eef3ccf9..d4344591c 100644 --- a/gtk/src/presets.c +++ b/gtk/src/presets.c @@ -572,10 +572,10 @@ set_preset_menu_button_label(signal_user_data_t *ud, hb_preset_index_t *path) dict = hb_preset_get(path); type = ghb_dict_get_int(dict, "Type"); - fullname = preset_get_fullname(path, " > "); + fullname = preset_get_fullname(path, " <span alpha=\"70%\">></span> "); label = GTK_LABEL(GHB_WIDGET(ud->builder, "presets_menu_button_label")); text = g_strdup_printf("%s%s", type ? "Custom" : "Official", fullname); - gtk_label_set_text(label, text); + gtk_label_set_markup(label, text); free(fullname); free(text); } @@ -1141,14 +1141,27 @@ get_selected_path(signal_user_data_t *ud) } G_MODULE_EXPORT void -preset_select_action_cb(GSimpleAction *action, GVariant *value, +preset_select_action_cb(GSimpleAction *action, GVariant *param, signal_user_data_t *ud) { - const char * preset_path = g_variant_get_string(value, NULL); + const char * preset_path = g_variant_get_string(param, NULL); ghb_select_preset(ud, preset_path); } +G_MODULE_EXPORT void +preset_reset_action_cb(GSimpleAction *action, GVariant *param, + signal_user_data_t *ud) +{ + const char * preset_path; + + preset_path = ghb_dict_get_string(ud->settings, "PresetFullName"); + if (preset_path != NULL) + { + ghb_select_preset(ud, preset_path); + } +} + void ghb_presets_menu_init(signal_user_data_t *ud) { @@ -2654,7 +2667,19 @@ presets_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_ free(fullname); ghb_set_current_title_settings(ud); ghb_load_post_settings(ud); + } + if (!ghb_dict_get_bool(dict, "Folder")) + { + GtkLabel * label; + GSimpleAction * action; + 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-reset")); + g_simple_action_set_enabled(action, FALSE); } sensitive = TRUE; free(path); @@ -2667,14 +2692,24 @@ presets_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_ void ghb_clear_presets_selection(signal_user_data_t *ud) { - GtkTreeView *treeview; - GtkTreeSelection *selection; + GtkTreeView * treeview; + GtkTreeSelection * selection; + GtkLabel * label; + GSimpleAction * action; if (ud->dont_clear_presets) return; treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "presets_list")); - selection = gtk_tree_view_get_selection (treeview); - gtk_tree_selection_unselect_all (selection); + selection = gtk_tree_view_get_selection(treeview); + 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, "<u><i>Modified</i></u>"); + + action = G_SIMPLE_ACTION(g_action_map_lookup_action(G_ACTION_MAP(ud->app), + "preset-reset")); + g_simple_action_set_enabled(action, TRUE); } G_MODULE_EXPORT void |