add new options object for the "no image" display appearance.

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.


svn path=/trunk/; revision=25114
This commit is contained in:
Michael Natterer 2008-03-18 22:21:47 +00:00 committed by Michael Natterer
parent cee3baea0f
commit bd636468e8
12 changed files with 162 additions and 50 deletions

View File

@ -1,3 +1,29 @@
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.
2008-03-18 Michael Natterer <mitch@gimp.org>
First draft of the "no image open" window, which is implemented as

View File

@ -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);

View File

@ -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)
{

View File

@ -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__ */

View File

@ -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) \
(shell->display->image ? \
(gimp_display_shell_get_fullscreen (shell) ? \
shell->fullscreen_options : shell->options)
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))
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)
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))
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);

View File

@ -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);

View File

@ -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");

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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;

View File

@ -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)
{