[gimp] Bug 667169 - Single window mode: allow tabs position setting.



commit b2e40c4ca7d4854f792783947ffb825af7fd2452
Author: Jehan <jehan girinstud io>
Date:   Sun Sep 15 22:56:17 2013 +1200

    Bug 667169 - Single window mode: allow tabs position setting.

 app/actions/windows-actions.c  |   55 +++++++++++++++++++++++++++++++++++++++-
 app/actions/windows-commands.c |   17 ++++++++++++
 app/actions/windows-commands.h |    3 ++
 app/config/config-enums.c      |   33 ++++++++++++++++++++++++
 app/config/config-enums.h      |   11 ++++++++
 app/config/gimpguiconfig.c     |   12 ++++++++
 app/config/gimpguiconfig.h     |    1 +
 app/config/gimprc-blurbs.h     |    3 ++
 app/display/gimpimagewindow.c  |   47 +++++++++++++++++++++++++++++----
 app/gui/session.c              |   21 +++++++++++++++
 app/widgets/gimphelp-ids.h     |    4 +++
 menus/image-menu.xml.in        |    6 ++++
 12 files changed, 206 insertions(+), 7 deletions(-)
---
diff --git a/app/actions/windows-actions.c b/app/actions/windows-actions.c
index fa00a9e..db41972 100644
--- a/app/actions/windows-actions.c
+++ b/app/actions/windows-actions.c
@@ -110,7 +110,10 @@ static const GimpActionEntry windows_actions[] =
     NC_("windows-action", "Previous Image"), "<alt><shift>Tab",
     NC_("windows-action", "Switch to the previous image"),
     G_CALLBACK (windows_show_display_previous_cmd_callback),
-    NULL }
+    NULL },
+
+  { "windows-tab-position",        NULL, NC_("windows-action",
+                                             "_Tabs Position")   },
 };
 
 static const GimpToggleActionEntry windows_toggle_actions[] =
@@ -130,6 +133,28 @@ static const GimpToggleActionEntry windows_toggle_actions[] =
     GIMP_HELP_WINDOWS_USE_SINGLE_WINDOW_MODE }
 };
 
+static const GimpRadioActionEntry windows_tabs_position_actions[] =
+{
+  { "windows-tabs-position-top", GTK_STOCK_GOTO_TOP,
+    NC_("windows-tabs-position-action", "_Top"), NULL,
+    NC_("windows-tabs-position-action", "Position the tabs to the top"),
+    GIMP_POSITION_TOP, GIMP_HELP_WINDOWS_TABS_POSITION_TOP },
+
+  { "windows-tabs-position-bottom", GTK_STOCK_GOTO_BOTTOM,
+    NC_("windows-tabs-position-action", "_Bottom"), NULL,
+    NC_("windows-tabs-position-action", "Position the tabs to the bottom"),
+    GIMP_POSITION_BOTTOM, GIMP_HELP_WINDOWS_TABS_POSITION_BOTTOM },
+
+  { "windows-tabs-position-left", GTK_STOCK_GOTO_FIRST,
+    NC_("windows-tabs-position-action", "_Left"), NULL,
+    NC_("windows-tabs-position-action", "Position the tabs to the left"),
+    GIMP_POSITION_LEFT, GIMP_HELP_WINDOWS_TABS_POSITION_LEFT },
+
+  { "windows-tabs-position-right", GTK_STOCK_GOTO_LAST,
+    NC_("windows-tabs-position-action", "_Right"), NULL,
+    NC_("windows-tabs-position-action", "Position the tabs to the right"),
+    GIMP_POSITION_RIGHT, GIMP_HELP_WINDOWS_TABS_POSITION_RIGHT },
+};
 
 void
 windows_actions_setup (GimpActionGroup *group)
@@ -144,6 +169,12 @@ windows_actions_setup (GimpActionGroup *group)
                                         windows_toggle_actions,
                                         G_N_ELEMENTS (windows_toggle_actions));
 
+  gimp_action_group_add_radio_actions (group, "windows-tabs-position-action",
+                                       windows_tabs_position_actions,
+                                       G_N_ELEMENTS (windows_tabs_position_actions),
+                                       NULL, 0,
+                                       G_CALLBACK (windows_set_tabs_position_cmd_callback));
+
   gimp_action_group_set_action_hide_empty (group, "windows-docks-menu", FALSE);
 
   g_signal_connect_object (group->gimp->displays, "add",
@@ -210,6 +241,7 @@ windows_actions_update (GimpActionGroup *group,
                         gpointer         data)
 {
   GimpGuiConfig *config = GIMP_GUI_CONFIG (group->gimp->config);
+  const gchar   *action = NULL;
 
 #define SET_ACTIVE(action,condition) \
         gimp_action_group_set_action_active (group, action, (condition) != 0)
@@ -217,6 +249,27 @@ windows_actions_update (GimpActionGroup *group,
   SET_ACTIVE ("windows-use-single-window-mode", config->single_window_mode);
   SET_ACTIVE ("windows-hide-docks", config->hide_docks);
 
+  switch (config->tabs_position)
+    {
+    case GIMP_POSITION_TOP:
+      action = "windows-tabs-position-top";
+      break;
+    case GIMP_POSITION_BOTTOM:
+      action = "windows-tabs-position-bottom";
+      break;
+    case GIMP_POSITION_LEFT:
+      action = "windows-tabs-position-left";
+      break;
+    case GIMP_POSITION_RIGHT:
+      action = "windows-tabs-position-right";
+      break;
+    default:
+      action = "windows-tabs-position-top";
+      break;
+    }
+
+  gimp_action_group_set_action_active (group, action, TRUE);
+
 #undef SET_ACTIVE
 }
 
diff --git a/app/actions/windows-commands.c b/app/actions/windows-commands.c
index f7ff19c..9a04c47 100644
--- a/app/actions/windows-commands.c
+++ b/app/actions/windows-commands.c
@@ -66,6 +66,23 @@ windows_hide_docks_cmd_callback (GtkAction *action,
 }
 
 void
+windows_set_tabs_position_cmd_callback (GtkAction *action,
+                                        GtkAction *current,
+                                        gpointer   data)
+{
+  GimpPosition value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
+  Gimp     *gimp;
+  return_if_no_gimp (gimp, data);
+
+  if (GIMP_GUI_CONFIG (gimp->config)->tabs_position == value)
+    return;
+
+  g_object_set (gimp->config,
+                "tabs-position", value,
+                NULL);
+}
+
+void
 windows_use_single_window_mode_cmd_callback (GtkAction *action,
                                              gpointer   data)
 {
diff --git a/app/actions/windows-commands.h b/app/actions/windows-commands.h
index 880cdd5..957d1c4 100644
--- a/app/actions/windows-commands.h
+++ b/app/actions/windows-commands.h
@@ -21,6 +21,9 @@
 
 void  windows_hide_docks_cmd_callback             (GtkAction *action,
                                                    gpointer   data);
+void  windows_set_tabs_position_cmd_callback      (GtkAction *action,
+                                                   GtkAction *current,
+                                                   gpointer   data);
 void  windows_use_single_window_mode_cmd_callback (GtkAction *action,
                                                    gpointer   data);
 
diff --git a/app/config/config-enums.c b/app/config/config-enums.c
index 2a3d6b5..71ad6cd 100644
--- a/app/config/config-enums.c
+++ b/app/config/config-enums.c
@@ -250,6 +250,39 @@ gimp_handedness_get_type (void)
   return type;
 }
 
+GType
+gimp_position_get_type (void)
+{
+  static const GEnumValue values[] =
+  {
+    { GIMP_POSITION_TOP, "GIMP_POSITION_TOP", "top" },
+    { GIMP_POSITION_BOTTOM, "GIMP_POSITION_BOTTOM", "bottom" },
+    { GIMP_POSITION_LEFT, "GIMP_POSITION_LEFT", "left" },
+    { GIMP_POSITION_RIGHT, "GIMP_POSITION_RIGHT", "right" },
+    { 0, NULL, NULL }
+  };
+
+  static const GimpEnumDesc descs[] =
+  {
+    { GIMP_POSITION_TOP, NC_("position", "Top"), NULL },
+    { GIMP_POSITION_BOTTOM, NC_("position", "Bottom"), NULL },
+    { GIMP_POSITION_LEFT, NC_("position", "Left"), NULL },
+    { GIMP_POSITION_RIGHT, NC_("position", "Right"), NULL },
+    { 0, NULL, NULL }
+  };
+
+  static GType type = 0;
+
+  if (G_UNLIKELY (! type))
+    {
+      type = g_enum_register_static ("GimpPosition", values);
+      gimp_type_set_translation_context (type, "position");
+      gimp_enum_set_value_descriptions (type, descs);
+    }
+
+  return type;
+}
+
 
 /* Generated data ends here */
 
diff --git a/app/config/config-enums.h b/app/config/config-enums.h
index ea433de..5b3e4c9 100644
--- a/app/config/config-enums.h
+++ b/app/config/config-enums.h
@@ -112,5 +112,16 @@ typedef enum
   GIMP_HANDEDNESS_RIGHT /*< desc="Right-handed" >*/
 } GimpHandedness;
 
+#define GIMP_TYPE_POSITION (gimp_position_get_type ())
+
+GType gimp_position_get_type (void) G_GNUC_CONST;
+
+typedef enum
+{
+  GIMP_POSITION_TOP,    /*< desc="Top" >*/
+  GIMP_POSITION_BOTTOM, /*< desc="Bottom" >*/
+  GIMP_POSITION_LEFT,   /*< desc="Left"  >*/
+  GIMP_POSITION_RIGHT   /*< desc="Right" >*/
+} GimpPosition;
 
 #endif /* __CONFIG_ENUMS_H__ */
diff --git a/app/config/gimpguiconfig.c b/app/config/gimpguiconfig.c
index b3e4eb0..4a9cd8f 100644
--- a/app/config/gimpguiconfig.c
+++ b/app/config/gimpguiconfig.c
@@ -74,6 +74,7 @@ enum
 
   PROP_HIDE_DOCKS,
   PROP_SINGLE_WINDOW_MODE,
+  PROP_TABS_POSITION,
   PROP_LAST_TIP_SHOWN,
 
   /* ignored, only for backward compatibility: */
@@ -266,6 +267,11 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass)
                                                          G_PARAM_READWRITE |
                                                          G_PARAM_CONSTRUCT |
                                                          GIMP_PARAM_STATIC_STRINGS));
+  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_TABS_POSITION,
+                                 "tabs-position", WINDOWS_TABS_POSITION,
+                                 GIMP_TYPE_POSITION,
+                                 GIMP_POSITION_TOP,
+                                 GIMP_PARAM_STATIC_STRINGS);
   g_object_class_install_property (object_class, PROP_LAST_TIP_SHOWN,
                                    g_param_spec_int ("last-tip-shown",
                                                      NULL, NULL,
@@ -445,6 +451,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_TABS_POSITION:
+      gui_config->tabs_position = g_value_get_enum (value);
+      break;
     case PROP_LAST_TIP_SHOWN:
       gui_config->last_tip_shown = g_value_get_int (value);
       break;
@@ -567,6 +576,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_TABS_POSITION:
+      g_value_set_enum (value, gui_config->tabs_position);
+      break;
     case PROP_LAST_TIP_SHOWN:
       g_value_set_int (value, gui_config->last_tip_shown);
       break;
diff --git a/app/config/gimpguiconfig.h b/app/config/gimpguiconfig.h
index 12dc2c3..e7eed9f 100644
--- a/app/config/gimpguiconfig.h
+++ b/app/config/gimpguiconfig.h
@@ -70,6 +70,7 @@ struct _GimpGuiConfig
   /* saved in sessionrc */
   gboolean             hide_docks;
   gboolean             single_window_mode;
+  GimpPosition         tabs_position;
   gint                 last_tip_shown;
 };
 
diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h
index 6c2acd0..d638e1a 100644
--- a/app/config/gimprc-blurbs.h
+++ b/app/config/gimprc-blurbs.h
@@ -366,6 +366,9 @@ N_("Show a tooltip when the pointer hovers over an item.")
 #define SINGLE_WINDOW_MODE_BLURB \
 N_("Use GIMP in a single-window mode.")
 
+#define WINDOWS_TABS_POSITION \
+N_("Choose the position of the tabs.")
+
 #define HIDE_DOCKS_BLURB \
 N_("Hide docks and other windows, leaving only image windows.")
 
diff --git a/app/display/gimpimagewindow.c b/app/display/gimpimagewindow.c
index 17c2f6d..0be97ba 100644
--- a/app/display/gimpimagewindow.c
+++ b/app/display/gimpimagewindow.c
@@ -409,6 +409,8 @@ gimp_image_window_constructed (GObject *object)
   gtk_notebook_set_scrollable (GTK_NOTEBOOK (private->notebook), TRUE);
   gtk_notebook_set_show_border (GTK_NOTEBOOK (private->notebook), FALSE);
   gtk_notebook_set_show_tabs (GTK_NOTEBOOK (private->notebook), FALSE);
+  gtk_notebook_set_tab_pos (GTK_NOTEBOOK (private->notebook), GTK_POS_TOP);
+
   gtk_paned_pack1 (GTK_PANED (private->right_hpane), private->notebook,
                    TRUE, TRUE);
   g_signal_connect (private->notebook, "switch-page",
@@ -437,6 +439,9 @@ gimp_image_window_constructed (GObject *object)
   g_signal_connect_object (config, "notify::hide-docks",
                            G_CALLBACK (gimp_image_window_config_notify),
                            window, G_CONNECT_SWAPPED);
+  g_signal_connect_object (config, "notify::tabs-position",
+                           G_CALLBACK (gimp_image_window_config_notify),
+                           window, G_CONNECT_SWAPPED);
 
   gimp_image_window_session_update (window,
                                     NULL /*new_display*/,
@@ -1524,12 +1529,14 @@ gimp_image_window_update_tabs (GimpImageWindow  *window)
 {
   GimpImageWindowPrivate *private;
   GimpGuiConfig          *config;
+  GtkPositionType         position;
 
   g_return_if_fail (GIMP_IS_IMAGE_WINDOW (window));
 
   private = GIMP_IMAGE_WINDOW_GET_PRIVATE (window);
   config = GIMP_GUI_CONFIG (private->gimp->config);
 
+  /* Tab visibility. */
   gtk_notebook_set_show_tabs (GTK_NOTEBOOK (private->notebook),
                               config->single_window_mode &&
                               ! config->hide_docks       &&
@@ -1537,6 +1544,28 @@ gimp_image_window_update_tabs (GimpImageWindow  *window)
                                 private->active_shell->display &&
                                 gimp_display_get_image (private->active_shell->display)) ||
                                g_list_length (private->shells) > 1));
+
+  /* Tab position. */
+  switch (config->tabs_position)
+    {
+    case GIMP_POSITION_TOP:
+      position = GTK_POS_TOP;
+      break;
+    case GIMP_POSITION_BOTTOM:
+      position = GTK_POS_BOTTOM;
+      break;
+    case GIMP_POSITION_LEFT:
+      position = GTK_POS_LEFT;
+      break;
+    case GIMP_POSITION_RIGHT:
+      position = GTK_POS_RIGHT;
+      break;
+    default:
+      /* If we have any strange value, just reset to default. */
+      position = GTK_POS_TOP;
+      break;
+    }
+  gtk_notebook_set_tab_pos (GTK_NOTEBOOK (private->notebook), position);
 }
 
 /*  private functions  */
@@ -1567,14 +1596,20 @@ 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, "hide-docks")         == 0 ||
+      strcmp (pspec->name, "tabs-position")      == 0)
     {
-      gboolean show_docks = (config->single_window_mode &&
-                             ! config->hide_docks);
+      if (strcmp (pspec->name, "single-window-mode") == 0 ||
+          strcmp (pspec->name, "hide-docks")         == 0)
+        {
+          gboolean show_docks = (config->single_window_mode &&
+                                 ! config->hide_docks);
+
+          gimp_image_window_keep_canvas_pos (window);
+          gtk_widget_set_visible (private->left_docks, show_docks);
+          gtk_widget_set_visible (private->right_docks, show_docks);
+        }
 
-      gimp_image_window_keep_canvas_pos (window);
-      gtk_widget_set_visible (private->left_docks, show_docks);
-      gtk_widget_set_visible (private->right_docks, show_docks);
       gimp_image_window_update_tabs (window);
     }
 
diff --git a/app/gui/session.c b/app/gui/session.c
index 721ede7..ef34ab6 100644
--- a/app/gui/session.c
+++ b/app/gui/session.c
@@ -60,6 +60,7 @@ enum
   SESSION_INFO = 1,
   HIDE_DOCKS,
   SINGLE_WINDOW_MODE,
+  TABS_POSITION,
   LAST_TIP_SHOWN
 };
 
@@ -114,6 +115,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,  "tabs-position",
+                              GINT_TO_POINTER (TABS_POSITION));
   g_scanner_scope_add_symbol (scanner, 0,  "last-tip-shown",
                               GINT_TO_POINTER (LAST_TIP_SHOWN));
 
@@ -252,6 +255,19 @@ session_init (Gimp *gimp)
                             "single-window-mode", single_window_mode,
                             NULL);
             }
+          else if (scanner->value.v_symbol == GINT_TO_POINTER (TABS_POSITION))
+            {
+              gint tabs_position;
+
+              token = G_TOKEN_INT;
+
+              if (! gimp_scanner_parse_int (scanner, &tabs_position))
+                break;
+
+              g_object_set (gimp->config,
+                            "tabs-position", tabs_position,
+                            NULL);
+            }
           else if (scanner->value.v_symbol == GINT_TO_POINTER (LAST_TIP_SHOWN))
             {
               gint last_tip_shown;
@@ -365,6 +381,11 @@ session_save (Gimp     *gimp,
                                  "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);
+  gimp_config_writer_close (writer);
+
   gimp_config_writer_open (writer, "last-tip-shown");
   gimp_config_writer_printf (writer, "%d",
                              GIMP_GUI_CONFIG (gimp->config)->last_tip_shown);
diff --git a/app/widgets/gimphelp-ids.h b/app/widgets/gimphelp-ids.h
index 72097fb..55dda17 100644
--- a/app/widgets/gimphelp-ids.h
+++ b/app/widgets/gimphelp-ids.h
@@ -525,6 +525,10 @@
 
 #define GIMP_HELP_WINDOWS_SHOW_DOCK               "gimp-windows-show-dock"
 #define GIMP_HELP_WINDOWS_HIDE_DOCKS              "gimp-windows-hide-docks"
+#define GIMP_HELP_WINDOWS_TABS_POSITION_TOP       "gimp-windows-tabs-position-top"
+#define GIMP_HELP_WINDOWS_TABS_POSITION_BOTTOM    "gimp-windows-tabs-position-bottom"
+#define GIMP_HELP_WINDOWS_TABS_POSITION_LEFT      "gimp-windows-tabs-position-left"
+#define GIMP_HELP_WINDOWS_TABS_POSITION_RIGHT     "gimp-windows-tabs-position-right"
 #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 3e69f54..b130d05 100644
--- a/menus/image-menu.xml.in
+++ b/menus/image-menu.xml.in
@@ -733,6 +733,12 @@
       </placeholder>
       <separator />
       <menuitem action="windows-hide-docks" />
+      <menu action="windows-tab-position" name="Position">
+        <menuitem action="windows-tabs-position-top" />
+        <menuitem action="windows-tabs-position-bottom" />
+        <menuitem action="windows-tabs-position-left" />
+        <menuitem action="windows-tabs-position-right" />
+      </menu>
       <menuitem action="windows-use-single-window-mode" />
       <separator />
     </menu>


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