Commit cac3f7cb authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

app/apptypes.h app/brush_edit.c app/brush_select.c app/brushes_cmds.c

2001-01-14  Michael Natterer  <mitch@gimp.org>

	* app/apptypes.h
	* app/brush_edit.c
	* app/brush_select.c
	* app/brushes_cmds.c
	* app/channel.h
	* app/colormap_dialog.c
	* app/datafiles.[ch]
	* app/devices.c
	* app/docindex.c
	* app/fileops.c
	* app/gdisplay.c
	* app/gimage.c
	* app/gimpbrush.[ch]
	* app/gimpbrushgenerated.[ch]
	* app/gimpbrushlist.[ch]
	* app/gimpbrushpipe.[ch]
	* app/gimpcontext.[ch]
	* app/gimpcontextpreview.c
	* app/gimpdnd.c
	* app/gimpdrawable.h
	* app/gimpimage.[ch]
	* app/gimplist.h
	* app/gimpobject.h
	* app/gimpset.[ch]
	* app/gradient.c
	* app/info_window.c
	* app/layer.[ch]
	* app/module_db.c
	* app/palette.[ch]
	* app/patterns.[ch]
	* app/plug_in.[ch]
	* app/undo_history.c
	* app/xcf.c
	* tools/pdbgen/pdb/brushes.pdb

	- Removed the "name" argument from all objects and use
	  GimpObject's name.
	- Use the same code in all "uniquefy name" functions (this
	  functionality will be a method of the "GimpContainer" class).
	- Renamed the parent instances of all objects to "parent instance".
	- Added missing instance and class cast macros.
	- Changed some "gchar *" to "const gchar *" parameters.
parent fc121e6c
2001-01-14 Michael Natterer <mitch@gimp.org>
* app/apptypes.h
* app/brush_edit.c
* app/brush_select.c
* app/brushes_cmds.c
* app/channel.h
* app/colormap_dialog.c
* app/datafiles.[ch]
* app/devices.c
* app/docindex.c
* app/fileops.c
* app/gdisplay.c
* app/gimage.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontext.[ch]
* app/gimpcontextpreview.c
* app/gimpdnd.c
* app/gimpdrawable.h
* app/gimpimage.[ch]
* app/gimplist.h
* app/gimpobject.h
* app/gimpset.[ch]
* app/gradient.c
* app/info_window.c
* app/layer.[ch]
* app/module_db.c
* app/palette.[ch]
* app/patterns.[ch]
* app/plug_in.[ch]
* app/undo_history.c
* app/xcf.c
* tools/pdbgen/pdb/brushes.pdb
- Removed the "name" argument from all objects and use
GimpObject's name.
- Use the same code in all "uniquefy name" functions (this
functionality will be a method of the "GimpContainer" class).
- Renamed the parent instances of all objects to "parent instance".
- Added missing instance and class cast macros.
- Changed some "gchar *" to "const gchar *" parameters.
2001-01-12 Sven Neumann <sven@gimp.org>
* TODO.xml: updated status
......
......@@ -149,8 +149,8 @@ static void plug_in_handle_proc_run (GPProcRun *proc_run);
static void plug_in_handle_proc_return (GPProcReturn *proc_return);
static void plug_in_handle_proc_install (GPProcInstall *proc_install);
static void plug_in_handle_proc_uninstall (GPProcUninstall *proc_uninstall);
static void plug_in_write_rc (gchar *filename);
static void plug_in_init_file (gchar *filename);
static void plug_in_write_rc (const gchar *filename);
static void plug_in_init_file (const gchar *filename);
static void plug_in_query (PlugInDef *plug_in_def);
static void plug_in_add_to_db (void);
static void plug_in_make_menu (void);
......@@ -670,7 +670,7 @@ plug_in_file_handler (gchar *name,
PlugInDef *
plug_in_def_new (gchar *prog)
plug_in_def_new (const gchar *prog)
{
PlugInDef *plug_in_def;
......@@ -2213,7 +2213,7 @@ plug_in_write_rc_string (FILE *fp,
}
static void
plug_in_write_rc (gchar *filename)
plug_in_write_rc (const gchar *filename)
{
FILE *fp;
PlugInDef *plug_in_def;
......@@ -2327,7 +2327,7 @@ plug_in_write_rc (gchar *filename)
}
static void
plug_in_init_file (gchar *filename)
plug_in_init_file (const gchar *filename)
{
GSList *tmp;
PlugInDef *plug_in_def;
......
......@@ -88,9 +88,9 @@ typedef enum
COLOR_MODE,
VALUE_MODE,
DIVIDE_MODE,
DODGE_MODE,
BURN_MODE,
HARDLIGHT_MODE,
DODGE_MODE,
BURN_MODE,
HARDLIGHT_MODE,
ERASE_MODE, /*< skip >*/
REPLACE_MODE, /*< skip >*/
ANTI_ERASE_MODE /*< skip >*/
......@@ -152,7 +152,7 @@ typedef enum
} InterpolationType;
typedef enum /*< skip >*/
{
{
ORIENTATION_UNKNOWN,
ORIENTATION_HORIZONTAL,
ORIENTATION_VERTICAL
......@@ -203,7 +203,6 @@ typedef enum
PDB_CANCEL
} PDBStatusType;
/* Procedure types */
typedef enum /*< chop=PDB_ >*/
{
......
......@@ -140,11 +140,11 @@ brush_edit_brush_dirty_callback (GimpBrush *brush,
}
static void
brush_renamed_callback (GtkWidget *widget,
BrushEditGeneratedWindow *begw)
brush_name_changed_callback (GtkWidget *widget,
BrushEditGeneratedWindow *begw)
{
gtk_entry_set_text (GTK_ENTRY (begw->name),
gimp_brush_get_name (GIMP_BRUSH (begw->brush)));
gimp_object_get_name (GIMP_OBJECT (begw->brush)));
}
void
......@@ -178,8 +178,8 @@ brush_edit_generated_set_brush (BrushEditGeneratedWindow *begw,
gtk_signal_connect (GTK_OBJECT (brush), "dirty",
GTK_SIGNAL_FUNC (brush_edit_brush_dirty_callback),
begw);
gtk_signal_connect (GTK_OBJECT (brush), "rename",
GTK_SIGNAL_FUNC (brush_renamed_callback),
gtk_signal_connect (GTK_OBJECT (brush), "name_changed",
GTK_SIGNAL_FUNC (brush_name_changed_callback),
begw);
begw->brush = NULL;
......@@ -191,7 +191,8 @@ brush_edit_generated_set_brush (BrushEditGeneratedWindow *begw,
gimp_brush_generated_get_angle (brush));
gtk_adjustment_set_value (GTK_ADJUSTMENT (begw->aspect_ratio_data),
gimp_brush_generated_get_aspect_ratio (brush));
gtk_entry_set_text (GTK_ENTRY (begw->name), gimp_brush_get_name (gbrush));
gtk_entry_set_text (GTK_ENTRY (begw->name),
gimp_object_get_name (GIMP_OBJECT (gbrush)));
begw->brush = brush;
gtk_object_ref (GTK_OBJECT (begw->brush));
......@@ -205,7 +206,7 @@ name_changed_func (GtkWidget *widget,
gchar *entry_text;
entry_text = gtk_entry_get_text (GTK_ENTRY (widget));
gimp_brush_set_name (GIMP_BRUSH (begw->brush), entry_text);
gimp_object_set_name (GIMP_OBJECT (begw->brush), entry_text);
}
void
......
......@@ -676,10 +676,11 @@ static void
brush_change_callbacks (BrushSelect *bsp,
gboolean closing)
{
gchar *name;
gchar *name;
ProcRecord *prec = NULL;
GimpBrush *brush;
gint nreturn_vals;
GimpBrush *brush;
gint nreturn_vals;
static gboolean busy = FALSE;
/* Any procs registered to callback? */
......@@ -688,8 +689,8 @@ brush_change_callbacks (BrushSelect *bsp,
if (!bsp || !bsp->callback_name || busy)
return;
busy = TRUE;
name = bsp->callback_name;
busy = TRUE;
name = bsp->callback_name;
brush = gimp_context_get_brush (bsp->context);
/* If its still registered run it */
......@@ -700,7 +701,7 @@ brush_change_callbacks (BrushSelect *bsp,
return_vals =
procedural_db_run_proc (name,
&nreturn_vals,
PDB_STRING, brush->name,
PDB_STRING, GIMP_OBJECT (brush)->name,
PDB_FLOAT, gimp_context_get_opacity (bsp->context),
PDB_INT32, bsp->spacing_value,
PDB_INT32, (gint) gimp_context_get_paint_mode (bsp->context),
......@@ -725,9 +726,9 @@ void
brushes_check_dialogs (void)
{
BrushSelect *bsp;
GSList *list;
gchar *name;
ProcRecord *prec = NULL;
GSList *list;
gchar *name;
ProcRecord *prec = NULL;
list = brush_active_dialogs;
......@@ -896,7 +897,7 @@ connect_signals_to_brush (GimpBrush *brush,
gtk_signal_connect (GTK_OBJECT (brush), "dirty",
GTK_SIGNAL_FUNC (brush_select_brush_dirty_callback),
bsp);
gtk_signal_connect (GTK_OBJECT (brush), "rename",
gtk_signal_connect (GTK_OBJECT (brush), "name_changed",
GTK_SIGNAL_FUNC (brush_select_brush_dirty_callback),
bsp);
}
......@@ -1484,7 +1485,7 @@ update_active_brush_field (BrushSelect *bsp)
return;
/* Set brush name */
gtk_label_set_text (GTK_LABEL (bsp->brush_name), brush->name);
gtk_label_set_text (GTK_LABEL (bsp->brush_name), GIMP_OBJECT (brush)->name);
/* Set brush size */
g_snprintf (buf, sizeof (buf), "(%d x %d)",
......
......@@ -106,7 +106,7 @@ brushes_get_brush_invoker (Argument *args)
if (success)
{
return_args[1].value.pdb_pointer = g_strdup (brush->name);
return_args[1].value.pdb_pointer = g_strdup (GIMP_OBJECT (brush)->name);
return_args[2].value.pdb_int = brush->mask->width;
return_args[3].value.pdb_int = brush->mask->height;
return_args[4].value.pdb_int = brush->spacing;
......@@ -450,7 +450,7 @@ brushes_list_invoker (Argument *args)
while (list)
{
brushes[i++] = g_strdup (((GimpBrush *) list->data)->name);
brushes[i++] = g_strdup (GIMP_OBJECT (list->data)->name);
list = list->next;
}
......@@ -521,7 +521,7 @@ brushes_get_brush_data_invoker (Argument *args)
{
brush = (GimpBrush *) list->data;
if (!strcmp (brush->name, name))
if (!strcmp (GIMP_OBJECT (brush)->name, name))
{
success = TRUE;
break;
......@@ -543,7 +543,7 @@ brushes_get_brush_data_invoker (Argument *args)
if (success)
{
return_args[1].value.pdb_pointer = g_strdup (brush->name);
return_args[1].value.pdb_pointer = g_strdup (GIMP_OBJECT (brush)->name);
return_args[2].value.pdb_float = 1.0;
return_args[3].value.pdb_int = brush->spacing;
return_args[4].value.pdb_int = 0;
......
......@@ -41,28 +41,28 @@ typedef struct _GimpChannelClass GimpChannelClass;
struct _GimpChannel
{
GimpDrawable drawable;
GimpDrawable parent_instance;
guchar col[3]; /* RGB triplet for channel color */
gint opacity; /* Channel opacity */
gboolean show_masked; /* Show masked areas--as */
/* opposed to selected areas */
guchar col[3]; /* RGB triplet for channel color */
gint opacity; /* Channel opacity */
gboolean show_masked; /* Show masked areas--as */
/* opposed to selected areas */
/* Selection mask variables */
gboolean boundary_known; /* is the current boundary valid */
BoundSeg *segs_in; /* outline of selected region */
BoundSeg *segs_out; /* outline of selected region */
gint num_segs_in; /* number of lines in boundary */
gint num_segs_out; /* number of lines in boundary */
gboolean empty; /* is the region empty? */
gboolean bounds_known; /* recalculate the bounds? */
gint x1, y1; /* coordinates for bounding box */
gint x2, y2; /* lower right hand coordinate */
gboolean boundary_known; /* is the current boundary valid */
BoundSeg *segs_in; /* outline of selected region */
BoundSeg *segs_out; /* outline of selected region */
gint num_segs_in; /* number of lines in boundary */
gint num_segs_out; /* number of lines in boundary */
gboolean empty; /* is the region empty? */
gboolean bounds_known; /* recalculate the bounds? */
gint x1, y1; /* coordinates for bounding box */
gint x2, y2; /* lower right hand coordinate */
};
struct _GimpChannelClass
{
GimpDrawableClass parent_class;
GimpDrawableClass parent_class;
void (* removed) (GimpChannel *channel);
};
......
......@@ -263,7 +263,7 @@ gimp_colormap_dialog_create (GimpSet *context)
image_cmap_change_cb,
ipal);
ipal->rename_handler = gimp_set_add_handler (context,
"rename",
"name_changed",
image_rename_cb,
ipal);
......
......@@ -59,7 +59,6 @@
enum
{
DIRTY,
RENAME,
LAST_SIGNAL
};
......@@ -78,7 +77,6 @@ gimp_brush_destroy (GtkObject *object)
GimpBrush *brush = GIMP_BRUSH (object);
g_free (brush->filename);
g_free (brush->name);
if (brush->mask)
temp_buf_free (brush->mask);
......@@ -105,21 +103,11 @@ gimp_brush_class_init (GimpBrushClass *klass)
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gimp_brush_signals[RENAME] =
gtk_signal_new ("rename",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpBrushClass,
rename),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gtk_object_class_add_signals (object_class, gimp_brush_signals, LAST_SIGNAL);
object_class->destroy = gimp_brush_destroy;
klass->dirty = NULL;
klass->rename = NULL;
klass->select_brush = gimp_brush_select_brush;
klass->want_null_motion = gimp_brush_want_null_motion;
......@@ -129,7 +117,6 @@ void
gimp_brush_init (GimpBrush *brush)
{
brush->filename = NULL;
brush->name = NULL;
brush->spacing = 20;
brush->x_axis.x = 15.0;
......@@ -167,7 +154,7 @@ gimp_brush_get_type (void)
}
GimpBrush *
gimp_brush_load (gchar *filename)
gimp_brush_load (const gchar *filename)
{
GimpBrush *brush;
gint fd;
......@@ -208,7 +195,7 @@ gimp_brush_want_null_motion (PaintCore *paint_core)
}
TempBuf *
gimp_brush_get_mask (GimpBrush *brush)
gimp_brush_get_mask (const GimpBrush *brush)
{
g_return_val_if_fail (brush != NULL, NULL);
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
......@@ -217,7 +204,7 @@ gimp_brush_get_mask (GimpBrush *brush)
}
TempBuf *
gimp_brush_get_pixmap (GimpBrush *brush)
gimp_brush_get_pixmap (const GimpBrush *brush)
{
g_return_val_if_fail (brush != NULL, NULL);
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
......@@ -225,34 +212,8 @@ gimp_brush_get_pixmap (GimpBrush *brush)
return brush->pixmap;
}
gchar *
gimp_brush_get_name (GimpBrush *brush)
{
g_return_val_if_fail (brush != NULL, NULL);
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
return brush->name;
}
void
gimp_brush_set_name (GimpBrush *brush,
gchar *name)
{
g_return_if_fail (brush != NULL);
g_return_if_fail (GIMP_IS_BRUSH (brush));
if (strcmp (brush->name, name) == 0)
return;
if (brush->name)
g_free (brush->name);
brush->name = g_strdup (name);
gtk_signal_emit (GTK_OBJECT (brush), gimp_brush_signals[RENAME]);
}
gint
gimp_brush_get_spacing (GimpBrush *brush)
gimp_brush_get_spacing (const GimpBrush *brush)
{
g_return_val_if_fail (brush != NULL, 0);
g_return_val_if_fail (GIMP_IS_BRUSH (brush), 0);
......@@ -271,8 +232,8 @@ gimp_brush_set_spacing (GimpBrush *brush,
}
GimpBrush *
gimp_brush_load_brush (gint fd,
gchar *filename)
gimp_brush_load_brush (gint fd,
const gchar *filename)
{
GimpBrush *brush;
GPattern *pattern;
......@@ -285,7 +246,7 @@ gimp_brush_load_brush (gint fd,
g_return_val_if_fail (fd != -1, NULL);
/* Read in the header size */
if (read (fd, &header, sizeof (header)) != sizeof (header))
if (read (fd, &header, sizeof (header)) != sizeof (header))
return NULL;
/* rearrange the bytes in each unsigned int */
......@@ -335,10 +296,10 @@ gimp_brush_load_brush (gint fd,
switch (header.bytes)
{
case 1:
brush = GIMP_BRUSH (gtk_type_new (gimp_brush_get_type ()));
brush = GIMP_BRUSH (gtk_type_new (GIMP_TYPE_BRUSH));
brush->mask = temp_buf_new (header.width, header.height, 1,
0, 0, NULL);
if (read (fd,
if (read (fd,
temp_buf_data (brush->mask), header.width * header.height) <
header.width * header.height)
{
......@@ -348,7 +309,7 @@ gimp_brush_load_brush (gint fd,
gtk_object_unref (GTK_OBJECT (brush));
return NULL;
}
/* For backwards-compatibility, check if a pattern follows.
The obsolete .gpb format did it this way. */
pattern = pattern_load (fd, filename);
......@@ -377,13 +338,13 @@ gimp_brush_load_brush (gint fd,
break;
case 4:
brush = GIMP_BRUSH (gtk_type_new (gimp_brush_get_type ()));
brush = GIMP_BRUSH (gtk_type_new (GIMP_TYPE_BRUSH));
brush->mask = temp_buf_new (header.width, header.height, 1, 0, 0, NULL);
brush->pixmap = temp_buf_new (header.width, header.height, 3, 0, 0, NULL);
for (i = 0; i < header.width * header.height; i++)
{
if (read (fd, temp_buf_data (brush->pixmap)
if (read (fd, temp_buf_data (brush->pixmap)
+ i * 3, 3) != 3 ||
read (fd, temp_buf_data (brush->mask) + i, 1) != 1)
{
......@@ -403,7 +364,10 @@ gimp_brush_load_brush (gint fd,
return NULL;
}
brush->name = name;
gimp_object_set_name (GIMP_OBJECT (brush), name);
g_free (name);
brush->spacing = header.spacing;
brush->x_axis.x = header.width / 2.0;
brush->x_axis.y = 0.0;
......
......@@ -59,7 +59,6 @@
enum
{
DIRTY,
RENAME,
LAST_SIGNAL
};
......@@ -78,7 +77,6 @@ gimp_brush_destroy (GtkObject *object)
GimpBrush *brush = GIMP_BRUSH (object);
g_free (brush->filename);
g_free (brush->name);
if (brush->mask)
temp_buf_free (brush->mask);
......@@ -105,21 +103,11 @@ gimp_brush_class_init (GimpBrushClass *klass)
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gimp_brush_signals[RENAME] =
gtk_signal_new ("rename",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpBrushClass,
rename),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gtk_object_class_add_signals (object_class, gimp_brush_signals, LAST_SIGNAL);
object_class->destroy = gimp_brush_destroy;
klass->dirty = NULL;
klass->rename = NULL;
klass->select_brush = gimp_brush_select_brush;
klass->want_null_motion = gimp_brush_want_null_motion;
......@@ -129,7 +117,6 @@ void
gimp_brush_init (GimpBrush *brush)
{
brush->filename = NULL;
brush->name = NULL;
brush->spacing = 20;
brush->x_axis.x = 15.0;
......@@ -167,7 +154,7 @@ gimp_brush_get_type (void)
}
GimpBrush *
gimp_brush_load (gchar *filename)
gimp_brush_load (const gchar *filename)
{
GimpBrush *brush;
gint fd;
......@@ -208,7 +195,7 @@ gimp_brush_want_null_motion (PaintCore *paint_core)
}
TempBuf *
gimp_brush_get_mask (GimpBrush *brush)
gimp_brush_get_mask (const GimpBrush *brush)
{
g_return_val_if_fail (brush != NULL, NULL);
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
......@@ -217,7 +204,7 @@ gimp_brush_get_mask (GimpBrush *brush)
}
TempBuf *
gimp_brush_get_pixmap (GimpBrush *brush)
gimp_brush_get_pixmap (const GimpBrush *brush)
{
g_return_val_if_fail (brush != NULL, NULL);
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
......@@ -225,34 +212,8 @@ gimp_brush_get_pixmap (GimpBrush *brush)
return brush->pixmap;
}
gchar *
gimp_brush_get_name (GimpBrush *brush)
{
g_return_val_if_fail (brush != NULL, NULL);
g_return_val_if_fail (GIMP_IS_BRUSH (brush), NULL);
return brush->name;
}
void
gimp_brush_set_name (GimpBrush *brush,
gchar *name)
{
g_return_if_fail (brush != NULL);
g_return_if_fail (GIMP_IS_BRUSH (brush));
if (strcmp (brush->name, name) == 0)
return;
if (brush->name)
g_free (brush->name);
brush->name = g_strdup (name);
gtk_signal_emit (GTK_OBJECT (brush), gimp_brush_signals[RENAME]);
}
gint
gimp_brush_get_spacing (GimpBrush *brush)
gimp_brush_get_spacing (const GimpBrush *brush)
{
g_return_val_if_fail (brush != NULL, 0);
g_return_val_if_fail (GIMP_IS_BRUSH (brush), 0);
......@@ -271,8 +232,8 @@ gimp_brush_set_spacing (GimpBrush *brush,
}
GimpBrush *
gimp_brush_load_brush (gint fd,
gchar *filename)
gimp_brush_load_brush (gint fd,
const gchar *filename)
{
GimpBrush *brush;
GPattern *pattern;
......@@ -285,7 +246,7 @@ gimp_brush_load_brush (gint fd,
g_return_val_if_fail (fd != -1, NULL);
/* Read in the header size */
if (read (fd, &header, sizeof (header)) != sizeof (header))