app/core/gimpimage-guides.[ch] add accessors for the lists of guides and

2007-12-25  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpimage-guides.[ch]
	* app/core/gimpimage-sample-points.[ch]: add accessors for the lists
	of guides and sample points.

	* 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-snap.c
	* app/core/gimpimage.c
	* app/display/gimpdisplayshell-appearance.c
	* app/display/gimpdisplayshell-draw.c
	* app/display/gimpdisplayshell.c
	* app/widgets/gimpsamplepointeditor.c
	* app/xcf/xcf-save.c: use the new accessors.


svn path=/trunk/; revision=24434
This commit is contained in:
Michael Natterer
2007-12-25 17:09:04 +00:00
committed by Michael Natterer
parent 0d31cf5521
commit 6074f7e248
18 changed files with 99 additions and 44 deletions

View File

@ -1,3 +1,23 @@
2007-12-25 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage-guides.[ch]
* app/core/gimpimage-sample-points.[ch]: add accessors for the lists
of guides and sample points.
* 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-snap.c
* app/core/gimpimage.c
* app/display/gimpdisplayshell-appearance.c
* app/display/gimpdisplayshell-draw.c
* app/display/gimpdisplayshell.c
* app/widgets/gimpsamplepointeditor.c
* app/xcf/xcf-save.c: use the new accessors.
2007-12-25 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage.h (struct GimpImage):: renamed "cmap" to

View File

@ -199,7 +199,7 @@ gimp_image_crop (GimpImage *image,
}
/* Reposition or remove all guides */
list = image->guides;
list = gimp_image_get_guides (image);
while (list)
{
GimpGuide *guide = list->data;
@ -235,7 +235,7 @@ gimp_image_crop (GimpImage *image,
}
/* Reposition or remove sample points */
list = image->sample_points;
list = gimp_image_get_sample_points (image);
while (list)
{
GimpSamplePoint *sample_point = list->data;

View File

@ -239,7 +239,7 @@ gimp_image_duplicate (GimpImage *image)
}
/* Copy any guides */
for (list = image->guides; list; list = g_list_next (list))
for (list = gimp_image_get_guides (image); list; list = g_list_next (list))
{
GimpGuide *guide = list->data;
gint position = gimp_guide_get_position (guide);
@ -260,7 +260,7 @@ gimp_image_duplicate (GimpImage *image)
}
/* Copy any sample points */
for (list = image->sample_points; list; list = g_list_next (list))
for (list = gimp_image_get_sample_points (image); list; list = g_list_next (list))
{
GimpSamplePoint *sample_point = list->data;

View File

@ -123,7 +123,7 @@ gimp_image_flip (GimpImage *image,
}
/* Flip all Guides */
for (list = image->guides; list; list = g_list_next (list))
for (list = gimp_image_get_guides (image); list; list = g_list_next (list))
{
GimpGuide *guide = list->data;
gint position = gimp_guide_get_position (guide);
@ -150,7 +150,7 @@ gimp_image_flip (GimpImage *image,
}
/* Flip all sample points */
for (list = image->sample_points; list; list = g_list_next (list))
for (list = gimp_image_get_sample_points (image); list; list = g_list_next (list))
{
GimpSamplePoint *sample_point = list->data;

View File

@ -144,6 +144,14 @@ gimp_image_move_guide (GimpImage *image,
gimp_image_update_guide (image, guide);
}
GList *
gimp_image_get_guides (GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
return image->guides;
}
GimpGuide *
gimp_image_get_guide (GimpImage *image,
guint32 id)

View File

@ -38,6 +38,7 @@ void gimp_image_move_guide (GimpImage *image,
gint position,
gboolean push_undo);
GList * gimp_image_get_guides (GimpImage *image);
GimpGuide * gimp_image_get_guide (GimpImage *image,
guint32 id);
GimpGuide * gimp_image_get_next_guide (GimpImage *image,

View File

@ -165,7 +165,7 @@ gimp_image_resize_with_layers (GimpImage *image,
g_list_free (resize_layers);
/* Reposition or remove all guides */
for (list = image->guides; list; list = g_list_next (list))
for (list = gimp_image_get_guides (image); list; list = g_list_next (list))
{
GimpGuide *guide = list->data;
gboolean remove_guide = FALSE;
@ -196,7 +196,7 @@ gimp_image_resize_with_layers (GimpImage *image,
}
/* Reposition or remove sample points */
for (list = image->sample_points; list; list = g_list_next (list))
for (list = gimp_image_get_sample_points (image); list; list = g_list_next (list))
{
GimpSamplePoint *sample_point = list->data;
gboolean remove_sample_point = FALSE;

View File

@ -255,7 +255,7 @@ gimp_image_rotate_guides (GimpImage *image,
GList *list;
/* Rotate all Guides */
for (list = image->guides; list; list = g_list_next (list))
for (list = gimp_image_get_guides (image); list; list = g_list_next (list))
{
GimpGuide *guide = list->data;
GimpOrientationType orientation = gimp_guide_get_orientation (guide);
@ -334,7 +334,7 @@ gimp_image_rotate_sample_points (GimpImage *image,
GList *list;
/* Rotate all sample points */
for (list = image->sample_points; list; list = g_list_next (list))
for (list = gimp_image_get_sample_points (image); list; list = g_list_next (list))
{
GimpSamplePoint *sample_point = list->data;
gint old_x;

View File

@ -141,6 +141,14 @@ gimp_image_move_sample_point (GimpImage *image,
gimp_image_update_sample_point (image, sample_point);
}
GList *
gimp_image_get_sample_points (GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
return image->sample_points;
}
GimpSamplePoint *
gimp_image_find_sample_point (GimpImage *image,
gdouble x,

View File

@ -37,6 +37,7 @@ void gimp_image_move_sample_point (GimpImage *image,
gint y,
gboolean push_undo);
GList * gimp_image_get_sample_points (GimpImage *image);
GimpSamplePoint * gimp_image_find_sample_point (GimpImage *image,
gdouble x,
gdouble y,

View File

@ -169,7 +169,7 @@ gimp_image_scale (GimpImage *image,
g_list_free (remove);
/* Scale all Guides */
for (list = image->guides; list; list = g_list_next (list))
for (list = gimp_image_get_guides (image); list; list = g_list_next (list))
{
GimpGuide *guide = list->data;
gint position = gimp_guide_get_position (guide);
@ -192,7 +192,7 @@ gimp_image_scale (GimpImage *image,
}
/* Scale all sample points */
for (list = image->sample_points; list; list = g_list_next (list))
for (list = gimp_image_get_sample_points (image); list; list = g_list_next (list))
{
GimpSamplePoint *sample_point = list->data;

View File

@ -58,8 +58,8 @@ gimp_image_snap_x (GimpImage *image,
*tx = x;
if (! image->guides) snap_to_guides = FALSE;
if (! image->grid) snap_to_grid = FALSE;
if (! gimp_image_get_guides (image)) snap_to_guides = FALSE;
if (! gimp_image_get_grid (image)) snap_to_grid = FALSE;
if (! (snap_to_guides || snap_to_grid || snap_to_canvas))
return FALSE;
@ -71,7 +71,7 @@ gimp_image_snap_x (GimpImage *image,
{
GList *list;
for (list = image->guides; list; list = g_list_next (list))
for (list = gimp_image_get_guides (image); list; list = g_list_next (list))
{
GimpGuide *guide = list->data;
gint position = gimp_guide_get_position (guide);
@ -166,8 +166,8 @@ gimp_image_snap_y (GimpImage *image,
*ty = y;
if (! image->guides) snap_to_guides = FALSE;
if (! image->grid) snap_to_grid = FALSE;
if (! gimp_image_get_guides (image)) snap_to_guides = FALSE;
if (! gimp_image_get_grid (image)) snap_to_grid = FALSE;
if (! (snap_to_guides || snap_to_grid || snap_to_canvas))
return FALSE;
@ -179,7 +179,7 @@ gimp_image_snap_y (GimpImage *image,
{
GList *list;
for (list = image->guides; list; list = g_list_next (list))
for (list = gimp_image_get_guides (image); list; list = g_list_next (list))
{
GimpGuide *guide = list->data;
gint position = gimp_guide_get_position (guide);
@ -281,7 +281,7 @@ gimp_image_snap_point (GimpImage *image,
*tx = x;
*ty = y;
if (! image->guides) snap_to_guides = FALSE;
if (! gimp_image_get_guides (image)) snap_to_guides = FALSE;
if (! gimp_image_get_grid (image)) snap_to_grid = FALSE;
if (! gimp_image_get_active_vectors (image)) snap_to_vectors = FALSE;
@ -298,7 +298,7 @@ gimp_image_snap_point (GimpImage *image,
{
GList *list;
for (list = image->guides; list; list = g_list_next (list))
for (list = gimp_image_get_guides (image); list; list = g_list_next (list))
{
GimpGuide *guide = list->data;
gint position = gimp_guide_get_position (guide);
@ -494,7 +494,7 @@ gimp_image_snap_rectangle (GimpImage *image,
*tx1 = x1;
*ty1 = y1;
if (! image->guides) snap_to_guides = FALSE;
if (! gimp_image_get_guides (image)) snap_to_guides = FALSE;
if (! gimp_image_get_grid (image)) snap_to_grid = FALSE;
if (! gimp_image_get_active_vectors (image)) snap_to_vectors = FALSE;

View File

@ -991,11 +991,12 @@ gimp_image_get_memsize (GimpObject *object,
memsize += gimp_object_get_memsize (GIMP_OBJECT (image->projection),
gui_size);
memsize += gimp_g_list_get_memsize (image->guides, sizeof (GimpGuide));
memsize += gimp_g_list_get_memsize (gimp_image_get_guides (image),
sizeof (GimpGuide));
memsize += gimp_object_get_memsize (GIMP_OBJECT (image->grid), gui_size);
memsize += gimp_g_list_get_memsize (image->sample_points,
memsize += gimp_g_list_get_memsize (gimp_image_get_sample_points (image),
sizeof (GimpSamplePoint));
memsize += gimp_object_get_memsize (GIMP_OBJECT (image->layers),

View File

@ -28,6 +28,8 @@
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-guides.h"
#include "core/gimpimage-sample-points.h"
#include "widgets/gimpactiongroup.h"
#include "widgets/gimprender.h"
@ -336,7 +338,7 @@ gimp_display_shell_set_show_guides (GimpDisplayShell *shell,
g_object_set (options, "show-guides", show, NULL);
if (shell->display->image->guides)
if (gimp_image_get_guides (shell->display->image))
gimp_display_shell_expose_full (shell);
SET_ACTIVE (shell->menubar_manager, "view-show-guides", show);
@ -394,7 +396,7 @@ gimp_display_shell_set_show_sample_points (GimpDisplayShell *shell,
g_object_set (options, "show-sample-points", show, NULL);
if (shell->display->image->sample_points)
if (gimp_image_get_sample_points (shell->display->image))
gimp_display_shell_expose_full (shell);
SET_ACTIVE (shell->menubar_manager, "view-show-sample-points", show);

View File

@ -31,6 +31,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/gimpprojection.h"
#include "core/gimpsamplepoint.h"
@ -122,7 +124,7 @@ gimp_display_shell_draw_guides (GimpDisplayShell *shell)
{
GList *list;
for (list = shell->display->image->guides;
for (list = gimp_image_get_guides (shell->display->image);
list;
list = g_list_next (list))
{
@ -408,7 +410,7 @@ gimp_display_shell_draw_sample_point (GimpDisplayShell *shell,
gimp_canvas_draw_text (GIMP_CANVAS (shell->canvas), style,
x + 2, y + 2,
"%d",
g_list_index (shell->display->image->sample_points,
g_list_index (gimp_image_get_sample_points (shell->display->image),
sample_point) + 1);
}
@ -421,7 +423,7 @@ gimp_display_shell_draw_sample_points (GimpDisplayShell *shell)
{
GList *list;
for (list = shell->display->image->sample_points;
for (list = gimp_image_get_sample_points (shell->display->image);
list;
list = g_list_next (list))
{

View File

@ -39,6 +39,8 @@
#include "core/gimpcontext.h"
#include "core/gimpguide.h"
#include "core/gimpimage.h"
#include "core/gimpimage-grid.h"
#include "core/gimpimage-guides.h"
#include "core/gimpimage-snap.h"
#include "core/gimpprojection.h"
#include "core/gimpmarshal.h"
@ -1241,13 +1243,13 @@ gimp_display_shell_snap_coords (GimpDisplayShell *shell,
*snapped_coords = *coords;
if (gimp_display_shell_get_snap_to_guides (shell) &&
shell->display->image->guides)
gimp_image_get_guides (shell->display->image))
{
snap_to_guides = TRUE;
}
if (gimp_display_shell_get_snap_to_grid (shell) &&
shell->display->image->grid)
gimp_image_get_grid (shell->display->image))
{
snap_to_grid = TRUE;
}

View File

@ -30,6 +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"
@ -364,7 +365,7 @@ gimp_sample_point_editor_point_update (GimpImage *image,
GimpSamplePoint *sample_point,
GimpSamplePointEditor *editor)
{
gint i = g_list_index (image->sample_points, sample_point);
gint i = g_list_index (gimp_image_get_sample_points (image), sample_point);
if (i < 4)
gimp_sample_point_editor_dirty (editor, i);
@ -380,13 +381,16 @@ gimp_sample_point_editor_proj_update (GimpImage *image,
GimpSamplePointEditor *editor)
{
GimpImageEditor *image_editor = GIMP_IMAGE_EDITOR (editor);
GList *sample_points;
gint n_points = 0;
GList *list;
gint i;
n_points = MIN (4, g_list_length (image_editor->image->sample_points));
sample_points = gimp_image_get_sample_points (image_editor->image);
for (i = 0, list = image_editor->image->sample_points;
n_points = MIN (4, g_list_length (sample_points));
for (i = 0, list = sample_points;
i < n_points;
i++, list = g_list_next (list))
{
@ -404,11 +408,14 @@ static void
gimp_sample_point_editor_points_changed (GimpSamplePointEditor *editor)
{
GimpImageEditor *image_editor = GIMP_IMAGE_EDITOR (editor);
GList *sample_points;
gint n_points = 0;
gint i;
sample_points = gimp_image_get_sample_points (image_editor->image);
if (image_editor->image)
n_points = MIN (4, g_list_length (image_editor->image->sample_points));
n_points = MIN (4, g_list_length (sample_points));
for (i = 0; i < n_points; i++)
{
@ -446,6 +453,7 @@ static gboolean
gimp_sample_point_editor_update (GimpSamplePointEditor *editor)
{
GimpImageEditor *image_editor = GIMP_IMAGE_EDITOR (editor);
GList *sample_points;
gint n_points = 0;
GList *list;
gint i;
@ -455,9 +463,11 @@ gimp_sample_point_editor_update (GimpSamplePointEditor *editor)
if (! image_editor->image)
return FALSE;
n_points = MIN (4, g_list_length (image_editor->image->sample_points));
sample_points = gimp_image_get_sample_points (image_editor->image);
for (i = 0, list = image_editor->image->sample_points;
n_points = MIN (4, g_list_length (sample_points));
for (i = 0, list = sample_points;
i < n_points;
i++, list = g_list_next (list))
{

View File

@ -400,16 +400,16 @@ xcf_save_image_props (XcfInfo *info,
gimp_image_get_colormap (image)));
if (info->compression != COMPRESS_NONE)
xcf_check_error (xcf_save_prop (info, image, PROP_COMPRESSION,
error, info->compression));
xcf_check_error (xcf_save_prop (info, image, PROP_COMPRESSION, error,
info->compression));
if (image->guides)
xcf_check_error (xcf_save_prop (info, image, PROP_GUIDES,
error, image->guides));
if (gimp_image_get_guides (image))
xcf_check_error (xcf_save_prop (info, image, PROP_GUIDES, error,
gimp_image_get_guides (image)));
if (image->sample_points)
xcf_check_error (xcf_save_prop (info, image, PROP_SAMPLE_POINTS,
error, image->sample_points));
if (gimp_image_get_sample_points (image))
xcf_check_error (xcf_save_prop (info, image, PROP_SAMPLE_POINTS, error,
gimp_image_get_sample_points (image)));
xcf_check_error (xcf_save_prop (info, image, PROP_RESOLUTION, error,
image->xresolution, image->yresolution));