1999-06-18 03:13:08 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
1999-06-19 02:29:27 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
#include "gimpcontext.h"
|
|
|
|
#include "gimpsignal.h"
|
|
|
|
|
1999-06-19 02:29:27 +08:00
|
|
|
#define context_return_if_fail(context) \
|
|
|
|
g_return_if_fail ((context) != NULL); \
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
g_return_if_fail (GIMP_IS_CONTEXT (context))
|
1999-06-19 02:29:27 +08:00
|
|
|
|
1999-06-20 21:53:15 +08:00
|
|
|
#define context_return_val_if_fail(context,val) \
|
1999-06-19 02:29:27 +08:00
|
|
|
g_return_val_if_fail ((context) != NULL, (val)); \
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_CONTEXT (context), (val))
|
1999-06-19 02:29:27 +08:00
|
|
|
|
|
|
|
#define context_check_current(context) \
|
1999-06-18 03:13:08 +08:00
|
|
|
((context) = (context) ? (context) : current_context)
|
|
|
|
|
1999-06-20 21:53:15 +08:00
|
|
|
#define context_find_defined(context,field_defined) \
|
1999-06-19 02:29:27 +08:00
|
|
|
while (!((context)->field_defined) && (context)->parent) \
|
|
|
|
(context) = (context)->parent
|
|
|
|
|
1999-06-20 21:53:15 +08:00
|
|
|
enum {
|
|
|
|
ARG_0,
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
ARG_IMAGE,
|
|
|
|
ARG_DISPLAY,
|
|
|
|
ARG_TOOL,
|
|
|
|
ARG_FOREGROUND,
|
|
|
|
ARG_BACKGROUND,
|
1999-06-20 21:53:15 +08:00
|
|
|
ARG_OPACITY,
|
|
|
|
ARG_PAINT_MODE,
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
ARG_BRUSH,
|
|
|
|
ARG_PATTERN,
|
|
|
|
ARG_GRADIENT
|
1999-06-20 21:53:15 +08:00
|
|
|
};
|
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
enum {
|
1999-06-19 02:29:27 +08:00
|
|
|
IMAGE_CHANGED,
|
|
|
|
DISPLAY_CHANGED,
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
TOOL_CHANGED,
|
|
|
|
FOREGROUND_CHANGED,
|
|
|
|
BACKGROUND_CHANGED,
|
|
|
|
OPACITY_CHANGED,
|
|
|
|
PAINT_MODE_CHANGED,
|
|
|
|
BRUSH_CHANGED,
|
|
|
|
PATTERN_CHANGED,
|
|
|
|
GRADIENT_CHANGED,
|
1999-06-18 03:13:08 +08:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint gimp_context_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
1999-06-19 02:29:27 +08:00
|
|
|
static GimpObjectClass * parent_class = NULL;
|
1999-06-18 03:13:08 +08:00
|
|
|
|
|
|
|
/* the currently active context */
|
|
|
|
static GimpContext * current_context = NULL;
|
|
|
|
|
1999-06-19 02:29:27 +08:00
|
|
|
/* the context user by the interface */
|
|
|
|
static GimpContext * user_context = NULL;
|
|
|
|
|
|
|
|
/* the default context which is initialized from gimprc */
|
|
|
|
static GimpContext * default_context = NULL;
|
|
|
|
|
|
|
|
/* the hardcoded standard context */
|
|
|
|
static GimpContext * standard_context = NULL;
|
|
|
|
|
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
/* private functions *******************************************************/
|
1999-06-19 02:29:27 +08:00
|
|
|
|
1999-06-20 21:53:15 +08:00
|
|
|
static void
|
|
|
|
gimp_context_set_arg (GtkObject *object,
|
|
|
|
GtkArg *arg,
|
|
|
|
guint arg_id)
|
|
|
|
{
|
|
|
|
GimpContext *context;
|
|
|
|
|
|
|
|
context = GIMP_CONTEXT (object);
|
|
|
|
|
|
|
|
switch (arg_id)
|
|
|
|
{
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
case ARG_IMAGE:
|
|
|
|
gimp_context_set_image (context, GTK_VALUE_POINTER (*arg));
|
|
|
|
break;
|
|
|
|
case ARG_DISPLAY:
|
|
|
|
gimp_context_set_display (context, GTK_VALUE_POINTER (*arg));
|
|
|
|
break;
|
|
|
|
case ARG_TOOL:
|
|
|
|
gimp_context_set_tool (context, GTK_VALUE_INT (*arg));
|
|
|
|
break;
|
|
|
|
case ARG_FOREGROUND:
|
|
|
|
gimp_context_set_foreground (context, GTK_VALUE_POINTER (*arg));
|
|
|
|
break;
|
|
|
|
case ARG_BACKGROUND:
|
|
|
|
gimp_context_set_background (context, GTK_VALUE_POINTER (*arg));
|
|
|
|
break;
|
1999-06-20 21:53:15 +08:00
|
|
|
case ARG_OPACITY:
|
|
|
|
gimp_context_set_opacity (context, GTK_VALUE_DOUBLE (*arg));
|
|
|
|
break;
|
|
|
|
case ARG_PAINT_MODE:
|
|
|
|
gimp_context_set_paint_mode (context, GTK_VALUE_INT (*arg));
|
|
|
|
break;
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
case ARG_BRUSH:
|
|
|
|
gimp_context_set_brush (context, GTK_VALUE_POINTER (*arg));
|
1999-06-20 21:53:15 +08:00
|
|
|
break;
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
case ARG_PATTERN:
|
|
|
|
gimp_context_set_pattern (context, GTK_VALUE_POINTER (*arg));
|
|
|
|
break;
|
|
|
|
case ARG_GRADIENT:
|
|
|
|
gimp_context_set_gradient (context, GTK_VALUE_POINTER (*arg));
|
1999-06-20 21:53:15 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_context_get_arg (GtkObject *object,
|
|
|
|
GtkArg *arg,
|
|
|
|
guint arg_id)
|
|
|
|
{
|
|
|
|
GimpContext *context;
|
|
|
|
|
|
|
|
context = GIMP_CONTEXT (object);
|
|
|
|
|
|
|
|
switch (arg_id)
|
|
|
|
{
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
case ARG_IMAGE:
|
|
|
|
GTK_VALUE_POINTER (*arg) = gimp_context_get_image (context);
|
|
|
|
break;
|
|
|
|
case ARG_DISPLAY:
|
|
|
|
GTK_VALUE_POINTER (*arg) = gimp_context_get_display (context);
|
|
|
|
break;
|
|
|
|
case ARG_TOOL:
|
|
|
|
GTK_VALUE_INT (*arg) = gimp_context_get_tool (context);
|
|
|
|
break;
|
|
|
|
case ARG_FOREGROUND:
|
|
|
|
{
|
|
|
|
guchar *dest = GTK_VALUE_POINTER (*arg);
|
|
|
|
guchar src[3];
|
|
|
|
gimp_context_get_foreground (context, src);
|
|
|
|
dest[0] = src[0];
|
|
|
|
dest[1] = src[1];
|
|
|
|
dest[2] = src[2];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ARG_BACKGROUND:
|
|
|
|
{
|
|
|
|
guchar *dest = GTK_VALUE_POINTER (*arg);
|
|
|
|
guchar src[3];
|
|
|
|
gimp_context_get_background (context, src);
|
|
|
|
dest[0] = src[0];
|
|
|
|
dest[1] = src[1];
|
|
|
|
dest[2] = src[2];
|
|
|
|
}
|
|
|
|
break;
|
1999-06-20 21:53:15 +08:00
|
|
|
case ARG_OPACITY:
|
|
|
|
GTK_VALUE_DOUBLE (*arg) = gimp_context_get_opacity (context);
|
|
|
|
break;
|
|
|
|
case ARG_PAINT_MODE:
|
|
|
|
GTK_VALUE_INT (*arg) = gimp_context_get_paint_mode (context);
|
|
|
|
break;
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
case ARG_BRUSH:
|
|
|
|
GTK_VALUE_POINTER (*arg) = gimp_context_get_brush (context);
|
1999-06-20 21:53:15 +08:00
|
|
|
break;
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
case ARG_PATTERN:
|
|
|
|
GTK_VALUE_POINTER (*arg) = gimp_context_get_pattern (context);
|
|
|
|
break;
|
|
|
|
case ARG_GRADIENT:
|
|
|
|
GTK_VALUE_POINTER (*arg) = gimp_context_get_gradient (context);
|
1999-06-20 21:53:15 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
arg->type = GTK_TYPE_INVALID;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
static void
|
|
|
|
gimp_context_destroy (GtkObject *object)
|
|
|
|
{
|
|
|
|
GimpContext *context;
|
|
|
|
|
1999-06-19 02:29:27 +08:00
|
|
|
context_return_if_fail (object);
|
1999-06-18 03:13:08 +08:00
|
|
|
|
|
|
|
context = GIMP_CONTEXT (object);
|
|
|
|
|
1999-06-19 02:29:27 +08:00
|
|
|
if (context->name)
|
|
|
|
g_free (context->name);
|
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
|
|
|
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_context_class_init (GimpContextClass *klass)
|
|
|
|
{
|
|
|
|
GtkObjectClass *object_class;
|
|
|
|
|
|
|
|
object_class = GTK_OBJECT_CLASS (klass);
|
|
|
|
|
1999-06-20 21:53:15 +08:00
|
|
|
gtk_object_add_arg_type ("GimpContext::image",
|
|
|
|
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_IMAGE);
|
|
|
|
gtk_object_add_arg_type ("GimpContext::display",
|
|
|
|
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_DISPLAY);
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
gtk_object_add_arg_type ("GimpContext::tool",
|
|
|
|
GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_TOOL);
|
|
|
|
gtk_object_add_arg_type ("GimpContext::foreground",
|
|
|
|
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_FOREGROUND);
|
|
|
|
gtk_object_add_arg_type ("GimpContext::background",
|
|
|
|
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_BACKGROUND);
|
|
|
|
gtk_object_add_arg_type ("GimpContext::opacity",
|
|
|
|
GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_OPACITY);
|
|
|
|
gtk_object_add_arg_type ("GimpContext::paint_mode",
|
|
|
|
GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_PAINT_MODE);
|
|
|
|
gtk_object_add_arg_type ("GimpContext::brush",
|
|
|
|
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_BRUSH);
|
|
|
|
gtk_object_add_arg_type ("GimpContext::pattern",
|
|
|
|
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_PATTERN);
|
|
|
|
gtk_object_add_arg_type ("GimpContext::gradient",
|
|
|
|
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_GRADIENT);
|
1999-06-20 21:53:15 +08:00
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
parent_class = gtk_type_class (gimp_object_get_type ());
|
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
gimp_context_signals[IMAGE_CHANGED] =
|
|
|
|
gimp_signal_new ("image_changed",
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
|
|
|
image_changed),
|
|
|
|
gimp_sigtype_pointer);
|
|
|
|
|
|
|
|
gimp_context_signals[DISPLAY_CHANGED] =
|
|
|
|
gimp_signal_new ("display_changed",
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
|
|
|
display_changed),
|
|
|
|
gimp_sigtype_pointer);
|
|
|
|
|
|
|
|
gimp_context_signals[TOOL_CHANGED] =
|
|
|
|
gimp_signal_new ("tool_changed",
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
|
|
|
tool_changed),
|
|
|
|
gimp_sigtype_int);
|
|
|
|
|
|
|
|
gimp_context_signals[FOREGROUND_CHANGED] =
|
|
|
|
gimp_signal_new ("foreground_changed",
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
|
|
|
foreground_changed),
|
|
|
|
gimp_sigtype_pointer);
|
|
|
|
|
|
|
|
gimp_context_signals[BACKGROUND_CHANGED] =
|
|
|
|
gimp_signal_new ("background_changed",
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
|
|
|
background_changed),
|
|
|
|
gimp_sigtype_pointer);
|
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
gimp_context_signals[OPACITY_CHANGED] =
|
|
|
|
gimp_signal_new ("opacity_changed",
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
|
|
|
opacity_changed),
|
1999-06-20 21:53:15 +08:00
|
|
|
gimp_sigtype_double);
|
1999-06-18 03:13:08 +08:00
|
|
|
|
|
|
|
gimp_context_signals[PAINT_MODE_CHANGED] =
|
|
|
|
gimp_signal_new ("paint_mode_changed",
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
|
|
|
paint_mode_changed),
|
1999-06-20 21:53:15 +08:00
|
|
|
gimp_sigtype_int);
|
1999-06-18 03:13:08 +08:00
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
gimp_context_signals[BRUSH_CHANGED] =
|
|
|
|
gimp_signal_new ("brush_changed",
|
1999-06-19 02:29:27 +08:00
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
brush_changed),
|
1999-06-20 21:53:15 +08:00
|
|
|
gimp_sigtype_pointer);
|
1999-06-19 02:29:27 +08:00
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
gimp_context_signals[PATTERN_CHANGED] =
|
|
|
|
gimp_signal_new ("pattern_changed",
|
1999-06-19 02:29:27 +08:00
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
pattern_changed),
|
|
|
|
gimp_sigtype_pointer);
|
|
|
|
|
|
|
|
gimp_context_signals[GRADIENT_CHANGED] =
|
|
|
|
gimp_signal_new ("gradient_changed",
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
|
|
|
gradient_changed),
|
1999-06-20 21:53:15 +08:00
|
|
|
gimp_sigtype_pointer);
|
1999-06-19 02:29:27 +08:00
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
gtk_object_class_add_signals (object_class, gimp_context_signals,
|
|
|
|
LAST_SIGNAL);
|
|
|
|
|
1999-06-20 21:53:15 +08:00
|
|
|
object_class->set_arg = gimp_context_set_arg;
|
|
|
|
object_class->get_arg = gimp_context_get_arg;
|
|
|
|
object_class->destroy = gimp_context_destroy;
|
|
|
|
|
1999-06-19 02:29:27 +08:00
|
|
|
klass->image_changed = NULL;
|
|
|
|
klass->display_changed = NULL;
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
klass->tool_changed = NULL;
|
|
|
|
klass->foreground_changed = NULL;
|
|
|
|
klass->background_changed = NULL;
|
|
|
|
klass->opacity_changed = NULL;
|
|
|
|
klass->paint_mode_changed = NULL;
|
|
|
|
klass->brush_changed = NULL;
|
|
|
|
klass->pattern_changed = NULL;
|
|
|
|
klass->gradient_changed = NULL;
|
1999-06-18 03:13:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_context_init (GimpContext *context)
|
|
|
|
{
|
1999-06-19 02:29:27 +08:00
|
|
|
context->name = NULL;
|
|
|
|
context->parent = NULL;
|
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
/* Values to be taken from the parent context by default */
|
|
|
|
|
|
|
|
context->image_defined = FALSE;
|
|
|
|
context->image = NULL;
|
|
|
|
|
|
|
|
context->display_defined = FALSE;
|
|
|
|
context->display = NULL;
|
|
|
|
|
|
|
|
context->tool_defined = FALSE;
|
|
|
|
context->tool = RECT_SELECT;
|
|
|
|
|
1999-06-19 02:29:27 +08:00
|
|
|
/* Values defined by default */
|
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
context->foreground_defined = TRUE;
|
|
|
|
context->foreground[0] = 255;
|
|
|
|
context->foreground[1] = 255;
|
|
|
|
context->foreground[2] = 255;
|
|
|
|
|
|
|
|
context->background_defined = TRUE;
|
|
|
|
context->background[0] = 0;
|
|
|
|
context->background[1] = 0;
|
|
|
|
context->background[2] = 0;
|
|
|
|
|
1999-06-19 02:29:27 +08:00
|
|
|
context->opacity_defined = TRUE;
|
|
|
|
context->opacity = 1.0;
|
|
|
|
|
|
|
|
context->paint_mode_defined = TRUE;
|
1999-06-18 03:13:08 +08:00
|
|
|
context->paint_mode = 0;
|
1999-06-19 02:29:27 +08:00
|
|
|
|
|
|
|
/* Values to be taken from the parent context by default */
|
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
context->brush_defined = FALSE;
|
|
|
|
context->brush = NULL;
|
1999-06-19 02:29:27 +08:00
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
context->pattern_defined = FALSE;
|
|
|
|
context->pattern = NULL;
|
|
|
|
|
|
|
|
context->gradient_defined = FALSE;
|
|
|
|
context->gradient = NULL;
|
1999-06-18 03:13:08 +08:00
|
|
|
}
|
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
/* public functions ********************************************************/
|
1999-06-19 02:29:27 +08:00
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
GtkType
|
|
|
|
gimp_context_get_type (void)
|
|
|
|
{
|
1999-06-19 02:29:27 +08:00
|
|
|
static GtkType context_type = 0;
|
1999-06-18 03:13:08 +08:00
|
|
|
|
1999-06-19 02:29:27 +08:00
|
|
|
if(! context_type)
|
1999-06-18 03:13:08 +08:00
|
|
|
{
|
1999-06-19 02:29:27 +08:00
|
|
|
GtkTypeInfo context_info =
|
1999-06-18 03:13:08 +08:00
|
|
|
{
|
|
|
|
"GimpContext",
|
1999-06-20 04:20:59 +08:00
|
|
|
sizeof (GimpContext),
|
|
|
|
sizeof (GimpContextClass),
|
1999-06-18 03:13:08 +08:00
|
|
|
(GtkClassInitFunc) gimp_context_class_init,
|
|
|
|
(GtkObjectInitFunc) gimp_context_init,
|
|
|
|
/* reserved_1 */ NULL,
|
|
|
|
/* reserved_2 */ NULL,
|
|
|
|
(GtkClassInitFunc) NULL
|
|
|
|
};
|
|
|
|
|
1999-06-19 02:29:27 +08:00
|
|
|
context_type = gtk_type_unique (gimp_object_get_type (), &context_info);
|
1999-06-18 03:13:08 +08:00
|
|
|
}
|
|
|
|
|
1999-06-19 02:29:27 +08:00
|
|
|
return context_type;
|
1999-06-18 03:13:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GimpContext *
|
1999-06-19 02:29:27 +08:00
|
|
|
gimp_context_new (gchar *name,
|
|
|
|
GimpContext *template,
|
|
|
|
GimpContext *parent)
|
1999-06-18 03:13:08 +08:00
|
|
|
{
|
|
|
|
GimpContext *context;
|
|
|
|
|
1999-06-19 02:29:27 +08:00
|
|
|
g_return_val_if_fail (!template || GIMP_IS_CONTEXT (template), NULL);
|
|
|
|
g_return_val_if_fail (!parent || GIMP_IS_CONTEXT (parent), NULL);
|
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
context = gtk_type_new (gimp_context_get_type ());
|
|
|
|
|
1999-06-19 02:29:27 +08:00
|
|
|
/* FIXME: need unique (translated??) names here
|
|
|
|
*/
|
|
|
|
context->name = g_strdup (name ? name : "Unnamed");
|
|
|
|
context->parent = parent;
|
|
|
|
|
|
|
|
if (template)
|
|
|
|
{
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
guchar col[3];
|
|
|
|
|
|
|
|
context->image = gimp_context_get_image (template);
|
|
|
|
context->display = gimp_context_get_display (template);
|
|
|
|
context->tool = gimp_context_get_tool (template);
|
|
|
|
gimp_context_get_foreground (template, col);
|
|
|
|
context->foreground[0] = col[0];
|
|
|
|
context->foreground[1] = col[1];
|
|
|
|
context->foreground[2] = col[2];
|
|
|
|
gimp_context_get_background (template, col);
|
|
|
|
context->background[0] = col[0];
|
|
|
|
context->background[1] = col[1];
|
|
|
|
context->background[2] = col[2];
|
|
|
|
context->opacity = gimp_context_get_opacity (template);
|
|
|
|
context->paint_mode = gimp_context_get_paint_mode (template);
|
|
|
|
context->brush = gimp_context_get_brush (template);
|
|
|
|
context->pattern = gimp_context_get_pattern (template);
|
|
|
|
context->gradient = gimp_context_get_gradient (template);
|
1999-06-19 02:29:27 +08:00
|
|
|
|
|
|
|
context->image_defined = template->image_defined;
|
|
|
|
context->display_defined = template->display_defined;
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
context->tool_defined = template->tool_defined;
|
|
|
|
context->foreground_defined = template->foreground_defined;
|
|
|
|
context->background_defined = template->background_defined;
|
|
|
|
context->opacity_defined = template->opacity_defined;
|
|
|
|
context->paint_mode_defined = template->paint_mode_defined;
|
|
|
|
context->brush_defined = template->brush_defined;
|
|
|
|
context->pattern_defined = template->pattern_defined;
|
|
|
|
context->gradient_defined = template->gradient_defined;
|
1999-06-19 02:29:27 +08:00
|
|
|
}
|
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
return context;
|
|
|
|
}
|
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
/* getting/setting the special contexts ************************************/
|
1999-06-19 02:29:27 +08:00
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
GimpContext *
|
|
|
|
gimp_context_get_current (void)
|
|
|
|
{
|
|
|
|
return current_context;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_set_current (GimpContext *context)
|
|
|
|
{
|
|
|
|
current_context = context;
|
|
|
|
}
|
|
|
|
|
1999-06-19 02:29:27 +08:00
|
|
|
GimpContext *
|
|
|
|
gimp_context_get_user (void)
|
|
|
|
{
|
|
|
|
return user_context;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_set_user (GimpContext *context)
|
|
|
|
{
|
|
|
|
user_context = context;
|
|
|
|
}
|
|
|
|
|
|
|
|
GimpContext *
|
|
|
|
gimp_context_get_default (void)
|
|
|
|
{
|
|
|
|
return default_context;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_set_default (GimpContext *context)
|
|
|
|
{
|
|
|
|
default_context = context;
|
|
|
|
}
|
|
|
|
|
|
|
|
GimpContext *
|
|
|
|
gimp_context_get_standard (void)
|
|
|
|
{
|
|
|
|
if (! standard_context)
|
|
|
|
{
|
|
|
|
standard_context = gimp_context_new ("Standard", NULL, NULL);
|
|
|
|
|
|
|
|
gtk_quit_add_destroy (TRUE, GTK_OBJECT (standard_context));
|
|
|
|
}
|
|
|
|
|
|
|
|
return standard_context;
|
|
|
|
}
|
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
/* functions manipulating a single context *********************************/
|
1999-06-19 02:29:27 +08:00
|
|
|
|
1999-06-20 04:20:59 +08:00
|
|
|
gchar *
|
|
|
|
gimp_context_get_name (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_val_if_fail (context, NULL);
|
|
|
|
|
|
|
|
return context->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
GimpContext *
|
|
|
|
gimp_context_get_parent (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_return_val_if_fail (context, NULL);
|
|
|
|
|
|
|
|
return context->parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_set_parent (GimpContext *context,
|
|
|
|
GimpContext *parent)
|
|
|
|
{
|
|
|
|
context_return_if_fail (context);
|
|
|
|
g_return_if_fail (!parent || GIMP_IS_CONTEXT (parent));
|
|
|
|
|
|
|
|
context->parent = parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* attribute access functions */
|
|
|
|
|
1999-06-19 02:29:27 +08:00
|
|
|
/* FIXME: - this is UGLY code duplication
|
|
|
|
* - gimp_context_*_defined and _define_* sounds very ugly, too
|
|
|
|
* TODO: - implement a generic way or alternatively
|
|
|
|
* - write some macros which will fold one of the following
|
|
|
|
* functions into a single macro call
|
|
|
|
*/
|
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
/* image *******************************************************************/
|
|
|
|
|
|
|
|
GimpImage *
|
|
|
|
gimp_context_get_image (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_val_if_fail (context, NULL);
|
|
|
|
context_find_defined (context, image_defined);
|
|
|
|
|
|
|
|
return context->image;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_set_image (GimpContext *context,
|
|
|
|
GimpImage *image)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
context_find_defined (context, image_defined);
|
|
|
|
|
|
|
|
if (context->image == image) return;
|
|
|
|
|
|
|
|
context->image = image;
|
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
|
|
|
gimp_context_signals[IMAGE_CHANGED],
|
|
|
|
image);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_context_image_defined (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_return_val_if_fail (context, FALSE);
|
|
|
|
|
|
|
|
return context->image_defined;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_define_image (GimpContext *context,
|
|
|
|
gboolean defined)
|
|
|
|
{
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
|
|
|
if (defined)
|
|
|
|
context->image = gimp_context_get_image (context);
|
|
|
|
|
|
|
|
context->image_defined = defined;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* display *****************************************************************/
|
|
|
|
|
|
|
|
GDisplay *
|
|
|
|
gimp_context_get_display (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_val_if_fail (context, NULL);
|
|
|
|
context_find_defined (context, display_defined);
|
|
|
|
|
|
|
|
return context->display;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_set_display (GimpContext *context,
|
|
|
|
GDisplay *display)
|
|
|
|
{
|
|
|
|
GimpContext *orig = context;
|
|
|
|
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
context_find_defined (context, display_defined);
|
|
|
|
|
|
|
|
if (context->display == display) return;
|
|
|
|
|
|
|
|
context->display = display;
|
|
|
|
|
|
|
|
/* set the image _before_ emitting the display_changed signal */
|
|
|
|
if (display)
|
|
|
|
gimp_context_set_image (orig, display->gimage);
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
|
|
|
gimp_context_signals[DISPLAY_CHANGED],
|
|
|
|
display);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_context_display_defined (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_return_val_if_fail (context, FALSE);
|
|
|
|
|
|
|
|
return context->display_defined;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_define_display (GimpContext *context,
|
|
|
|
gboolean defined)
|
|
|
|
{
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
|
|
|
if (defined)
|
|
|
|
context->display = gimp_context_get_display (context);
|
|
|
|
|
|
|
|
context->display_defined = defined;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* tool ********************************************************************/
|
|
|
|
|
|
|
|
ToolType
|
|
|
|
gimp_context_get_tool (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_val_if_fail (context, 0);
|
|
|
|
context_find_defined (context, tool_defined);
|
|
|
|
|
|
|
|
return context->tool;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_set_tool (GimpContext *context,
|
|
|
|
ToolType tool)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
context_find_defined (context, tool_defined);
|
|
|
|
|
|
|
|
if (context->tool == tool) return;
|
|
|
|
|
|
|
|
context->tool = tool;
|
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
|
|
|
gimp_context_signals[TOOL_CHANGED],
|
|
|
|
tool);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_context_tool_defined (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_return_val_if_fail (context, FALSE);
|
|
|
|
|
|
|
|
return context->tool_defined;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_define_tool (GimpContext *context,
|
|
|
|
gboolean defined)
|
|
|
|
{
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
|
|
|
if (defined)
|
|
|
|
context->tool = gimp_context_get_tool (context);
|
|
|
|
|
|
|
|
context->tool_defined = defined;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* foreground color ********************************************************/
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_get_foreground (GimpContext *context,
|
|
|
|
guchar foreground[3])
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
context_find_defined (context, foreground_defined);
|
|
|
|
|
|
|
|
foreground[0] = context->foreground[0];
|
|
|
|
foreground[1] = context->foreground[1];
|
|
|
|
foreground[2] = context->foreground[2];
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_set_foreground (GimpContext *context,
|
|
|
|
guchar foreground[3])
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
context_find_defined (context, foreground_defined);
|
|
|
|
|
|
|
|
if (context->foreground[0] == foreground[0] &&
|
|
|
|
context->foreground[1] == foreground[1] &&
|
|
|
|
context->foreground[2] == foreground[2]) return;
|
|
|
|
|
|
|
|
context->foreground[0] = foreground[0];
|
|
|
|
context->foreground[1] = foreground[1];
|
|
|
|
context->foreground[2] = foreground[2];
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
|
|
|
gimp_context_signals[FOREGROUND_CHANGED],
|
|
|
|
context->foreground);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_context_foreground_defined (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_return_val_if_fail (context, FALSE);
|
|
|
|
|
|
|
|
return context->foreground_defined;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_define_foreground (GimpContext *context,
|
|
|
|
gboolean defined)
|
|
|
|
{
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
|
|
|
if (defined)
|
|
|
|
{
|
|
|
|
guchar col[3];
|
|
|
|
|
|
|
|
gimp_context_get_foreground (context, col);
|
|
|
|
context->foreground[0] = col[0];
|
|
|
|
context->foreground[1] = col[1];
|
|
|
|
context->foreground[2] = col[2];
|
|
|
|
}
|
|
|
|
|
|
|
|
context->foreground_defined = defined;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* background color ********************************************************/
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_get_background (GimpContext *context,
|
|
|
|
guchar background[3])
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
context_find_defined (context, background_defined);
|
|
|
|
|
|
|
|
background[0] = context->background[0];
|
|
|
|
background[1] = context->background[1];
|
|
|
|
background[2] = context->background[2];
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_set_background (GimpContext *context,
|
|
|
|
guchar background[3])
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
context_find_defined (context, background_defined);
|
|
|
|
|
|
|
|
if (context->background[0] == background[0] &&
|
|
|
|
context->background[1] == background[1] &&
|
|
|
|
context->background[2] == background[2]) return;
|
|
|
|
|
|
|
|
context->background[0] = background[0];
|
|
|
|
context->background[1] = background[1];
|
|
|
|
context->background[2] = background[2];
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
|
|
|
gimp_context_signals[BACKGROUND_CHANGED],
|
|
|
|
context->background);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_context_background_defined (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_return_val_if_fail (context, FALSE);
|
|
|
|
|
|
|
|
return context->background_defined;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_define_background (GimpContext *context,
|
|
|
|
gboolean defined)
|
|
|
|
{
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
|
|
|
if (defined)
|
|
|
|
{
|
|
|
|
guchar col[3];
|
|
|
|
|
|
|
|
gimp_context_get_background (context, col);
|
|
|
|
context->background[0] = col[0];
|
|
|
|
context->background[1] = col[1];
|
|
|
|
context->background[2] = col[2];
|
|
|
|
}
|
|
|
|
|
|
|
|
context->background_defined = defined;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* opacity *****************************************************************/
|
1999-06-19 02:29:27 +08:00
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
gdouble
|
|
|
|
gimp_context_get_opacity (GimpContext *context)
|
|
|
|
{
|
1999-06-19 02:29:27 +08:00
|
|
|
context_check_current (context);
|
|
|
|
context_return_val_if_fail (context, 1.0);
|
|
|
|
context_find_defined (context, opacity_defined);
|
1999-06-18 03:13:08 +08:00
|
|
|
|
|
|
|
return context->opacity;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_set_opacity (GimpContext *context,
|
|
|
|
gdouble opacity)
|
|
|
|
{
|
1999-06-19 02:29:27 +08:00
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
context_find_defined (context, opacity_defined);
|
1999-06-18 03:13:08 +08:00
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
if (context->opacity == opacity) return;
|
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
context->opacity = opacity;
|
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
1999-06-20 21:53:15 +08:00
|
|
|
gimp_context_signals[OPACITY_CHANGED],
|
|
|
|
opacity);
|
1999-06-18 03:13:08 +08:00
|
|
|
}
|
|
|
|
|
1999-06-19 02:29:27 +08:00
|
|
|
gboolean
|
|
|
|
gimp_context_opacity_defined (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_return_val_if_fail (context, FALSE);
|
|
|
|
|
|
|
|
return context->opacity_defined;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_define_opacity (GimpContext *context,
|
|
|
|
gboolean defined)
|
|
|
|
{
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
|
|
|
if (defined)
|
|
|
|
context->opacity = gimp_context_get_opacity (context);
|
|
|
|
|
|
|
|
context->opacity_defined = defined;
|
|
|
|
}
|
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
/* paint mode **************************************************************/
|
1999-06-19 02:29:27 +08:00
|
|
|
|
Actually use the enum types GimpImageType, GimpImageBaseType,
* app/*.[ch]: Actually use the enum types GimpImageType,
GimpImageBaseType, LayerModeEffects, PaintApplicationMode,
BrushApplicationMode, GimpFillType and ConvertPaletteType, instead
of just int or gint. Hopefully I catched most of the places
where these should be used.
Add an enum ConvolutionType, suffix the too general constants
NORMAL, ABSOLUTE and NEGATIVE with _CONVOL. Use NORMAL_MODE
instead of NORMAL in some places (this was what was intended). Fix
some minor gccisms.
* app/apptypes.h: New file. This file contains the above
enumeration types, and some opaque struct typedefs. It was
necessary to collect these in one header that doesn't include
other headers, because when we started using the above mentioned
types in the headers, all hell broke loose because of the
spaghetti-like cross-inclusion mess between headers.
(An example: Header A includes header B, which includes header C
which includes A. B uses a type defined in A. This is not defined,
because A hasn't defined it yet at the point where it includes B,
and A included from B of course is skipped as we already are
reading A.)
1999-08-19 07:41:39 +08:00
|
|
|
LayerModeEffects
|
1999-06-18 03:13:08 +08:00
|
|
|
gimp_context_get_paint_mode (GimpContext *context)
|
|
|
|
{
|
1999-06-19 02:29:27 +08:00
|
|
|
context_check_current (context);
|
|
|
|
context_return_val_if_fail (context, 0);
|
|
|
|
context_find_defined (context, paint_mode_defined);
|
1999-06-18 03:13:08 +08:00
|
|
|
|
|
|
|
return context->paint_mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
Actually use the enum types GimpImageType, GimpImageBaseType,
* app/*.[ch]: Actually use the enum types GimpImageType,
GimpImageBaseType, LayerModeEffects, PaintApplicationMode,
BrushApplicationMode, GimpFillType and ConvertPaletteType, instead
of just int or gint. Hopefully I catched most of the places
where these should be used.
Add an enum ConvolutionType, suffix the too general constants
NORMAL, ABSOLUTE and NEGATIVE with _CONVOL. Use NORMAL_MODE
instead of NORMAL in some places (this was what was intended). Fix
some minor gccisms.
* app/apptypes.h: New file. This file contains the above
enumeration types, and some opaque struct typedefs. It was
necessary to collect these in one header that doesn't include
other headers, because when we started using the above mentioned
types in the headers, all hell broke loose because of the
spaghetti-like cross-inclusion mess between headers.
(An example: Header A includes header B, which includes header C
which includes A. B uses a type defined in A. This is not defined,
because A hasn't defined it yet at the point where it includes B,
and A included from B of course is skipped as we already are
reading A.)
1999-08-19 07:41:39 +08:00
|
|
|
gimp_context_set_paint_mode (GimpContext *context,
|
|
|
|
LayerModeEffects paint_mode)
|
1999-06-18 03:13:08 +08:00
|
|
|
{
|
1999-06-19 02:29:27 +08:00
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
context_find_defined (context, paint_mode_defined);
|
1999-06-18 03:13:08 +08:00
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
if (context->paint_mode == paint_mode) return;
|
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
context->paint_mode = paint_mode;
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
1999-06-20 21:53:15 +08:00
|
|
|
gimp_context_signals[PAINT_MODE_CHANGED],
|
|
|
|
paint_mode);
|
1999-06-18 03:13:08 +08:00
|
|
|
}
|
1999-06-19 02:29:27 +08:00
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_context_paint_mode_defined (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_return_val_if_fail (context, FALSE);
|
|
|
|
|
|
|
|
return context->paint_mode_defined;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_define_paint_mode (GimpContext *context,
|
|
|
|
gboolean defined)
|
|
|
|
{
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
|
|
|
if (defined)
|
|
|
|
context->paint_mode = gimp_context_get_paint_mode (context);
|
|
|
|
|
|
|
|
context->paint_mode_defined = defined;
|
|
|
|
}
|
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
/* brush *******************************************************************/
|
1999-06-19 02:29:27 +08:00
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
GimpBrush *
|
|
|
|
gimp_context_get_brush (GimpContext *context)
|
1999-06-19 02:29:27 +08:00
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_val_if_fail (context, NULL);
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
context_find_defined (context, brush_defined);
|
1999-06-19 02:29:27 +08:00
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
return context->brush;
|
1999-06-19 02:29:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
gimp_context_set_brush (GimpContext *context,
|
|
|
|
GimpBrush *brush)
|
1999-06-19 02:29:27 +08:00
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
context_find_defined (context, brush_defined);
|
1999-06-19 02:29:27 +08:00
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
if (context->brush == brush) return;
|
1999-06-20 21:53:15 +08:00
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
context->brush = brush;
|
1999-06-19 02:29:27 +08:00
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
gimp_context_signals[BRUSH_CHANGED],
|
|
|
|
brush);
|
1999-06-19 02:29:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
gimp_context_brush_defined (GimpContext *context)
|
1999-06-19 02:29:27 +08:00
|
|
|
{
|
|
|
|
context_return_val_if_fail (context, FALSE);
|
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
return context->brush_defined;
|
1999-06-19 02:29:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
gimp_context_define_brush (GimpContext *context,
|
1999-06-19 02:29:27 +08:00
|
|
|
gboolean defined)
|
|
|
|
{
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
|
|
|
if (defined)
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
context->brush = gimp_context_get_brush (context);
|
1999-06-19 02:29:27 +08:00
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
context->brush_defined = defined;
|
1999-06-19 02:29:27 +08:00
|
|
|
}
|
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
/* pattern *****************************************************************/
|
1999-06-19 02:29:27 +08:00
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
GPattern *
|
|
|
|
gimp_context_get_pattern (GimpContext *context)
|
1999-06-19 02:29:27 +08:00
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_val_if_fail (context, NULL);
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
context_find_defined (context, pattern_defined);
|
1999-06-19 02:29:27 +08:00
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
return context->pattern;
|
1999-06-19 02:29:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
gimp_context_set_pattern (GimpContext *context,
|
|
|
|
GPattern *pattern)
|
1999-06-19 02:29:27 +08:00
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
context_find_defined (context, pattern_defined);
|
1999-06-19 02:29:27 +08:00
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
if (context->pattern == pattern) return;
|
1999-06-20 21:53:15 +08:00
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
context->pattern = pattern;
|
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
|
|
|
gimp_context_signals[PATTERN_CHANGED],
|
|
|
|
pattern);
|
|
|
|
}
|
1999-06-20 21:53:15 +08:00
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
gboolean
|
|
|
|
gimp_context_pattern_defined (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_return_val_if_fail (context, FALSE);
|
|
|
|
|
|
|
|
return context->pattern_defined;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_define_pattern (GimpContext *context,
|
|
|
|
gboolean defined)
|
|
|
|
{
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
|
|
|
if (defined)
|
|
|
|
context->pattern = gimp_context_get_pattern (context);
|
|
|
|
|
|
|
|
context->pattern_defined = defined;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* gradient ****************************************************************/
|
|
|
|
|
|
|
|
gradient_t *
|
|
|
|
gimp_context_get_gradient (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_val_if_fail (context, NULL);
|
|
|
|
context_find_defined (context, gradient_defined);
|
|
|
|
|
|
|
|
return context->gradient;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_set_gradient (GimpContext *context,
|
|
|
|
gradient_t *gradient)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
context_find_defined (context, gradient_defined);
|
1999-06-20 21:53:15 +08:00
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
if (context->gradient == gradient) return;
|
|
|
|
|
|
|
|
context->gradient = gradient;
|
1999-06-19 02:29:27 +08:00
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
gimp_context_signals[GRADIENT_CHANGED],
|
|
|
|
gradient);
|
1999-06-19 02:29:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
gimp_context_gradient_defined (GimpContext *context)
|
1999-06-19 02:29:27 +08:00
|
|
|
{
|
|
|
|
context_return_val_if_fail (context, FALSE);
|
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
return context->gradient_defined;
|
1999-06-19 02:29:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
gimp_context_define_gradient (GimpContext *context,
|
|
|
|
gboolean defined)
|
1999-06-19 02:29:27 +08:00
|
|
|
{
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
|
|
|
if (defined)
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
context->gradient = gimp_context_get_gradient (context);
|
1999-06-19 02:29:27 +08:00
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
context->gradient_defined = defined;
|
1999-06-19 02:29:27 +08:00
|
|
|
}
|