GdkColormap -> GObject
- From: Havoc Pennington <hp redhat com>
- To: gtk-devel-list gnome org
- Subject: GdkColormap -> GObject
- Date: 15 May 2000 18:44:15 -0400
Hi,
Started with the simplest GDK type needing GObject-ification.
Here's the patch; please comment, and I'll move on to the other types.
Issues -
- no object args added, since that stuff seems to be the subject
of controversy still. This means that gdk_x_colormap_init()
doesn't really do what it should do, and gdk_colormap_new()
or gdk_colormap_get_system() must be used to create colormaps.
Once this stuff settles, default construction can be added.
- It might seem more intuitive to have a GdkColormap type,
with GdkXColormap as a subclass; however in practice I think
it works out better to avoid introducing a type in
cross-platform code (i.e. only GdkXColormap really exists,
and there's a fake GdkColormap type which is user-visible).
Havoc
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.1246
diff -u -r1.1246 ChangeLog
--- ChangeLog 2000/05/15 16:09:43 1.1246
+++ ChangeLog 2000/05/15 22:33:27
@@ -1,3 +1,34 @@
+2000-05-15 Havoc Pennington <hp@redhat.com>
+
+ * gtk/gtk-boxed.defs: Remove GdkColormap boxed type.
+
+ * gdk/x11/gdkx.h: Include the gdkcolor-x11.h header; remove
+ GdkColormapPrivateX; fix GDK_COLORMAP_XDISPLAY and
+ GDK_COLORMAP_XCOLORMAP so they keep working
+
+ * gdk/x11/gdkcolor-x11.h (struct _GdkXColormap): New header for
+ the GdkXColormap GObject
+
+ * gdk/x11/gdkcolor-x11.c: Implement GdkXColormap, which is a
+ GObject of type GdkColormap; implement gdk_colormap_get_type() as
+ simply a call to gdk_x_colormap_get_type(); replace
+ GdkColormapPrivateX with GdkXColormap.
+
+ * gdk/gdkprivate.h: Remove GdkColormapPrivate
+
+ * gdk/gdkcolor.h (struct _GdkColormap): This is now a GObject,
+ sort of - the actual object type is defined in port-specific code,
+ but GdkColormap appears to be a GObject; add "visual" field from
+ GdkColormapPrivate to the instance struct; add GObject boilerplate
+ stuff
+
+ * gdk/gdkcolor.c (gdk_colormap_ref): just a g_object_ref wrapper
+ now
+ (gdk_colormap_unref): wrap gtk_object_unref
+ (gdk_colormap_get_visual): fix to reflect absence of GdkColormapPrivate
+
+ * gdk/gdk.c (gdk_init_check): Call g_type_init ()
+
Fri May 12 18:46:51 2000 Owen Taylor <otaylor@redhat.com>
* docs/Changes-1.4.txt: A bit of editing.
Index: gdk/gdk.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdk.c,v
retrieving revision 1.118
diff -u -r1.118 gdk.c
--- gdk/gdk.c 2000/05/02 21:36:07 1.118
+++ gdk/gdk.c 2000/05/15 22:33:27
@@ -277,6 +277,8 @@
if (gdk_initialized)
return TRUE;
+
+ g_type_init ();
if (g_thread_supported ())
gdk_threads_mutex = g_mutex_new ();
Index: gdk/gdkcolor.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkcolor.c,v
retrieving revision 1.22
diff -u -r1.22 gdkcolor.c
--- gdk/gdkcolor.c 2000/03/28 01:40:57 1.22
+++ gdk/gdkcolor.c 2000/05/15 22:33:27
@@ -32,37 +32,30 @@
GdkColormap*
gdk_colormap_ref (GdkColormap *cmap)
{
- GdkColormapPrivate *private = (GdkColormapPrivate *)cmap;
-
g_return_val_if_fail (cmap != NULL, NULL);
+ g_return_val_if_fail (GDK_IS_COLORMAP (cmap), NULL);
+
+ g_object_ref (G_OBJECT (cmap));
- private->ref_count += 1;
return cmap;
}
void
gdk_colormap_unref (GdkColormap *cmap)
{
- GdkColormapPrivate *private = (GdkColormapPrivate *)cmap;
-
g_return_if_fail (cmap != NULL);
- g_return_if_fail (private->ref_count > 0);
+ g_return_if_fail (GDK_IS_COLORMAP (cmap));
- private->ref_count -= 1;
- if (private->ref_count == 0)
- _gdk_colormap_real_destroy (cmap);
+ g_object_unref (G_OBJECT (cmap));
}
GdkVisual *
gdk_colormap_get_visual (GdkColormap *colormap)
{
- GdkColormapPrivate *private;
-
g_return_val_if_fail (colormap != NULL, NULL);
-
- private = (GdkColormapPrivate *)colormap;
+ g_return_val_if_fail (GDK_IS_COLORMAP (colormap), NULL);
- return private->visual;
+ return colormap->visual;
}
void
Index: gdk/gdkcolor.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkcolor.h,v
retrieving revision 1.2
diff -u -r1.2 gdkcolor.h
--- gdk/gdkcolor.h 2000/03/14 19:57:22 1.2
+++ gdk/gdkcolor.h 2000/05/15 22:33:27
@@ -2,6 +2,7 @@
#define __GDK_COLOR_H__
#include <gdk/gdktypes.h>
+#include <gobject/gobject.h>
#ifdef __cplusplus
extern "C" {
@@ -24,17 +25,34 @@
/* The colormap type.
*/
+typedef struct _GdkColormapClass GdkColormapClass;
+
+#define GDK_TYPE_COLORMAP (gdk_colormap_get_type ())
+#define GDK_COLORMAP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_COLORMAP, GdkColormap))
+#define GDK_COLORMAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_COLORMAP, GdkColormapClass))
+#define GDK_IS_COLORMAP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_COLORMAP))
+#define GDK_IS_COLORMAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_COLORMAP))
+
struct _GdkColormap
+{
+ GObject parent_instance;
+
+ gint size;
+ GdkColor *colors;
+ GdkVisual *visual;
+};
+
+struct _GdkColormapClass
{
- gint size;
- GdkColor *colors;
+ GObjectClass parent_class;
};
+GType gdk_colormap_get_type ();
+GdkColormap* gdk_colormap_new (GdkVisual *visual,
+ gboolean allocate);
+GdkColormap* gdk_colormap_ref (GdkColormap *cmap);
+void gdk_colormap_unref (GdkColormap *cmap);
-GdkColormap* gdk_colormap_new (GdkVisual *visual,
- gboolean allocate);
-GdkColormap* gdk_colormap_ref (GdkColormap *cmap);
-void gdk_colormap_unref (GdkColormap *cmap);
GdkColormap* gdk_colormap_get_system (void);
gint gdk_colormap_get_system_size (void);
Index: gdk/gdkprivate.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkprivate.h,v
retrieving revision 1.44
diff -u -r1.44 gdkprivate.h
--- gdk/gdkprivate.h 2000/03/28 01:24:42 1.44
+++ gdk/gdkprivate.h 2000/05/15 22:33:27
@@ -59,7 +59,6 @@
typedef struct _GdkImageClass GdkImageClass;
typedef struct _GdkImagePrivate GdkImagePrivate;
typedef struct _GdkGCPrivate GdkGCPrivate;
-typedef struct _GdkColormapPrivate GdkColormapPrivate;
typedef struct _GdkColorInfo GdkColorInfo;
typedef struct _GdkFontPrivate GdkFontPrivate;
typedef struct _GdkEventFilter GdkEventFilter;
@@ -157,14 +156,6 @@
struct _GdkColorInfo
{
GdkColorInfoFlags flags;
- guint ref_count;
-};
-
-struct _GdkColormapPrivate
-{
- GdkColormap colormap;
- GdkVisual *visual;
-
guint ref_count;
};
Index: gdk/x11/Makefile.am
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/Makefile.am,v
retrieving revision 1.7
diff -u -r1.7 Makefile.am
--- gdk/x11/Makefile.am 2000/04/07 21:36:12 1.7
+++ gdk/x11/Makefile.am 2000/05/15 22:33:27
@@ -65,6 +65,7 @@
gxid_lib.c \
gxid_lib.h \
gxid_proto.h \
+ gdkcolor-x11.h \
gdkx.h \
gdkprivate-x11.h \
gdkinputprivate.h \
Index: gdk/x11/gdkcolor-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkcolor-x11.c,v
retrieving revision 1.22
diff -u -r1.22 gdkcolor-x11.c
--- gdk/x11/gdkcolor-x11.c 2000/03/28 01:24:42 1.22
+++ gdk/x11/gdkcolor-x11.c 2000/05/15 22:33:27
@@ -38,31 +38,113 @@
static gint gdk_colormap_cmp (Colormap *a,
Colormap *b);
+static void gdk_x_colormap_class_init (GdkXColormapClass *klass);
+static void gdk_x_colormap_init (GdkXColormap *cmap);
+static void gdk_x_colormap_finalize (GObject *object);
+
+
static GHashTable *colormap_hash = NULL;
+static GObjectClass * parent_class = NULL;
+
+GType
+gdk_x_colormap_get_type ()
+{
+ static GType object_type = 0;
+
+ if (!object_type)
+ {
+ static const GTypeInfo object_info =
+ {
+ sizeof (GdkXColormapClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) gdk_x_colormap_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GdkXColormap),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gdk_x_colormap_init,
+ };
+
+ object_type = g_type_register_static (G_TYPE_OBJECT,
+ "GdkColormap",
+ &object_info);
+ }
+
+ return object_type;
+}
+
+static void
+gdk_x_colormap_class_init (GdkXColormapClass *klass)
+{
+ GObjectClass * object_class;
+
+ object_class = (GObjectClass *) klass;
+
+ object_class->finalize = gdk_x_colormap_finalize;
+
+ parent_class = g_type_class_ref (G_TYPE_OBJECT);
+}
+
+static void
+gdk_x_colormap_init (GdkXColormap *x_cmap)
+{
+ GdkColormap *cmap;
+
+ cmap = (GdkColormap *) x_cmap;
+
+ x_cmap->xdisplay = gdk_display;
+}
+
+static void
+gdk_x_colormap_finalize (GObject *object)
+{
+ GdkXColormap *x_cmap;
+ GdkColormap * colormap;
+
+ x_cmap = GDK_X_COLORMAP (object);
+ colormap = (GdkColormap *) x_cmap;
+
+ gdk_colormap_remove (colormap);
+ XFreeColormap (x_cmap->xdisplay, x_cmap->xcolormap);
+ if (x_cmap->hash)
+ g_hash_table_destroy (x_cmap->hash);
+
+ g_free (x_cmap->info);
+ g_free (colormap->colors);
+
+ (* parent_class->finalize) (object);
+}
+
+GType
+gdk_colormap_get_type ()
+{
+ return gdk_x_colormap_get_type ();
+}
GdkColormap*
gdk_colormap_new (GdkVisual *visual,
gboolean private_cmap)
{
GdkColormap *colormap;
- GdkColormapPrivateX *private;
+ GdkXColormap *x_cmap;
Visual *xvisual;
int size;
int i;
g_return_val_if_fail (visual != NULL, NULL);
- private = g_new (GdkColormapPrivateX, 1);
- colormap = (GdkColormap*) private;
+ x_cmap = (GdkXColormap *) g_type_create_instance (gdk_x_colormap_get_type ());
+ colormap = (GdkColormap*) x_cmap;
- private->xdisplay = gdk_display;
- private->base.visual = visual;
- private->base.ref_count = 1;
+ colormap->visual = visual;
+
+ x_cmap->xdisplay = gdk_display;
- private->hash = NULL;
- private->last_sync_time = 0;
- private->info = NULL;
+ x_cmap->hash = NULL;
+ x_cmap->last_sync_time = 0;
+ x_cmap->info = NULL;
xvisual = ((GdkVisualPrivate*) visual)->xvisual;
@@ -73,15 +155,15 @@
{
case GDK_VISUAL_GRAYSCALE:
case GDK_VISUAL_PSEUDO_COLOR:
- private->info = g_new0 (GdkColorInfo, colormap->size);
+ x_cmap->info = g_new0 (GdkColorInfo, colormap->size);
colormap->colors = g_new (GdkColor, colormap->size);
- private->hash = g_hash_table_new ((GHashFunc) gdk_color_hash,
- (GCompareFunc) gdk_color_equal);
+ x_cmap->hash = g_hash_table_new ((GHashFunc) gdk_color_hash,
+ (GCompareFunc) gdk_color_equal);
- private->private_val = private_cmap;
- private->xcolormap = XCreateColormap (private->xdisplay, gdk_root_window,
- xvisual, (private_cmap) ? (AllocAll) : (AllocNone));
+ x_cmap->private_val = private_cmap;
+ x_cmap->xcolormap = XCreateColormap (x_cmap->xdisplay, gdk_root_window,
+ xvisual, (private_cmap) ? (AllocAll) : (AllocNone));
if (private_cmap)
{
@@ -92,8 +174,8 @@
for (i = 0; i < colormap->size; i++)
default_colors[i].pixel = i;
- XQueryColors (private->xdisplay,
- DefaultColormap (private->xdisplay, gdk_screen),
+ XQueryColors (x_cmap->xdisplay,
+ DefaultColormap (x_cmap->xdisplay, gdk_screen),
default_colors, colormap->size);
for (i = 0; i < colormap->size; i++)
@@ -111,9 +193,9 @@
break;
case GDK_VISUAL_DIRECT_COLOR:
- private->private_val = TRUE;
- private->xcolormap = XCreateColormap (private->xdisplay, gdk_root_window,
- xvisual, AllocAll);
+ x_cmap->private_val = TRUE;
+ x_cmap->xcolormap = XCreateColormap (x_cmap->xdisplay, gdk_root_window,
+ xvisual, AllocAll);
colormap->colors = g_new (GdkColor, colormap->size);
size = 1 << visual->red_prec;
@@ -134,9 +216,9 @@
case GDK_VISUAL_STATIC_GRAY:
case GDK_VISUAL_STATIC_COLOR:
case GDK_VISUAL_TRUE_COLOR:
- private->private_val = FALSE;
- private->xcolormap = XCreateColormap (private->xdisplay, gdk_root_window,
- xvisual, AllocNone);
+ x_cmap->private_val = FALSE;
+ x_cmap->xcolormap = XCreateColormap (x_cmap->xdisplay, gdk_root_window,
+ xvisual, AllocNone);
break;
}
@@ -145,22 +227,6 @@
return colormap;
}
-void
-_gdk_colormap_real_destroy (GdkColormap *colormap)
-{
- GdkColormapPrivateX *private = (GdkColormapPrivateX*) colormap;
-
- gdk_colormap_remove (colormap);
- XFreeColormap (private->xdisplay, private->xcolormap);
-
- if (private->hash)
- g_hash_table_destroy (private->hash);
-
- g_free (private->info);
- g_free (colormap->colors);
- g_free (colormap);
-}
-
#define MIN_SYNC_TIME 2
void
@@ -168,7 +234,7 @@
gboolean force)
{
time_t current_time;
- GdkColormapPrivateX *private = (GdkColormapPrivateX *)colormap;
+ GdkXColormap * private = (GdkXColormap *) colormap;
XColor *xpalette;
gint nlookup;
gint i;
@@ -215,28 +281,27 @@
gdk_colormap_get_system (void)
{
static GdkColormap *colormap = NULL;
- GdkColormapPrivateX *private;
+ GdkXColormap *private;
if (!colormap)
{
- private = g_new (GdkColormapPrivateX, 1);
+ private = (GdkXColormap *) g_type_create_instance (gdk_x_colormap_get_type ());
colormap = (GdkColormap*) private;
private->xdisplay = gdk_display;
private->xcolormap = DefaultColormap (gdk_display, gdk_screen);
- private->base.visual = gdk_visual_get_system ();
+ colormap->visual = gdk_visual_get_system ();
private->private_val = FALSE;
- private->base.ref_count = 1;
private->hash = NULL;
private->last_sync_time = 0;
private->info = NULL;
colormap->colors = NULL;
- colormap->size = private->base.visual->colormap_size;
+ colormap->size = colormap->visual->colormap_size;
- if ((private->base.visual->type == GDK_VISUAL_GRAYSCALE) ||
- (private->base.visual->type == GDK_VISUAL_PSEUDO_COLOR))
+ if ((colormap->visual->type == GDK_VISUAL_GRAYSCALE) ||
+ (colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR))
{
private->info = g_new0 (GdkColorInfo, colormap->size);
colormap->colors = g_new (GdkColor, colormap->size);
@@ -263,7 +328,7 @@
gdk_colormap_change (GdkColormap *colormap,
gint ncolors)
{
- GdkColormapPrivateX *private;
+ GdkXColormap *private;
GdkVisual *visual;
XColor *palette;
gint shift;
@@ -275,8 +340,8 @@
palette = g_new (XColor, ncolors);
- private = (GdkColormapPrivateX*) colormap;
- switch (private->base.visual->type)
+ private = (GdkXColormap*) colormap;
+ switch (colormap->visual->type)
{
case GDK_VISUAL_GRAYSCALE:
case GDK_VISUAL_PSEUDO_COLOR:
@@ -293,7 +358,7 @@
break;
case GDK_VISUAL_DIRECT_COLOR:
- visual = private->base.visual;
+ visual = colormap->visual;
shift = visual->red_shift;
max_colors = 1 << visual->red_prec;
@@ -350,13 +415,13 @@
gulong *pixels,
gint npixels)
{
- GdkColormapPrivateX *private;
+ GdkXColormap *private;
gint return_val;
gint i;
g_return_val_if_fail (colormap != NULL, 0);
- private = (GdkColormapPrivateX*) colormap;
+ private = (GdkXColormap *) colormap;
return_val = XAllocColorCells (private->xdisplay, private->xcolormap,
contiguous, planes, nplanes, pixels, npixels);
@@ -408,7 +473,7 @@
gint in_npixels,
gulong planes)
{
- GdkColormapPrivateX *private;
+ GdkXColormap *private;
gulong *pixels;
gint npixels = 0;
gint i;
@@ -416,10 +481,10 @@
g_return_if_fail (colormap != NULL);
g_return_if_fail (in_pixels != NULL);
- private = (GdkColormapPrivateX*) colormap;
+ private = (GdkXColormap*) colormap;
- if ((private->base.visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
- (private->base.visual->type != GDK_VISUAL_GRAYSCALE))
+ if ((colormap->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
+ (colormap->visual->type != GDK_VISUAL_GRAYSCALE))
return;
pixels = g_new (gulong, in_npixels);
@@ -456,7 +521,7 @@
GdkColor *colors,
gint ncolors)
{
- GdkColormapPrivateX *private;
+ GdkXColormap *private;
gulong *pixels;
gint npixels = 0;
gint i;
@@ -464,10 +529,10 @@
g_return_if_fail (colormap != NULL);
g_return_if_fail (colors != NULL);
- private = (GdkColormapPrivateX*) colormap;
+ private = (GdkXColormap*) colormap;
- if ((private->base.visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
- (private->base.visual->type != GDK_VISUAL_GRAYSCALE))
+ if ((colormap->visual->type != GDK_VISUAL_PSEUDO_COLOR) &&
+ (colormap->visual->type != GDK_VISUAL_GRAYSCALE))
return;
pixels = g_new (gulong, ncolors);
@@ -509,10 +574,10 @@
GdkColor *color,
GdkColor *ret)
{
- GdkColormapPrivateX *private;
+ GdkXColormap *private;
XColor xcolor;
- private = (GdkColormapPrivateX*) colormap;
+ private = (GdkXColormap*) colormap;
xcolor.red = color->red;
xcolor.green = color->green;
@@ -561,12 +626,12 @@
gboolean best_match,
gboolean *success)
{
- GdkColormapPrivateX *private;
+ GdkXColormap *private;
gulong *pixels;
Status status;
gint i, index;
- private = (GdkColormapPrivateX*) colormap;
+ private = (GdkXColormap*) colormap;
if (private->private_val)
{
@@ -619,13 +684,13 @@
gboolean best_match,
gboolean *success)
{
- GdkColormapPrivateX *private;
+ GdkXColormap *private;
gint i, index;
XColor *store = g_new (XColor, ncolors);
gint nstore = 0;
gint nremaining = 0;
- private = (GdkColormapPrivateX*) colormap;
+ private = (GdkXColormap*) colormap;
index = -1;
/* First, store the colors we have room for */
@@ -698,12 +763,12 @@
gboolean best_match,
gboolean *success)
{
- GdkColormapPrivateX *private;
+ GdkXColormap *private;
gint i, index;
gint nremaining = 0;
gint nfailed = 0;
- private = (GdkColormapPrivateX*) colormap;
+ private = (GdkXColormap*) colormap;
index = -1;
for (i=0; i<ncolors; i++)
@@ -790,12 +855,12 @@
gboolean best_match,
gboolean *success)
{
- GdkColormapPrivateX *private;
+ GdkXColormap *private;
GdkColor *lookup_color;
gint i;
gint nremaining = 0;
- private = (GdkColormapPrivateX*) colormap;
+ private = (GdkXColormap*) colormap;
/* Check for an exact match among previously allocated colors */
@@ -837,7 +902,7 @@
gboolean best_match,
gboolean *success)
{
- GdkColormapPrivateX *private;
+ GdkXColormap *private;
GdkVisual *visual;
gint i;
gint nremaining = 0;
@@ -846,14 +911,14 @@
g_return_val_if_fail (colormap != NULL, FALSE);
g_return_val_if_fail (colors != NULL, FALSE);
- private = (GdkColormapPrivateX*) colormap;
+ private = (GdkXColormap*) colormap;
for (i=0; i<ncolors; i++)
{
success[i] = FALSE;
}
- switch (private->base.visual->type)
+ switch (colormap->visual->type)
{
case GDK_VISUAL_PSEUDO_COLOR:
case GDK_VISUAL_GRAYSCALE:
@@ -867,7 +932,7 @@
case GDK_VISUAL_DIRECT_COLOR:
case GDK_VISUAL_TRUE_COLOR:
- visual = private->base.visual;
+ visual = colormap->visual;
for (i=0; i<ncolors; i++)
{
@@ -905,7 +970,7 @@
gdk_color_change (GdkColormap *colormap,
GdkColor *color)
{
- GdkColormapPrivateX *private;
+ GdkXColormap *private;
XColor xcolor;
g_return_val_if_fail (colormap != NULL, FALSE);
@@ -917,7 +982,7 @@
xcolor.blue = color->blue;
xcolor.flags = DoRed | DoGreen | DoBlue;
- private = (GdkColormapPrivateX*) colormap;
+ private = (GdkXColormap*) colormap;
XStoreColor (private->xdisplay, private->xcolormap, &xcolor);
return TRUE;
@@ -930,7 +995,7 @@
gdkx_colormap_get (Colormap xcolormap)
{
GdkColormap *colormap;
- GdkColormapPrivateX *private;
+ GdkXColormap *private;
colormap = gdk_colormap_lookup (xcolormap);
if (colormap)
@@ -939,12 +1004,12 @@
if (xcolormap == DefaultColormap (gdk_display, gdk_screen))
return gdk_colormap_get_system ();
- private = g_new (GdkColormapPrivateX, 1);
+ private = g_new (GdkXColormap, 1);
colormap = (GdkColormap*) private;
private->xdisplay = gdk_display;
private->xcolormap = xcolormap;
- private->base.visual = NULL;
+ colormap->visual = NULL;
private->private_val = TRUE;
/* To do the following safely, we would have to have some way of finding
@@ -1035,13 +1100,13 @@
static void
gdk_colormap_add (GdkColormap *cmap)
{
- GdkColormapPrivateX *private;
+ GdkXColormap *private;
if (!colormap_hash)
colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
(GCompareFunc) gdk_colormap_cmp);
- private = (GdkColormapPrivateX*)cmap;
+ private = (GdkXColormap*)cmap;
g_hash_table_insert (colormap_hash, &private->xcolormap, cmap);
}
@@ -1049,13 +1114,13 @@
static void
gdk_colormap_remove (GdkColormap *cmap)
{
- GdkColormapPrivateX *private;
+ GdkXColormap *private;
if (!colormap_hash)
colormap_hash = g_hash_table_new ((GHashFunc) gdk_colormap_hash,
(GCompareFunc) gdk_colormap_cmp);
- private = (GdkColormapPrivateX *)cmap;
+ private = (GdkXColormap *)cmap;
g_hash_table_remove (colormap_hash, &private->xcolormap);
}
Index: gdk/x11/gdkcolor-x11.h
===================================================================
RCS file: gdkcolor-x11.h
diff -N gdkcolor-x11.h
--- /dev/null Tue May 5 16:32:27 1998
+++ gdkcolor-x11.h Mon May 15 18:33:27 2000
@@ -0,0 +1,70 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
+#ifndef __GDK_COLOR_X11_H__
+#define __GDK_COLOR_X11_H__
+
+#include <gdk/gdkcolor.h>
+#include <X11/Xlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+typedef struct _GdkXColormap GdkXColormap;
+typedef struct _GdkXColormapClass GdkXColormapClass;
+
+#define GDK_TYPE_X_COLORMAP (gdk_x_colormap_get_type ())
+#define GDK_X_COLORMAP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_X_COLORMAP, GdkXColormap))
+#define GDK_X_COLORMAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_X_COLORMAP, GdkXColormapClass))
+#define GDK_IS_X_COLORMAP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_X_COLORMAP))
+#define GDK_IS_X_COLORMAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_X_COLORMAP))
+
+struct _GdkXColormap
+{
+ GdkColormap parent_instance;
+
+ Colormap xcolormap;
+ Display *xdisplay;
+ gint private_val;
+
+ GHashTable *hash;
+ GdkColorInfo *info;
+ time_t last_sync_time;
+};
+
+struct _GdkXColormapClass
+{
+ GdkColormapClass parent_class;
+};
+
+GType gdk_x_colormap_get_type ();
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __GDK_COLOR_X11_H__ */
Index: gdk/x11/gdkdrawable-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkdrawable-x11.c,v
retrieving revision 1.2
diff -u -r1.2 gdkdrawable-x11.c
--- gdk/x11/gdkdrawable-x11.c 2000/03/28 01:24:43 1.2
+++ gdk/x11/gdkdrawable-x11.c 2000/05/15 22:33:27
@@ -135,21 +135,21 @@
GdkColormap *colormap)
{
GdkDrawablePrivate *drawable_private;
- GdkColormapPrivateX *colormap_private;
+ GdkXColormap *colormap_private;
g_return_if_fail (drawable != NULL);
g_return_if_fail (colormap != NULL);
drawable_private = (GdkDrawablePrivate *)drawable;
- colormap_private = (GdkColormapPrivateX *)colormap;
+ colormap_private = (GdkXColormap *)colormap;
if (!GDK_DRAWABLE_DESTROYED (drawable))
{
if (GDK_IS_WINDOW (drawable))
{
- g_return_if_fail (colormap_private->base.visual !=
- ((GdkColormapPrivate *)(drawable_private->colormap))->visual);
-
+ g_return_if_fail (colormap->visual !=
+ drawable_private->colormap->visual);
+
XSetWindowColormap (GDK_DRAWABLE_XDISPLAY (drawable),
GDK_DRAWABLE_XID (drawable),
colormap_private->xcolormap);
Index: gdk/x11/gdkpixmap-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkpixmap-x11.c,v
retrieving revision 1.31
diff -u -r1.31 gdkpixmap-x11.c
--- gdk/x11/gdkpixmap-x11.c 2000/03/28 01:24:43 1.31
+++ gdk/x11/gdkpixmap-x11.c 2000/05/15 22:33:27
@@ -483,7 +483,7 @@
visual = gdk_drawable_get_visual (window);
}
else
- visual = ((GdkColormapPrivate *)colormap)->visual;
+ visual = colormap->visual;
buffer = (*get_buf) (op_header, handle);
if (buffer == NULL)
Index: gdk/x11/gdkx.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkx.h,v
retrieving revision 1.9
diff -u -r1.9 gdkx.h
--- gdk/x11/gdkx.h 2000/03/28 01:24:43 1.9
+++ gdk/x11/gdkx.h 2000/05/15 22:33:27
@@ -33,11 +33,12 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
+#include <gdk/x11/gdkcolor-x11.h>
+
typedef struct _GdkGCXData GdkGCXData;
typedef struct _GdkDrawableXData GdkDrawableXData;
typedef struct _GdkWindowXData GdkWindowXData;
typedef struct _GdkXPositionInfo GdkXPositionInfo;
-typedef struct _GdkColormapPrivateX GdkColormapPrivateX;
typedef struct _GdkCursorPrivate GdkCursorPrivate;
typedef struct _GdkFontPrivateX GdkFontPrivateX;
typedef struct _GdkImagePrivateX GdkImagePrivateX;
@@ -110,19 +111,6 @@
Visual *xvisual;
};
-struct _GdkColormapPrivateX
-{
- GdkColormapPrivate base;
-
- Colormap xcolormap;
- Display *xdisplay;
- gint private_val;
-
- GHashTable *hash;
- GdkColorInfo *info;
- time_t last_sync_time;
-};
-
struct _GdkImagePrivateX
{
GdkImagePrivate base;
@@ -152,8 +140,8 @@
#define GDK_IMAGE_XDISPLAY(image) (((GdkImagePrivate*) image)->xdisplay)
#define GDK_IMAGE_XIMAGE(image) (((GdkImagePrivate*) image)->ximage)
#define GDK_GC_XDISPLAY(gc) (GDK_GC_XDATA(gc)->xdisplay)
-#define GDK_COLORMAP_XDISPLAY(cmap) (((GdkColormapPrivateX *)cmap)->xdisplay)
-#define GDK_COLORMAP_XCOLORMAP(cmap) (((GdkColormapPrivateX *)cmap)->xcolormap)
+#define GDK_COLORMAP_XDISPLAY(cmap) (((GdkXColormap *)cmap)->xdisplay)
+#define GDK_COLORMAP_XCOLORMAP(cmap) (((GdkXColormap *)cmap)->xcolormap)
#define GDK_VISUAL_XVISUAL(vis) (((GdkVisualPrivate*) vis)->xvisual)
#define GDK_FONT_XDISPLAY(font) (((GdkFontPrivate*) font)->xdisplay)
#define GDK_FONT_XFONT(font) (((GdkFontPrivateX *)font)->xfont)
Index: gtk/gtk-boxed.defs
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtk-boxed.defs,v
retrieving revision 1.5
diff -u -r1.5 gtk-boxed.defs
--- gtk/gtk-boxed.defs 1998/11/26 18:47:54 1.5
+++ gtk/gtk-boxed.defs 2000/05/15 22:33:27
@@ -29,10 +29,6 @@
; gdk_point_copy
; gdk_point_destroy)
-(define-boxed GdkColormap
- gdk_colormap_ref
- gdk_colormap_unref)
-
(define-boxed GdkVisual
gdk_visual_ref
gdk_visual_unref)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]