summaryrefslogtreecommitdiffstats
path: root/gtk/src
diff options
context:
space:
mode:
authorJohn Stebbins <[email protected]>2017-12-22 14:04:15 -0800
committerJohn Stebbins <[email protected]>2017-12-22 14:04:15 -0800
commit96dfcf66c13723485b0df00f0d17035a2c3b9c68 (patch)
treecbf492c97333775bc50cce85a922936cccce860a /gtk/src
parent1db9254b719e35b96dbc2281ef608dd945debeef (diff)
LinGui: add preset options inline menu
Diffstat (limited to 'gtk/src')
-rw-r--r--gtk/src/ghb.m4256
-rw-r--r--gtk/src/main.c3
-rw-r--r--gtk/src/presets.c82
3 files changed, 317 insertions, 24 deletions
diff --git a/gtk/src/ghb.m4 b/gtk/src/ghb.m4
index d6cdd99db..7b8c3c74d 100644
--- a/gtk/src/ghb.m4
+++ b/gtk/src/ghb.m4
@@ -8,6 +8,48 @@ filter_output([
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
+ <menu id="presets-mm">
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">Set De_fault</attribute>
+ <attribute name="action">app.preset-default</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_Save</attribute>
+ <attribute name="action">app.preset-save</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Save _As</attribute>
+ <attribute name="action">app.preset-save-as</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Rename</attribute>
+ <attribute name="action">app.preset-rename</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Delete</attribute>
+ <attribute name="action">app.preset-remove</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_Import</attribute>
+ <attribute name="action">app.preset-import</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Export</attribute>
+ <attribute name="action">app.preset-export</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">Reset _Built-in Presets</attribute>
+ <attribute name="action">app.presets-reload</attribute>
+ </item>
+ </section>
+ </menu>
<object class="GtkFileFilter" id="SourceFilterAVI"/>
<object class="GtkFileFilter" id="SourceFilterAll"/>
<object class="GtkFileFilter" id="SourceFilterEVO"/>
@@ -138,6 +180,15 @@ conjunction with the "Forced" option.</property>
</object>
</child>
<child>
+ <object class="GtkMenuItem" id="presets_window_rename">
+ <property name="label" translatable="yes">_Rename</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_underline">True</property>
+ <property name="action-name">app.preset-rename</property>
+ </object>
+ </child>
+ <child>
<object class="GtkMenuItem" id="presets_window_remove">
<property name="label" translatable="yes">_Delete</property>
<property name="visible">True</property>
@@ -148,7 +199,7 @@ conjunction with the "Forced" option.</property>
</child>
<child>
<object class="GtkMenuItem" id="presets_window_default">
- <property name="label" translatable="yes">_Make Default</property>
+ <property name="label" translatable="yes">Set De_fault</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
@@ -156,26 +207,26 @@ conjunction with the "Forced" option.</property>
</object>
</child>
<child>
- <object class="GtkMenuItem" id="presets_window_export">
- <property name="label" translatable="yes">_Export</property>
+ <object class="GtkMenuItem" id="presets_window_import">
+ <property name="label" translatable="yes">_Import</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
- <property name="action-name">app.preset-export</property>
+ <property name="action-name">app.preset-import</property>
</object>
</child>
<child>
- <object class="GtkMenuItem" id="presets_window_import">
- <property name="label" translatable="yes">_Import</property>
+ <object class="GtkMenuItem" id="presets_window_export">
+ <property name="label" translatable="yes">_Export</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
- <property name="action-name">app.preset-import</property>
+ <property name="action-name">app.preset-export</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="presets_window_restore">
- <property name="label" translatable="yes">_Reload Built-in Presets</property>
+ <property name="label" translatable="yes">Reset _Built-in Presets</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
@@ -950,6 +1001,15 @@ libx264 authors:
</object>
</child>
<child>
+ <object class="GtkMenuItem" id="presets_rename">
+ <property name="label" translatable="yes">_Rename</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="use_underline">True</property>
+ <property name="action-name">app.preset-rename</property>
+ </object>
+ </child>
+ <child>
<object class="GtkMenuItem" id="presets_remove">
<property name="label" translatable="yes">_Delete</property>
<property name="visible">True</property>
@@ -960,7 +1020,7 @@ libx264 authors:
</child>
<child>
<object class="GtkMenuItem" id="presets_default">
- <property name="label" translatable="yes">_Make Default</property>
+ <property name="label" translatable="yes">Set De_fault</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
@@ -968,26 +1028,26 @@ libx264 authors:
</object>
</child>
<child>
- <object class="GtkMenuItem" id="presets_export">
- <property name="label" translatable="yes">_Export</property>
+ <object class="GtkMenuItem" id="presets_import">
+ <property name="label" translatable="yes">_Import</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
- <property name="action-name">app.preset-export</property>
+ <property name="action-name">app.preset-import</property>
</object>
</child>
<child>
- <object class="GtkMenuItem" id="presets_import">
- <property name="label" translatable="yes">_Import</property>
+ <object class="GtkMenuItem" id="presets_export">
+ <property name="label" translatable="yes">_Export</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
- <property name="action-name">app.preset-import</property>
+ <property name="action-name">app.preset-export</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="presets_restore">
- <property name="label" translatable="yes">_Reload Built-in Presets</property>
+ <property name="label" translatable="yes">Reset _Built-in Presets</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_underline">True</property>
@@ -1578,7 +1638,7 @@ This is often the feature title of a DVD.</property>
</child>
<child>
<object class="GtkLabel" id="preset_selection_modified_label">
- <property name="visible">True</property>
+ <property name="visible">False</property>
<property name="can_focus">False</property>
<property name="width-chars">10</property>
<property name="label" translatable="yes"></property>
@@ -1594,7 +1654,7 @@ This is often the feature title of a DVD.</property>
<child>
<object class="GtkButton" id="preset_selection_reload">
<property name="label" translatable="yes">Reload</property>
- <property name="visible">True</property>
+ <property name="visible">False</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>
@@ -1611,7 +1671,7 @@ This is often the feature title of a DVD.</property>
<child>
<object class="GtkButton" id="preset_save_new">
<property name="label" translatable="yes">Save New Preset</property>
- <property name="visible">True</property>
+ <property name="visible">False</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>
@@ -1625,6 +1685,52 @@ This is often the feature title of a DVD.</property>
<property name="position">4</property>
</packing>
</child>
+ <child>
+ <object class="GtkMenuButton" id="preset_options_button">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="direction">down</property>
+ <property name="menu-model">presets-mm</property>
+ <child>
+ <object class="GtkBox" id="presets_options_button_box">
+ <property name="orientation">horizontal</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel" id="presets_options_button_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Options</property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="presets_options_button_arrow">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">pan-down-symbolic</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="top_attach">2</property>
@@ -8405,6 +8511,118 @@ Uncheck this if you want to allow changing each title's settings independently.<
<action-widget response="-5">preset_folder_ok</action-widget>
</action-widgets>
</object>
+ <object class="GtkDialog" id="preset_rename_dialog">
+ <property name="transient_for">hb_window</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="border_width">5</property>
+ <property name="modal">True</property>
+ <property name="window_position">center-on-parent</property>
+ <property name="type_hint">dialog</property>
+ <signal name="delete-event" handler="gtk_widget_hide_on_delete" swapped="no"/>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-preset-rename-box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_preset_rename_area">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="preset_rename_cancel">
+ <property name="label" translatable="yes">Cancel</property>
+ <property name="image">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="preset_rename_ok">
+ <property name="label" translatable="yes">OK</property>
+ <property name="image">gtk-ok</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="preset_rename_hbox">
+ <property name="orientation">horizontal</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <object class="GtkLabel" id="preset_rename_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">Preset Name:</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="PresetReName">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="max_length">40</property>
+ <property name="activates_default">True</property>
+ <property name="width-chars">30</property>
+ <property name="truncate_multiline">True</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <signal name="changed" handler="preset_name_changed_cb" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">preset_rename_cancel</action-widget>
+ <action-widget response="-5">preset_rename_ok</action-widget>
+ </action-widgets>
+ </object>
<object class="GtkDialog" id="preset_save_dialog">
<property name="transient_for">hb_window</property>
<property name="can_focus">False</property>
diff --git a/gtk/src/main.c b/gtk/src/main.c
index 592a98029..f347af03d 100644
--- a/gtk/src/main.c
+++ b/gtk/src/main.c
@@ -865,6 +865,8 @@ 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_rename_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);
@@ -909,6 +911,7 @@ static void map_actions(GApplication * app, signal_user_data_t * ud)
NULL, "false", show_activity_action_cb },
{ "preset-save", preset_save_action_cb },
{ "preset-save-as", preset_save_as_action_cb },
+ { "preset-rename", preset_rename_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 565de81e8..8da10ce5d 100644
--- a/gtk/src/presets.c
+++ b/gtk/src/presets.c
@@ -542,7 +542,8 @@ set_preset_menu_button_label(signal_user_data_t *ud, hb_preset_index_t *path)
type = ghb_dict_get_int(dict, "Type");
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);
+ text = g_strdup_printf("%s%s", type == HB_PRESET_TYPE_CUSTOM ?
+ "Custom" : "Official", fullname);
gtk_label_set_markup(label, text);
free(fullname);
free(text);
@@ -585,6 +586,16 @@ select_preset2(signal_user_data_t *ud, hb_preset_index_t *path)
gtk_tree_path_free(treepath);
}
set_preset_menu_button_label(ud, path);
+
+ int type = preset_get_type(path);
+ GSimpleAction * action;
+
+ action = G_SIMPLE_ACTION(g_action_map_lookup_action(
+ G_ACTION_MAP(ud->app), "preset-rename"));
+ g_simple_action_set_enabled(action, type == HB_PRESET_TYPE_CUSTOM);
+ action = G_SIMPLE_ACTION(g_action_map_lookup_action(
+ G_ACTION_MAP(ud->app), "preset-save"));
+ g_simple_action_set_enabled(action, type == HB_PRESET_TYPE_CUSTOM);
}
void
@@ -1189,7 +1200,7 @@ ghb_presets_menu_init(signal_user_data_t *ud)
continue;
}
- if (type == 0)
+ if (type == HB_PRESET_TYPE_OFFICIAL)
{
// Add folder name to list of official names
official_names[kk++] = g_strdup(folder_name);
@@ -1236,7 +1247,7 @@ ghb_presets_menu_init(signal_user_data_t *ud)
free(preset_path);
free(detail_action);
}
- if (type == 1 &&
+ if (type == HB_PRESET_TYPE_CUSTOM &&
ghb_strv_contains((const char**)official_names, folder_name))
{
menu_item_name = g_strdup_printf("My %s", folder_name);
@@ -1251,7 +1262,9 @@ ghb_presets_menu_init(signal_user_data_t *ud)
}
g_string_free(folder_str, TRUE);
}
- g_menu_append_section(menu, type ? "Custom" : "Official",
+ g_menu_append_section(menu,
+ type == HB_PRESET_TYPE_CUSTOM ?
+ "Custom" : "Official",
G_MENU_MODEL(section));
}
g_free(path);
@@ -2066,6 +2079,56 @@ preset_export_action_cb(GSimpleAction *action, GVariant *param,
hb_value_free(&dict);
}
+G_MODULE_EXPORT void
+preset_rename_action_cb(GSimpleAction *action, GVariant *param,
+ signal_user_data_t *ud)
+{
+ const gchar * name;
+ const gchar * fullname;
+ int type;
+ hb_preset_index_t * path;
+ GtkWidget * dialog;
+ GtkEntry * entry;
+ GhbValue * dict;
+ GtkResponseType response;
+
+ name = ghb_dict_get_string(ud->settings, "PresetName");
+ type = ghb_dict_get_int(ud->settings, "Type");
+ fullname = ghb_dict_get_string(ud->settings, "PresetFullName");
+
+ if (type != HB_PRESET_TYPE_CUSTOM)
+ {
+ // Only allow renaming custom presets
+ return;
+ }
+ path = hb_preset_search_index(fullname, 0, type);
+
+ dialog = GHB_WIDGET(ud->builder, "preset_rename_dialog");
+ entry = GTK_ENTRY(GHB_WIDGET(ud->builder, "PresetReName"));
+ gtk_entry_set_text(entry, name);
+
+ response = gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_hide(dialog);
+ if (response == GTK_RESPONSE_OK)
+ {
+ // save the new name
+ name = gtk_entry_get_text(entry);
+ dict = hb_preset_get(path);
+ if (dict != NULL)
+ {
+ ghb_dict_set_string(dict, "PresetName", name);
+ store_presets();
+ }
+
+ char * full = preset_get_fullname(path, "/");
+ ghb_dict_set_string(ud->settings, "PresetFullName", full);
+ ghb_dict_set_string(ud->settings, "PresetName", name);
+ free(full);
+ ghb_presets_menu_reinit(ud);
+ set_preset_menu_button_label(ud, path);
+ }
+}
+
static void preset_save_action(signal_user_data_t *ud, gboolean as)
{
const char * category = NULL;
@@ -2121,7 +2184,7 @@ static void preset_save_action(signal_user_data_t *ud, gboolean as)
{
continue;
}
- if (ghb_dict_get_int(dict, "Type") == 1)
+ if (ghb_dict_get_int(dict, "Type") == HB_PRESET_TYPE_CUSTOM)
{
category = ghb_dict_get_string(dict, "PresetName");
break;
@@ -2737,6 +2800,15 @@ presets_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_
widget = GHB_WIDGET(ud->builder, "preset_save_new");
gtk_widget_set_visible(widget, FALSE);
}
+ int type = preset_get_type(path);
+ GSimpleAction * action;
+
+ action = G_SIMPLE_ACTION(g_action_map_lookup_action(
+ G_ACTION_MAP(ud->app), "preset-rename"));
+ g_simple_action_set_enabled(action, type == HB_PRESET_TYPE_CUSTOM);
+ action = G_SIMPLE_ACTION(g_action_map_lookup_action(
+ G_ACTION_MAP(ud->app), "preset-save"));
+ g_simple_action_set_enabled(action, type == HB_PRESET_TYPE_CUSTOM);
free(path);
}
}