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

removed the ID system from the pdb/ subdir...

2001-04-13  Michael Natterer  <mitch@gimp.org>

	* app/pdb/procedural_db.[ch]: removed the ID system from the pdb/
	subdir...

	* app/gimpimage.[ch]: ...and temporarily added it back to GimpImage.

	The ID stuff is not only used by the PDB but is a more general
	type of service which is needed for the PDB, DND and some parts of
	the GUI. Finally, a GimpFactory class with subclasses for data
	objects, images etc. will maintain the ID spaces.

	* app/colormap_dialog.c
	* app/file-open.c
	* app/file-save.c
	* app/gdisplay.c
	* app/gimpdnd.c
	* app/gimpdrawable.c
	* app/info_window.c
	* app/lc_dialog.c
	* app/nav_window.c
	* app/palette_import.c
	* app/paths_dialog.c
	* app/plug_in.c
	* app/xcf.c
	* app/tools/gimptexttool.c
	* tools/pdbgen/pdb.pl
	* tools/pdbgen/pdb/image.pdb: use GimpImage's ID functions.

	* app/pdb/channel_cmds.c
	* app/pdb/channel_ops_cmds.c
	* app/pdb/convert_cmds.c
	* app/pdb/display_cmds.c
	* app/pdb/drawable_cmds.c
	* app/pdb/fileops_cmds.c
	* app/pdb/guides_cmds.c
	* app/pdb/image_cmds.c
	* app/pdb/layer_cmds.c
	* app/pdb/parasite_cmds.c
	* app/pdb/paths_cmds.c
	* app/pdb/selection_cmds.c
	* app/pdb/text_tool_cmds.c
	* app/pdb/tools_cmds.c
	* app/pdb/undo_cmds.c: regenerated.
parent 330072d6
2001-04-13 Michael Natterer <mitch@gimp.org>
* app/pdb/procedural_db.[ch]: removed the ID system from the pdb/
subdir...
* app/gimpimage.[ch]: ...and temporarily added it back to GimpImage.
The ID stuff is not only used by the PDB but is a more general
type of service which is needed for the PDB, DND and some parts of
the GUI. Finally, a GimpFactory class with subclasses for data
objects, images etc. will maintain the ID spaces.
* app/colormap_dialog.c
* app/file-open.c
* app/file-save.c
* app/gdisplay.c
* app/gimpdnd.c
* app/gimpdrawable.c
* app/info_window.c
* app/lc_dialog.c
* app/nav_window.c
* app/palette_import.c
* app/paths_dialog.c
* app/plug_in.c
* app/xcf.c
* app/tools/gimptexttool.c
* tools/pdbgen/pdb.pl
* tools/pdbgen/pdb/image.pdb: use GimpImage's ID functions.
* app/pdb/channel_cmds.c
* app/pdb/channel_ops_cmds.c
* app/pdb/convert_cmds.c
* app/pdb/display_cmds.c
* app/pdb/drawable_cmds.c
* app/pdb/fileops_cmds.c
* app/pdb/guides_cmds.c
* app/pdb/image_cmds.c
* app/pdb/layer_cmds.c
* app/pdb/parasite_cmds.c
* app/pdb/paths_cmds.c
* app/pdb/selection_cmds.c
* app/pdb/text_tool_cmds.c
* app/pdb/tools_cmds.c
* app/pdb/undo_cmds.c: regenerated.
2001-04-13 Michael Natterer <mitch@gimp.org>
* app/gimpdnd.c: added a DND type for GimpImage.
......
......@@ -1371,7 +1371,7 @@ plug_in_repeat (gboolean with_interface)
/* initialize the first three plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = pdb_image_to_id (gdisplay->gimage);
args[1].value.pdb_int = gimp_image_get_ID (gdisplay->gimage);
args[2].value.pdb_int = gimp_drawable_get_ID (gimp_image_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */
......@@ -2639,7 +2639,7 @@ plug_in_callback (GtkWidget *widget,
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = RUN_INTERACTIVE;
args[1].value.pdb_int = pdb_image_to_id (gdisplay->gimage);
args[1].value.pdb_int = gimp_image_get_ID (gdisplay->gimage);
args[2].value.pdb_int = gimp_drawable_get_ID (gimp_image_active_drawable (gdisplay->gimage));
argc = 3;
}
......@@ -2662,7 +2662,7 @@ plug_in_callback (GtkWidget *widget,
{
gdisp_ID = gdisplay->ID;
args[1].value.pdb_int = pdb_image_to_id (gdisplay->gimage);
args[1].value.pdb_int = gimp_image_get_ID (gdisplay->gimage);
args[2].value.pdb_int = gimp_drawable_get_ID (gimp_image_active_drawable (gdisplay->gimage));
argc = 3;
}
......
......@@ -42,8 +42,6 @@
#include "gimpdnd.h"
#include "gimpimage.h"
#include "pdb/procedural_db.h"
#include "libgimp/gimpintl.h"
......@@ -1112,7 +1110,7 @@ create_image_menu_cb (gpointer im,
image_name = g_basename (gimp_image_filename (gimage));
menu_item_label = g_strdup_printf ("%s-%d", image_name,
pdb_image_to_id (gimage));
gimp_image_get_ID (gimage));
menu_item = gtk_menu_item_new_with_label (menu_item_label);
gtk_object_set_data (GTK_OBJECT (menu_item), "colormap_dialog", data->ipal);
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
......
......@@ -183,7 +183,7 @@ gimp_drawable_destroy (GtkObject *object)
drawable = GIMP_DRAWABLE (object);
g_hash_table_remove (gimp_drawable_table, (gpointer) drawable->ID);
g_hash_table_remove (gimp_drawable_table, GINT_TO_POINTER (drawable->ID));
if (drawable->tiles)
tile_manager_destroy (drawable->tiles);
......@@ -387,7 +387,7 @@ gimp_drawable_get_by_ID (gint drawable_id)
return NULL;
return (GimpDrawable *) g_hash_table_lookup (gimp_drawable_table,
(gpointer) drawable_id);
GINT_TO_POINTER (drawable_id));
}
GimpImage *
......
......@@ -171,6 +171,9 @@ static guint gimp_image_signals[LAST_SIGNAL] = { 0 };
static GimpViewableClass *parent_class = NULL;
static gint global_image_ID = 1;
static GHashTable *gimp_image_table = NULL;
GtkType
gimp_image_get_type (void)
......@@ -324,6 +327,8 @@ gimp_image_class_init (GimpImageClass *klass)
static void
gimp_image_init (GimpImage *gimage)
{
gimage->ID = global_image_ID++;
gimage->save_proc = NULL;
gimage->width = 0;
......@@ -388,12 +393,23 @@ gimp_image_init (GimpImage *gimage)
gimage->comp_preview = NULL;
gimage->comp_preview_valid = FALSE;
if (gimp_image_table == NULL)
gimp_image_table = g_hash_table_new (g_direct_hash, NULL);
g_hash_table_insert (gimp_image_table,
GINT_TO_POINTER (gimage->ID),
(gpointer) gimage);
}
static void
gimp_image_destroy (GtkObject *object)
{
GimpImage *gimage = GIMP_IMAGE (object);
GimpImage *gimage;
gimage = GIMP_IMAGE (object);
g_hash_table_remove (gimp_image_table, GINT_TO_POINTER (gimage->ID));
gimp_image_free_projection (gimage);
gimp_image_free_shadow (gimage);
......@@ -547,6 +563,25 @@ gimp_image_new (gint width,
return gimage;
}
gint
gimp_image_get_ID (GimpImage *gimage)
{
g_return_val_if_fail (gimage != NULL, -1);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), -1);
return gimage->ID;
}
GimpImage *
gimp_image_get_by_ID (gint image_id)
{
if (gimp_image_table == NULL)
return NULL;
return (GimpImage *) g_hash_table_lookup (gimp_image_table,
GINT_TO_POINTER (image_id));
}
void
gimp_image_set_filename (GimpImage *gimage,
const gchar *filename)
......
......@@ -70,6 +70,8 @@ struct _GimpImage
{
GimpViewable parent_instance;
gint ID; /* provides a unique ID */
PlugInProcDef *save_proc; /* last PDB save proc used */
gint width, height; /* width and height attributes */
......@@ -195,6 +197,10 @@ GtkType gimp_image_get_type (void);
GimpImage * gimp_image_new (gint width,
gint height,
GimpImageBaseType base_type);
gint gimp_image_get_ID (GimpImage *gimage);
GimpImage * gimp_image_get_by_ID (gint id);
void gimp_image_set_filename (GimpImage *gimage,
const gchar *filename);
void gimp_image_set_resolution (GimpImage *gimage,
......
......@@ -171,6 +171,9 @@ static guint gimp_image_signals[LAST_SIGNAL] = { 0 };
static GimpViewableClass *parent_class = NULL;
static gint global_image_ID = 1;
static GHashTable *gimp_image_table = NULL;
GtkType
gimp_image_get_type (void)
......@@ -324,6 +327,8 @@ gimp_image_class_init (GimpImageClass *klass)
static void
gimp_image_init (GimpImage *gimage)
{
gimage->ID = global_image_ID++;
gimage->save_proc = NULL;
gimage->width = 0;
......@@ -388,12 +393,23 @@ gimp_image_init (GimpImage *gimage)
gimage->comp_preview = NULL;
gimage->comp_preview_valid = FALSE;
if (gimp_image_table == NULL)
gimp_image_table = g_hash_table_new (g_direct_hash, NULL);
g_hash_table_insert (gimp_image_table,
GINT_TO_POINTER (gimage->ID),
(gpointer) gimage);
}
static void
gimp_image_destroy (GtkObject *object)
{
GimpImage *gimage = GIMP_IMAGE (object);
GimpImage *gimage;
gimage = GIMP_IMAGE (object);
g_hash_table_remove (gimp_image_table, GINT_TO_POINTER (gimage->ID));
gimp_image_free_projection (gimage);
gimp_image_free_shadow (gimage);
......@@ -547,6 +563,25 @@ gimp_image_new (gint width,
return gimage;
}
gint
gimp_image_get_ID (GimpImage *gimage)
{
g_return_val_if_fail (gimage != NULL, -1);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), -1);
return gimage->ID;
}
GimpImage *
gimp_image_get_by_ID (gint image_id)
{
if (gimp_image_table == NULL)
return NULL;
return (GimpImage *) g_hash_table_lookup (gimp_image_table,
GINT_TO_POINTER (image_id));
}
void
gimp_image_set_filename (GimpImage *gimage,
const gchar *filename)
......
......@@ -70,6 +70,8 @@ struct _GimpImage
{
GimpViewable parent_instance;
gint ID; /* provides a unique ID */
PlugInProcDef *save_proc; /* last PDB save proc used */
gint width, height; /* width and height attributes */
......@@ -195,6 +197,10 @@ GtkType gimp_image_get_type (void);
GimpImage * gimp_image_new (gint width,
gint height,
GimpImageBaseType base_type);
gint gimp_image_get_ID (GimpImage *gimage);
GimpImage * gimp_image_get_by_ID (gint id);
void gimp_image_set_filename (GimpImage *gimage,
const gchar *filename);
void gimp_image_set_resolution (GimpImage *gimage,
......
......@@ -171,6 +171,9 @@ static guint gimp_image_signals[LAST_SIGNAL] = { 0 };
static GimpViewableClass *parent_class = NULL;
static gint global_image_ID = 1;
static GHashTable *gimp_image_table = NULL;
GtkType
gimp_image_get_type (void)
......@@ -324,6 +327,8 @@ gimp_image_class_init (GimpImageClass *klass)
static void
gimp_image_init (GimpImage *gimage)
{
gimage->ID = global_image_ID++;
gimage->save_proc = NULL;
gimage->width = 0;
......@@ -388,12 +393,23 @@ gimp_image_init (GimpImage *gimage)
gimage->comp_preview = NULL;
gimage->comp_preview_valid = FALSE;
if (gimp_image_table == NULL)
gimp_image_table = g_hash_table_new (g_direct_hash, NULL);
g_hash_table_insert (gimp_image_table,
GINT_TO_POINTER (gimage->ID),
(gpointer) gimage);
}
static void
gimp_image_destroy (GtkObject *object)
{
GimpImage *gimage = GIMP_IMAGE (object);
GimpImage *gimage;
gimage = GIMP_IMAGE (object);
g_hash_table_remove (gimp_image_table, GINT_TO_POINTER (gimage->ID));
gimp_image_free_projection (gimage);
gimp_image_free_shadow (gimage);
......@@ -547,6 +563,25 @@ gimp_image_new (gint width,
return gimage;
}
gint
gimp_image_get_ID (GimpImage *gimage)
{
g_return_val_if_fail (gimage != NULL, -1);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), -1);
return gimage->ID;
}
GimpImage *
gimp_image_get_by_ID (gint image_id)
{
if (gimp_image_table == NULL)
return NULL;
return (GimpImage *) g_hash_table_lookup (gimp_image_table,
GINT_TO_POINTER (image_id));
}
void
gimp_image_set_filename (GimpImage *gimage,
const gchar *filename)
......
......@@ -70,6 +70,8 @@ struct _GimpImage
{
GimpViewable parent_instance;
gint ID; /* provides a unique ID */
PlugInProcDef *save_proc; /* last PDB save proc used */
gint width, height; /* width and height attributes */
......@@ -195,6 +197,10 @@ GtkType gimp_image_get_type (void);
GimpImage * gimp_image_new (gint width,
gint height,
GimpImageBaseType base_type);
gint gimp_image_get_ID (GimpImage *gimage);
GimpImage * gimp_image_get_by_ID (gint id);
void gimp_image_set_filename (GimpImage *gimage,
const gchar *filename);
void gimp_image_set_resolution (GimpImage *gimage,
......
......@@ -171,6 +171,9 @@ static guint gimp_image_signals[LAST_SIGNAL] = { 0 };
static GimpViewableClass *parent_class = NULL;
static gint global_image_ID = 1;
static GHashTable *gimp_image_table = NULL;
GtkType
gimp_image_get_type (void)
......@@ -324,6 +327,8 @@ gimp_image_class_init (GimpImageClass *klass)
static void
gimp_image_init (GimpImage *gimage)
{
gimage->ID = global_image_ID++;
gimage->save_proc = NULL;
gimage->width = 0;
......@@ -388,12 +393,23 @@ gimp_image_init (GimpImage *gimage)
gimage->comp_preview = NULL;
gimage->comp_preview_valid = FALSE;
if (gimp_image_table == NULL)
gimp_image_table = g_hash_table_new (g_direct_hash, NULL);
g_hash_table_insert (gimp_image_table,
GINT_TO_POINTER (gimage->ID),
(gpointer) gimage);
}
static void
gimp_image_destroy (GtkObject *object)
{
GimpImage *gimage = GIMP_IMAGE (object);
GimpImage *gimage;
gimage = GIMP_IMAGE (object);
g_hash_table_remove (gimp_image_table, GINT_TO_POINTER (gimage->ID));
gimp_image_free_projection (gimage);
gimp_image_free_shadow (gimage);
......@@ -547,6 +563,25 @@ gimp_image_new (gint width,
return gimage;
}
gint
gimp_image_get_ID (GimpImage *gimage)
{
g_return_val_if_fail (gimage != NULL, -1);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), -1);
return gimage->ID;
}
GimpImage *
gimp_image_get_by_ID (gint image_id)
{
if (gimp_image_table == NULL)
return NULL;
return (GimpImage *) g_hash_table_lookup (gimp_image_table,
GINT_TO_POINTER (image_id));
}
void
gimp_image_set_filename (GimpImage *gimage,
const gchar *filename)
......
......@@ -70,6 +70,8 @@ struct _GimpImage
{
GimpViewable parent_instance;
gint ID; /* provides a unique ID */
PlugInProcDef *save_proc; /* last PDB save proc used */
gint width, height; /* width and height attributes */
......@@ -195,6 +197,10 @@ GtkType gimp_image_get_type (void);
GimpImage * gimp_image_new (gint width,
gint height,
GimpImageBaseType base_type);
gint gimp_image_get_ID (GimpImage *gimage);
GimpImage * gimp_image_get_by_ID (gint id);
void gimp_image_set_filename (GimpImage *gimage,
const gchar *filename);
void gimp_image_set_resolution (GimpImage *gimage,
......
......@@ -171,6 +171,9 @@ static guint gimp_image_signals[LAST_SIGNAL] = { 0 };
static GimpViewableClass *parent_class = NULL;
static gint global_image_ID = 1;
static GHashTable *gimp_image_table = NULL;
GtkType
gimp_image_get_type (void)
......@@ -324,6 +327,8 @@ gimp_image_class_init (GimpImageClass *klass)
static void
gimp_image_init (GimpImage *gimage)
{
gimage->ID = global_image_ID++;
gimage->save_proc = NULL;
gimage->width = 0;
......@@ -388,12 +393,23 @@ gimp_image_init (GimpImage *gimage)
gimage->comp_preview = NULL;
gimage->comp_preview_valid = FALSE;
if (gimp_image_table == NULL)
gimp_image_table = g_hash_table_new (g_direct_hash, NULL);
g_hash_table_insert (gimp_image_table,
GINT_TO_POINTER (gimage->ID),
(gpointer) gimage);
}
static void
gimp_image_destroy (GtkObject *object)
{
GimpImage *gimage = GIMP_IMAGE (object);
GimpImage *gimage;
gimage = GIMP_IMAGE (object);
g_hash_table_remove (gimp_image_table, GINT_TO_POINTER (gimage->ID));
gimp_image_free_projection (gimage);
gimp_image_free_shadow (gimage);
......@@ -547,6 +563,25 @@ gimp_image_new (gint width,
return gimage;
}
gint
gimp_image_get_ID (GimpImage *gimage)
{
g_return_val_if_fail (gimage != NULL, -1);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), -1);
return gimage->ID;
}
GimpImage *
gimp_image_get_by_ID (gint image_id)
{
if (gimp_image_table == NULL)
return NULL;
return (GimpImage *) g_hash_table_lookup (gimp_image_table,
GINT_TO_POINTER (image_id));
}
void
gimp_image_set_filename (GimpImage *gimage,
const gchar *filename)
......
......@@ -70,6 +70,8 @@ struct _GimpImage
{
GimpViewable parent_instance;
gint ID; /* provides a unique ID */
PlugInProcDef *save_proc; /* last PDB save proc used */
gint width, height; /* width and height attributes */
......@@ -195,6 +197,10 @@ GtkType gimp_image_get_type (void);
GimpImage * gimp_image_new (gint width,
gint height,
GimpImageBaseType base_type);
gint gimp_image_get_ID (GimpImage *gimage);
GimpImage * gimp_image_get_by_ID (gint id);
void gimp_image_set_filename (GimpImage *gimage,
const gchar *filename);
void gimp_image_set_resolution (GimpImage *gimage,
......
......@@ -171,6 +171,9 @@ static guint gimp_image_signals[LAST_SIGNAL] = { 0 };
static GimpViewableClass *parent_class = NULL;
static gint global_image_ID = 1;
static GHashTable *gimp_image_table = NULL;
GtkType
gimp_image_get_type (void)
......@@ -324,6 +327,8 @@ gimp_image_class_init (GimpImageClass *klass)
static void
gimp_image_init (GimpImage *gimage)
{
gimage->ID = global_image_ID++;
gimage->save_proc = NULL;
gimage->width = 0;
......@@ -388,12 +393,23 @@ gimp_image_init (GimpImage *gimage)
gimage->comp_preview = NULL;
gimage->comp_preview_valid = FALSE;
if (gimp_image_table == NULL)
gimp_image_table = g_hash_table_new (g_direct_hash, NULL);
g_hash_table_insert (gimp_image_table,
GINT_TO_POINTER (gimage->ID),
(gpointer) gimage);
}
static void
gimp_image_destroy (GtkObject *object)
{
GimpImage *gimage = GIMP_IMAGE (object);
GimpImage *gimage;
gimage = GIMP_IMAGE (object);
g_hash_table_remove (gimp_image_table, GINT_TO_POINTER (gimage->ID));
gimp_image_free_projection (gimage);
gimp_image_free_shadow (gimage);
......@@ -547,6 +563,25 @@ gimp_image_new (gint width,
return gimage;
}
gint
gimp_image_get_ID (GimpImage *gimage)
{
g_return_val_if_fail (gimage != NULL, -1);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), -1);
return gimage->ID;
}
GimpImage *
gimp_image_get_by_ID (gint image_id)
{