Move "grid", "guides" and "sample_points" to GimpImagePrivate
This commit is contained in:
@ -23,6 +23,7 @@
|
||||
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-guides.h"
|
||||
#include "gimpimage-private.h"
|
||||
#include "gimpguide.h"
|
||||
#include "gimpguideundo.h"
|
||||
|
||||
@ -165,7 +166,9 @@ gimp_guide_undo_pop (GimpUndo *undo,
|
||||
|
||||
if (position == -1)
|
||||
{
|
||||
undo->image->guides = g_list_prepend (undo->image->guides,
|
||||
GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (undo->image);
|
||||
|
||||
private->guides = g_list_prepend (private->guides,
|
||||
guide_undo->guide);
|
||||
gimp_guide_set_position (guide_undo->guide, guide_undo->position);
|
||||
g_object_ref (guide_undo->guide);
|
||||
|
@ -416,8 +416,8 @@ static void
|
||||
gimp_image_duplicate_grid (GimpImage *image,
|
||||
GimpImage *new_image)
|
||||
{
|
||||
if (image->grid)
|
||||
gimp_image_set_grid (new_image, image->grid, FALSE);
|
||||
if (gimp_image_get_grid (image))
|
||||
gimp_image_set_grid (new_image, gimp_image_get_grid (image), FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "gimpgrid.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-grid.h"
|
||||
#include "gimpimage-private.h"
|
||||
#include "gimpimage-undo-push.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
@ -39,7 +40,7 @@ gimp_image_get_grid (GimpImage *image)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
|
||||
return image->grid;
|
||||
return GIMP_IMAGE_GET_PRIVATE (image)->grid;
|
||||
}
|
||||
|
||||
void
|
||||
@ -47,14 +48,18 @@ gimp_image_set_grid (GimpImage *image,
|
||||
GimpGrid *grid,
|
||||
gboolean push_undo)
|
||||
{
|
||||
GimpImagePrivate *private;
|
||||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
g_return_if_fail (GIMP_IS_GRID (grid));
|
||||
|
||||
if (gimp_config_is_equal_to (GIMP_CONFIG (image->grid), GIMP_CONFIG (grid)))
|
||||
private = GIMP_IMAGE_GET_PRIVATE (image);
|
||||
|
||||
if (gimp_config_is_equal_to (GIMP_CONFIG (private->grid), GIMP_CONFIG (grid)))
|
||||
return;
|
||||
|
||||
if (push_undo)
|
||||
gimp_image_undo_push_image_grid (image, _("Grid"), image->grid);
|
||||
gimp_image_undo_push_image_grid (image, _("Grid"), private->grid);
|
||||
|
||||
gimp_config_sync (G_OBJECT (grid), G_OBJECT (image->grid), 0);
|
||||
gimp_config_sync (G_OBJECT (grid), G_OBJECT (private->grid), 0);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "gimpimage.h"
|
||||
#include "gimpguide.h"
|
||||
#include "gimpimage-guides.h"
|
||||
#include "gimpimage-private.h"
|
||||
#include "gimpimage-undo-push.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
@ -83,16 +84,20 @@ gimp_image_add_guide (GimpImage *image,
|
||||
GimpGuide *guide,
|
||||
gint position)
|
||||
{
|
||||
GimpImagePrivate *private;
|
||||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
g_return_if_fail (GIMP_IS_GUIDE (guide));
|
||||
g_return_if_fail (position >= 0);
|
||||
|
||||
private = GIMP_IMAGE_GET_PRIVATE (image);
|
||||
|
||||
if (gimp_guide_get_orientation (guide) == GIMP_ORIENTATION_HORIZONTAL)
|
||||
g_return_if_fail (position <= gimp_image_get_height (image));
|
||||
else
|
||||
g_return_if_fail (position <= gimp_image_get_width (image));
|
||||
|
||||
image->guides = g_list_prepend (image->guides, guide);
|
||||
private->guides = g_list_prepend (private->guides, guide);
|
||||
|
||||
gimp_guide_set_position (guide, position);
|
||||
g_object_ref (G_OBJECT (guide));
|
||||
@ -105,15 +110,19 @@ gimp_image_remove_guide (GimpImage *image,
|
||||
GimpGuide *guide,
|
||||
gboolean push_undo)
|
||||
{
|
||||
GimpImagePrivate *private;
|
||||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
g_return_if_fail (GIMP_IS_GUIDE (guide));
|
||||
|
||||
private = GIMP_IMAGE_GET_PRIVATE (image);
|
||||
|
||||
gimp_image_update_guide (image, guide);
|
||||
|
||||
if (push_undo)
|
||||
gimp_image_undo_push_guide (image, _("Remove Guide"), guide);
|
||||
|
||||
image->guides = g_list_remove (image->guides, guide);
|
||||
private->guides = g_list_remove (private->guides, guide);
|
||||
gimp_guide_removed (guide);
|
||||
|
||||
gimp_guide_set_position (guide, -1);
|
||||
@ -148,7 +157,7 @@ gimp_image_get_guides (GimpImage *image)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
|
||||
return image->guides;
|
||||
return GIMP_IMAGE_GET_PRIVATE (image)->guides;
|
||||
}
|
||||
|
||||
GimpGuide *
|
||||
@ -159,7 +168,9 @@ gimp_image_get_guide (GimpImage *image,
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
|
||||
for (guides = image->guides; guides; guides = g_list_next (guides))
|
||||
for (guides = GIMP_IMAGE_GET_PRIVATE (image)->guides;
|
||||
guides;
|
||||
guides = g_list_next (guides))
|
||||
{
|
||||
GimpGuide *guide = guides->data;
|
||||
|
||||
@ -186,7 +197,9 @@ gimp_image_get_next_guide (GimpImage *image,
|
||||
else
|
||||
*guide_found = FALSE;
|
||||
|
||||
for (guides = image->guides; guides; guides = g_list_next (guides))
|
||||
for (guides = GIMP_IMAGE_GET_PRIVATE (image)->guides;
|
||||
guides;
|
||||
guides = g_list_next (guides))
|
||||
{
|
||||
GimpGuide *guide = guides->data;
|
||||
|
||||
@ -211,20 +224,19 @@ gimp_image_find_guide (GimpImage *image,
|
||||
gdouble epsilon_y)
|
||||
{
|
||||
GList *list;
|
||||
GimpGuide *guide;
|
||||
GimpGuide *ret = NULL;
|
||||
gdouble dist;
|
||||
gdouble mindist = G_MAXDOUBLE;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
g_return_val_if_fail (epsilon_x > 0 && epsilon_y > 0, NULL);
|
||||
|
||||
for (list = image->guides; list; list = g_list_next (list))
|
||||
for (list = GIMP_IMAGE_GET_PRIVATE (image)->guides;
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
gint position;
|
||||
|
||||
guide = list->data;
|
||||
position = gimp_guide_get_position (guide);
|
||||
GimpGuide *guide = list->data;
|
||||
gint position = gimp_guide_get_position (guide);
|
||||
gdouble dist;
|
||||
|
||||
if (position < 0)
|
||||
continue;
|
||||
|
@ -52,6 +52,10 @@ struct _GimpImagePrivate
|
||||
|
||||
GimpProjection *projection; /* projection layers & channels */
|
||||
GeglNode *graph; /* GEGL projection graph */
|
||||
|
||||
GList *guides; /* guides */
|
||||
GimpGrid *grid; /* grid */
|
||||
GList *sample_points; /* color sample points */
|
||||
};
|
||||
|
||||
#define GIMP_IMAGE_GET_PRIVATE(image) \
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-private.h"
|
||||
#include "gimpimage-sample-points.h"
|
||||
#include "gimpimage-undo-push.h"
|
||||
#include "gimpsamplepoint.h"
|
||||
@ -64,6 +65,8 @@ gimp_image_add_sample_point (GimpImage *image,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
GimpImagePrivate *private;
|
||||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
g_return_if_fail (sample_point != NULL);
|
||||
g_return_if_fail (x >= 0);
|
||||
@ -71,7 +74,9 @@ gimp_image_add_sample_point (GimpImage *image,
|
||||
g_return_if_fail (x < gimp_image_get_width (image));
|
||||
g_return_if_fail (y < gimp_image_get_height (image));
|
||||
|
||||
image->sample_points = g_list_append (image->sample_points, sample_point);
|
||||
private = GIMP_IMAGE_GET_PRIVATE (image);
|
||||
|
||||
private->sample_points = g_list_append (private->sample_points, sample_point);
|
||||
|
||||
sample_point->x = x;
|
||||
sample_point->y = y;
|
||||
@ -86,22 +91,25 @@ gimp_image_remove_sample_point (GimpImage *image,
|
||||
GimpSamplePoint *sample_point,
|
||||
gboolean push_undo)
|
||||
{
|
||||
GimpImagePrivate *private;
|
||||
GList *list;
|
||||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
g_return_if_fail (sample_point != NULL);
|
||||
|
||||
private = GIMP_IMAGE_GET_PRIVATE (image);
|
||||
|
||||
gimp_image_update_sample_point (image, sample_point);
|
||||
|
||||
if (push_undo)
|
||||
gimp_image_undo_push_sample_point (image, _("Remove Sample Point"),
|
||||
sample_point);
|
||||
|
||||
list = g_list_find (image->sample_points, sample_point);
|
||||
list = g_list_find (private->sample_points, sample_point);
|
||||
if (list)
|
||||
list = g_list_next (list);
|
||||
|
||||
image->sample_points = g_list_remove (image->sample_points, sample_point);
|
||||
private->sample_points = g_list_remove (private->sample_points, sample_point);
|
||||
|
||||
gimp_image_sample_point_removed (image, sample_point);
|
||||
|
||||
@ -145,7 +153,7 @@ gimp_image_get_sample_points (GimpImage *image)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
|
||||
return image->sample_points;
|
||||
return GIMP_IMAGE_GET_PRIVATE (image)->sample_points;
|
||||
}
|
||||
|
||||
GimpSamplePoint *
|
||||
@ -168,7 +176,9 @@ gimp_image_find_sample_point (GimpImage *image,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (list = image->sample_points; list; list = g_list_next (list))
|
||||
for (list = GIMP_IMAGE_GET_PRIVATE (image)->sample_points;
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
GimpSamplePoint *sample_point = list->data;
|
||||
gdouble dist;
|
||||
|
@ -614,9 +614,9 @@ gimp_image_init (GimpImage *image)
|
||||
|
||||
private->projection = gimp_projection_new (GIMP_PROJECTABLE (image));
|
||||
|
||||
image->guides = NULL;
|
||||
image->grid = NULL;
|
||||
image->sample_points = NULL;
|
||||
private->guides = NULL;
|
||||
private->grid = NULL;
|
||||
private->sample_points = NULL;
|
||||
|
||||
image->layers = gimp_drawable_stack_new (GIMP_TYPE_LAYER);
|
||||
image->channels = gimp_drawable_stack_new (GIMP_TYPE_CHANNEL);
|
||||
@ -721,7 +721,7 @@ gimp_image_constructor (GType type,
|
||||
private->yresolution = config->default_image->yresolution;
|
||||
private->resolution_unit = config->default_image->resolution_unit;
|
||||
|
||||
image->grid = gimp_config_duplicate (GIMP_CONFIG (config->default_grid));
|
||||
private->grid = gimp_config_duplicate (GIMP_CONFIG (config->default_grid));
|
||||
|
||||
switch (private->base_type)
|
||||
{
|
||||
@ -926,25 +926,25 @@ gimp_image_finalize (GObject *object)
|
||||
image->parasites = NULL;
|
||||
}
|
||||
|
||||
if (image->guides)
|
||||
if (private->guides)
|
||||
{
|
||||
g_list_foreach (image->guides, (GFunc) g_object_unref, NULL);
|
||||
g_list_free (image->guides);
|
||||
image->guides = NULL;
|
||||
g_list_foreach (private->guides, (GFunc) g_object_unref, NULL);
|
||||
g_list_free (private->guides);
|
||||
private->guides = NULL;
|
||||
}
|
||||
|
||||
if (image->grid)
|
||||
if (private->grid)
|
||||
{
|
||||
g_object_unref (image->grid);
|
||||
image->grid = NULL;
|
||||
g_object_unref (private->grid);
|
||||
private->grid = NULL;
|
||||
}
|
||||
|
||||
if (image->sample_points)
|
||||
if (private->sample_points)
|
||||
{
|
||||
g_list_foreach (image->sample_points,
|
||||
g_list_foreach (private->sample_points,
|
||||
(GFunc) gimp_sample_point_unref, NULL);
|
||||
g_list_free (image->sample_points);
|
||||
image->sample_points = NULL;
|
||||
g_list_free (private->sample_points);
|
||||
private->sample_points = NULL;
|
||||
}
|
||||
|
||||
if (image->undo_stack)
|
||||
@ -1016,7 +1016,7 @@ gimp_image_get_memsize (GimpObject *object,
|
||||
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_object_get_memsize (GIMP_OBJECT (private->grid), gui_size);
|
||||
|
||||
memsize += gimp_g_list_get_memsize (gimp_image_get_sample_points (image),
|
||||
sizeof (GimpSamplePoint));
|
||||
|
@ -105,10 +105,6 @@ struct _GimpImage
|
||||
|
||||
Gimp *gimp; /* the GIMP the image belongs to*/
|
||||
|
||||
GList *guides; /* guides */
|
||||
GimpGrid *grid; /* grid */
|
||||
GList *sample_points; /* color sample points */
|
||||
|
||||
/* Layer/Channel attributes */
|
||||
GimpContainer *layers; /* the list of layers */
|
||||
GimpContainer *channels; /* the list of masks */
|
||||
|
@ -404,7 +404,7 @@ gimp_image_undo_pop (GimpUndo *undo,
|
||||
{
|
||||
GimpGrid *grid;
|
||||
|
||||
grid = gimp_config_duplicate (GIMP_CONFIG (image->grid));
|
||||
grid = gimp_config_duplicate (GIMP_CONFIG (gimp_image_get_grid (image)));
|
||||
|
||||
gimp_image_set_grid (image, image_undo->grid, FALSE);
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "core-types.h"
|
||||
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-private.h"
|
||||
#include "gimpimage-sample-points.h"
|
||||
#include "gimpsamplepoint.h"
|
||||
#include "gimpsamplepointundo.h"
|
||||
@ -165,8 +166,9 @@ gimp_sample_point_undo_pop (GimpUndo *undo,
|
||||
|
||||
if (x == -1)
|
||||
{
|
||||
undo->image->sample_points =
|
||||
g_list_append (undo->image->sample_points,
|
||||
GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (undo->image);
|
||||
|
||||
private->sample_points = g_list_append (private->sample_points,
|
||||
sample_point_undo->sample_point);
|
||||
|
||||
sample_point_undo->sample_point->x = sample_point_undo->x;
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "core/gimpgrid.h"
|
||||
#include "core/gimpguide.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-grid.h"
|
||||
#include "core/gimpimage-guides.h"
|
||||
#include "core/gimpimage-sample-points.h"
|
||||
#include "core/gimpprojection.h"
|
||||
@ -220,7 +221,7 @@ gimp_display_shell_draw_grid (GimpDisplayShell *shell,
|
||||
|
||||
#define CROSSHAIR 2
|
||||
|
||||
grid = GIMP_GRID (image->grid);
|
||||
grid = gimp_image_get_grid (image);
|
||||
if (! grid)
|
||||
return;
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontainer.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-grid.h"
|
||||
#include "core/gimpitem.h"
|
||||
#include "core/gimptreehandler.h"
|
||||
|
||||
@ -161,7 +162,7 @@ gimp_display_shell_connect (GimpDisplayShell *shell)
|
||||
g_signal_connect (image, "undo-event",
|
||||
G_CALLBACK (gimp_display_shell_undo_event_handler),
|
||||
shell);
|
||||
g_signal_connect (image->grid, "notify",
|
||||
g_signal_connect (gimp_image_get_grid (image), "notify",
|
||||
G_CALLBACK (gimp_display_shell_grid_notify_handler),
|
||||
shell);
|
||||
g_signal_connect (image, "name-changed",
|
||||
@ -383,7 +384,7 @@ gimp_display_shell_disconnect (GimpDisplayShell *shell)
|
||||
g_signal_handlers_disconnect_by_func (image,
|
||||
gimp_display_shell_name_changed_handler,
|
||||
shell);
|
||||
g_signal_handlers_disconnect_by_func (image->grid,
|
||||
g_signal_handlers_disconnect_by_func (gimp_image_get_grid (image),
|
||||
gimp_display_shell_grid_notify_handler,
|
||||
shell);
|
||||
g_signal_handlers_disconnect_by_func (image,
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "core/gimpimage-colormap.h"
|
||||
#include "core/gimpimage-grid.h"
|
||||
#include "core/gimpimage-guides.h"
|
||||
#include "core/gimpimage-private.h"
|
||||
#include "core/gimpimage-sample-points.h"
|
||||
#include "core/gimpitemstack.h"
|
||||
#include "core/gimplayer-floating-sel.h"
|
||||
@ -450,6 +451,7 @@ xcf_load_image_props (XcfInfo *info,
|
||||
|
||||
case PROP_GUIDES:
|
||||
{
|
||||
GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
|
||||
gint32 position;
|
||||
gint8 orientation;
|
||||
gint i, nguides;
|
||||
@ -485,10 +487,10 @@ xcf_load_image_props (XcfInfo *info,
|
||||
}
|
||||
|
||||
/* this is silly as the order of guides doesn't really matter,
|
||||
* but it restores the list to it's original order, which
|
||||
* but it restores the list to its original order, which
|
||||
* cannot be wrong --Mitch
|
||||
*/
|
||||
image->guides = g_list_reverse (image->guides);
|
||||
private->guides = g_list_reverse (private->guides);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -417,7 +417,7 @@ xcf_save_image_props (XcfInfo *info,
|
||||
if (unit >= _gimp_unit_get_number_of_built_in_units (image->gimp))
|
||||
xcf_check_error (xcf_save_prop (info, image, PROP_USER_UNIT, error, unit));
|
||||
|
||||
if (GIMP_IS_GRID (image->grid))
|
||||
if (gimp_image_get_grid (image))
|
||||
{
|
||||
GimpGrid *grid = gimp_image_get_grid (image);
|
||||
|
||||
|
Reference in New Issue
Block a user