From bd636468e86567c68c990fe3bbb0481b89542c1c Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Tue, 18 Mar 2008 22:21:47 +0000 Subject: [PATCH] add new options object for the "no image" display appearance. 2008-03-18 Michael Natterer * 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. svn path=/trunk/; revision=25114 --- ChangeLog | 26 +++++++++ app/actions/view-actions.c | 22 ++++---- app/display/gimpdisplayoptions.c | 54 +++++++++++++++++-- app/display/gimpdisplayoptions.h | 2 + app/display/gimpdisplayshell-appearance.c | 64 ++++++++++++++++++++--- app/display/gimpdisplayshell-appearance.h | 2 + app/display/gimpdisplayshell-callbacks.c | 28 +--------- app/display/gimpdisplayshell-close.c | 3 ++ app/display/gimpdisplayshell-selection.c | 4 +- app/display/gimpdisplayshell.c | 4 ++ app/display/gimpdisplayshell.h | 1 + app/gui/gui-vtable.c | 2 + 12 files changed, 162 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0b591d6c91..143981006c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +2008-03-18 Michael Natterer + + * 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. + 2008-03-18 Michael Natterer First draft of the "no image open" window, which is implemented as diff --git a/app/actions/view-actions.c b/app/actions/view-actions.c index 04444f5748..fafc05d340 100644 --- a/app/actions/view-actions.c +++ b/app/actions/view-actions.c @@ -545,7 +545,9 @@ view_actions_update (GimpActionGroup *group, 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 @@ view_actions_update (GimpActionGroup *group, 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 @@ view_actions_update (GimpActionGroup *group, } } - 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); diff --git a/app/display/gimpdisplayoptions.c b/app/display/gimpdisplayoptions.c index d6b5c7f1fa..d38b478120 100644 --- a/app/display/gimpdisplayoptions.c +++ b/app/display/gimpdisplayoptions.c @@ -80,6 +80,16 @@ G_DEFINE_TYPE_WITH_CODE (GimpDisplayOptionsFullscreen, 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) @@ -197,6 +207,44 @@ gimp_display_options_fullscreen_class_init (GimpDisplayOptionsFullscreenClass *k GIMP_PARAM_STATIC_STRINGS); } +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) { @@ -255,9 +303,9 @@ gimp_display_options_set_property (GObject *object, 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); diff --git a/app/display/gimpdisplayoptions.h b/app/display/gimpdisplayoptions.h index 34e7c4d38b..9f7b2afbe9 100644 --- a/app/display/gimpdisplayoptions.h +++ b/app/display/gimpdisplayoptions.h @@ -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 @@ struct _GimpDisplayOptionsClass 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__ */ diff --git a/app/display/gimpdisplayshell-appearance.c b/app/display/gimpdisplayshell-appearance.c index 11e0384873..ecfabdce8b 100644 --- a/app/display/gimpdisplayshell-appearance.c +++ b/app/display/gimpdisplayshell-appearance.c @@ -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 = \ @@ -65,6 +68,42 @@ ((shell)->display->gimp))) +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 @@ gimp_display_shell_set_show_guides (GimpDisplayShell *shell, 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 @@ gimp_display_shell_set_show_grid (GimpDisplayShell *shell, 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 @@ gimp_display_shell_set_show_sample_points (GimpDisplayShell *shell, 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); diff --git a/app/display/gimpdisplayshell-appearance.h b/app/display/gimpdisplayshell-appearance.h index fabc0be04b..26800c00e7 100644 --- a/app/display/gimpdisplayshell-appearance.h +++ b/app/display/gimpdisplayshell-appearance.h @@ -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); diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c index acf9a19e9a..8ac5db8ca1 100644 --- a/app/display/gimpdisplayshell-callbacks.c +++ b/app/display/gimpdisplayshell-callbacks.c @@ -210,7 +210,6 @@ gimp_display_shell_events (GtkWidget *widget, case GDK_WINDOW_STATE: { GdkEventWindowState *sevent = (GdkEventWindowState *) event; - GimpDisplayOptions *options; gboolean fullscreen; GimpActionGroup *group; @@ -221,32 +220,7 @@ gimp_display_shell_events (GtkWidget *widget, 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"); diff --git a/app/display/gimpdisplayshell-close.c b/app/display/gimpdisplayshell-close.c index 4ce50e1ee0..33979e6fb2 100644 --- a/app/display/gimpdisplayshell-close.c +++ b/app/display/gimpdisplayshell-close.c @@ -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 @@ gimp_display_shell_really_close (GimpDisplayShell *shell) if (shell->display == gimp_context_get_display (user_context)) gimp_ui_manager_update (shell->popup_manager, shell->display); + + gimp_display_shell_appearance_update (shell); } } diff --git a/app/display/gimpdisplayshell-selection.c b/app/display/gimpdisplayshell-selection.c index 9bf53a9aa8..55802af119 100644 --- a/app/display/gimpdisplayshell-selection.c +++ b/app/display/gimpdisplayshell-selection.c @@ -205,7 +205,7 @@ gimp_display_shell_selection_set_hidden (GimpDisplayShell *shell, { 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 @@ gimp_display_shell_selection_layer_set_hidden (GimpDisplayShell *shell, { g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); - if (shell->selection) + if (shell->selection && shell->display->image) { Selection *selection = shell->selection; diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c index 93b81de164..f7f284ba78 100644 --- a/app/display/gimpdisplayshell.c +++ b/app/display/gimpdisplayshell.c @@ -315,6 +315,7 @@ gimp_display_shell_init (GimpDisplayShell *shell) 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 @@ gimp_display_shell_finalize (GObject *object) 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); } diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h index e2743406bf..a27ec00510 100644 --- a/app/display/gimpdisplayshell.h +++ b/app/display/gimpdisplayshell.h @@ -169,6 +169,7 @@ struct _GimpDisplayShell GimpDisplayOptions *options; GimpDisplayOptions *fullscreen_options; + GimpDisplayOptions *no_image_options; /* the state of gimp_display_shell_tool_events() */ gboolean space_pressed; diff --git a/app/gui/gui-vtable.c b/app/gui/gui-vtable.c index 6b8f97c876..2f071e22d0 100644 --- a/app/gui/gui-vtable.c +++ b/app/gui/gui-vtable.c @@ -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 @@ gui_display_create (Gimp *gimp, 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) { -- GitLab