Commit 11b1d24a authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

app/core/Makefile.am new files implementing new(), ref() and unref() and

2007-01-30  Michael Natterer  <mitch@gimp.org>

	* app/core/Makefile.am
	* app/core/gimpsamplepoint.[ch]: new files implementing new(),
	ref() and unref() and the new GIMP_TYPE_SAMPLE_TYPE boxed type.

	* app/core/gimpimage-sample-points.[ch]: removed ref() and unref()
	functions here.

	* app/core/gimpimage.c
	* app/core/gimpimage-crop.c
	* app/core/gimpimage-duplicate.c
	* app/core/gimpimage-flip.c
	* app/core/gimpimage-resize.c
	* app/core/gimpimage-rotate.c
	* app/core/gimpimage-scale.c
	* app/core/gimpimage-undo-push.c
	* app/display/gimpdisplayshell.c
	* app/display/gimpdisplayshell-draw.c
	* app/tools/gimpcolortool.c
	* app/widgets/gimpsamplepointeditor.c
	* app/xcf/xcf-save.c: changed accordingly.

	* app/core/gimpimage-rotate.c (gimp_image_rotate_sample_points):
	added missing call to gimp_image_undo_push_sample_point().


svn path=/trunk/; revision=21812
parent 6091e304
2007-01-30 Michael Natterer <mitch@gimp.org>
* app/core/Makefile.am
* app/core/gimpsamplepoint.[ch]: new files implementing new(),
ref() and unref() and the new GIMP_TYPE_SAMPLE_TYPE boxed type.
* app/core/gimpimage-sample-points.[ch]: removed ref() and unref()
functions here.
* app/core/gimpimage.c
* app/core/gimpimage-crop.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage-flip.c
* app/core/gimpimage-resize.c
* app/core/gimpimage-rotate.c
* app/core/gimpimage-scale.c
* app/core/gimpimage-undo-push.c
* app/display/gimpdisplayshell.c
* app/display/gimpdisplayshell-draw.c
* app/tools/gimpcolortool.c
* app/widgets/gimpsamplepointeditor.c
* app/xcf/xcf-save.c: changed accordingly.
* app/core/gimpimage-rotate.c (gimp_image_rotate_sample_points):
added missing call to gimp_image_undo_push_sample_point().
2007-01-30 Michael Natterer <mitch@gimp.org>
 
* app/core/core-enums.[ch]
......@@ -251,6 +251,8 @@ libappcore_a_sources = \
gimpprojection.h \
gimpprojection-construct.c \
gimpprojection-construct.h \
gimpsamplepoint.c \
gimpsamplepoint.h \
gimpscanconvert.c \
gimpscanconvert.h \
gimpselection.c \
......
......@@ -38,6 +38,7 @@
#include "gimplayer.h"
#include "gimplist.h"
#include "gimppickable.h"
#include "gimpsamplepoint.h"
#include "gimp-intl.h"
......
......@@ -39,6 +39,7 @@
#include "gimplayer-floating-sel.h"
#include "gimplist.h"
#include "gimpparasitelist.h"
#include "gimpsamplepoint.h"
#include "vectors/gimpvectors.h"
......
......@@ -34,6 +34,7 @@
#include "gimpitem.h"
#include "gimplist.h"
#include "gimpprogress.h"
#include "gimpsamplepoint.h"
void
......
......@@ -35,6 +35,7 @@
#include "gimplayer.h"
#include "gimplist.h"
#include "gimpprogress.h"
#include "gimpsamplepoint.h"
#include "gimp-intl.h"
......
......@@ -34,6 +34,7 @@
#include "gimpitem.h"
#include "gimplist.h"
#include "gimpprogress.h"
#include "gimpsamplepoint.h"
static void gimp_image_rotate_item_offset (GimpImage *image,
......@@ -332,6 +333,8 @@ gimp_image_rotate_sample_points (GimpImage *image,
gint old_x;
gint old_y;
gimp_image_undo_push_sample_point (image, NULL, sample_point);
old_x = sample_point->x;
old_y = sample_point->y;
......
......@@ -26,6 +26,7 @@
#include "gimpimage.h"
#include "gimpimage-sample-points.h"
#include "gimpimage-undo-push.h"
#include "gimpsamplepoint.h"
#include "gimp-intl.h"
......@@ -44,44 +45,18 @@ gimp_image_add_sample_point_at_pos (GimpImage *image,
g_return_val_if_fail (x >= 0 && x < image->width, NULL);
g_return_val_if_fail (y >= 0 && y < image->height, NULL);
sample_point = g_new0 (GimpSamplePoint, 1);
sample_point->ref_count = 1;
sample_point->x = -1;
sample_point->y = -1;
sample_point->sample_point_ID = image->gimp->next_sample_point_ID++;
sample_point = gimp_sample_point_new (image->gimp->next_sample_point_ID++);
if (push_undo)
gimp_image_undo_push_sample_point (image, _("Add Sample_Point"),
sample_point);
gimp_image_add_sample_point (image, sample_point, x, y);
gimp_image_sample_point_unref (sample_point);
return sample_point;
}
GimpSamplePoint *
gimp_image_sample_point_ref (GimpSamplePoint *sample_point)
{
g_return_val_if_fail (sample_point != NULL, NULL);
sample_point->ref_count++;
gimp_sample_point_unref (sample_point);
return sample_point;
}
void
gimp_image_sample_point_unref (GimpSamplePoint *sample_point)
{
g_return_if_fail (sample_point != NULL);
sample_point->ref_count--;
if (sample_point->ref_count < 1)
g_free (sample_point);
}
void
gimp_image_add_sample_point (GimpImage *image,
GimpSamplePoint *sample_point,
......@@ -99,7 +74,7 @@ gimp_image_add_sample_point (GimpImage *image,
sample_point->x = x;
sample_point->y = y;
gimp_image_sample_point_ref (sample_point);
gimp_sample_point_ref (sample_point);
gimp_image_sample_point_added (image, sample_point);
gimp_image_update_sample_point (image, sample_point);
......@@ -131,7 +106,7 @@ gimp_image_remove_sample_point (GimpImage *image,
sample_point->x = -1;
sample_point->y = -1;
gimp_image_sample_point_unref (sample_point);
gimp_sample_point_unref (sample_point);
while (list)
{
......
......@@ -19,24 +19,11 @@
#ifndef __GIMP_IMAGE_SAMPLE_POINTS_H__
#define __GIMP_IMAGE_SAMPLE_POINTS_H__
#define GIMP_SAMPLE_POINT_DRAW_SIZE 10
struct _GimpSamplePoint
{
gint ref_count;
gint x;
gint y;
guint32 sample_point_ID;
};
GimpSamplePoint * gimp_image_add_sample_point_at_pos (GimpImage *image,
gint x,
gint y,
gboolean push_undo);
GimpSamplePoint * gimp_image_sample_point_ref (GimpSamplePoint *sample_point);
void gimp_image_sample_point_unref (GimpSamplePoint *sample_point);
void gimp_image_add_sample_point (GimpImage *image,
GimpSamplePoint *sample_point,
gint x,
......
......@@ -35,6 +35,7 @@
#include "gimplayer.h"
#include "gimplist.h"
#include "gimpprogress.h"
#include "gimpsamplepoint.h"
#include "gimp-intl.h"
......
......@@ -47,6 +47,7 @@
#include "gimplayerpropundo.h"
#include "gimplist.h"
#include "gimpparasitelist.h"
#include "gimpsamplepoint.h"
#include "gimpselection.h"
#include "text/gimptextlayer.h"
......@@ -280,7 +281,7 @@ gimp_image_undo_push_sample_point (GimpImage *image,
{
SamplePointUndo *spu = new->data;
spu->sample_point = gimp_image_sample_point_ref (sample_point);
spu->sample_point = gimp_sample_point_ref (sample_point);
spu->x = sample_point->x;
spu->y = sample_point->y;
......@@ -315,7 +316,7 @@ undo_pop_sample_point (GimpUndo *undo,
spu->sample_point->x = spu->x;
spu->sample_point->y = spu->y;
gimp_image_sample_point_ref (spu->sample_point);
gimp_sample_point_ref (spu->sample_point);
gimp_image_sample_point_added (undo->image, spu->sample_point);
gimp_image_update_sample_point (undo->image, spu->sample_point);
......@@ -344,7 +345,7 @@ undo_free_sample_point (GimpUndo *undo,
{
SamplePointUndo *gu = undo->data;
gimp_image_sample_point_unref (gu->sample_point);
gimp_sample_point_unref (gu->sample_point);
g_free (gu);
}
......
......@@ -58,6 +58,7 @@
#include "gimpparasitelist.h"
#include "gimppickable.h"
#include "gimpprojection.h"
#include "gimpsamplepoint.h"
#include "gimpselection.h"
#include "gimptemplate.h"
#include "gimpundostack.h"
......@@ -916,7 +917,7 @@ gimp_image_finalize (GObject *object)
if (image->sample_points)
{
g_list_foreach (image->sample_points,
(GFunc) gimp_image_sample_point_unref, NULL);
(GFunc) gimp_sample_point_unref, NULL);
g_list_free (image->sample_points);
image->sample_points = NULL;
}
......
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib-object.h>
#include "core-types.h"
#include "gimpsamplepoint.h"
GType
gimp_sample_point_get_type (void)
{
static GType type = 0;
if (! type)
type = g_boxed_type_register_static ("GimpSamplePoint",
(GBoxedCopyFunc) gimp_sample_point_ref,
(GBoxedFreeFunc) gimp_sample_point_unref);
return type;
}
GimpSamplePoint *
gimp_sample_point_new (guint32 sample_point_ID)
{
GimpSamplePoint *sample_point;
sample_point = g_new0 (GimpSamplePoint, 1);
sample_point->ref_count = 1;
sample_point->sample_point_ID = sample_point_ID;
sample_point->x = -1;
sample_point->y = -1;
return sample_point;
}
GimpSamplePoint *
gimp_sample_point_ref (GimpSamplePoint *sample_point)
{
g_return_val_if_fail (sample_point != NULL, NULL);
sample_point->ref_count++;
return sample_point;
}
void
gimp_sample_point_unref (GimpSamplePoint *sample_point)
{
g_return_if_fail (sample_point != NULL);
sample_point->ref_count--;
if (sample_point->ref_count < 1)
g_free (sample_point);
}
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_SAMPLE_POINT_H__
#define __GIMP_SAMPLE_POINT_H__
#define GIMP_SAMPLE_POINT_DRAW_SIZE 10
#define GIMP_TYPE_SAMPLE_POINT (gimp_sample_point_get_type ())
struct _GimpSamplePoint
{
gint ref_count;
guint32 sample_point_ID;
gint x;
gint y;
};
GType gimp_sample_point_get_type (void) G_GNUC_CONST;
GimpSamplePoint * gimp_sample_point_new (guint32 sample_point_ID);
GimpSamplePoint * gimp_sample_point_ref (GimpSamplePoint *sample_point);
void gimp_sample_point_unref (GimpSamplePoint *sample_point);
#endif /* __GIMP_SAMPLE_POINT_H__ */
......@@ -28,9 +28,8 @@
#include "core/gimpgrid.h"
#include "core/gimpguide.h"
#include "core/gimpimage.h"
#include "core/gimpimage-guides.h"
#include "core/gimpimage-sample-points.h"
#include "core/gimplist.h"
#include "core/gimpsamplepoint.h"
#include "vectors/gimpstroke.h"
#include "vectors/gimpvectors.h"
......
......@@ -38,10 +38,9 @@
#include "core/gimpcontext.h"
#include "core/gimpguide.h"
#include "core/gimpimage.h"
#include "core/gimpimage-guides.h"
#include "core/gimpimage-sample-points.h"
#include "core/gimpimage-snap.h"
#include "core/gimpmarshal.h"
#include "core/gimpsamplepoint.h"
#include "widgets/gimprender.h"
#include "widgets/gimphelp-ids.h"
......
......@@ -34,6 +34,7 @@
#include "core/gimpimage-sample-points.h"
#include "core/gimpitem.h"
#include "core/gimpmarshal.h"
#include "core/gimpsamplepoint.h"
#include "widgets/gimpcolormapeditor.h"
#include "widgets/gimpdialogfactory.h"
......
......@@ -30,7 +30,7 @@
#include "core/gimp.h"
#include "core/gimpimage.h"
#include "core/gimpimage-pick-color.h"
#include "core/gimpimage-sample-points.h"
#include "core/gimpsamplepoint.h"
#include "gimpcolorframe.h"
#include "gimpmenufactory.h"
......
......@@ -47,6 +47,7 @@
#include "core/gimplist.h"
#include "core/gimpparasitelist.h"
#include "core/gimpprogress.h"
#include "core/gimpsamplepoint.h"
#include "core/gimpunit.h"
#include "text/gimptextlayer.h"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment