[gimp] Bug 657505 - Strange behaviour with SWM



commit bcb45524b7defd05265d1039198f32281e0f3811
Author: Michael Natterer <mitch gimp org>
Date:   Sat Nov 5 17:52:45 2011 +0100

    Bug 657505 - Strange behaviour with SWM
    
    when window positions aren't automatically saved.
    
    Save "hide-docks" and "single-window-mode" in sessionrc instead of
    gimprc, so a session layout is always saved either completely or not
    at all. Also change "last-tip-shown" saving a bit so all three
    session-saved gimprc properties are implemented the same.

 app/config/gimpguiconfig.c |   71 +++++++++++++++++++++++++++++--------------
 app/config/gimpguiconfig.h |    7 ++--
 app/dialogs/tips-dialog.c  |    8 ++--
 app/gui/session.c          |   59 +++++++++++++++++++++++++++++++-----
 4 files changed, 107 insertions(+), 38 deletions(-)
---
diff --git a/app/config/gimpguiconfig.c b/app/config/gimpguiconfig.c
index c1f4158..a1fc464 100644
--- a/app/config/gimpguiconfig.c
+++ b/app/config/gimpguiconfig.c
@@ -51,8 +51,6 @@ enum
   PROP_RESTORE_SESSION,
   PROP_SAVE_TOOL_OPTIONS,
   PROP_SHOW_TOOLTIPS,
-  PROP_HIDE_DOCKS,
-  PROP_SINGLE_WINDOW_MODE,
   PROP_TEAROFF_MENUS,
   PROP_CAN_CHANGE_ACCELS,
   PROP_SAVE_ACCELS,
@@ -75,6 +73,10 @@ enum
   PROP_CURSOR_FORMAT,
   PROP_CURSOR_HANDEDNESS,
 
+  PROP_HIDE_DOCKS,
+  PROP_SINGLE_WINDOW_MODE,
+  PROP_LAST_TIP_SHOWN,
+
   /* ignored, only for backward compatibility: */
   PROP_INFO_WINDOW_PER_DISPLAY,
   PROP_MENU_MNEMONICS,
@@ -151,15 +153,6 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass)
                                     TRUE,
                                     GIMP_PARAM_STATIC_STRINGS |
                                     GIMP_CONFIG_PARAM_RESTART);
-  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_HIDE_DOCKS,
-                                    "hide-docks", HIDE_DOCKS_BLURB,
-                                    FALSE,
-                                    GIMP_PARAM_STATIC_STRINGS |
-                                    GIMP_CONFIG_PARAM_RESTART);
-  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SINGLE_WINDOW_MODE,
-                                    "single-window-mode", SINGLE_WINDOW_MODE_BLURB,
-                                    FALSE,
-                                    GIMP_PARAM_STATIC_STRINGS);
   GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_TEAROFF_MENUS,
                                     "tearoff-menus", TEAROFF_MENUS_BLURB,
                                     TRUE,
@@ -262,6 +255,30 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass)
                                  GIMP_HANDEDNESS_RIGHT,
                                  GIMP_PARAM_STATIC_STRINGS);
 
+  g_object_class_install_property (object_class, PROP_HIDE_DOCKS,
+                                   g_param_spec_boolean ("hide-docks",
+                                                         NULL,
+                                                         HIDE_DOCKS_BLURB,
+                                                         FALSE,
+                                                         G_PARAM_READWRITE |
+                                                         G_PARAM_CONSTRUCT |
+                                                         GIMP_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (object_class, PROP_SINGLE_WINDOW_MODE,
+                                   g_param_spec_boolean ("single-window-mode",
+                                                         NULL,
+                                                         SINGLE_WINDOW_MODE_BLURB,
+                                                         FALSE,
+                                                         G_PARAM_READWRITE |
+                                                         G_PARAM_CONSTRUCT |
+                                                         GIMP_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (object_class, PROP_LAST_TIP_SHOWN,
+                                   g_param_spec_int ("last-tip-shown",
+                                                     NULL, NULL,
+                                                     0, G_MAXINT, 0,
+                                                     G_PARAM_READWRITE |
+                                                     G_PARAM_CONSTRUCT |
+                                                     GIMP_PARAM_STATIC_STRINGS));
+
   /*  only for backward compatibility:  */
   GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_INFO_WINDOW_PER_DISPLAY,
                                     "info-window-per-display",
@@ -356,12 +373,6 @@ gimp_gui_config_set_property (GObject      *object,
     case PROP_SHOW_TOOLTIPS:
       gui_config->show_tooltips = g_value_get_boolean (value);
       break;
-    case PROP_HIDE_DOCKS:
-      gui_config->hide_docks = g_value_get_boolean (value);
-      break;
-    case PROP_SINGLE_WINDOW_MODE:
-      gui_config->single_window_mode = g_value_get_boolean (value);
-      break;
     case PROP_TEAROFF_MENUS:
       gui_config->tearoff_menus = g_value_get_boolean (value);
       break;
@@ -430,6 +441,16 @@ gimp_gui_config_set_property (GObject      *object,
       gui_config->cursor_handedness = g_value_get_enum (value);
       break;
 
+    case PROP_HIDE_DOCKS:
+      gui_config->hide_docks = g_value_get_boolean (value);
+      break;
+    case PROP_SINGLE_WINDOW_MODE:
+      gui_config->single_window_mode = g_value_get_boolean (value);
+      break;
+    case PROP_LAST_TIP_SHOWN:
+      gui_config->last_tip_shown = g_value_get_int (value);
+      break;
+
     case PROP_INFO_WINDOW_PER_DISPLAY:
     case PROP_MENU_MNEMONICS:
     case PROP_SHOW_TOOL_TIPS:
@@ -480,12 +501,6 @@ gimp_gui_config_get_property (GObject    *object,
     case PROP_SHOW_TOOLTIPS:
       g_value_set_boolean (value, gui_config->show_tooltips);
       break;
-    case PROP_HIDE_DOCKS:
-      g_value_set_boolean (value, gui_config->hide_docks);
-      break;
-    case PROP_SINGLE_WINDOW_MODE:
-      g_value_set_boolean (value, gui_config->single_window_mode);
-      break;
     case PROP_TEAROFF_MENUS:
       g_value_set_boolean (value, gui_config->tearoff_menus);
       break;
@@ -550,6 +565,16 @@ gimp_gui_config_get_property (GObject    *object,
       g_value_set_enum (value, gui_config->cursor_handedness);
       break;
 
+    case PROP_HIDE_DOCKS:
+      g_value_set_boolean (value, gui_config->hide_docks);
+      break;
+    case PROP_SINGLE_WINDOW_MODE:
+      g_value_set_boolean (value, gui_config->single_window_mode);
+      break;
+    case PROP_LAST_TIP_SHOWN:
+      g_value_set_int (value, gui_config->last_tip_shown);
+      break;
+
     case PROP_INFO_WINDOW_PER_DISPLAY:
     case PROP_MENU_MNEMONICS:
     case PROP_SHOW_TOOL_TIPS:
diff --git a/app/config/gimpguiconfig.h b/app/config/gimpguiconfig.h
index b8e9fed..bf6a6c6 100644
--- a/app/config/gimpguiconfig.h
+++ b/app/config/gimpguiconfig.h
@@ -45,8 +45,6 @@ struct _GimpGuiConfig
   gboolean             restore_session;
   gboolean             save_tool_options;
   gboolean             show_tooltips;
-  gboolean             hide_docks;
-  gboolean             single_window_mode;
   gboolean             tearoff_menus;
   gboolean             can_change_accels;
   gboolean             save_accels;
@@ -70,7 +68,10 @@ struct _GimpGuiConfig
   GimpCursorFormat     cursor_format;
   GimpHandedness       cursor_handedness;
 
-  gint                 last_tip;  /* saved in sessionrc */
+  /* saved in sessionrc */
+  gboolean             hide_docks;
+  gboolean             single_window_mode;
+  gint                 last_tip_shown;
 };
 
 struct _GimpGuiConfigClass
diff --git a/app/dialogs/tips-dialog.c b/app/dialogs/tips-dialog.c
index d5fb810..3a2a6e7 100644
--- a/app/dialogs/tips-dialog.c
+++ b/app/dialogs/tips-dialog.c
@@ -117,10 +117,10 @@ tips_dialog_create (Gimp *gimp)
 
   config = GIMP_GUI_CONFIG (gimp->config);
 
-  if (config->last_tip >= tips_count || config->last_tip < 0)
-    config->last_tip = 0;
+  if (config->last_tip_shown >= tips_count || config->last_tip_shown < 0)
+    config->last_tip_shown = 0;
 
-  current_tip = g_list_nth (tips, config->last_tip);
+  current_tip = g_list_nth (tips, config->last_tip_shown);
 
   if (tips_dialog)
     return tips_dialog;
@@ -208,7 +208,7 @@ tips_dialog_destroy (GtkWidget     *widget,
                      GimpGuiConfig *config)
 {
   /* the last-shown-tip is saved in sessionrc */
-  config->last_tip = g_list_position (tips, current_tip);
+  config->last_tip_shown = g_list_position (tips, current_tip);
 
   tips_dialog = NULL;
   current_tip = NULL;
diff --git a/app/gui/session.c b/app/gui/session.c
index 3f06bdb..0487e05 100644
--- a/app/gui/session.c
+++ b/app/gui/session.c
@@ -58,6 +58,8 @@
 enum
 {
   SESSION_INFO = 1,
+  HIDE_DOCKS,
+  SINGLE_WINDOW_MODE,
   LAST_TIP_SHOWN
 };
 
@@ -108,6 +110,10 @@ session_init (Gimp *gimp)
 
   g_scanner_scope_add_symbol (scanner, 0, "session-info",
                               GINT_TO_POINTER (SESSION_INFO));
+  g_scanner_scope_add_symbol (scanner, 0,  "hide-docks",
+                              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,  "last-tip-shown",
                               GINT_TO_POINTER (LAST_TIP_SHOWN));
 
@@ -215,14 +221,44 @@ session_init (Gimp *gimp)
                   break;
                 }
             }
+          else if (scanner->value.v_symbol == GINT_TO_POINTER (HIDE_DOCKS))
+            {
+              gboolean hide_docks;
+
+              token = G_TOKEN_IDENTIFIER;
+
+              if (! gimp_scanner_parse_boolean (scanner, &hide_docks))
+                break;
+
+              g_object_set (gimp->config,
+                            "hide-docks", hide_docks,
+                            NULL);
+            }
+          else if (scanner->value.v_symbol == GINT_TO_POINTER (SINGLE_WINDOW_MODE))
+            {
+              gboolean single_window_mode;
+
+              token = G_TOKEN_IDENTIFIER;
+
+              if (! gimp_scanner_parse_boolean (scanner, &single_window_mode))
+                break;
+
+              g_object_set (gimp->config,
+                            "single-window-mode", single_window_mode,
+                            NULL);
+            }
           else if (scanner->value.v_symbol == GINT_TO_POINTER (LAST_TIP_SHOWN))
             {
-              GimpGuiConfig *config = GIMP_GUI_CONFIG (gimp->config);
+              gint last_tip_shown;
 
               token = G_TOKEN_INT;
 
-              if (! gimp_scanner_parse_int (scanner, &config->last_tip))
+              if (! gimp_scanner_parse_int (scanner, &last_tip_shown))
                 break;
+
+              g_object_set (gimp->config,
+                            "last-tip-shown", last_tip_shown,
+                            NULL);
             }
           token = G_TOKEN_RIGHT_PAREN;
           break;
@@ -310,14 +346,21 @@ session_save (Gimp     *gimp,
   gimp_dialog_factory_save (gimp_dialog_factory_get_singleton (), writer);
   gimp_config_writer_linefeed (writer);
 
-  /* save last tip shown
-   *
-   * FIXME: Make last-tip-shown increment only when used within the
-   * session
-   */
+  gimp_config_writer_open (writer, "hide-docks");
+  gimp_config_writer_identifier (writer,
+                                 GIMP_GUI_CONFIG (gimp->config)->hide_docks ?
+                                 "yes" : "no");
+  gimp_config_writer_close (writer);
+
+  gimp_config_writer_open (writer, "single-window-mode");
+  gimp_config_writer_identifier (writer,
+                                 GIMP_GUI_CONFIG (gimp->config)->single_window_mode ?
+                                 "yes" : "no");
+  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);
+                             GIMP_GUI_CONFIG (gimp->config)->last_tip_shown);
   gimp_config_writer_close (writer);
 
   if (! gimp_config_writer_finish (writer, "end of sessionrc", &error))



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