]> granicus.if.org Git - handbrake/commitdiff
LinGui: add preset "Save As" option
authorJohn Stebbins <jstebbins.hb@gmail.com>
Fri, 22 Dec 2017 18:13:21 +0000 (10:13 -0800)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Fri, 22 Dec 2017 18:13:21 +0000 (10:13 -0800)
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
gtk/src/main.c
gtk/src/presets.c

index e17e723ee4c3d00275e8938cd755a478be122498..d6cdd99db45ba912f795ac4a7eaa7f3ac39bb7c3 100644 (file)
@@ -128,6 +128,15 @@ conjunction with the "Forced" option.</property>
                         <property name="action-name">app.preset-save</property>
                       </object>
                     </child>
+                    <child>
+                      <object class="GtkMenuItem" id="presets_window_save_as">
+                        <property name="label" translatable="yes">Save _As</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="action-name">app.preset-save-as</property>
+                      </object>
+                    </child>
                     <child>
                       <object class="GtkMenuItem" id="presets_window_remove">
                         <property name="label" translatable="yes">_Delete</property>
@@ -931,6 +940,15 @@ libx264 authors:
                         <property name="action-name">app.preset-save</property>
                       </object>
                     </child>
+                    <child>
+                      <object class="GtkMenuItem" id="presets_save_as">
+                        <property name="label" translatable="yes">Save _As</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="use_underline">True</property>
+                        <property name="action-name">app.preset-save-as</property>
+                      </object>
+                    </child>
                     <child>
                       <object class="GtkMenuItem" id="presets_remove">
                         <property name="label" translatable="yes">_Delete</property>
@@ -1564,6 +1582,7 @@ This is often the feature title of a DVD.</property>
                         <property name="can_focus">False</property>
                         <property name="width-chars">10</property>
                         <property name="label" translatable="yes"></property>
+                        <property name="label" translatable="yes">&lt;u&gt;&lt;i&gt;Modified&lt;/i&gt;&lt;/u&gt;</property>
                         <property name="use_markup">True</property>
                       </object>
                       <packing>
@@ -1589,6 +1608,23 @@ This is often the feature title of a DVD.</property>
                         <property name="position">3</property>
                       </packing>
                     </child>
+                    <child>
+                      <object class="GtkButton" id="preset_save_new">
+                        <property name="label" translatable="yes">Save New Preset</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="tooltip_text" translatable="yes">Reload the encoding settings for the currently selected preset.
+    Modifications will be discarded.</property>
+                        <property name="receives_default">True</property>
+                        <property name="halign">end</property>
+                        <property name="action-name">app.preset-save-as</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">4</property>
+                      </packing>
+                    </child>
                   </object>
                   <packing>
                     <property name="top_attach">2</property>
index 5046f0e4c489f2c344566e52325365057fce2363..592a9802954c23e24c9513cc35ca9503c508a956 100644 (file)
@@ -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         },
index 3978e444cb2c370ead5859dd73b9d0b3eacea76a..565de81e8789ef576254cbf08be31ffa49e7292e 100644 (file)
@@ -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, "<u><i>Modified</i></u>");
 
     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