1999-06-18 03:13:08 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
1999-10-19 23:52:32 +08:00
|
|
|
* gimpcontext.c: Copyright (C) 1999 Michael Natterer <mitch@gimp.org>
|
|
|
|
*
|
1999-06-18 03:13:08 +08:00
|
|
|
* 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-10-19 23:52:32 +08:00
|
|
|
#include "appenv.h"
|
1999-10-27 02:27:27 +08:00
|
|
|
#include "gimpbrush.h"
|
|
|
|
#include "gimpbrushlist.h"
|
1999-06-18 03:13:08 +08:00
|
|
|
#include "gimpcontext.h"
|
1999-10-27 02:27:27 +08:00
|
|
|
#include "gimprc.h"
|
1999-06-18 03:13:08 +08:00
|
|
|
#include "gimpsignal.h"
|
1999-10-27 02:27:27 +08:00
|
|
|
#include "gradient_header.h"
|
|
|
|
#include "patterns.h"
|
|
|
|
|
|
|
|
#include "libgimp/gimpintl.h"
|
1999-06-18 03:13:08 +08:00
|
|
|
|
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-10-19 23:52:32 +08:00
|
|
|
#define context_find_defined(context,arg_mask) \
|
|
|
|
while (!(((context)->defined_args) & arg_mask) && (context)->parent) \
|
1999-06-19 02:29:27 +08:00
|
|
|
(context) = (context)->parent
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
typedef void (* GimpContextCopyArgFunc) (GimpContext *src, GimpContext *dest);
|
|
|
|
|
|
|
|
/* local function prototypes */
|
1999-11-14 18:50:19 +08:00
|
|
|
|
|
|
|
/* image */
|
1999-10-19 23:52:32 +08:00
|
|
|
static void gimp_context_real_set_image (GimpContext *context,
|
|
|
|
GimpImage *image);
|
|
|
|
static void gimp_context_copy_image (GimpContext *src,
|
|
|
|
GimpContext *dest);
|
|
|
|
static void gimp_context_image_changed (GimpContext *parent,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpContext *child);
|
1999-11-14 18:50:19 +08:00
|
|
|
|
|
|
|
/* display */
|
|
|
|
static void gimp_context_real_set_display (GimpContext *context,
|
|
|
|
GDisplay *display);
|
|
|
|
static void gimp_context_copy_display (GimpContext *src,
|
|
|
|
GimpContext *dest);
|
1999-10-19 23:52:32 +08:00
|
|
|
static void gimp_context_display_changed (GimpContext *parent,
|
|
|
|
GDisplay *display,
|
|
|
|
GimpContext *child);
|
1999-11-14 18:50:19 +08:00
|
|
|
|
|
|
|
/* tool */
|
|
|
|
static void gimp_context_real_set_tool (GimpContext *context,
|
|
|
|
ToolType tool);
|
|
|
|
static void gimp_context_copy_tool (GimpContext *src,
|
|
|
|
GimpContext *dest);
|
1999-10-19 23:52:32 +08:00
|
|
|
static void gimp_context_tool_changed (GimpContext *parent,
|
|
|
|
ToolType tool,
|
|
|
|
GimpContext *child);
|
1999-11-14 18:50:19 +08:00
|
|
|
|
|
|
|
/* foreground */
|
|
|
|
static void gimp_context_real_set_foreground (GimpContext *context,
|
|
|
|
gint r,
|
|
|
|
gint g,
|
|
|
|
gint b);
|
|
|
|
static void gimp_context_copy_foreground (GimpContext *src,
|
|
|
|
GimpContext *dest);
|
1999-10-19 23:52:32 +08:00
|
|
|
static void gimp_context_foreground_changed (GimpContext *parent,
|
|
|
|
gint r,
|
|
|
|
gint g,
|
|
|
|
gint b,
|
|
|
|
GimpContext *child);
|
1999-11-14 18:50:19 +08:00
|
|
|
|
|
|
|
/* background */
|
|
|
|
static void gimp_context_real_set_background (GimpContext *context,
|
|
|
|
gint r,
|
|
|
|
gint g,
|
|
|
|
gint b);
|
|
|
|
static void gimp_context_copy_background (GimpContext *src,
|
|
|
|
GimpContext *dest);
|
1999-10-19 23:52:32 +08:00
|
|
|
static void gimp_context_background_changed (GimpContext *parent,
|
|
|
|
gint r,
|
|
|
|
gint g,
|
|
|
|
gint b,
|
|
|
|
GimpContext *child);
|
1999-11-14 18:50:19 +08:00
|
|
|
|
|
|
|
/* opacity */
|
|
|
|
static void gimp_context_real_set_opacity (GimpContext *context,
|
|
|
|
gdouble opacity);
|
|
|
|
static void gimp_context_copy_opacity (GimpContext *src,
|
|
|
|
GimpContext *dest);
|
1999-10-19 23:52:32 +08:00
|
|
|
static void gimp_context_opacity_changed (GimpContext *parent,
|
|
|
|
gdouble opacity,
|
|
|
|
GimpContext *child);
|
1999-11-14 18:50:19 +08:00
|
|
|
|
|
|
|
/* paint mode */
|
|
|
|
static void gimp_context_real_set_paint_mode (GimpContext *context,
|
|
|
|
LayerModeEffects paint_mode);
|
|
|
|
static void gimp_context_copy_paint_mode (GimpContext *src,
|
|
|
|
GimpContext *dest);
|
1999-10-19 23:52:32 +08:00
|
|
|
static void gimp_context_paint_mode_changed (GimpContext *parent,
|
|
|
|
LayerModeEffects paint_mode,
|
|
|
|
GimpContext *child);
|
1999-11-14 18:50:19 +08:00
|
|
|
|
|
|
|
/* brush */
|
|
|
|
static void gimp_context_real_set_brush (GimpContext *context,
|
|
|
|
GimpBrush *brush);
|
|
|
|
static void gimp_context_copy_brush (GimpContext *src,
|
|
|
|
GimpContext *dest);
|
1999-10-19 23:52:32 +08:00
|
|
|
static void gimp_context_brush_changed (GimpContext *parent,
|
|
|
|
GimpBrush *brush,
|
|
|
|
GimpContext *child);
|
1999-11-14 18:50:19 +08:00
|
|
|
|
|
|
|
/* pattern */
|
|
|
|
static void gimp_context_real_set_pattern (GimpContext *context,
|
|
|
|
GPattern *pattern);
|
|
|
|
static void gimp_context_copy_pattern (GimpContext *src,
|
|
|
|
GimpContext *dest);
|
1999-10-19 23:52:32 +08:00
|
|
|
static void gimp_context_pattern_changed (GimpContext *parent,
|
|
|
|
GPattern *pattern,
|
|
|
|
GimpContext *child);
|
1999-11-14 18:50:19 +08:00
|
|
|
|
|
|
|
/* gradient */
|
|
|
|
static void gimp_context_real_set_gradient (GimpContext *context,
|
|
|
|
gradient_t *gradient);
|
|
|
|
static void gimp_context_copy_gradient (GimpContext *src,
|
|
|
|
GimpContext *dest);
|
1999-10-19 23:52:32 +08:00
|
|
|
static void gimp_context_gradient_changed (GimpContext *parent,
|
|
|
|
gradient_t *gradient,
|
|
|
|
GimpContext *child);
|
|
|
|
|
1999-11-14 18:50:19 +08:00
|
|
|
/* arguments */
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
enum
|
|
|
|
{
|
1999-06-20 21:53:15 +08:00
|
|
|
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-10-27 02:27:27 +08:00
|
|
|
static gchar *gimp_context_arg_names[] =
|
1999-10-19 23:52:32 +08:00
|
|
|
{
|
|
|
|
"GimpContext::image",
|
|
|
|
"GimpContext::display",
|
|
|
|
"GimpContext::tool",
|
|
|
|
"GimpContext::foreground",
|
|
|
|
"GimpContext::background",
|
|
|
|
"GimpContext::opacity",
|
|
|
|
"GimpContext::paint_mode",
|
|
|
|
"GimpContext::brush",
|
|
|
|
"GimpContext::pattern",
|
|
|
|
"GimpContext::gradient"
|
|
|
|
};
|
|
|
|
|
1999-11-14 18:50:19 +08:00
|
|
|
static GimpContextCopyArgFunc gimp_context_copy_arg_funcs[] =
|
|
|
|
{
|
|
|
|
gimp_context_copy_image,
|
|
|
|
gimp_context_copy_display,
|
|
|
|
gimp_context_copy_tool,
|
|
|
|
gimp_context_copy_foreground,
|
|
|
|
gimp_context_copy_background,
|
|
|
|
gimp_context_copy_opacity,
|
|
|
|
gimp_context_copy_paint_mode,
|
|
|
|
gimp_context_copy_brush,
|
|
|
|
gimp_context_copy_pattern,
|
|
|
|
gimp_context_copy_gradient
|
|
|
|
};
|
|
|
|
|
|
|
|
/* signals */
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
IMAGE_CHANGED,
|
|
|
|
DISPLAY_CHANGED,
|
|
|
|
TOOL_CHANGED,
|
|
|
|
FOREGROUND_CHANGED,
|
|
|
|
BACKGROUND_CHANGED,
|
|
|
|
OPACITY_CHANGED,
|
|
|
|
PAINT_MODE_CHANGED,
|
|
|
|
BRUSH_CHANGED,
|
|
|
|
PATTERN_CHANGED,
|
|
|
|
GRADIENT_CHANGED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
static guint gimp_context_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
static gchar *gimp_context_signal_names[] =
|
1999-10-19 23:52:32 +08:00
|
|
|
{
|
|
|
|
"image_changed",
|
|
|
|
"display_changed",
|
|
|
|
"tool_changed",
|
|
|
|
"foreground_changed",
|
|
|
|
"background_changed",
|
|
|
|
"opacity_changed",
|
|
|
|
"paint_mode_changed",
|
|
|
|
"brush_changed",
|
|
|
|
"pattern_changed",
|
|
|
|
"gradient_changed"
|
|
|
|
};
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
static GtkSignalFunc gimp_context_signal_handlers[] =
|
1999-10-19 23:52:32 +08:00
|
|
|
{
|
|
|
|
gimp_context_image_changed,
|
|
|
|
gimp_context_display_changed,
|
|
|
|
gimp_context_tool_changed,
|
|
|
|
gimp_context_foreground_changed,
|
|
|
|
gimp_context_background_changed,
|
|
|
|
gimp_context_opacity_changed,
|
|
|
|
gimp_context_paint_mode_changed,
|
|
|
|
gimp_context_brush_changed,
|
|
|
|
gimp_context_pattern_changed,
|
|
|
|
gimp_context_gradient_changed
|
|
|
|
};
|
|
|
|
|
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 */
|
1999-11-14 18:50:19 +08:00
|
|
|
static GimpContext *current_context = NULL;
|
1999-06-18 03:13:08 +08:00
|
|
|
|
1999-06-19 02:29:27 +08:00
|
|
|
/* the context user by the interface */
|
1999-11-14 18:50:19 +08:00
|
|
|
static GimpContext *user_context = NULL;
|
1999-06-19 02:29:27 +08:00
|
|
|
|
|
|
|
/* the default context which is initialized from gimprc */
|
1999-11-14 18:50:19 +08:00
|
|
|
static GimpContext *default_context = NULL;
|
1999-06-19 02:29:27 +08:00
|
|
|
|
|
|
|
/* the hardcoded standard context */
|
1999-11-14 18:50:19 +08:00
|
|
|
static GimpContext *standard_context = NULL;
|
1999-06-19 02:29:27 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/* the list of all contexts */
|
1999-11-14 18:50:19 +08:00
|
|
|
static GSList *context_list = NULL;
|
1999-06-19 02:29:27 +08:00
|
|
|
|
1999-10-27 02:27: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
|
|
|
/* 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:
|
1999-10-17 21:48:19 +08:00
|
|
|
{
|
|
|
|
guchar *col = GTK_VALUE_POINTER (*arg);
|
|
|
|
gimp_context_set_foreground (context, col[0], col[1], col[2]);
|
|
|
|
}
|
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
|
|
|
break;
|
|
|
|
case ARG_BACKGROUND:
|
1999-10-17 21:48:19 +08:00
|
|
|
{
|
|
|
|
guchar *col = GTK_VALUE_POINTER (*arg);
|
|
|
|
gimp_context_set_background (context, col[0], col[1], col[2]);
|
|
|
|
}
|
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
|
|
|
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:
|
|
|
|
{
|
1999-10-17 21:48:19 +08:00
|
|
|
guchar *col = GTK_VALUE_POINTER (*arg);
|
|
|
|
gimp_context_get_foreground (context, &col[0], &col[1], &col[2]);
|
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
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ARG_BACKGROUND:
|
|
|
|
{
|
1999-10-17 21:48:19 +08:00
|
|
|
guchar *col = GTK_VALUE_POINTER (*arg);
|
|
|
|
gimp_context_get_background (context, &col[0], &col[1], &col[2]);
|
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
|
|
|
}
|
|
|
|
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;
|
|
|
|
|
|
|
|
context = GIMP_CONTEXT (object);
|
|
|
|
|
1999-11-14 18:50:19 +08:00
|
|
|
if (context->parent)
|
|
|
|
gimp_context_unset_parent (context);
|
1999-10-19 23:52:32 +08:00
|
|
|
|
1999-06-19 02:29:27 +08:00
|
|
|
if (context->name)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
|
|
|
g_free (context->name);
|
|
|
|
context->name = NULL;
|
|
|
|
}
|
1999-06-19 02:29:27 +08:00
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
if (context->image)
|
|
|
|
gtk_signal_disconnect_by_data (GTK_OBJECT (image_context), context);
|
|
|
|
|
|
|
|
if (context->display)
|
|
|
|
gtk_signal_disconnect_by_data (GTK_OBJECT (context->display->shell),
|
|
|
|
context);
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
if (context->brush)
|
|
|
|
{
|
|
|
|
gtk_signal_disconnect_by_data (GTK_OBJECT (context->brush), context);
|
|
|
|
gtk_signal_disconnect_by_data (GTK_OBJECT (brush_list), context);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (context->brush_name)
|
|
|
|
{
|
|
|
|
g_free (context->brush_name);
|
|
|
|
context->brush_name = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (context->pattern_name)
|
|
|
|
{
|
|
|
|
g_free (context->pattern_name);
|
|
|
|
context->pattern_name = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (context->gradient_name)
|
|
|
|
{
|
|
|
|
g_free (context->gradient_name);
|
|
|
|
context->gradient_name = NULL;
|
|
|
|
}
|
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
|
|
|
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
context_list = g_slist_remove (context_list, context);
|
1999-06-18 03:13:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_context_class_init (GimpContextClass *klass)
|
|
|
|
{
|
|
|
|
GtkObjectClass *object_class;
|
1999-11-14 18:50:19 +08:00
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
object_class = GTK_OBJECT_CLASS (klass);
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
gtk_object_add_arg_type (gimp_context_arg_names[IMAGE_CHANGED],
|
1999-06-20 21:53:15 +08:00
|
|
|
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_IMAGE);
|
1999-10-19 23:52:32 +08:00
|
|
|
gtk_object_add_arg_type (gimp_context_arg_names[DISPLAY_CHANGED],
|
1999-06-20 21:53:15 +08:00
|
|
|
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_DISPLAY);
|
1999-10-19 23:52:32 +08:00
|
|
|
gtk_object_add_arg_type (gimp_context_arg_names[TOOL_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
|
|
|
GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_TOOL);
|
1999-10-19 23:52:32 +08:00
|
|
|
gtk_object_add_arg_type (gimp_context_arg_names[FOREGROUND_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
|
|
|
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_FOREGROUND);
|
1999-10-19 23:52:32 +08:00
|
|
|
gtk_object_add_arg_type (gimp_context_arg_names[BACKGROUND_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
|
|
|
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_BACKGROUND);
|
1999-10-19 23:52:32 +08:00
|
|
|
gtk_object_add_arg_type (gimp_context_arg_names[OPACITY_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
|
|
|
GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_OPACITY);
|
1999-10-19 23:52:32 +08:00
|
|
|
gtk_object_add_arg_type (gimp_context_arg_names[PAINT_MODE_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
|
|
|
GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_PAINT_MODE);
|
1999-10-19 23:52:32 +08:00
|
|
|
gtk_object_add_arg_type (gimp_context_arg_names[BRUSH_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
|
|
|
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_BRUSH);
|
1999-10-19 23:52:32 +08:00
|
|
|
gtk_object_add_arg_type (gimp_context_arg_names[PATTERN_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
|
|
|
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_PATTERN);
|
1999-10-27 10:01:27 +08:00
|
|
|
gtk_object_add_arg_type (gimp_context_arg_names[GRADIENT_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
|
|
|
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] =
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_signal_new (gimp_context_signal_names[IMAGE_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
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
|
|
|
image_changed),
|
|
|
|
gimp_sigtype_pointer);
|
|
|
|
|
|
|
|
gimp_context_signals[DISPLAY_CHANGED] =
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_signal_new (gimp_context_signal_names[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
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
|
|
|
display_changed),
|
|
|
|
gimp_sigtype_pointer);
|
|
|
|
|
|
|
|
gimp_context_signals[TOOL_CHANGED] =
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_signal_new (gimp_context_signal_names[TOOL_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
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
|
|
|
tool_changed),
|
|
|
|
gimp_sigtype_int);
|
|
|
|
|
|
|
|
gimp_context_signals[FOREGROUND_CHANGED] =
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_signal_new (gimp_context_signal_names[FOREGROUND_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
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
|
|
|
foreground_changed),
|
1999-10-17 21:48:19 +08:00
|
|
|
gimp_sigtype_int_int_int);
|
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[BACKGROUND_CHANGED] =
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_signal_new (gimp_context_signal_names[BACKGROUND_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
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
|
|
|
background_changed),
|
1999-10-17 21:48:19 +08:00
|
|
|
gimp_sigtype_int_int_int);
|
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
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
gimp_context_signals[OPACITY_CHANGED] =
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_signal_new (gimp_context_signal_names[OPACITY_CHANGED],
|
1999-06-18 03:13:08 +08:00
|
|
|
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] =
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_signal_new (gimp_context_signal_names[PAINT_MODE_CHANGED],
|
1999-06-18 03:13:08 +08:00
|
|
|
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] =
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_signal_new (gimp_context_signal_names[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] =
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_signal_new (gimp_context_signal_names[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] =
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_signal_new (gimp_context_signal_names[GRADIENT_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
|
|
|
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-10-19 23:52:32 +08:00
|
|
|
context->name = NULL;
|
1999-06-19 02:29:27 +08:00
|
|
|
context->parent = NULL;
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
context->defined_args = GIMP_CONTEXT_ALL_ARGS_MASK;
|
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
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
context->image = 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->display = NULL;
|
|
|
|
|
|
|
|
context->tool = RECT_SELECT;
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
context->foreground[0] = 0;
|
|
|
|
context->foreground[1] = 0;
|
|
|
|
context->foreground[2] = 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
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
context->background[0] = 255;
|
|
|
|
context->background[1] = 255;
|
|
|
|
context->background[2] = 255;
|
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
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
context->opacity = 1.0;
|
|
|
|
context->paint_mode = NORMAL_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
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
context->brush = NULL;
|
|
|
|
context->brush_name = NULL;
|
|
|
|
|
|
|
|
context->pattern = NULL;
|
|
|
|
context->pattern_name = NULL;
|
|
|
|
|
|
|
|
context->gradient = NULL;
|
|
|
|
context->gradient_name = NULL;
|
|
|
|
|
|
|
|
context_list = g_slist_prepend (context_list, context);
|
1999-06-18 03:13:08 +08:00
|
|
|
}
|
|
|
|
|
1999-10-27 02:27: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
|
|
|
/* 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-10-19 23:52:32 +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,
|
1999-10-19 23:52:32 +08:00
|
|
|
GimpContext *template)
|
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);
|
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
context = gtk_type_new (gimp_context_get_type ());
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
/* FIXME: need unique names here */
|
1999-06-19 02:29:27 +08:00
|
|
|
context->name = g_strdup (name ? name : "Unnamed");
|
|
|
|
|
|
|
|
if (template)
|
|
|
|
{
|
1999-10-19 23:52:32 +08:00
|
|
|
context->defined_args = template->defined_args;
|
|
|
|
|
1999-11-14 18:50:19 +08:00
|
|
|
gimp_context_copy_args (template, context, GIMP_CONTEXT_ALL_ARGS_MASK);
|
1999-06-19 02:29:27 +08:00
|
|
|
}
|
|
|
|
|
1999-06-18 03:13:08 +08:00
|
|
|
return context;
|
|
|
|
}
|
|
|
|
|
1999-10-27 02:27: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
|
|
|
/* 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)
|
|
|
|
{
|
1999-10-19 23:52:32 +08:00
|
|
|
standard_context = gimp_context_new ("Standard", NULL);
|
1999-06-19 02:29:27 +08:00
|
|
|
|
|
|
|
gtk_quit_add_destroy (TRUE, GTK_OBJECT (standard_context));
|
|
|
|
}
|
|
|
|
|
|
|
|
return standard_context;
|
|
|
|
}
|
|
|
|
|
1999-10-27 02:27: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
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
void
|
|
|
|
gimp_context_set_name (GimpContext *context,
|
|
|
|
gchar *name)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
|
|
|
if (context->name)
|
|
|
|
g_free (context->name);
|
|
|
|
|
|
|
|
context->name = g_strdup (name ? name : "Unnamed");
|
|
|
|
}
|
|
|
|
|
1999-06-20 04:20:59 +08:00
|
|
|
GimpContext *
|
|
|
|
gimp_context_get_parent (GimpContext *context)
|
|
|
|
{
|
1999-10-19 23:52:32 +08:00
|
|
|
context_check_current (context);
|
1999-06-20 04:20:59 +08:00
|
|
|
context_return_val_if_fail (context, NULL);
|
|
|
|
|
|
|
|
return context->parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_set_parent (GimpContext *context,
|
|
|
|
GimpContext *parent)
|
|
|
|
{
|
1999-10-19 23:52:32 +08:00
|
|
|
GimpContextArgType arg;
|
|
|
|
|
|
|
|
context_check_current (context);
|
1999-06-20 04:20:59 +08:00
|
|
|
context_return_if_fail (context);
|
|
|
|
g_return_if_fail (!parent || GIMP_IS_CONTEXT (parent));
|
|
|
|
|
1999-11-14 18:50:19 +08:00
|
|
|
if (context == parent)
|
|
|
|
return;
|
1999-10-19 23:52:32 +08:00
|
|
|
|
|
|
|
for (arg = 0; arg < GIMP_CONTEXT_NUM_ARGS; arg++)
|
|
|
|
if (! ((1 << arg) & context->defined_args))
|
|
|
|
{
|
|
|
|
gimp_context_copy_arg (parent, context, arg);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (parent),
|
|
|
|
gimp_context_signal_names[arg],
|
|
|
|
gimp_context_signal_handlers[arg],
|
|
|
|
context);
|
|
|
|
}
|
|
|
|
|
1999-06-20 04:20:59 +08:00
|
|
|
context->parent = parent;
|
|
|
|
}
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
void
|
|
|
|
gimp_context_unset_parent (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
1999-06-20 04:20:59 +08:00
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
if (context->parent)
|
|
|
|
{
|
|
|
|
if (context->defined_args != GIMP_CONTEXT_ALL_ARGS_MASK)
|
|
|
|
gtk_signal_disconnect_by_data (GTK_OBJECT (context->parent), context);
|
1999-06-20 04:20:59 +08:00
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
context->parent = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* define / undefinine context arguments */
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_define_arg (GimpContext *context,
|
|
|
|
GimpContextArgType arg,
|
|
|
|
gboolean defined)
|
|
|
|
{
|
|
|
|
GimpContextArgMask mask;
|
|
|
|
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
g_return_if_fail ((arg >= 0) && (arg < GIMP_CONTEXT_NUM_ARGS));
|
|
|
|
|
|
|
|
mask = (1 << arg);
|
|
|
|
|
|
|
|
if (defined)
|
|
|
|
{
|
|
|
|
if (! (context->defined_args & mask))
|
|
|
|
{
|
|
|
|
context->defined_args |= mask;
|
|
|
|
if (context->parent)
|
|
|
|
gtk_signal_disconnect_by_func (GTK_OBJECT (context->parent),
|
|
|
|
gimp_context_signal_handlers[arg],
|
|
|
|
context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (context->defined_args & mask)
|
|
|
|
{
|
|
|
|
context->defined_args &= ~mask;
|
|
|
|
if (context->parent)
|
|
|
|
{
|
|
|
|
gimp_context_copy_arg (context->parent, context, arg);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (context->parent),
|
|
|
|
gimp_context_signal_names[arg],
|
|
|
|
gimp_context_signal_handlers[arg],
|
|
|
|
context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_context_arg_defined (GimpContext *context,
|
|
|
|
GimpContextArgType arg)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_val_if_fail (context, FALSE);
|
|
|
|
|
|
|
|
return (context->defined_args & (1 << arg)) ? TRUE : FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_define_args (GimpContext *context,
|
|
|
|
guint32 args_mask,
|
|
|
|
gboolean defined)
|
|
|
|
{
|
|
|
|
GimpContextArgType arg;
|
|
|
|
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
|
|
|
for (arg = 0; arg < GIMP_CONTEXT_NUM_ARGS; arg++)
|
|
|
|
if ((1 << arg) & args_mask)
|
|
|
|
gimp_context_define_arg (context, arg, defined);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* copying context arguments */
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_copy_arg (GimpContext *src,
|
|
|
|
GimpContext *dest,
|
|
|
|
GimpContextArgType arg)
|
|
|
|
{
|
|
|
|
context_check_current (src);
|
|
|
|
context_return_if_fail (src);
|
|
|
|
context_check_current (dest);
|
|
|
|
context_return_if_fail (dest);
|
|
|
|
g_return_if_fail ((arg >= 0) && (arg < GIMP_CONTEXT_NUM_ARGS));
|
|
|
|
|
|
|
|
(* gimp_context_copy_arg_funcs[arg]) (src, dest);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_copy_args (GimpContext *src,
|
|
|
|
GimpContext *dest,
|
|
|
|
GimpContextArgMask args_mask)
|
|
|
|
{
|
|
|
|
GimpContextArgType arg;
|
|
|
|
|
|
|
|
context_check_current (src);
|
|
|
|
context_return_if_fail (src);
|
|
|
|
context_check_current (dest);
|
|
|
|
context_return_if_fail (dest);
|
|
|
|
|
|
|
|
for (arg = 0; arg < GIMP_CONTEXT_NUM_ARGS; arg++)
|
|
|
|
if ((1 << arg) & args_mask)
|
|
|
|
{
|
|
|
|
gimp_context_copy_arg (src, dest, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* attribute access functions */
|
1999-06-19 02:29:27 +08:00
|
|
|
|
1999-10-27 02:27: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
|
|
|
/* image *******************************************************************/
|
|
|
|
|
|
|
|
GimpImage *
|
|
|
|
gimp_context_get_image (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_val_if_fail (context, NULL);
|
|
|
|
|
|
|
|
return context->image;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_set_image (GimpContext *context,
|
|
|
|
GimpImage *image)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
1999-10-19 23:52:32 +08:00
|
|
|
context_find_defined (context, GIMP_CONTEXT_IMAGE_MASK);
|
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
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_context_real_set_image (context, image);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* handle disappearing images */
|
|
|
|
static void
|
|
|
|
gimp_context_image_removed (GimpSet *set,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
if (context->image == image)
|
|
|
|
gimp_context_real_set_image (context, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_context_real_set_image (GimpContext *context,
|
|
|
|
GimpImage *image)
|
|
|
|
{
|
1999-11-14 18:50:19 +08:00
|
|
|
if (context->image == image)
|
|
|
|
return;
|
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
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
if (image == NULL)
|
|
|
|
gtk_signal_disconnect_by_data (GTK_OBJECT (image_context), context);
|
|
|
|
|
|
|
|
if (context->image == NULL)
|
|
|
|
gtk_signal_connect (GTK_OBJECT (image_context), "remove",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_context_image_removed),
|
|
|
|
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->image = image;
|
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
|
|
|
gimp_context_signals[IMAGE_CHANGED],
|
|
|
|
image);
|
|
|
|
}
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_copy_image (GimpContext *src,
|
|
|
|
GimpContext *dest)
|
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
|
|
|
{
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_context_real_set_image (dest, src->image);
|
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
|
|
|
}
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_image_changed (GimpContext *parent,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpContext *child)
|
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
|
|
|
{
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_context_real_set_image (child, image);
|
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
|
|
|
}
|
|
|
|
|
1999-10-27 02:27: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
|
|
|
/* display *****************************************************************/
|
|
|
|
|
|
|
|
GDisplay *
|
|
|
|
gimp_context_get_display (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_val_if_fail (context, NULL);
|
|
|
|
|
|
|
|
return context->display;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_set_display (GimpContext *context,
|
|
|
|
GDisplay *display)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
1999-10-19 23:52:32 +08:00
|
|
|
context_find_defined (context, GIMP_CONTEXT_DISPLAY_MASK);
|
|
|
|
|
|
|
|
gimp_context_real_set_display (context, 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
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
/* handle dissapearing displays */
|
|
|
|
static void
|
|
|
|
gimp_context_display_destroy (GtkWidget *disp_shell,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
context->display = NULL;
|
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
|
|
|
gimp_context_signals[DISPLAY_CHANGED],
|
|
|
|
NULL);
|
1999-10-19 23:52:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_context_real_set_display (GimpContext *context,
|
|
|
|
GDisplay *display)
|
|
|
|
{
|
1999-11-14 18:50:19 +08:00
|
|
|
if (context->display == display)
|
|
|
|
return;
|
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
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
if (context->display && GTK_IS_OBJECT (context->display->shell))
|
|
|
|
gtk_signal_disconnect_by_data (GTK_OBJECT (context->display->shell),
|
|
|
|
context);
|
|
|
|
|
|
|
|
if (display)
|
|
|
|
gtk_signal_connect (GTK_OBJECT (display->shell), "destroy",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_context_display_destroy),
|
|
|
|
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->display = display;
|
|
|
|
|
|
|
|
/* set the image _before_ emitting the display_changed signal */
|
|
|
|
if (display)
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_context_real_set_image (context, display->gimage);
|
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),
|
|
|
|
gimp_context_signals[DISPLAY_CHANGED],
|
|
|
|
display);
|
|
|
|
}
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_copy_display (GimpContext *src,
|
|
|
|
GimpContext *dest)
|
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
|
|
|
{
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_context_real_set_display (dest, src->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
|
|
|
}
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_display_changed (GimpContext *parent,
|
|
|
|
GDisplay *display,
|
|
|
|
GimpContext *child)
|
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
|
|
|
{
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_context_real_set_display (child, 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
|
|
|
}
|
|
|
|
|
1999-10-27 02:27: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
|
|
|
/* tool ********************************************************************/
|
|
|
|
|
|
|
|
ToolType
|
|
|
|
gimp_context_get_tool (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_val_if_fail (context, 0);
|
|
|
|
|
|
|
|
return context->tool;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_set_tool (GimpContext *context,
|
|
|
|
ToolType tool)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
1999-10-19 23:52:32 +08:00
|
|
|
context_find_defined (context, GIMP_CONTEXT_TOOL_MASK);
|
|
|
|
|
|
|
|
gimp_context_real_set_tool (context, tool);
|
|
|
|
}
|
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
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_real_set_tool (GimpContext *context,
|
|
|
|
ToolType tool)
|
|
|
|
{
|
1999-11-14 18:50:19 +08:00
|
|
|
if (context->tool == tool)
|
|
|
|
return;
|
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 = tool;
|
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
|
|
|
gimp_context_signals[TOOL_CHANGED],
|
|
|
|
tool);
|
|
|
|
}
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_copy_tool (GimpContext *src,
|
|
|
|
GimpContext *dest)
|
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
|
|
|
{
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_context_real_set_tool (dest, src->tool);
|
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
|
|
|
}
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_tool_changed (GimpContext *parent,
|
|
|
|
ToolType tool,
|
|
|
|
GimpContext *child)
|
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
|
|
|
{
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_context_real_set_tool (child, tool);
|
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
|
|
|
}
|
|
|
|
|
1999-10-27 02:27: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
|
|
|
/* foreground color ********************************************************/
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_get_foreground (GimpContext *context,
|
1999-10-17 21:48:19 +08:00
|
|
|
guchar *r,
|
|
|
|
guchar *g,
|
|
|
|
guchar *b)
|
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_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
1999-10-17 21:48:19 +08:00
|
|
|
*r = context->foreground[0];
|
|
|
|
*g = context->foreground[1];
|
|
|
|
*b = context->foreground[2];
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_set_foreground (GimpContext *context,
|
1999-10-17 21:48:19 +08:00
|
|
|
gint r,
|
|
|
|
gint g,
|
|
|
|
gint b)
|
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_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
1999-10-19 23:52:32 +08:00
|
|
|
context_find_defined (context, GIMP_CONTEXT_FOREGROUND_MASK);
|
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
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_context_real_set_foreground (context, r, g, b);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_context_real_set_foreground (GimpContext *context,
|
|
|
|
gint r,
|
|
|
|
gint g,
|
|
|
|
gint b)
|
|
|
|
{
|
1999-10-17 21:48:19 +08:00
|
|
|
if (context->foreground[0] == r &&
|
|
|
|
context->foreground[1] == g &&
|
1999-11-14 18:50:19 +08:00
|
|
|
context->foreground[2] == b)
|
|
|
|
return;
|
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
|
|
|
|
1999-10-17 21:48:19 +08:00
|
|
|
context->foreground[0] = r;
|
|
|
|
context->foreground[1] = g;
|
|
|
|
context->foreground[2] = b;
|
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),
|
|
|
|
gimp_context_signals[FOREGROUND_CHANGED],
|
1999-10-17 21:48:19 +08:00
|
|
|
r, g, b);
|
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
|
|
|
}
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_copy_foreground (GimpContext *src,
|
|
|
|
GimpContext *dest)
|
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
|
|
|
{
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_context_real_set_foreground (dest,
|
|
|
|
src->foreground[0],
|
|
|
|
src->foreground[1],
|
|
|
|
src->foreground[2]);
|
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
|
|
|
}
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_foreground_changed (GimpContext *parent,
|
|
|
|
gint r,
|
|
|
|
gint g,
|
|
|
|
gint b,
|
|
|
|
GimpContext *child)
|
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
|
|
|
{
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_context_real_set_foreground (child, r, g, b);
|
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
|
|
|
}
|
|
|
|
|
1999-10-27 02:27: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
|
|
|
/* background color ********************************************************/
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_get_background (GimpContext *context,
|
1999-10-17 21:48:19 +08:00
|
|
|
guchar *r,
|
|
|
|
guchar *g,
|
|
|
|
guchar *b)
|
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_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
1999-10-17 21:48:19 +08:00
|
|
|
*r = context->background[0];
|
|
|
|
*g = context->background[1];
|
|
|
|
*b = context->background[2];
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_set_background (GimpContext *context,
|
1999-10-17 21:48:19 +08:00
|
|
|
gint r,
|
|
|
|
gint g,
|
|
|
|
gint b)
|
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_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
1999-10-19 23:52:32 +08:00
|
|
|
context_find_defined (context, GIMP_CONTEXT_BACKGROUND_MASK);
|
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
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_context_real_set_background (context, r, g, b);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_context_real_set_background (GimpContext *context,
|
|
|
|
gint r,
|
|
|
|
gint g,
|
|
|
|
gint b)
|
|
|
|
{
|
1999-10-17 21:48:19 +08:00
|
|
|
if (context->background[0] == r &&
|
|
|
|
context->background[1] == g &&
|
1999-11-14 18:50:19 +08:00
|
|
|
context->background[2] == b)
|
|
|
|
return;
|
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
|
|
|
|
1999-10-17 21:48:19 +08:00
|
|
|
context->background[0] = r;
|
|
|
|
context->background[1] = g;
|
|
|
|
context->background[2] = b;
|
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),
|
|
|
|
gimp_context_signals[BACKGROUND_CHANGED],
|
1999-10-17 21:48:19 +08:00
|
|
|
r, g, b);
|
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
|
|
|
}
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_copy_background (GimpContext *src,
|
|
|
|
GimpContext *dest)
|
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
|
|
|
{
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_context_real_set_foreground (dest,
|
|
|
|
src->background[0],
|
|
|
|
src->background[1],
|
|
|
|
src->background[2]);
|
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
|
|
|
}
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_background_changed (GimpContext *parent,
|
|
|
|
gint r,
|
|
|
|
gint g,
|
|
|
|
gint b,
|
|
|
|
GimpContext *child)
|
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
|
|
|
{
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_context_real_set_background (child, r, g, b);
|
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
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* color utility functions *************************************************/
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_set_default_colors (GimpContext *context)
|
|
|
|
{
|
|
|
|
GimpContext *bg_context;
|
|
|
|
|
|
|
|
bg_context = context;
|
|
|
|
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
context_find_defined (context, GIMP_CONTEXT_FOREGROUND_MASK);
|
|
|
|
context_find_defined (bg_context, GIMP_CONTEXT_BACKGROUND_MASK);
|
|
|
|
|
|
|
|
gimp_context_real_set_foreground (context, 0, 0, 0);
|
|
|
|
gimp_context_real_set_background (bg_context, 255, 255, 255);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_swap_colors (GimpContext *context)
|
|
|
|
{
|
|
|
|
GimpContext *bg_context;
|
|
|
|
guchar f_r, f_g, f_b;
|
|
|
|
guchar b_r, b_g, b_b;
|
|
|
|
|
|
|
|
bg_context = context;
|
|
|
|
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
context_find_defined (context, GIMP_CONTEXT_FOREGROUND_MASK);
|
|
|
|
context_find_defined (bg_context, GIMP_CONTEXT_BACKGROUND_MASK);
|
|
|
|
|
|
|
|
gimp_context_get_foreground (context, &f_r, &f_g, &f_b);
|
|
|
|
gimp_context_get_background (bg_context, &b_r, &b_g, &b_b);
|
|
|
|
|
|
|
|
gimp_context_real_set_foreground (context, b_r, b_g, b_b);
|
|
|
|
gimp_context_real_set_background (bg_context, f_r, f_g, f_b);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
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
|
|
|
/* 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);
|
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);
|
1999-10-19 23:52:32 +08:00
|
|
|
context_find_defined (context, GIMP_CONTEXT_OPACITY_MASK);
|
|
|
|
|
|
|
|
gimp_context_real_set_opacity (context, opacity);
|
|
|
|
}
|
1999-06-18 03:13:08 +08:00
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_real_set_opacity (GimpContext *context,
|
|
|
|
gdouble opacity)
|
|
|
|
{
|
1999-11-14 18:50:19 +08:00
|
|
|
if (context->opacity == opacity)
|
|
|
|
return;
|
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
|
|
|
|
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-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_copy_opacity (GimpContext *src,
|
|
|
|
GimpContext *dest)
|
1999-06-19 02:29:27 +08:00
|
|
|
{
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_context_real_set_opacity (dest, src->opacity);
|
1999-06-19 02:29:27 +08:00
|
|
|
}
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_opacity_changed (GimpContext *parent,
|
|
|
|
gdouble opacity,
|
|
|
|
GimpContext *child)
|
1999-06-19 02:29:27 +08:00
|
|
|
{
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_context_real_set_opacity (child, opacity);
|
1999-06-19 02:29:27 +08:00
|
|
|
}
|
|
|
|
|
1999-10-27 02:27: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
|
|
|
/* 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);
|
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);
|
1999-10-19 23:52:32 +08:00
|
|
|
context_find_defined (context, GIMP_CONTEXT_PAINT_MODE_MASK);
|
|
|
|
|
|
|
|
gimp_context_real_set_paint_mode (context, paint_mode);
|
|
|
|
}
|
1999-06-18 03:13:08 +08:00
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_real_set_paint_mode (GimpContext *context,
|
|
|
|
LayerModeEffects paint_mode)
|
|
|
|
{
|
1999-11-14 18:50:19 +08:00
|
|
|
if (context->paint_mode == paint_mode)
|
|
|
|
return;
|
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
|
|
|
|
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
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_copy_paint_mode (GimpContext *src,
|
|
|
|
GimpContext *dest)
|
1999-06-19 02:29:27 +08:00
|
|
|
{
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_context_real_set_paint_mode (dest, src->paint_mode);
|
1999-06-19 02:29:27 +08:00
|
|
|
}
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_paint_mode_changed (GimpContext *parent,
|
|
|
|
LayerModeEffects paint_mode,
|
|
|
|
GimpContext *child)
|
1999-06-19 02:29:27 +08:00
|
|
|
{
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_context_real_set_paint_mode (child, paint_mode);
|
1999-06-19 02:29:27 +08:00
|
|
|
}
|
|
|
|
|
1999-10-27 02:27: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
|
|
|
/* brush *******************************************************************/
|
1999-06-19 02:29:27 +08:00
|
|
|
|
1999-11-14 18:50:19 +08:00
|
|
|
static GimpBrush *standard_brush = 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
|
|
|
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
|
|
|
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);
|
1999-10-19 23:52:32 +08:00
|
|
|
context_find_defined (context, GIMP_CONTEXT_BRUSH_MASK);
|
|
|
|
|
|
|
|
gimp_context_real_set_brush (context, brush);
|
|
|
|
}
|
1999-06-19 02:29:27 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/* the active brush was modified */
|
|
|
|
static void
|
|
|
|
gimp_context_brush_dirty (GimpBrush *brush,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
g_free (context->brush_name);
|
|
|
|
context->brush_name = g_strdup (brush->name);
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
|
|
|
gimp_context_signals[BRUSH_CHANGED],
|
|
|
|
brush);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the active brush disappeared */
|
|
|
|
static void
|
|
|
|
gimp_context_brush_removed (GimpBrushList *brush_list,
|
|
|
|
GimpBrush *brush,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
if (brush == context->brush)
|
|
|
|
{
|
|
|
|
context->brush = NULL;
|
|
|
|
|
|
|
|
gtk_signal_disconnect_by_data (GTK_OBJECT (brush), context);
|
|
|
|
gtk_signal_disconnect_by_data (GTK_OBJECT (brush_list), context);
|
|
|
|
gtk_object_unref (GTK_OBJECT (brush));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_real_set_brush (GimpContext *context,
|
|
|
|
GimpBrush *brush)
|
|
|
|
{
|
1999-11-14 18:50:19 +08:00
|
|
|
if (! standard_brush)
|
|
|
|
standard_brush = brushes_get_standard_brush ();
|
1999-06-20 21:53:15 +08:00
|
|
|
|
1999-11-14 18:50:19 +08:00
|
|
|
if (context->brush == brush)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (context->brush_name && brush != standard_brush)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
|
|
|
g_free (context->brush_name);
|
|
|
|
context->brush_name = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make sure the active brush is swapped before we get a new one... */
|
|
|
|
if (stingy_memory_use &&
|
|
|
|
context->brush && context->brush->mask &&
|
|
|
|
GTK_OBJECT (context->brush)->ref_count == 2)
|
|
|
|
{
|
|
|
|
temp_buf_swap (brush->mask);
|
|
|
|
}
|
|
|
|
|
1999-11-14 18:50:19 +08:00
|
|
|
/* disconnect from the old brush's signals */
|
1999-10-27 02:27:27 +08:00
|
|
|
if (context->brush)
|
|
|
|
{
|
|
|
|
gtk_signal_disconnect_by_data (GTK_OBJECT (context->brush), context);
|
|
|
|
gtk_object_unref (GTK_OBJECT (context->brush));
|
|
|
|
|
|
|
|
/* if we don't get a new brush, also disconnect from the brush list */
|
|
|
|
if (! brush)
|
|
|
|
{
|
|
|
|
gtk_signal_disconnect_by_data (GTK_OBJECT (brush_list), context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* if we get a new brush but didn't have one before... */
|
|
|
|
else if (brush)
|
|
|
|
{
|
|
|
|
/* ...connect to the brush list */
|
|
|
|
gtk_signal_connect (GTK_OBJECT (brush_list), "remove",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_context_brush_removed),
|
|
|
|
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->brush = brush;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
if (brush)
|
|
|
|
{
|
|
|
|
gtk_object_ref (GTK_OBJECT (brush));
|
|
|
|
gtk_signal_connect (GTK_OBJECT (brush), "dirty",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_context_brush_dirty),
|
|
|
|
context);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (brush), "rename",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_context_brush_dirty),
|
|
|
|
context);
|
|
|
|
|
|
|
|
/* Make sure the active brush is unswapped... */
|
|
|
|
if (stingy_memory_use &&
|
|
|
|
brush->mask &&
|
1999-11-14 18:50:19 +08:00
|
|
|
GTK_OBJECT (brush)->ref_count < 2)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
|
|
|
temp_buf_unswap (brush->mask);
|
|
|
|
}
|
|
|
|
|
1999-11-14 18:50:19 +08:00
|
|
|
if (brush != standard_brush)
|
|
|
|
context->brush_name = g_strdup (brush->name);
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_copy_brush (GimpContext *src,
|
|
|
|
GimpContext *dest)
|
1999-06-19 02:29:27 +08:00
|
|
|
{
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_context_real_set_brush (dest, src->brush);
|
1999-11-14 18:50:19 +08:00
|
|
|
|
|
|
|
if ((!src->brush || src->brush == standard_brush) && src->brush_name)
|
|
|
|
{
|
|
|
|
g_free (dest->brush_name);
|
|
|
|
dest->brush_name = g_strdup (src->brush_name);
|
|
|
|
}
|
1999-06-19 02:29:27 +08:00
|
|
|
}
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_brush_changed (GimpContext *parent,
|
|
|
|
GimpBrush *brush,
|
|
|
|
GimpContext *child)
|
1999-06-19 02:29:27 +08:00
|
|
|
{
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_context_real_set_brush (child, brush);
|
1999-06-19 02:29:27 +08:00
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
static void
|
|
|
|
gimp_context_refresh_brush (GimpContext *context,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpBrush *brush;
|
|
|
|
|
|
|
|
if (! context->brush_name)
|
|
|
|
context->brush_name = g_strdup (default_brush);
|
|
|
|
|
|
|
|
if ((brush = gimp_brush_list_get_brush (brush_list, context->brush_name)))
|
|
|
|
{
|
|
|
|
gimp_context_real_set_brush (context, brush);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gimp_brush_list_length (brush_list))
|
|
|
|
gimp_context_real_set_brush
|
|
|
|
(context, gimp_brush_list_get_brush_by_index (brush_list, 0));
|
|
|
|
else
|
|
|
|
gimp_context_real_set_brush (context, brushes_get_standard_brush ());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_refresh_brushes (void)
|
|
|
|
{
|
|
|
|
g_slist_foreach (context_list, (GFunc) gimp_context_refresh_brush, 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
|
|
|
/* pattern *****************************************************************/
|
1999-06-19 02:29:27 +08:00
|
|
|
|
1999-11-14 18:50:19 +08:00
|
|
|
static GPattern *standard_pattern = 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
|
|
|
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
|
|
|
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);
|
1999-10-19 23:52:32 +08:00
|
|
|
context_find_defined (context, GIMP_CONTEXT_PATTERN_MASK);
|
|
|
|
|
|
|
|
gimp_context_real_set_pattern (context, pattern);
|
|
|
|
}
|
1999-06-19 02:29:27 +08:00
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_real_set_pattern (GimpContext *context,
|
|
|
|
GPattern *pattern)
|
|
|
|
{
|
1999-11-14 18:50:19 +08:00
|
|
|
if (! standard_pattern)
|
|
|
|
standard_pattern = patterns_get_standard_pattern ();
|
1999-06-20 21:53:15 +08:00
|
|
|
|
1999-11-14 18:50:19 +08:00
|
|
|
if (context->pattern == pattern)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (context->pattern_name && pattern != standard_pattern)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
|
|
|
g_free (context->pattern_name);
|
|
|
|
context->pattern_name = 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->pattern = pattern;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1999-11-14 18:50:19 +08:00
|
|
|
if (pattern && pattern != standard_pattern)
|
1999-10-27 02:27:27 +08:00
|
|
|
context->pattern_name = g_strdup (pattern->name);
|
|
|
|
|
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),
|
|
|
|
gimp_context_signals[PATTERN_CHANGED],
|
|
|
|
pattern);
|
|
|
|
}
|
1999-06-20 21:53:15 +08:00
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_copy_pattern (GimpContext *src,
|
|
|
|
GimpContext *dest)
|
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
|
|
|
{
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_context_real_set_pattern (dest, src->pattern);
|
1999-11-14 18:50:19 +08:00
|
|
|
|
|
|
|
if ((!src->pattern || src->pattern == standard_pattern) && src->pattern_name)
|
|
|
|
{
|
|
|
|
g_free (dest->pattern_name);
|
|
|
|
dest->pattern_name = g_strdup (src->pattern_name);
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_pattern_changed (GimpContext *parent,
|
|
|
|
GPattern *pattern,
|
|
|
|
GimpContext *child)
|
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
|
|
|
{
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_context_real_set_pattern (child, pattern);
|
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
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
static void
|
|
|
|
gimp_context_refresh_pattern (GimpContext *context,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GPattern *pattern;
|
|
|
|
|
|
|
|
if (! context->pattern_name)
|
|
|
|
context->pattern_name = g_strdup (default_pattern);
|
|
|
|
|
|
|
|
if ((pattern = pattern_list_get_pattern (pattern_list,
|
|
|
|
context->pattern_name)))
|
|
|
|
{
|
1999-11-14 18:50:19 +08:00
|
|
|
gimp_context_real_set_pattern (context, pattern);
|
1999-10-27 02:27:27 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((pattern = pattern_list_get_pattern_by_index (pattern_list, 0)))
|
|
|
|
gimp_context_real_set_pattern (context, pattern);
|
|
|
|
else
|
|
|
|
gimp_context_real_set_pattern (context, patterns_get_standard_pattern ());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_refresh_patterns (void)
|
|
|
|
{
|
|
|
|
g_slist_foreach (context_list, (GFunc) gimp_context_refresh_pattern, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_context_update_pattern (GimpContext *context,
|
|
|
|
GPattern *pattern)
|
|
|
|
{
|
|
|
|
if (context->pattern == pattern)
|
|
|
|
{
|
|
|
|
if (context->pattern_name)
|
|
|
|
g_free (context->pattern_name);
|
|
|
|
|
|
|
|
context->pattern_name = g_strdup (pattern->name);
|
1999-11-14 18:50:19 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
|
|
|
gimp_context_signals[PATTERN_CHANGED],
|
|
|
|
pattern);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_update_patterns (GPattern *pattern)
|
|
|
|
{
|
|
|
|
g_slist_foreach (context_list, (GFunc) gimp_context_update_pattern, pattern);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
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
|
|
|
/* gradient ****************************************************************/
|
|
|
|
|
1999-11-14 18:50:19 +08:00
|
|
|
static gradient_t *standard_gradient = 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
|
|
|
gradient_t *
|
|
|
|
gimp_context_get_gradient (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_val_if_fail (context, NULL);
|
|
|
|
|
|
|
|
return context->gradient;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_set_gradient (GimpContext *context,
|
|
|
|
gradient_t *gradient)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
1999-10-19 23:52:32 +08:00
|
|
|
context_find_defined (context, GIMP_CONTEXT_GRADIENT_MASK);
|
|
|
|
|
|
|
|
gimp_context_real_set_gradient (context, gradient);
|
|
|
|
}
|
1999-06-20 21:53:15 +08:00
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_real_set_gradient (GimpContext *context,
|
|
|
|
gradient_t *gradient)
|
|
|
|
{
|
1999-11-14 18:50:19 +08:00
|
|
|
if (! standard_gradient)
|
|
|
|
standard_gradient = gradients_get_standard_gradient ();
|
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
|
|
|
|
1999-11-14 18:50:19 +08:00
|
|
|
if (context->gradient == gradient)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (context->gradient_name && gradient != standard_gradient)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
|
|
|
g_free (context->gradient_name);
|
|
|
|
context->gradient_name = 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->gradient = gradient;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1999-11-14 18:50:19 +08:00
|
|
|
if (gradient && gradient != standard_gradient)
|
1999-10-27 02:27:27 +08:00
|
|
|
context->gradient_name = g_strdup (gradient->name);
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_copy_gradient (GimpContext *src,
|
|
|
|
GimpContext *dest)
|
1999-06-19 02:29:27 +08:00
|
|
|
{
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_context_real_set_gradient (dest, src->gradient);
|
1999-11-14 18:50:19 +08:00
|
|
|
|
|
|
|
if ((!src->gradient || src->gradient == standard_gradient) &&
|
|
|
|
src->gradient_name)
|
|
|
|
{
|
|
|
|
g_free (dest->gradient_name);
|
|
|
|
dest->gradient_name = g_strdup (src->gradient_name);
|
|
|
|
}
|
1999-06-19 02:29:27 +08:00
|
|
|
}
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_gradient_changed (GimpContext *parent,
|
|
|
|
gradient_t *gradient,
|
|
|
|
GimpContext *child)
|
1999-06-19 02:29:27 +08:00
|
|
|
{
|
1999-10-19 23:52:32 +08:00
|
|
|
gimp_context_real_set_gradient (child, gradient);
|
1999-06-19 02:29:27 +08:00
|
|
|
}
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_context_refresh_gradient (GimpContext *context,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
gradient_t *gradient;
|
|
|
|
|
|
|
|
if (! context->gradient_name)
|
|
|
|
context->gradient_name = g_strdup (default_gradient);
|
|
|
|
|
1999-10-28 23:05:49 +08:00
|
|
|
if ((gradient = gradient_list_get_gradient (gradients_list,
|
|
|
|
context->gradient_name)))
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
1999-11-14 18:50:19 +08:00
|
|
|
gimp_context_real_set_gradient (context, gradient);
|
1999-10-28 23:05:49 +08:00
|
|
|
return;
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (gradients_list)
|
|
|
|
gimp_context_real_set_gradient (context,
|
|
|
|
(gradient_t *) gradients_list->data);
|
|
|
|
else
|
|
|
|
gimp_context_real_set_gradient (context, gradients_get_standard_gradient ());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_refresh_gradients (void)
|
|
|
|
{
|
|
|
|
g_slist_foreach (context_list, (GFunc) gimp_context_refresh_gradient, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_context_update_gradient (GimpContext *context,
|
|
|
|
gradient_t *gradient)
|
|
|
|
{
|
|
|
|
if (context->gradient == gradient)
|
|
|
|
{
|
|
|
|
if (context->gradient_name)
|
|
|
|
g_free (context->gradient_name);
|
|
|
|
|
|
|
|
context->gradient_name = g_strdup (gradient->name);
|
1999-11-14 18:50:19 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
|
|
|
gimp_context_signals[GRADIENT_CHANGED],
|
|
|
|
gradient);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_update_gradients (gradient_t *gradient)
|
|
|
|
{
|
|
|
|
g_slist_foreach (context_list, (GFunc) gimp_context_update_gradient, gradient);
|
|
|
|
}
|