gimp r25114 - in trunk: . app/actions app/display app/gui



Author: mitch
Date: Tue Mar 18 22:21:47 2008
New Revision: 25114
URL: http://svn.gnome.org/viewvc/gimp?rev=25114&view=rev

Log:
2008-03-18  Michael Natterer  <mitch gimp org>

	* app/display/gimpdisplayoptions.[ch]: add new options object
	for the "no image" display appearance.

	* app/display/gimpdisplayshell.[ch]: keep one of them around.

	* app/display/gimpdisplayshell-appearance.[ch]: use the options
	object when the display is empty. Add guards against no image
	to some functions. Add gimp_display_shell_appearance_update()
	which sets all options according to the current display state
	(normal, fullscreen, no image).

	* app/actions/view-actions.c: don't allow to configure the GUI
	of the empty display.

	* app/display/gimpdisplayshell-callbacks.c: use the new appearance
	update function instead of doing it all here.

	* app/display/gimpdisplayshell-close.c
	* app/gui/gui-vtable.c: update the appearance when clearing or
	filling the display.

	* app/display/gimpdisplayshell-selection.c: forgot some guards
	against empty displays.



Modified:
   trunk/ChangeLog
   trunk/app/actions/view-actions.c
   trunk/app/display/gimpdisplayoptions.c
   trunk/app/display/gimpdisplayoptions.h
   trunk/app/display/gimpdisplayshell-appearance.c
   trunk/app/display/gimpdisplayshell-appearance.h
   trunk/app/display/gimpdisplayshell-callbacks.c
   trunk/app/display/gimpdisplayshell-close.c
   trunk/app/display/gimpdisplayshell-selection.c
   trunk/app/display/gimpdisplayshell.c
   trunk/app/display/gimpdisplayshell.h
   trunk/app/gui/gui-vtable.c

Modified: trunk/app/actions/view-actions.c
==============================================================================
--- trunk/app/actions/view-actions.c	(original)
+++ trunk/app/actions/view-actions.c	Tue Mar 18 22:21:47 2008
@@ -545,7 +545,9 @@
 
       fullscreen = gimp_display_shell_get_fullscreen (shell);
 
-      options = fullscreen ? shell->fullscreen_options : shell->options;
+      options = (image ?
+                 (fullscreen ? shell->fullscreen_options : shell->options) :
+                 shell->no_image_options);
 
       revert_enabled = gimp_display_shell_scale_can_revert (shell);
     }
@@ -619,11 +621,11 @@
   SET_SENSITIVE ("view-snap-to-vectors",     image);
   SET_ACTIVE    ("view-snap-to-vectors",     display && shell->snap_to_vectors);
 
-  SET_SENSITIVE ("view-padding-color-theme",       display);
-  SET_SENSITIVE ("view-padding-color-light-check", display);
-  SET_SENSITIVE ("view-padding-color-dark-check",  display);
-  SET_SENSITIVE ("view-padding-color-custom",      display);
-  SET_SENSITIVE ("view-padding-color-prefs",       display);
+  SET_SENSITIVE ("view-padding-color-theme",       image);
+  SET_SENSITIVE ("view-padding-color-light-check", image);
+  SET_SENSITIVE ("view-padding-color-dark-check",  image);
+  SET_SENSITIVE ("view-padding-color-custom",      image);
+  SET_SENSITIVE ("view-padding-color-prefs",       image);
 
   if (display)
     {
@@ -642,13 +644,13 @@
         }
     }
 
-  SET_SENSITIVE ("view-show-menubar",    display);
+  SET_SENSITIVE ("view-show-menubar",    image);
   SET_ACTIVE    ("view-show-menubar",    display && options->show_menubar);
-  SET_SENSITIVE ("view-show-rulers",     display);
+  SET_SENSITIVE ("view-show-rulers",     image);
   SET_ACTIVE    ("view-show-rulers",     display && options->show_rulers);
-  SET_SENSITIVE ("view-show-scrollbars", display);
+  SET_SENSITIVE ("view-show-scrollbars", image);
   SET_ACTIVE    ("view-show-scrollbars", display && options->show_scrollbars);
-  SET_SENSITIVE ("view-show-statusbar",  display);
+  SET_SENSITIVE ("view-show-statusbar",  image);
   SET_ACTIVE    ("view-show-statusbar",  display && options->show_statusbar);
 
   SET_SENSITIVE ("view-shrink-wrap", image);

Modified: trunk/app/display/gimpdisplayoptions.c
==============================================================================
--- trunk/app/display/gimpdisplayoptions.c	(original)
+++ trunk/app/display/gimpdisplayoptions.c	Tue Mar 18 22:21:47 2008
@@ -80,6 +80,16 @@
                          GIMP_TYPE_DISPLAY_OPTIONS,
                          G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG, NULL))
 
+typedef struct _GimpDisplayOptions      GimpDisplayOptionsNoImage;
+typedef struct _GimpDisplayOptionsClass GimpDisplayOptionsNoImageClass;
+
+#define gimp_display_options_no_image_init gimp_display_options_init
+
+G_DEFINE_TYPE_WITH_CODE (GimpDisplayOptionsNoImage,
+                         gimp_display_options_no_image,
+                         GIMP_TYPE_DISPLAY_OPTIONS,
+                         G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG, NULL))
+
 
 static void
 gimp_display_options_class_init (GimpDisplayOptionsClass *klass)
@@ -198,6 +208,44 @@
 }
 
 static void
+gimp_display_options_no_image_class_init (GimpDisplayOptionsNoImageClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->set_property = gimp_display_options_set_property;
+  object_class->get_property = gimp_display_options_get_property;
+
+  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SHOW_RULERS,
+                                    "show-rulers", SHOW_RULERS_BLURB,
+                                    FALSE,
+                                    GIMP_PARAM_STATIC_STRINGS);
+  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SHOW_SCROLLBARS,
+                                    "show-scrollbars", SHOW_SCROLLBARS_BLURB,
+                                    FALSE,
+                                    GIMP_PARAM_STATIC_STRINGS);
+  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SHOW_SELECTION,
+                                    "show-selection", SHOW_SELECTION_BLURB,
+                                    FALSE,
+                                    GIMP_PARAM_STATIC_STRINGS);
+  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SHOW_LAYER_BOUNDARY,
+                                    "show-layer-boundary", SHOW_LAYER_BOUNDARY_BLURB,
+                                    FALSE,
+                                    GIMP_PARAM_STATIC_STRINGS);
+  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SHOW_GUIDES,
+                                    "show-guides", SHOW_GUIDES_BLURB,
+                                    FALSE,
+                                    GIMP_PARAM_STATIC_STRINGS);
+  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SHOW_GRID,
+                                    "show-grid", SHOW_GRID_BLURB,
+                                    FALSE,
+                                    GIMP_PARAM_STATIC_STRINGS);
+  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SHOW_SAMPLE_POINTS,
+                                    "show-sample-points", SHOW_SAMPLE_POINTS_BLURB,
+                                    FALSE,
+                                    GIMP_PARAM_STATIC_STRINGS);
+}
+
+static void
 gimp_display_options_init (GimpDisplayOptions *options)
 {
   options->padding_mode_set = FALSE;
@@ -255,9 +303,9 @@
 
 static void
 gimp_display_options_get_property (GObject    *object,
-                                      guint       property_id,
-                                      GValue     *value,
-                                      GParamSpec *pspec)
+                                   guint       property_id,
+                                   GValue     *value,
+                                   GParamSpec *pspec)
 {
   GimpDisplayOptions *options = GIMP_DISPLAY_OPTIONS (object);
 

Modified: trunk/app/display/gimpdisplayoptions.h
==============================================================================
--- trunk/app/display/gimpdisplayoptions.h	(original)
+++ trunk/app/display/gimpdisplayoptions.h	Tue Mar 18 22:21:47 2008
@@ -25,6 +25,7 @@
 
 #define GIMP_TYPE_DISPLAY_OPTIONS            (gimp_display_options_get_type ())
 #define GIMP_TYPE_DISPLAY_OPTIONS_FULLSCREEN (gimp_display_options_fullscreen_get_type ())
+#define GIMP_TYPE_DISPLAY_OPTIONS_NO_IMAGE   (gimp_display_options_no_image_get_type ())
 
 #define GIMP_DISPLAY_OPTIONS(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_DISPLAY_OPTIONS, GimpDisplayOptions))
 #define GIMP_DISPLAY_OPTIONS_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DISPLAY_OPTIONS, GimpDisplayOptionsClass))
@@ -64,6 +65,7 @@
 
 GType  gimp_display_options_get_type            (void) G_GNUC_CONST;
 GType  gimp_display_options_fullscreen_get_type (void) G_GNUC_CONST;
+GType  gimp_display_options_no_image_get_type   (void) G_GNUC_CONST;
 
 
 #endif /* __GIMP_DISPLAY_OPTIONS_H__ */

Modified: trunk/app/display/gimpdisplayshell-appearance.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-appearance.c	(original)
+++ trunk/app/display/gimpdisplayshell-appearance.c	Tue Mar 18 22:21:47 2008
@@ -28,6 +28,7 @@
 #include "core/gimp.h"
 #include "core/gimpcontext.h"
 #include "core/gimpimage.h"
+#include "core/gimpimage-grid.h"
 #include "core/gimpimage-guides.h"
 #include "core/gimpimage-sample-points.h"
 
@@ -46,8 +47,10 @@
 
 
 #define GET_OPTIONS(shell) \
-  (gimp_display_shell_get_fullscreen (shell) ? \
-   shell->fullscreen_options : shell->options)
+  (shell->display->image ? \
+   (gimp_display_shell_get_fullscreen (shell) ? \
+    shell->fullscreen_options : shell->options) : \
+   shell->no_image_options)
 
 #define SET_ACTIVE(manager,action_name,active) \
   { GimpActionGroup *group = \
@@ -66,6 +69,42 @@
 
 
 void
+gimp_display_shell_appearance_update (GimpDisplayShell *shell)
+{
+  GimpDisplayOptions *options;
+
+  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
+
+  options = GET_OPTIONS (shell);
+
+  gtk_widget_set_name (GTK_WIDGET (shell->menubar),
+                       gimp_display_shell_get_fullscreen (shell) ?
+                       "gimp-menubar-fullscreen" : NULL);
+
+  gimp_display_shell_set_show_menubar       (shell,
+                                             options->show_menubar);
+  gimp_display_shell_set_show_rulers        (shell,
+                                             options->show_rulers);
+  gimp_display_shell_set_show_scrollbars    (shell,
+                                             options->show_scrollbars);
+  gimp_display_shell_set_show_statusbar     (shell,
+                                             options->show_statusbar);
+  gimp_display_shell_set_show_selection     (shell,
+                                             options->show_selection);
+  gimp_display_shell_set_show_layer         (shell,
+                                             options->show_layer_boundary);
+  gimp_display_shell_set_show_guides        (shell,
+                                             options->show_guides);
+  gimp_display_shell_set_show_grid          (shell,
+                                             options->show_grid);
+  gimp_display_shell_set_show_sample_points (shell,
+                                             options->show_sample_points);
+  gimp_display_shell_set_padding            (shell,
+                                             options->padding_mode,
+                                             &options->padding_color);
+}
+
+void
 gimp_display_shell_set_fullscreen (GimpDisplayShell *shell,
                                    gboolean          fullscreen)
 {
@@ -337,8 +376,11 @@
 
   g_object_set (options, "show-guides", show, NULL);
 
-  if (gimp_image_get_guides (shell->display->image))
-    gimp_display_shell_expose_full (shell);
+  if (shell->display->image &&
+      gimp_image_get_guides (shell->display->image))
+    {
+      gimp_display_shell_expose_full (shell);
+    }
 
   SET_ACTIVE (shell->menubar_manager, "view-show-guides", show);
 
@@ -366,8 +408,11 @@
 
   g_object_set (options, "show-grid", show, NULL);
 
-  if (shell->display->image->grid)
-    gimp_display_shell_expose_full (shell);
+  if (shell->display->image &&
+      gimp_image_get_grid (shell->display->image))
+    {
+      gimp_display_shell_expose_full (shell);
+    }
 
   SET_ACTIVE (shell->menubar_manager, "view-show-grid", show);
 
@@ -395,8 +440,11 @@
 
   g_object_set (options, "show-sample-points", show, NULL);
 
-  if (gimp_image_get_sample_points (shell->display->image))
-    gimp_display_shell_expose_full (shell);
+  if (shell->display->image &&
+      gimp_image_get_sample_points (shell->display->image))
+    {
+      gimp_display_shell_expose_full (shell);
+    }
 
   SET_ACTIVE (shell->menubar_manager, "view-show-sample-points", show);
 

Modified: trunk/app/display/gimpdisplayshell-appearance.h
==============================================================================
--- trunk/app/display/gimpdisplayshell-appearance.h	(original)
+++ trunk/app/display/gimpdisplayshell-appearance.h	Tue Mar 18 22:21:47 2008
@@ -20,6 +20,8 @@
 #define __GIMP_DISPLAY_SHELL_APPEARANCE_H__
 
 
+void       gimp_display_shell_appearance_update      (GimpDisplayShell *shell);
+
 void       gimp_display_shell_set_fullscreen         (GimpDisplayShell *shell,
                                                       gboolean          fullscreen);
 gboolean   gimp_display_shell_get_fullscreen         (GimpDisplayShell *shell);

Modified: trunk/app/display/gimpdisplayshell-callbacks.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-callbacks.c	(original)
+++ trunk/app/display/gimpdisplayshell-callbacks.c	Tue Mar 18 22:21:47 2008
@@ -210,7 +210,6 @@
     case GDK_WINDOW_STATE:
       {
         GdkEventWindowState *sevent = (GdkEventWindowState *) event;
-        GimpDisplayOptions  *options;
         gboolean             fullscreen;
         GimpActionGroup     *group;
 
@@ -221,32 +220,7 @@
 
         fullscreen = gimp_display_shell_get_fullscreen (shell);
 
-        gtk_widget_set_name (GTK_WIDGET (shell->menubar),
-                             fullscreen ? "gimp-menubar-fullscreen" : NULL);
-
-        options = fullscreen ? shell->fullscreen_options : shell->options;
-
-        gimp_display_shell_set_show_menubar       (shell,
-                                                   options->show_menubar);
-        gimp_display_shell_set_show_rulers        (shell,
-                                                   options->show_rulers);
-        gimp_display_shell_set_show_scrollbars    (shell,
-                                                   options->show_scrollbars);
-        gimp_display_shell_set_show_statusbar     (shell,
-                                                   options->show_statusbar);
-        gimp_display_shell_set_show_selection     (shell,
-                                                   options->show_selection);
-        gimp_display_shell_set_show_layer         (shell,
-                                                   options->show_layer_boundary);
-        gimp_display_shell_set_show_guides        (shell,
-                                                   options->show_guides);
-        gimp_display_shell_set_show_grid          (shell,
-                                                   options->show_grid);
-        gimp_display_shell_set_show_sample_points (shell,
-                                                   options->show_sample_points);
-        gimp_display_shell_set_padding            (shell,
-                                                   options->padding_mode,
-                                                   &options->padding_color);
+        gimp_display_shell_appearance_update (shell);
 
         group = gimp_ui_manager_get_action_group (shell->menubar_manager,
                                                   "view");

Modified: trunk/app/display/gimpdisplayshell-close.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-close.c	(original)
+++ trunk/app/display/gimpdisplayshell-close.c	Tue Mar 18 22:21:47 2008
@@ -42,6 +42,7 @@
 
 #include "gimpdisplay.h"
 #include "gimpdisplayshell.h"
+#include "gimpdisplayshell-appearance.h"
 #include "gimpdisplayshell-close.h"
 #include "gimpdisplayshell-cursor.h"
 #include "gimpdisplayshell-scale.h"
@@ -330,6 +331,8 @@
 
       if (shell->display == gimp_context_get_display (user_context))
         gimp_ui_manager_update (shell->popup_manager, shell->display);
+
+      gimp_display_shell_appearance_update (shell);
     }
 }
 

Modified: trunk/app/display/gimpdisplayshell-selection.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-selection.c	(original)
+++ trunk/app/display/gimpdisplayshell-selection.c	Tue Mar 18 22:21:47 2008
@@ -205,7 +205,7 @@
 {
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
 
-  if (shell->selection)
+  if (shell->selection && shell->display->image)
     {
       Selection *selection = shell->selection;
 
@@ -227,7 +227,7 @@
 {
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
 
-  if (shell->selection)
+  if (shell->selection && shell->display->image)
     {
       Selection *selection = shell->selection;
 

Modified: trunk/app/display/gimpdisplayshell.c
==============================================================================
--- trunk/app/display/gimpdisplayshell.c	(original)
+++ trunk/app/display/gimpdisplayshell.c	Tue Mar 18 22:21:47 2008
@@ -315,6 +315,7 @@
 
   shell->options                = g_object_new (GIMP_TYPE_DISPLAY_OPTIONS, NULL);
   shell->fullscreen_options     = g_object_new (GIMP_TYPE_DISPLAY_OPTIONS_FULLSCREEN, NULL);
+  shell->no_image_options       = g_object_new (GIMP_TYPE_DISPLAY_OPTIONS_NO_IMAGE, NULL);
 
   shell->space_pressed          = FALSE;
   shell->space_release_pending  = FALSE;
@@ -384,6 +385,9 @@
   if (shell->fullscreen_options)
     g_object_unref (shell->fullscreen_options);
 
+  if (shell->no_image_options)
+    g_object_unref (shell->no_image_options);
+
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 

Modified: trunk/app/display/gimpdisplayshell.h
==============================================================================
--- trunk/app/display/gimpdisplayshell.h	(original)
+++ trunk/app/display/gimpdisplayshell.h	Tue Mar 18 22:21:47 2008
@@ -169,6 +169,7 @@
 
   GimpDisplayOptions *options;
   GimpDisplayOptions *fullscreen_options;
+  GimpDisplayOptions *no_image_options;
 
   /*  the state of gimp_display_shell_tool_events()  */
   gboolean          space_pressed;

Modified: trunk/app/gui/gui-vtable.c
==============================================================================
--- trunk/app/gui/gui-vtable.c	(original)
+++ trunk/app/gui/gui-vtable.c	Tue Mar 18 22:21:47 2008
@@ -59,6 +59,7 @@
 #include "display/gimpdisplay.h"
 #include "display/gimpdisplay-foreach.h"
 #include "display/gimpdisplayshell.h"
+#include "display/gimpdisplayshell-appearance.h"
 #include "display/gimpdisplayshell-scale.h"
 
 #include "actions/plug-in-actions.h"
@@ -301,6 +302,7 @@
       gimp_display_shell_set_unit (GIMP_DISPLAY_SHELL (display->shell), unit);
       gimp_display_shell_scale (GIMP_DISPLAY_SHELL (display->shell),
                                 GIMP_ZOOM_TO, scale);
+      gimp_display_shell_appearance_update (GIMP_DISPLAY_SHELL (display->shell));
 
       if (gimp_context_get_display (context) == display)
         {



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