[gnome-commander/GSettings] Adds mainmenu_visibility to GSettings (now known as mainmenu-visibility)



commit 269e114b6035d24abcc9b224573544fcd25af0b3
Author: Uwe Scholz <uwescholz src gnome org>
Date:   Sun Jul 17 18:29:14 2016 +0200

    Adds mainmenu_visibility to GSettings (now known as mainmenu-visibility)

 data/org.gnome.gnome-commander.gschema.xml |    7 +++++++
 src/gnome-cmd-data.cc                      |   21 +++++++++++++++++++--
 src/gnome-cmd-data.h                       |    1 +
 src/gnome-cmd-main-win.cc                  |    4 ++--
 src/gnome-cmd-user-actions.cc              |    5 +++--
 5 files changed, 32 insertions(+), 6 deletions(-)
---
diff --git a/data/org.gnome.gnome-commander.gschema.xml b/data/org.gnome.gnome-commander.gschema.xml
index 74cd35b..5c034ab 100644
--- a/data/org.gnome.gnome-commander.gschema.xml
+++ b/data/org.gnome.gnome-commander.gschema.xml
@@ -397,6 +397,13 @@
           This option defines if mounting of devices should be skipped when they are opened.
       </description>
     </key>
+    <key name="mainmenu-visibility" type="b">
+      <default l10n="messages">true</default>
+      <summary>Main menu visibility</summary>
+      <description>
+          This option defines if the main menu is visible or not.
+      </description>
+    </key>
   </schema>
   <schema gettext-domain="gnome-commander" id="org.gnome.gnome-commander.preferences.network" 
path="/org/gnome/gnome-commander/preferences/network/">
     <key name="quick-connect-uri" type="s">
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index 4646d95..575d453 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -783,6 +783,15 @@ void on_dev_only_icon_changed()
     gnome_cmd_data.options.device_only_icon = dev_only_icon;
 }
 
+void on_mainmenu_visibility_changed()
+{
+    gboolean mainmenu_visibility;
+
+    mainmenu_visibility = g_settings_get_boolean (gnome_cmd_data.options.gcmd_settings->general, 
GCMD_SETTINGS_MAINMENU_VISIBILITY);
+    gnome_cmd_data.mainmenu_visibility = mainmenu_visibility;
+    main_win->update_mainmenu_visibility();
+}
+
 void on_viewer_cmd_changed()
 {
     gchar *viewer_cmd;
@@ -1203,6 +1212,11 @@ static void gcmd_connect_gsettings_signals(GcmdSettings *gs)
                       G_CALLBACK (on_dev_only_icon_changed),
                       NULL);
 
+    g_signal_connect (gs->general,
+                      "changed::mainmenu-visibility",
+                      G_CALLBACK (on_mainmenu_visibility_changed),
+                      NULL);
+
     g_signal_connect (gs->programs,
                       "changed::viewer-cmd",
                       G_CALLBACK (on_viewer_cmd_changed),
@@ -2896,6 +2910,9 @@ void GnomeCmdData::migrate_all_data_to_gsettings()
         //only_icon
         migrate_data_int_value_into_gsettings(gnome_cmd_data_get_bool ("/devices/only_icon", FALSE) ? 1 : 0,
                                               options.gcmd_settings->general, GCMD_SETTINGS_DEV_ONLY_ICON);
+        //mainmenu_visibility
+        migrate_data_int_value_into_gsettings(gnome_cmd_data_get_bool ("/programs/mainmenu_visibility", 
FALSE) ? 1 : 0,
+                                              options.gcmd_settings->general, 
GCMD_SETTINGS_MAINMENU_VISIBILITY);
         //uri
         migrate_data_string_value_into_gsettings(gnome_cmd_data_get_string ("/quick-connect/uri", 
"ftp://anonymous ftp gnome org/pub/GNOME/"),
                                                         options.gcmd_settings->network, 
GCMD_SETTINGS_QUICK_CONNECT_URI);
@@ -3273,7 +3290,7 @@ void GnomeCmdData::load()
     show_devlist = g_settings_get_boolean (options.gcmd_settings->general, GCMD_SETTINGS_SHOW_DEVLIST);
     cmdline_visibility = g_settings_get_boolean (options.gcmd_settings->general, GCMD_SETTINGS_SHOW_CMDLINE);
     buttonbar_visibility = g_settings_get_boolean (options.gcmd_settings->general, 
GCMD_SETTINGS_SHOW_BUTTONBAR);
-    mainmenu_visibility = gnome_cmd_data_get_bool ("/programs/mainmenu_visibility", TRUE);
+    mainmenu_visibility = g_settings_get_boolean (options.gcmd_settings->general, 
GCMD_SETTINGS_MAINMENU_VISIBILITY);
 
     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);
@@ -3811,7 +3828,7 @@ void GnomeCmdData::save()
     set_gsettings_when_changed      (options.gcmd_settings->general, GCMD_SETTINGS_SHOW_DEVLIST, 
&(show_devlist));
     set_gsettings_when_changed      (options.gcmd_settings->general, GCMD_SETTINGS_SHOW_CMDLINE, 
&(cmdline_visibility));
     set_gsettings_when_changed      (options.gcmd_settings->general, GCMD_SETTINGS_SHOW_BUTTONBAR, 
&(buttonbar_visibility));
-    gnome_cmd_data_set_bool   ("/programs/mainmenu_visibility", mainmenu_visibility);
+    set_gsettings_when_changed      (options.gcmd_settings->general, GCMD_SETTINGS_MAINMENU_VISIBILITY, 
&(mainmenu_visibility));
 
     set_gsettings_when_changed      (options.gcmd_settings->general, GCMD_SETTINGS_MAIN_WIN_POS_X, 
&(options.main_win_pos[0]));
     set_gsettings_when_changed      (options.gcmd_settings->general, GCMD_SETTINGS_MAIN_WIN_POS_Y, 
&(options.main_win_pos[1]));
diff --git a/src/gnome-cmd-data.h b/src/gnome-cmd-data.h
index 0bfe786..e60a1c3 100644
--- a/src/gnome-cmd-data.h
+++ b/src/gnome-cmd-data.h
@@ -96,6 +96,7 @@ GcmdSettings *gcmd_settings_new (void);
 #define GCMD_SETTINGS_QUICK_SEARCH_EXACT_MATCH_END    "quick-search-exact-match-end"
 #define GCMD_SETTINGS_DEV_SKIP_MOUNTING               "dev-skip-mounting"
 #define GCMD_SETTINGS_DEV_ONLY_ICON                   "dev-only-icon"
+#define GCMD_SETTINGS_MAINMENU_VISIBILITY             "mainmenu-visibility"
 
 #define GCMD_PREF_FILTER                              "org.gnome.gnome-commander.preferences.filter"
 #define GCMD_SETTINGS_FILTER_HIDE_UNKNOWN             "hide-unknown"
diff --git a/src/gnome-cmd-main-win.cc b/src/gnome-cmd-main-win.cc
index 12b55a5..d4e3736 100644
--- a/src/gnome-cmd-main-win.cc
+++ b/src/gnome-cmd-main-win.cc
@@ -1299,11 +1299,11 @@ void GnomeCmdMainWin::update_mainmenu_visibility()
 {
     if (gnome_cmd_data.mainmenu_visibility)
     {
-               gtk_widget_show (priv->menubar);
+        gtk_widget_show (priv->menubar);
     }
     else
     {
-               gtk_widget_hide (priv->menubar);
+        gtk_widget_hide (priv->menubar);
     }
 }
 
diff --git a/src/gnome-cmd-user-actions.cc b/src/gnome-cmd-user-actions.cc
index 916e4b1..d08f3da 100644
--- a/src/gnome-cmd-user-actions.cc
+++ b/src/gnome-cmd-user-actions.cc
@@ -1588,8 +1588,9 @@ void view_main_menu (GtkMenuItem *menuitem, gpointer not_used)
 {
     if (!GTK_WIDGET_REALIZED (main_win)) return;
 
-    gnome_cmd_data.mainmenu_visibility = !gnome_cmd_data.mainmenu_visibility;
-    main_win->update_mainmenu_visibility();
+    gboolean mainmenu_visibility;
+    mainmenu_visibility = g_settings_get_boolean (gcmd_user_actions.settings->general, 
GCMD_SETTINGS_MAINMENU_VISIBILITY);
+    g_settings_set_boolean (gcmd_user_actions.settings->general, GCMD_SETTINGS_MAINMENU_VISIBILITY, 
!mainmenu_visibility);
 }
 
 void view_first (GtkMenuItem *menuitem, gpointer not_used)


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