app/gimpdrawable.[ch] did some code review: s/0/NULL/,

2000-10-28  Michael Natterer  <mitch@gimp.org>

	* app/gimpdrawable.[ch]
	* libgimp/gimpsizeentry.c: did some code review: s/0/NULL/,
	s/sprintf/g_snprintf/, spacing.
This commit is contained in:
Michael Natterer 2000-10-28 15:43:56 +00:00 committed by Michael Natterer
parent 02312acc28
commit 6cfb041479
7 changed files with 73 additions and 66 deletions

View File

@ -1,3 +1,8 @@
2000-10-28 Michael Natterer <mitch@gimp.org>
* app/gimpdrawable.[ch]
* libgimp/gimpsizeentry.c
2000-10-27 Michael Natterer <mitch@gimp.org>
* plug-ins/common/gauss_iir.c

View File

@ -325,12 +325,12 @@ void
gimp_drawable_set_name (GimpDrawable *drawable,
gchar *name)
{
GSList *list, *listb, *base_list;
GSList *list, *listb, *base_list;
GimpDrawable *drawableb;
gint number = 1;
gchar *newname;
gchar *ext;
gchar numberbuf[20];
gint number = 1;
gchar *newname;
gchar *ext;
gchar numberbuf[20];
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (name != NULL);
@ -341,7 +341,7 @@ gimp_drawable_set_name (GimpDrawable *drawable,
drawable->name = NULL;
}
if (drawable->gimage == 0 || drawable->gimage->layers == 0)
if (drawable->gimage == NULL || drawable->gimage->layers == NULL)
{
/* no other layers to check name against */
drawable->name = g_strdup (name);
@ -355,8 +355,7 @@ gimp_drawable_set_name (GimpDrawable *drawable,
else
base_list = NULL;
list = base_list;
while (list)
for (list = base_list; list; list = g_slist_next (list))
{
drawableb = GIMP_DRAWABLE (list->data);
if (drawable != drawableb &&
@ -369,7 +368,7 @@ gimp_drawable_set_name (GimpDrawable *drawable,
{
number = atoi(ext+1);
/* Check if there really was the number we think after the # */
sprintf (numberbuf, "#%d", number);
g_snprintf (numberbuf, sizeof (numberbuf), "#%d", number);
if (strcmp (ext, numberbuf) != 0)
{
/* No, so just ignore the # */
@ -382,14 +381,14 @@ gimp_drawable_set_name (GimpDrawable *drawable,
number = 1;
ext = &newname[strlen (newname)];
}
sprintf (ext, "#%d", number+1);
sprintf (ext, "#%d", number + 1);
listb = base_list;
while (listb) /* make sure the new name is unique */
{
drawableb = GIMP_DRAWABLE (listb->data);
if (drawable !=
drawableb && strcmp (newname,
gimp_drawable_get_name(drawableb)) == 0)
if (drawable != drawableb &&
strcmp (newname, gimp_drawable_get_name (drawableb)) == 0)
{
number++;
sprintf (ext, "#%d", number+1);
@ -403,8 +402,8 @@ gimp_drawable_set_name (GimpDrawable *drawable,
g_free (newname);
return;
}
list = list->next;
}
drawable->name = g_strdup (name);
}
@ -413,7 +412,7 @@ gimp_drawable_get_color_at (GimpDrawable *drawable,
gint x,
gint y)
{
Tile *tile;
Tile *tile;
guchar *src;
guchar *dest;
@ -551,7 +550,8 @@ gimp_drawable_get_tattoo (const GimpDrawable *drawable)
}
void
gimp_drawable_set_tattoo (GimpDrawable *drawable, Tattoo val)
gimp_drawable_set_tattoo (GimpDrawable *drawable,
Tattoo val)
{
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
@ -699,7 +699,7 @@ gimp_drawable_init (GimpDrawable *drawable)
gimp_drawable_table = g_hash_table_new (g_direct_hash, NULL);
g_hash_table_insert (gimp_drawable_table,
(gpointer) drawable->ID,
GINT_TO_POINTER (drawable->ID),
(gpointer) drawable);
}
@ -727,7 +727,7 @@ gimp_drawable_destroy (GtkObject *object)
gtk_object_unref (GTK_OBJECT (drawable->parasites));
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
void
@ -738,7 +738,7 @@ gimp_drawable_configure (GimpDrawable *drawable,
GimpImageType type,
gchar *name)
{
gint bpp;
gint bpp;
gboolean alpha;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));

View File

@ -15,8 +15,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMPDRAWABLE_H__
#define __GIMPDRAWABLE_H__
#ifndef __GIMP_DRAWABLE_H__
#define __GIMP_DRAWABLE_H__
#include "apptypes.h"
#include "gimpobject.h"
@ -87,4 +88,4 @@ void gimp_drawable_deallocate (GimpDrawable *);
GimpImage * gimp_drawable_gimage (GimpDrawable*);
void gimp_drawable_set_gimage (GimpDrawable*, GimpImage *);
#endif /* __GIMPDRAWABLE_H__ */
#endif /* __GIMP_DRAWABLE_H__ */

View File

@ -325,12 +325,12 @@ void
gimp_drawable_set_name (GimpDrawable *drawable,
gchar *name)
{
GSList *list, *listb, *base_list;
GSList *list, *listb, *base_list;
GimpDrawable *drawableb;
gint number = 1;
gchar *newname;
gchar *ext;
gchar numberbuf[20];
gint number = 1;
gchar *newname;
gchar *ext;
gchar numberbuf[20];
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (name != NULL);
@ -341,7 +341,7 @@ gimp_drawable_set_name (GimpDrawable *drawable,
drawable->name = NULL;
}
if (drawable->gimage == 0 || drawable->gimage->layers == 0)
if (drawable->gimage == NULL || drawable->gimage->layers == NULL)
{
/* no other layers to check name against */
drawable->name = g_strdup (name);
@ -355,8 +355,7 @@ gimp_drawable_set_name (GimpDrawable *drawable,
else
base_list = NULL;
list = base_list;
while (list)
for (list = base_list; list; list = g_slist_next (list))
{
drawableb = GIMP_DRAWABLE (list->data);
if (drawable != drawableb &&
@ -369,7 +368,7 @@ gimp_drawable_set_name (GimpDrawable *drawable,
{
number = atoi(ext+1);
/* Check if there really was the number we think after the # */
sprintf (numberbuf, "#%d", number);
g_snprintf (numberbuf, sizeof (numberbuf), "#%d", number);
if (strcmp (ext, numberbuf) != 0)
{
/* No, so just ignore the # */
@ -382,14 +381,14 @@ gimp_drawable_set_name (GimpDrawable *drawable,
number = 1;
ext = &newname[strlen (newname)];
}
sprintf (ext, "#%d", number+1);
sprintf (ext, "#%d", number + 1);
listb = base_list;
while (listb) /* make sure the new name is unique */
{
drawableb = GIMP_DRAWABLE (listb->data);
if (drawable !=
drawableb && strcmp (newname,
gimp_drawable_get_name(drawableb)) == 0)
if (drawable != drawableb &&
strcmp (newname, gimp_drawable_get_name (drawableb)) == 0)
{
number++;
sprintf (ext, "#%d", number+1);
@ -403,8 +402,8 @@ gimp_drawable_set_name (GimpDrawable *drawable,
g_free (newname);
return;
}
list = list->next;
}
drawable->name = g_strdup (name);
}
@ -413,7 +412,7 @@ gimp_drawable_get_color_at (GimpDrawable *drawable,
gint x,
gint y)
{
Tile *tile;
Tile *tile;
guchar *src;
guchar *dest;
@ -551,7 +550,8 @@ gimp_drawable_get_tattoo (const GimpDrawable *drawable)
}
void
gimp_drawable_set_tattoo (GimpDrawable *drawable, Tattoo val)
gimp_drawable_set_tattoo (GimpDrawable *drawable,
Tattoo val)
{
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
@ -699,7 +699,7 @@ gimp_drawable_init (GimpDrawable *drawable)
gimp_drawable_table = g_hash_table_new (g_direct_hash, NULL);
g_hash_table_insert (gimp_drawable_table,
(gpointer) drawable->ID,
GINT_TO_POINTER (drawable->ID),
(gpointer) drawable);
}
@ -727,7 +727,7 @@ gimp_drawable_destroy (GtkObject *object)
gtk_object_unref (GTK_OBJECT (drawable->parasites));
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
void
@ -738,7 +738,7 @@ gimp_drawable_configure (GimpDrawable *drawable,
GimpImageType type,
gchar *name)
{
gint bpp;
gint bpp;
gboolean alpha;
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));

View File

@ -15,8 +15,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMPDRAWABLE_H__
#define __GIMPDRAWABLE_H__
#ifndef __GIMP_DRAWABLE_H__
#define __GIMP_DRAWABLE_H__
#include "apptypes.h"
#include "gimpobject.h"
@ -87,4 +88,4 @@ void gimp_drawable_deallocate (GimpDrawable *);
GimpImage * gimp_drawable_gimage (GimpDrawable*);
void gimp_drawable_set_gimage (GimpDrawable*, GimpImage *);
#endif /* __GIMPDRAWABLE_H__ */
#endif /* __GIMP_DRAWABLE_H__ */

View File

@ -154,14 +154,14 @@ gimp_size_entry_class_init (GimpSizeEntryClass *class)
static void
gimp_size_entry_init (GimpSizeEntry *gse)
{
gse->fields = NULL;
gse->number_of_fields = 0;
gse->unitmenu = NULL;
gse->unit = GIMP_UNIT_PIXEL;
gse->menu_show_pixels = TRUE;
gse->fields = NULL;
gse->number_of_fields = 0;
gse->unitmenu = NULL;
gse->unit = GIMP_UNIT_PIXEL;
gse->menu_show_pixels = TRUE;
gse->menu_show_percent = TRUE;
gse->show_refval = FALSE;
gse->update_policy = GIMP_SIZE_ENTRY_UPDATE_NONE;
gse->show_refval = FALSE;
gse->update_policy = GIMP_SIZE_ENTRY_UPDATE_NONE;
}
GtkType
@ -250,12 +250,12 @@ gimp_size_entry_new (gint number_of_fields,
g_return_val_if_fail ((number_of_fields >= 0) && (number_of_fields <= 16),
NULL);
gse = gtk_type_new (gimp_size_entry_get_type ());
gse = gtk_type_new (GIMP_TYPE_SIZE_ENTRY);
gse->number_of_fields = number_of_fields;
gse->unit = unit;
gse->show_refval = show_refval;
gse->update_policy = update_policy;
gse->unit = unit;
gse->show_refval = show_refval;
gse->update_policy = update_policy;
gtk_table_resize (GTK_TABLE (gse),
1 + gse->show_refval + 2,

View File

@ -154,14 +154,14 @@ gimp_size_entry_class_init (GimpSizeEntryClass *class)
static void
gimp_size_entry_init (GimpSizeEntry *gse)
{
gse->fields = NULL;
gse->number_of_fields = 0;
gse->unitmenu = NULL;
gse->unit = GIMP_UNIT_PIXEL;
gse->menu_show_pixels = TRUE;
gse->fields = NULL;
gse->number_of_fields = 0;
gse->unitmenu = NULL;
gse->unit = GIMP_UNIT_PIXEL;
gse->menu_show_pixels = TRUE;
gse->menu_show_percent = TRUE;
gse->show_refval = FALSE;
gse->update_policy = GIMP_SIZE_ENTRY_UPDATE_NONE;
gse->show_refval = FALSE;
gse->update_policy = GIMP_SIZE_ENTRY_UPDATE_NONE;
}
GtkType
@ -250,12 +250,12 @@ gimp_size_entry_new (gint number_of_fields,
g_return_val_if_fail ((number_of_fields >= 0) && (number_of_fields <= 16),
NULL);
gse = gtk_type_new (gimp_size_entry_get_type ());
gse = gtk_type_new (GIMP_TYPE_SIZE_ENTRY);
gse->number_of_fields = number_of_fields;
gse->unit = unit;
gse->show_refval = show_refval;
gse->update_policy = update_policy;
gse->unit = unit;
gse->show_refval = show_refval;
gse->update_policy = update_policy;
gtk_table_resize (GTK_TABLE (gse),
1 + gse->show_refval + 2,