[gimp/gimp-2-10] app: Add option in the windows menu to hide the image tab bar.



commit 360aee10d8cc0de55072f78095e064f2e35bd5df
Author: Sergio Jiménez Herena <sergio jimenez herena gmail com>
Date:   Thu Oct 18 15:47:30 2018 +0200

    app: Add option in the windows menu to hide the image tab bar.

 app/actions/windows-actions.c  |  9 +++++++++
 app/actions/windows-commands.c | 17 +++++++++++++++++
 app/actions/windows-commands.h |  4 ++++
 app/config/gimpguiconfig.c     | 16 ++++++++++++++++
 app/config/gimpguiconfig.h     |  1 +
 app/config/gimprc-blurbs.h     |  3 +++
 app/display/gimpimagewindow.c  |  5 +++++
 app/gui/session.c              | 22 ++++++++++++++++++++++
 app/widgets/gimphelp-ids.h     |  1 +
 menus/image-menu.xml.in        |  1 +
 10 files changed, 79 insertions(+)
---
diff --git a/app/actions/windows-actions.c b/app/actions/windows-actions.c
index 52863d8825..4e045c83a4 100644
--- a/app/actions/windows-actions.c
+++ b/app/actions/windows-actions.c
@@ -126,6 +126,13 @@ static const GimpToggleActionEntry windows_toggle_actions[] =
     FALSE,
     GIMP_HELP_WINDOWS_HIDE_DOCKS },
 
+  { "windows-show-tabs", NULL,
+    NC_("windows-action", "Show Tabs"), NULL,
+    NC_("windows-action", "When enabled, the image tabs bar is shown."),
+    G_CALLBACK (windows_show_tabs_cmd_callback),
+    FALSE,
+    GIMP_HELP_WINDOWS_SHOW_TABS },
+
   { "windows-use-single-window-mode", NULL,
     NC_("windows-action", "Single-Window Mode"), NULL,
     NC_("windows-action", "When enabled, GIMP is in a single-window mode."),
@@ -249,6 +256,7 @@ windows_actions_update (GimpActionGroup *group,
 
   SET_ACTIVE ("windows-use-single-window-mode", config->single_window_mode);
   SET_ACTIVE ("windows-hide-docks", config->hide_docks);
+  SET_ACTIVE ("windows-show-tabs", config->show_tabs);
 
   switch (config->tabs_position)
     {
@@ -271,6 +279,7 @@ windows_actions_update (GimpActionGroup *group,
 
   gimp_action_group_set_action_active (group, action, TRUE);
   gimp_action_group_set_action_sensitive (group, "windows-tab-position", config->single_window_mode);
+  gimp_action_group_set_action_sensitive (group, "windows-show-tabs", config->single_window_mode);
 
 #undef SET_ACTIVE
 }
diff --git a/app/actions/windows-commands.c b/app/actions/windows-commands.c
index b3adb55dcc..045db56a67 100644
--- a/app/actions/windows-commands.c
+++ b/app/actions/windows-commands.c
@@ -65,6 +65,23 @@ windows_hide_docks_cmd_callback (GtkAction *action,
                   NULL);
 }
 
+void
+windows_show_tabs_cmd_callback (GtkAction *action,
+                                gpointer data)
+{
+  Gimp     *gimp;
+  gboolean  active;
+  return_if_no_gimp (gimp, data);
+
+  active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+
+  if (active != GIMP_GUI_CONFIG (gimp->config)->show_tabs)
+    g_object_set (gimp->config,
+                  "show-tabs", active,
+                  NULL);
+}
+
+
 void
 windows_set_tabs_position_cmd_callback (GtkAction *action,
                                         GtkAction *current,
diff --git a/app/actions/windows-commands.h b/app/actions/windows-commands.h
index c4d9a2a98e..88955b3dd4 100644
--- a/app/actions/windows-commands.h
+++ b/app/actions/windows-commands.h
@@ -21,6 +21,10 @@
 
 void  windows_hide_docks_cmd_callback             (GtkAction *action,
                                                    gpointer   data);
+
+void  windows_show_tabs_cmd_callback              (GtkAction *action,
+                                                   gpointer data);
+
 void  windows_set_tabs_position_cmd_callback      (GtkAction *action,
                                                    GtkAction *current,
                                                    gpointer   data);
diff --git a/app/config/gimpguiconfig.c b/app/config/gimpguiconfig.c
index 6086b39636..00bdcc84af 100644
--- a/app/config/gimpguiconfig.c
+++ b/app/config/gimpguiconfig.c
@@ -95,6 +95,7 @@ enum
 
   PROP_HIDE_DOCKS,
   PROP_SINGLE_WINDOW_MODE,
+  PROP_SHOW_TABS,
   PROP_TABS_POSITION,
   PROP_LAST_TIP_SHOWN,
 
@@ -456,6 +457,15 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass)
                                                          G_PARAM_CONSTRUCT |
                                                          GIMP_PARAM_STATIC_STRINGS));
 
+  g_object_class_install_property (object_class, PROP_SHOW_TABS,
+                                   g_param_spec_boolean ("show-tabs",
+                                                         NULL,
+                                                         SHOW_TABS_BLURB,
+                                                         TRUE,
+                                                         G_PARAM_READWRITE |
+                                                         G_PARAM_CONSTRUCT |
+                                                         GIMP_PARAM_STATIC_STRINGS));
+
   g_object_class_install_property (object_class, PROP_TABS_POSITION,
                                    g_param_spec_enum ("tabs-position", NULL, NULL,
                                                       GIMP_TYPE_POSITION,
@@ -721,6 +731,9 @@ gimp_gui_config_set_property (GObject      *object,
     case PROP_SINGLE_WINDOW_MODE:
       gui_config->single_window_mode = g_value_get_boolean (value);
       break;
+    case PROP_SHOW_TABS:
+      gui_config->show_tabs = g_value_get_boolean (value);
+      break;
     case PROP_TABS_POSITION:
       gui_config->tabs_position = g_value_get_enum (value);
       break;
@@ -881,6 +894,9 @@ gimp_gui_config_get_property (GObject    *object,
     case PROP_SINGLE_WINDOW_MODE:
       g_value_set_boolean (value, gui_config->single_window_mode);
       break;
+    case PROP_SHOW_TABS:
+      g_value_set_boolean (value, gui_config->show_tabs);
+      break;
     case PROP_TABS_POSITION:
       g_value_set_enum (value, gui_config->tabs_position);
       break;
diff --git a/app/config/gimpguiconfig.h b/app/config/gimpguiconfig.h
index 67e90bb185..bae6b60711 100644
--- a/app/config/gimpguiconfig.h
+++ b/app/config/gimpguiconfig.h
@@ -86,6 +86,7 @@ struct _GimpGuiConfig
   /* saved in sessionrc */
   gboolean             hide_docks;
   gboolean             single_window_mode;
+  gboolean             show_tabs;
   GimpPosition         tabs_position;
   gint                 last_tip_shown;
 };
diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h
index 1085ce4184..237daca3f9 100644
--- a/app/config/gimprc-blurbs.h
+++ b/app/config/gimprc-blurbs.h
@@ -418,6 +418,9 @@ _("Use GIMP in a single-window mode.")
 #define HIDE_DOCKS_BLURB \
 _("Hide docks and other windows, leaving only image windows.")
 
+#define SHOW_TABS_BLURB \
+_("Show the image tabs bar in single window mode.")
+
 #define PLAYGROUND_NPD_TOOL_BLURB \
 _("Enable the N-Point Deformation tool.")
 
diff --git a/app/display/gimpimagewindow.c b/app/display/gimpimagewindow.c
index 1a42c894fa..8fd598d91f 100644
--- a/app/display/gimpimagewindow.c
+++ b/app/display/gimpimagewindow.c
@@ -499,6 +499,9 @@ gimp_image_window_constructed (GObject *object)
   g_signal_connect_object (config, "notify::single-window-mode",
                            G_CALLBACK (gimp_image_window_config_notify),
                            window, G_CONNECT_SWAPPED);
+  g_signal_connect_object (config, "notify::show-tabs",
+                           G_CALLBACK (gimp_image_window_config_notify),
+                           window, G_CONNECT_SWAPPED);
   g_signal_connect_object (config, "notify::hide-docks",
                            G_CALLBACK (gimp_image_window_config_notify),
                            window, G_CONNECT_SWAPPED);
@@ -1771,6 +1774,7 @@ gimp_image_window_update_tabs (GimpImageWindow *window)
   /* Tab visibility. */
   gtk_notebook_set_show_tabs (GTK_NOTEBOOK (private->notebook),
                               config->single_window_mode &&
+                              config->show_tabs          &&
                               ! config->hide_docks       &&
                               ((private->active_shell          &&
                                 private->active_shell->display &&
@@ -1831,6 +1835,7 @@ gimp_image_window_config_notify (GimpImageWindow *window,
   /* Dock column visibility */
   if (strcmp (pspec->name, "single-window-mode") == 0 ||
       strcmp (pspec->name, "hide-docks")         == 0 ||
+      strcmp (pspec->name, "show-tabs")          == 0 ||
       strcmp (pspec->name, "tabs-position")      == 0)
     {
       if (strcmp (pspec->name, "single-window-mode") == 0 ||
diff --git a/app/gui/session.c b/app/gui/session.c
index c1cb33497a..cfbc1c81d1 100644
--- a/app/gui/session.c
+++ b/app/gui/session.c
@@ -51,6 +51,7 @@ enum
   SESSION_INFO = 1,
   HIDE_DOCKS,
   SINGLE_WINDOW_MODE,
+  SHOW_TABS,
   TABS_POSITION,
   LAST_TIP_SHOWN
 };
@@ -106,6 +107,8 @@ session_init (Gimp *gimp)
                               GINT_TO_POINTER (HIDE_DOCKS));
   g_scanner_scope_add_symbol (scanner, 0,  "single-window-mode",
                               GINT_TO_POINTER (SINGLE_WINDOW_MODE));
+  g_scanner_scope_add_symbol (scanner, 0,  "show-tabs",
+                              GINT_TO_POINTER (SHOW_TABS));
   g_scanner_scope_add_symbol (scanner, 0,  "tabs-position",
                               GINT_TO_POINTER (TABS_POSITION));
   g_scanner_scope_add_symbol (scanner, 0,  "last-tip-shown",
@@ -246,6 +249,19 @@ session_init (Gimp *gimp)
                             "single-window-mode", single_window_mode,
                             NULL);
             }
+          else if (scanner->value.v_symbol == GINT_TO_POINTER (SHOW_TABS))
+          {
+            gboolean show_tabs;
+
+            token = G_TOKEN_IDENTIFIER;
+
+            if (! gimp_scanner_parse_boolean (scanner, &show_tabs))
+              break;
+
+            g_object_set (gimp->config,
+                          "show-tabs", show_tabs,
+                          NULL);
+          }
           else if (scanner->value.v_symbol == GINT_TO_POINTER (TABS_POSITION))
             {
               gint tabs_position;
@@ -385,6 +401,12 @@ session_save (Gimp     *gimp,
                                  "yes" : "no");
   gimp_config_writer_close (writer);
 
+  gimp_config_writer_open (writer, "show-tabs");
+  gimp_config_writer_printf (writer,
+                             GIMP_GUI_CONFIG (gimp->config)->show_tabs ?
+                             "yes" : "no");
+  gimp_config_writer_close (writer);
+
   gimp_config_writer_open (writer, "tabs-position");
   gimp_config_writer_printf (writer, "%d",
                              GIMP_GUI_CONFIG (gimp->config)->tabs_position);
diff --git a/app/widgets/gimphelp-ids.h b/app/widgets/gimphelp-ids.h
index 450dfd7de3..2b2d96eb32 100644
--- a/app/widgets/gimphelp-ids.h
+++ b/app/widgets/gimphelp-ids.h
@@ -718,6 +718,7 @@
 
 #define GIMP_HELP_WINDOWS_SHOW_DOCK               "gimp-windows-show-dock"
 #define GIMP_HELP_WINDOWS_HIDE_DOCKS              "gimp-windows-hide-docks"
+#define GIMP_HELP_WINDOWS_SHOW_TABS               "gimp-windows-show-tabs"
 #define GIMP_HELP_WINDOWS_TABS_POSITION           "gimp-windows-tabs-position"
 #define GIMP_HELP_WINDOWS_USE_SINGLE_WINDOW_MODE  "gimp-windows-use-single-window-mode"
 #define GIMP_HELP_WINDOWS_OPEN_RECENT_DOCK        "gimp-windows-open-recent-dock"
diff --git a/menus/image-menu.xml.in b/menus/image-menu.xml.in
index a5c2063e1c..5e4e3ca11b 100644
--- a/menus/image-menu.xml.in
+++ b/menus/image-menu.xml.in
@@ -840,6 +840,7 @@
       </placeholder>
       <separator />
       <menuitem action="windows-hide-docks" />
+      <menuitem action="windows-show-tabs" />
       <menu action="windows-tab-position" name="Position">
         <menuitem action="windows-tabs-position-top" />
         <menuitem action="windows-tabs-position-bottom" />


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