removed the return value again.

2006-04-02  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpparasitelist.[ch] (gimp_parasite_list_add): removed
	the return value again.

	(gimp_parasite_list_find): return a const parasite.

	* app/core/gimp-parasites.[ch]
	* app/core/gimpimage.[ch]
	* app/core/gimpitem.[ch] (*_parasite_attach): take a const
	parasite. Make a local copy of the parasite struct because
	gimp_parasite_shift_parent() changes it.

	(*_parasite_find): return a const parasite.

	* app/core/gimptemplate.c
	* app/text/gimptextlayer-xcf.c
	* app/xcf/xcf-load.c: changed accordingly.
This commit is contained in:
Michael Natterer 2006-04-02 15:37:25 +00:00 committed by Michael Natterer
parent 5e28089de9
commit 5fb387ea1b
12 changed files with 247 additions and 200 deletions

View File

@ -1,3 +1,22 @@
2006-04-02 Michael Natterer <mitch@gimp.org>
* app/core/gimpparasitelist.[ch] (gimp_parasite_list_add): removed
the return value again.
(gimp_parasite_list_find): return a const parasite.
* app/core/gimp-parasites.[ch]
* app/core/gimpimage.[ch]
* app/core/gimpitem.[ch] (*_parasite_attach): take a const
parasite. Make a local copy of the parasite struct because
gimp_parasite_shift_parent() changes it.
(*_parasite_find): return a const parasite.
* app/core/gimptemplate.c
* app/text/gimptextlayer-xcf.c
* app/xcf/xcf-load.c: changed accordingly.
2006-04-02 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage-undo-push.[ch]

View File

@ -30,9 +30,12 @@
void
gimp_parasite_attach (Gimp *gimp,
GimpParasite *parasite)
gimp_parasite_attach (Gimp *gimp,
const GimpParasite *parasite)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (parasite != NULL);
gimp_parasite_list_add (gimp->parasites, parasite);
}
@ -40,13 +43,19 @@ void
gimp_parasite_detach (Gimp *gimp,
const gchar *name)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (name != NULL);
gimp_parasite_list_remove (gimp->parasites, name);
}
GimpParasite *
const GimpParasite *
gimp_parasite_find (Gimp *gimp,
const gchar *name)
{
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (name != NULL, NULL);
return gimp_parasite_list_find (gimp->parasites, name);
}
@ -65,6 +74,9 @@ gimp_parasite_list (Gimp *gimp,
gchar **list;
gchar **current;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (count != NULL, NULL);
*count = gimp_parasite_list_length (gimp->parasites);
list = current = g_new (gchar *, *count);
@ -80,8 +92,7 @@ gimp_parasite_list (Gimp *gimp,
void
gimp_parasite_shift_parent (GimpParasite *parasite)
{
if (parasite == NULL)
return;
g_return_if_fail (parasite != NULL);
parasite->flags = (parasite->flags >> 8);
}

View File

@ -21,19 +21,19 @@
/* some wrappers to access gimp->parasites, mainly for the PDB */
void gimp_parasite_attach (Gimp *gimp,
GimpParasite *parasite);
void gimp_parasite_detach (Gimp *gimp,
const gchar *name);
GimpParasite * gimp_parasite_find (Gimp *gimp,
const gchar *name);
gchar ** gimp_parasite_list (Gimp *gimp,
gint *count);
void gimp_parasite_attach (Gimp *gimp,
const GimpParasite *parasite);
void gimp_parasite_detach (Gimp *gimp,
const gchar *name);
const GimpParasite * gimp_parasite_find (Gimp *gimp,
const gchar *name);
gchar ** gimp_parasite_list (Gimp *gimp,
gint *count);
void gimp_parasite_shift_parent (GimpParasite *parasite);
void gimp_parasite_shift_parent (GimpParasite *parasite);
void gimp_parasiterc_load (Gimp *gimp);
void gimp_parasiterc_save (Gimp *gimp);
void gimp_parasiterc_load (Gimp *gimp);
void gimp_parasiterc_save (Gimp *gimp);
#endif /* __GIMP_PARASITES_H__ */

View File

@ -2196,7 +2196,7 @@ gimp_image_free_shadow (GimpImage *image)
/* parasites */
GimpParasite *
const GimpParasite *
gimp_image_parasite_find (const GimpImage *image,
const gchar *name)
{
@ -2231,17 +2231,25 @@ gimp_image_parasite_list (const GimpImage *image,
}
void
gimp_image_parasite_attach (GimpImage *image,
GimpParasite *parasite)
gimp_image_parasite_attach (GimpImage *image,
const GimpParasite *parasite)
{
g_return_if_fail (GIMP_IS_IMAGE (image) && parasite != NULL);
GimpParasite *copy;
g_return_if_fail (GIMP_IS_IMAGE (image));
g_return_if_fail (parasite != NULL);
/* make a temp copy of the struct because
* gimp_parasite_shift_parent() changes it
*/
copy = g_memdup (parasite, sizeof (GimpParasite));
/* only set the dirty bit manually if we can be saved and the new
parasite differs from the current one and we aren't undoable */
if (gimp_parasite_is_undoable (parasite))
if (gimp_parasite_is_undoable (copy))
gimp_image_undo_push_image_parasite (image,
_("Attach Parasite to Image"),
parasite);
copy);
/* We used to push an cantundo on te stack here. This made the undo stack
unusable (NULL on the stack) and prevented people from undoing after a
@ -2250,33 +2258,35 @@ gimp_image_parasite_attach (GimpImage *image,
undoable but does not block the undo system. --Sven
*/
gimp_parasite_list_add (image->parasites, parasite);
gimp_parasite_list_add (image->parasites, copy);
if (gimp_parasite_has_flag (parasite, GIMP_PARASITE_ATTACH_PARENT))
if (gimp_parasite_has_flag (copy, GIMP_PARASITE_ATTACH_PARENT))
{
gimp_parasite_shift_parent (parasite);
gimp_parasite_attach (image->gimp, parasite);
gimp_parasite_shift_parent (copy);
gimp_parasite_attach (image->gimp, copy);
}
g_free (copy);
}
void
gimp_image_parasite_detach (GimpImage *image,
const gchar *parasite)
const gchar *name)
{
GimpParasite *p;
const GimpParasite *parasite;
g_return_if_fail (GIMP_IS_IMAGE (image));
g_return_if_fail (parasite != NULL);
g_return_if_fail (name != NULL);
if (!(p = gimp_parasite_list_find (image->parasites, parasite)))
if (! (parasite = gimp_parasite_list_find (image->parasites, name)))
return;
if (gimp_parasite_is_undoable (p))
if (gimp_parasite_is_undoable (parasite))
gimp_image_undo_push_image_parasite_remove (image,
_("Remove Parasite from Image"),
gimp_parasite_name (p));
name);
gimp_parasite_list_remove (image->parasites, parasite);
gimp_parasite_list_remove (image->parasites, name);
}

View File

@ -376,14 +376,14 @@ void gimp_image_free_shadow (GimpImage *image);
/* parasites */
GimpParasite * gimp_image_parasite_find (const GimpImage *image,
const GimpParasite * gimp_image_parasite_find (const GimpImage *image,
const gchar *name);
gchar ** gimp_image_parasite_list (const GimpImage *image,
gint *count);
void gimp_image_parasite_attach (GimpImage *image,
GimpParasite *parasite);
const GimpParasite *parasite);
void gimp_image_parasite_detach (GimpImage *image,
const gchar *parasite);
const gchar *name);
/* tattoos */

View File

@ -1130,62 +1130,71 @@ gimp_item_set_image (GimpItem *item,
}
void
gimp_item_parasite_attach (GimpItem *item,
GimpParasite *parasite)
gimp_item_parasite_attach (GimpItem *item,
const GimpParasite *parasite)
{
GimpParasite *copy;
g_return_if_fail (GIMP_IS_ITEM (item));
g_return_if_fail (parasite != NULL);
/* make a temp copy of the struct because
* gimp_parasite_shift_parent() changes it
*/
copy = g_memdup (parasite, sizeof (GimpParasite));
if (gimp_item_is_attached (item))
{
/* only set the dirty bit manually if we can be saved and the new
* parasite differs from the current one and we aren't undoable
*/
if (gimp_parasite_is_undoable (parasite))
if (gimp_parasite_is_undoable (copy))
{
/* do a group in case we have attach_parent set */
gimp_image_undo_group_start (item->image,
GIMP_UNDO_GROUP_PARASITE_ATTACH,
_("Attach Parasite"));
gimp_image_undo_push_item_parasite (item->image, NULL, item,
parasite);
gimp_image_undo_push_item_parasite (item->image, NULL, item, copy);
}
else if (gimp_parasite_is_persistent (parasite) &&
! gimp_parasite_compare (parasite,
else if (gimp_parasite_is_persistent (copy) &&
! gimp_parasite_compare (copy,
gimp_item_parasite_find
(item, gimp_parasite_name (parasite))))
(item, gimp_parasite_name (copy))))
{
gimp_image_undo_push_cantundo (item->image,
_("Attach Parasite to Item"));
}
}
gimp_parasite_list_add (item->parasites, parasite);
gimp_parasite_list_add (item->parasites, copy);
if (gimp_parasite_has_flag (parasite, GIMP_PARASITE_ATTACH_PARENT))
if (gimp_parasite_has_flag (copy, GIMP_PARASITE_ATTACH_PARENT))
{
gimp_parasite_shift_parent (parasite);
gimp_image_parasite_attach (item->image, parasite);
gimp_parasite_shift_parent (copy);
gimp_image_parasite_attach (item->image, copy);
}
else if (gimp_parasite_has_flag (parasite, GIMP_PARASITE_ATTACH_GRANDPARENT))
else if (gimp_parasite_has_flag (copy, GIMP_PARASITE_ATTACH_GRANDPARENT))
{
gimp_parasite_shift_parent (parasite);
gimp_parasite_shift_parent (parasite);
gimp_parasite_attach (item->image->gimp, parasite);
gimp_parasite_shift_parent (copy);
gimp_parasite_shift_parent (copy);
gimp_parasite_attach (item->image->gimp, copy);
}
if (gimp_item_is_attached (item) &&
gimp_parasite_is_undoable (parasite))
gimp_parasite_is_undoable (copy))
{
gimp_image_undo_group_end (item->image);
}
g_free (copy);
}
void
gimp_item_parasite_detach (GimpItem *item,
const gchar *name)
{
GimpParasite *parasite;
const GimpParasite *parasite;
g_return_if_fail (GIMP_IS_ITEM (item));
@ -1210,7 +1219,7 @@ gimp_item_parasite_detach (GimpItem *item,
gimp_parasite_list_remove (item->parasites, name);
}
GimpParasite *
const GimpParasite *
gimp_item_parasite_find (const GimpItem *item,
const gchar *name)
{

View File

@ -128,129 +128,129 @@ struct _GimpItemClass
GType gimp_item_get_type (void) G_GNUC_CONST;
gboolean gimp_item_is_floating (const GimpItem *item);
void gimp_item_sink (GimpItem *item);
gboolean gimp_item_is_floating (const GimpItem *item);
void gimp_item_sink (GimpItem *item);
void gimp_item_removed (GimpItem *item);
gboolean gimp_item_is_removed (const GimpItem *item);
void gimp_item_removed (GimpItem *item);
gboolean gimp_item_is_removed (const GimpItem *item);
gboolean gimp_item_is_attached (GimpItem *item);
gboolean gimp_item_is_attached (GimpItem *item);
void gimp_item_configure (GimpItem *item,
GimpImage *image,
gint offset_x,
gint offset_y,
gint width,
gint height,
const gchar *name);
GimpItem * gimp_item_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha);
GimpItem * gimp_item_convert (GimpItem *item,
GimpImage *dest_image,
GType new_type,
gboolean add_alpha);
void gimp_item_configure (GimpItem *item,
GimpImage *image,
gint offset_x,
gint offset_y,
gint width,
gint height,
const gchar *name);
GimpItem * gimp_item_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha);
GimpItem * gimp_item_convert (GimpItem *item,
GimpImage *dest_image,
GType new_type,
gboolean add_alpha);
gboolean gimp_item_rename (GimpItem *item,
const gchar *new_name);
gboolean gimp_item_rename (GimpItem *item,
const gchar *new_name);
gint gimp_item_width (const GimpItem *item);
gint gimp_item_height (const GimpItem *item);
void gimp_item_offsets (const GimpItem *item,
gint *offset_x,
gint *offset_y);
gint gimp_item_width (const GimpItem *item);
gint gimp_item_height (const GimpItem *item);
void gimp_item_offsets (const GimpItem *item,
gint *offset_x,
gint *offset_y);
void gimp_item_translate (GimpItem *item,
gint offset_x,
gint offset_y,
gboolean push_undo);
void gimp_item_translate (GimpItem *item,
gint offset_x,
gint offset_y,
gboolean push_undo);
gboolean gimp_item_check_scaling (const GimpItem *item,
gint new_width,
gint new_height);
void gimp_item_scale (GimpItem *item,
gint new_width,
gint new_height,
gint new_offset_x,
gint new_offset_y,
GimpInterpolationType interpolation,
GimpProgress *progress);
gboolean gimp_item_scale_by_factors (GimpItem *item,
gdouble w_factor,
gdouble h_factor,
gboolean gimp_item_check_scaling (const GimpItem *item,
gint new_width,
gint new_height);
void gimp_item_scale (GimpItem *item,
gint new_width,
gint new_height,
gint new_offset_x,
gint new_offset_y,
GimpInterpolationType interpolation,
GimpProgress *progress);
void gimp_item_scale_by_origin (GimpItem *item,
gint new_width,
gint new_height,
GimpProgress *progress);
gboolean gimp_item_scale_by_factors (GimpItem *item,
gdouble w_factor,
gdouble h_factor,
GimpInterpolationType interpolation,
GimpProgress *progress,
gboolean local_origin);
void gimp_item_resize (GimpItem *item,
GimpContext *context,
gint new_width,
gint new_height,
gint offset_x,
gint offset_y);
void gimp_item_resize_to_image (GimpItem *item);
GimpProgress *progress);
void gimp_item_scale_by_origin (GimpItem *item,
gint new_width,
gint new_height,
GimpInterpolationType interpolation,
GimpProgress *progress,
gboolean local_origin);
void gimp_item_resize (GimpItem *item,
GimpContext *context,
gint new_width,
gint new_height,
gint offset_x,
gint offset_y);
void gimp_item_resize_to_image (GimpItem *item);
void gimp_item_flip (GimpItem *item,
GimpContext *context,
void gimp_item_flip (GimpItem *item,
GimpContext *context,
GimpOrientationType flip_type,
gdouble axis,
gboolean flip_result);
void gimp_item_rotate (GimpItem *item,
GimpContext *context,
GimpRotationType rotate_type,
gdouble center_x,
gdouble center_y,
gboolean flip_result);
void gimp_item_transform (GimpItem *item,
GimpContext *context,
const GimpMatrix3 *matrix,
gdouble axis,
gboolean flip_result);
void gimp_item_rotate (GimpItem *item,
GimpContext *context,
GimpRotationType rotate_type,
gdouble center_x,
gdouble center_y,
gboolean flip_result);
void gimp_item_transform (GimpItem *item,
GimpContext *context,
const GimpMatrix3 *matrix,
GimpTransformDirection direction,
GimpInterpolationType interpolation_type,
gboolean supersample,
gint recursion_level,
gboolean clip_result,
GimpProgress *progress);
gboolean supersample,
gint recursion_level,
gboolean clip_result,
GimpProgress *progress);
gboolean gimp_item_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpContext *context,
GimpStrokeDesc *stroke_desc,
gboolean use_default_values);
gboolean gimp_item_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpContext *context,
GimpStrokeDesc *stroke_desc,
gboolean use_default_values);
gint gimp_item_get_ID (GimpItem *item);
GimpItem * gimp_item_get_by_ID (Gimp *gimp,
gint id);
gint gimp_item_get_ID (GimpItem *item);
GimpItem * gimp_item_get_by_ID (Gimp *gimp,
gint id);
GimpTattoo gimp_item_get_tattoo (const GimpItem *item);
void gimp_item_set_tattoo (GimpItem *item,
GimpTattoo tattoo);
GimpTattoo gimp_item_get_tattoo (const GimpItem *item);
void gimp_item_set_tattoo (GimpItem *item,
GimpTattoo tattoo);
GimpImage * gimp_item_get_image (const GimpItem *item);
void gimp_item_set_image (GimpItem *item,
GimpImage *image);
GimpImage * gimp_item_get_image (const GimpItem *item);
void gimp_item_set_image (GimpItem *item,
GimpImage *image);
void gimp_item_parasite_attach (GimpItem *item,
GimpParasite *parasite);
void gimp_item_parasite_detach (GimpItem *item,
const gchar *name);
GimpParasite * gimp_item_parasite_find (const GimpItem *item,
const gchar *name);
gchar ** gimp_item_parasite_list (const GimpItem *item,
gint *count);
void gimp_item_parasite_attach (GimpItem *item,
const GimpParasite *parasite);
void gimp_item_parasite_detach (GimpItem *item,
const gchar *name);
const GimpParasite *gimp_item_parasite_find(const GimpItem *item,
const gchar *name);
gchar ** gimp_item_parasite_list (const GimpItem *item,
gint *count);
gboolean gimp_item_get_visible (const GimpItem *item);
void gimp_item_set_visible (GimpItem *item,
gboolean visible,
gboolean push_undo);
gboolean gimp_item_get_visible (const GimpItem *item);
void gimp_item_set_visible (GimpItem *item,
gboolean visible,
gboolean push_undo);
void gimp_item_set_linked (GimpItem *item,
gboolean linked,
gboolean push_undo);
gboolean gimp_item_get_linked (const GimpItem *item);
void gimp_item_set_linked (GimpItem *item,
gboolean linked,
gboolean push_undo);
gboolean gimp_item_get_linked (const GimpItem *item);
#endif /* __GIMP_ITEM_H__ */

View File

@ -330,15 +330,15 @@ gimp_parasite_list_copy (const GimpParasiteList *list)
return newlist;
}
GimpParasite *
void
gimp_parasite_list_add (GimpParasiteList *list,
const GimpParasite *parasite)
{
GimpParasite *copy;
g_return_val_if_fail (GIMP_IS_PARASITE_LIST (list), NULL);
g_return_val_if_fail (parasite != NULL, NULL);
g_return_val_if_fail (parasite->name != NULL, NULL);
g_return_if_fail (GIMP_IS_PARASITE_LIST (list));
g_return_if_fail (parasite != NULL);
g_return_if_fail (parasite->name != NULL);
if (list->table == NULL)
list->table = g_hash_table_new (g_str_hash, g_str_equal);
@ -348,21 +348,19 @@ gimp_parasite_list_add (GimpParasiteList *list,
g_hash_table_insert (list->table, copy->name, copy);
g_signal_emit (list, parasite_list_signals[ADD], 0, copy);
return copy;
}
void
gimp_parasite_list_remove (GimpParasiteList *list,
const gchar *name)
{
GimpParasite *parasite;
g_return_if_fail (GIMP_IS_PARASITE_LIST (list));
if (list->table)
{
parasite = gimp_parasite_list_find (list, name);
GimpParasite *parasite;
parasite = (GimpParasite *) gimp_parasite_list_find (list, name);
if (parasite)
{
@ -415,7 +413,7 @@ gimp_parasite_list_foreach (GimpParasiteList *list,
g_hash_table_foreach (list->table, function, user_data);
}
GimpParasite *
const GimpParasite *
gimp_parasite_list_find (GimpParasiteList *list,
const gchar *name)
{

View File

@ -50,21 +50,21 @@ struct _GimpParasiteListClass
};
GType gimp_parasite_list_get_type (void) G_GNUC_CONST;
GType gimp_parasite_list_get_type (void) G_GNUC_CONST;
GimpParasiteList * gimp_parasite_list_new (void);
GimpParasiteList * gimp_parasite_list_copy (const GimpParasiteList *list);
GimpParasite * gimp_parasite_list_add (GimpParasiteList *list,
const GimpParasite *parasite);
void gimp_parasite_list_remove (GimpParasiteList *list,
const gchar *name);
gint gimp_parasite_list_length (GimpParasiteList *list);
gint gimp_parasite_list_persistent_length (GimpParasiteList *list);
void gimp_parasite_list_foreach (GimpParasiteList *list,
GHFunc function,
gpointer user_data);
GimpParasite * gimp_parasite_list_find (GimpParasiteList *list,
const gchar *name);
GimpParasiteList * gimp_parasite_list_new (void);
GimpParasiteList * gimp_parasite_list_copy (const GimpParasiteList *list);
void gimp_parasite_list_add (GimpParasiteList *list,
const GimpParasite *parasite);
void gimp_parasite_list_remove (GimpParasiteList *list,
const gchar *name);
gint gimp_parasite_list_length (GimpParasiteList *list);
gint gimp_parasite_list_persistent_length (GimpParasiteList *list);
void gimp_parasite_list_foreach (GimpParasiteList *list,
GHFunc function,
gpointer user_data);
const GimpParasite * gimp_parasite_list_find (GimpParasiteList *list,
const gchar *name);
#endif /* __GIMP_PARASITE_LIST_H__ */

View File

@ -319,11 +319,11 @@ void
gimp_template_set_from_image (GimpTemplate *template,
GimpImage *image)
{
gdouble xresolution;
gdouble yresolution;
GimpImageBaseType image_type;
GimpParasite *parasite;
gchar *comment = NULL;
gdouble xresolution;
gdouble yresolution;
GimpImageBaseType image_type;
const GimpParasite *parasite;
gchar *comment = NULL;
g_return_if_fail (GIMP_IS_TEMPLATE (template));
g_return_if_fail (GIMP_IS_IMAGE (image));

View File

@ -52,9 +52,9 @@ static GimpLayer * gimp_text_layer_from_layer (GimpLayer *layer,
gboolean
gimp_text_layer_xcf_load_hack (GimpLayer **layer)
{
const gchar *name;
GimpText *text = NULL;
GimpParasite *parasite;
const gchar *name;
GimpText *text = NULL;
const GimpParasite *parasite;
g_return_val_if_fail (layer != NULL, FALSE);
g_return_val_if_fail (GIMP_IS_LAYER (*layer), FALSE);

View File

@ -119,16 +119,16 @@ GimpImage *
xcf_load_image (Gimp *gimp,
XcfInfo *info)
{
GimpImage *image;
GimpLayer *layer;
GimpChannel *channel;
GimpParasite *parasite;
guint32 saved_pos;
guint32 offset;
gint width;
gint height;
gint image_type;
gint num_successful_elements = 0;
GimpImage *image;
GimpLayer *layer;
GimpChannel *channel;
const GimpParasite *parasite;
guint32 saved_pos;
guint32 offset;
gint width;
gint height;
gint image_type;
gint num_successful_elements = 0;
/* read in the image width, height and type */
info->cp += xcf_read_int32 (info->fp, (guint32 *) &width, 1);