[gnome-commander] Add option for show/hide the samba workgroups button



commit 0498aad23a5f4bd25b4fcea299e3abf59f046310
Author: Uwe Scholz <u scholz83 gmx de>
Date:   Sat Oct 9 23:01:34 2021 +0200

    Add option for show/hide the samba workgroups button

 data/org.gnome.gnome-commander.gschema.xml |  7 +++++++
 src/dialogs/gnome-cmd-options-dialog.cc    |  8 +++++++-
 src/gnome-cmd-con-list.cc                  |  6 ++++--
 src/gnome-cmd-data.cc                      | 17 +++++++++++++++++
 src/gnome-cmd-data.h                       |  5 ++++-
 5 files changed, 39 insertions(+), 4 deletions(-)
---
diff --git a/data/org.gnome.gnome-commander.gschema.xml b/data/org.gnome.gnome-commander.gschema.xml
index a5b5cc16..63fa8f43 100644
--- a/data/org.gnome.gnome-commander.gschema.xml
+++ b/data/org.gnome.gnome-commander.gschema.xml
@@ -472,6 +472,13 @@
           This option defines if only device icons should be shown instead of icons and text label.
       </description>
     </key>
+    <key name="show-samba-workgroup-button" type="b">
+      <default>false</default>
+      <summary>Show the samba workgroups icon</summary>
+      <description>
+          This option defines if the Samba workgroups icon should be shown in the devices list.
+      </description>
+    </key>
     <key name="mainmenu-visibility" type="b">
       <default>true</default>
       <summary>Main menu visibility</summary>
diff --git a/src/dialogs/gnome-cmd-options-dialog.cc b/src/dialogs/gnome-cmd-options-dialog.cc
index 726f8a08..1226de00 100644
--- a/src/dialogs/gnome-cmd-options-dialog.cc
+++ b/src/dialogs/gnome-cmd-options-dialog.cc
@@ -2115,6 +2115,10 @@ static GtkWidget *create_devices_tab (GtkWidget *parent, GnomeCmdData::Options &
     GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
     gtk_container_add (GTK_CONTAINER (bbox), button);
 
+    check = create_check (parent, _("Show Samba workgroups button\n(Needs program restart if altered)"), 
"samba_workgroups_button");
+    gtk_container_add (GTK_CONTAINER (cat_box), check);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), cfg.show_samba_workgroups_button);
+
     check = create_check (parent, _("Show only the icons"), "device_only_icon");
     gtk_container_add (GTK_CONTAINER (cat_box), check);
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), cfg.device_only_icon);
@@ -2131,8 +2135,10 @@ static GtkWidget *create_devices_tab (GtkWidget *parent, GnomeCmdData::Options &
 void store_devices_options (GtkWidget *dialog, GnomeCmdData::Options &cfg)
 {
     GtkWidget *device_only_icon = lookup_widget (dialog, "device_only_icon");
-
     cfg.device_only_icon = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (device_only_icon));
+
+    GtkWidget *samba_workgroups_button = lookup_widget (dialog, "samba_workgroups_button");
+    cfg.show_samba_workgroups_button = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON 
(samba_workgroups_button));
 }
 
 
diff --git a/src/gnome-cmd-con-list.cc b/src/gnome-cmd-con-list.cc
index 7011c4ab..18a6c59c 100644
--- a/src/gnome-cmd-con-list.cc
+++ b/src/gnome-cmd-con-list.cc
@@ -146,11 +146,13 @@ static void init (GnomeCmdConList *con_list)
 
     con_list->priv->home_con = gnome_cmd_con_home_new ();
 
-    con_list->priv->smb_con = gnome_cmd_con_smb_new ();
+    if (gnome_cmd_data.options.show_samba_workgroups_button)
+        con_list->priv->smb_con = gnome_cmd_con_smb_new ();
 
     con_list->priv->all_cons = g_list_append (nullptr, con_list->priv->home_con);
 
-    con_list->priv->all_cons = g_list_append (con_list->priv->all_cons, con_list->priv->smb_con);
+    if (gnome_cmd_data.options.show_samba_workgroups_button)
+        con_list->priv->all_cons = g_list_append (con_list->priv->all_cons, con_list->priv->smb_con);
 }
 
 
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index bfd9410f..302aa34d 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -824,6 +824,14 @@ static void on_dev_only_icon_changed()
     gnome_cmd_data.options.device_only_icon = dev_only_icon;
 }
 
+static void on_samba_device_icon_changed()
+{
+    gboolean show_samba_workgroups_button;
+
+    show_samba_workgroups_button = g_settings_get_boolean (gnome_cmd_data.options.gcmd_settings->general, 
GCMD_SETTINGS_SHOW_SAMBA_WORKGROUP_BUTTON);
+    gnome_cmd_data.options.show_samba_workgroups_button = show_samba_workgroups_button;
+}
+
 static void on_mainmenu_visibility_changed()
 {
     gboolean mainmenu_visibility;
@@ -1268,6 +1276,11 @@ static void gcmd_connect_gsettings_signals(GcmdSettings *gs)
                       G_CALLBACK (on_dev_only_icon_changed),
                       nullptr);
 
+    g_signal_connect (gs->general,
+                      "changed::show-samba-workgroup-button",
+                      G_CALLBACK (on_samba_device_icon_changed),
+                      nullptr);
+
     g_signal_connect (gs->general,
                       "changed::mainmenu-visibility",
                       G_CALLBACK (on_mainmenu_visibility_changed),
@@ -1419,6 +1432,7 @@ GnomeCmdData::Options::Options(const Options &cfg)
     termexec = g_strdup (cfg.termexec);
     fav_apps = cfg.fav_apps;
     device_only_icon = cfg.device_only_icon;
+    show_samba_workgroups_button = cfg.show_samba_workgroups_button;
     gcmd_settings = nullptr;
 }
 
@@ -1480,6 +1494,7 @@ GnomeCmdData::Options &GnomeCmdData::Options::operator = (const Options &cfg)
         termexec = g_strdup (cfg.termexec);
         fav_apps = cfg.fav_apps;
         device_only_icon = cfg.device_only_icon;
+        show_samba_workgroups_button = cfg.show_samba_workgroups_button;
         gcmd_settings = nullptr;
     }
 
@@ -3082,6 +3097,7 @@ void GnomeCmdData::load()
     options.quick_search_exact_match_end = g_settings_get_boolean (options.gcmd_settings->general, 
GCMD_SETTINGS_QUICK_SEARCH_EXACT_MATCH_END);
 
     options.device_only_icon = g_settings_get_boolean(options.gcmd_settings->general, 
GCMD_SETTINGS_DEV_ONLY_ICON);
+    options.show_samba_workgroups_button = g_settings_get_boolean(options.gcmd_settings->general, 
GCMD_SETTINGS_SHOW_SAMBA_WORKGROUP_BUTTON);
 
     options.symlink_prefix = g_settings_get_string(options.gcmd_settings->general, 
GCMD_SETTINGS_SYMLINK_PREFIX);
     if (!*options.symlink_prefix || strcmp(options.symlink_prefix, _("link to %s"))==0)
@@ -3456,6 +3472,7 @@ void GnomeCmdData::save()
     set_gsettings_when_changed      (options.gcmd_settings->general, 
GCMD_SETTINGS_QUICK_SEARCH_EXACT_MATCH_END, &(options.quick_search_exact_match_end));
 
     set_gsettings_when_changed      (options.gcmd_settings->general, GCMD_SETTINGS_DEV_ONLY_ICON, 
&(options.device_only_icon));
+    set_gsettings_when_changed      (options.gcmd_settings->general, 
GCMD_SETTINGS_SHOW_SAMBA_WORKGROUP_BUTTON, &(options.show_samba_workgroups_button));
 
     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));
diff --git a/src/gnome-cmd-data.h b/src/gnome-cmd-data.h
index 5483973d..a90f06fb 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_BEGIN  "quick-search-exact-match-begin"
 #define GCMD_SETTINGS_QUICK_SEARCH_EXACT_MATCH_END    "quick-search-exact-match-end"
 #define GCMD_SETTINGS_DEV_ONLY_ICON                   "dev-only-icon"
+#define GCMD_SETTINGS_SHOW_SAMBA_WORKGROUP_BUTTON     "show-samba-workgroup-button"
 #define GCMD_SETTINGS_MAINMENU_VISIBILITY             "mainmenu-visibility"
 #define GCMD_SETTINGS_QUICK_SEARCH_SHORTCUT           "quick-search"
 #define GCMD_SETTINGS_MAIN_WIN_WIDTH                  "main-win-width"
@@ -371,6 +372,7 @@ struct GnomeCmdData
         GList                       *fav_apps;
         //  Devices
         gboolean                     device_only_icon;
+        gboolean                     show_samba_workgroups_button;
 
         Options(): gcmd_settings(nullptr),
                    left_mouse_button_mode(LEFT_BUTTON_OPENS_WITH_DOUBLE_CLICK),
@@ -419,7 +421,8 @@ struct GnomeCmdData
                    termopen(nullptr),
                    termexec(nullptr),
                    fav_apps(nullptr),
-                   device_only_icon(FALSE)
+                   device_only_icon(FALSE),
+                   show_samba_workgroups_button(FALSE)
         {
             memset(&color_themes, 0, sizeof(color_themes));
             memset(&ls_colors_palette, 0, sizeof(ls_colors_palette));


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