1998-07-12 19:40:43 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
2000-09-29 20:00:00 +08:00
|
|
|
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
|
1998-07-12 19:40:43 +08:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2000-09-29 20:00:00 +08:00
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1998-08-14 02:53:12 +08:00
|
|
|
#include <stdio.h>
|
2000-09-29 20:00:00 +08:00
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "apptypes.h"
|
|
|
|
|
|
|
|
#include "gimpobject.h"
|
1998-07-12 19:40:43 +08:00
|
|
|
#include "gimpsignal.h"
|
Jens Lautenbacher <jtl@gimp.org>
2000-12-18 Sven Neumann <sven@gimp.org>
Jens Lautenbacher <jtl@gimp.org>
* app/Makefile.am
* app/gimpbrushlistP.h
* app/gimpbrushpipeP.h
* app/gimpobjectP.h: removed these three files
* app/parasitelistP.h
* app/channels_dialog.c
* app/docindex.c
* app/gimpdrawable.c
* app/gimpdrawableP.h
* app/gimpimage.c
* app/gimpimageP.h
* app/gimplist.[ch]
* app/gimpobject.c
* app/gimpobject.h
* app/gimpsetP.h: changed according to header removal
* app/airbrush.c
* app/brush_select.[ch]
* app/brushes_cmds.c
* app/gimpbrush.[ch]
* app/gimpbrushgenerated.[ch]
* app/gimpbrushlist.[ch]
* app/gimpbrushpipe.[ch]
* app/gimpcontextpreview.c
* app/paint_core.c
* app/paintbrush.c
* app/pencil.c
* tools/pdbgen/pdb/brushes.pdb: Big Brushes Cleanup.
The GimpBrush* object hierarchy and the file formats were broken by
"design". This made it overly difficult to read and write pixmap
brushes and brush pipes, leading to the situation that The GIMP was
not able to read it's very own file formats. Since the GimpBrush
format did support arbitrary color depths, the introduction of a
file format for pixmap brushes was unnecessary.
The GimpBrushPixmap object is dead. GimpBrush has an additional
pixmap temp_buf and handles pixmap brushes transparently. The file
format of pixmap brushes is not any longer a grayscale brush plus
a pattern, but a simple brush with RGBA data. The old brushes can
still be loaded, but the .gpb format is deprecated.
GimpBrushPipe derives from GimpBrush. The fileformat is still a text
header, followed by a number of brushes, but those brushes are stored
in the new GimpBrush format (no pattern anymore). The pipe does not
care about the depth of the contained GimpBrushes, so we get
grayscale BrushPipes for free. Since the brush loader still loads the
old format, old .gih files can also still be loaded.
Since the brushes in the GimpBrushPipe do not any longer contain a
pointer to the pipe object, we do only temporarily switch brushes
in the paint_core routines. This is not very elegant, but the best
we can do without a major redesign.
* app/patterns.[ch]: changed the loader to work with a filedescriptor
instead of a filehandle to make it work with the new brush loading
code.
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/gih.c: new plug-in that saves GIH files in the
new format (loader will follow soon)
* plug-ins/common/gpb.c: removed since Pixmap Brushes are no longer
supported as a special file format.
* plug-ins/common/gbr.c: load and save brushes in the new brush format
which allows RGBA brushes too.
* plug-ins/common/pat.c: load and save grayscale patterns too
2000-12-18 23:14:08 +08:00
|
|
|
#include "gimplist.h"
|
1998-07-12 19:40:43 +08:00
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2000-09-29 20:00:00 +08:00
|
|
|
/* code mostly ripped from nether's gimpset class */
|
1998-07-12 19:40:43 +08:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
ADD,
|
|
|
|
REMOVE,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2000-09-29 20:00:00 +08:00
|
|
|
static guint gimp_list_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
|
|
static GimpObjectClass *parent_class = NULL;
|
1998-07-12 19:40:43 +08:00
|
|
|
|
|
|
|
|
2000-09-29 20:00:00 +08:00
|
|
|
static void gimp_list_add_func (GimpList *list,
|
|
|
|
gpointer object);
|
|
|
|
static void gimp_list_remove_func (GimpList *list,
|
|
|
|
gpointer object);
|
|
|
|
|
1998-07-12 19:40:43 +08:00
|
|
|
|
|
|
|
static void
|
2000-09-29 20:00:00 +08:00
|
|
|
gimp_list_destroy (GtkObject *object)
|
1998-07-12 19:40:43 +08:00
|
|
|
{
|
2000-09-29 20:00:00 +08:00
|
|
|
GimpList *list = GIMP_LIST (object);
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
while (list->list) /* ought to put a sanity check in here... */
|
|
|
|
{
|
|
|
|
gimp_list_remove (list, list->list->data);
|
|
|
|
}
|
|
|
|
g_slist_free (list->list);
|
2000-09-29 20:00:00 +08:00
|
|
|
|
|
|
|
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
|
|
|
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
1998-07-12 19:40:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-09-29 20:00:00 +08:00
|
|
|
gimp_list_init (GimpList *list)
|
1998-07-12 19:40:43 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
list->list = NULL;
|
|
|
|
list->type = GTK_TYPE_OBJECT;
|
1998-07-12 19:40:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-09-29 20:00:00 +08:00
|
|
|
gimp_list_class_init (GimpListClass *klass)
|
1998-07-12 19:40:43 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
|
|
|
|
GtkType type = object_class->type;
|
1998-07-12 19:40:43 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
parent_class = gtk_type_parent_class (type);
|
2000-09-29 20:00:00 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
object_class->destroy = gimp_list_destroy;
|
2000-09-29 20:00:00 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
gimp_list_signals[ADD]=
|
|
|
|
gimp_signal_new ("add", GTK_RUN_FIRST, type, 0,
|
|
|
|
gimp_sigtype_pointer);
|
|
|
|
gimp_list_signals[REMOVE]=
|
|
|
|
gimp_signal_new ("remove", GTK_RUN_FIRST, type, 0,
|
|
|
|
gimp_sigtype_pointer);
|
|
|
|
|
|
|
|
gtk_object_class_add_signals (object_class,
|
|
|
|
gimp_list_signals,
|
|
|
|
LAST_SIGNAL);
|
|
|
|
|
|
|
|
klass->add = gimp_list_add_func;
|
|
|
|
klass->remove = gimp_list_remove_func;
|
1998-07-12 19:40:43 +08:00
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
GtkType
|
|
|
|
gimp_list_get_type (void)
|
1998-07-12 19:40:43 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
static GtkType type;
|
|
|
|
|
|
|
|
GIMP_TYPE_INIT (type,
|
|
|
|
GimpList,
|
|
|
|
GimpListClass,
|
|
|
|
gimp_list_init,
|
|
|
|
gimp_list_class_init,
|
|
|
|
GIMP_TYPE_OBJECT);
|
1998-07-12 19:40:43 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
return type;
|
|
|
|
}
|
1998-07-12 19:40:43 +08:00
|
|
|
|
2000-09-29 20:00:00 +08:00
|
|
|
GimpList *
|
1999-10-27 02:27:27 +08:00
|
|
|
gimp_list_new (GtkType type,
|
|
|
|
gboolean weak)
|
|
|
|
{
|
2000-09-29 20:00:00 +08:00
|
|
|
GimpList *list;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
list = gtk_type_new (gimp_list_get_type ());
|
|
|
|
|
|
|
|
list->type = type;
|
|
|
|
list->weak = weak;
|
|
|
|
|
|
|
|
return list;
|
1998-07-12 19:40:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-09-29 20:00:00 +08:00
|
|
|
gimp_list_destroy_cb (GtkObject *object,
|
1999-10-27 02:27:27 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
2000-09-29 20:00:00 +08:00
|
|
|
GimpList *list;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
list = GIMP_LIST (data);
|
|
|
|
|
2000-09-29 20:00:00 +08:00
|
|
|
gimp_list_remove (list, object);
|
1998-07-12 19:40:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-10-27 02:27:27 +08:00
|
|
|
gimp_list_add_func (GimpList *list,
|
2000-09-29 20:00:00 +08:00
|
|
|
gpointer object)
|
1998-07-12 19:40:43 +08:00
|
|
|
{
|
2000-09-29 20:00:00 +08:00
|
|
|
list->list = g_slist_prepend (list->list, object);
|
1998-07-12 19:40:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-10-27 02:27:27 +08:00
|
|
|
gimp_list_remove_func (GimpList *list,
|
2000-09-29 20:00:00 +08:00
|
|
|
gpointer object)
|
1998-07-12 19:40:43 +08:00
|
|
|
{
|
2000-09-29 20:00:00 +08:00
|
|
|
list->list = g_slist_remove (list->list, object);
|
1998-07-12 19:40:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
1999-10-27 02:27:27 +08:00
|
|
|
gimp_list_add (GimpList *list,
|
2000-09-29 20:00:00 +08:00
|
|
|
gpointer object)
|
1998-07-12 19:40:43 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
g_return_val_if_fail (list, FALSE);
|
2000-09-29 20:00:00 +08:00
|
|
|
g_return_val_if_fail (GTK_CHECK_TYPE (object, list->type), FALSE);
|
1998-07-12 19:40:43 +08:00
|
|
|
|
2000-09-29 20:00:00 +08:00
|
|
|
if (g_slist_find (list->list, object))
|
1998-07-12 19:40:43 +08:00
|
|
|
return FALSE;
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
if (list->weak)
|
2000-09-29 20:00:00 +08:00
|
|
|
{
|
|
|
|
gtk_signal_connect (GTK_OBJECT (object), "destroy",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_list_destroy_cb),
|
|
|
|
list);
|
|
|
|
}
|
1998-07-12 19:40:43 +08:00
|
|
|
else
|
2000-09-29 20:00:00 +08:00
|
|
|
{
|
|
|
|
gtk_object_ref (GTK_OBJECT (object));
|
|
|
|
gtk_object_sink (GTK_OBJECT (object));
|
|
|
|
}
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2000-09-29 20:00:00 +08:00
|
|
|
GIMP_LIST_CLASS (GTK_OBJECT (list)->klass)->add (list, object);
|
1998-07-24 16:56:18 +08:00
|
|
|
|
2000-09-29 20:00:00 +08:00
|
|
|
gtk_signal_emit (GTK_OBJECT(list), gimp_list_signals[ADD], object);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1998-07-12 19:40:43 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
1999-10-27 02:27:27 +08:00
|
|
|
gimp_list_remove (GimpList *list,
|
2000-09-29 20:00:00 +08:00
|
|
|
gpointer object)
|
1998-07-12 19:40:43 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
g_return_val_if_fail (list, FALSE);
|
|
|
|
|
2000-09-29 20:00:00 +08:00
|
|
|
if (!g_slist_find (list->list, object))
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2000-09-29 20:00:00 +08:00
|
|
|
g_warning ("gimp_list_remove: can't find val");
|
1999-10-27 02:27:27 +08:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-09-29 20:00:00 +08:00
|
|
|
GIMP_LIST_CLASS (GTK_OBJECT (list)->klass)->remove (list, object);
|
|
|
|
|
|
|
|
gtk_signal_emit (GTK_OBJECT (list), gimp_list_signals[REMOVE], object);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
if (list->weak)
|
2000-09-29 20:00:00 +08:00
|
|
|
{
|
|
|
|
gtk_signal_disconnect_by_func (GTK_OBJECT (object),
|
|
|
|
GTK_SIGNAL_FUNC (gimp_list_destroy_cb),
|
|
|
|
list);
|
|
|
|
}
|
1999-10-27 02:27:27 +08:00
|
|
|
else
|
2000-09-29 20:00:00 +08:00
|
|
|
{
|
|
|
|
gtk_object_unref (GTK_OBJECT (object));
|
|
|
|
}
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
return TRUE;
|
1998-07-12 19:40:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
1999-10-27 02:27:27 +08:00
|
|
|
gimp_list_have (GimpList *list,
|
2000-09-29 20:00:00 +08:00
|
|
|
gpointer object)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2000-09-29 20:00:00 +08:00
|
|
|
return g_slist_find (list->list, object) ? TRUE : FALSE;
|
1998-07-12 19:40:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-10-27 02:27:27 +08:00
|
|
|
gimp_list_foreach (GimpList *list,
|
|
|
|
GFunc func,
|
|
|
|
gpointer user_data)
|
1998-07-12 19:40:43 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
g_slist_foreach (list->list, func, user_data);
|
1998-07-12 19:40:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkType
|
1999-10-27 02:27:27 +08:00
|
|
|
gimp_list_type (GimpList *list)
|
|
|
|
{
|
|
|
|
return list->type;
|
1998-07-12 19:40:43 +08:00
|
|
|
}
|