better error message if you try to add a widget to a bin that already has

2001-02-08  Havoc Pennington  <hp@redhat.com>

	* gtk/gtkbin.c (gtk_bin_add): better error message if you try to
	add a widget to a bin that already has a child.

	* gdk/gdkcc.h, gdk/gdkcc-x11.c: Remove GdkColorContext, #50512

	* docs/Changes-2.0.txt: note that GdkColorContext is gone.

	* gdk/x11/Makefile.am (libgdk_x11_la_SOURCES): remove gdkcc-x11.c

	* gdk/gdk.h: remove gdkcc.h

	* gdk/Makefile.am (gdk_public_h_sources): remove gdkcc.h

	* gtk/gtkpixmap.c (build_insensitive_pixmap): rewrite using
	GdkPixbuf, since the previous implementation was GdkColorContext
	dependent.

	* gtk/testgtk.c (create_pixmap): add test for insensitive GtkPixmap
This commit is contained in:
Havoc Pennington 2001-02-09 00:40:48 +00:00 committed by Havoc Pennington
parent 589b472609
commit 45510aefc3
17 changed files with 219 additions and 1962 deletions

View File

@ -1,3 +1,24 @@
2001-02-08 Havoc Pennington <hp@redhat.com>
* gtk/gtkbin.c (gtk_bin_add): better error message if you try to
add a widget to a bin that already has a child.
* gdk/gdkcc.h, gdk/gdkcc-x11.c: Remove GdkColorContext, #50512
* docs/Changes-2.0.txt: note that GdkColorContext is gone.
* gdk/x11/Makefile.am (libgdk_x11_la_SOURCES): remove gdkcc-x11.c
* gdk/gdk.h: remove gdkcc.h
* gdk/Makefile.am (gdk_public_h_sources): remove gdkcc.h
* gtk/gtkpixmap.c (build_insensitive_pixmap): rewrite using
GdkPixbuf, since the previous implementation was GdkColorContext
dependent.
* gtk/testgtk.c (create_pixmap): add test for insensitive GtkPixmap
Thu Feb 8 19:00:00 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (TREE_VIEW_VERTICAL_SEPARATOR): moved back to

View File

@ -1,3 +1,24 @@
2001-02-08 Havoc Pennington <hp@redhat.com>
* gtk/gtkbin.c (gtk_bin_add): better error message if you try to
add a widget to a bin that already has a child.
* gdk/gdkcc.h, gdk/gdkcc-x11.c: Remove GdkColorContext, #50512
* docs/Changes-2.0.txt: note that GdkColorContext is gone.
* gdk/x11/Makefile.am (libgdk_x11_la_SOURCES): remove gdkcc-x11.c
* gdk/gdk.h: remove gdkcc.h
* gdk/Makefile.am (gdk_public_h_sources): remove gdkcc.h
* gtk/gtkpixmap.c (build_insensitive_pixmap): rewrite using
GdkPixbuf, since the previous implementation was GdkColorContext
dependent.
* gtk/testgtk.c (create_pixmap): add test for insensitive GtkPixmap
Thu Feb 8 19:00:00 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (TREE_VIEW_VERTICAL_SEPARATOR): moved back to

View File

@ -1,3 +1,24 @@
2001-02-08 Havoc Pennington <hp@redhat.com>
* gtk/gtkbin.c (gtk_bin_add): better error message if you try to
add a widget to a bin that already has a child.
* gdk/gdkcc.h, gdk/gdkcc-x11.c: Remove GdkColorContext, #50512
* docs/Changes-2.0.txt: note that GdkColorContext is gone.
* gdk/x11/Makefile.am (libgdk_x11_la_SOURCES): remove gdkcc-x11.c
* gdk/gdk.h: remove gdkcc.h
* gdk/Makefile.am (gdk_public_h_sources): remove gdkcc.h
* gtk/gtkpixmap.c (build_insensitive_pixmap): rewrite using
GdkPixbuf, since the previous implementation was GdkColorContext
dependent.
* gtk/testgtk.c (create_pixmap): add test for insensitive GtkPixmap
Thu Feb 8 19:00:00 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (TREE_VIEW_VERTICAL_SEPARATOR): moved back to

View File

@ -1,3 +1,24 @@
2001-02-08 Havoc Pennington <hp@redhat.com>
* gtk/gtkbin.c (gtk_bin_add): better error message if you try to
add a widget to a bin that already has a child.
* gdk/gdkcc.h, gdk/gdkcc-x11.c: Remove GdkColorContext, #50512
* docs/Changes-2.0.txt: note that GdkColorContext is gone.
* gdk/x11/Makefile.am (libgdk_x11_la_SOURCES): remove gdkcc-x11.c
* gdk/gdk.h: remove gdkcc.h
* gdk/Makefile.am (gdk_public_h_sources): remove gdkcc.h
* gtk/gtkpixmap.c (build_insensitive_pixmap): rewrite using
GdkPixbuf, since the previous implementation was GdkColorContext
dependent.
* gtk/testgtk.c (create_pixmap): add test for insensitive GtkPixmap
Thu Feb 8 19:00:00 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (TREE_VIEW_VERTICAL_SEPARATOR): moved back to

View File

@ -1,3 +1,24 @@
2001-02-08 Havoc Pennington <hp@redhat.com>
* gtk/gtkbin.c (gtk_bin_add): better error message if you try to
add a widget to a bin that already has a child.
* gdk/gdkcc.h, gdk/gdkcc-x11.c: Remove GdkColorContext, #50512
* docs/Changes-2.0.txt: note that GdkColorContext is gone.
* gdk/x11/Makefile.am (libgdk_x11_la_SOURCES): remove gdkcc-x11.c
* gdk/gdk.h: remove gdkcc.h
* gdk/Makefile.am (gdk_public_h_sources): remove gdkcc.h
* gtk/gtkpixmap.c (build_insensitive_pixmap): rewrite using
GdkPixbuf, since the previous implementation was GdkColorContext
dependent.
* gtk/testgtk.c (create_pixmap): add test for insensitive GtkPixmap
Thu Feb 8 19:00:00 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (TREE_VIEW_VERTICAL_SEPARATOR): moved back to

View File

@ -1,3 +1,24 @@
2001-02-08 Havoc Pennington <hp@redhat.com>
* gtk/gtkbin.c (gtk_bin_add): better error message if you try to
add a widget to a bin that already has a child.
* gdk/gdkcc.h, gdk/gdkcc-x11.c: Remove GdkColorContext, #50512
* docs/Changes-2.0.txt: note that GdkColorContext is gone.
* gdk/x11/Makefile.am (libgdk_x11_la_SOURCES): remove gdkcc-x11.c
* gdk/gdk.h: remove gdkcc.h
* gdk/Makefile.am (gdk_public_h_sources): remove gdkcc.h
* gtk/gtkpixmap.c (build_insensitive_pixmap): rewrite using
GdkPixbuf, since the previous implementation was GdkColorContext
dependent.
* gtk/testgtk.c (create_pixmap): add test for insensitive GtkPixmap
Thu Feb 8 19:00:00 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (TREE_VIEW_VERTICAL_SEPARATOR): moved back to

View File

@ -1,3 +1,24 @@
2001-02-08 Havoc Pennington <hp@redhat.com>
* gtk/gtkbin.c (gtk_bin_add): better error message if you try to
add a widget to a bin that already has a child.
* gdk/gdkcc.h, gdk/gdkcc-x11.c: Remove GdkColorContext, #50512
* docs/Changes-2.0.txt: note that GdkColorContext is gone.
* gdk/x11/Makefile.am (libgdk_x11_la_SOURCES): remove gdkcc-x11.c
* gdk/gdk.h: remove gdkcc.h
* gdk/Makefile.am (gdk_public_h_sources): remove gdkcc.h
* gtk/gtkpixmap.c (build_insensitive_pixmap): rewrite using
GdkPixbuf, since the previous implementation was GdkColorContext
dependent.
* gtk/testgtk.c (create_pixmap): add test for insensitive GtkPixmap
Thu Feb 8 19:00:00 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (TREE_VIEW_VERTICAL_SEPARATOR): moved back to

View File

@ -293,3 +293,6 @@ Incompatible Changes from GTK+-1.2 to GTK+-2.0:
broken widgets are not declared in the headers by default; to use
them, define the symbol GTK_ENABLE_BROKEN during compilation. In
some future release, these widgets will be removed from GTK+.
- GdkColorContext is gone; you probably weren't using it anyway.
Use GdkColormap and the gdk_rgb_* functions instead.

View File

@ -51,7 +51,6 @@ LDFLAGS = @STRIP_BEGIN@ \
#
gdk_public_h_sources = @STRIP_BEGIN@ \
gdk.h \
gdkcc.h \
gdkcolor.h \
gdkcompat.h \
gdkcursor.h \

View File

@ -27,7 +27,6 @@
#ifndef __GDK_H__
#define __GDK_H__
#include <gdk/gdkcc.h>
#include <gdk/gdkcolor.h>
#include <gdk/gdkcursor.h>
#include <gdk/gdkdnd.h>

View File

@ -1,149 +0,0 @@
#ifndef __GDK_CC_H__
#define __GDK_CC_H__
#include <gdk/gdktypes.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct _GdkColorContextDither GdkColorContextDither;
typedef struct _GdkColorContext GdkColorContext;
/* Color Context modes.
*
* GDK_CC_MODE_UNDEFINED - unknown
* GDK_CC_MODE_BW - default B/W
* GDK_CC_MODE_STD_CMAP - has a standard colormap
* GDK_CC_MODE_TRUE - is a TrueColor/DirectColor visual
* GDK_CC_MODE_MY_GRAY - my grayramp
* GDK_CC_MODE_PALETTE - has a pre-allocated palette
*/
typedef enum
{
GDK_CC_MODE_UNDEFINED,
GDK_CC_MODE_BW,
GDK_CC_MODE_STD_CMAP,
GDK_CC_MODE_TRUE,
GDK_CC_MODE_MY_GRAY,
GDK_CC_MODE_PALETTE
} GdkColorContextMode;
struct _GdkColorContextDither
{
gint fast_rgb[32][32][32]; /* quick look-up table for faster rendering */
gint fast_err[32][32][32]; /* internal RGB error information */
gint fast_erg[32][32][32];
gint fast_erb[32][32][32];
};
struct _GdkColorContext
{
GdkVisual *visual;
GdkColormap *colormap;
gint num_colors; /* available no. of colors in colormap */
gint max_colors; /* maximum no. of colors */
gint num_allocated; /* no. of allocated colors */
GdkColorContextMode mode;
gint need_to_free_colormap;
GdkAtom std_cmap_atom;
gulong *clut; /* color look-up table */
GdkColor *cmap; /* colormap */
GHashTable *color_hash; /* hash table of allocated colors */
GdkColor *palette; /* preallocated palette */
gint num_palette; /* size of palette */
GdkColorContextDither *fast_dither; /* fast dither matrix */
struct
{
gint red;
gint green;
gint blue;
} shifts;
struct
{
gulong red;
gulong green;
gulong blue;
} masks;
struct
{
gint red;
gint green;
gint blue;
} bits;
gulong max_entry;
gulong black_pixel;
gulong white_pixel;
};
GdkColorContext *gdk_color_context_new (GdkVisual *visual,
GdkColormap *colormap);
GdkColorContext *gdk_color_context_new_mono (GdkVisual *visual,
GdkColormap *colormap);
void gdk_color_context_free (GdkColorContext *cc);
gulong gdk_color_context_get_pixel (GdkColorContext *cc,
gushort red,
gushort green,
gushort blue,
gint *failed);
void gdk_color_context_get_pixels (GdkColorContext *cc,
gushort *reds,
gushort *greens,
gushort *blues,
gint ncolors,
gulong *colors,
gint *nallocated);
void gdk_color_context_get_pixels_incremental (GdkColorContext *cc,
gushort *reds,
gushort *greens,
gushort *blues,
gint ncolors,
gint *used,
gulong *colors,
gint *nallocated);
gint gdk_color_context_query_color (GdkColorContext *cc,
GdkColor *color);
gint gdk_color_context_query_colors (GdkColorContext *cc,
GdkColor *colors,
gint num_colors);
gint gdk_color_context_add_palette (GdkColorContext *cc,
GdkColor *palette,
gint num_palette);
void gdk_color_context_init_dither (GdkColorContext *cc);
void gdk_color_context_free_dither (GdkColorContext *cc);
gulong gdk_color_context_get_pixel_from_palette (GdkColorContext *cc,
gushort *red,
gushort *green,
gushort *blue,
gint *failed);
guchar gdk_color_context_get_index_from_palette (GdkColorContext *cc,
gint *red,
gint *green,
gint *blue,
gint *failed);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GDK_CC_H__ */

View File

@ -43,7 +43,6 @@ endif
libgdk_x11_la_SOURCES = \
MwmUtil.h \
gdkcc-x11.c \
gdkcolor-x11.c \
gdkcursor-x11.c \
gdkdnd-x11.c \

File diff suppressed because it is too large Load Diff

View File

@ -189,7 +189,18 @@ gtk_bin_add (GtkContainer *container,
g_return_if_fail (GTK_IS_WIDGET (child));
bin = GTK_BIN (container);
g_return_if_fail (bin->child == NULL);
if (bin->child != NULL)
{
g_warning ("Attempting to add a widget with type %s to a %s, "
"but as a GtkBin subclass a %s can only contain one widget at a time; "
"it already contains a widget of type %s",
g_type_name (G_TYPE_FROM_INSTANCE (child)),
g_type_name (G_TYPE_FROM_INSTANCE (bin)),
g_type_name (G_TYPE_FROM_INSTANCE (bin)),
g_type_name (G_TYPE_FROM_INSTANCE (bin->child)));
return;
}
gtk_widget_set_parent (child, GTK_WIDGET (bin));
bin->child = child;

View File

@ -261,98 +261,43 @@ gtk_pixmap_set_build_insensitive (GtkPixmap *pixmap, guint build)
static void
build_insensitive_pixmap(GtkPixmap *gtkpixmap)
{
GdkGC *gc;
GdkPixmap *pixmap = gtkpixmap->pixmap;
GdkPixmap *insensitive;
gint w, h, x, y;
GdkGCValues vals;
GdkVisual *visual;
GdkImage *image;
GdkColorContext *cc;
GdkColor color;
GdkColormap *cmap;
gint32 red, green, blue;
GtkStyle *style;
GtkWidget *window;
GdkColor c;
int failed;
gint w, h;
GdkPixbuf *pixbuf;
GdkPixbuf *stated;
window = GTK_WIDGET (gtkpixmap);
gdk_window_get_size (pixmap, &w, &h);
g_return_if_fail(window != NULL);
pixbuf = gdk_pixbuf_get_from_drawable (NULL,
pixmap,
gtk_widget_get_colormap (GTK_WIDGET(gtkpixmap)),
0, 0,
0, 0,
w, h);
gdk_window_get_size(pixmap, &w, &h);
image = gdk_image_get(pixmap, 0, 0, w, h);
insensitive = gdk_pixmap_new(GTK_WIDGET (gtkpixmap)->window, w, h, -1);
gc = gdk_gc_new (pixmap);
stated = gdk_pixbuf_copy (pixbuf);
visual = gtk_widget_get_visual(GTK_WIDGET(gtkpixmap));
cmap = gtk_widget_get_colormap(GTK_WIDGET(gtkpixmap));
cc = gdk_color_context_new(visual, cmap);
gdk_pixbuf_saturate_and_pixelate (pixbuf, stated,
0.8, TRUE);
if ((cc->mode != GDK_CC_MODE_TRUE) && (cc->mode != GDK_CC_MODE_MY_GRAY))
{
gdk_draw_image(insensitive, gc, image, 0, 0, 0, 0, w, h);
g_object_unref (G_OBJECT (pixbuf));
pixbuf = NULL;
style = gtk_widget_get_style(window);
color = style->bg[0];
gdk_gc_set_foreground (gc, &color);
for (y = 0; y < h; y++)
{
for (x = y % 2; x < w; x += 2)
{
gdk_draw_point(insensitive, gc, x, y);
}
}
}
else
{
gdk_gc_get_values(gc, &vals);
style = gtk_widget_get_style(window);
insensitive = gdk_pixmap_new (GTK_WIDGET (gtkpixmap)->window, w, h, -1);
color = style->bg[0];
red = color.red;
green = color.green;
blue = color.blue;
for (y = 0; y < h; y++)
{
for (x = 0; x < w; x++)
{
c.pixel = gdk_image_get_pixel(image, x, y);
gdk_color_context_query_color(cc, &c);
c.red = (((gint32)c.red - red) >> 1) + red;
c.green = (((gint32)c.green - green) >> 1) + green;
c.blue = (((gint32)c.blue - blue) >> 1) + blue;
c.pixel = gdk_color_context_get_pixel(cc, c.red, c.green, c.blue,
&failed);
gdk_image_put_pixel(image, x, y, c.pixel);
}
}
for (y = 0; y < h; y++)
{
for (x = y % 2; x < w; x += 2)
{
c.pixel = gdk_image_get_pixel(image, x, y);
gdk_color_context_query_color(cc, &c);
c.red = (((gint32)c.red - red) >> 1) + red;
c.green = (((gint32)c.green - green) >> 1) + green;
c.blue = (((gint32)c.blue - blue) >> 1) + blue;
c.pixel = gdk_color_context_get_pixel(cc, c.red, c.green, c.blue,
&failed);
gdk_image_put_pixel(image, x, y, c.pixel);
}
}
gdk_draw_image(insensitive, gc, image, 0, 0, 0, 0, w, h);
}
gdk_pixbuf_render_to_drawable (stated,
insensitive,
GTK_WIDGET (gtkpixmap)->style->white_gc,
0, 0,
0, 0,
w, h,
GDK_RGB_DITHER_NORMAL,
0, 0);
gtkpixmap->pixmap_insensitive = insensitive;
gdk_image_destroy(image);
gdk_color_context_free(cc);
gdk_gc_destroy(gc);
g_object_unref (G_OBJECT (stated));
}

View File

@ -1988,7 +1988,6 @@ static GtkWidget*
create_sensitivity_control (GtkWidget *widget)
{
GtkWidget *button;
GtkWidget *toplevel;
button = gtk_toggle_button_new_with_label ("Sensitive");
@ -2442,6 +2441,20 @@ create_pixmap (void)
gtk_container_add (GTK_CONTAINER (box3), label);
gtk_container_add (GTK_CONTAINER (button), box3);
button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (box2), button, FALSE, FALSE, 0);
pixmapwid = new_pixmap ("test.xpm", window->window, NULL);
label = gtk_label_new ("Pixmap\ntest");
box3 = gtk_hbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (box3), 2);
gtk_container_add (GTK_CONTAINER (box3), pixmapwid);
gtk_container_add (GTK_CONTAINER (box3), label);
gtk_container_add (GTK_CONTAINER (button), box3);
gtk_widget_set_sensitive (button, FALSE);
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);

View File

@ -1988,7 +1988,6 @@ static GtkWidget*
create_sensitivity_control (GtkWidget *widget)
{
GtkWidget *button;
GtkWidget *toplevel;
button = gtk_toggle_button_new_with_label ("Sensitive");
@ -2442,6 +2441,20 @@ create_pixmap (void)
gtk_container_add (GTK_CONTAINER (box3), label);
gtk_container_add (GTK_CONTAINER (button), box3);
button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (box2), button, FALSE, FALSE, 0);
pixmapwid = new_pixmap ("test.xpm", window->window, NULL);
label = gtk_label_new ("Pixmap\ntest");
box3 = gtk_hbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (box3), 2);
gtk_container_add (GTK_CONTAINER (box3), pixmapwid);
gtk_container_add (GTK_CONTAINER (box3), label);
gtk_container_add (GTK_CONTAINER (button), box3);
gtk_widget_set_sensitive (button, FALSE);
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);