mirror of https://github.com/GNOME/gimp.git
app: port GimpData subclasses from ::duplicate() to ::copy()
Finish up commit 17583ff04a
, which
ported GimpGradient from ::duplicate() to ::copy(), by doing the
same for the rest of the GimpData subclasses that implement
::duplicate().
We still keep GimpData's ::duplicate() virtual function around,
even though it now points to the default implementation (which uses
::copy()) for all subclasses, since ::copy() is stronger than
::duplicate(), and we might want to have certain GimpData types
that are duplicatable, but not copyable.
This commit is contained in:
parent
9cd8e7f9c6
commit
880d3bd182
|
@ -64,7 +64,8 @@ static void gimp_brush_generated_get_property (GObject *object,
|
|||
|
||||
static void gimp_brush_generated_dirty (GimpData *data);
|
||||
static const gchar * gimp_brush_generated_get_extension (GimpData *data);
|
||||
static GimpData * gimp_brush_generated_duplicate (GimpData *data);
|
||||
static void gimp_brush_generated_copy (GimpData *data,
|
||||
GimpData *src_data);
|
||||
|
||||
static void gimp_brush_generated_transform_size(GimpBrush *gbrush,
|
||||
gdouble scale,
|
||||
|
@ -120,7 +121,7 @@ gimp_brush_generated_class_init (GimpBrushGeneratedClass *klass)
|
|||
data_class->save = gimp_brush_generated_save;
|
||||
data_class->dirty = gimp_brush_generated_dirty;
|
||||
data_class->get_extension = gimp_brush_generated_get_extension;
|
||||
data_class->duplicate = gimp_brush_generated_duplicate;
|
||||
data_class->copy = gimp_brush_generated_copy;
|
||||
|
||||
brush_class->transform_size = gimp_brush_generated_transform_size;
|
||||
brush_class->transform_mask = gimp_brush_generated_transform_mask;
|
||||
|
@ -275,18 +276,21 @@ gimp_brush_generated_get_extension (GimpData *data)
|
|||
return GIMP_BRUSH_GENERATED_FILE_EXTENSION;
|
||||
}
|
||||
|
||||
static GimpData *
|
||||
gimp_brush_generated_duplicate (GimpData *data)
|
||||
static void
|
||||
gimp_brush_generated_copy (GimpData *data,
|
||||
GimpData *src_data)
|
||||
{
|
||||
GimpBrushGenerated *brush = GIMP_BRUSH_GENERATED (data);
|
||||
GimpBrushGenerated *brush = GIMP_BRUSH_GENERATED (data);
|
||||
GimpBrushGenerated *src_brush = GIMP_BRUSH_GENERATED (src_data);
|
||||
|
||||
return gimp_brush_generated_new (gimp_object_get_name (brush),
|
||||
brush->shape,
|
||||
brush->radius,
|
||||
brush->spikes,
|
||||
brush->hardness,
|
||||
brush->aspect_ratio,
|
||||
brush->angle);
|
||||
brush->shape = src_brush->shape;
|
||||
brush->radius = src_brush->radius;
|
||||
brush->spikes = src_brush->spikes;
|
||||
brush->hardness = src_brush->hardness;
|
||||
brush->aspect_ratio = src_brush->aspect_ratio;
|
||||
brush->angle = src_brush->angle;
|
||||
|
||||
gimp_data_dirty (data);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -86,7 +86,8 @@ static gchar * gimp_curve_get_description (GimpViewable *viewable,
|
|||
|
||||
static void gimp_curve_dirty (GimpData *data);
|
||||
static const gchar * gimp_curve_get_extension (GimpData *data);
|
||||
static GimpData * gimp_curve_duplicate (GimpData *data);
|
||||
static void gimp_curve_data_copy (GimpData *data,
|
||||
GimpData *src_data);
|
||||
|
||||
static gboolean gimp_curve_serialize (GimpConfig *config,
|
||||
GimpConfigWriter *writer,
|
||||
|
@ -98,7 +99,7 @@ static gboolean gimp_curve_deserialize (GimpConfig *config,
|
|||
static gboolean gimp_curve_equal (GimpConfig *a,
|
||||
GimpConfig *b);
|
||||
static void _gimp_curve_reset (GimpConfig *config);
|
||||
static gboolean gimp_curve_copy (GimpConfig *src,
|
||||
static gboolean gimp_curve_config_copy (GimpConfig *src,
|
||||
GimpConfig *dest,
|
||||
GParamFlags flags);
|
||||
|
||||
|
@ -141,7 +142,7 @@ gimp_curve_class_init (GimpCurveClass *klass)
|
|||
data_class->dirty = gimp_curve_dirty;
|
||||
data_class->save = gimp_curve_save;
|
||||
data_class->get_extension = gimp_curve_get_extension;
|
||||
data_class->duplicate = gimp_curve_duplicate;
|
||||
data_class->copy = gimp_curve_data_copy;
|
||||
|
||||
GIMP_CONFIG_PROP_ENUM (object_class, PROP_CURVE_TYPE,
|
||||
"curve-type",
|
||||
|
@ -188,7 +189,7 @@ gimp_curve_config_iface_init (GimpConfigInterface *iface)
|
|||
iface->deserialize = gimp_curve_deserialize;
|
||||
iface->equal = gimp_curve_equal;
|
||||
iface->reset = _gimp_curve_reset;
|
||||
iface->copy = gimp_curve_copy;
|
||||
iface->copy = gimp_curve_config_copy;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -438,15 +439,16 @@ gimp_curve_get_extension (GimpData *data)
|
|||
return GIMP_CURVE_FILE_EXTENSION;
|
||||
}
|
||||
|
||||
static GimpData *
|
||||
gimp_curve_duplicate (GimpData *data)
|
||||
static void
|
||||
gimp_curve_data_copy (GimpData *data,
|
||||
GimpData *src_data)
|
||||
{
|
||||
GimpCurve *new = g_object_new (GIMP_TYPE_CURVE, NULL);
|
||||
gimp_data_freeze (data);
|
||||
|
||||
gimp_config_copy (GIMP_CONFIG (data),
|
||||
GIMP_CONFIG (new), 0);
|
||||
gimp_config_copy (GIMP_CONFIG (src_data),
|
||||
GIMP_CONFIG (data), 0);
|
||||
|
||||
return GIMP_DATA (new);
|
||||
gimp_data_thaw (data);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -498,9 +500,9 @@ _gimp_curve_reset (GimpConfig *config)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gimp_curve_copy (GimpConfig *src,
|
||||
GimpConfig *dest,
|
||||
GParamFlags flags)
|
||||
gimp_curve_config_copy (GimpConfig *src,
|
||||
GimpConfig *dest,
|
||||
GParamFlags flags)
|
||||
{
|
||||
GimpCurve *src_curve = GIMP_CURVE (src);
|
||||
GimpCurve *dest_curve = GIMP_CURVE (dest);
|
||||
|
|
|
@ -94,7 +94,8 @@ static void
|
|||
GParamSpec **pspecs);
|
||||
|
||||
static const gchar * gimp_dynamics_get_extension (GimpData *data);
|
||||
static GimpData * gimp_dynamics_duplicate (GimpData *data);
|
||||
static void gimp_dynamics_copy (GimpData *data,
|
||||
GimpData *src_data);
|
||||
|
||||
static GimpDynamicsOutput *
|
||||
gimp_dynamics_create_output (GimpDynamics *dynamics,
|
||||
|
@ -127,7 +128,7 @@ gimp_dynamics_class_init (GimpDynamicsClass *klass)
|
|||
|
||||
data_class->save = gimp_dynamics_save;
|
||||
data_class->get_extension = gimp_dynamics_get_extension;
|
||||
data_class->duplicate = gimp_dynamics_duplicate;
|
||||
data_class->copy = gimp_dynamics_copy;
|
||||
|
||||
GIMP_CONFIG_PROP_STRING (object_class, PROP_NAME,
|
||||
"name",
|
||||
|
@ -459,15 +460,16 @@ gimp_dynamics_get_extension (GimpData *data)
|
|||
return GIMP_DYNAMICS_FILE_EXTENSION;
|
||||
}
|
||||
|
||||
static GimpData *
|
||||
gimp_dynamics_duplicate (GimpData *data)
|
||||
static void
|
||||
gimp_dynamics_copy (GimpData *data,
|
||||
GimpData *src_data)
|
||||
{
|
||||
GimpData *dest = g_object_new (GIMP_TYPE_DYNAMICS, NULL);
|
||||
gimp_data_freeze (data);
|
||||
|
||||
gimp_config_copy (GIMP_CONFIG (data),
|
||||
GIMP_CONFIG (dest), 0);
|
||||
gimp_config_copy (GIMP_CONFIG (src_data),
|
||||
GIMP_CONFIG (data), 0);
|
||||
|
||||
return GIMP_DATA (dest);
|
||||
gimp_data_thaw (data);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -249,8 +249,6 @@ gimp_gradient_copy (GimpData *data,
|
|||
GimpGradient *src_gradient = GIMP_GRADIENT (src_data);
|
||||
GimpGradientSegment *head, *prev, *cur, *orig;
|
||||
|
||||
gimp_data_freeze (GIMP_DATA (gradient));
|
||||
|
||||
if (gradient->segments)
|
||||
{
|
||||
gimp_gradient_segments_free (gradient->segments);
|
||||
|
@ -258,7 +256,7 @@ gimp_gradient_copy (GimpData *data,
|
|||
}
|
||||
|
||||
prev = NULL;
|
||||
orig = GIMP_GRADIENT (src_gradient)->segments;
|
||||
orig = src_gradient->segments;
|
||||
head = NULL;
|
||||
|
||||
while (orig)
|
||||
|
@ -281,7 +279,7 @@ gimp_gradient_copy (GimpData *data,
|
|||
|
||||
gradient->segments = head;
|
||||
|
||||
gimp_data_thaw (GIMP_DATA (gradient));
|
||||
gimp_data_dirty (GIMP_DATA (gradient));
|
||||
}
|
||||
|
||||
static gint
|
||||
|
|
|
@ -67,7 +67,8 @@ static GimpTempBuf * gimp_palette_get_new_preview (GimpViewable *viewa
|
|||
static gchar * gimp_palette_get_description (GimpViewable *viewable,
|
||||
gchar **tooltip);
|
||||
static const gchar * gimp_palette_get_extension (GimpData *data);
|
||||
static GimpData * gimp_palette_duplicate (GimpData *data);
|
||||
static void gimp_palette_copy (GimpData *data,
|
||||
GimpData *src_data);
|
||||
|
||||
static void gimp_palette_entry_free (GimpPaletteEntry *entry);
|
||||
static gint64 gimp_palette_entry_get_memsize (GimpPaletteEntry *entry,
|
||||
|
@ -102,7 +103,7 @@ gimp_palette_class_init (GimpPaletteClass *klass)
|
|||
|
||||
data_class->save = gimp_palette_save;
|
||||
data_class->get_extension = gimp_palette_get_extension;
|
||||
data_class->duplicate = gimp_palette_duplicate;
|
||||
data_class->copy = gimp_palette_copy;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -309,25 +310,34 @@ gimp_palette_get_extension (GimpData *data)
|
|||
return GIMP_PALETTE_FILE_EXTENSION;
|
||||
}
|
||||
|
||||
static GimpData *
|
||||
gimp_palette_duplicate (GimpData *data)
|
||||
static void
|
||||
gimp_palette_copy (GimpData *data,
|
||||
GimpData *src_data)
|
||||
{
|
||||
GimpPalette *palette = GIMP_PALETTE (data);
|
||||
GimpPalette *new;
|
||||
GimpPalette *palette = GIMP_PALETTE (data);
|
||||
GimpPalette *src_palette = GIMP_PALETTE (src_data);
|
||||
GList *list;
|
||||
|
||||
new = g_object_new (GIMP_TYPE_PALETTE, NULL);
|
||||
gimp_data_freeze (data);
|
||||
|
||||
new->n_columns = palette->n_columns;
|
||||
if (palette->colors)
|
||||
{
|
||||
g_list_free_full (palette->colors,
|
||||
(GDestroyNotify) gimp_palette_entry_free);
|
||||
palette->colors = NULL;
|
||||
}
|
||||
|
||||
for (list = palette->colors; list; list = g_list_next (list))
|
||||
palette->n_colors = 0;
|
||||
palette->n_columns = src_palette->n_columns;
|
||||
|
||||
for (list = src_palette->colors; list; list = g_list_next (list))
|
||||
{
|
||||
GimpPaletteEntry *entry = list->data;
|
||||
|
||||
gimp_palette_add_entry (new, -1, entry->name, &entry->color);
|
||||
gimp_palette_add_entry (palette, -1, entry->name, &entry->color);
|
||||
}
|
||||
|
||||
return GIMP_DATA (new);
|
||||
gimp_data_thaw (data);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
|
|
|
@ -51,7 +51,8 @@ static gchar * gimp_pattern_get_description (GimpViewable *viewa
|
|||
gchar **tooltip);
|
||||
|
||||
static const gchar * gimp_pattern_get_extension (GimpData *data);
|
||||
static GimpData * gimp_pattern_duplicate (GimpData *data);
|
||||
static void gimp_pattern_copy (GimpData *data,
|
||||
GimpData *src_data);
|
||||
|
||||
static gchar * gimp_pattern_get_checksum (GimpTagged *tagged);
|
||||
|
||||
|
@ -81,7 +82,7 @@ gimp_pattern_class_init (GimpPatternClass *klass)
|
|||
viewable_class->get_description = gimp_pattern_get_description;
|
||||
|
||||
data_class->get_extension = gimp_pattern_get_extension;
|
||||
data_class->duplicate = gimp_pattern_duplicate;
|
||||
data_class->copy = gimp_pattern_copy;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -182,14 +183,18 @@ gimp_pattern_get_extension (GimpData *data)
|
|||
return GIMP_PATTERN_FILE_EXTENSION;
|
||||
}
|
||||
|
||||
static GimpData *
|
||||
gimp_pattern_duplicate (GimpData *data)
|
||||
static void
|
||||
gimp_pattern_copy (GimpData *data,
|
||||
GimpData *src_data)
|
||||
{
|
||||
GimpPattern *pattern = g_object_new (GIMP_TYPE_PATTERN, NULL);
|
||||
GimpPattern *pattern = GIMP_PATTERN (data);
|
||||
GimpPattern *src_pattern = GIMP_PATTERN (src_data);
|
||||
|
||||
pattern->mask = gimp_temp_buf_copy (GIMP_PATTERN (data)->mask);
|
||||
gimp_temp_buf_unref (pattern->mask);
|
||||
|
||||
return GIMP_DATA (pattern);
|
||||
pattern->mask = gimp_temp_buf_copy (src_pattern->mask);
|
||||
|
||||
gimp_data_dirty (data);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
|
|
Loading…
Reference in New Issue