changed the "parent context" implementation:

1999-10-19  Michael Natterer  <mitch@gimp.org>

	* gimpcontext.[ch]: changed the "parent context" implementation:

	- Automatically connect/disconnect the "*_changed" signals when
	  changing the parent and when setting the "defined" flag of the
	  attributes.
	- Store the former *_defined booleans in a single guint32.
	- Added generic functions to set the "defined" flags of the
	  attributes and to copy attributes between contexts.

	The contexts now correctly handle disappearing images and
	displays, so we don't have to explicitly reset them any more.

	* context_manager.[ch]: adopted to the changed context
	implementation, connect to the user context's "tool_changed"
	signal to switch the per-tool contexts, don't connect to the
	"removed" signal of the image context.

	* brush_select.c
	* tool_options.c: use LayerModeEffects instead of int when calling
	gimp_context_set_paint_mode().

	* gdisplay.c: no need to reset the active display when deleting it
	because the context connects to the "destroy" signal of the shell
	now.

	* menus.c: a shortcut for the navigation window. Moved
	<Image>/Image/Colors/Desaturate before the separator.

	* tools.c: tools_select(): set the active tool of the user context
	instead of calling a special context manager function.
This commit is contained in:
Michael Natterer 1999-10-19 15:52:32 +00:00 committed by Michael Natterer
parent fc8549b9cb
commit b74d256981
21 changed files with 1385 additions and 813 deletions

View File

@ -1,3 +1,36 @@
1999-10-19 Michael Natterer <mitch@gimp.org>
* gimpcontext.[ch]: changed the "parent context" implementation:
- Automatically connect/disconnect the "*_changed" signals when
changing the parent and when setting the "defined" flag of the
attributes.
- Store the former *_defined booleans in a single guint32.
- Added generic functions to set the "defined" flags of the
attributes and to copy attributes between contexts.
The contexts now correctly handle disappearing images and
displays, so we don't have to explicitly reset them any more.
* context_manager.[ch]: adopted to the changed context
implementation, connect to the user context's "tool_changed"
signal to switch the per-tool contexts, don't connect to the
"removed" signal of the image context.
* brush_select.c
* tool_options.c: use LayerModeEffects instead of int when calling
gimp_context_set_paint_mode().
* gdisplay.c: no need to reset the active display when deleting it
because the context connects to the "destroy" signal of the shell
now.
* menus.c: a shortcut for the navigation window. Moved
<Image>/Image/Colors/Desaturate before the separator.
* tools.c: tools_select(): set the active tool of the user context
instead of calling a special context manager function.
Thu Oct 19 05:57:10 BST 1999 Nick Lamb <njl195@zepler.org>
* app/plug_in.h
@ -37,7 +70,8 @@ Mon Oct 18 21:24:47 BST 1999 Andy Thomas <alt@gimp.org>
not on the curve the "new point" option will become selected and the
new point will be added.
2) The "new point" option is defaulted to on when a new image is created or a new image is selected from the image menu.
2) The "new point" option is defaulted to on when a new image is
created or a new image is selected from the image menu.
3) Move and flip tool now effect the path if it is locked.

View File

@ -1627,7 +1627,7 @@ paint_mode_menu_callback (GtkWidget *widget,
if (bsp == brush_select_dialog)
{
gimp_context_set_paint_mode (gimp_context_get_user (),
(int) data);
(LayerModeEffects) data);
}
else
{

View File

@ -15,16 +15,13 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "context_manager.h"
#include "appenv.h"
#include "gdisplay.h"
#include "gimprc.h"
#include "paint_options.h"
#include "tools.h"
static GimpContext * global_user_context;
static GimpContext * global_tool_context;
static void
@ -35,48 +32,74 @@ context_manager_display_changed (GimpContext *context,
gdisplay_set_menu_sensitivity (display);
}
/* FIXME: finally, install callbacks for all created contexts to prevent
* the image from appearing without notifying us
*/
static void
context_manager_image_removed (GimpSet *set,
GimpImage *gimage,
GimpContext *user_context)
context_manager_tool_changed (GimpContext *context,
ToolType tool_type,
gpointer data)
{
if (gimp_context_get_image (user_context) == gimage)
gimp_context_set_image (user_context, NULL);
GimpContext* tool_context;
if (! global_paint_options)
{
if (active_tool &&
(tool_context = tool_info[active_tool->type].tool_context))
{
gimp_context_unset_parent (tool_context);
}
if ((tool_context = tool_info[tool_type].tool_context))
{
gimp_context_copy_args (tool_context, gimp_context_get_user (),
GIMP_CONTEXT_PAINT_ARGS_MASK);
gimp_context_set_parent (tool_context, gimp_context_get_user ());
}
}
}
void
context_manager_init (void)
{
GimpContext *context;
GimpContext *standard_context;
GimpContext *default_context;
GimpContext *user_context;
gint i;
/* Implicitly create the standard context */
context = gimp_context_get_standard ();
standard_context = gimp_context_get_standard ();
/* TODO: load from disk */
context = gimp_context_new ("Default", NULL, NULL);
gimp_context_set_default (context);
default_context = gimp_context_new ("Default", NULL);
gimp_context_set_default (default_context);
/* Finally the user context will be initialized with the default context's
* values.
*/
context = gimp_context_new ("User", NULL, NULL);
gimp_context_set_user (context);
gimp_context_set_current (context);
/* Initialize the user context will with the default context's values */
user_context = gimp_context_new ("User", default_context);
gimp_context_set_user (user_context);
global_user_context = gimp_context_new ("Don't use :)", NULL, context);
gtk_signal_connect (GTK_OBJECT (context), "display_changed",
/* Update the tear-off menus */
gtk_signal_connect (GTK_OBJECT (user_context), "display_changed",
GTK_SIGNAL_FUNC (context_manager_display_changed),
NULL);
gtk_signal_connect (GTK_OBJECT (image_context), "remove",
GTK_SIGNAL_FUNC (context_manager_image_removed),
context);
/* Initialize the tools' contexts */
/* Update the per-tool paint options */
gtk_signal_connect (GTK_OBJECT (user_context), "tool_changed",
GTK_SIGNAL_FUNC (context_manager_tool_changed),
NULL);
/* Make the user contect the currently active context */
gimp_context_set_current (user_context);
/* Create a context to store the paint options of the
* global paint options mode
*/
global_tool_context = gimp_context_new ("Global Tool Context", user_context);
/* TODO: add foreground, background, brush, pattern, gradient */
gimp_context_define_args (global_tool_context,
GIMP_CONTEXT_OPACITY_MASK |
GIMP_CONTEXT_PAINT_MODE_MASK,
FALSE);
/* Initialize the paint tools' private contexts */
for (i = 0; i < num_tools; i++)
{
switch (tool_info[i].tool_id)
@ -93,7 +116,7 @@ context_manager_init (void)
case DODGEBURN:
case SMUDGE:
tool_info[i].tool_context =
gimp_context_new (tool_info[i].private_tip, NULL, context);
gimp_context_new (tool_info[i].private_tip, global_tool_context);
break;
default:
@ -101,6 +124,13 @@ context_manager_init (void)
break;
}
}
if (! global_paint_options &&
active_tool && tool_info[active_tool->type].tool_context)
gimp_context_set_parent (tool_info[active_tool->type].tool_context,
user_context);
else if (global_paint_options)
gimp_context_set_parent (global_tool_context, user_context);
}
void
@ -108,6 +138,9 @@ context_manager_free (void)
{
gint i;
gtk_object_unref (GTK_OBJECT (global_tool_context));
global_tool_context = NULL;
for (i = 0; i < num_tools; i++)
{
if (tool_info[i].tool_context != NULL)
@ -131,6 +164,8 @@ context_manager_set_global_paint_options (gboolean global)
{
GimpContext* context;
if (global == global_paint_options) return;
paint_options_set_global (global);
if (global)
@ -138,60 +173,23 @@ context_manager_set_global_paint_options (gboolean global)
if (active_tool &&
(context = tool_info[active_tool->type].tool_context))
{
gimp_context_define_opacity (context, TRUE);
gimp_context_define_paint_mode (context, TRUE);
gimp_context_unset_parent (context);
}
gimp_context_set_opacity (gimp_context_get_user (),
gimp_context_get_opacity (global_user_context));
gimp_context_set_paint_mode (gimp_context_get_user (),
gimp_context_get_paint_mode (global_user_context));
gimp_context_define_opacity (global_user_context, FALSE);
gimp_context_define_paint_mode (global_user_context, FALSE);
gimp_context_copy_args (global_tool_context, gimp_context_get_user (),
GIMP_CONTEXT_PAINT_ARGS_MASK);
gimp_context_set_parent (global_tool_context, gimp_context_get_user ());
}
else
{
gimp_context_define_opacity (global_user_context, TRUE);
gimp_context_define_paint_mode (global_user_context, TRUE);
gimp_context_unset_parent (global_tool_context);
if (active_tool &&
(context = tool_info[active_tool->type].tool_context))
{
gimp_context_set_opacity (gimp_context_get_user (),
gimp_context_get_opacity (context));
gimp_context_set_paint_mode (gimp_context_get_user (),
gimp_context_get_paint_mode (context));
gimp_context_define_opacity (context, FALSE);
gimp_context_define_paint_mode (context, FALSE);
}
}
}
void
context_manager_set_tool (ToolType tool_type)
{
GimpContext* context;
if (! global_paint_options)
{
if (active_tool &&
(context = tool_info[active_tool->type].tool_context))
{
gimp_context_define_opacity (context, TRUE);
gimp_context_define_paint_mode (context, TRUE);
}
if ((context = tool_info[tool_type].tool_context))
{
gimp_context_set_opacity (gimp_context_get_user (),
gimp_context_get_opacity (context));
gimp_context_set_paint_mode (gimp_context_get_user (),
gimp_context_get_paint_mode (context));
gimp_context_define_opacity (context, FALSE);
gimp_context_define_paint_mode (context, FALSE);
gimp_context_copy_args (context, gimp_context_get_user (),
GIMP_CONTEXT_PAINT_ARGS_MASK);
gimp_context_set_parent (context, gimp_context_get_user ());
}
}
}

View File

@ -25,6 +25,5 @@ void context_manager_init (void);
void context_manager_free (void);
void context_manager_set_global_paint_options (gboolean global);
void context_manager_set_tool (ToolType tool_type);
#endif /* __CONTEXT_MANAGER_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,8 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcontext.h: Copyright (C) 1999 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@ -37,31 +39,45 @@
typedef enum
{
GIMP_CONTEXT_ARG_IMAGE = 1 << 0,
GIMP_CONTEXT_ARG_DISPLAY = 1 << 1,
GIMP_CONTEXT_ARG_TOOL = 1 << 2,
GIMP_CONTEXT_ARG_FOREGROUND = 1 << 3,
GIMP_CONTEXT_ARG_BACKGROUND = 1 << 4,
GIMP_CONTEXT_ARG_OPACITY = 1 << 5,
GIMP_CONTEXT_ARG_PAINT_MODE = 1 << 6,
GIMP_CONTEXT_ARG_BRUSH = 1 << 7,
GIMP_CONTEXT_ARG_PATTERN = 1 << 8,
GIMP_CONTEXT_ARG_GRADIENT = 1 << 9,
/* aliases
*/
GIMP_CONTEXT_ARG_PAINT = GIMP_CONTEXT_ARG_FOREGROUND |
GIMP_CONTEXT_ARG_BACKGROUND |
GIMP_CONTEXT_ARG_OPACITY |
GIMP_CONTEXT_ARG_PAINT_MODE |
GIMP_CONTEXT_ARG_BRUSH |
GIMP_CONTEXT_ARG_PATTERN |
GIMP_CONTEXT_ARG_GRADIENT,
GIMP_CONTEXT_ARG_ALL = GIMP_CONTEXT_ARG_IMAGE |
GIMP_CONTEXT_ARG_DISPLAY |
GIMP_CONTEXT_ARG_TOOL |
GIMP_CONTEXT_ARG_PAINT
} GimpContextArgs;
GIMP_CONTEXT_ARG_IMAGE,
GIMP_CONTEXT_ARG_DISPLAY,
GIMP_CONTEXT_ARG_TOOL,
GIMP_CONTEXT_ARG_FOREGROUND,
GIMP_CONTEXT_ARG_BACKGROUND,
GIMP_CONTEXT_ARG_OPACITY,
GIMP_CONTEXT_ARG_PAINT_MODE,
GIMP_CONTEXT_ARG_BRUSH,
GIMP_CONTEXT_ARG_PATTERN,
GIMP_CONTEXT_ARG_GRADIENT,
GIMP_CONTEXT_NUM_ARGS
} GimpContextArgType;
typedef enum
{
GIMP_CONTEXT_IMAGE_MASK = 1 << 0,
GIMP_CONTEXT_DISPLAY_MASK = 1 << 1,
GIMP_CONTEXT_TOOL_MASK = 1 << 2,
GIMP_CONTEXT_FOREGROUND_MASK = 1 << 3,
GIMP_CONTEXT_BACKGROUND_MASK = 1 << 4,
GIMP_CONTEXT_OPACITY_MASK = 1 << 5,
GIMP_CONTEXT_PAINT_MODE_MASK = 1 << 6,
GIMP_CONTEXT_BRUSH_MASK = 1 << 7,
GIMP_CONTEXT_PATTERN_MASK = 1 << 8,
GIMP_CONTEXT_GRADIENT_MASK = 1 << 9,
/* aliases */
GIMP_CONTEXT_PAINT_ARGS_MASK = GIMP_CONTEXT_FOREGROUND_MASK |
GIMP_CONTEXT_BACKGROUND_MASK |
GIMP_CONTEXT_OPACITY_MASK |
GIMP_CONTEXT_PAINT_MODE_MASK |
GIMP_CONTEXT_BRUSH_MASK |
GIMP_CONTEXT_PATTERN_MASK |
GIMP_CONTEXT_GRADIENT_MASK,
GIMP_CONTEXT_ALL_ARGS_MASK = GIMP_CONTEXT_IMAGE_MASK |
GIMP_CONTEXT_DISPLAY_MASK |
GIMP_CONTEXT_TOOL_MASK |
GIMP_CONTEXT_PAINT_ARGS_MASK
} GimpContextArgMask;
typedef struct _GimpContext GimpContext;
typedef struct _GimpContextClass GimpContextClass;
@ -73,37 +89,21 @@ struct _GimpContext
gchar *name;
GimpContext *parent;
/* FIXME: the solution of having a boolean for each attribute and the
* name "defined" need some brainstorming
*/
gboolean image_defined;
GimpImage *image;
guint32 defined_args;
gboolean display_defined;
GimpImage *image;
GDisplay *display;
gboolean tool_defined;
ToolType tool;
gboolean foreground_defined;
guchar foreground[3];
gboolean background_defined;
guchar background[3];
gboolean opacity_defined;
gdouble opacity;
gboolean paint_mode_defined;
LayerModeEffects paint_mode;
gboolean brush_defined;
GimpBrush *brush;
gboolean pattern_defined;
GPattern *pattern;
gboolean gradient_defined;
gradient_t *gradient;
};
@ -141,12 +141,9 @@ struct _GimpContextClass
GtkType gimp_context_get_type (void);
GimpContext * gimp_context_new (gchar *name,
GimpContext *template,
GimpContext *parent);
GimpContext *template);
/* TODO: - gimp_context_set_parent ()
* - gimp_context_get_parent ()
* - gimp_context_find ()
/* TODO: - gimp_context_find ()
*
* probably interacting with the context manager:
* - gimp_context_push () which will call gimp_context_set_parent()
@ -174,45 +171,55 @@ GimpContext * gimp_context_get_default (void);
GimpContext * gimp_context_get_standard (void);
/* functions for manipulating a single context
*
* FIXME: this interface may be ok but the implementation is
* ugly code duplication. There needs to be a generic way.
*/
gchar * gimp_context_get_name (GimpContext *context);
gchar * gimp_context_get_name (GimpContext *context);
GimpContext * gimp_context_get_parent (GimpContext *context);
void gimp_context_set_parent (GimpContext *context,
GimpContext *parent);
GimpContext * gimp_context_get_parent (GimpContext *context);
void gimp_context_set_parent (GimpContext *context,
GimpContext *parent);
void gimp_context_unset_parent (GimpContext *context);
/* define / undefinine context arguments
*
* the value of an undefined argument will be taken from the parent context.
*/
void gimp_context_define_arg (GimpContext *context,
GimpContextArgType arg,
gboolean defined);
gboolean gimp_context_arg_defined (GimpContext *context,
GimpContextArgType arg);
void gimp_context_define_args (GimpContext *context,
guint32 args_mask,
gboolean defined);
/* copying context arguments
*/
void gimp_context_copy_arg (GimpContext *src,
GimpContext *dest,
GimpContextArgType arg);
void gimp_context_copy_args (GimpContext *src,
GimpContext *dest,
GimpContextArgMask args_mask);
/* image */
GimpImage * gimp_context_get_image (GimpContext *context);
void gimp_context_set_image (GimpContext *context,
GimpImage *image);
gboolean gimp_context_image_defined (GimpContext *context);
void gimp_context_define_image (GimpContext *context,
gboolean defined);
/* display */
GDisplay * gimp_context_get_display (GimpContext *context);
void gimp_context_set_display (GimpContext *context,
GDisplay *display);
gboolean gimp_context_display_defined (GimpContext *context);
void gimp_context_define_display (GimpContext *context,
gboolean defined);
/* tool */
ToolType gimp_context_get_tool (GimpContext *context);
void gimp_context_set_tool (GimpContext *context,
ToolType tool_type);
gboolean gimp_context_tool_defined (GimpContext *context);
void gimp_context_define_tool (GimpContext *context,
gboolean defined);
/* foreground color */
void gimp_context_get_foreground (GimpContext *context,
guchar *r,
guchar *g,
@ -221,12 +228,8 @@ void gimp_context_set_foreground (GimpContext *context,
gint r,
gint g,
gint b);
gboolean gimp_context_foreground_defined (GimpContext *context);
void gimp_context_define_foreground (GimpContext *context,
gboolean defined);
/* background color */
void gimp_context_get_background (GimpContext *context,
guchar *r,
guchar *g,
@ -235,53 +238,30 @@ void gimp_context_set_background (GimpContext *context,
gint r,
gint g,
gint b);
gboolean gimp_context_background_defined (GimpContext *context);
void gimp_context_define_background (GimpContext *context,
gboolean defined);
/* opacity */
gdouble gimp_context_get_opacity (GimpContext *context);
void gimp_context_set_opacity (GimpContext *context,
gdouble opacity);
gboolean gimp_context_opacity_defined (GimpContext *context);
void gimp_context_define_opacity (GimpContext *context,
gboolean defined);
/* paint mode */
LayerModeEffects gimp_context_get_paint_mode (GimpContext *context);
void gimp_context_set_paint_mode (GimpContext *context,
LayerModeEffects paint_mode);
gboolean gimp_context_paint_mode_defined (GimpContext *context);
void gimp_context_define_paint_mode (GimpContext *context,
gboolean defined);
/* brush */
GimpBrush * gimp_context_get_brush (GimpContext *context);
void gimp_context_set_brush (GimpContext *context,
GimpBrush *brush);
gboolean gimp_context_brush_defined (GimpContext *context);
void gimp_context_define_brush (GimpContext *context,
gboolean defined);
/* pattern */
GPattern * gimp_context_get_pattern (GimpContext *context);
void gimp_context_set_pattern (GimpContext *context,
GPattern *pattern);
gboolean gimp_context_pattern_defined (GimpContext *context);
void gimp_context_define_pattern (GimpContext *context,
gboolean defined);
/* gradient */
gradient_t * gimp_context_get_gradient (GimpContext *context);
void gimp_context_set_gradient (GimpContext *context,
gradient_t *gradient);
gboolean gimp_context_gradient_defined (GimpContext *context);
void gimp_context_define_gradient (GimpContext *context,
gboolean defined);
#endif /* __GIMP_CONTEXT_H__ */

View File

@ -313,8 +313,6 @@ gdisplay_format_title (GDisplay *gdisp,
static void
gdisplay_delete (GDisplay *gdisp)
{
GimpContext *context;
g_hash_table_remove (display_ht, gdisp->shell);
g_hash_table_remove (display_ht, gdisp->canvas);
@ -369,11 +367,6 @@ gdisplay_delete (GDisplay *gdisp)
if (gdisp->nav_popup)
nav_popup_free(gdisp->nav_popup);
/* set the active display to NULL if it was this display */
context = gimp_context_get_user ();
if (gimp_context_get_display (context) == gdisp)
gimp_context_set_display (context, NULL);
gtk_widget_unref (gdisp->shell);
g_free (gdisp);

View File

@ -106,7 +106,7 @@ tool_options_paint_mode_update (GtkWidget *widget,
context = (GimpContext *) gtk_object_get_user_data (GTK_OBJECT (widget));
gimp_context_set_paint_mode (GIMP_CONTEXT (context),
(long) data);
(LayerModeEffects) data);
}
void

View File

@ -313,8 +313,6 @@ gdisplay_format_title (GDisplay *gdisp,
static void
gdisplay_delete (GDisplay *gdisp)
{
GimpContext *context;
g_hash_table_remove (display_ht, gdisp->shell);
g_hash_table_remove (display_ht, gdisp->canvas);
@ -369,11 +367,6 @@ gdisplay_delete (GDisplay *gdisp)
if (gdisp->nav_popup)
nav_popup_free(gdisp->nav_popup);
/* set the active display to NULL if it was this display */
context = gimp_context_get_user ();
if (gimp_context_get_display (context) == gdisp)
gimp_context_set_display (context, NULL);
gtk_widget_unref (gdisp->shell);
g_free (gdisp);

View File

@ -313,8 +313,6 @@ gdisplay_format_title (GDisplay *gdisp,
static void
gdisplay_delete (GDisplay *gdisp)
{
GimpContext *context;
g_hash_table_remove (display_ht, gdisp->shell);
g_hash_table_remove (display_ht, gdisp->canvas);
@ -369,11 +367,6 @@ gdisplay_delete (GDisplay *gdisp)
if (gdisp->nav_popup)
nav_popup_free(gdisp->nav_popup);
/* set the active display to NULL if it was this display */
context = gimp_context_get_user ();
if (gimp_context_get_display (context) == gdisp)
gimp_context_set_display (context, NULL);
gtk_widget_unref (gdisp->shell);
g_free (gdisp);

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,8 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcontext.h: Copyright (C) 1999 Michael Natterer <mitch@gimp.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@ -37,31 +39,45 @@
typedef enum
{
GIMP_CONTEXT_ARG_IMAGE = 1 << 0,
GIMP_CONTEXT_ARG_DISPLAY = 1 << 1,
GIMP_CONTEXT_ARG_TOOL = 1 << 2,
GIMP_CONTEXT_ARG_FOREGROUND = 1 << 3,
GIMP_CONTEXT_ARG_BACKGROUND = 1 << 4,
GIMP_CONTEXT_ARG_OPACITY = 1 << 5,
GIMP_CONTEXT_ARG_PAINT_MODE = 1 << 6,
GIMP_CONTEXT_ARG_BRUSH = 1 << 7,
GIMP_CONTEXT_ARG_PATTERN = 1 << 8,
GIMP_CONTEXT_ARG_GRADIENT = 1 << 9,
/* aliases
*/
GIMP_CONTEXT_ARG_PAINT = GIMP_CONTEXT_ARG_FOREGROUND |
GIMP_CONTEXT_ARG_BACKGROUND |
GIMP_CONTEXT_ARG_OPACITY |
GIMP_CONTEXT_ARG_PAINT_MODE |
GIMP_CONTEXT_ARG_BRUSH |
GIMP_CONTEXT_ARG_PATTERN |
GIMP_CONTEXT_ARG_GRADIENT,
GIMP_CONTEXT_ARG_ALL = GIMP_CONTEXT_ARG_IMAGE |
GIMP_CONTEXT_ARG_DISPLAY |
GIMP_CONTEXT_ARG_TOOL |
GIMP_CONTEXT_ARG_PAINT
} GimpContextArgs;
GIMP_CONTEXT_ARG_IMAGE,
GIMP_CONTEXT_ARG_DISPLAY,
GIMP_CONTEXT_ARG_TOOL,
GIMP_CONTEXT_ARG_FOREGROUND,
GIMP_CONTEXT_ARG_BACKGROUND,
GIMP_CONTEXT_ARG_OPACITY,
GIMP_CONTEXT_ARG_PAINT_MODE,
GIMP_CONTEXT_ARG_BRUSH,
GIMP_CONTEXT_ARG_PATTERN,
GIMP_CONTEXT_ARG_GRADIENT,
GIMP_CONTEXT_NUM_ARGS
} GimpContextArgType;
typedef enum
{
GIMP_CONTEXT_IMAGE_MASK = 1 << 0,
GIMP_CONTEXT_DISPLAY_MASK = 1 << 1,
GIMP_CONTEXT_TOOL_MASK = 1 << 2,
GIMP_CONTEXT_FOREGROUND_MASK = 1 << 3,
GIMP_CONTEXT_BACKGROUND_MASK = 1 << 4,
GIMP_CONTEXT_OPACITY_MASK = 1 << 5,
GIMP_CONTEXT_PAINT_MODE_MASK = 1 << 6,
GIMP_CONTEXT_BRUSH_MASK = 1 << 7,
GIMP_CONTEXT_PATTERN_MASK = 1 << 8,
GIMP_CONTEXT_GRADIENT_MASK = 1 << 9,
/* aliases */
GIMP_CONTEXT_PAINT_ARGS_MASK = GIMP_CONTEXT_FOREGROUND_MASK |
GIMP_CONTEXT_BACKGROUND_MASK |
GIMP_CONTEXT_OPACITY_MASK |
GIMP_CONTEXT_PAINT_MODE_MASK |
GIMP_CONTEXT_BRUSH_MASK |
GIMP_CONTEXT_PATTERN_MASK |
GIMP_CONTEXT_GRADIENT_MASK,
GIMP_CONTEXT_ALL_ARGS_MASK = GIMP_CONTEXT_IMAGE_MASK |
GIMP_CONTEXT_DISPLAY_MASK |
GIMP_CONTEXT_TOOL_MASK |
GIMP_CONTEXT_PAINT_ARGS_MASK
} GimpContextArgMask;
typedef struct _GimpContext GimpContext;
typedef struct _GimpContextClass GimpContextClass;
@ -73,37 +89,21 @@ struct _GimpContext
gchar *name;
GimpContext *parent;
/* FIXME: the solution of having a boolean for each attribute and the
* name "defined" need some brainstorming
*/
gboolean image_defined;
GimpImage *image;
guint32 defined_args;
gboolean display_defined;
GimpImage *image;
GDisplay *display;
gboolean tool_defined;
ToolType tool;
gboolean foreground_defined;
guchar foreground[3];
gboolean background_defined;
guchar background[3];
gboolean opacity_defined;
gdouble opacity;
gboolean paint_mode_defined;
LayerModeEffects paint_mode;
gboolean brush_defined;
GimpBrush *brush;
gboolean pattern_defined;
GPattern *pattern;
gboolean gradient_defined;
gradient_t *gradient;
};
@ -141,12 +141,9 @@ struct _GimpContextClass
GtkType gimp_context_get_type (void);
GimpContext * gimp_context_new (gchar *name,
GimpContext *template,
GimpContext *parent);
GimpContext *template);
/* TODO: - gimp_context_set_parent ()
* - gimp_context_get_parent ()
* - gimp_context_find ()
/* TODO: - gimp_context_find ()
*
* probably interacting with the context manager:
* - gimp_context_push () which will call gimp_context_set_parent()
@ -174,45 +171,55 @@ GimpContext * gimp_context_get_default (void);
GimpContext * gimp_context_get_standard (void);
/* functions for manipulating a single context
*
* FIXME: this interface may be ok but the implementation is
* ugly code duplication. There needs to be a generic way.
*/
gchar * gimp_context_get_name (GimpContext *context);
gchar * gimp_context_get_name (GimpContext *context);
GimpContext * gimp_context_get_parent (GimpContext *context);
void gimp_context_set_parent (GimpContext *context,
GimpContext *parent);
GimpContext * gimp_context_get_parent (GimpContext *context);
void gimp_context_set_parent (GimpContext *context,
GimpContext *parent);
void gimp_context_unset_parent (GimpContext *context);
/* define / undefinine context arguments
*
* the value of an undefined argument will be taken from the parent context.
*/
void gimp_context_define_arg (GimpContext *context,
GimpContextArgType arg,
gboolean defined);
gboolean gimp_context_arg_defined (GimpContext *context,
GimpContextArgType arg);
void gimp_context_define_args (GimpContext *context,
guint32 args_mask,
gboolean defined);
/* copying context arguments
*/
void gimp_context_copy_arg (GimpContext *src,
GimpContext *dest,
GimpContextArgType arg);
void gimp_context_copy_args (GimpContext *src,
GimpContext *dest,
GimpContextArgMask args_mask);
/* image */
GimpImage * gimp_context_get_image (GimpContext *context);
void gimp_context_set_image (GimpContext *context,
GimpImage *image);
gboolean gimp_context_image_defined (GimpContext *context);
void gimp_context_define_image (GimpContext *context,
gboolean defined);
/* display */
GDisplay * gimp_context_get_display (GimpContext *context);
void gimp_context_set_display (GimpContext *context,
GDisplay *display);
gboolean gimp_context_display_defined (GimpContext *context);
void gimp_context_define_display (GimpContext *context,
gboolean defined);
/* tool */
ToolType gimp_context_get_tool (GimpContext *context);
void gimp_context_set_tool (GimpContext *context,
ToolType tool_type);
gboolean gimp_context_tool_defined (GimpContext *context);
void gimp_context_define_tool (GimpContext *context,
gboolean defined);
/* foreground color */
void gimp_context_get_foreground (GimpContext *context,
guchar *r,
guchar *g,
@ -221,12 +228,8 @@ void gimp_context_set_foreground (GimpContext *context,
gint r,
gint g,
gint b);
gboolean gimp_context_foreground_defined (GimpContext *context);
void gimp_context_define_foreground (GimpContext *context,
gboolean defined);
/* background color */
void gimp_context_get_background (GimpContext *context,
guchar *r,
guchar *g,
@ -235,53 +238,30 @@ void gimp_context_set_background (GimpContext *context,
gint r,
gint g,
gint b);
gboolean gimp_context_background_defined (GimpContext *context);
void gimp_context_define_background (GimpContext *context,
gboolean defined);
/* opacity */
gdouble gimp_context_get_opacity (GimpContext *context);
void gimp_context_set_opacity (GimpContext *context,
gdouble opacity);
gboolean gimp_context_opacity_defined (GimpContext *context);
void gimp_context_define_opacity (GimpContext *context,
gboolean defined);
/* paint mode */
LayerModeEffects gimp_context_get_paint_mode (GimpContext *context);
void gimp_context_set_paint_mode (GimpContext *context,
LayerModeEffects paint_mode);
gboolean gimp_context_paint_mode_defined (GimpContext *context);
void gimp_context_define_paint_mode (GimpContext *context,
gboolean defined);
/* brush */
GimpBrush * gimp_context_get_brush (GimpContext *context);
void gimp_context_set_brush (GimpContext *context,
GimpBrush *brush);
gboolean gimp_context_brush_defined (GimpContext *context);
void gimp_context_define_brush (GimpContext *context,
gboolean defined);
/* pattern */
GPattern * gimp_context_get_pattern (GimpContext *context);
void gimp_context_set_pattern (GimpContext *context,
GPattern *pattern);
gboolean gimp_context_pattern_defined (GimpContext *context);
void gimp_context_define_pattern (GimpContext *context,
gboolean defined);
/* gradient */
gradient_t * gimp_context_get_gradient (GimpContext *context);
void gimp_context_set_gradient (GimpContext *context,
gradient_t *gradient);
gboolean gimp_context_gradient_defined (GimpContext *context);
void gimp_context_define_gradient (GimpContext *context,
gboolean defined);
#endif /* __GIMP_CONTEXT_H__ */

View File

@ -1627,7 +1627,7 @@ paint_mode_menu_callback (GtkWidget *widget,
if (bsp == brush_select_dialog)
{
gimp_context_set_paint_mode (gimp_context_get_user (),
(int) data);
(LayerModeEffects) data);
}
else
{

View File

@ -257,7 +257,7 @@ static GimpItemFactoryEntry image_entries[] =
"view/dot_for_dot.html", NULL },
{ { N_("/View/Info Window..."), "<control><shift>I", view_window_info_cmd_callback, 0 },
"view/dialogs/info_window.html", NULL },
{ { N_("/View/Nav. Window..."), NULL, view_window_nav_cmd_callback, 0 },
{ { N_("/View/Nav. Window..."), "<control><shift>N", view_window_nav_cmd_callback, 0 },
"view/dialogs/navigation_window.html", NULL },
{ { N_("/View/---"), NULL, NULL, 0, "<Separator>" },
@ -288,10 +288,10 @@ static GimpItemFactoryEntry image_entries[] =
"image/colors/equalize.html", NULL },
{ { N_("/Image/Colors/Invert"), NULL, image_invert_cmd_callback, 0 },
"image/colors/invert.html", NULL },
{ { N_("/Image/Colors/---"), NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Image/Colors/Desaturate"), NULL, image_desaturate_cmd_callback, 0 },
"image/colors/desaturate.html", NULL },
{ { N_("/Image/Colors/---"), NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Image/Channels/tearoff1"), NULL, tearoff_cmd_callback, 0, "<Tearoff>" },
NULL, NULL },

View File

@ -257,7 +257,7 @@ static GimpItemFactoryEntry image_entries[] =
"view/dot_for_dot.html", NULL },
{ { N_("/View/Info Window..."), "<control><shift>I", view_window_info_cmd_callback, 0 },
"view/dialogs/info_window.html", NULL },
{ { N_("/View/Nav. Window..."), NULL, view_window_nav_cmd_callback, 0 },
{ { N_("/View/Nav. Window..."), "<control><shift>N", view_window_nav_cmd_callback, 0 },
"view/dialogs/navigation_window.html", NULL },
{ { N_("/View/---"), NULL, NULL, 0, "<Separator>" },
@ -288,10 +288,10 @@ static GimpItemFactoryEntry image_entries[] =
"image/colors/equalize.html", NULL },
{ { N_("/Image/Colors/Invert"), NULL, image_invert_cmd_callback, 0 },
"image/colors/invert.html", NULL },
{ { N_("/Image/Colors/---"), NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Image/Colors/Desaturate"), NULL, image_desaturate_cmd_callback, 0 },
"image/colors/desaturate.html", NULL },
{ { N_("/Image/Colors/---"), NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Image/Channels/tearoff1"), NULL, tearoff_cmd_callback, 0, "<Tearoff>" },
NULL, NULL },

View File

@ -257,7 +257,7 @@ static GimpItemFactoryEntry image_entries[] =
"view/dot_for_dot.html", NULL },
{ { N_("/View/Info Window..."), "<control><shift>I", view_window_info_cmd_callback, 0 },
"view/dialogs/info_window.html", NULL },
{ { N_("/View/Nav. Window..."), NULL, view_window_nav_cmd_callback, 0 },
{ { N_("/View/Nav. Window..."), "<control><shift>N", view_window_nav_cmd_callback, 0 },
"view/dialogs/navigation_window.html", NULL },
{ { N_("/View/---"), NULL, NULL, 0, "<Separator>" },
@ -288,10 +288,10 @@ static GimpItemFactoryEntry image_entries[] =
"image/colors/equalize.html", NULL },
{ { N_("/Image/Colors/Invert"), NULL, image_invert_cmd_callback, 0 },
"image/colors/invert.html", NULL },
{ { N_("/Image/Colors/---"), NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Image/Colors/Desaturate"), NULL, image_desaturate_cmd_callback, 0 },
"image/colors/desaturate.html", NULL },
{ { N_("/Image/Colors/---"), NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Image/Channels/tearoff1"), NULL, tearoff_cmd_callback, 0, "<Tearoff>" },
NULL, NULL },

View File

@ -106,7 +106,7 @@ tool_options_paint_mode_update (GtkWidget *widget,
context = (GimpContext *) gtk_object_get_user_data (GTK_OBJECT (widget));
gimp_context_set_paint_mode (GIMP_CONTEXT (context),
(long) data);
(LayerModeEffects) data);
}
void

View File

@ -696,8 +696,11 @@ active_tool_free (void)
void
tools_select (ToolType tool_type)
{
/* Care for switching to the tool's private context */
context_manager_set_tool (tool_type);
/* Care for switching to the tool's private context _before_ actually
* switching the tool itself (the context manager needs to know the
* old tool)
*/
gimp_context_set_tool (gimp_context_get_user (), tool_type);
if (active_tool)
active_tool_free ();

View File

@ -106,7 +106,7 @@ tool_options_paint_mode_update (GtkWidget *widget,
context = (GimpContext *) gtk_object_get_user_data (GTK_OBJECT (widget));
gimp_context_set_paint_mode (GIMP_CONTEXT (context),
(long) data);
(LayerModeEffects) data);
}
void

View File

@ -696,8 +696,11 @@ active_tool_free (void)
void
tools_select (ToolType tool_type)
{
/* Care for switching to the tool's private context */
context_manager_set_tool (tool_type);
/* Care for switching to the tool's private context _before_ actually
* switching the tool itself (the context manager needs to know the
* old tool)
*/
gimp_context_set_tool (gimp_context_get_user (), tool_type);
if (active_tool)
active_tool_free ();

View File

@ -257,7 +257,7 @@ static GimpItemFactoryEntry image_entries[] =
"view/dot_for_dot.html", NULL },
{ { N_("/View/Info Window..."), "<control><shift>I", view_window_info_cmd_callback, 0 },
"view/dialogs/info_window.html", NULL },
{ { N_("/View/Nav. Window..."), NULL, view_window_nav_cmd_callback, 0 },
{ { N_("/View/Nav. Window..."), "<control><shift>N", view_window_nav_cmd_callback, 0 },
"view/dialogs/navigation_window.html", NULL },
{ { N_("/View/---"), NULL, NULL, 0, "<Separator>" },
@ -288,10 +288,10 @@ static GimpItemFactoryEntry image_entries[] =
"image/colors/equalize.html", NULL },
{ { N_("/Image/Colors/Invert"), NULL, image_invert_cmd_callback, 0 },
"image/colors/invert.html", NULL },
{ { N_("/Image/Colors/---"), NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Image/Colors/Desaturate"), NULL, image_desaturate_cmd_callback, 0 },
"image/colors/desaturate.html", NULL },
{ { N_("/Image/Colors/---"), NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Image/Channels/tearoff1"), NULL, tearoff_cmd_callback, 0, "<Tearoff>" },
NULL, NULL },