add signal "structure-changed" and API to emit it.

2008-11-05  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpprojectable.[ch]: add signal "structure-changed"
	and API to emit it.

	* app/core/gimpimage.c: emit it when the image emits
	"mode-changed" and "size-changed".

	* app/core/gimpprojection.c: connect to the new signal instead of
	"mode-changed" and "size-changed" to get rid of one more image
	dependency.


svn path=/trunk/; revision=27556
This commit is contained in:
Michael Natterer 2008-11-04 23:22:45 +00:00 committed by Michael Natterer
parent a40525ac39
commit 62a74f9da6
5 changed files with 49 additions and 14 deletions

View File

@ -1,3 +1,15 @@
2008-11-05 Michael Natterer <mitch@gimp.org>
* app/core/gimpprojectable.[ch]: add signal "structure-changed"
and API to emit it.
* app/core/gimpimage.c: emit it when the image emits
"mode-changed" and "size-changed".
* app/core/gimpprojection.c: connect to the new signal instead of
"mode-changed" and "size-changed" to get rid of one more image
dependency.
2008-11-04 Sven Neumann <sven@gimp.org>
* app/display/gimpdisplayshell-dnd.c

View File

@ -156,6 +156,8 @@ 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_mode_changed (GimpImage *image);
static void gimp_image_real_size_changed_detailed
(GimpImage *image,
gint previous_origin_x,
@ -491,7 +493,7 @@ gimp_image_class_init (GimpImageClass *klass)
viewable_class->get_new_preview = gimp_image_get_new_preview;
viewable_class->get_description = gimp_image_get_description;
klass->mode_changed = NULL;
klass->mode_changed = gimp_image_real_mode_changed;
klass->alpha_changed = NULL;
klass->floating_selection_changed = NULL;
klass->active_layer_changed = NULL;
@ -1067,6 +1069,8 @@ gimp_image_size_changed (GimpViewable *viewable)
}
gimp_viewable_size_changed (GIMP_VIEWABLE (gimp_image_get_mask (image)));
gimp_projectable_structure_changed (GIMP_PROJECTABLE (image));
}
static gchar *
@ -1092,6 +1096,12 @@ gimp_image_get_description (GimpViewable *viewable,
return retval;
}
static void
gimp_image_real_mode_changed (GimpImage *image)
{
gimp_projectable_structure_changed (GIMP_PROJECTABLE (image));
}
static void
gimp_image_real_size_changed_detailed (GimpImage *image,
gint previous_origin_x,

View File

@ -34,6 +34,7 @@ enum
{
UPDATE,
FLUSH,
STRUCTURE_CHANGED,
LAST_SIGNAL
};
@ -102,6 +103,15 @@ gimp_projectable_iface_base_init (GimpProjectableInterface *iface)
G_TYPE_NONE, 1,
G_TYPE_BOOLEAN);
projectable_signals[STRUCTURE_CHANGED] =
g_signal_new ("structure-changed",
G_TYPE_FROM_CLASS (iface),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpProjectableInterface, structure_changed),
NULL, NULL,
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
initialized = TRUE;
}
}
@ -132,6 +142,14 @@ gimp_projectable_flush (GimpProjectable *projectable,
preview_invalidated);
}
void
gimp_projectable_structure_changed (GimpProjectable *projectable)
{
g_return_if_fail (GIMP_IS_PROJECTABLE (projectable));
g_signal_emit (projectable, projectable_signals[STRUCTURE_CHANGED], 0);
}
GimpImage *
gimp_projectable_get_image (GimpProjectable *projectable)
{

View File

@ -43,6 +43,7 @@ struct _GimpProjectableInterface
gint height);
void (* flush) (GimpProjectable *projectable,
gboolean invalidate_preview);
void (* structure_changed) (GimpProjectable *projectable);
/* virtual functions */
GimpImage * (* get_image) (GimpProjectable *projectable);
@ -60,6 +61,7 @@ void gimp_projectable_update (GimpProjectable *projectable,
gint height);
void gimp_projectable_flush (GimpProjectable *projectable,
gboolean preview_invalidated);
void gimp_projectable_structure_changed (GimpProjectable *projectable);
GimpImage * gimp_projectable_get_image (GimpProjectable *projectable);
GeglNode * gimp_projectable_get_graph (GimpProjectable *projectable);

View File

@ -110,7 +110,7 @@ static void gimp_projection_projectable_update (GimpProjectable *proje
static void gimp_projection_projectable_flush (GimpProjectable *projectable,
gboolean invalidate_preview,
GimpProjection *proj);
static void gimp_projection_image_changed (GimpImage *image,
static void gimp_projection_projectable_changed (GimpProjectable *projectable,
GimpProjection *proj);
@ -345,7 +345,6 @@ GimpProjection *
gimp_projection_new (GimpProjectable *projectable)
{
GimpProjection *proj;
GimpImage *image;
g_return_val_if_fail (GIMP_IS_PROJECTABLE (projectable), NULL);
@ -359,14 +358,8 @@ gimp_projection_new (GimpProjectable *projectable)
g_signal_connect_object (projectable, "flush",
G_CALLBACK (gimp_projection_projectable_flush),
proj, 0);
image = gimp_projectable_get_image (projectable);
g_signal_connect_object (image, "size-changed",
G_CALLBACK (gimp_projection_image_changed),
proj, 0);
g_signal_connect_object (image, "mode-changed",
G_CALLBACK (gimp_projection_image_changed),
g_signal_connect_object (projectable, "structure-changed",
G_CALLBACK (gimp_projection_projectable_changed),
proj, 0);
return proj;
@ -789,8 +782,8 @@ gimp_projection_projectable_flush (GimpProjectable *projectable,
}
static void
gimp_projection_image_changed (GimpImage *image,
GimpProjection *proj)
gimp_projection_projectable_changed (GimpProjectable *projectable,
GimpProjection *proj)
{
gint width, height;
@ -800,7 +793,7 @@ gimp_projection_image_changed (GimpImage *image,
proj->pyramid = NULL;
}
gimp_viewable_get_size (GIMP_VIEWABLE (image), &width, &height);
gimp_viewable_get_size (GIMP_VIEWABLE (projectable), &width, &height);
gimp_projection_add_update_area (proj, 0, 0, width, height);
}