Started gimpset, a generic class for handling collections of

objects. (And to automatically manage their signals, not implemented
yet)

Moved drawable_apply_image to drawable.c

Created a global context object (image_context) to handle the
collection of images that the app manages.
This commit is contained in:
Lauri Alanko 1998-07-01 23:06:49 +00:00
parent 52087b374e
commit 6a02cda396
38 changed files with 355 additions and 133 deletions

View File

@ -1,3 +1,34 @@
Thu Jul 2 01:45:24 EEST 1998 Lauri Alanko <nether@gimp.org>
* app/Makefile.am:
* app/gimpset(.c|[FP]?.h):
Started gimpset, a generic class for handling collections of
objects. (And to automatically manage their signals, not
implemented yet)
* app/drawable.[ch]
* app/gimpdrawable.[ch]
* app/gimpimage.c:
Moved drawable_apply_image to drawable.c
* app/app_procs.c
* app/appenv.h
* app/gimage.[ch]
* app/layers_dialog.c
* app/main.c
* app/procedural_db.c:
Created a global context object (image_context) to handle the
collection of images that the app manages.
* app/gimpobject.c:
* app/layer.h: Nothing major.
* app/move.c: Fixed an uninitialized var that made guides crash.
* app/tools.h: Removed an unused and conflicting X define.
Wed Jul 1 14:55:21 PDT 1998 Manish Singh <yosh@gimp.org>
* added waterselect plug-in

View File

@ -5,7 +5,7 @@ scriptdata =
bin_PROGRAMS = gimp
noinst_LIBRARIES = libgimpim.a
libgimpim_a_SOURCES = gimpobject.c gimpimage.c gimpsignal.c gimpdrawable.c
libgimpim_a_SOURCES = gimpobject.c gimpimage.c gimpset.c gimpsignal.c gimpdrawable.c
gimp_SOURCES = \
about_dialog.c \
@ -317,6 +317,7 @@ LDADD = \
-lc
DEPS = \
libgimpim.a \
$(top_builddir)/libgimp/libgimpi.a
gimp_DEPENDENCIES = $(DEPS)

View File

@ -35,6 +35,7 @@
#include "colormaps.h"
#include "fileops.h"
#include "gimprc.h"
#include "gimpset.h"
#include "global_edit.h"
#include "gradient.h"
#include "gximage.h"
@ -456,7 +457,11 @@ app_init (void)
if (no_interface == FALSE && no_splash == FALSE && win_initstatus) {
splash_text_draw (logo_area);
}
/* Create the context of all existing images */
image_context=gimp_set_new(GIMP_TYPE_IMAGE, TRUE);
/*
* Initialize the procedural database
* We need to do this first because any of the init

View File

@ -20,6 +20,7 @@
#include "gdk/gdkx.h"
#include "gtk/gtk.h"
#include "gimpsetF.h"
#define DISPLAY ((Display *) GDK_DISPLAY())
@ -40,6 +41,7 @@ extern int no_data;
extern int be_verbose;
extern int use_debug_handler;
extern int console_messages;
extern GimpSet* image_context;
extern MessageHandlerType message_handler;

View File

@ -20,7 +20,6 @@
#include "gimpsignal.h"
#include "gimage.h"
#include "gimage_mask.h"
#include "undo.h"
enum {
@ -90,22 +89,6 @@ gimp_drawable_get_ID (int drawable_id)
(gpointer) drawable_id);
}
void
gimp_drawable_apply_image (GimpDrawable *drawable,
int x1, int y1, int x2, int y2,
TileManager *tiles, int sparse)
{
if (drawable)
{
if (! tiles)
undo_push_image (drawable->gimage, drawable,
x1, y1, x2, y2);
else
undo_push_image_mod (drawable->gimage, drawable,
x1, y1, x2, y2, tiles, sparse);
}
}
void
gimp_drawable_merge_shadow (GimpDrawable *drawable, int undo)

View File

@ -40,9 +40,6 @@ typedef enum
/* drawable access functions */
void gimp_drawable_apply_image (GimpDrawable *,
int, int, int, int,
TileManager *, int);
void gimp_drawable_merge_shadow (GimpDrawable *, int);
void gimp_drawable_fill (GimpDrawable *drawable, guchar r, guchar g,
guchar b, guchar a);

View File

@ -506,7 +506,7 @@ gimp_image_apply_image (GimpImage *gimage, GimpDrawable *drawable, PixelRegion *
/* If the calling procedure specified an undo step... */
if (undo)
drawable_apply_image (drawable, x1, y1, x2, y2, NULL, FALSE);
undo_push_image (gimp_drawable_gimage(drawable), drawable, x1, y1, x2, y2);
/* configure the pixel regions
* If an alternative to using the drawable's data as src1 was provided...

View File

@ -506,7 +506,7 @@ gimp_image_apply_image (GimpImage *gimage, GimpDrawable *drawable, PixelRegion *
/* If the calling procedure specified an undo step... */
if (undo)
drawable_apply_image (drawable, x1, y1, x2, y2, NULL, FALSE);
undo_push_image (gimp_drawable_gimage(drawable), drawable, x1, y1, x2, y2);
/* configure the pixel regions
* If an alternative to using the drawable's data as src1 was provided...

View File

@ -506,7 +506,7 @@ gimp_image_apply_image (GimpImage *gimage, GimpDrawable *drawable, PixelRegion *
/* If the calling procedure specified an undo step... */
if (undo)
drawable_apply_image (drawable, x1, y1, x2, y2, NULL, FALSE);
undo_push_image (gimp_drawable_gimage(drawable), drawable, x1, y1, x2, y2);
/* configure the pixel regions
* If an alternative to using the drawable's data as src1 was provided...

View File

@ -506,7 +506,7 @@ gimp_image_apply_image (GimpImage *gimage, GimpDrawable *drawable, PixelRegion *
/* If the calling procedure specified an undo step... */
if (undo)
drawable_apply_image (drawable, x1, y1, x2, y2, NULL, FALSE);
undo_push_image (gimp_drawable_gimage(drawable), drawable, x1, y1, x2, y2);
/* configure the pixel regions
* If an alternative to using the drawable's data as src1 was provided...

View File

@ -506,7 +506,7 @@ gimp_image_apply_image (GimpImage *gimage, GimpDrawable *drawable, PixelRegion *
/* If the calling procedure specified an undo step... */
if (undo)
drawable_apply_image (drawable, x1, y1, x2, y2, NULL, FALSE);
undo_push_image (gimp_drawable_gimage(drawable), drawable, x1, y1, x2, y2);
/* configure the pixel regions
* If an alternative to using the drawable's data as src1 was provided...

View File

@ -506,7 +506,7 @@ gimp_image_apply_image (GimpImage *gimage, GimpDrawable *drawable, PixelRegion *
/* If the calling procedure specified an undo step... */
if (undo)
drawable_apply_image (drawable, x1, y1, x2, y2, NULL, FALSE);
undo_push_image (gimp_drawable_gimage(drawable), drawable, x1, y1, x2, y2);
/* configure the pixel regions
* If an alternative to using the drawable's data as src1 was provided...

View File

@ -138,9 +138,6 @@ TempBuf * layer_mask_preview (Layer *, int, int);
void layer_invalidate_previews (GimpImage*);
/* temp thingies.. dynamic downcast. GTK_NO_CHECK_CASTS must not be
defined */
#define drawable_layer GIMP_IS_LAYER
#define drawable_layer_mask GIMP_IS_LAYER_MASK

View File

@ -10,10 +10,6 @@ gimp_object_class_init (GimpObjectClass *gobjectclass)
{
}
GtkType gimp_object_get_type (void)
{
static GtkType type;
@ -26,3 +22,7 @@ GtkType gimp_object_get_type (void)
return type;
}

View File

@ -506,7 +506,7 @@ gimp_image_apply_image (GimpImage *gimage, GimpDrawable *drawable, PixelRegion *
/* If the calling procedure specified an undo step... */
if (undo)
drawable_apply_image (drawable, x1, y1, x2, y2, NULL, FALSE);
undo_push_image (gimp_drawable_gimage(drawable), drawable, x1, y1, x2, y2);
/* configure the pixel regions
* If an alternative to using the drawable's data as src1 was provided...

View File

@ -22,6 +22,7 @@
#include "palette.h"
#include "gimpimageF.h"
#include "gdisplay.h"
#include "undo.h"
int
drawable_ID (GimpDrawable *drawable)
@ -72,3 +73,20 @@ drawable_update (GimpDrawable *drawable, int x, int y, int w, int h)
/* invalidate the preview */
gimp_drawable_invalidate_preview (drawable);
}
void
drawable_apply_image (GimpDrawable *drawable,
int x1, int y1, int x2, int y2,
TileManager *tiles, int sparse)
{
if (drawable)
{
if (! tiles)
undo_push_image (drawable->gimage, drawable,
x1, y1, x2, y2);
else
undo_push_image_mod (drawable->gimage, drawable,
x1, y1, x2, y2, tiles, sparse);
}
}

View File

@ -23,9 +23,10 @@
int drawable_ID (GimpDrawable *);
void drawable_fill (GimpDrawable *drawable, int fill_type);
void drawable_update (GimpDrawable *drawable, int x, int y, int w, int h);
void drawable_apply_image (GimpDrawable *, int, int, int, int,
TileManager *, int);
#define drawable_apply_image gimp_drawable_apply_image
#define drawable_merge_shadow gimp_drawable_merge_shadow
#define drawable_mask_bounds gimp_drawable_mask_bounds
#define drawable_invalidate_preview gimp_drawable_invalidate_preview

View File

@ -18,6 +18,8 @@
#include "channel.h"
#include "tools.h"
#include "general.h"
#include "appenv.h"
#include "gimpset.h"
/* gimage.c: Junk (ugly dependencies) from gimpimage.c on its way
to proper places. That is, the handlers should be moved to
@ -30,11 +32,6 @@ static void gimage_resize_handler (GimpImage* gimage);
static void gimage_restructure_handler (GimpImage* gimage);
static void gimage_repaint_handler (GimpImage* gimage, gint, gint, gint, gint);
/* This is the app's global context of "all images".. This should be
unglobalized, too */
static GSList* image_list;
GImage*
gimage_new(int width, int height, GimpImageBaseType base_type)
{
@ -53,9 +50,8 @@ gimage_new(int width, int height, GimpImageBaseType base_type)
gtk_signal_connect (GTK_OBJECT (gimage), "repaint",
GTK_SIGNAL_FUNC(gimage_repaint_handler), NULL);
image_list=g_slist_prepend(image_list, gimage);
pdb_add_image(gimage);
lc_dialog_update_image_list ();
gimp_set_add(image_context, gimage);
indexed_palette_update_image_list ();
return gimage;
}
@ -79,19 +75,17 @@ gimage_delete (GImage *gimage)
gtk_object_unref (GTK_OBJECT(gimage));
};
static void
invalidate_cb(gpointer image, gpointer user_data){
gimp_image_invalidate_preview(GIMP_IMAGE(image));
}
void
gimage_invalidate_previews (void)
{
GSList *tmp = image_list;
GimpImage *gimage;
while (tmp)
{
gimage = (GimpImage *) tmp->data;
gimp_image_invalidate_preview (gimage);
tmp = g_slist_next (tmp);
}
gimp_set_foreach(image_context, invalidate_cb, NULL);
}
static void
gimage_dirty_handler (GimpImage* gimage){
if (active_tool && !active_tool->preserve) {
@ -112,10 +106,6 @@ gimage_destroy_handler (GimpImage* gimage)
/* free the undo list */
undo_free (gimage);
pdb_remove_image(gimage);
image_list=g_slist_remove(image_list, gimage);
lc_dialog_update_image_list ();
indexed_palette_update_image_list ();
}
@ -207,26 +197,6 @@ gimage_set_layer_mask_show (GImage *gimage, GimpLayer* layer)
void
gimage_foreach (GFunc func, gpointer user_data){
GSList* l;
for(l=image_list;l;l=l->next)
func(l->data, user_data);
}
GImage *
gimage_get_named (gchar *name)
{
GSList *tmp = image_list;
GimpImage *gimage;
char *str;
while (tmp)
{
gimage = tmp->data;
str = prune_filename (gimp_image_filename (gimage));
if (strcmp (str, name) == 0)
return gimage;
tmp = g_slist_next (tmp);
}
return NULL;
gimp_set_foreach(image_context, func, user_data);
}

View File

@ -48,8 +48,6 @@ gimage_set_layer_mask_show (GImage *gimage, GimpLayer* layer);
void
gimage_foreach (GFunc func, gpointer user_data);
GImage * gimage_get_named (gchar *name);
#define gimage_set_filename gimp_image_set_filename
#define gimage_resize gimp_image_resize

View File

@ -20,7 +20,6 @@
#include "gimpsignal.h"
#include "gimage.h"
#include "gimage_mask.h"
#include "undo.h"
enum {
@ -90,22 +89,6 @@ gimp_drawable_get_ID (int drawable_id)
(gpointer) drawable_id);
}
void
gimp_drawable_apply_image (GimpDrawable *drawable,
int x1, int y1, int x2, int y2,
TileManager *tiles, int sparse)
{
if (drawable)
{
if (! tiles)
undo_push_image (drawable->gimage, drawable,
x1, y1, x2, y2);
else
undo_push_image_mod (drawable->gimage, drawable,
x1, y1, x2, y2, tiles, sparse);
}
}
void
gimp_drawable_merge_shadow (GimpDrawable *drawable, int undo)

View File

@ -40,9 +40,6 @@ typedef enum
/* drawable access functions */
void gimp_drawable_apply_image (GimpDrawable *,
int, int, int, int,
TileManager *, int);
void gimp_drawable_merge_shadow (GimpDrawable *, int);
void gimp_drawable_fill (GimpDrawable *drawable, guchar r, guchar g,
guchar b, guchar a);

View File

@ -506,7 +506,7 @@ gimp_image_apply_image (GimpImage *gimage, GimpDrawable *drawable, PixelRegion *
/* If the calling procedure specified an undo step... */
if (undo)
drawable_apply_image (drawable, x1, y1, x2, y2, NULL, FALSE);
undo_push_image (gimp_drawable_gimage(drawable), drawable, x1, y1, x2, y2);
/* configure the pixel regions
* If an alternative to using the drawable's data as src1 was provided...

View File

@ -138,9 +138,6 @@ TempBuf * layer_mask_preview (Layer *, int, int);
void layer_invalidate_previews (GimpImage*);
/* temp thingies.. dynamic downcast. GTK_NO_CHECK_CASTS must not be
defined */
#define drawable_layer GIMP_IS_LAYER
#define drawable_layer_mask GIMP_IS_LAYER_MASK

View File

@ -10,10 +10,6 @@ gimp_object_class_init (GimpObjectClass *gobjectclass)
{
}
GtkType gimp_object_get_type (void)
{
static GtkType type;
@ -26,3 +22,7 @@ GtkType gimp_object_get_type (void)
return type;
}

142
app/gimpset.c Normal file
View File

@ -0,0 +1,142 @@
#include "gimpsignal.h"
#include "gimpsetP.h"
/* Yep, this can be optimized quite a lot */
enum
{
ADD,
REMOVE,
LAST_SIGNAL
};
static guint gimp_set_signals [LAST_SIGNAL];
static GimpObjectClass* parent_class;
static void
gimp_set_destroy (GtkObject* ob)
{
GimpSet* set=GIMP_SET(ob);
GSList* node;
for(node=set->list;node;node=node->next){
if(!set->weak)
gtk_object_unref(GTK_OBJECT(node->data));
gtk_signal_emit (GTK_OBJECT(set),
gimp_set_signals[REMOVE],
node->data);
}
g_slist_free(set->list);
GTK_OBJECT_CLASS(parent_class)->destroy (ob);
}
static void
gimp_set_init (GimpSet* set)
{
set->list=NULL;
set->type=GTK_TYPE_OBJECT;
}
static void
gimp_set_class_init (GimpSetClass* klass)
{
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkType type = object_class->type;
parent_class=gtk_type_parent_class(type);
object_class->destroy = gimp_set_destroy;
gimp_set_signals[ADD]=
gimp_signal_new ("add", 0, type, 0, gimp_sigtype_pointer);
gimp_set_signals[REMOVE]=
gimp_signal_new ("remove", 0, type, 0, gimp_sigtype_pointer);
gtk_object_class_add_signals (object_class,
gimp_set_signals,
LAST_SIGNAL);
}
GtkType gimp_set_get_type (void)
{
static GtkType type;
GIMP_TYPE_INIT(type,
GimpSet,
GimpSetClass,
gimp_set_init,
gimp_set_class_init,
GIMP_TYPE_OBJECT);
return type;
}
GimpSet*
gimp_set_new (GtkType type, gboolean weak){
GimpSet* set=gtk_type_new (gimp_set_get_type ());
set->type=type;
set->weak=weak;
return set;
}
static void
gimp_set_destroy_cb (GtkObject* ob, gpointer data){
GimpSet* set=GIMP_SET(data);
gimp_set_remove(set, ob);
}
gboolean
gimp_set_add (GimpSet* set, gpointer val)
{
g_return_val_if_fail(set, FALSE);
g_return_val_if_fail(GTK_CHECK_TYPE(val, set->type), FALSE);
if(g_slist_find(set->list, val))
return FALSE;
set->list=g_slist_prepend(set->list, val);
if(set->weak)
gtk_signal_connect(GTK_OBJECT(val), "destroy",
GTK_SIGNAL_FUNC(gimp_set_destroy_cb), set);
else
gtk_object_ref(GTK_OBJECT(val));
gtk_signal_emit (GTK_OBJECT(set), gimp_set_signals[ADD], val);
return TRUE;
}
gboolean
gimp_set_remove (GimpSet* set, gpointer val) {
g_return_val_if_fail(set, FALSE);
if(!g_slist_find(set->list, val))
return FALSE;
set->list=g_slist_remove(set->list, val);
gtk_signal_emit (GTK_OBJECT(set), gimp_set_signals[REMOVE], val);
if(set->weak)
gtk_signal_disconnect_by_func
(GTK_OBJECT(val),
GTK_SIGNAL_FUNC(gimp_set_destroy_cb),
set);
else
gtk_object_unref(GTK_OBJECT(val));
return TRUE;
}
gboolean
gimp_set_have (GimpSet* set, gpointer val) {
return g_slist_find(set->list, val)?TRUE:FALSE;
}
void
gimp_set_foreach(GimpSet* set, GFunc func, gpointer user_data)
{
g_slist_foreach(set->list, func, user_data);
}
GtkType
gimp_set_type (GimpSet* set){
return set->type;
}

38
app/gimpset.h Normal file
View File

@ -0,0 +1,38 @@
#ifndef __GIMPSET_H__
#define __GIMPSET_H__
#include <glib.h>
#include "gimpsetF.h"
/* GimpSet - a typed set of objects with signals for adding and
removing of stuff. If it is weak, destroyed objects get removed
automatically. If it is not, it refs them so they won't be freed
till they are removed. (Though they can be destroyed, of course) */
#define GIMP_TYPE_SET gimp_set_get_type()
#define GIMP_SET(obj) GTK_CHECK_CAST (obj, GIMP_TYPE_SET, GimpSet)
#define GIMP_IS_SET(obj) GTK_CHECK_TYPE (obj, gimp_set_get_type())
/* Signals:
add
remove
*/
guint gimp_set_get_type (void);
GimpSet* gimp_set_new (GtkType type, gboolean weak);
GtkType gimp_set_type (GimpSet* set);
gboolean gimp_set_add (GimpSet* gimpset, gpointer ob);
gboolean gimp_set_remove (GimpSet* gimpset, gpointer ob);
gboolean gimp_set_have (GimpSet* gimpset, gpointer ob);
void gimp_set_foreach(GimpSet* gimpset, GFunc func,
gpointer user_data);
gint gimp_set_size (GimpSet* gimpset);
#endif

6
app/gimpsetF.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef __GIMPSETF_H__
#define __GIMPSETF_H__
typedef struct _GimpSet GimpSet;
#endif

23
app/gimpsetP.h Normal file
View File

@ -0,0 +1,23 @@
#ifndef __GIMPSETP_H__
#define __GIMPSETP_H__
#include "gimpobjectP.h"
#include "gimpset.h"
struct _GimpSet{
GimpObject gobject;
GtkType type;
GSList* list;
gboolean weak;
};
struct _GimpSetClass{
GimpObjectClass parent_class;
};
typedef struct _GimpSetClass GimpSetClass;
#define GIMP_SET_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gimp_set_get_type(), GimpSetClass)
#endif

View File

@ -30,6 +30,7 @@
#include "gimage.h"
#include "gimage_mask.h"
#include "gimprc.h"
#include "gimpset.h"
#include "general.h"
#include "image_render.h"
#include "interface.h"
@ -167,6 +168,8 @@ static void layers_dialog_mask_select_callback (GtkWidget *, gpointer);
static void layers_dialog_add_alpha_channel_callback (GtkWidget *, gpointer);
static gint lc_dialog_close_callback (GtkWidget *, gpointer);
static void lc_dialog_update_cb (GimpSet *, GimpImage *, gpointer);
/* layer widget function prototypes */
static LayerWidget *layer_widget_get_ID (Layer *);
static LayerWidget *create_layer_widget (GImage *, Layer *);
@ -387,7 +390,11 @@ lc_dialog_create (GimpImage* gimage)
no image present. */
ops_button_box_set_insensitive (layers_ops_buttons);
}
gtk_signal_connect (GTK_OBJECT (image_context), "add",
GTK_SIGNAL_FUNC (lc_dialog_update_cb), NULL);
gtk_signal_connect (GTK_OBJECT (image_context), "remove",
GTK_SIGNAL_FUNC(lc_dialog_update_cb), NULL);
layers_dialog_update (gimage);
channels_dialog_update (gimage);
gdisplays_flush ();
@ -1873,6 +1880,15 @@ lc_dialog_close_callback (GtkWidget *w,
}
static void
lc_dialog_update_cb (GimpSet *set,
GimpImage *image,
gpointer user_data)
{
lc_dialog_update_image_list ();
}
/****************************/
/* layer widget functions */
/****************************/

View File

@ -138,9 +138,6 @@ TempBuf * layer_mask_preview (Layer *, int, int);
void layer_invalidate_previews (GimpImage*);
/* temp thingies.. dynamic downcast. GTK_NO_CHECK_CASTS must not be
defined */
#define drawable_layer GIMP_IS_LAYER
#define drawable_layer_mask GIMP_IS_LAYER_MASK

View File

@ -30,6 +30,7 @@
#include "gimage.h"
#include "gimage_mask.h"
#include "gimprc.h"
#include "gimpset.h"
#include "general.h"
#include "image_render.h"
#include "interface.h"
@ -167,6 +168,8 @@ static void layers_dialog_mask_select_callback (GtkWidget *, gpointer);
static void layers_dialog_add_alpha_channel_callback (GtkWidget *, gpointer);
static gint lc_dialog_close_callback (GtkWidget *, gpointer);
static void lc_dialog_update_cb (GimpSet *, GimpImage *, gpointer);
/* layer widget function prototypes */
static LayerWidget *layer_widget_get_ID (Layer *);
static LayerWidget *create_layer_widget (GImage *, Layer *);
@ -387,7 +390,11 @@ lc_dialog_create (GimpImage* gimage)
no image present. */
ops_button_box_set_insensitive (layers_ops_buttons);
}
gtk_signal_connect (GTK_OBJECT (image_context), "add",
GTK_SIGNAL_FUNC (lc_dialog_update_cb), NULL);
gtk_signal_connect (GTK_OBJECT (image_context), "remove",
GTK_SIGNAL_FUNC(lc_dialog_update_cb), NULL);
layers_dialog_update (gimage);
channels_dialog_update (gimage);
gdisplays_flush ();
@ -1873,6 +1880,15 @@ lc_dialog_close_callback (GtkWidget *w,
}
static void
lc_dialog_update_cb (GimpSet *set,
GimpImage *image,
gpointer user_data)
{
lc_dialog_update_image_list ();
}
/****************************/
/* layer widget functions */
/****************************/

View File

@ -48,6 +48,7 @@ int be_verbose;
int use_shm;
int use_debug_handler;
int console_messages;
GimpSet* image_context;
MessageHandlerType message_handler;

View File

@ -438,6 +438,7 @@ tools_new_move_tool ()
private->layer = NULL;
private->guide = NULL;
private->disp = NULL;
return tool;
}

View File

@ -1266,19 +1266,31 @@ static gboolean id_cmp_func(gconstpointer id1, gconstpointer id2){
return (*((guint*)id1)==*((guint*)id2));
}
static void pdb_id_init (void){
image_hash=g_hash_table_new(id_hash_func, id_cmp_func);
drawable_hash=g_hash_table_new(id_hash_func, id_cmp_func);
display_hash=g_hash_table_new(id_hash_func, id_cmp_func);
}
void pdb_add_image(GimpImage* gimage){
static void add_cb(GimpSet* set, GimpImage* gimage, gpointer data){
guint* id=g_new(gint,1);
*id=next_image_id++;
gtk_object_set_data(GTK_OBJECT(gimage), "pdb_id", id);
g_hash_table_insert(image_hash, id, gimage);
}
static void remove_cb(GimpSet* set, GimpImage* image, gpointer data){
guint* id=gtk_object_get_data(GTK_OBJECT(image), "pdb_id");
gtk_object_remove_data(GTK_OBJECT(image), "pdb_id");
g_hash_table_remove(image_hash, id);
g_free(id);
}
static void pdb_id_init (void){
image_hash=g_hash_table_new(id_hash_func, id_cmp_func);
drawable_hash=g_hash_table_new(id_hash_func, id_cmp_func);
display_hash=g_hash_table_new(id_hash_func, id_cmp_func);
gtk_signal_connect(GTK_OBJECT(image_context), "add",
GTK_SIGNAL_FUNC(add_cb), NULL);
gtk_signal_connect(GTK_OBJECT(image_context), "remove",
GTK_SIGNAL_FUNC(remove_cb), NULL);
}
gint pdb_image_to_id(GimpImage* gimage){
guint *id=gtk_object_get_data(GTK_OBJECT(gimage), "pdb_id");
return id?(gint)*id:-1;
@ -1289,10 +1301,4 @@ GimpImage* pdb_id_to_image(gint id){
}
void pdb_remove_image(GimpImage* image){
guint* id=gtk_object_get_data(GTK_OBJECT(image), "pdb_id");
gtk_object_remove_data(GTK_OBJECT(image), "pdb_id");
g_hash_table_remove(image_hash, id);
g_free(id);
}

View File

@ -86,9 +86,6 @@ typedef enum
HISTOGRAM
} ToolType;
#define XButtonEvent GdkEventButton
#define XMotionEvent GdkEventMotion
/* Structure definitions */
typedef struct _tool Tool;

View File

@ -438,6 +438,7 @@ tools_new_move_tool ()
private->layer = NULL;
private->guide = NULL;
private->disp = NULL;
return tool;
}

View File

@ -438,6 +438,7 @@ tools_new_move_tool ()
private->layer = NULL;
private->guide = NULL;
private->disp = NULL;
return tool;
}

View File

@ -86,9 +86,6 @@ typedef enum
HISTOGRAM
} ToolType;
#define XButtonEvent GdkEventButton
#define XMotionEvent GdkEventMotion
/* Structure definitions */
typedef struct _tool Tool;