1999-06-18 03:13:08 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2001-04-24 00:58:18 +08:00
|
|
|
* gimpcontext.c
|
|
|
|
* Copyright (C) 1999-2001 Michael Natterer
|
1999-10-19 23:52:32 +08:00
|
|
|
*
|
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.
|
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
1999-06-19 02:29:27 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-01-24 02:49:44 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "core-types.h"
|
|
|
|
|
2001-05-15 19:25:25 +08:00
|
|
|
#include "base/base-config.h"
|
|
|
|
#include "base/temp-buf.h"
|
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
#include "gimp.h"
|
1999-10-27 02:27:27 +08:00
|
|
|
#include "gimpbrush.h"
|
2001-06-26 20:09:43 +08:00
|
|
|
#include "gimpbuffer.h"
|
2001-02-06 01:48:50 +08:00
|
|
|
#include "gimpcontainer.h"
|
1999-06-18 03:13:08 +08:00
|
|
|
#include "gimpcontext.h"
|
2001-02-14 03:53:07 +08:00
|
|
|
#include "gimpdatafactory.h"
|
2001-02-11 03:35:29 +08:00
|
|
|
#include "gimpgradient.h"
|
2001-02-07 23:01:52 +08:00
|
|
|
#include "gimpimage.h"
|
2001-01-10 08:36:54 +08:00
|
|
|
#include "gimpmarshal.h"
|
2001-02-12 00:14:25 +08:00
|
|
|
#include "gimppalette.h"
|
2001-02-05 01:34:30 +08:00
|
|
|
#include "gimppattern.h"
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "gimptoolinfo.h"
|
|
|
|
|
|
|
|
#include "gdisplay.h"
|
1999-10-27 02:27:27 +08:00
|
|
|
#include "gimprc.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-02-07 23:01:52 +08:00
|
|
|
typedef void (* GimpContextCopyArgFunc) (GimpContext *src,
|
|
|
|
GimpContext *dest);
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
/* local function prototypes */
|
1999-11-14 18:50:19 +08:00
|
|
|
|
2001-02-07 23:01:52 +08:00
|
|
|
static void gimp_context_class_init (GimpContextClass *klass);
|
|
|
|
static void gimp_context_init (GimpContext *context);
|
|
|
|
static void gimp_context_destroy (GtkObject *object);
|
|
|
|
static void gimp_context_set_arg (GtkObject *object,
|
|
|
|
GtkArg *arg,
|
|
|
|
guint arg_id);
|
|
|
|
static void gimp_context_get_arg (GtkObject *object,
|
|
|
|
GtkArg *arg,
|
|
|
|
guint arg_id);
|
|
|
|
|
1999-11-14 18:50:19 +08:00
|
|
|
/* image */
|
2001-02-12 11:27:28 +08:00
|
|
|
static void gimp_context_image_removed (GimpContainer *container,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpContext *context);
|
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);
|
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);
|
|
|
|
|
|
|
|
/* tool */
|
2001-02-21 20:18:09 +08:00
|
|
|
static void gimp_context_tool_dirty (GimpToolInfo *tool_info,
|
|
|
|
GimpContext *context);
|
|
|
|
static void gimp_context_tool_removed (GimpContainer *container,
|
|
|
|
GimpToolInfo *tool_info,
|
|
|
|
GimpContext *context);
|
|
|
|
static void gimp_context_tool_list_thaw (GimpContainer *container,
|
|
|
|
GimpContext *context);
|
1999-11-14 18:50:19 +08:00
|
|
|
static void gimp_context_real_set_tool (GimpContext *context,
|
2001-02-21 20:18:09 +08:00
|
|
|
GimpToolInfo *tool_info);
|
1999-11-14 18:50:19 +08:00
|
|
|
static void gimp_context_copy_tool (GimpContext *src,
|
|
|
|
GimpContext *dest);
|
|
|
|
|
|
|
|
/* foreground */
|
|
|
|
static void gimp_context_real_set_foreground (GimpContext *context,
|
2001-01-20 23:37:26 +08:00
|
|
|
const GimpRGB *color);
|
1999-11-14 18:50:19 +08:00
|
|
|
static void gimp_context_copy_foreground (GimpContext *src,
|
|
|
|
GimpContext *dest);
|
|
|
|
|
|
|
|
/* background */
|
|
|
|
static void gimp_context_real_set_background (GimpContext *context,
|
2001-01-20 23:37:26 +08:00
|
|
|
const GimpRGB *color);
|
1999-11-14 18:50:19 +08:00
|
|
|
static void gimp_context_copy_background (GimpContext *src,
|
|
|
|
GimpContext *dest);
|
|
|
|
|
|
|
|
/* opacity */
|
|
|
|
static void gimp_context_real_set_opacity (GimpContext *context,
|
|
|
|
gdouble opacity);
|
|
|
|
static void gimp_context_copy_opacity (GimpContext *src,
|
|
|
|
GimpContext *dest);
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
|
|
|
/* brush */
|
2001-02-05 01:34:30 +08:00
|
|
|
static void gimp_context_brush_dirty (GimpBrush *brush,
|
|
|
|
GimpContext *context);
|
|
|
|
static void gimp_context_brush_removed (GimpContainer *brush_list,
|
|
|
|
GimpBrush *brush,
|
|
|
|
GimpContext *context);
|
2001-02-12 11:27:28 +08:00
|
|
|
static void gimp_context_brush_list_thaw (GimpContainer *container,
|
|
|
|
GimpContext *context);
|
1999-11-14 18:50:19 +08:00
|
|
|
static void gimp_context_real_set_brush (GimpContext *context,
|
|
|
|
GimpBrush *brush);
|
|
|
|
static void gimp_context_copy_brush (GimpContext *src,
|
|
|
|
GimpContext *dest);
|
|
|
|
|
|
|
|
/* pattern */
|
2001-02-05 01:34:30 +08:00
|
|
|
static void gimp_context_pattern_dirty (GimpPattern *pattern,
|
|
|
|
GimpContext *context);
|
2001-02-21 20:18:09 +08:00
|
|
|
static void gimp_context_pattern_removed (GimpContainer *container,
|
2001-02-05 01:34:30 +08:00
|
|
|
GimpPattern *pattern,
|
|
|
|
GimpContext *context);
|
2001-02-12 11:27:28 +08:00
|
|
|
static void gimp_context_pattern_list_thaw (GimpContainer *container,
|
|
|
|
GimpContext *context);
|
1999-11-14 18:50:19 +08:00
|
|
|
static void gimp_context_real_set_pattern (GimpContext *context,
|
2001-02-05 01:34:30 +08:00
|
|
|
GimpPattern *pattern);
|
1999-11-14 18:50:19 +08:00
|
|
|
static void gimp_context_copy_pattern (GimpContext *src,
|
|
|
|
GimpContext *dest);
|
|
|
|
|
|
|
|
/* gradient */
|
2001-02-12 11:27:28 +08:00
|
|
|
static void gimp_context_gradient_dirty (GimpGradient *gradient,
|
|
|
|
GimpContext *context);
|
|
|
|
static void gimp_context_gradient_removed (GimpContainer *container,
|
|
|
|
GimpGradient *gradient,
|
|
|
|
GimpContext *context);
|
|
|
|
static void gimp_context_gradient_list_thaw (GimpContainer *container,
|
|
|
|
GimpContext *context);
|
1999-11-14 18:50:19 +08:00
|
|
|
static void gimp_context_real_set_gradient (GimpContext *context,
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradient *gradient);
|
1999-11-14 18:50:19 +08:00
|
|
|
static void gimp_context_copy_gradient (GimpContext *src,
|
|
|
|
GimpContext *dest);
|
1999-10-19 23:52:32 +08:00
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
/* palette */
|
|
|
|
static void gimp_context_palette_dirty (GimpPalette *palette,
|
|
|
|
GimpContext *context);
|
2001-02-21 20:18:09 +08:00
|
|
|
static void gimp_context_palette_removed (GimpContainer *container,
|
2001-02-12 00:14:25 +08:00
|
|
|
GimpPalette *palatte,
|
|
|
|
GimpContext *context);
|
2001-02-12 11:27:28 +08:00
|
|
|
static void gimp_context_palette_list_thaw (GimpContainer *container,
|
|
|
|
GimpContext *context);
|
2001-02-12 00:14:25 +08:00
|
|
|
static void gimp_context_real_set_palette (GimpContext *context,
|
|
|
|
GimpPalette *palatte);
|
|
|
|
static void gimp_context_copy_palette (GimpContext *src,
|
|
|
|
GimpContext *dest);
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
/* buffer */
|
|
|
|
static void gimp_context_buffer_dirty (GimpBuffer *buffer,
|
|
|
|
GimpContext *context);
|
|
|
|
static void gimp_context_buffer_removed (GimpContainer *container,
|
|
|
|
GimpBuffer *buffer,
|
|
|
|
GimpContext *context);
|
|
|
|
static void gimp_context_buffer_list_thaw (GimpContainer *container,
|
|
|
|
GimpContext *context);
|
|
|
|
static void gimp_context_real_set_buffer (GimpContext *context,
|
|
|
|
GimpBuffer *buffer);
|
|
|
|
static void gimp_context_copy_buffer (GimpContext *src,
|
|
|
|
GimpContext *dest);
|
|
|
|
|
2001-02-07 23:01:52 +08:00
|
|
|
|
|
|
|
/* arguments & signals */
|
1999-11-14 18:50:19 +08:00
|
|
|
|
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,
|
2001-02-12 00:14:25 +08:00
|
|
|
ARG_GRADIENT,
|
2001-06-26 20:09:43 +08:00
|
|
|
ARG_PALETTE,
|
|
|
|
ARG_BUFFER
|
1999-06-20 21:53:15 +08:00
|
|
|
};
|
|
|
|
|
2001-02-07 23:01:52 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
IMAGE_CHANGED,
|
|
|
|
DISPLAY_CHANGED,
|
|
|
|
TOOL_CHANGED,
|
|
|
|
FOREGROUND_CHANGED,
|
|
|
|
BACKGROUND_CHANGED,
|
|
|
|
OPACITY_CHANGED,
|
|
|
|
PAINT_MODE_CHANGED,
|
|
|
|
BRUSH_CHANGED,
|
|
|
|
PATTERN_CHANGED,
|
|
|
|
GRADIENT_CHANGED,
|
2001-02-12 00:14:25 +08:00
|
|
|
PALETTE_CHANGED,
|
2001-06-26 20:09:43 +08:00
|
|
|
BUFFER_CHANGED,
|
2001-02-07 23:01:52 +08:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
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",
|
2001-02-12 00:14:25 +08:00
|
|
|
"GimpContext::gradient",
|
2001-06-26 20:09:43 +08:00
|
|
|
"GimpContext::palette",
|
|
|
|
"GimpContext::buffer"
|
1999-10-19 23:52:32 +08:00
|
|
|
};
|
|
|
|
|
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,
|
2001-02-12 00:14:25 +08:00
|
|
|
gimp_context_copy_gradient,
|
2001-06-26 20:09:43 +08:00
|
|
|
gimp_context_copy_palette,
|
|
|
|
gimp_context_copy_buffer
|
1999-11-14 18:50:19 +08:00
|
|
|
};
|
|
|
|
|
2001-02-07 23:01:52 +08:00
|
|
|
static GtkType gimp_context_arg_types[] =
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-02-07 23:01:52 +08:00
|
|
|
0,
|
|
|
|
GTK_TYPE_NONE,
|
2001-02-21 20:18:09 +08:00
|
|
|
0,
|
2001-02-07 23:01:52 +08:00
|
|
|
GTK_TYPE_NONE,
|
|
|
|
GTK_TYPE_NONE,
|
|
|
|
GTK_TYPE_NONE,
|
|
|
|
GTK_TYPE_NONE,
|
|
|
|
0,
|
|
|
|
0,
|
2001-02-12 00:14:25 +08:00
|
|
|
0,
|
2001-06-26 20:09:43 +08:00
|
|
|
0,
|
2001-02-11 03:35:29 +08:00
|
|
|
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",
|
2001-02-12 00:14:25 +08:00
|
|
|
"gradient_changed",
|
2001-06-26 20:09:43 +08:00
|
|
|
"palette_changed",
|
|
|
|
"buffer_changed"
|
1999-10-19 23:52:32 +08:00
|
|
|
};
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
static GtkSignalFunc gimp_context_signal_handlers[] =
|
1999-10-19 23:52:32 +08:00
|
|
|
{
|
2000-02-23 01:06:44 +08:00
|
|
|
gimp_context_real_set_image,
|
|
|
|
gimp_context_real_set_display,
|
|
|
|
gimp_context_real_set_tool,
|
|
|
|
gimp_context_real_set_foreground,
|
|
|
|
gimp_context_real_set_background,
|
|
|
|
gimp_context_real_set_opacity,
|
|
|
|
gimp_context_real_set_paint_mode,
|
|
|
|
gimp_context_real_set_brush,
|
|
|
|
gimp_context_real_set_pattern,
|
2001-02-12 00:14:25 +08:00
|
|
|
gimp_context_real_set_gradient,
|
2001-06-26 20:09:43 +08:00
|
|
|
gimp_context_real_set_palette,
|
|
|
|
gimp_context_real_set_buffer
|
1999-10-19 23:52:32 +08:00
|
|
|
};
|
|
|
|
|
2001-02-07 23:01:52 +08:00
|
|
|
|
|
|
|
static guint gimp_context_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
1999-06-19 02:29:27 +08:00
|
|
|
static GimpObjectClass * parent_class = NULL;
|
1999-06-18 03:13:08 +08:00
|
|
|
|
|
|
|
/* the currently active context */
|
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
|
|
|
|
2001-02-07 23:01:52 +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-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);
|
|
|
|
|
2001-01-14 11:55:56 +08:00
|
|
|
parent_class = gtk_type_class (GIMP_TYPE_OBJECT);
|
|
|
|
|
2001-02-11 03:35:29 +08:00
|
|
|
gimp_context_arg_types[GIMP_CONTEXT_ARG_IMAGE] = GIMP_TYPE_IMAGE;
|
2001-04-24 00:58:18 +08:00
|
|
|
gimp_context_arg_types[GIMP_CONTEXT_ARG_TOOL] = GIMP_TYPE_TOOL_INFO;
|
2001-02-11 03:35:29 +08:00
|
|
|
gimp_context_arg_types[GIMP_CONTEXT_ARG_BRUSH] = GIMP_TYPE_BRUSH;
|
|
|
|
gimp_context_arg_types[GIMP_CONTEXT_ARG_PATTERN] = GIMP_TYPE_PATTERN;
|
|
|
|
gimp_context_arg_types[GIMP_CONTEXT_ARG_GRADIENT] = GIMP_TYPE_GRADIENT;
|
2001-02-12 00:14:25 +08:00
|
|
|
gimp_context_arg_types[GIMP_CONTEXT_ARG_PALETTE] = GIMP_TYPE_PALETTE;
|
2001-06-26 20:09:43 +08:00
|
|
|
gimp_context_arg_types[GIMP_CONTEXT_ARG_BUFFER] = GIMP_TYPE_BUFFER;
|
2001-02-07 23:01:52 +08:00
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
gtk_object_add_arg_type (gimp_context_arg_names[IMAGE_CHANGED],
|
2001-02-07 23:01:52 +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],
|
2001-02-07 23:01:52 +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],
|
2001-04-24 00:58:18 +08:00
|
|
|
GTK_TYPE_POINTER, GTK_ARG_READWRITE,
|
2001-02-07 23:01:52 +08:00
|
|
|
ARG_TOOL);
|
1999-10-19 23:52:32 +08:00
|
|
|
gtk_object_add_arg_type (gimp_context_arg_names[FOREGROUND_CHANGED],
|
2001-02-07 23:01:52 +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],
|
2001-02-07 23:01:52 +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],
|
2001-02-07 23:01:52 +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],
|
2001-02-07 23:01:52 +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],
|
2001-02-07 23:01:52 +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],
|
2001-02-07 23:01:52 +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],
|
2001-02-07 23:01:52 +08:00
|
|
|
GTK_TYPE_POINTER, GTK_ARG_READWRITE,
|
|
|
|
ARG_GRADIENT);
|
2001-02-12 00:14:25 +08:00
|
|
|
gtk_object_add_arg_type (gimp_context_arg_names[PALETTE_CHANGED],
|
|
|
|
GTK_TYPE_POINTER, GTK_ARG_READWRITE,
|
|
|
|
ARG_PALETTE);
|
2001-06-26 20:09:43 +08:00
|
|
|
gtk_object_add_arg_type (gimp_context_arg_names[BUFFER_CHANGED],
|
|
|
|
GTK_TYPE_POINTER, GTK_ARG_READWRITE,
|
|
|
|
ARG_BUFFER);
|
1999-06-20 21:53:15 +08:00
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
gimp_context_signals[IMAGE_CHANGED] =
|
2001-01-10 08:36:54 +08:00
|
|
|
gtk_signal_new (gimp_context_signal_names[IMAGE_CHANGED],
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
|
|
|
image_changed),
|
|
|
|
gtk_marshal_NONE__POINTER,
|
|
|
|
GTK_TYPE_NONE, 1,
|
|
|
|
GTK_TYPE_POINTER);
|
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[DISPLAY_CHANGED] =
|
2001-01-10 08:36:54 +08:00
|
|
|
gtk_signal_new (gimp_context_signal_names[DISPLAY_CHANGED],
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
|
|
|
display_changed),
|
|
|
|
gtk_marshal_NONE__POINTER,
|
|
|
|
GTK_TYPE_NONE, 1,
|
|
|
|
GTK_TYPE_POINTER);
|
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[TOOL_CHANGED] =
|
2001-01-10 08:36:54 +08:00
|
|
|
gtk_signal_new (gimp_context_signal_names[TOOL_CHANGED],
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
|
|
|
tool_changed),
|
2001-02-14 12:55:21 +08:00
|
|
|
gtk_marshal_NONE__POINTER,
|
2001-01-10 08:36:54 +08:00
|
|
|
GTK_TYPE_NONE, 1,
|
2001-02-14 12:55:21 +08:00
|
|
|
GTK_TYPE_POINTER);
|
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[FOREGROUND_CHANGED] =
|
2001-01-10 08:36:54 +08:00
|
|
|
gtk_signal_new (gimp_context_signal_names[FOREGROUND_CHANGED],
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
|
|
|
foreground_changed),
|
2001-01-15 09:48:53 +08:00
|
|
|
gtk_marshal_NONE__POINTER,
|
|
|
|
GTK_TYPE_NONE, 1,
|
|
|
|
GTK_TYPE_POINTER);
|
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] =
|
2001-01-10 08:36:54 +08:00
|
|
|
gtk_signal_new (gimp_context_signal_names[BACKGROUND_CHANGED],
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
|
|
|
background_changed),
|
2001-01-15 09:48:53 +08:00
|
|
|
gtk_marshal_NONE__POINTER,
|
|
|
|
GTK_TYPE_NONE, 1,
|
|
|
|
GTK_TYPE_POINTER);
|
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] =
|
2001-01-10 08:36:54 +08:00
|
|
|
gtk_signal_new (gimp_context_signal_names[OPACITY_CHANGED],
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
|
|
|
opacity_changed),
|
|
|
|
gimp_marshal_NONE__DOUBLE,
|
|
|
|
GTK_TYPE_NONE, 1,
|
|
|
|
GTK_TYPE_DOUBLE);
|
1999-06-18 03:13:08 +08:00
|
|
|
|
|
|
|
gimp_context_signals[PAINT_MODE_CHANGED] =
|
2001-01-10 08:36:54 +08:00
|
|
|
gtk_signal_new (gimp_context_signal_names[PAINT_MODE_CHANGED],
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
|
|
|
paint_mode_changed),
|
|
|
|
gtk_marshal_NONE__INT,
|
|
|
|
GTK_TYPE_NONE, 1,
|
|
|
|
GTK_TYPE_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] =
|
2001-01-10 08:36:54 +08:00
|
|
|
gtk_signal_new (gimp_context_signal_names[BRUSH_CHANGED],
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
|
|
|
brush_changed),
|
|
|
|
gtk_marshal_NONE__POINTER,
|
|
|
|
GTK_TYPE_NONE, 1,
|
|
|
|
GTK_TYPE_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] =
|
2001-01-10 08:36:54 +08:00
|
|
|
gtk_signal_new (gimp_context_signal_names[PATTERN_CHANGED],
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
|
|
|
pattern_changed),
|
|
|
|
gtk_marshal_NONE__POINTER,
|
|
|
|
GTK_TYPE_NONE, 1,
|
|
|
|
GTK_TYPE_POINTER);
|
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] =
|
2001-01-10 08:36:54 +08:00
|
|
|
gtk_signal_new (gimp_context_signal_names[GRADIENT_CHANGED],
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
|
|
|
gradient_changed),
|
|
|
|
gtk_marshal_NONE__POINTER,
|
|
|
|
GTK_TYPE_NONE, 1,
|
|
|
|
GTK_TYPE_POINTER);
|
1999-06-19 02:29:27 +08:00
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
gimp_context_signals[PALETTE_CHANGED] =
|
|
|
|
gtk_signal_new (gimp_context_signal_names[PALETTE_CHANGED],
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
|
|
|
palette_changed),
|
|
|
|
gtk_marshal_NONE__POINTER,
|
|
|
|
GTK_TYPE_NONE, 1,
|
|
|
|
GTK_TYPE_POINTER);
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
gimp_context_signals[BUFFER_CHANGED] =
|
|
|
|
gtk_signal_new (gimp_context_signal_names[BUFFER_CHANGED],
|
|
|
|
GTK_RUN_FIRST,
|
|
|
|
object_class->type,
|
|
|
|
GTK_SIGNAL_OFFSET (GimpContextClass,
|
|
|
|
buffer_changed),
|
|
|
|
gtk_marshal_NONE__POINTER,
|
|
|
|
GTK_TYPE_NONE, 1,
|
|
|
|
GTK_TYPE_POINTER);
|
|
|
|
|
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;
|
2001-02-12 00:14:25 +08:00
|
|
|
klass->palette_changed = NULL;
|
2001-06-26 20:09:43 +08:00
|
|
|
klass->buffer_changed = NULL;
|
1999-06-18 03:13:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_context_init (GimpContext *context)
|
|
|
|
{
|
2001-07-05 03:31:35 +08:00
|
|
|
context->gimp = NULL;
|
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
context->parent = NULL;
|
1999-06-19 02:29:27 +08:00
|
|
|
|
2001-02-12 00:14:25 +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
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
context->image = NULL;
|
|
|
|
context->display = 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
|
|
|
|
2001-02-21 20:18:09 +08:00
|
|
|
context->tool_info = NULL;
|
|
|
|
context->tool_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
|
|
|
|
2001-01-15 09:48:53 +08:00
|
|
|
gimp_rgba_set (&context->foreground, 0.0, 0.0, 0.0, 1.0);
|
|
|
|
gimp_rgba_set (&context->background, 1.0, 1.0, 1.0, 1.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
|
|
|
|
2001-02-12 00:14:25 +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
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
context->brush = NULL;
|
|
|
|
context->brush_name = NULL;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
context->pattern = NULL;
|
|
|
|
context->pattern_name = NULL;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
context->gradient = NULL;
|
|
|
|
context->gradient_name = NULL;
|
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
context->palette = NULL;
|
|
|
|
context->palette_name = NULL;
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
context->buffer = NULL;
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
context_list = g_slist_prepend (context_list, context);
|
1999-06-18 03:13:08 +08:00
|
|
|
}
|
|
|
|
|
2001-02-07 23:01:52 +08:00
|
|
|
static void
|
|
|
|
gimp_context_destroy (GtkObject *object)
|
|
|
|
{
|
|
|
|
GimpContext *context;
|
|
|
|
|
|
|
|
context = GIMP_CONTEXT (object);
|
|
|
|
|
|
|
|
if (context->parent)
|
|
|
|
gimp_context_unset_parent (context);
|
|
|
|
|
2001-04-24 00:58:18 +08:00
|
|
|
context_list = g_slist_remove (context_list, context);
|
|
|
|
|
|
|
|
context->image = NULL;
|
|
|
|
context->display = NULL;
|
|
|
|
|
2001-02-21 20:18:09 +08:00
|
|
|
if (context->tool_info)
|
2001-04-24 00:58:18 +08:00
|
|
|
{
|
|
|
|
gtk_object_unref (GTK_OBJECT (context->tool_info));
|
|
|
|
context->tool_info = NULL;
|
|
|
|
}
|
2001-02-21 20:18:09 +08:00
|
|
|
|
|
|
|
if (context->tool_name)
|
|
|
|
{
|
|
|
|
g_free (context->tool_name);
|
|
|
|
context->tool_name = NULL;
|
|
|
|
}
|
|
|
|
|
2001-02-07 23:01:52 +08:00
|
|
|
if (context->brush)
|
2001-04-24 00:58:18 +08:00
|
|
|
{
|
|
|
|
gtk_object_unref (GTK_OBJECT (context->brush));
|
|
|
|
context->brush = NULL;
|
|
|
|
}
|
2001-02-07 23:01:52 +08:00
|
|
|
|
|
|
|
if (context->brush_name)
|
|
|
|
{
|
|
|
|
g_free (context->brush_name);
|
|
|
|
context->brush_name = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (context->pattern)
|
2001-04-24 00:58:18 +08:00
|
|
|
{
|
|
|
|
gtk_object_unref (GTK_OBJECT (context->pattern));
|
|
|
|
context->pattern = NULL;
|
|
|
|
}
|
2001-02-07 23:01:52 +08:00
|
|
|
|
|
|
|
if (context->pattern_name)
|
|
|
|
{
|
|
|
|
g_free (context->pattern_name);
|
|
|
|
context->pattern_name = NULL;
|
|
|
|
}
|
|
|
|
|
2001-02-12 11:27:28 +08:00
|
|
|
if (context->gradient)
|
2001-04-24 00:58:18 +08:00
|
|
|
{
|
|
|
|
gtk_object_unref (GTK_OBJECT (context->gradient));
|
|
|
|
context->gradient = NULL;
|
|
|
|
}
|
2001-02-12 11:27:28 +08:00
|
|
|
|
2001-02-07 23:01:52 +08:00
|
|
|
if (context->gradient_name)
|
|
|
|
{
|
|
|
|
g_free (context->gradient_name);
|
|
|
|
context->gradient_name = NULL;
|
|
|
|
}
|
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
if (context->palette)
|
2001-04-24 00:58:18 +08:00
|
|
|
{
|
|
|
|
gtk_object_unref (GTK_OBJECT (context->palette));
|
|
|
|
context->palette = NULL;
|
|
|
|
}
|
2001-02-12 00:14:25 +08:00
|
|
|
|
|
|
|
if (context->palette_name)
|
|
|
|
{
|
|
|
|
g_free (context->palette_name);
|
|
|
|
context->palette_name = NULL;
|
|
|
|
}
|
|
|
|
|
2001-06-26 20:09:43 +08:00
|
|
|
if (context->buffer)
|
|
|
|
{
|
|
|
|
gtk_object_unref (GTK_OBJECT (context->buffer));
|
|
|
|
context->buffer = NULL;
|
|
|
|
}
|
|
|
|
|
2001-02-07 23:01:52 +08:00
|
|
|
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
|
|
|
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_context_set_arg (GtkObject *object,
|
|
|
|
GtkArg *arg,
|
|
|
|
guint arg_id)
|
|
|
|
{
|
|
|
|
GimpContext *context;
|
|
|
|
|
|
|
|
context = GIMP_CONTEXT (object);
|
|
|
|
|
|
|
|
switch (arg_id)
|
|
|
|
{
|
|
|
|
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:
|
2001-02-21 20:18:09 +08:00
|
|
|
gimp_context_set_tool (context, GTK_VALUE_POINTER (*arg));
|
2001-02-07 23:01:52 +08:00
|
|
|
break;
|
|
|
|
case ARG_FOREGROUND:
|
|
|
|
gimp_context_set_foreground (context, GTK_VALUE_POINTER (*arg));
|
|
|
|
break;
|
|
|
|
case ARG_BACKGROUND:
|
|
|
|
gimp_context_set_background (context, GTK_VALUE_POINTER (*arg));
|
|
|
|
break;
|
|
|
|
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;
|
|
|
|
case ARG_BRUSH:
|
|
|
|
gimp_context_set_brush (context, GTK_VALUE_POINTER (*arg));
|
|
|
|
break;
|
|
|
|
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));
|
|
|
|
break;
|
2001-02-12 00:14:25 +08:00
|
|
|
case ARG_PALETTE:
|
|
|
|
gimp_context_set_palette (context, GTK_VALUE_POINTER (*arg));
|
|
|
|
break;
|
2001-06-26 20:09:43 +08:00
|
|
|
case ARG_BUFFER:
|
|
|
|
gimp_context_set_buffer (context, GTK_VALUE_POINTER (*arg));
|
|
|
|
break;
|
2001-02-07 23:01:52 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_context_get_arg (GtkObject *object,
|
|
|
|
GtkArg *arg,
|
|
|
|
guint arg_id)
|
|
|
|
{
|
|
|
|
GimpContext *context;
|
|
|
|
|
|
|
|
context = GIMP_CONTEXT (object);
|
|
|
|
|
|
|
|
switch (arg_id)
|
|
|
|
{
|
|
|
|
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:
|
2001-02-21 20:18:09 +08:00
|
|
|
GTK_VALUE_POINTER (*arg) = gimp_context_get_tool (context);
|
2001-02-07 23:01:52 +08:00
|
|
|
break;
|
|
|
|
case ARG_FOREGROUND:
|
|
|
|
gimp_context_get_foreground (context, GTK_VALUE_POINTER (*arg));
|
|
|
|
break;
|
|
|
|
case ARG_BACKGROUND:
|
|
|
|
gimp_context_get_background (context, GTK_VALUE_POINTER (*arg));
|
|
|
|
break;
|
|
|
|
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;
|
|
|
|
case ARG_BRUSH:
|
|
|
|
GTK_VALUE_POINTER (*arg) = gimp_context_get_brush (context);
|
|
|
|
break;
|
|
|
|
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);
|
|
|
|
break;
|
2001-02-12 00:14:25 +08:00
|
|
|
case ARG_PALETTE:
|
|
|
|
GTK_VALUE_POINTER (*arg) = gimp_context_get_palette (context);
|
|
|
|
break;
|
2001-06-26 20:09:43 +08:00
|
|
|
case ARG_BUFFER:
|
|
|
|
GTK_VALUE_POINTER (*arg) = gimp_context_get_buffer (context);
|
|
|
|
break;
|
2001-02-07 23:01:52 +08:00
|
|
|
default:
|
|
|
|
arg->type = GTK_TYPE_INVALID;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2001-01-14 11:55:56 +08:00
|
|
|
context_type = gtk_type_unique (GIMP_TYPE_OBJECT, &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 *
|
2001-07-05 03:31:35 +08:00
|
|
|
gimp_context_new (Gimp *gimp,
|
|
|
|
const gchar *name,
|
1999-10-19 23:52:32 +08:00
|
|
|
GimpContext *template)
|
1999-06-18 03:13:08 +08:00
|
|
|
{
|
|
|
|
GimpContext *context;
|
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
g_return_val_if_fail (gimp != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
1999-06-19 02:29:27 +08:00
|
|
|
g_return_val_if_fail (!template || GIMP_IS_CONTEXT (template), NULL);
|
|
|
|
|
2001-01-14 11:55:56 +08:00
|
|
|
context = gtk_type_new (GIMP_TYPE_CONTEXT);
|
1999-06-18 03:13:08 +08:00
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
context->gimp = gimp;
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
/* FIXME: need unique names here */
|
2001-01-14 11:55:56 +08:00
|
|
|
if (! name)
|
|
|
|
name = "Unnamed";
|
|
|
|
|
|
|
|
gimp_object_set_name (GIMP_OBJECT (context), name);
|
1999-06-19 02:29:27 +08:00
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
gtk_signal_connect_while_alive (GTK_OBJECT (gimp->images), "remove",
|
2001-02-12 11:27:28 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimp_context_image_removed),
|
|
|
|
context,
|
|
|
|
GTK_OBJECT (context));
|
2001-04-24 00:58:18 +08:00
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
gtk_signal_connect_while_alive (GTK_OBJECT (gimp->tool_info_list),
|
2001-02-21 20:18:09 +08:00
|
|
|
"remove",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_context_tool_removed),
|
|
|
|
context,
|
|
|
|
GTK_OBJECT (context));
|
2001-07-05 03:31:35 +08:00
|
|
|
gtk_signal_connect_while_alive (GTK_OBJECT (gimp->tool_info_list),
|
2001-02-21 20:18:09 +08:00
|
|
|
"thaw",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_context_tool_list_thaw),
|
|
|
|
context,
|
|
|
|
GTK_OBJECT (context));
|
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
gtk_signal_connect_while_alive (GTK_OBJECT (gimp->brush_factory->container),
|
2001-02-14 03:53:07 +08:00
|
|
|
"remove",
|
2001-02-12 11:27:28 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimp_context_brush_removed),
|
|
|
|
context,
|
|
|
|
GTK_OBJECT (context));
|
2001-07-05 03:31:35 +08:00
|
|
|
gtk_signal_connect_while_alive (GTK_OBJECT (gimp->brush_factory->container),
|
2001-02-14 03:53:07 +08:00
|
|
|
"thaw",
|
2001-02-12 11:27:28 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimp_context_brush_list_thaw),
|
|
|
|
context,
|
|
|
|
GTK_OBJECT (context));
|
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
gtk_signal_connect_while_alive (GTK_OBJECT (gimp->pattern_factory->container),
|
2001-02-14 03:53:07 +08:00
|
|
|
"remove",
|
2001-02-12 11:27:28 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimp_context_pattern_removed),
|
|
|
|
context,
|
|
|
|
GTK_OBJECT (context));
|
2001-07-05 03:31:35 +08:00
|
|
|
gtk_signal_connect_while_alive (GTK_OBJECT (gimp->pattern_factory->container),
|
2001-02-14 03:53:07 +08:00
|
|
|
"thaw",
|
2001-02-12 11:27:28 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimp_context_pattern_list_thaw),
|
|
|
|
context,
|
|
|
|
GTK_OBJECT (context));
|
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
gtk_signal_connect_while_alive (GTK_OBJECT (gimp->gradient_factory->container),
|
2001-02-14 03:53:07 +08:00
|
|
|
"remove",
|
2001-02-12 11:27:28 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimp_context_gradient_removed),
|
|
|
|
context,
|
|
|
|
GTK_OBJECT (context));
|
2001-07-05 03:31:35 +08:00
|
|
|
gtk_signal_connect_while_alive (GTK_OBJECT (gimp->gradient_factory->container),
|
2001-02-14 03:53:07 +08:00
|
|
|
"thaw",
|
2001-02-12 11:27:28 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimp_context_gradient_list_thaw),
|
|
|
|
context,
|
|
|
|
GTK_OBJECT (context));
|
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
gtk_signal_connect_while_alive (GTK_OBJECT (gimp->palette_factory->container),
|
2001-02-14 03:53:07 +08:00
|
|
|
"remove",
|
2001-02-12 11:27:28 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimp_context_palette_removed),
|
|
|
|
context,
|
|
|
|
GTK_OBJECT (context));
|
2001-07-05 03:31:35 +08:00
|
|
|
gtk_signal_connect_while_alive (GTK_OBJECT (gimp->palette_factory->container),
|
2001-02-14 03:53:07 +08:00
|
|
|
"thaw",
|
2001-02-12 11:27:28 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimp_context_palette_list_thaw),
|
|
|
|
context,
|
|
|
|
GTK_OBJECT (context));
|
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
gtk_signal_connect_while_alive (GTK_OBJECT (gimp->named_buffers),
|
2001-06-26 20:09:43 +08:00
|
|
|
"remove",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_context_buffer_removed),
|
|
|
|
context,
|
|
|
|
GTK_OBJECT (context));
|
2001-07-05 03:31:35 +08:00
|
|
|
gtk_signal_connect_while_alive (GTK_OBJECT (gimp->named_buffers),
|
2001-06-26 20:09:43 +08:00
|
|
|
"thaw",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_context_buffer_list_thaw),
|
|
|
|
context,
|
|
|
|
GTK_OBJECT (context));
|
|
|
|
|
1999-06-19 02:29:27 +08:00
|
|
|
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 *
|
2001-07-05 03:31:35 +08:00
|
|
|
gimp_context_get_standard (Gimp *gimp)
|
1999-06-19 02:29:27 +08:00
|
|
|
{
|
2001-07-05 03:31:35 +08:00
|
|
|
g_return_val_if_fail (gimp != NULL, NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
|
|
|
|
1999-06-19 02:29:27 +08:00
|
|
|
if (! standard_context)
|
|
|
|
{
|
2001-07-05 03:31:35 +08:00
|
|
|
standard_context = gimp_context_new (gimp, "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
|
|
|
|
2001-01-14 11:55:56 +08:00
|
|
|
const gchar *
|
|
|
|
gimp_context_get_name (const GimpContext *context)
|
1999-06-20 04:20:59 +08:00
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_val_if_fail (context, NULL);
|
|
|
|
|
2001-01-14 11:55:56 +08:00
|
|
|
return gimp_object_get_name (GIMP_OBJECT (context));
|
1999-06-20 04:20:59 +08:00
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
void
|
|
|
|
gimp_context_set_name (GimpContext *context,
|
2000-11-18 08:25:42 +08:00
|
|
|
const gchar *name)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
2001-01-14 11:55:56 +08:00
|
|
|
if (! name)
|
|
|
|
name = "Unnamed";
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-01-14 11:55:56 +08:00
|
|
|
gimp_object_set_name (GIMP_OBJECT (context), name);
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
|
|
|
|
1999-06-20 04:20:59 +08:00
|
|
|
GimpContext *
|
2001-01-14 11:55:56 +08:00
|
|
|
gimp_context_get_parent (const GimpContext *context)
|
1999-06-20 04:20:59 +08:00
|
|
|
{
|
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));
|
|
|
|
|
2001-04-24 00:58:18 +08:00
|
|
|
if (context == parent || context->parent == parent)
|
1999-11-14 18:50:19 +08:00
|
|
|
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);
|
2000-02-23 01:06:44 +08:00
|
|
|
gtk_signal_connect_object (GTK_OBJECT (parent),
|
|
|
|
gimp_context_signal_names[arg],
|
|
|
|
gimp_context_signal_handlers[arg],
|
|
|
|
GTK_OBJECT (context));
|
1999-10-19 23:52:32 +08:00
|
|
|
}
|
|
|
|
|
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);
|
2000-02-23 01:06:44 +08:00
|
|
|
gtk_signal_connect_object (GTK_OBJECT (context->parent),
|
|
|
|
gimp_context_signal_names[arg],
|
|
|
|
gimp_context_signal_handlers[arg],
|
|
|
|
GTK_OBJECT (context));
|
1999-10-19 23:52:32 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2000-02-23 01:06:44 +08:00
|
|
|
gimp_context_define_args (GimpContext *context,
|
|
|
|
GimpContextArgMask args_mask,
|
|
|
|
gboolean defined)
|
1999-10-19 23:52:32 +08:00
|
|
|
{
|
|
|
|
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));
|
|
|
|
|
2001-04-24 00:58:18 +08:00
|
|
|
gimp_context_copy_arg_funcs[arg] (src, dest);
|
1999-10-19 23:52:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2001-02-07 23:01:52 +08:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* manipulate by GtkType ***************************************************/
|
|
|
|
|
|
|
|
GimpContextArgType
|
|
|
|
gimp_context_type_to_arg (GtkType type)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < GIMP_CONTEXT_NUM_ARGS; i++)
|
|
|
|
{
|
2001-03-05 06:07:19 +08:00
|
|
|
if (gtk_type_is_a (type, gimp_context_arg_types[i]))
|
2001-02-07 23:01:52 +08:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
const gchar *
|
|
|
|
gimp_context_type_to_signal_name (GtkType type)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
for (i = 0; i < GIMP_CONTEXT_NUM_ARGS; i++)
|
|
|
|
{
|
2001-04-24 00:58:18 +08:00
|
|
|
if (gtk_type_is_a (type, gimp_context_arg_types[i]))
|
2001-02-07 23:01:52 +08:00
|
|
|
return gimp_context_signal_names[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
GimpObject *
|
|
|
|
gimp_context_get_by_type (GimpContext *context,
|
|
|
|
GtkType type)
|
|
|
|
{
|
|
|
|
GimpContextArgType arg;
|
|
|
|
GimpObject *object = NULL;
|
|
|
|
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_val_if_fail (context, NULL);
|
|
|
|
g_return_val_if_fail ((arg = gimp_context_type_to_arg (type)) != -1, NULL);
|
|
|
|
|
|
|
|
gtk_object_get (GTK_OBJECT (context),
|
|
|
|
gimp_context_arg_names[arg], &object,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return object;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_set_by_type (GimpContext *context,
|
|
|
|
GtkType type,
|
|
|
|
GimpObject *object)
|
|
|
|
{
|
|
|
|
GimpContextArgType arg;
|
|
|
|
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
g_return_if_fail ((arg = gimp_context_type_to_arg (type)) != -1);
|
|
|
|
|
|
|
|
gtk_object_set (GTK_OBJECT (context),
|
|
|
|
gimp_context_arg_names[arg], object,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_changed_by_type (GimpContext *context,
|
|
|
|
GtkType type)
|
|
|
|
{
|
|
|
|
GimpContextArgType arg;
|
|
|
|
GimpObject *object;
|
|
|
|
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
g_return_if_fail ((arg = gimp_context_type_to_arg (type)) != -1);
|
|
|
|
|
|
|
|
object = gimp_context_get_by_type (context, type);
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
|
|
|
gimp_context_signals[arg],
|
|
|
|
object);
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2000-02-23 01:06:44 +08:00
|
|
|
void
|
|
|
|
gimp_context_image_changed (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
|
|
|
gimp_context_signals[IMAGE_CHANGED],
|
|
|
|
context->image);
|
|
|
|
}
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
/* handle disappearing images */
|
|
|
|
static void
|
2001-02-04 22:10:03 +08:00
|
|
|
gimp_context_image_removed (GimpContainer *container,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpContext *context)
|
1999-10-19 23:52:32 +08:00
|
|
|
{
|
|
|
|
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
|
|
|
|
|
|
|
context->image = image;
|
2001-02-12 11:27:28 +08:00
|
|
|
|
2000-02-23 01:06:44 +08:00
|
|
|
gimp_context_image_changed (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
|
|
|
}
|
|
|
|
|
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-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
|
|
|
|
2000-02-23 01:06:44 +08:00
|
|
|
void
|
|
|
|
gimp_context_display_changed (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
|
|
|
gimp_context_signals[DISPLAY_CHANGED],
|
|
|
|
context->display);
|
|
|
|
}
|
|
|
|
|
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;
|
2000-02-23 01:06:44 +08:00
|
|
|
gimp_context_display_changed (context);
|
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)
|
2001-02-12 11:27:28 +08:00
|
|
|
gtk_signal_connect_while_alive
|
|
|
|
(GTK_OBJECT (display->shell), "destroy",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_context_display_destroy),
|
|
|
|
context,
|
|
|
|
GTK_OBJECT (context));
|
1999-10-19 23:52:32 +08:00
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
context->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
|
|
|
|
2000-02-23 01:06:44 +08:00
|
|
|
gimp_context_display_changed (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
|
|
|
}
|
|
|
|
|
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-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 ********************************************************************/
|
|
|
|
|
2001-02-24 05:32:47 +08:00
|
|
|
static GimpToolInfo *standard_tool_info = NULL;
|
|
|
|
|
2001-02-21 20:18:09 +08:00
|
|
|
GimpToolInfo *
|
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_get_tool (GimpContext *context)
|
|
|
|
{
|
2001-02-21 20:18:09 +08:00
|
|
|
g_return_val_if_fail (! context || GIMP_IS_CONTEXT (context), NULL);
|
|
|
|
|
added the possibility to store the current tool, FG/BG color, brush,
1999-10-17 Michael Natterer <mitch@gimp.org>
* app/gimpcontext.[ch]: added the possibility to store the current
tool, FG/BG color, brush, pattern and gradient, but don't use
these attributes yet.
Before replacing the get/set color/brush/... functions with
context functions, I'll have to change the "parent context"
implementation to something where the children catch the parent's
color/brush/..._changed signals.
Finally, updating the indicator_area, device_status, tool_options
etc. will be done by connecting to their own context's "*_changed"
signals, which will be much cleaner than calling the update
functions from various places.
(I think this is a "consistency fix", please let me know if you
consider it a new feature).
1999-10-17 20:28:38 +08:00
|
|
|
context_check_current (context);
|
2001-02-21 20:18:09 +08:00
|
|
|
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
|
|
|
|
2001-02-21 20:18:09 +08:00
|
|
|
return context->tool_info;
|
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
|
2001-02-21 20:18:09 +08:00
|
|
|
gimp_context_set_tool (GimpContext *context,
|
|
|
|
GimpToolInfo *tool_info)
|
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
|
|
|
{
|
2001-02-21 20:18:09 +08:00
|
|
|
g_return_if_fail (! context || GIMP_IS_CONTEXT (context));
|
|
|
|
g_return_if_fail (! tool_info || GIMP_IS_TOOL_INFO (tool_info));
|
|
|
|
|
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_TOOL_MASK);
|
|
|
|
|
2001-02-21 20:18:09 +08:00
|
|
|
gimp_context_real_set_tool (context, tool_info);
|
1999-10-19 23:52:32 +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
|
|
|
|
2000-02-23 01:06:44 +08:00
|
|
|
void
|
|
|
|
gimp_context_tool_changed (GimpContext *context)
|
|
|
|
{
|
2001-02-21 20:18:09 +08:00
|
|
|
g_return_if_fail (! context || GIMP_IS_CONTEXT (context));
|
|
|
|
|
2000-02-23 01:06:44 +08:00
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
|
|
|
gimp_context_signals[TOOL_CHANGED],
|
2001-02-21 20:18:09 +08:00
|
|
|
context->tool_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the active tool was modified */
|
|
|
|
static void
|
|
|
|
gimp_context_tool_dirty (GimpToolInfo *tool_info,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
g_free (context->tool_name);
|
|
|
|
context->tool_name = g_strdup (GIMP_OBJECT (tool_info)->name);
|
|
|
|
|
|
|
|
gimp_context_tool_changed (context);
|
2000-02-23 01:06:44 +08:00
|
|
|
}
|
|
|
|
|
2001-02-21 20:18:09 +08:00
|
|
|
/* the global tool list is there again after refresh */
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
2001-02-21 20:18:09 +08:00
|
|
|
gimp_context_tool_list_thaw (GimpContainer *container,
|
|
|
|
GimpContext *context)
|
1999-10-19 23:52:32 +08:00
|
|
|
{
|
2001-02-21 20:18:09 +08:00
|
|
|
GimpToolInfo *tool_info;
|
|
|
|
|
|
|
|
if (! context->tool_name)
|
|
|
|
context->tool_name = g_strdup ("Color Picker");
|
|
|
|
|
|
|
|
if ((tool_info = (GimpToolInfo *)
|
|
|
|
gimp_container_get_child_by_name (container,
|
|
|
|
context->tool_name)))
|
|
|
|
{
|
|
|
|
gimp_context_real_set_tool (context, tool_info);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gimp_container_num_children (container))
|
|
|
|
gimp_context_real_set_tool
|
|
|
|
(context,
|
|
|
|
GIMP_TOOL_INFO (gimp_container_get_child_by_index (container, 0)));
|
|
|
|
else
|
2001-02-24 05:32:47 +08:00
|
|
|
gimp_context_real_set_tool (context, gimp_tool_info_get_standard ());
|
2001-02-21 20:18:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* the active tool disappeared */
|
|
|
|
static void
|
|
|
|
gimp_context_tool_removed (GimpContainer *container,
|
|
|
|
GimpToolInfo *tool_info,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
if (tool_info == context->tool_info)
|
|
|
|
{
|
|
|
|
context->tool_info = NULL;
|
|
|
|
|
|
|
|
gtk_signal_disconnect_by_func (GTK_OBJECT (tool_info),
|
|
|
|
gimp_context_tool_dirty,
|
|
|
|
context);
|
|
|
|
gtk_object_unref (GTK_OBJECT (tool_info));
|
|
|
|
|
|
|
|
if (! gimp_container_frozen (container))
|
|
|
|
gimp_context_tool_list_thaw (container, context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_context_real_set_tool (GimpContext *context,
|
|
|
|
GimpToolInfo *tool_info)
|
|
|
|
{
|
|
|
|
if (! standard_tool_info)
|
2001-02-24 05:32:47 +08:00
|
|
|
standard_tool_info = gimp_tool_info_get_standard ();
|
2001-02-21 20:18:09 +08:00
|
|
|
|
|
|
|
if (context->tool_info == tool_info)
|
1999-11-14 18:50:19 +08:00
|
|
|
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
|
|
|
|
2001-02-24 05:32:47 +08:00
|
|
|
if (context->tool_name && tool_info != standard_tool_info)
|
2001-02-21 20:18:09 +08:00
|
|
|
{
|
|
|
|
g_free (context->tool_name);
|
|
|
|
context->tool_name = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* disconnect from the old tool's signals */
|
|
|
|
if (context->tool_info)
|
|
|
|
{
|
|
|
|
gtk_signal_disconnect_by_func (GTK_OBJECT (context->tool_info),
|
|
|
|
gimp_context_tool_dirty,
|
|
|
|
context);
|
|
|
|
gtk_object_unref (GTK_OBJECT (context->tool_info));
|
|
|
|
}
|
|
|
|
|
|
|
|
context->tool_info = tool_info;
|
|
|
|
|
|
|
|
if (tool_info)
|
|
|
|
{
|
|
|
|
gtk_object_ref (GTK_OBJECT (tool_info));
|
|
|
|
gtk_signal_connect (GTK_OBJECT (tool_info), "invalidate_preview",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_context_tool_dirty),
|
|
|
|
context);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (tool_info), "name_changed",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_context_tool_dirty),
|
|
|
|
context);
|
|
|
|
|
2001-02-24 05:32:47 +08:00
|
|
|
if (tool_info != standard_tool_info)
|
|
|
|
context->tool_name = g_strdup (GIMP_OBJECT (tool_info)->name);
|
2001-02-21 20:18:09 +08:00
|
|
|
}
|
|
|
|
|
2000-02-23 01:06:44 +08:00
|
|
|
gimp_context_tool_changed (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
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2001-02-21 20:18:09 +08:00
|
|
|
gimp_context_real_set_tool (dest, src->tool_info);
|
|
|
|
|
2001-02-24 05:32:47 +08:00
|
|
|
if ((!src->tool_info || src->tool_info == standard_tool_info) &&
|
2001-02-21 20:18:09 +08:00
|
|
|
src->tool_name)
|
|
|
|
{
|
|
|
|
g_free (dest->tool_name);
|
|
|
|
dest->tool_name = g_strdup (src->tool_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
|
|
|
}
|
|
|
|
|
2001-02-21 20:18:09 +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,
|
2001-01-15 09:48:53 +08:00
|
|
|
GimpRGB *color)
|
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);
|
|
|
|
|
2001-01-15 09:48:53 +08:00
|
|
|
g_return_if_fail (color != NULL);
|
|
|
|
|
|
|
|
*color = context->foreground;
|
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
|
2001-01-20 23:37:26 +08:00
|
|
|
gimp_context_set_foreground (GimpContext *context,
|
|
|
|
const GimpRGB *color)
|
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
|
|
|
|
2001-01-15 09:48:53 +08:00
|
|
|
g_return_if_fail (color != NULL);
|
|
|
|
|
|
|
|
gimp_context_real_set_foreground (context, color);
|
1999-10-19 23:52:32 +08:00
|
|
|
}
|
|
|
|
|
2000-02-23 01:06:44 +08:00
|
|
|
void
|
|
|
|
gimp_context_foreground_changed (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
|
|
|
gimp_context_signals[FOREGROUND_CHANGED],
|
2001-01-15 09:48:53 +08:00
|
|
|
&context->foreground);
|
2000-02-23 01:06:44 +08:00
|
|
|
}
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
2001-01-20 23:37:26 +08:00
|
|
|
gimp_context_real_set_foreground (GimpContext *context,
|
|
|
|
const GimpRGB *color)
|
1999-10-19 23:52:32 +08:00
|
|
|
{
|
2001-01-15 09:48:53 +08:00
|
|
|
if (gimp_rgba_distance (&context->foreground, color) < 0.0001)
|
1999-11-14 18:50:19 +08:00
|
|
|
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
|
|
|
|
2001-01-15 09:48:53 +08:00
|
|
|
context->foreground = *color;
|
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
|
|
|
|
2000-02-23 01:06:44 +08:00
|
|
|
gimp_context_foreground_changed (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
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2001-01-15 09:48:53 +08:00
|
|
|
gimp_context_real_set_foreground (dest, &src->foreground);
|
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,
|
2001-01-15 09:48:53 +08:00
|
|
|
GimpRGB *color)
|
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);
|
|
|
|
|
2001-01-15 09:48:53 +08:00
|
|
|
g_return_if_fail (color != NULL);
|
|
|
|
|
|
|
|
*color = context->background;
|
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
|
|
|
}
|
|
|
|
|
2001-01-11 06:49:45 +08:00
|
|
|
void
|
2001-01-20 23:37:26 +08:00
|
|
|
gimp_context_set_background (GimpContext *context,
|
|
|
|
const GimpRGB *color)
|
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
|
|
|
|
2001-01-15 09:48:53 +08:00
|
|
|
g_return_if_fail (color != NULL);
|
|
|
|
|
|
|
|
gimp_context_real_set_background (context, color);
|
1999-10-19 23:52:32 +08:00
|
|
|
}
|
|
|
|
|
2000-02-23 01:06:44 +08:00
|
|
|
void
|
|
|
|
gimp_context_background_changed (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
|
|
|
gimp_context_signals[BACKGROUND_CHANGED],
|
2001-01-15 09:48:53 +08:00
|
|
|
&context->background);
|
2000-02-23 01:06:44 +08:00
|
|
|
}
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
2001-01-20 23:37:26 +08:00
|
|
|
gimp_context_real_set_background (GimpContext *context,
|
|
|
|
const GimpRGB *color)
|
1999-10-19 23:52:32 +08:00
|
|
|
{
|
2001-01-15 09:48:53 +08:00
|
|
|
if (gimp_rgba_distance (&context->background, color) < 0.0001)
|
1999-11-14 18:50:19 +08:00
|
|
|
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
|
|
|
|
2001-01-15 09:48:53 +08:00
|
|
|
context->background = *color;
|
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
|
|
|
|
2000-02-23 01:06:44 +08:00
|
|
|
gimp_context_background_changed (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
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2001-01-15 09:48:53 +08:00
|
|
|
gimp_context_real_set_background (dest, &src->background);
|
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;
|
2001-01-15 09:48:53 +08:00
|
|
|
GimpRGB fg;
|
|
|
|
GimpRGB bg;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2001-01-15 09:48:53 +08:00
|
|
|
gimp_rgba_set (&fg, 0.0, 0.0, 0.0, 1.0);
|
|
|
|
gimp_rgba_set (&bg, 1.0, 1.0, 1.0, 1.0);
|
|
|
|
|
|
|
|
gimp_context_real_set_foreground (context, &fg);
|
|
|
|
gimp_context_real_set_background (bg_context, &bg);
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_swap_colors (GimpContext *context)
|
|
|
|
{
|
|
|
|
GimpContext *bg_context;
|
2001-01-15 09:48:53 +08:00
|
|
|
GimpRGB fg;
|
|
|
|
GimpRGB bg;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2001-01-15 09:48:53 +08:00
|
|
|
gimp_context_get_foreground (context, &fg);
|
|
|
|
gimp_context_get_background (bg_context, &bg);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-01-15 09:48:53 +08:00
|
|
|
gimp_context_real_set_foreground (context, &bg);
|
|
|
|
gimp_context_real_set_background (bg_context, &fg);
|
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
|
|
|
/* 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
|
|
|
|
2000-02-23 01:06:44 +08:00
|
|
|
void
|
|
|
|
gimp_context_opacity_changed (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
|
|
|
gimp_context_signals[OPACITY_CHANGED],
|
|
|
|
context->opacity);
|
|
|
|
}
|
|
|
|
|
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;
|
2000-02-23 01:06:44 +08:00
|
|
|
gimp_context_opacity_changed (context);
|
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-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)
|
|
|
|
{
|
2001-02-24 05:32:47 +08:00
|
|
|
g_return_val_if_fail (! context || GIMP_IS_CONTEXT (context), NORMAL_MODE);
|
|
|
|
|
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
|
|
|
{
|
2001-02-24 05:32:47 +08:00
|
|
|
g_return_if_fail (! context || GIMP_IS_CONTEXT (context));
|
|
|
|
|
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
|
|
|
|
2000-02-23 01:06:44 +08:00
|
|
|
void
|
|
|
|
gimp_context_paint_mode_changed (GimpContext *context)
|
|
|
|
{
|
2001-02-24 05:32:47 +08:00
|
|
|
g_return_if_fail (! context || GIMP_IS_CONTEXT (context));
|
|
|
|
|
2000-02-23 01:06:44 +08:00
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
|
|
|
gimp_context_signals[PAINT_MODE_CHANGED],
|
|
|
|
context->paint_mode);
|
|
|
|
}
|
|
|
|
|
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;
|
2000-02-23 01:06:44 +08:00
|
|
|
gimp_context_paint_mode_changed (context);
|
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-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
|
|
|
{
|
2001-02-24 05:32:47 +08:00
|
|
|
g_return_val_if_fail (! context || GIMP_IS_CONTEXT (context), NULL);
|
|
|
|
|
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
|
|
|
{
|
2001-02-24 05:32:47 +08:00
|
|
|
g_return_if_fail (! context || GIMP_IS_CONTEXT (context));
|
|
|
|
g_return_if_fail (! brush || GIMP_IS_BRUSH (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
|
|
|
|
2000-02-23 01:06:44 +08:00
|
|
|
void
|
|
|
|
gimp_context_brush_changed (GimpContext *context)
|
|
|
|
{
|
2001-02-24 05:32:47 +08:00
|
|
|
g_return_if_fail (! context || GIMP_IS_CONTEXT (context));
|
|
|
|
|
2000-02-23 01:06:44 +08:00
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
|
|
|
gimp_context_signals[BRUSH_CHANGED],
|
|
|
|
context->brush);
|
|
|
|
}
|
|
|
|
|
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);
|
2001-01-14 11:55:56 +08:00
|
|
|
context->brush_name = g_strdup (GIMP_OBJECT (brush)->name);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2000-02-23 01:06:44 +08:00
|
|
|
gimp_context_brush_changed (context);
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
|
|
|
|
2001-02-12 11:27:28 +08:00
|
|
|
/* the global brush list is there again after refresh */
|
|
|
|
static void
|
|
|
|
gimp_context_brush_list_thaw (GimpContainer *container,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
GimpBrush *brush;
|
|
|
|
|
|
|
|
if (! context->brush_name)
|
2001-06-04 04:40:50 +08:00
|
|
|
context->brush_name = g_strdup (gimprc.default_brush);
|
2001-02-12 11:27:28 +08:00
|
|
|
|
|
|
|
if ((brush = (GimpBrush *)
|
|
|
|
gimp_container_get_child_by_name (container,
|
|
|
|
context->brush_name)))
|
|
|
|
{
|
|
|
|
gimp_context_real_set_brush (context, brush);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gimp_container_num_children (container))
|
|
|
|
gimp_context_real_set_brush
|
|
|
|
(context, GIMP_BRUSH (gimp_container_get_child_by_index (container, 0)));
|
|
|
|
else
|
2001-02-14 22:57:14 +08:00
|
|
|
gimp_context_real_set_brush (context,
|
|
|
|
GIMP_BRUSH (gimp_brush_get_standard ()));
|
2001-02-12 11:27:28 +08:00
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/* the active brush disappeared */
|
|
|
|
static void
|
2001-02-12 11:27:28 +08:00
|
|
|
gimp_context_brush_removed (GimpContainer *container,
|
1999-10-27 02:27:27 +08:00
|
|
|
GimpBrush *brush,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
if (brush == context->brush)
|
|
|
|
{
|
|
|
|
context->brush = NULL;
|
|
|
|
|
2001-02-05 01:34:30 +08:00
|
|
|
gtk_signal_disconnect_by_func (GTK_OBJECT (brush),
|
|
|
|
gimp_context_brush_dirty,
|
|
|
|
context);
|
1999-10-27 02:27:27 +08:00
|
|
|
gtk_object_unref (GTK_OBJECT (brush));
|
2001-02-12 11:27:28 +08:00
|
|
|
|
|
|
|
if (! gimp_container_frozen (container))
|
|
|
|
gimp_context_brush_list_thaw (container, context);
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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)
|
2001-02-14 22:57:14 +08:00
|
|
|
standard_brush = GIMP_BRUSH (gimp_brush_get_standard ());
|
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... */
|
2001-05-15 19:25:25 +08:00
|
|
|
if (base_config->stingy_memory_use &&
|
1999-10-27 02:27:27 +08:00
|
|
|
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)
|
|
|
|
{
|
2001-02-05 01:34:30 +08:00
|
|
|
gtk_signal_disconnect_by_func (GTK_OBJECT (context->brush),
|
|
|
|
gimp_context_brush_dirty,
|
|
|
|
context);
|
1999-10-27 02:27:27 +08:00
|
|
|
gtk_object_unref (GTK_OBJECT (context->brush));
|
|
|
|
}
|
|
|
|
|
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));
|
2001-02-07 11:14:38 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (brush), "invalidate_preview",
|
1999-10-27 02:27:27 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimp_context_brush_dirty),
|
|
|
|
context);
|
2001-01-14 11:55:56 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (brush), "name_changed",
|
1999-10-27 02:27:27 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimp_context_brush_dirty),
|
|
|
|
context);
|
|
|
|
|
|
|
|
/* Make sure the active brush is unswapped... */
|
2001-05-15 19:25:25 +08:00
|
|
|
if (base_config->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)
|
2001-01-14 11:55:56 +08:00
|
|
|
context->brush_name = g_strdup (GIMP_OBJECT (brush)->name);
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
|
|
|
|
2000-02-23 01:06:44 +08:00
|
|
|
gimp_context_brush_changed (context);
|
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-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
|
|
|
/* pattern *****************************************************************/
|
1999-06-19 02:29:27 +08:00
|
|
|
|
2001-02-05 01:34:30 +08:00
|
|
|
static GimpPattern *standard_pattern = NULL;
|
1999-11-14 18:50:19 +08:00
|
|
|
|
2001-02-05 01:34:30 +08:00
|
|
|
GimpPattern *
|
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_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,
|
2001-02-05 01:34:30 +08:00
|
|
|
GimpPattern *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
|
|
|
|
2000-02-23 01:06:44 +08:00
|
|
|
void
|
|
|
|
gimp_context_pattern_changed (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
|
|
|
gimp_context_signals[PATTERN_CHANGED],
|
|
|
|
context->pattern);
|
|
|
|
}
|
|
|
|
|
2001-02-05 01:34:30 +08:00
|
|
|
/* the active pattern was modified */
|
|
|
|
static void
|
|
|
|
gimp_context_pattern_dirty (GimpPattern *pattern,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
g_free (context->pattern_name);
|
|
|
|
context->pattern_name = g_strdup (GIMP_OBJECT (pattern)->name);
|
|
|
|
|
|
|
|
gimp_context_pattern_changed (context);
|
|
|
|
}
|
|
|
|
|
2001-02-12 11:27:28 +08:00
|
|
|
/* the global pattern list is there again after refresh */
|
|
|
|
static void
|
|
|
|
gimp_context_pattern_list_thaw (GimpContainer *container,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
GimpPattern *pattern;
|
|
|
|
|
|
|
|
if (! context->pattern_name)
|
2001-06-04 04:40:50 +08:00
|
|
|
context->pattern_name = g_strdup (gimprc.default_pattern);
|
2001-02-12 11:27:28 +08:00
|
|
|
|
|
|
|
if ((pattern = (GimpPattern *)
|
|
|
|
gimp_container_get_child_by_name (container,
|
|
|
|
context->pattern_name)))
|
|
|
|
{
|
|
|
|
gimp_context_real_set_pattern (context, pattern);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gimp_container_num_children (container))
|
|
|
|
gimp_context_real_set_pattern
|
|
|
|
(context,
|
|
|
|
GIMP_PATTERN (gimp_container_get_child_by_index (container, 0)));
|
|
|
|
else
|
2001-02-14 22:57:14 +08:00
|
|
|
gimp_context_real_set_pattern (context,
|
|
|
|
GIMP_PATTERN (gimp_pattern_get_standard ()));
|
2001-02-12 11:27:28 +08:00
|
|
|
}
|
|
|
|
|
2001-02-05 01:34:30 +08:00
|
|
|
/* the active pattern disappeared */
|
|
|
|
static void
|
2001-02-12 11:27:28 +08:00
|
|
|
gimp_context_pattern_removed (GimpContainer *container,
|
2001-02-05 01:34:30 +08:00
|
|
|
GimpPattern *pattern,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
if (pattern == context->pattern)
|
|
|
|
{
|
|
|
|
context->pattern = NULL;
|
|
|
|
|
|
|
|
gtk_signal_disconnect_by_func (GTK_OBJECT (pattern),
|
|
|
|
gimp_context_pattern_dirty,
|
|
|
|
context);
|
|
|
|
gtk_object_unref (GTK_OBJECT (pattern));
|
2001-02-12 11:27:28 +08:00
|
|
|
|
|
|
|
if (! gimp_container_frozen (container))
|
2001-02-14 09:42:12 +08:00
|
|
|
gimp_context_pattern_list_thaw (container, context);
|
2001-02-05 01:34:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
|
|
|
gimp_context_real_set_pattern (GimpContext *context,
|
2001-02-05 01:34:30 +08:00
|
|
|
GimpPattern *pattern)
|
1999-10-19 23:52:32 +08:00
|
|
|
{
|
1999-11-14 18:50:19 +08:00
|
|
|
if (! standard_pattern)
|
2001-02-14 22:57:14 +08:00
|
|
|
standard_pattern = GIMP_PATTERN (gimp_pattern_get_standard ());
|
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;
|
|
|
|
}
|
|
|
|
|
2001-02-05 01:34:30 +08:00
|
|
|
/* make sure the active pattern is swapped before we get a new one... */
|
2001-05-15 19:25:25 +08:00
|
|
|
if (base_config->stingy_memory_use &&
|
2001-02-05 01:34:30 +08:00
|
|
|
context->pattern && context->pattern->mask &&
|
|
|
|
GTK_OBJECT (context->pattern)->ref_count == 2)
|
|
|
|
{
|
|
|
|
temp_buf_swap (pattern->mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* disconnect from the old pattern's signals */
|
|
|
|
if (context->pattern)
|
|
|
|
{
|
|
|
|
gtk_signal_disconnect_by_func (GTK_OBJECT (context->pattern),
|
|
|
|
gimp_context_pattern_dirty,
|
|
|
|
context);
|
|
|
|
gtk_object_unref (GTK_OBJECT (context->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
|
|
|
context->pattern = pattern;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-02-05 01:34:30 +08:00
|
|
|
if (pattern)
|
|
|
|
{
|
|
|
|
gtk_object_ref (GTK_OBJECT (pattern));
|
|
|
|
gtk_signal_connect (GTK_OBJECT (pattern), "name_changed",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_context_pattern_dirty),
|
|
|
|
context);
|
|
|
|
|
|
|
|
/* Make sure the active pattern is unswapped... */
|
2001-05-15 19:25:25 +08:00
|
|
|
if (base_config->stingy_memory_use &&
|
|
|
|
pattern->mask &&
|
2001-02-05 01:34:30 +08:00
|
|
|
GTK_OBJECT (pattern)->ref_count < 2)
|
|
|
|
{
|
|
|
|
temp_buf_unswap (pattern->mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pattern != standard_pattern)
|
|
|
|
context->pattern_name = g_strdup (GIMP_OBJECT (pattern)->name);
|
|
|
|
}
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2000-02-23 01:06:44 +08:00
|
|
|
gimp_context_pattern_changed (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
|
|
|
}
|
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-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
|
|
|
/* gradient ****************************************************************/
|
|
|
|
|
2001-02-11 03:35:29 +08:00
|
|
|
static GimpGradient *standard_gradient = NULL;
|
1999-11-14 18:50:19 +08:00
|
|
|
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradient *
|
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_get_gradient (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_val_if_fail (context, NULL);
|
|
|
|
|
|
|
|
return context->gradient;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-02-11 03:35:29 +08:00
|
|
|
gimp_context_set_gradient (GimpContext *context,
|
|
|
|
GimpGradient *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
|
|
|
{
|
|
|
|
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
|
|
|
|
2000-02-23 01:06:44 +08:00
|
|
|
void
|
|
|
|
gimp_context_gradient_changed (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
|
|
|
gimp_context_signals[GRADIENT_CHANGED],
|
|
|
|
context->gradient);
|
|
|
|
}
|
|
|
|
|
2001-02-12 11:27:28 +08:00
|
|
|
/* the active gradient was modified */
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
2001-02-12 11:27:28 +08:00
|
|
|
gimp_context_gradient_dirty (GimpGradient *gradient,
|
|
|
|
GimpContext *context)
|
1999-10-19 23:52:32 +08:00
|
|
|
{
|
2001-02-12 11:27:28 +08:00
|
|
|
g_free (context->gradient_name);
|
|
|
|
context->gradient_name = g_strdup (GIMP_OBJECT (gradient)->name);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2000-02-23 01:06:44 +08:00
|
|
|
gimp_context_gradient_changed (context);
|
1999-06-19 02:29:27 +08:00
|
|
|
}
|
|
|
|
|
2001-02-12 11:27:28 +08:00
|
|
|
/* the global gradient list is there again after refresh */
|
1999-10-19 23:52:32 +08:00
|
|
|
static void
|
2001-02-12 11:27:28 +08:00
|
|
|
gimp_context_gradient_list_thaw (GimpContainer *container,
|
|
|
|
GimpContext *context)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-02-11 03:35:29 +08:00
|
|
|
GimpGradient *gradient;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
if (! context->gradient_name)
|
2001-06-04 04:40:50 +08:00
|
|
|
context->gradient_name = g_strdup (gimprc.default_gradient);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-02-12 11:27:28 +08:00
|
|
|
if ((gradient = (GimpGradient *)
|
|
|
|
gimp_container_get_child_by_name (container,
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2001-02-12 11:27:28 +08:00
|
|
|
if (gimp_container_num_children (container))
|
2001-02-11 03:35:29 +08:00
|
|
|
gimp_context_real_set_gradient
|
|
|
|
(context,
|
2001-02-12 11:27:28 +08:00
|
|
|
GIMP_GRADIENT (gimp_container_get_child_by_index (container, 0)));
|
1999-10-27 02:27:27 +08:00
|
|
|
else
|
2001-02-14 22:57:14 +08:00
|
|
|
gimp_context_real_set_gradient (context,
|
|
|
|
GIMP_GRADIENT (gimp_gradient_get_standard ()));
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
|
|
|
|
2001-02-12 11:27:28 +08:00
|
|
|
/* the active gradient disappeared */
|
|
|
|
static void
|
|
|
|
gimp_context_gradient_removed (GimpContainer *container,
|
|
|
|
GimpGradient *gradient,
|
|
|
|
GimpContext *context)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-02-12 11:27:28 +08:00
|
|
|
if (gradient == context->gradient)
|
|
|
|
{
|
|
|
|
context->gradient = NULL;
|
|
|
|
|
|
|
|
gtk_signal_disconnect_by_func (GTK_OBJECT (gradient),
|
|
|
|
gimp_context_gradient_dirty,
|
|
|
|
context);
|
|
|
|
gtk_object_unref (GTK_OBJECT (gradient));
|
|
|
|
|
|
|
|
if (! gimp_container_frozen (container))
|
2001-02-14 09:42:12 +08:00
|
|
|
gimp_context_gradient_list_thaw (container, context);
|
2001-02-12 11:27:28 +08:00
|
|
|
}
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-02-12 11:27:28 +08:00
|
|
|
gimp_context_real_set_gradient (GimpContext *context,
|
|
|
|
GimpGradient *gradient)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-02-12 11:27:28 +08:00
|
|
|
if (! standard_gradient)
|
2001-02-14 22:57:14 +08:00
|
|
|
standard_gradient = GIMP_GRADIENT (gimp_gradient_get_standard ());
|
2001-02-12 11:27:28 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
if (context->gradient == gradient)
|
2001-02-12 11:27:28 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (context->gradient_name && gradient != standard_gradient)
|
|
|
|
{
|
|
|
|
g_free (context->gradient_name);
|
|
|
|
context->gradient_name = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* disconnect from the old gradient's signals */
|
|
|
|
if (context->gradient)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-02-12 11:27:28 +08:00
|
|
|
gtk_signal_disconnect_by_func (GTK_OBJECT (context->gradient),
|
|
|
|
gimp_context_gradient_dirty,
|
|
|
|
context);
|
|
|
|
gtk_object_unref (GTK_OBJECT (context->gradient));
|
|
|
|
}
|
|
|
|
|
|
|
|
context->gradient = gradient;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-02-12 11:27:28 +08:00
|
|
|
if (gradient)
|
|
|
|
{
|
|
|
|
gtk_object_ref (GTK_OBJECT (gradient));
|
|
|
|
gtk_signal_connect (GTK_OBJECT (gradient), "name_changed",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_context_gradient_dirty),
|
|
|
|
context);
|
1999-11-14 18:50:19 +08:00
|
|
|
|
2001-02-12 11:27:28 +08:00
|
|
|
if (gradient != standard_gradient)
|
|
|
|
context->gradient_name = g_strdup (GIMP_OBJECT (gradient)->name);
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
|
|
|
|
2001-02-12 11:27:28 +08:00
|
|
|
gimp_context_gradient_changed (context);
|
|
|
|
}
|
2001-01-12 07:36:59 +08:00
|
|
|
|
2001-02-12 11:27:28 +08:00
|
|
|
static void
|
|
|
|
gimp_context_copy_gradient (GimpContext *src,
|
|
|
|
GimpContext *dest)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-02-12 11:27:28 +08:00
|
|
|
gimp_context_real_set_gradient (dest, src->gradient);
|
|
|
|
|
|
|
|
if ((!src->gradient || src->gradient == standard_gradient) &&
|
|
|
|
src->gradient_name)
|
|
|
|
{
|
|
|
|
g_free (dest->gradient_name);
|
|
|
|
dest->gradient_name = g_strdup (src->gradient_name);
|
|
|
|
}
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
2001-02-12 00:14:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* palette *****************************************************************/
|
|
|
|
|
|
|
|
static GimpPalette *standard_palette = NULL;
|
|
|
|
|
|
|
|
GimpPalette *
|
|
|
|
gimp_context_get_palette (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_val_if_fail (context, NULL);
|
|
|
|
|
|
|
|
return context->palette;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_set_palette (GimpContext *context,
|
|
|
|
GimpPalette *palette)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
context_find_defined (context, GIMP_CONTEXT_PALETTE_MASK);
|
|
|
|
|
|
|
|
gimp_context_real_set_palette (context, palette);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_palette_changed (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
|
|
|
gimp_context_signals[PALETTE_CHANGED],
|
|
|
|
context->palette);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the active palette was modified */
|
|
|
|
static void
|
|
|
|
gimp_context_palette_dirty (GimpPalette *palette,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
g_free (context->palette_name);
|
|
|
|
context->palette_name = g_strdup (GIMP_OBJECT (palette)->name);
|
|
|
|
|
|
|
|
gimp_context_palette_changed (context);
|
|
|
|
}
|
|
|
|
|
2001-02-12 11:27:28 +08:00
|
|
|
/* the global gradient list is there again after refresh */
|
|
|
|
static void
|
|
|
|
gimp_context_palette_list_thaw (GimpContainer *container,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
GimpPalette *palette;
|
|
|
|
|
|
|
|
if (! context->palette_name)
|
2001-06-04 04:40:50 +08:00
|
|
|
context->palette_name = g_strdup (gimprc.default_palette);
|
2001-02-12 11:27:28 +08:00
|
|
|
|
|
|
|
if ((palette = (GimpPalette *)
|
|
|
|
gimp_container_get_child_by_name (container,
|
|
|
|
context->palette_name)))
|
|
|
|
{
|
|
|
|
gimp_context_real_set_palette (context, palette);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gimp_container_num_children (container))
|
|
|
|
gimp_context_real_set_palette
|
|
|
|
(context,
|
|
|
|
GIMP_PALETTE (gimp_container_get_child_by_index (container, 0)));
|
|
|
|
else
|
2001-02-14 22:57:14 +08:00
|
|
|
gimp_context_real_set_palette (context,
|
|
|
|
GIMP_PALETTE (gimp_palette_get_standard ()));
|
2001-02-12 11:27:28 +08:00
|
|
|
}
|
|
|
|
|
2001-02-12 00:14:25 +08:00
|
|
|
/* the active palette disappeared */
|
|
|
|
static void
|
2001-02-12 11:27:28 +08:00
|
|
|
gimp_context_palette_removed (GimpContainer *container,
|
2001-02-12 00:14:25 +08:00
|
|
|
GimpPalette *palette,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
if (palette == context->palette)
|
|
|
|
{
|
|
|
|
context->palette = NULL;
|
|
|
|
|
|
|
|
gtk_signal_disconnect_by_func (GTK_OBJECT (palette),
|
|
|
|
gimp_context_palette_dirty,
|
|
|
|
context);
|
|
|
|
gtk_object_unref (GTK_OBJECT (palette));
|
2001-02-12 11:27:28 +08:00
|
|
|
|
|
|
|
if (! gimp_container_frozen (container))
|
2001-02-14 09:42:12 +08:00
|
|
|
gimp_context_palette_list_thaw (container, context);
|
2001-02-12 00:14:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_context_real_set_palette (GimpContext *context,
|
|
|
|
GimpPalette *palette)
|
|
|
|
{
|
|
|
|
if (! standard_palette)
|
2001-02-14 22:57:14 +08:00
|
|
|
standard_palette = GIMP_PALETTE (gimp_palette_get_standard ());
|
2001-02-12 00:14:25 +08:00
|
|
|
|
|
|
|
if (context->palette == palette)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (context->palette_name && palette != standard_palette)
|
|
|
|
{
|
|
|
|
g_free (context->palette_name);
|
|
|
|
context->palette_name = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* disconnect from the old palette's signals */
|
|
|
|
if (context->palette)
|
|
|
|
{
|
|
|
|
gtk_signal_disconnect_by_func (GTK_OBJECT (context->palette),
|
|
|
|
gimp_context_palette_dirty,
|
|
|
|
context);
|
|
|
|
gtk_object_unref (GTK_OBJECT (context->palette));
|
|
|
|
}
|
|
|
|
|
|
|
|
context->palette = palette;
|
|
|
|
|
|
|
|
if (palette)
|
|
|
|
{
|
|
|
|
gtk_object_ref (GTK_OBJECT (palette));
|
|
|
|
gtk_signal_connect (GTK_OBJECT (palette), "name_changed",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_context_palette_dirty),
|
|
|
|
context);
|
|
|
|
|
|
|
|
if (palette != standard_palette)
|
|
|
|
context->palette_name = g_strdup (GIMP_OBJECT (palette)->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_context_palette_changed (context);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_context_copy_palette (GimpContext *src,
|
|
|
|
GimpContext *dest)
|
|
|
|
{
|
|
|
|
gimp_context_real_set_palette (dest, src->palette);
|
|
|
|
|
|
|
|
if ((!src->palette || src->palette == standard_palette) && src->palette_name)
|
|
|
|
{
|
|
|
|
g_free (dest->palette_name);
|
|
|
|
dest->palette_name = g_strdup (src->palette_name);
|
|
|
|
}
|
|
|
|
}
|
2001-06-26 20:09:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* buffer ******************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
static GimpBuffer *standard_buffer = NULL;
|
|
|
|
*/
|
|
|
|
|
|
|
|
GimpBuffer *
|
|
|
|
gimp_context_get_buffer (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_val_if_fail (context, NULL);
|
|
|
|
|
|
|
|
return context->buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_set_buffer (GimpContext *context,
|
|
|
|
GimpBuffer *buffer)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
context_find_defined (context, GIMP_CONTEXT_BUFFER_MASK);
|
|
|
|
|
|
|
|
gimp_context_real_set_buffer (context, buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_context_buffer_changed (GimpContext *context)
|
|
|
|
{
|
|
|
|
context_check_current (context);
|
|
|
|
context_return_if_fail (context);
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (context),
|
|
|
|
gimp_context_signals[BUFFER_CHANGED],
|
|
|
|
context->buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the active buffer was modified */
|
|
|
|
static void
|
|
|
|
gimp_context_buffer_dirty (GimpBuffer *buffer,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
g_free (context->buffer_name);
|
|
|
|
context->buffer_name = g_strdup (GIMP_OBJECT (buffer)->name);
|
|
|
|
*/
|
|
|
|
|
|
|
|
gimp_context_buffer_changed (context);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the global gradient list is there again after refresh */
|
|
|
|
static void
|
|
|
|
gimp_context_buffer_list_thaw (GimpContainer *container,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
GimpBuffer *buffer;
|
|
|
|
|
|
|
|
if (! context->buffer_name)
|
|
|
|
context->buffer_name = g_strdup (gimprc.default_buffer);
|
|
|
|
|
|
|
|
if ((buffer = (GimpBuffer *)
|
|
|
|
gimp_container_get_child_by_name (container,
|
|
|
|
context->buffer_name)))
|
|
|
|
{
|
|
|
|
gimp_context_real_set_buffer (context, buffer);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (gimp_container_num_children (container))
|
|
|
|
gimp_context_real_set_buffer
|
|
|
|
(context,
|
|
|
|
GIMP_BUFFER (gimp_container_get_child_by_index (container, 0)));
|
|
|
|
else
|
|
|
|
gimp_context_buffer_changed (context);
|
|
|
|
|
|
|
|
/*
|
|
|
|
else
|
|
|
|
gimp_context_real_set_buffer (context,
|
|
|
|
GIMP_BUFFER (gimp_buffer_get_standard ()));
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the active buffer disappeared */
|
|
|
|
static void
|
|
|
|
gimp_context_buffer_removed (GimpContainer *container,
|
|
|
|
GimpBuffer *buffer,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
if (buffer == context->buffer)
|
|
|
|
{
|
|
|
|
context->buffer = NULL;
|
|
|
|
|
|
|
|
gtk_signal_disconnect_by_func (GTK_OBJECT (buffer),
|
|
|
|
gimp_context_buffer_dirty,
|
|
|
|
context);
|
|
|
|
gtk_object_unref (GTK_OBJECT (buffer));
|
|
|
|
|
|
|
|
if (! gimp_container_frozen (container))
|
|
|
|
gimp_context_buffer_list_thaw (container, context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_context_real_set_buffer (GimpContext *context,
|
|
|
|
GimpBuffer *buffer)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
if (! standard_buffer)
|
|
|
|
standard_buffer = GIMP_BUFFER (gimp_buffer_get_standard ());
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (context->buffer == buffer)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
if (context->buffer_name && buffer != standard_buffer)
|
|
|
|
{
|
|
|
|
g_free (context->buffer_name);
|
|
|
|
context->buffer_name = NULL;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* disconnect from the old buffer's signals */
|
|
|
|
if (context->buffer)
|
|
|
|
{
|
|
|
|
gtk_signal_disconnect_by_func (GTK_OBJECT (context->buffer),
|
|
|
|
gimp_context_buffer_dirty,
|
|
|
|
context);
|
|
|
|
gtk_object_unref (GTK_OBJECT (context->buffer));
|
|
|
|
}
|
|
|
|
|
|
|
|
context->buffer = buffer;
|
|
|
|
|
|
|
|
if (buffer)
|
|
|
|
{
|
|
|
|
gtk_object_ref (GTK_OBJECT (buffer));
|
|
|
|
gtk_signal_connect (GTK_OBJECT (buffer), "name_changed",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_context_buffer_dirty),
|
|
|
|
context);
|
|
|
|
|
|
|
|
/*
|
|
|
|
if (buffer != standard_buffer)
|
|
|
|
context->buffer_name = g_strdup (GIMP_OBJECT (buffer)->name);
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_context_buffer_changed (context);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_context_copy_buffer (GimpContext *src,
|
|
|
|
GimpContext *dest)
|
|
|
|
{
|
|
|
|
gimp_context_real_set_buffer (dest, src->buffer);
|
|
|
|
|
|
|
|
/*
|
|
|
|
if ((!src->buffer || src->buffer == standard_buffer) && src->buffer_name)
|
|
|
|
{
|
|
|
|
g_free (dest->buffer_name);
|
|
|
|
dest->buffer_name = g_strdup (src->buffer_name);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
}
|