gimp r27523 - in trunk: . app/core
- From: mitch svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r27523 - in trunk: . app/core
- Date: Sun, 2 Nov 2008 19:53:51 +0000 (UTC)
Author: mitch
Date: Sun Nov 2 19:53:51 2008
New Revision: 27523
URL: http://svn.gnome.org/viewvc/gimp?rev=27523&view=rev
Log:
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().
Modified:
trunk/ChangeLog
trunk/app/core/gimpdrawablestack.c
trunk/app/core/gimpdrawablestack.h
trunk/app/core/gimpimage.c
trunk/app/core/gimpimage.h
Modified: trunk/app/core/gimpdrawablestack.c
==============================================================================
--- trunk/app/core/gimpdrawablestack.c (original)
+++ trunk/app/core/gimpdrawablestack.c Sun Nov 2 19:53:51 2008
@@ -27,6 +27,14 @@
#include "gimpdrawable.h"
#include "gimpdrawablestack.h"
+#include "gimpmarshal.h"
+
+
+enum
+{
+ UPDATE,
+ LAST_SIGNAL
+};
#ifdef __GNUC__
@@ -44,26 +52,45 @@
/* local function prototypes */
-static void gimp_drawable_stack_finalize (GObject *object);
-
-static void gimp_drawable_stack_add (GimpContainer *container,
- GimpObject *object);
-static void gimp_drawable_stack_remove (GimpContainer *container,
- GimpObject *object);
-static void gimp_drawable_stack_reorder (GimpContainer *container,
- GimpObject *object,
- gint new_index);
-
-static void gimp_drawable_stack_add_node (GimpDrawableStack *stack,
- GimpDrawable *drawable);
-static void gimp_drawable_stack_remove_node (GimpDrawableStack *stack,
- GimpDrawable *drawable);
+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,
+ GimpObject *object);
+static void gimp_drawable_stack_remove (GimpContainer *container,
+ GimpObject *object);
+static void gimp_drawable_stack_reorder (GimpContainer *container,
+ GimpObject *object,
+ gint new_index);
+
+static void gimp_drawable_stack_add_node (GimpDrawableStack *stack,
+ GimpDrawable *drawable);
+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,16 +98,54 @@
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpContainerClass *container_class = GIMP_CONTAINER_CLASS (klass);
- object_class->finalize = gimp_drawable_stack_finalize;
-
- container_class->add = gimp_drawable_stack_add;
- container_class->remove = gimp_drawable_stack_remove;
- container_class->reorder = gimp_drawable_stack_reorder;
+ 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;
+ container_class->remove = gimp_drawable_stack_remove;
+ container_class->reorder = gimp_drawable_stack_reorder;
}
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
@@ -107,6 +172,9 @@
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_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 @@
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 @@
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));
+}
Modified: trunk/app/core/gimpdrawablestack.h
==============================================================================
--- trunk/app/core/gimpdrawablestack.h (original)
+++ trunk/app/core/gimpdrawablestack.h Sun Nov 2 19:53:51 2008
@@ -44,6 +44,12 @@
struct _GimpDrawableStackClass
{
GimpListClass parent_class;
+
+ void (* update) (GimpDrawableStack *stack,
+ gint x,
+ gint y,
+ gint width,
+ gint height);
};
Modified: trunk/app/core/gimpimage.c
==============================================================================
--- trunk/app/core/gimpimage.c (original)
+++ trunk/app/core/gimpimage.c Sun Nov 2 19:53:51 2008
@@ -131,74 +131,60 @@
static void gimp_color_managed_iface_init (GimpColorManagedInterface *iface);
-static GObject *gimp_image_constructor (GType type,
- guint n_params,
+static GObject *gimp_image_constructor (GType type,
+ guint n_params,
GObjectConstructParam *params);
-static void gimp_image_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gimp_image_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static void gimp_image_dispose (GObject *object);
-static void gimp_image_finalize (GObject *object);
-
-static void gimp_image_name_changed (GimpObject *object);
-static gint64 gimp_image_get_memsize (GimpObject *object,
- gint64 *gui_size);
-
-static gboolean gimp_image_get_size (GimpViewable *viewable,
- gint *width,
- gint *height);
-static void gimp_image_invalidate_preview (GimpViewable *viewable);
-static void gimp_image_size_changed (GimpViewable *viewable);
-static gchar * gimp_image_get_description (GimpViewable *viewable,
- gchar **tooltip);
+static void gimp_image_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_image_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_image_dispose (GObject *object);
+static void gimp_image_finalize (GObject *object);
+
+static void gimp_image_name_changed (GimpObject *object);
+static gint64 gimp_image_get_memsize (GimpObject *object,
+ gint64 *gui_size);
+
+static gboolean gimp_image_get_size (GimpViewable *viewable,
+ gint *width,
+ gint *height);
+static void gimp_image_invalidate_preview (GimpViewable *viewable);
+static void gimp_image_size_changed (GimpViewable *viewable);
+static gchar * gimp_image_get_description (GimpViewable *viewable,
+ gchar **tooltip);
static void gimp_image_real_size_changed_detailed
- (GimpImage *image,
- gint previous_origin_x,
- gint previous_origin_y,
- gint previous_width,
- gint previous_height);
-static void gimp_image_real_colormap_changed (GimpImage *image,
- gint color_index);
-static void gimp_image_real_flush (GimpImage *image,
- gboolean invalidate_preview);
-
-static void gimp_image_mask_update (GimpDrawable *drawable,
- gint x,
- gint y,
- 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);
-static void gimp_image_channel_remove (GimpContainer *container,
- GimpChannel *channel,
- GimpImage *image);
-static void gimp_image_channel_name_changed (GimpChannel *channel,
- GimpImage *image);
-static void gimp_image_channel_color_changed (GimpChannel *channel,
- GimpImage *image);
+ (GimpImage *image,
+ gint previous_origin_x,
+ gint previous_origin_y,
+ gint previous_width,
+ gint previous_height);
+static void gimp_image_real_colormap_changed (GimpImage *image,
+ gint color_index);
+static void gimp_image_real_flush (GimpImage *image,
+ gboolean invalidate_preview);
+
+static void gimp_image_mask_update (GimpDrawable *drawable,
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ GimpImage *image);
+static void gimp_image_layer_alpha_changed (GimpDrawable *drawable,
+ GimpImage *image);
+static void gimp_image_channel_add (GimpContainer *container,
+ GimpChannel *channel,
+ GimpImage *image);
+static void gimp_image_channel_remove (GimpContainer *container,
+ GimpChannel *channel,
+ GimpImage *image);
+static void gimp_image_channel_name_changed (GimpChannel *channel,
+ GimpImage *image);
+static void gimp_image_channel_color_changed (GimpChannel *channel,
+ GimpImage *image);
static const guint8 * gimp_image_get_icc_profile (GimpColorManaged *managed,
gsize *len);
@@ -631,27 +617,19 @@
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),
- image);
+ 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),
- image);
+ 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 @@
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_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);
@@ -1206,42 +1170,6 @@
}
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)
{
@@ -1250,37 +1178,10 @@
}
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 @@
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_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 @@
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 @@
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;
}
Modified: trunk/app/core/gimpimage.h
==============================================================================
--- trunk/app/core/gimpimage.h (original)
+++ trunk/app/core/gimpimage.h Sun Nov 2 19:53:51 2008
@@ -138,11 +138,7 @@
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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]