[gnome-commander/GSettings] Adds ext_disp_mode option to GSettings (now known as extension-display-mode)



commit 22ef3cf3b6f2a5d3d00ef310773a1d5bb5c75b0b
Author: Uwe Scholz <uwescholz src gnome org>
Date:   Sat May 21 15:04:40 2016 +0200

    Adds ext_disp_mode option to GSettings (now known as extension-display-mode)

 data/org.gnome.gnome-commander.gschema.xml |   16 ++++++++++++----
 src/gnome-cmd-data.cc                      |   22 ++++++++++++++++++++--
 src/gnome-cmd-data.h                       |    1 +
 3 files changed, 33 insertions(+), 6 deletions(-)
---
diff --git a/data/org.gnome.gnome-commander.gschema.xml b/data/org.gnome.gnome-commander.gschema.xml
index 6103417..e82e9d6 100644
--- a/data/org.gnome.gnome-commander.gschema.xml
+++ b/data/org.gnome.gnome-commander.gschema.xml
@@ -39,6 +39,12 @@
     <value nick="MIME icons" value="2"/>
   </enum>
 
+  <enum id="org.gnome.gnome-commander.preferences.general.extension-display-mode">
+    <value nick="with filename column" value="0"/>
+    <value nick="separate column" value="1"/>
+    <value nick="both columns" value="2"/>
+  </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>
@@ -96,10 +102,12 @@
       <summary>List font</summary>
       <description>The font in the file panes.</description>
     </key>
-    <key name="ext-disp-mode" type="i">
-      <default l10n="messages">2</default>
-      <summary></summary>
-      <description></description>
+    <key name='extension-display-mode' 
enum='org.gnome.gnome-commander.preferences.general.extension-display-mode'>
+      <default l10n="messages">'both columns'</default>
+      <summary>Extension display mode</summary>
+      <description>
+          Defines where the file name extension is displayed.
+      </description>
     </key>
     <key name="left-mouse-button-mode" type="i">
       <default l10n="messages">1</default>
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index 5d181e9..e97451c 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -175,6 +175,16 @@ void on_list_font_changed ()
     main_win->update_view();
 }
 
+void on_ext_disp_mode_changed ()
+{
+    gint ext_disp_mode;
+
+    ext_disp_mode = g_settings_get_enum (gnome_cmd_data.options.gcmd_settings->general, 
GCMD_SETTINGS_EXT_DISP_MODE);
+    gnome_cmd_data.options.ext_disp_mode = (GnomeCmdExtDispMode) ext_disp_mode;
+
+    main_win->update_view();
+}
+
 static void gcmd_settings_class_init (GcmdSettingsClass *klass)
 {
     GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -271,6 +281,11 @@ static void gcmd_connect_gsettings_signals(GcmdSettings *gs)
                       G_CALLBACK (on_filter_changed),
                       NULL);
 
+    g_signal_connect (gs->general,
+                      "changed::extension-display-mode",
+                      G_CALLBACK (on_ext_disp_mode_changed),
+                      NULL);
+
 }
 
 
@@ -1651,6 +1666,9 @@ void GnomeCmdData::migrate_all_data_to_gsettings()
         //list_font
         migrate_data_string_value_into_gsettings(gnome_cmd_data_get_string ("/options/list_font", 
"-misc-fixed-medium-r-normal-*-10-*-*-*-c-*-iso8859-1"),
                                                         options.gcmd_settings->general, 
GCMD_SETTINGS_LIST_FONT);
+        //ext_disp_mode
+        migrate_data_int_value_into_gsettings(gnome_cmd_data_get_int ("/options/ext_disp_mode", 
GNOME_CMD_EXT_DISP_BOTH),
+                                                        options.gcmd_settings->general, 
GCMD_SETTINGS_EXT_DISP_MODE);
         // ToDo: Move old xml-file to ~/.gnome-commander/gnome-commander.xml.backup
         //       à la save_devices_old ("devices.backup");
         //       and move .gnome2/gnome-commander to .gnome2/gnome-commander.backup
@@ -1825,7 +1843,7 @@ void GnomeCmdData::load()
 
     options.list_font = g_settings_get_string (options.gcmd_settings->general, GCMD_SETTINGS_LIST_FONT);
 
-    options.ext_disp_mode = (GnomeCmdExtDispMode) gnome_cmd_data_get_int ("/options/ext_disp_mode", 
GNOME_CMD_EXT_DISP_BOTH);
+    options.ext_disp_mode = (GnomeCmdExtDispMode) g_settings_get_enum (options.gcmd_settings->general, 
GCMD_SETTINGS_EXT_DISP_MODE);
     options.left_mouse_button_mode = (LeftMouseButtonMode) gnome_cmd_data_get_int 
("/options/left_mouse_button_mode", LEFT_BUTTON_OPENS_WITH_DOUBLE_CLICK);
     options.left_mouse_button_unselects = gnome_cmd_data_get_bool ("/options/left_mouse_button_unselects", 
TRUE);
     options.middle_mouse_button_mode = (MiddleMouseButtonMode) gnome_cmd_data_get_int 
("/options/middle_mouse_button_mode", MIDDLE_BUTTON_GOES_UP_DIR);
@@ -2359,7 +2377,7 @@ void GnomeCmdData::save()
 
     set_gsettings_when_changed      (options.gcmd_settings->general, GCMD_SETTINGS_LIST_FONT, 
options.list_font);
 
-    gnome_cmd_data_set_int    ("/options/ext_disp_mode", options.ext_disp_mode);
+    set_gsettings_enum_when_changed (options.gcmd_settings->general, GCMD_SETTINGS_EXT_DISP_MODE, 
options.ext_disp_mode);
     gnome_cmd_data_set_int    ("/options/left_mouse_button_mode", options.left_mouse_button_mode);
     gnome_cmd_data_set_bool   ("/options/left_mouse_button_unselects", options.left_mouse_button_unselects);
     gnome_cmd_data_set_int    ("/options/middle_mouse_button_mode", options.middle_mouse_button_mode);
diff --git a/src/gnome-cmd-data.h b/src/gnome-cmd-data.h
index 9d84181..0358b32 100644
--- a/src/gnome-cmd-data.h
+++ b/src/gnome-cmd-data.h
@@ -63,6 +63,7 @@ GcmdSettings *gcmd_settings_new (void);
 #define GCMD_SETTINGS_LIST_ROW_HEIGHT                 "list-row-height"
 #define GCMD_SETTINGS_DATE_DISP_FORMAT                "date-disp-format"
 #define GCMD_SETTINGS_LIST_FONT                       "list-font"
+#define GCMD_SETTINGS_EXT_DISP_MODE                   "extension-display-mode"
 
 #define GCMD_PREF_FILTER                              "org.gnome.gnome-commander.preferences.filter"
 #define GCMD_SETTINGS_FILTER_HIDE_UNKNOWN             "hide-unknown"


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