[gnome-commander/GSettings] Adds toolbar_visibility option to GSettings (now known as show-toolbar)



commit ae945ab82e4983d59ce37d9f3c617131b41002cb
Author: Uwe Scholz <uwescholz src gnome org>
Date:   Sun Jun 5 15:16:28 2016 +0200

    Adds toolbar_visibility option to GSettings (now known as show-toolbar)

 data/org.gnome.gnome-commander.gschema.xml |   10 +++++-----
 src/gnome-cmd-data.cc                      |   23 ++++++++++++++++++++---
 src/gnome-cmd-data.h                       |    3 ++-
 src/gnome-cmd-main-menu.cc                 |    2 +-
 src/gnome-cmd-main-win.cc                  |   14 +++++++-------
 src/gnome-cmd-main-win.h                   |    2 +-
 src/gnome-cmd-user-actions.cc              |    4 +---
 7 files changed, 37 insertions(+), 21 deletions(-)
---
diff --git a/data/org.gnome.gnome-commander.gschema.xml b/data/org.gnome.gnome-commander.gschema.xml
index 70055f4..cda97a1 100644
--- a/data/org.gnome.gnome-commander.gschema.xml
+++ b/data/org.gnome.gnome-commander.gschema.xml
@@ -204,6 +204,11 @@
       <summary>Show command line</summary>
       <description>Defines if command line is shown.</description>
     </key>
+    <key name="show-toolbar" type="b">
+      <default l10n="messages">true</default>
+      <summary>Show toolbar</summary>
+      <description>Defines if the toolbar is shown.</description>
+    </key>
     <key name="symlink-prefix" type="s">
       <default l10n="messages">''</default>
       <summary></summary>
@@ -403,11 +408,6 @@
       <summary></summary>
       <description></description>
     </key>
-    <key name="toolbar-visibility" type="b">
-      <default l10n="messages">true</default>
-      <summary></summary>
-      <description></description>
-    </key>
     <key name="buttonbar-visibility" type="b">
       <default l10n="messages">true</default>
       <summary></summary>
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index bce8c2c..19da652 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -225,6 +225,15 @@ void on_show_cmdline_changed ()
     main_win->update_cmdline_visibility();
 }
 
+void on_show_toolbar_changed ()
+{
+    if (gnome_cmd_data.show_toolbar != g_settings_get_boolean 
(gnome_cmd_data.options.gcmd_settings->general, GCMD_SETTINGS_SHOW_TOOLBAR))
+    {
+        gnome_cmd_data.show_toolbar = g_settings_get_boolean (gnome_cmd_data.options.gcmd_settings->general, 
GCMD_SETTINGS_SHOW_TOOLBAR);
+        main_win->update_show_toolbar();
+    }
+}
+
 void on_horizontal_orientation_changed ()
 {
     gboolean horizontal_orientation;
@@ -358,6 +367,11 @@ static void gcmd_connect_gsettings_signals(GcmdSettings *gs)
                       NULL);
 
     g_signal_connect (gs->general,
+                      "changed::show-toolbar",
+                      G_CALLBACK (on_show_toolbar_changed),
+                      NULL);
+
+    g_signal_connect (gs->general,
                       "changed::horizontal-orientation",
                       G_CALLBACK (on_horizontal_orientation_changed),
                       NULL);
@@ -1651,7 +1665,7 @@ GnomeCmdData::GnomeCmdData(): search_defaults(selections)
 
     horizontal_orientation = FALSE;
 
-    toolbar_visibility = TRUE;
+    show_toolbar = TRUE;
     show_devbuttons = TRUE;
     show_devlist = TRUE;
     cmdline_visibility = TRUE;
@@ -1823,6 +1837,9 @@ void GnomeCmdData::migrate_all_data_to_gsettings()
         //cmdline_visibility
         migrate_data_int_value_into_gsettings(gnome_cmd_data_get_bool ("/options/cmdline_visibility", TRUE) 
? 1 : 0,
                                                         options.gcmd_settings->general, 
GCMD_SETTINGS_SHOW_CMDLINE);
+        //toolbar_visibility
+        migrate_data_int_value_into_gsettings(gnome_cmd_data_get_bool ("/programs/toolbar_visibility", TRUE) 
? 1 : 0,
+                                                        options.gcmd_settings->general, 
GCMD_SETTINGS_SHOW_TOOLBAR);
         // 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
@@ -2009,7 +2026,7 @@ void GnomeCmdData::load()
     priv->main_win_pos[0] = gnome_cmd_data_get_int ("/options/main_win_pos_x", -1);
     priv->main_win_pos[1] = gnome_cmd_data_get_int ("/options/main_win_pos_y", -1);
 
-    toolbar_visibility = gnome_cmd_data_get_bool ("/programs/toolbar_visibility", TRUE);
+    show_toolbar = g_settings_get_boolean (options.gcmd_settings->general, GCMD_SETTINGS_SHOW_TOOLBAR);
     show_devbuttons = g_settings_get_boolean (options.gcmd_settings->general, GCMD_SETTINGS_SHOW_DEVBUTTONS);
     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);
@@ -2545,7 +2562,7 @@ void GnomeCmdData::save()
     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);
 
-    gnome_cmd_data_set_bool   ("/programs/toolbar_visibility", toolbar_visibility);
+    set_gsettings_when_changed      (options.gcmd_settings->general, GCMD_SETTINGS_SHOW_TOOLBAR, 
&(show_toolbar));
     set_gsettings_when_changed      (options.gcmd_settings->general, GCMD_SETTINGS_SHOW_DEVBUTTONS, 
&(show_devbuttons));
     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));
diff --git a/src/gnome-cmd-data.h b/src/gnome-cmd-data.h
index f11b82e..9dcc3b1 100644
--- a/src/gnome-cmd-data.h
+++ b/src/gnome-cmd-data.h
@@ -77,6 +77,7 @@ GcmdSettings *gcmd_settings_new (void);
 #define GCMD_SETTINGS_SHOW_DEVBUTTONS                 "show-devbuttons"
 #define GCMD_SETTINGS_SHOW_DEVLIST                    "show-devlist"
 #define GCMD_SETTINGS_SHOW_CMDLINE                    "show-cmdline"
+#define GCMD_SETTINGS_SHOW_TOOLBAR                    "show-toolbar"
 
 #define GCMD_PREF_FILTER                              "org.gnome.gnome-commander.preferences.filter"
 #define GCMD_SETTINGS_FILTER_HIDE_UNKNOWN             "hide-unknown"
@@ -501,7 +502,7 @@ struct GnomeCmdData
 
     gboolean                     horizontal_orientation;
 
-    gboolean                     toolbar_visibility;
+    gboolean                     show_toolbar;
     gboolean                     show_devbuttons;
     gboolean                     show_devlist;
     gboolean                     cmdline_visibility;
diff --git a/src/gnome-cmd-main-menu.cc b/src/gnome-cmd-main-menu.cc
index 5dd399f..1565b96 100644
--- a/src/gnome-cmd-main-menu.cc
+++ b/src/gnome-cmd-main-menu.cc
@@ -809,7 +809,7 @@ static void init (GnomeCmdMainMenu *main_menu)
     main_menu->priv->menu_view_back = view_menu_uiinfo[0].widget;
     main_menu->priv->menu_view_forward = view_menu_uiinfo[1].widget;
 
-    gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (view_menu_uiinfo[8].widget), 
gnome_cmd_data.toolbar_visibility);
+    gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (view_menu_uiinfo[8].widget), 
gnome_cmd_data.show_toolbar);
     gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (view_menu_uiinfo[9].widget), 
gnome_cmd_data.show_devbuttons);
     gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (view_menu_uiinfo[10].widget), 
gnome_cmd_data.show_devlist);
     gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (view_menu_uiinfo[11].widget), 
gnome_cmd_data.cmdline_visibility);
diff --git a/src/gnome-cmd-main-win.cc b/src/gnome-cmd-main-win.cc
index 3737204..48190a3 100644
--- a/src/gnome-cmd-main-win.cc
+++ b/src/gnome-cmd-main-win.cc
@@ -544,7 +544,7 @@ inline void update_browse_buttons (GnomeCmdMainWin *mw, GnomeCmdFileSelector *fs
 
     if (fs == mw->fs(ACTIVE))
     {
-        if (gnome_cmd_data.toolbar_visibility)
+        if (gnome_cmd_data.show_toolbar)
         {
             gtk_widget_set_sensitive (mw->priv->tb_first_btn, fs->can_back());
             gtk_widget_set_sensitive (mw->priv->tb_back_btn, fs->can_back());
@@ -569,7 +569,7 @@ void GnomeCmdMainWin::update_drop_con_button(GnomeCmdFileList *fl)
     if (!con)
         return;
 
-    if (!gnome_cmd_data.toolbar_visibility
+    if (!gnome_cmd_data.show_toolbar
         || (gnome_cmd_data.options.skip_mounting && GNOME_CMD_IS_CON_DEVICE (con)))
         return;
 
@@ -797,7 +797,7 @@ static void init (GnomeCmdMainWin *mw)
     gtk_widget_show (mw->priv->file_selector[RIGHT]);
     gtk_paned_pack2 (GTK_PANED (mw->priv->paned), mw->priv->file_selector[RIGHT], TRUE, TRUE);
 
-    mw->update_toolbar_visibility();
+    mw->update_show_toolbar();
     mw->update_cmdline_visibility();
     mw->update_buttonbar_visibility();
 
@@ -1165,7 +1165,7 @@ void GnomeCmdMainWin::update_bookmarks()
 }
 
 
-void GnomeCmdMainWin::update_toolbar_visibility()
+void GnomeCmdMainWin::update_show_toolbar()
 {
     static GnomeUIInfo toolbar_uiinfo[] =
     {
@@ -1191,7 +1191,7 @@ void GnomeCmdMainWin::update_toolbar_visibility()
         GNOMEUIINFO_END
     };
 
-    if (gnome_cmd_data.toolbar_visibility)
+    if (gnome_cmd_data.show_toolbar)
     {
         create_toolbar (this, toolbar_uiinfo);
         gtk_box_pack_start (GTK_BOX (priv->vbox), priv->toolbar, FALSE, TRUE, 0);
@@ -1243,7 +1243,7 @@ void GnomeCmdMainWin::update_cmdline_visibility()
         g_object_ref (priv->cmdline);
         g_object_set_data_full (*this, "cmdline", priv->cmdline, g_object_unref);
         gtk_widget_show (priv->cmdline);
-        if (gnome_cmd_data.toolbar_visibility)
+        if (gnome_cmd_data.show_toolbar)
             pos += 2;
         gtk_box_pack_start (GTK_BOX (priv->vbox), priv->cmdline_sep, FALSE, TRUE, 0);
         gtk_box_pack_start (GTK_BOX (priv->vbox), priv->cmdline, FALSE, TRUE, 1);
@@ -1282,7 +1282,7 @@ void GnomeCmdMainWin::update_horizontal_orientation()
     gtk_paned_pack1 (GTK_PANED (priv->paned), priv->file_selector[LEFT], TRUE, TRUE);
     gtk_paned_pack2 (GTK_PANED (priv->paned), priv->file_selector[RIGHT], TRUE, TRUE);
 
-    if (gnome_cmd_data.toolbar_visibility)
+    if (gnome_cmd_data.show_toolbar)
         pos += 2;
 
     gtk_box_pack_start (GTK_BOX (priv->vbox), priv->paned, TRUE, TRUE, 0);
diff --git a/src/gnome-cmd-main-win.h b/src/gnome-cmd-main-win.h
index 88fe54a..e79debc 100644
--- a/src/gnome-cmd-main-win.h
+++ b/src/gnome-cmd-main-win.h
@@ -92,7 +92,7 @@ struct GnomeCmdMainWin
     void update_view();
     void update_style();
     void update_bookmarks();
-    void update_toolbar_visibility();
+    void update_show_toolbar();
     void update_cmdline_visibility();
     void update_buttonbar_visibility();
     void update_horizontal_orientation();
diff --git a/src/gnome-cmd-user-actions.cc b/src/gnome-cmd-user-actions.cc
index 4119d51..f514520 100644
--- a/src/gnome-cmd-user-actions.cc
+++ b/src/gnome-cmd-user-actions.cc
@@ -1554,10 +1554,8 @@ void view_devlist (GtkMenuItem *menuitem, gpointer not_used)
 void view_toolbar (GtkMenuItem *menuitem, gpointer not_used)
 {
     if (!GTK_WIDGET_REALIZED (main_win)) return;
-
     GtkCheckMenuItem *checkitem = (GtkCheckMenuItem *) menuitem;
-    gnome_cmd_data.toolbar_visibility = checkitem->active;
-    main_win->update_toolbar_visibility();
+    g_settings_set_boolean (gcmd_user_actions.settings->general, GCMD_SETTINGS_SHOW_TOOLBAR, 
checkitem->active);
 }
 
 


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