mirror of https://github.com/GNOME/gimp.git
Fixed incomplete core/ui separation of paint tools and paint methods:
2005-12-27 Michael Natterer <mitch@gimp.org> Fixed incomplete core/ui separation of paint tools and paint methods: * app/core/core-enums.h * app/core/gimpcontext.[ch]: added a "paint-info" property and API so the current paint method can be selected without the need for an active tool. (gimp_context_real_set_tool): set the paint-info to tool_info->paint_info so the paint method follows the active tool just as the active image follows the active display. * app/core/gimp.h (struct Gimp) * app/core/gimppaintinfo.[ch]: added "standard_paint_info" API and stuff to be consistent with other context object properties. * app/paint/gimp-paint.c: set the paintbrush as standard_paint_info. * app/core/gimpstrokedesc.c (gimp_stroke_desc_new): removed the hack of falling back to the paintbrush when there is no active tool and use the active paint method instead. Fall back to the standard paint method if there is no active one. (nothing in the core uses the active tool any more now). * app/widgets/gimpdeviceinfo.h: add the paint info to the properties which are saved in devicerc. Added identifiers (names) and stock-ids to GimpPaintInfo: * app/core/gimppaintinfo.[ch] (gimp_paint_info_new): added identifier and stock-id parameters. * app/core/gimptoolinfo.c (gimp_tool_info_new): removed the hack of setting the paint-info stock-id from the tool-info stock-id. * app/paint/paint-types.h * app/paint/gimp-paint.c: changed GimpPaintRegisterCallback accordingly. * app/tools/gimp-tools.c (gimp_tools_register): changed paint info names accordingly. * app/paint/*.c (gimp_*_register): pass identifier and stock-id accordingly.
This commit is contained in:
parent
d23fa327c8
commit
ef9b04c535
48
ChangeLog
48
ChangeLog
|
@ -1,3 +1,51 @@
|
|||
2005-12-27 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
Fixed incomplete core/ui separation of paint tools and paint
|
||||
methods:
|
||||
|
||||
* app/core/core-enums.h
|
||||
* app/core/gimpcontext.[ch]: added a "paint-info" property and API
|
||||
so the current paint method can be selected without the need for
|
||||
an active tool.
|
||||
|
||||
(gimp_context_real_set_tool): set the paint-info to
|
||||
tool_info->paint_info so the paint method follows the active tool
|
||||
just as the active image follows the active display.
|
||||
|
||||
* app/core/gimp.h (struct Gimp)
|
||||
* app/core/gimppaintinfo.[ch]: added "standard_paint_info" API
|
||||
and stuff to be consistent with other context object properties.
|
||||
|
||||
* app/paint/gimp-paint.c: set the paintbrush as
|
||||
standard_paint_info.
|
||||
|
||||
* app/core/gimpstrokedesc.c (gimp_stroke_desc_new): removed the
|
||||
hack of falling back to the paintbrush when there is no active
|
||||
tool and use the active paint method instead. Fall back to the
|
||||
standard paint method if there is no active one.
|
||||
(nothing in the core uses the active tool any more now).
|
||||
|
||||
* app/widgets/gimpdeviceinfo.h: add the paint info to the
|
||||
properties which are saved in devicerc.
|
||||
|
||||
Added identifiers (names) and stock-ids to GimpPaintInfo:
|
||||
|
||||
* app/core/gimppaintinfo.[ch] (gimp_paint_info_new): added
|
||||
identifier and stock-id parameters.
|
||||
|
||||
* app/core/gimptoolinfo.c (gimp_tool_info_new): removed the hack
|
||||
of setting the paint-info stock-id from the tool-info stock-id.
|
||||
|
||||
* app/paint/paint-types.h
|
||||
* app/paint/gimp-paint.c: changed GimpPaintRegisterCallback
|
||||
accordingly.
|
||||
|
||||
* app/tools/gimp-tools.c (gimp_tools_register): changed paint
|
||||
info names accordingly.
|
||||
|
||||
* app/paint/*.c (gimp_*_register): pass identifier and stock-id
|
||||
accordingly.
|
||||
|
||||
2005-12-27 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/common/unsharp.c (query): fixed type of threshold
|
||||
|
|
|
@ -449,18 +449,19 @@ typedef enum /*< pdb-skip, skip >*/
|
|||
GIMP_CONTEXT_PROP_IMAGE = GIMP_CONTEXT_FIRST_PROP,
|
||||
GIMP_CONTEXT_PROP_DISPLAY = 3,
|
||||
GIMP_CONTEXT_PROP_TOOL = 4,
|
||||
GIMP_CONTEXT_PROP_FOREGROUND = 5,
|
||||
GIMP_CONTEXT_PROP_BACKGROUND = 6,
|
||||
GIMP_CONTEXT_PROP_OPACITY = 7,
|
||||
GIMP_CONTEXT_PROP_PAINT_MODE = 8,
|
||||
GIMP_CONTEXT_PROP_BRUSH = 9,
|
||||
GIMP_CONTEXT_PROP_PATTERN = 10,
|
||||
GIMP_CONTEXT_PROP_GRADIENT = 11,
|
||||
GIMP_CONTEXT_PROP_PALETTE = 12,
|
||||
GIMP_CONTEXT_PROP_FONT = 13,
|
||||
GIMP_CONTEXT_PROP_BUFFER = 14,
|
||||
GIMP_CONTEXT_PROP_IMAGEFILE = 15,
|
||||
GIMP_CONTEXT_PROP_TEMPLATE = 16,
|
||||
GIMP_CONTEXT_PROP_PAINT_INFO = 5,
|
||||
GIMP_CONTEXT_PROP_FOREGROUND = 6,
|
||||
GIMP_CONTEXT_PROP_BACKGROUND = 7,
|
||||
GIMP_CONTEXT_PROP_OPACITY = 8,
|
||||
GIMP_CONTEXT_PROP_PAINT_MODE = 9,
|
||||
GIMP_CONTEXT_PROP_BRUSH = 10,
|
||||
GIMP_CONTEXT_PROP_PATTERN = 11,
|
||||
GIMP_CONTEXT_PROP_GRADIENT = 12,
|
||||
GIMP_CONTEXT_PROP_PALETTE = 13,
|
||||
GIMP_CONTEXT_PROP_FONT = 14,
|
||||
GIMP_CONTEXT_PROP_BUFFER = 15,
|
||||
GIMP_CONTEXT_PROP_IMAGEFILE = 16,
|
||||
GIMP_CONTEXT_PROP_TEMPLATE = 17,
|
||||
|
||||
GIMP_CONTEXT_LAST_PROP = GIMP_CONTEXT_PROP_TEMPLATE
|
||||
} GimpContextPropType;
|
||||
|
@ -470,18 +471,19 @@ typedef enum /*< pdb-skip, skip >*/
|
|||
GIMP_CONTEXT_IMAGE_MASK = 1 << 2,
|
||||
GIMP_CONTEXT_DISPLAY_MASK = 1 << 3,
|
||||
GIMP_CONTEXT_TOOL_MASK = 1 << 4,
|
||||
GIMP_CONTEXT_FOREGROUND_MASK = 1 << 5,
|
||||
GIMP_CONTEXT_BACKGROUND_MASK = 1 << 6,
|
||||
GIMP_CONTEXT_OPACITY_MASK = 1 << 7,
|
||||
GIMP_CONTEXT_PAINT_MODE_MASK = 1 << 8,
|
||||
GIMP_CONTEXT_BRUSH_MASK = 1 << 9,
|
||||
GIMP_CONTEXT_PATTERN_MASK = 1 << 10,
|
||||
GIMP_CONTEXT_GRADIENT_MASK = 1 << 11,
|
||||
GIMP_CONTEXT_PALETTE_MASK = 1 << 12,
|
||||
GIMP_CONTEXT_FONT_MASK = 1 << 13,
|
||||
GIMP_CONTEXT_BUFFER_MASK = 1 << 14,
|
||||
GIMP_CONTEXT_IMAGEFILE_MASK = 1 << 15,
|
||||
GIMP_CONTEXT_TEMPLATE_MASK = 1 << 16,
|
||||
GIMP_CONTEXT_PAINT_INFO_MASK = 1 << 5,
|
||||
GIMP_CONTEXT_FOREGROUND_MASK = 1 << 6,
|
||||
GIMP_CONTEXT_BACKGROUND_MASK = 1 << 7,
|
||||
GIMP_CONTEXT_OPACITY_MASK = 1 << 8,
|
||||
GIMP_CONTEXT_PAINT_MODE_MASK = 1 << 9,
|
||||
GIMP_CONTEXT_BRUSH_MASK = 1 << 10,
|
||||
GIMP_CONTEXT_PATTERN_MASK = 1 << 11,
|
||||
GIMP_CONTEXT_GRADIENT_MASK = 1 << 12,
|
||||
GIMP_CONTEXT_PALETTE_MASK = 1 << 13,
|
||||
GIMP_CONTEXT_FONT_MASK = 1 << 14,
|
||||
GIMP_CONTEXT_BUFFER_MASK = 1 << 15,
|
||||
GIMP_CONTEXT_IMAGEFILE_MASK = 1 << 16,
|
||||
GIMP_CONTEXT_TEMPLATE_MASK = 1 << 17,
|
||||
|
||||
/* aliases */
|
||||
GIMP_CONTEXT_PAINT_PROPS_MASK = (GIMP_CONTEXT_FOREGROUND_MASK |
|
||||
|
@ -494,6 +496,7 @@ typedef enum /*< pdb-skip, skip >*/
|
|||
GIMP_CONTEXT_ALL_PROPS_MASK = (GIMP_CONTEXT_IMAGE_MASK |
|
||||
GIMP_CONTEXT_DISPLAY_MASK |
|
||||
GIMP_CONTEXT_TOOL_MASK |
|
||||
GIMP_CONTEXT_PAINT_INFO_MASK |
|
||||
GIMP_CONTEXT_PALETTE_MASK |
|
||||
GIMP_CONTEXT_FONT_MASK |
|
||||
GIMP_CONTEXT_BUFFER_MASK |
|
||||
|
|
|
@ -64,6 +64,7 @@ struct _Gimp
|
|||
GimpParasiteList *parasites;
|
||||
|
||||
GimpContainer *paint_info_list;
|
||||
GimpPaintInfo *standard_paint_info;
|
||||
|
||||
GimpModuleDB *module_db;
|
||||
gboolean write_modulerc;
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "gimpgradient.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimpmarshal.h"
|
||||
#include "gimppaintinfo.h"
|
||||
#include "gimppalette.h"
|
||||
#include "gimppattern.h"
|
||||
#include "gimptemplate.h"
|
||||
|
@ -122,6 +123,17 @@ static void gimp_context_tool_list_thaw (GimpContainer *container,
|
|||
static void gimp_context_real_set_tool (GimpContext *context,
|
||||
GimpToolInfo *tool_info);
|
||||
|
||||
/* paint info */
|
||||
static void gimp_context_paint_info_dirty (GimpPaintInfo *paint_info,
|
||||
GimpContext *context);
|
||||
static void gimp_context_paint_info_removed (GimpContainer *container,
|
||||
GimpPaintInfo *paint_info,
|
||||
GimpContext *context);
|
||||
static void gimp_context_paint_info_list_thaw(GimpContainer *container,
|
||||
GimpContext *context);
|
||||
static void gimp_context_real_set_paint_info (GimpContext *context,
|
||||
GimpPaintInfo *paint_info);
|
||||
|
||||
/* foreground */
|
||||
static void gimp_context_real_set_foreground (GimpContext *context,
|
||||
const GimpRGB *color);
|
||||
|
@ -251,6 +263,7 @@ enum
|
|||
IMAGE_CHANGED,
|
||||
DISPLAY_CHANGED,
|
||||
TOOL_CHANGED,
|
||||
PAINT_INFO_CHANGED,
|
||||
FOREGROUND_CHANGED,
|
||||
BACKGROUND_CHANGED,
|
||||
OPACITY_CHANGED,
|
||||
|
@ -273,6 +286,7 @@ static gchar *gimp_context_prop_names[] =
|
|||
"image",
|
||||
"display",
|
||||
"tool",
|
||||
"paint-info",
|
||||
"foreground",
|
||||
"background",
|
||||
"opacity",
|
||||
|
@ -294,6 +308,7 @@ static GType gimp_context_prop_types[] =
|
|||
0,
|
||||
G_TYPE_NONE,
|
||||
0,
|
||||
0,
|
||||
G_TYPE_NONE,
|
||||
G_TYPE_NONE,
|
||||
G_TYPE_NONE,
|
||||
|
@ -317,12 +332,13 @@ G_DEFINE_TYPE_WITH_CODE (GimpContext, gimp_context, GIMP_TYPE_OBJECT,
|
|||
|
||||
static guint gimp_context_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
static GimpToolInfo *standard_tool_info = NULL;
|
||||
static GimpBrush *standard_brush = NULL;
|
||||
static GimpPattern *standard_pattern = NULL;
|
||||
static GimpGradient *standard_gradient = NULL;
|
||||
static GimpPalette *standard_palette = NULL;
|
||||
static GimpFont *standard_font = NULL;
|
||||
static GimpToolInfo *standard_tool_info = NULL;
|
||||
static GimpPaintInfo *standard_paint_info = NULL;
|
||||
static GimpBrush *standard_brush = NULL;
|
||||
static GimpPattern *standard_pattern = NULL;
|
||||
static GimpGradient *standard_gradient = NULL;
|
||||
static GimpPalette *standard_palette = NULL;
|
||||
static GimpFont *standard_font = NULL;
|
||||
|
||||
|
||||
static void
|
||||
|
@ -366,6 +382,16 @@ gimp_context_class_init (GimpContextClass *klass)
|
|||
G_TYPE_NONE, 1,
|
||||
GIMP_TYPE_TOOL_INFO);
|
||||
|
||||
gimp_context_signals[PAINT_INFO_CHANGED] =
|
||||
g_signal_new ("paint-info-changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpContextClass, paint_info_changed),
|
||||
NULL, NULL,
|
||||
gimp_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE, 1,
|
||||
GIMP_TYPE_PAINT_INFO);
|
||||
|
||||
gimp_context_signals[FOREGROUND_CHANGED] =
|
||||
g_signal_new ("foreground-changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
|
@ -497,6 +523,7 @@ gimp_context_class_init (GimpContextClass *klass)
|
|||
klass->image_changed = NULL;
|
||||
klass->display_changed = NULL;
|
||||
klass->tool_changed = NULL;
|
||||
klass->paint_info_changed = NULL;
|
||||
klass->foreground_changed = NULL;
|
||||
klass->background_changed = NULL;
|
||||
klass->opacity_changed = NULL;
|
||||
|
@ -510,16 +537,17 @@ gimp_context_class_init (GimpContextClass *klass)
|
|||
klass->imagefile_changed = NULL;
|
||||
klass->template_changed = NULL;
|
||||
|
||||
gimp_context_prop_types[GIMP_CONTEXT_PROP_IMAGE] = GIMP_TYPE_IMAGE;
|
||||
gimp_context_prop_types[GIMP_CONTEXT_PROP_TOOL] = GIMP_TYPE_TOOL_INFO;
|
||||
gimp_context_prop_types[GIMP_CONTEXT_PROP_BRUSH] = GIMP_TYPE_BRUSH;
|
||||
gimp_context_prop_types[GIMP_CONTEXT_PROP_PATTERN] = GIMP_TYPE_PATTERN;
|
||||
gimp_context_prop_types[GIMP_CONTEXT_PROP_GRADIENT] = GIMP_TYPE_GRADIENT;
|
||||
gimp_context_prop_types[GIMP_CONTEXT_PROP_PALETTE] = GIMP_TYPE_PALETTE;
|
||||
gimp_context_prop_types[GIMP_CONTEXT_PROP_FONT] = GIMP_TYPE_FONT;
|
||||
gimp_context_prop_types[GIMP_CONTEXT_PROP_BUFFER] = GIMP_TYPE_BUFFER;
|
||||
gimp_context_prop_types[GIMP_CONTEXT_PROP_IMAGEFILE] = GIMP_TYPE_IMAGEFILE;
|
||||
gimp_context_prop_types[GIMP_CONTEXT_PROP_TEMPLATE] = GIMP_TYPE_TEMPLATE;
|
||||
gimp_context_prop_types[GIMP_CONTEXT_PROP_IMAGE] = GIMP_TYPE_IMAGE;
|
||||
gimp_context_prop_types[GIMP_CONTEXT_PROP_TOOL] = GIMP_TYPE_TOOL_INFO;
|
||||
gimp_context_prop_types[GIMP_CONTEXT_PROP_PAINT_INFO] = GIMP_TYPE_PAINT_INFO;
|
||||
gimp_context_prop_types[GIMP_CONTEXT_PROP_BRUSH] = GIMP_TYPE_BRUSH;
|
||||
gimp_context_prop_types[GIMP_CONTEXT_PROP_PATTERN] = GIMP_TYPE_PATTERN;
|
||||
gimp_context_prop_types[GIMP_CONTEXT_PROP_GRADIENT] = GIMP_TYPE_GRADIENT;
|
||||
gimp_context_prop_types[GIMP_CONTEXT_PROP_PALETTE] = GIMP_TYPE_PALETTE;
|
||||
gimp_context_prop_types[GIMP_CONTEXT_PROP_FONT] = GIMP_TYPE_FONT;
|
||||
gimp_context_prop_types[GIMP_CONTEXT_PROP_BUFFER] = GIMP_TYPE_BUFFER;
|
||||
gimp_context_prop_types[GIMP_CONTEXT_PROP_IMAGEFILE] = GIMP_TYPE_IMAGEFILE;
|
||||
gimp_context_prop_types[GIMP_CONTEXT_PROP_TEMPLATE] = GIMP_TYPE_TEMPLATE;
|
||||
|
||||
g_object_class_install_property (object_class, GIMP_CONTEXT_PROP_GIMP,
|
||||
g_param_spec_object ("gimp",
|
||||
|
@ -545,6 +573,11 @@ gimp_context_class_init (GimpContextClass *klass)
|
|||
GIMP_TYPE_TOOL_INFO,
|
||||
0);
|
||||
|
||||
GIMP_CONFIG_INSTALL_PROP_OBJECT (object_class, GIMP_CONTEXT_PROP_PAINT_INFO,
|
||||
gimp_context_prop_names[GIMP_CONTEXT_PROP_PAINT_INFO], NULL,
|
||||
GIMP_TYPE_PAINT_INFO,
|
||||
0);
|
||||
|
||||
GIMP_CONFIG_INSTALL_PROP_RGB (object_class, GIMP_CONTEXT_PROP_FOREGROUND,
|
||||
gimp_context_prop_names[GIMP_CONTEXT_PROP_FOREGROUND],
|
||||
NULL,
|
||||
|
@ -637,6 +670,9 @@ gimp_context_init (GimpContext *context)
|
|||
context->tool_info = NULL;
|
||||
context->tool_name = NULL;
|
||||
|
||||
context->paint_info = NULL;
|
||||
context->paint_name = NULL;
|
||||
|
||||
context->brush = NULL;
|
||||
context->brush_name = NULL;
|
||||
|
||||
|
@ -700,6 +736,13 @@ gimp_context_constructor (GType type,
|
|||
G_CALLBACK (gimp_context_tool_list_thaw),
|
||||
object, 0);
|
||||
|
||||
g_signal_connect_object (gimp->paint_info_list, "remove",
|
||||
G_CALLBACK (gimp_context_paint_info_removed),
|
||||
object, 0);
|
||||
g_signal_connect_object (gimp->paint_info_list, "thaw",
|
||||
G_CALLBACK (gimp_context_paint_info_list_thaw),
|
||||
object, 0);
|
||||
|
||||
g_signal_connect_object (gimp->brush_factory->container, "remove",
|
||||
G_CALLBACK (gimp_context_brush_removed),
|
||||
object, 0);
|
||||
|
@ -794,6 +837,17 @@ gimp_context_finalize (GObject *object)
|
|||
context->tool_name = NULL;
|
||||
}
|
||||
|
||||
if (context->paint_info)
|
||||
{
|
||||
g_object_unref (context->paint_info);
|
||||
context->paint_info = NULL;
|
||||
}
|
||||
if (context->paint_name)
|
||||
{
|
||||
g_free (context->paint_name);
|
||||
context->paint_name = NULL;
|
||||
}
|
||||
|
||||
if (context->brush)
|
||||
{
|
||||
g_object_unref (context->brush);
|
||||
|
@ -907,6 +961,9 @@ gimp_context_set_property (GObject *object,
|
|||
case GIMP_CONTEXT_PROP_TOOL:
|
||||
gimp_context_set_tool (context, g_value_get_object (value));
|
||||
break;
|
||||
case GIMP_CONTEXT_PROP_PAINT_INFO:
|
||||
gimp_context_set_paint_info (context, g_value_get_object (value));
|
||||
break;
|
||||
case GIMP_CONTEXT_PROP_FOREGROUND:
|
||||
gimp_context_set_foreground (context, g_value_get_boxed (value));
|
||||
break;
|
||||
|
@ -971,6 +1028,9 @@ gimp_context_get_property (GObject *object,
|
|||
case GIMP_CONTEXT_PROP_TOOL:
|
||||
g_value_set_object (value, gimp_context_get_tool (context));
|
||||
break;
|
||||
case GIMP_CONTEXT_PROP_PAINT_INFO:
|
||||
g_value_set_object (value, gimp_context_get_paint_info (context));
|
||||
break;
|
||||
case GIMP_CONTEXT_PROP_FOREGROUND:
|
||||
{
|
||||
GimpRGB color;
|
||||
|
@ -1033,6 +1093,9 @@ gimp_context_get_memsize (GimpObject *object,
|
|||
if (context->tool_name)
|
||||
memsize += strlen (context->tool_name) + 1;
|
||||
|
||||
if (context->paint_name)
|
||||
memsize += strlen (context->paint_name) + 1;
|
||||
|
||||
if (context->brush_name)
|
||||
memsize += strlen (context->brush_name) + 1;
|
||||
|
||||
|
@ -1083,6 +1146,7 @@ gimp_context_serialize_property (GimpConfig *config,
|
|||
switch (property_id)
|
||||
{
|
||||
case GIMP_CONTEXT_PROP_TOOL:
|
||||
case GIMP_CONTEXT_PROP_PAINT_INFO:
|
||||
case GIMP_CONTEXT_PROP_BRUSH:
|
||||
case GIMP_CONTEXT_PROP_PATTERN:
|
||||
case GIMP_CONTEXT_PROP_GRADIENT:
|
||||
|
@ -1131,6 +1195,13 @@ gimp_context_deserialize_property (GimpConfig *object,
|
|||
no_data = TRUE;
|
||||
break;
|
||||
|
||||
case GIMP_CONTEXT_PROP_PAINT_INFO:
|
||||
container = context->gimp->paint_info_list;
|
||||
current = (GimpObject *) context->paint_info;
|
||||
name_loc = &context->paint_name;
|
||||
no_data = TRUE;
|
||||
break;
|
||||
|
||||
case GIMP_CONTEXT_PROP_BRUSH:
|
||||
container = context->gimp->brush_factory->container;
|
||||
current = (GimpObject *) context->brush;
|
||||
|
@ -1425,6 +1496,14 @@ gimp_context_copy_property (GimpContext *src,
|
|||
dest_name_loc = &dest->tool_name;
|
||||
break;
|
||||
|
||||
case GIMP_CONTEXT_PROP_PAINT_INFO:
|
||||
gimp_context_real_set_paint_info (dest, src->paint_info);
|
||||
object = src->paint_info;
|
||||
standard_object = standard_paint_info;
|
||||
src_name = src->paint_name;
|
||||
dest_name_loc = &dest->paint_name;
|
||||
break;
|
||||
|
||||
case GIMP_CONTEXT_PROP_FOREGROUND:
|
||||
gimp_context_real_set_foreground (dest, &src->foreground);
|
||||
break;
|
||||
|
@ -1862,6 +1941,9 @@ gimp_context_real_set_tool (GimpContext *context,
|
|||
|
||||
if (tool_info != standard_tool_info)
|
||||
context->tool_name = g_strdup (GIMP_OBJECT (tool_info)->name);
|
||||
|
||||
if (tool_info->paint_info)
|
||||
gimp_context_real_set_paint_info (context, tool_info->paint_info);
|
||||
}
|
||||
|
||||
g_object_notify (G_OBJECT (context), "tool");
|
||||
|
@ -1869,6 +1951,129 @@ gimp_context_real_set_tool (GimpContext *context,
|
|||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* paint info **************************************************************/
|
||||
|
||||
GimpPaintInfo *
|
||||
gimp_context_get_paint_info (GimpContext *context)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
||||
|
||||
return context->paint_info;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_context_set_paint_info (GimpContext *context,
|
||||
GimpPaintInfo *paint_info)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
||||
g_return_if_fail (! paint_info || GIMP_IS_PAINT_INFO (paint_info));
|
||||
context_find_defined (context, GIMP_CONTEXT_PROP_PAINT_INFO);
|
||||
|
||||
gimp_context_real_set_paint_info (context, paint_info);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_context_paint_info_changed (GimpContext *context)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
||||
|
||||
g_signal_emit (context,
|
||||
gimp_context_signals[PAINT_INFO_CHANGED], 0,
|
||||
context->paint_info);
|
||||
}
|
||||
|
||||
/* the active paint info was modified */
|
||||
static void
|
||||
gimp_context_paint_info_dirty (GimpPaintInfo *paint_info,
|
||||
GimpContext *context)
|
||||
{
|
||||
g_free (context->paint_name);
|
||||
context->paint_name = g_strdup (GIMP_OBJECT (paint_info)->name);
|
||||
}
|
||||
|
||||
/* the global paint info list is there again after refresh */
|
||||
static void
|
||||
gimp_context_paint_info_list_thaw (GimpContainer *container,
|
||||
GimpContext *context)
|
||||
{
|
||||
GimpPaintInfo *paint_info;
|
||||
|
||||
if (! context->paint_name)
|
||||
context->paint_name = g_strdup ("GimpPaintbrush");
|
||||
|
||||
paint_info = gimp_context_find_object (context, container,
|
||||
context->paint_name,
|
||||
gimp_paint_info_get_standard (context->gimp));
|
||||
|
||||
gimp_context_real_set_paint_info (context, paint_info);
|
||||
}
|
||||
|
||||
/* the active paint info disappeared */
|
||||
static void
|
||||
gimp_context_paint_info_removed (GimpContainer *container,
|
||||
GimpPaintInfo *paint_info,
|
||||
GimpContext *context)
|
||||
{
|
||||
if (paint_info == context->paint_info)
|
||||
{
|
||||
context->paint_info = NULL;
|
||||
|
||||
g_signal_handlers_disconnect_by_func (paint_info,
|
||||
gimp_context_paint_info_dirty,
|
||||
context);
|
||||
g_object_unref (paint_info);
|
||||
|
||||
if (! gimp_container_frozen (container))
|
||||
gimp_context_paint_info_list_thaw (container, context);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_context_real_set_paint_info (GimpContext *context,
|
||||
GimpPaintInfo *paint_info)
|
||||
{
|
||||
if (! standard_paint_info)
|
||||
standard_paint_info = gimp_paint_info_get_standard (context->gimp);
|
||||
|
||||
if (context->paint_info == paint_info)
|
||||
return;
|
||||
|
||||
if (context->paint_name && paint_info != standard_paint_info)
|
||||
{
|
||||
g_free (context->paint_name);
|
||||
context->paint_name = NULL;
|
||||
}
|
||||
|
||||
/* disconnect from the old paint info's signals */
|
||||
if (context->paint_info)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (context->paint_info,
|
||||
gimp_context_paint_info_dirty,
|
||||
context);
|
||||
g_object_unref (context->paint_info);
|
||||
}
|
||||
|
||||
context->paint_info = paint_info;
|
||||
|
||||
if (paint_info)
|
||||
{
|
||||
g_object_ref (paint_info);
|
||||
|
||||
g_signal_connect_object (paint_info, "name-changed",
|
||||
G_CALLBACK (gimp_context_paint_info_dirty),
|
||||
context,
|
||||
0);
|
||||
|
||||
if (paint_info != standard_paint_info)
|
||||
context->paint_name = g_strdup (GIMP_OBJECT (paint_info)->name);
|
||||
}
|
||||
|
||||
g_object_notify (G_OBJECT (context), "paint-info");
|
||||
gimp_context_paint_info_changed (context);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* foreground color ********************************************************/
|
||||
|
||||
|
|
|
@ -53,6 +53,9 @@ struct _GimpContext
|
|||
GimpToolInfo *tool_info;
|
||||
gchar *tool_name;
|
||||
|
||||
GimpPaintInfo *paint_info;
|
||||
gchar *paint_name;
|
||||
|
||||
GimpRGB foreground;
|
||||
GimpRGB background;
|
||||
|
||||
|
@ -95,6 +98,8 @@ struct _GimpContextClass
|
|||
|
||||
void (* tool_changed) (GimpContext *context,
|
||||
GimpToolInfo *tool_info);
|
||||
void (* paint_info_changed) (GimpContext *context,
|
||||
GimpPaintInfo *paint_info);
|
||||
|
||||
void (* foreground_changed) (GimpContext *context,
|
||||
GimpRGB *color);
|
||||
|
@ -208,6 +213,13 @@ void gimp_context_set_tool (GimpContext *context,
|
|||
void gimp_context_tool_changed (GimpContext *context);
|
||||
|
||||
|
||||
/* paint info */
|
||||
GimpPaintInfo * gimp_context_get_paint_info (GimpContext *context);
|
||||
void gimp_context_set_paint_info (GimpContext *context,
|
||||
GimpPaintInfo *paint_info);
|
||||
void gimp_context_paint_info_changed (GimpContext *context);
|
||||
|
||||
|
||||
/* foreground color */
|
||||
void gimp_context_get_foreground (GimpContext *context,
|
||||
GimpRGB *color);
|
||||
|
|
|
@ -91,15 +91,20 @@ GimpPaintInfo *
|
|||
gimp_paint_info_new (Gimp *gimp,
|
||||
GType paint_type,
|
||||
GType paint_options_type,
|
||||
const gchar *blurb)
|
||||
const gchar *identifier,
|
||||
const gchar *blurb,
|
||||
const gchar *stock_id)
|
||||
{
|
||||
GimpPaintInfo *paint_info;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (identifier != NULL, NULL);
|
||||
g_return_val_if_fail (blurb != NULL, NULL);
|
||||
g_return_val_if_fail (stock_id != NULL, NULL);
|
||||
|
||||
paint_info = g_object_new (GIMP_TYPE_PAINT_INFO,
|
||||
"name", g_type_name (paint_type),
|
||||
"name", identifier,
|
||||
"stock-id", stock_id,
|
||||
NULL);
|
||||
|
||||
paint_info->gimp = gimp;
|
||||
|
@ -111,3 +116,30 @@ gimp_paint_info_new (Gimp *gimp,
|
|||
|
||||
return paint_info;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_paint_info_set_standard (Gimp *gimp,
|
||||
GimpPaintInfo *paint_info)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (! paint_info || GIMP_IS_PAINT_INFO (paint_info));
|
||||
|
||||
if (paint_info != gimp->standard_paint_info)
|
||||
{
|
||||
if (gimp->standard_paint_info)
|
||||
g_object_unref (gimp->standard_paint_info);
|
||||
|
||||
gimp->standard_paint_info = paint_info;
|
||||
|
||||
if (gimp->standard_paint_info)
|
||||
g_object_ref (gimp->standard_paint_info);
|
||||
}
|
||||
}
|
||||
|
||||
GimpPaintInfo *
|
||||
gimp_paint_info_get_standard (Gimp *gimp)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
|
||||
return gimp->standard_paint_info;
|
||||
}
|
||||
|
|
|
@ -53,12 +53,18 @@ struct _GimpPaintInfoClass
|
|||
};
|
||||
|
||||
|
||||
GType gimp_paint_info_get_type (void) G_GNUC_CONST;
|
||||
GType gimp_paint_info_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GimpPaintInfo * gimp_paint_info_new (Gimp *gimp,
|
||||
GType paint_type,
|
||||
GType paint_options_type,
|
||||
const gchar *blurb);
|
||||
GimpPaintInfo * gimp_paint_info_new (Gimp *gimp,
|
||||
GType paint_type,
|
||||
GType paint_options_type,
|
||||
const gchar *identifier,
|
||||
const gchar *blurb,
|
||||
const gchar *stock_id);
|
||||
|
||||
void gimp_paint_info_set_standard (Gimp *gimp,
|
||||
GimpPaintInfo *paint_info);
|
||||
GimpPaintInfo * gimp_paint_info_get_standard (Gimp *gimp);
|
||||
|
||||
|
||||
#endif /* __GIMP_PAINT_INFO_H__ */
|
||||
|
|
|
@ -30,11 +30,9 @@
|
|||
|
||||
#include "config/gimpcoreconfig.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontainer.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimpcontainer.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimppaintinfo.h"
|
||||
#include "gimpstrokedesc.h"
|
||||
#include "gimpstrokeoptions.h"
|
||||
|
@ -247,15 +245,10 @@ gimp_stroke_desc_new (Gimp *gimp,
|
|||
|
||||
if (context)
|
||||
{
|
||||
GimpToolInfo *tool_info = gimp_context_get_tool (context);
|
||||
|
||||
if (tool_info)
|
||||
paint_info = tool_info->paint_info;
|
||||
paint_info = gimp_context_get_paint_info (context);
|
||||
|
||||
if (! paint_info)
|
||||
paint_info = (GimpPaintInfo *)
|
||||
gimp_container_get_child_by_name (gimp->paint_info_list,
|
||||
"GimpPaintbrush");
|
||||
paint_info = gimp_paint_info_get_standard (gimp);
|
||||
}
|
||||
|
||||
desc = g_object_new (GIMP_TYPE_STROKE_DESC,
|
||||
|
|
|
@ -256,8 +256,6 @@ gimp_tool_info_new (Gimp *gimp,
|
|||
|
||||
if (tool_info->tool_options_type == paint_info->paint_options_type)
|
||||
{
|
||||
gimp_viewable_set_stock_id (GIMP_VIEWABLE (paint_info), stock_id);
|
||||
|
||||
tool_info->tool_options = g_object_ref (paint_info->paint_options);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -44,7 +44,9 @@
|
|||
static void gimp_paint_register (Gimp *gimp,
|
||||
GType paint_type,
|
||||
GType paint_options_type,
|
||||
const gchar *blurb);
|
||||
const gchar *identifier,
|
||||
const gchar *blurb,
|
||||
const gchar *stock_id);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
@ -72,10 +74,14 @@ gimp_paint_init (Gimp *gimp)
|
|||
gimp->paint_info_list = gimp_list_new (GIMP_TYPE_PAINT_INFO, FALSE);
|
||||
gimp_object_set_name (GIMP_OBJECT (gimp->paint_info_list), "paint infos");
|
||||
|
||||
gimp_container_freeze (gimp->paint_info_list);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (register_funcs); i++)
|
||||
{
|
||||
register_funcs[i] (gimp, gimp_paint_register);
|
||||
}
|
||||
|
||||
gimp_container_thaw (gimp->paint_info_list);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -83,6 +89,8 @@ gimp_paint_exit (Gimp *gimp)
|
|||
{
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
|
||||
gimp_paint_info_set_standard (gimp, NULL);
|
||||
|
||||
if (gimp->paint_info_list)
|
||||
{
|
||||
g_object_unref (gimp->paint_info_list);
|
||||
|
@ -97,7 +105,9 @@ static void
|
|||
gimp_paint_register (Gimp *gimp,
|
||||
GType paint_type,
|
||||
GType paint_options_type,
|
||||
const gchar *blurb)
|
||||
const gchar *identifier,
|
||||
const gchar *blurb,
|
||||
const gchar *stock_id)
|
||||
{
|
||||
GimpPaintInfo *paint_info;
|
||||
|
||||
|
@ -109,8 +119,13 @@ gimp_paint_register (Gimp *gimp,
|
|||
paint_info = gimp_paint_info_new (gimp,
|
||||
paint_type,
|
||||
paint_options_type,
|
||||
blurb);
|
||||
identifier,
|
||||
blurb,
|
||||
stock_id);
|
||||
|
||||
gimp_container_add (gimp->paint_info_list, GIMP_OBJECT (paint_info));
|
||||
g_object_unref (paint_info);
|
||||
|
||||
if (paint_type == GIMP_TYPE_PAINTBRUSH)
|
||||
gimp_paint_info_set_standard (gimp, paint_info);
|
||||
}
|
||||
|
|
|
@ -65,7 +65,9 @@ gimp_airbrush_register (Gimp *gimp,
|
|||
(* callback) (gimp,
|
||||
GIMP_TYPE_AIRBRUSH,
|
||||
GIMP_TYPE_AIRBRUSH_OPTIONS,
|
||||
_("Airbrush"));
|
||||
"gimp-airbrush",
|
||||
_("Airbrush"),
|
||||
"gimp-tool-airbrush");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -85,7 +85,9 @@ gimp_clone_register (Gimp *gimp,
|
|||
(* callback) (gimp,
|
||||
GIMP_TYPE_CLONE,
|
||||
GIMP_TYPE_CLONE_OPTIONS,
|
||||
_("Clone"));
|
||||
"gimp-clone",
|
||||
_("Clone"),
|
||||
"gimp-tool-clone");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -115,7 +115,9 @@ gimp_convolve_register (Gimp *gimp,
|
|||
(* callback) (gimp,
|
||||
GIMP_TYPE_CONVOLVE,
|
||||
GIMP_TYPE_CONVOLVE_OPTIONS,
|
||||
_("Convolve"));
|
||||
"gimp-convolve",
|
||||
_("Convolve"),
|
||||
"gimp-tool-convolve");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -83,7 +83,9 @@ gimp_dodge_burn_register (Gimp *gimp,
|
|||
(* callback) (gimp,
|
||||
GIMP_TYPE_DODGE_BURN,
|
||||
GIMP_TYPE_DODGE_BURN_OPTIONS,
|
||||
_("Dodge/Burn"));
|
||||
"gimp-dodge-burn",
|
||||
_("Dodge/Burn"),
|
||||
"gimp-tool-dodge-burn");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -58,7 +58,9 @@ gimp_eraser_register (Gimp *gimp,
|
|||
(* callback) (gimp,
|
||||
GIMP_TYPE_ERASER,
|
||||
GIMP_TYPE_ERASER_OPTIONS,
|
||||
_("Eraser"));
|
||||
"gimp-eraser",
|
||||
_("Eraser"),
|
||||
"gimp-tool-eraser");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -99,7 +99,9 @@ gimp_ink_register (Gimp *gimp,
|
|||
(* callback) (gimp,
|
||||
GIMP_TYPE_INK,
|
||||
GIMP_TYPE_INK_OPTIONS,
|
||||
_("Ink"));
|
||||
"gimp-ink",
|
||||
_("Ink"),
|
||||
"gimp-tool-ink");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -59,7 +59,9 @@ gimp_paintbrush_register (Gimp *gimp,
|
|||
(* callback) (gimp,
|
||||
GIMP_TYPE_PAINTBRUSH,
|
||||
GIMP_TYPE_PAINT_OPTIONS,
|
||||
_("Paintbrush"));
|
||||
"gimp-paintbrush",
|
||||
_("Paintbrush"),
|
||||
"gimp-tool-paintbrush");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -38,7 +38,9 @@ gimp_pencil_register (Gimp *gimp,
|
|||
(* callback) (gimp,
|
||||
GIMP_TYPE_PENCIL,
|
||||
GIMP_TYPE_PENCIL_OPTIONS,
|
||||
_("Pencil"));
|
||||
"gimp-pencil",
|
||||
_("Pencil"),
|
||||
"gimp-tool-pencil");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -74,7 +74,9 @@ gimp_smudge_register (Gimp *gimp,
|
|||
(* callback) (gimp,
|
||||
GIMP_TYPE_SMUDGE,
|
||||
GIMP_TYPE_SMUDGE_OPTIONS,
|
||||
_("Smudge"));
|
||||
"gimp-smudge",
|
||||
_("Smudge"),
|
||||
"gimp-tool-smudge");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -85,7 +85,9 @@ gimp_clone_register (Gimp *gimp,
|
|||
(* callback) (gimp,
|
||||
GIMP_TYPE_CLONE,
|
||||
GIMP_TYPE_CLONE_OPTIONS,
|
||||
_("Clone"));
|
||||
"gimp-clone",
|
||||
_("Clone"),
|
||||
"gimp-tool-clone");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -36,7 +36,9 @@ typedef struct _GimpPaintOptions GimpPaintOptions;
|
|||
typedef void (* GimpPaintRegisterCallback) (Gimp *gimp,
|
||||
GType paint_type,
|
||||
GType paint_options_type,
|
||||
const gchar *blurb);
|
||||
const gchar *identifier,
|
||||
const gchar *blurb,
|
||||
const gchar *stock_id);
|
||||
|
||||
typedef void (* GimpPaintRegisterFunc) (Gimp *gimp,
|
||||
GimpPaintRegisterCallback callback);
|
||||
|
|
|
@ -488,43 +488,43 @@ gimp_tools_register (GType tool_type,
|
|||
|
||||
if (tool_type == GIMP_TYPE_PENCIL_TOOL)
|
||||
{
|
||||
paint_core_name = "GimpPencil";
|
||||
paint_core_name = "gimp-pencil";
|
||||
}
|
||||
else if (tool_type == GIMP_TYPE_PAINTBRUSH_TOOL)
|
||||
{
|
||||
paint_core_name = "GimpPaintbrush";
|
||||
paint_core_name = "gimp-paintbrush";
|
||||
}
|
||||
else if (tool_type == GIMP_TYPE_ERASER_TOOL)
|
||||
{
|
||||
paint_core_name = "GimpEraser";
|
||||
paint_core_name = "gimp-eraser";
|
||||
}
|
||||
else if (tool_type == GIMP_TYPE_AIRBRUSH_TOOL)
|
||||
{
|
||||
paint_core_name = "GimpAirbrush";
|
||||
paint_core_name = "gimp-airbrush";
|
||||
}
|
||||
else if (tool_type == GIMP_TYPE_CLONE_TOOL)
|
||||
{
|
||||
paint_core_name = "GimpClone";
|
||||
paint_core_name = "gimp-clone";
|
||||
}
|
||||
else if (tool_type == GIMP_TYPE_CONVOLVE_TOOL)
|
||||
{
|
||||
paint_core_name = "GimpConvolve";
|
||||
paint_core_name = "gimp-convolve";
|
||||
}
|
||||
else if (tool_type == GIMP_TYPE_SMUDGE_TOOL)
|
||||
{
|
||||
paint_core_name = "GimpSmudge";
|
||||
paint_core_name = "gimp-smudge";
|
||||
}
|
||||
else if (tool_type == GIMP_TYPE_DODGE_BURN_TOOL)
|
||||
{
|
||||
paint_core_name = "GimpDodgeBurn";
|
||||
paint_core_name = "gimp-dodge-burn";
|
||||
}
|
||||
else if (tool_type == GIMP_TYPE_INK_TOOL)
|
||||
{
|
||||
paint_core_name = "GimpInk";
|
||||
paint_core_name = "gimp-ink";
|
||||
}
|
||||
else
|
||||
{
|
||||
paint_core_name = "GimpPaintbrush";
|
||||
paint_core_name = "gimp-paintbrush";
|
||||
}
|
||||
|
||||
tool_info = gimp_tool_info_new (gimp,
|
||||
|
|
|
@ -29,6 +29,7 @@ G_BEGIN_DECLS
|
|||
|
||||
|
||||
#define GIMP_DEVICE_INFO_CONTEXT_MASK (GIMP_CONTEXT_TOOL_MASK | \
|
||||
GIMP_CONTEXT_PAINT_INFO_MASK | \
|
||||
GIMP_CONTEXT_FOREGROUND_MASK | \
|
||||
GIMP_CONTEXT_BACKGROUND_MASK | \
|
||||
GIMP_CONTEXT_BRUSH_MASK | \
|
||||
|
|
Loading…
Reference in New Issue