[gthumb] shortcuts: added button to restore the default shortcuts
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] shortcuts: added button to restore the default shortcuts
- Date: Sun, 24 Nov 2019 12:30:36 +0000 (UTC)
commit ee4b2ef7de51dc380a48893703bdbd4fe120230a
Author: Paolo Bacchilega <paobac src gnome org>
Date: Tue Nov 12 10:36:46 2019 +0100
shortcuts: added button to restore the default shortcuts
data/ui/shortcuts-preferences.ui | 43 ++++++++++++++++++++++++++++++++++++--
gthumb/dlg-preferences-shortcuts.c | 37 ++++++++++++++++++++++++++++++++
2 files changed, 78 insertions(+), 2 deletions(-)
---
diff --git a/data/ui/shortcuts-preferences.ui b/data/ui/shortcuts-preferences.ui
index 1da14f7d..dca2d5c8 100644
--- a/data/ui/shortcuts-preferences.ui
+++ b/data/ui/shortcuts-preferences.ui
@@ -44,13 +44,27 @@
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Keyboard Shortcuts:</property>
+ <property name="mnemonic_widget">shortcuts_list</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
- <object class="GtkViewport">
+ <object class="GtkViewport" id="viewport1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
@@ -65,7 +79,32 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">0</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkButton" id="restore_all_button">
+ <property name="label" translatable="yes">_Restore All…</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
diff --git a/gthumb/dlg-preferences-shortcuts.c b/gthumb/dlg-preferences-shortcuts.c
index a83437c6..ff65ad45 100644
--- a/gthumb/dlg-preferences-shortcuts.c
+++ b/gthumb/dlg-preferences-shortcuts.c
@@ -395,6 +395,39 @@ sort_shortcuts_by_category (gconstpointer a,
}
+static void
+restore_all_button_clicked_cb (GtkButton *button,
+ gpointer user_data)
+{
+ BrowserData *data = user_data;
+ GtkWidget *dialog;
+ gboolean reassign;
+
+ dialog = _gtk_yesno_dialog_new (GTK_WINDOW (data->preferences_dialog),
+ GTK_DIALOG_MODAL,
+ _("Do you want to revert all the changes and restore the default
shortcuts?"),
+ _GTK_LABEL_CANCEL,
+ _("Restore"));
+ _gtk_dialog_add_class_to_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES,
GTK_STYLE_CLASS_DESTRUCTIVE_ACTION);
+
+ reassign = gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES;
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+
+ if (reassign) {
+ int i;
+
+ for (i = 0; i < data->rows->len; i++) {
+ RowData *row_data = g_ptr_array_index (data->rows, i);
+
+ gth_shortcut_set_accelerator (row_data->shortcut,
row_data->shortcut->default_accelerator);
+ row_data_update_accel_label (row_data);
+ }
+
+ gth_main_shortcuts_changed (gth_window_get_shortcuts (GTH_WINDOW (data->browser)));
+ }
+}
+
+
void
shortcuts__dlg_preferences_construct_cb (GtkWidget *dialog,
GthBrowser *browser,
@@ -444,6 +477,10 @@ shortcuts__dlg_preferences_construct_cb (GtkWidget *dialog,
"row-activated",
G_CALLBACK (shortcuts_list_row_activated_cb),
data);
+ g_signal_connect (_gtk_builder_get_widget (data->builder, "restore_all_button"),
+ "clicked",
+ G_CALLBACK (restore_all_button_clicked_cb),
+ data);
/* add the page to the preferences dialog */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]