mirror of https://github.com/GNOME/gimp.git
add "update" signal with the same signature as GimpImage::update().
2008-11-02 Michael Natterer <mitch@gimp.org> * app/core/gimpdrawablestack.[ch]: add "update" signal with the same signature as GimpImage::update(). Install handlers for the drawables' "update" and "visibility-changed" signals and emit "update" accordingly, item offsets taken into account. Also emit "update" when drawables are added, removed and reordered. * app/core/gimpimage.[ch]: remove handlers and tons of code that makes sure the image emits "update" on any of the above handled events and simply connect the layer and channel stacks' "update" signal to gimp_image_update(). svn path=/trunk/; revision=27523
This commit is contained in:
parent
50ac74be1e
commit
c14c84ba63
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2008-11-02 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/gimpdrawablestack.[ch]: add "update" signal with the
|
||||
same signature as GimpImage::update(). Install handlers for the
|
||||
drawables' "update" and "visibility-changed" signals and emit
|
||||
"update" accordingly, item offsets taken into account. Also emit
|
||||
"update" when drawables are added, removed and reordered.
|
||||
|
||||
* app/core/gimpimage.[ch]: remove handlers and tons of code that
|
||||
makes sure the image emits "update" on any of the above handled
|
||||
events and simply connect the layer and channel stacks' "update"
|
||||
signal to gimp_image_update().
|
||||
|
||||
2008-11-02 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/gimplayer.[ch]: remove the mask_node and simply set
|
||||
|
|
|
@ -27,6 +27,14 @@
|
|||
|
||||
#include "gimpdrawable.h"
|
||||
#include "gimpdrawablestack.h"
|
||||
#include "gimpmarshal.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
UPDATE,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
@ -44,6 +52,9 @@ GeglNode * gegl_node_remove_child (GeglNode *self,
|
|||
|
||||
/* local function prototypes */
|
||||
|
||||
static GObject * gimp_drawable_stack_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params);
|
||||
static void gimp_drawable_stack_finalize (GObject *object);
|
||||
|
||||
static void gimp_drawable_stack_add (GimpContainer *container,
|
||||
|
@ -59,11 +70,27 @@ static void gimp_drawable_stack_add_node (GimpDrawableStack *stack,
|
|||
static void gimp_drawable_stack_remove_node (GimpDrawableStack *stack,
|
||||
GimpDrawable *drawable);
|
||||
|
||||
static void gimp_drawable_stack_update (GimpDrawableStack *stack,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height);
|
||||
static void gimp_drawable_stack_drawable_update (GimpItem *item,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpDrawableStack *stack);
|
||||
static void gimp_drawable_stack_drawable_visible (GimpItem *item,
|
||||
GimpDrawableStack *stack);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpDrawableStack, gimp_drawable_stack, GIMP_TYPE_LIST)
|
||||
|
||||
#define parent_class gimp_drawable_stack_parent_class
|
||||
|
||||
static guint stack_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
|
||||
static void
|
||||
gimp_drawable_stack_class_init (GimpDrawableStackClass *klass)
|
||||
|
@ -71,6 +98,20 @@ gimp_drawable_stack_class_init (GimpDrawableStackClass *klass)
|
|||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpContainerClass *container_class = GIMP_CONTAINER_CLASS (klass);
|
||||
|
||||
stack_signals[UPDATE] =
|
||||
g_signal_new ("update",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpDrawableStackClass, update),
|
||||
NULL, NULL,
|
||||
gimp_marshal_VOID__INT_INT_INT_INT,
|
||||
G_TYPE_NONE, 4,
|
||||
G_TYPE_INT,
|
||||
G_TYPE_INT,
|
||||
G_TYPE_INT,
|
||||
G_TYPE_INT);
|
||||
|
||||
object_class->constructor = gimp_drawable_stack_constructor;
|
||||
object_class->finalize = gimp_drawable_stack_finalize;
|
||||
|
||||
container_class->add = gimp_drawable_stack_add;
|
||||
|
@ -79,10 +120,34 @@ gimp_drawable_stack_class_init (GimpDrawableStackClass *klass)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_drawable_stack_init (GimpDrawableStack *list)
|
||||
gimp_drawable_stack_init (GimpDrawableStack *stack)
|
||||
{
|
||||
}
|
||||
|
||||
static GObject *
|
||||
gimp_drawable_stack_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params)
|
||||
{
|
||||
GObject *object;
|
||||
GimpContainer *container;
|
||||
|
||||
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
||||
|
||||
container = GIMP_CONTAINER (object);
|
||||
|
||||
g_assert (g_type_is_a (container->children_type, GIMP_TYPE_DRAWABLE));
|
||||
|
||||
gimp_container_add_handler (container, "update",
|
||||
G_CALLBACK (gimp_drawable_stack_drawable_update),
|
||||
container);
|
||||
gimp_container_add_handler (container, "visibility-changed",
|
||||
G_CALLBACK (gimp_drawable_stack_drawable_visible),
|
||||
container);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_drawable_stack_finalize (GObject *object)
|
||||
{
|
||||
|
@ -107,6 +172,9 @@ gimp_drawable_stack_add (GimpContainer *container,
|
|||
|
||||
if (stack->graph)
|
||||
gimp_drawable_stack_add_node (stack, GIMP_DRAWABLE (object));
|
||||
|
||||
if (gimp_item_get_visible (GIMP_ITEM (object)))
|
||||
gimp_drawable_stack_drawable_visible (GIMP_ITEM (object), stack);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -124,6 +192,9 @@ gimp_drawable_stack_remove (GimpContainer *container,
|
|||
}
|
||||
|
||||
GIMP_CONTAINER_CLASS (parent_class)->remove (container, object);
|
||||
|
||||
if (gimp_item_get_visible (GIMP_ITEM (object)))
|
||||
gimp_drawable_stack_drawable_visible (GIMP_ITEM (object), stack);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -140,6 +211,9 @@ gimp_drawable_stack_reorder (GimpContainer *container,
|
|||
|
||||
if (stack->graph)
|
||||
gimp_drawable_stack_add_node (stack, GIMP_DRAWABLE (object));
|
||||
|
||||
if (gimp_item_get_visible (GIMP_ITEM (object)))
|
||||
gimp_drawable_stack_drawable_visible (GIMP_ITEM (object), stack);
|
||||
}
|
||||
|
||||
|
||||
|
@ -297,3 +371,50 @@ gimp_drawable_stack_remove_node (GimpDrawableStack *stack,
|
|||
gegl_node_disconnect (node_above, "input");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_drawable_stack_update (GimpDrawableStack *stack,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
g_signal_emit (stack, stack_signals[UPDATE], 0,
|
||||
x, y, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_drawable_stack_drawable_update (GimpItem *item,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpDrawableStack *stack)
|
||||
{
|
||||
if (gimp_item_get_visible (item))
|
||||
{
|
||||
gint offset_x;
|
||||
gint offset_y;
|
||||
|
||||
gimp_item_offsets (item, &offset_x, &offset_y);
|
||||
|
||||
gimp_drawable_stack_update (stack,
|
||||
x + offset_x, y + offset_y,
|
||||
width, height);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_drawable_stack_drawable_visible (GimpItem *item,
|
||||
GimpDrawableStack *stack)
|
||||
{
|
||||
gint offset_x;
|
||||
gint offset_y;
|
||||
|
||||
gimp_item_offsets (item, &offset_x, &offset_y);
|
||||
|
||||
gimp_drawable_stack_update (stack,
|
||||
offset_x, offset_y,
|
||||
gimp_item_width (item),
|
||||
gimp_item_height (item));
|
||||
}
|
||||
|
|
|
@ -44,6 +44,12 @@ struct _GimpDrawableStack
|
|||
struct _GimpDrawableStackClass
|
||||
{
|
||||
GimpListClass parent_class;
|
||||
|
||||
void (* update) (GimpDrawableStack *stack,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -173,22 +173,8 @@ static void gimp_image_mask_update (GimpDrawable *drawable,
|
|||
gint width,
|
||||
gint height,
|
||||
GimpImage *image);
|
||||
static void gimp_image_drawable_update (GimpDrawable *drawable,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpImage *image);
|
||||
static void gimp_image_drawable_visibility (GimpItem *item,
|
||||
GimpImage *image);
|
||||
static void gimp_image_layer_alpha_changed (GimpDrawable *drawable,
|
||||
GimpImage *image);
|
||||
static void gimp_image_layer_add (GimpContainer *container,
|
||||
GimpLayer *layer,
|
||||
GimpImage *image);
|
||||
static void gimp_image_layer_remove (GimpContainer *container,
|
||||
GimpLayer *layer,
|
||||
GimpImage *image);
|
||||
static void gimp_image_channel_add (GimpContainer *container,
|
||||
GimpChannel *channel,
|
||||
GimpImage *image);
|
||||
|
@ -631,27 +617,19 @@ gimp_image_init (GimpImage *image)
|
|||
image->vectors = gimp_list_new (GIMP_TYPE_VECTORS, TRUE);
|
||||
image->layer_stack = NULL;
|
||||
|
||||
image->layer_update_handler =
|
||||
gimp_container_add_handler (image->layers, "update",
|
||||
G_CALLBACK (gimp_image_drawable_update),
|
||||
image);
|
||||
image->layer_visible_handler =
|
||||
gimp_container_add_handler (image->layers, "visibility-changed",
|
||||
G_CALLBACK (gimp_image_drawable_visibility),
|
||||
g_signal_connect_swapped (image->layers, "update",
|
||||
G_CALLBACK (gimp_image_update),
|
||||
image);
|
||||
|
||||
image->layer_alpha_handler =
|
||||
gimp_container_add_handler (image->layers, "alpha-changed",
|
||||
G_CALLBACK (gimp_image_layer_alpha_changed),
|
||||
image);
|
||||
|
||||
image->channel_update_handler =
|
||||
gimp_container_add_handler (image->channels, "update",
|
||||
G_CALLBACK (gimp_image_drawable_update),
|
||||
image);
|
||||
image->channel_visible_handler =
|
||||
gimp_container_add_handler (image->channels, "visibility-changed",
|
||||
G_CALLBACK (gimp_image_drawable_visibility),
|
||||
g_signal_connect_swapped (image->channels, "update",
|
||||
G_CALLBACK (gimp_image_update),
|
||||
image);
|
||||
|
||||
image->channel_name_changed_handler =
|
||||
gimp_container_add_handler (image->channels, "name-changed",
|
||||
G_CALLBACK (gimp_image_channel_name_changed),
|
||||
|
@ -661,13 +639,6 @@ gimp_image_init (GimpImage *image)
|
|||
G_CALLBACK (gimp_image_channel_color_changed),
|
||||
image);
|
||||
|
||||
g_signal_connect (image->layers, "add",
|
||||
G_CALLBACK (gimp_image_layer_add),
|
||||
image);
|
||||
g_signal_connect (image->layers, "remove",
|
||||
G_CALLBACK (gimp_image_layer_remove),
|
||||
image);
|
||||
|
||||
g_signal_connect (image->channels, "add",
|
||||
G_CALLBACK (gimp_image_channel_add),
|
||||
image);
|
||||
|
@ -851,29 +822,22 @@ gimp_image_dispose (GObject *object)
|
|||
|
||||
gimp_image_undo_free (image);
|
||||
|
||||
gimp_container_remove_handler (image->layers,
|
||||
image->layer_update_handler);
|
||||
gimp_container_remove_handler (image->layers,
|
||||
image->layer_visible_handler);
|
||||
g_signal_handlers_disconnect_by_func (image->layers,
|
||||
gimp_image_update,
|
||||
image);
|
||||
|
||||
gimp_container_remove_handler (image->layers,
|
||||
image->layer_alpha_handler);
|
||||
|
||||
gimp_container_remove_handler (image->channels,
|
||||
image->channel_update_handler);
|
||||
gimp_container_remove_handler (image->channels,
|
||||
image->channel_visible_handler);
|
||||
g_signal_handlers_disconnect_by_func (image->channels,
|
||||
gimp_image_update,
|
||||
image);
|
||||
|
||||
gimp_container_remove_handler (image->channels,
|
||||
image->channel_name_changed_handler);
|
||||
gimp_container_remove_handler (image->channels,
|
||||
image->channel_color_changed_handler);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (image->layers,
|
||||
gimp_image_layer_add,
|
||||
image);
|
||||
g_signal_handlers_disconnect_by_func (image->layers,
|
||||
gimp_image_layer_remove,
|
||||
image);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (image->channels,
|
||||
gimp_image_channel_add,
|
||||
image);
|
||||
|
@ -1205,42 +1169,6 @@ gimp_image_mask_update (GimpDrawable *drawable,
|
|||
image->flush_accum.mask_changed = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_drawable_update (GimpDrawable *drawable,
|
||||
gint x,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpImage *image)
|
||||
{
|
||||
GimpItem *item = GIMP_ITEM (drawable);
|
||||
|
||||
if (gimp_item_get_visible (item))
|
||||
{
|
||||
gint offset_x;
|
||||
gint offset_y;
|
||||
|
||||
gimp_item_offsets (item, &offset_x, &offset_y);
|
||||
|
||||
gimp_image_update (image, x + offset_x, y + offset_y, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_drawable_visibility (GimpItem *item,
|
||||
GimpImage *image)
|
||||
{
|
||||
gint offset_x;
|
||||
gint offset_y;
|
||||
|
||||
gimp_item_offsets (item, &offset_x, &offset_y);
|
||||
|
||||
gimp_image_update (image,
|
||||
offset_x, offset_y,
|
||||
gimp_item_width (item),
|
||||
gimp_item_height (item));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_layer_alpha_changed (GimpDrawable *drawable,
|
||||
GimpImage *image)
|
||||
|
@ -1249,38 +1177,11 @@ gimp_image_layer_alpha_changed (GimpDrawable *drawable,
|
|||
image->flush_accum.alpha_changed = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_layer_add (GimpContainer *container,
|
||||
GimpLayer *layer,
|
||||
GimpImage *image)
|
||||
{
|
||||
GimpItem *item = GIMP_ITEM (layer);
|
||||
|
||||
if (gimp_item_get_visible (item))
|
||||
gimp_image_drawable_visibility (item, image);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_layer_remove (GimpContainer *container,
|
||||
GimpLayer *layer,
|
||||
GimpImage *image)
|
||||
{
|
||||
GimpItem *item = GIMP_ITEM (layer);
|
||||
|
||||
if (gimp_item_get_visible (item))
|
||||
gimp_image_drawable_visibility (item, image);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_channel_add (GimpContainer *container,
|
||||
GimpChannel *channel,
|
||||
GimpImage *image)
|
||||
{
|
||||
GimpItem *item = GIMP_ITEM (channel);
|
||||
|
||||
if (gimp_item_get_visible (item))
|
||||
gimp_image_drawable_visibility (item, image);
|
||||
|
||||
if (! strcmp (GIMP_IMAGE_QUICK_MASK_NAME,
|
||||
gimp_object_get_name (GIMP_OBJECT (channel))))
|
||||
{
|
||||
|
@ -1293,11 +1194,6 @@ gimp_image_channel_remove (GimpContainer *container,
|
|||
GimpChannel *channel,
|
||||
GimpImage *image)
|
||||
{
|
||||
GimpItem *item = GIMP_ITEM (channel);
|
||||
|
||||
if (gimp_item_get_visible (item))
|
||||
gimp_image_drawable_visibility (item, image);
|
||||
|
||||
if (! strcmp (GIMP_IMAGE_QUICK_MASK_NAME,
|
||||
gimp_object_get_name (GIMP_OBJECT (channel))))
|
||||
{
|
||||
|
@ -3278,18 +3174,6 @@ gimp_image_position_layer (GimpImage *image,
|
|||
|
||||
gimp_container_reorder (image->layers, GIMP_OBJECT (layer), new_index);
|
||||
|
||||
if (gimp_item_get_visible (GIMP_ITEM (layer)))
|
||||
{
|
||||
gint off_x, off_y;
|
||||
|
||||
gimp_item_offsets (GIMP_ITEM (layer), &off_x, &off_y);
|
||||
|
||||
gimp_image_update (image,
|
||||
off_x, off_y,
|
||||
gimp_item_width (GIMP_ITEM (layer)),
|
||||
gimp_item_height (GIMP_ITEM (layer)));
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -3520,20 +3404,7 @@ gimp_image_position_channel (GimpImage *image,
|
|||
if (push_undo)
|
||||
gimp_image_undo_push_channel_reposition (image, undo_desc, channel);
|
||||
|
||||
gimp_container_reorder (image->channels,
|
||||
GIMP_OBJECT (channel), new_index);
|
||||
|
||||
if (gimp_item_get_visible (GIMP_ITEM (channel)))
|
||||
{
|
||||
gint off_x, off_y;
|
||||
|
||||
gimp_item_offsets (GIMP_ITEM (channel), &off_x, &off_y);
|
||||
|
||||
gimp_image_update (image,
|
||||
off_x, off_y,
|
||||
gimp_item_width (GIMP_ITEM (channel)),
|
||||
gimp_item_height (GIMP_ITEM (channel)));
|
||||
}
|
||||
gimp_container_reorder (image->channels, GIMP_OBJECT (channel), new_index);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -3740,8 +3611,7 @@ gimp_image_position_vectors (GimpImage *image,
|
|||
if (push_undo)
|
||||
gimp_image_undo_push_vectors_reposition (image, undo_desc, vectors);
|
||||
|
||||
gimp_container_reorder (image->vectors,
|
||||
GIMP_OBJECT (vectors), new_index);
|
||||
gimp_container_reorder (image->vectors, GIMP_OBJECT (vectors), new_index);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -138,11 +138,7 @@ struct _GimpImage
|
|||
GimpContainer *vectors; /* the list of vectors */
|
||||
GSList *layer_stack; /* the layers in MRU order */
|
||||
|
||||
GQuark layer_update_handler;
|
||||
GQuark layer_visible_handler;
|
||||
GQuark layer_alpha_handler;
|
||||
GQuark channel_update_handler;
|
||||
GQuark channel_visible_handler;
|
||||
GQuark channel_name_changed_handler;
|
||||
GQuark channel_color_changed_handler;
|
||||
|
||||
|
|
Loading…
Reference in New Issue