]> granicus.if.org Git - handbrake/commitdiff
LinGui: add preset "modified" indicator and reset button
authorJohn Stebbins <jstebbins.hb@gmail.com>
Mon, 18 Sep 2017 17:45:47 +0000 (10:45 -0700)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Mon, 6 Nov 2017 16:19:49 +0000 (08:19 -0800)
When a setting is modified, the word "Modified" appears next to the
preset selection menu button and the "Reset" button is enabled.

gtk/src/ghb.m4
gtk/src/main.c
gtk/src/presets.c

index 6ecd20ac8d190766f12a90f4518054d43e0e6d74..c5e15731ca7a6c65482a9d772b30cfea6327537c 100644 (file)
@@ -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>
index a452830bb019a3e6e0c66ebb1f05f5ab0f79a39b..bcfdbed91ae82f9168bb7d35bd13864f026a8a07 100644 (file)
@@ -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);
index 3eef3ccf9b3ddad809f5afaab8b12092a0fa7ffc..d4344591cf806dffe7189b20a625876bf23fbd43 100644 (file)
@@ -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