[gnome-commander/GSettings] Adds alt_quick_search to GSettings (now known as quick_search)



commit c3296a8f9271f3c8b1500bd6b2494e65bf0681eb
Author: Uwe Scholz <uwescholz src gnome org>
Date:   Sun Jul 3 13:25:46 2016 +0200

    Adds alt_quick_search to GSettings (now known as quick_search)

 data/org.gnome.gnome-commander.gschema.xml |   21 +++++++++++-----
 src/dialogs/gnome-cmd-options-dialog.cc    |   10 ++++----
 src/gnome-cmd-data.cc                      |   36 +++++++++++++++++++++-------
 src/gnome-cmd-data.h                       |    7 ++++-
 src/gnome-cmd-main-win.cc                  |    2 +-
 src/gnome-cmd-types.h                      |    7 +++++
 6 files changed, 59 insertions(+), 24 deletions(-)
---
diff --git a/data/org.gnome.gnome-commander.gschema.xml b/data/org.gnome.gnome-commander.gschema.xml
index e296264..731f245 100644
--- a/data/org.gnome.gnome-commander.gschema.xml
+++ b/data/org.gnome.gnome-commander.gschema.xml
@@ -11,7 +11,7 @@
     <child name="filter" schema="org.gnome.gnome-commander.preferences.filter"/>
     <child name="programs" schema="org.gnome.gnome-commander.preferences.programs"/>
     <child name="devices" schema="org.gnome.gnome-commander.preferences.devices"/>
-    <child name="keys-bindings" schema="org.gnome.gnome-commander.preferences.keys-bindings"/>
+    <child name="keybindings" schema="org.gnome.gnome-commander.preferences.keybindings"/>
     <child name="colors" schema="org.gnome.gnome-commander.preferences.colors"/>
     <child name="search-history" schema="org.gnome.gnome-commander.preferences.search-history"/>
     <child name="internal-viewer" schema="org.gnome.gnome-commander.preferences.internal-viewer"/>
@@ -94,6 +94,11 @@
     <value nick="custom" value="7"/>
   </enum>
 
+  <enum id="org.gnome.gnome-commander.preferences.keybindings.quick-search-enum">
+    <value nick="CTRL+ALT+letter" value="0"/>
+    <value nick="ALT+letter" value="1"/>
+  </enum>
+
   <schema gettext-domain="gnome-commander" id="org.gnome.gnome-commander.preferences.general" 
path="/org/gnome/gnome-commander/preferences/general/">
     <key name="use-default-font" type="b">
       <default>true</default>
@@ -490,11 +495,6 @@
           This option defines if the internal viewer should be used by default.
       </description>
     </key>
-    <key name="alt-quick-search" type="b">
-      <default l10n="messages">false</default>
-      <summary></summary>
-      <description></description>
-    </key>
     <key name="skip-mounting" type="b">
       <default l10n="messages">true</default>
       <summary></summary>
@@ -563,7 +563,14 @@
       <description></description>
     </key>
   </schema>
-  <schema gettext-domain="gnome-commander" id="org.gnome.gnome-commander.preferences.keys-bindings" 
path="/org/gnome/gnome-commander/preferences/keys-bindings/">
+  <schema gettext-domain="gnome-commander" id="org.gnome.gnome-commander.preferences.keybindings" 
path="/org/gnome/gnome-commander/preferences/keybindings/">
+    <key name="quick-search" enum="org.gnome.gnome-commander.preferences.keybindings.quick-search-enum">
+      <default>'CTRL+ALT+letter'</default>
+      <summary>Quick search shortcut</summary>
+      <description>
+          This option defines the shortcut for quick search.
+      </description>
+    </key>
     <key name="view-equal-panes" type="as">
       <default><![CDATA[['<Control><Shift>plus']]]></default>
       <summary></summary>
diff --git a/src/dialogs/gnome-cmd-options-dialog.cc b/src/dialogs/gnome-cmd-options-dialog.cc
index 541e26a..4ad14b6 100644
--- a/src/dialogs/gnome-cmd-options-dialog.cc
+++ b/src/dialogs/gnome-cmd-options-dialog.cc
@@ -167,10 +167,10 @@ inline GtkWidget *create_general_tab (GtkWidget *parent, GnomeCmdData::Options &
 
     radio = create_radio (parent, NULL, _("CTRL+ALT+letters"), "ctrl_alt_quick_search");
     gtk_box_pack_start (GTK_BOX (cat_box), radio, FALSE, TRUE, 0);
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), !cfg.alt_quick_search);
-    radio = create_radio (parent, get_radio_group (radio), _("ALT+letters (menu access with F10)"), 
"alt_quick_search");
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), !cfg.quick_search);
+    radio = create_radio (parent, get_radio_group (radio), _("ALT+letters (menu access with F10)"), 
"quick_search");
     gtk_container_add (GTK_CONTAINER (cat_box), radio);
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), cfg.alt_quick_search);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), cfg.quick_search);
 
     check = create_check (parent, _("Match beginning of the file name"), "qsearch_exact_match_begin");
     gtk_box_pack_start (GTK_BOX (cat_box), check, FALSE, TRUE, 0);
@@ -222,7 +222,7 @@ inline void store_general_options (GtkWidget *dialog, GnomeCmdData::Options &cfg
     GtkWidget *rmb_popup_radio = lookup_widget (dialog, "rmb_popup_radio");
     GtkWidget *select_dirs = lookup_widget (dialog, "select_dirs");
     GtkWidget *case_sens_check = lookup_widget (dialog, "case_sens_check");
-    GtkWidget *alt_quick_search = lookup_widget (dialog, "alt_quick_search");
+    GtkWidget *quick_search = lookup_widget (dialog, "quick_search");
     GtkWidget *multiple_instance_check = lookup_widget (dialog, "multiple_instance_check");
     GtkWidget *qsearch_exact_match_begin = lookup_widget (dialog, "qsearch_exact_match_begin");
     GtkWidget *qsearch_exact_match_end = lookup_widget (dialog, "qsearch_exact_match_end");
@@ -242,7 +242,7 @@ inline void store_general_options (GtkWidget *dialog, GnomeCmdData::Options &cfg
 
     cfg.select_dirs = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (select_dirs));
     cfg.case_sens_sort = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (case_sens_check));
-    cfg.alt_quick_search = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (alt_quick_search));
+    cfg.quick_search = (GnomeCmdQuickSearchShortcut) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON 
(quick_search));
     cfg.allow_multiple_instances = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON 
(multiple_instance_check));
     cfg.quick_search_exact_match_begin = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON 
(qsearch_exact_match_begin));
     cfg.quick_search_exact_match_end = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON 
(qsearch_exact_match_end));
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index d496cb7..d43ea4e 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -58,6 +58,7 @@ struct _GcmdSettings
     GSettings *confirm;
     GSettings *colors;
     GSettings *programs;
+    GSettings *keybindings;
 };
 
 G_DEFINE_TYPE (GcmdSettings, gcmd_settings, G_TYPE_OBJECT)
@@ -80,6 +81,7 @@ static void gcmd_settings_dispose (GObject *object)
     g_clear_object (&gs->confirm);
     g_clear_object (&gs->colors);
     g_clear_object (&gs->programs);
+    g_clear_object (&gs->keybindings);
 
     G_OBJECT_CLASS (gcmd_settings_parent_class)->dispose (object);
 }
@@ -704,6 +706,13 @@ void on_use_internal_viewer_changed()
     gnome_cmd_data.options.use_internal_viewer = use_internal_viewer;
 }
 
+void on_quick_search_shortcut_changed()
+{
+    gint quick_search;
+    quick_search = g_settings_get_enum (gnome_cmd_data.options.gcmd_settings->keybindings, 
GCMD_SETTINGS_QUICK_SEARCH_SHORTCUT);
+    gnome_cmd_data.options.quick_search = (GnomeCmdQuickSearchShortcut) quick_search;
+}
+
 static void gcmd_settings_class_init (GcmdSettingsClass *klass)
 {
     GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -1040,16 +1049,22 @@ static void gcmd_connect_gsettings_signals(GcmdSettings *gs)
                       G_CALLBACK (on_use_internal_viewer_changed),
                       NULL);
 
+    g_signal_connect (gs->keybindings,
+                      "changed::quick-search",
+                      G_CALLBACK (on_quick_search_shortcut_changed),
+                      NULL);
+
 }
 
 
 static void gcmd_settings_init (GcmdSettings *gs)
 {
-    gs->general  = g_settings_new (GCMD_PREF_GENERAL);
-    gs->filter   = g_settings_new (GCMD_PREF_FILTER);
-    gs->confirm  = g_settings_new (GCMD_PREF_CONFIRM);
-    gs->colors   = g_settings_new (GCMD_PREF_COLORS);
-    gs->programs = g_settings_new (GCMD_PREF_PROGRAMS);
+    gs->general     = g_settings_new (GCMD_PREF_GENERAL);
+    gs->filter      = g_settings_new (GCMD_PREF_FILTER);
+    gs->confirm     = g_settings_new (GCMD_PREF_CONFIRM);
+    gs->colors      = g_settings_new (GCMD_PREF_COLORS);
+    gs->programs    = g_settings_new (GCMD_PREF_PROGRAMS);
+    gs->keybindings = g_settings_new (GCMD_PREF_KEYBINDINGS);
     //TODO: Activate the following function in GCMD > 1.6
     //gcmd_connect_gsettings_signals(gs);
 }
@@ -1079,7 +1094,7 @@ GnomeCmdData::Options::Options(const Options &cfg)
     right_mouse_button_mode = cfg.right_mouse_button_mode;
     select_dirs = cfg.select_dirs;
     case_sens_sort = cfg.case_sens_sort;
-    alt_quick_search = cfg.alt_quick_search;
+    quick_search = cfg.quick_search;
     quick_search_exact_match_begin = cfg.quick_search_exact_match_begin;
     quick_search_exact_match_end = cfg.quick_search_exact_match_end;
     allow_multiple_instances = cfg.allow_multiple_instances;
@@ -1139,7 +1154,7 @@ GnomeCmdData::Options &GnomeCmdData::Options::operator = (const Options &cfg)
         right_mouse_button_mode = cfg.right_mouse_button_mode;
         select_dirs = cfg.select_dirs;
         case_sens_sort = cfg.case_sens_sort;
-        alt_quick_search = cfg.alt_quick_search;
+        quick_search = cfg.quick_search;
         quick_search_exact_match_begin = cfg.quick_search_exact_match_begin;
         quick_search_exact_match_end = cfg.quick_search_exact_match_end;
         allow_multiple_instances = cfg.allow_multiple_instances;
@@ -2665,6 +2680,9 @@ void GnomeCmdData::migrate_all_data_to_gsettings()
         //use_internal_viewer
         migrate_data_int_value_into_gsettings(gnome_cmd_data_get_bool ("/programs/use_internal_viewer", 
TRUE) ? 1 : 0,
                                               options.gcmd_settings->programs, 
GCMD_SETTINGS_USE_INTERNAL_VIEWER);
+        //alt_quick_search
+        migrate_data_int_value_into_gsettings(gnome_cmd_data_get_bool ("/programs/alt_quick_search", FALSE) 
? 1 : 0,
+                                              options.gcmd_settings->keybindings, 
GCMD_SETTINGS_QUICK_SEARCH_SHORTCUT);
 
         g_free(color);
         // ToDo: Move old xml-file to ~/.gnome-commander/gnome-commander.xml.backup
@@ -3030,7 +3048,7 @@ void GnomeCmdData::load()
     options.honor_expect_uris = g_settings_get_boolean (options.gcmd_settings->programs, 
GCMD_SETTINGS_DONT_DOWNLOAD);
     options.allow_multiple_instances = g_settings_get_boolean (options.gcmd_settings->general, 
GCMD_SETTINGS_MULTIPLE_INSTANCES);
     options.use_internal_viewer = g_settings_get_boolean (options.gcmd_settings->programs, 
GCMD_SETTINGS_USE_INTERNAL_VIEWER);
-    options.alt_quick_search = gnome_cmd_data_get_bool ("/programs/alt_quick_search", FALSE);
+    options.quick_search = (GnomeCmdQuickSearchShortcut) g_settings_get_enum 
(options.gcmd_settings->keybindings, GCMD_SETTINGS_QUICK_SEARCH_SHORTCUT);
     options.quick_search_exact_match_begin = gnome_cmd_data_get_bool 
("/programs/quick_search_exact_match_begin", TRUE);
     options.quick_search_exact_match_end = gnome_cmd_data_get_bool 
("/programs/quick_search_exact_match_end", FALSE);
     options.skip_mounting = gnome_cmd_data_get_bool ("/programs/skip_mounting", FALSE);
@@ -3555,10 +3573,10 @@ void GnomeCmdData::save()
     set_gsettings_when_changed      (options.gcmd_settings->general, GCMD_SETTINGS_HORIZONTAL_ORIENTATION, 
&(horizontal_orientation));
     set_gsettings_when_changed      (options.gcmd_settings->general, GCMD_SETTINGS_GUI_UPDATE_RATE, 
&(gui_update_rate));
     set_gsettings_when_changed      (options.gcmd_settings->general, GCMD_SETTINGS_MULTIPLE_INSTANCES, 
&(options.allow_multiple_instances));
+    set_gsettings_enum_when_changed (options.gcmd_settings->keybindings, 
GCMD_SETTINGS_QUICK_SEARCH_SHORTCUT, options.quick_search);
 
     set_gsettings_when_changed      (options.gcmd_settings->programs, GCMD_SETTINGS_DONT_DOWNLOAD, 
&(options.honor_expect_uris));
     set_gsettings_when_changed      (options.gcmd_settings->programs, GCMD_SETTINGS_USE_INTERNAL_VIEWER, 
&(options.use_internal_viewer));
-    gnome_cmd_data_set_bool   ("/programs/alt_quick_search", options.alt_quick_search);
     gnome_cmd_data_set_bool   ("/programs/quick_search_exact_match_begin", 
options.quick_search_exact_match_begin);
     gnome_cmd_data_set_bool   ("/programs/quick_search_exact_match_end", 
options.quick_search_exact_match_end);
     gnome_cmd_data_set_bool   ("/programs/skip_mounting", options.skip_mounting);
diff --git a/src/gnome-cmd-data.h b/src/gnome-cmd-data.h
index 8c18b03..182e1bb 100644
--- a/src/gnome-cmd-data.h
+++ b/src/gnome-cmd-data.h
@@ -145,6 +145,9 @@ GcmdSettings *gcmd_settings_new (void);
 #define GCMD_SETTINGS_DONT_DOWNLOAD                   "dont-download"
 #define GCMD_SETTINGS_USE_INTERNAL_VIEWER             "use-internal-viewer"
 
+#define GCMD_PREF_KEYBINDINGS                         "org.gnome.gnome-commander.preferences.keybindings"
+#define GCMD_SETTINGS_QUICK_SEARCH_SHORTCUT           "quick-search"
+
 struct GnomeCmdConRemote;
 
 struct GnomeCmdData
@@ -205,7 +208,7 @@ struct GnomeCmdData
         RightMouseButtonMode         right_mouse_button_mode;
         gboolean                     select_dirs;
         gboolean                     case_sens_sort;
-        gboolean                     alt_quick_search;
+        GnomeCmdQuickSearchShortcut  quick_search;
         gboolean                     quick_search_exact_match_begin;
         gboolean                     quick_search_exact_match_end;
         gboolean                     allow_multiple_instances;
@@ -263,7 +266,7 @@ struct GnomeCmdData
                    right_mouse_button_mode(RIGHT_BUTTON_POPUPS_MENU),
                    select_dirs(TRUE),
                    case_sens_sort(TRUE),
-                   alt_quick_search(FALSE),
+                   quick_search(GNOME_CMD_QUICK_SEARCH_CTRL_ALT),
                    quick_search_exact_match_begin(TRUE),
                    quick_search_exact_match_end(FALSE),
                    allow_multiple_instances(FALSE),
diff --git a/src/gnome-cmd-main-win.cc b/src/gnome-cmd-main-win.cc
index 4f27f49..7c39081 100644
--- a/src/gnome-cmd-main-win.cc
+++ b/src/gnome-cmd-main-win.cc
@@ -140,7 +140,7 @@ gint gnome_cmd_key_snooper(GtkWidget *grab_widget, GdkEventKey *event, GnomeCmdM
           event->keyval == GDK_period || event->keyval == GDK_question|| event->keyval == GDK_asterisk || 
event->keyval == GDK_bracketleft))
         return FALSE;
 
-    if (!gnome_cmd_data.options.alt_quick_search)
+    if (!gnome_cmd_data.options.quick_search)
         return FALSE;
 
     if (!state_is_alt (event->state) && !state_is_alt_shift (event->state))
diff --git a/src/gnome-cmd-types.h b/src/gnome-cmd-types.h
index b6b2b11..7927fb7 100644
--- a/src/gnome-cmd-types.h
+++ b/src/gnome-cmd-types.h
@@ -57,6 +57,13 @@ enum GnomeCmdPermDispMode
 };
 
 
+enum GnomeCmdQuickSearchShortcut
+{
+    GNOME_CMD_QUICK_SEARCH_CTRL_ALT,
+    GNOME_CMD_QUICK_SEARCH_ALT
+};
+
+
 enum GnomeCmdExtDispMode
 {
     GNOME_CMD_EXT_DISP_WITH_FNAME,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]