derive from GObject, we don't need any GimpObject functionality here.

2006-06-07  Sven Neumann  <sven@gimp.org>

	* app/core/gimpguide.[ch]: derive from GObject, we don't need any
	GimpObject functionality here.  Declare "orientation" and "id"
	properties CONSTRUCT_ONLY, added a gimp_guide_new() function and
	emit notify on position changes.

	* app/core/gimpimage-guides.c: use gimp_guide_new() to instantiate
	guides.

	* app/core/gimpimage.c (gimp_image_get_memsize): formatting.
This commit is contained in:
Sven Neumann 2006-06-07 07:45:16 +00:00 committed by Sven Neumann
parent 1cb89bf43f
commit 04e1fe94f1
5 changed files with 47 additions and 25 deletions

View File

@ -1,3 +1,15 @@
2006-06-07 Sven Neumann <sven@gimp.org>
* app/core/gimpguide.[ch]: derive from GObject, we don't need any
GimpObject functionality here. Declare "orientation" and "id"
properties CONSTRUCT_ONLY, added a gimp_guide_new() function and
emit notify on position changes.
* app/core/gimpimage-guides.c: use gimp_guide_new() to instantiate
guides.
* app/core/gimpimage.c (gimp_image_get_memsize): formatting.
2006-06-07 Michael Natterer <mitch@gimp.org>
* app/actions/context-commands.c: cosmetic cleanup.

View File

@ -55,7 +55,7 @@ static void gimp_guide_set_property (GObject *object,
GParamSpec *pspec);
G_DEFINE_TYPE (GimpGuide, gimp_guide, GIMP_TYPE_OBJECT)
G_DEFINE_TYPE (GimpGuide, gimp_guide, G_TYPE_OBJECT)
static void
@ -76,13 +76,15 @@ gimp_guide_class_init (GimpGuideClass *klass)
"orientation",
N_("Orientation of the guide."),
GIMP_TYPE_ORIENTATION_TYPE,
GIMP_ORIENTATION_VERTICAL,
GIMP_ORIENTATION_UNKNOWN,
G_PARAM_CONSTRUCT_ONLY |
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_ID,
"guide-id",
"id",
N_("Identifying number for the guide."),
0,
G_MAXINT, 0,
G_PARAM_CONSTRUCT_ONLY |
GIMP_PARAM_STATIC_STRINGS);
}
@ -141,10 +143,20 @@ gimp_guide_set_property (GObject *object,
}
}
GimpGuide *
gimp_guide_new (GimpOrientationType orientation,
guint32 guide_ID)
{
return g_object_new (GIMP_TYPE_GUIDE,
"orientation", orientation,
"id", guide_ID,
NULL);
}
gint
gimp_guide_get_position (GimpGuide *guide)
{
g_return_val_if_fail (GIMP_IS_GUIDE (guide), 0);
g_return_val_if_fail (GIMP_IS_GUIDE (guide), -1);
return guide->position;
}
@ -156,12 +168,14 @@ gimp_guide_set_position (GimpGuide *guide,
g_return_if_fail (GIMP_IS_GUIDE (guide));
guide->position = position;
g_object_notify (G_OBJECT (guide), "position");
}
GimpOrientationType
gimp_guide_get_orientation (GimpGuide *guide)
{
g_return_val_if_fail (GIMP_IS_GUIDE (guide), 0);
g_return_val_if_fail (GIMP_IS_GUIDE (guide), GIMP_ORIENTATION_UNKNOWN);
return guide->orientation;
}

View File

@ -38,7 +38,7 @@ typedef struct _GimpGuideClass GimpGuideClass;
struct _GimpGuide
{
GimpObject parent_instance;
GObject parent_instance;
gint position;
GimpOrientationType orientation;
@ -48,15 +48,18 @@ struct _GimpGuide
struct _GimpGuideClass
{
GimpObjectClass parent_class;
GObjectClass parent_class;
};
GType gimp_guide_get_type (void) G_GNUC_CONST;
gint gimp_guide_get_position (GimpGuide *guide);
void gimp_guide_set_position (GimpGuide *guide,
gint position);
GimpOrientationType gimp_guide_get_orientation (GimpGuide *guide);
GimpGuide * gimp_guide_new (GimpOrientationType orientation,
guint32 guide_ID);
gint gimp_guide_get_position (GimpGuide *guide);
void gimp_guide_set_position (GimpGuide *guide,
gint position);
GimpOrientationType gimp_guide_get_orientation (GimpGuide *guide);
#endif /* __GIMP_GUIDE_H__ */

View File

@ -43,15 +43,11 @@ gimp_image_add_hguide (GimpImage *image,
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (position >= 0 && position <= image->height, NULL);
guide = g_object_new (GIMP_TYPE_GUIDE, NULL);
guide->position = -1;
guide->orientation = GIMP_ORIENTATION_HORIZONTAL;
guide->guide_ID = image->gimp->next_guide_ID++;
guide = gimp_guide_new (GIMP_ORIENTATION_HORIZONTAL,
image->gimp->next_guide_ID++);
if (push_undo)
gimp_image_undo_push_image_guide (image, _("Add Horizontal Guide"),
guide);
gimp_image_undo_push_image_guide (image, _("Add Horizontal Guide"), guide);
gimp_image_add_guide (image, guide, position);
g_object_unref (G_OBJECT (guide));
@ -69,15 +65,11 @@ gimp_image_add_vguide (GimpImage *image,
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (position >= 0 && position <= image->width, NULL);
guide = g_object_new (GIMP_TYPE_GUIDE, NULL);
guide->position = -1;
guide->orientation = GIMP_ORIENTATION_VERTICAL;
guide->guide_ID = image->gimp->next_guide_ID++;
guide = gimp_guide_new (GIMP_ORIENTATION_VERTICAL,
image->gimp->next_guide_ID++);
if (push_undo)
gimp_image_undo_push_image_guide (image, _("Add Vertical Guide"),
guide);
gimp_image_undo_push_image_guide (image, _("Add Vertical Guide"), guide);
gimp_image_add_guide (image, guide, position);
g_object_unref (G_OBJECT (guide));

View File

@ -944,6 +944,7 @@ gimp_image_get_memsize (GimpObject *object,
gui_size);
memsize += gimp_g_list_get_memsize (image->guides, sizeof (GimpGuide));
if (image->grid)
memsize += gimp_object_get_memsize (GIMP_OBJECT (image->grid), gui_size);