summaryrefslogtreecommitdiff
path: root/gtk/gtkpixmap.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@src.gnome.org>1997-12-18 02:17:14 +0000
committerOwen Taylor <otaylor@src.gnome.org>1997-12-18 02:17:14 +0000
commitd5d01a5af9aaa11762d7ba86760796df00af3786 (patch)
treec12bb7c7980b3177456cab8987755a976297b205 /gtk/gtkpixmap.c
parent65e63db01e93820093c2eb5169d5f8c0be3fe4e5 (diff)
downloadgtk+-d5d01a5af9aaa11762d7ba86760796df00af3786.tar.gz
It's all in the changelog. Well, almost all.
-owt
Diffstat (limited to 'gtk/gtkpixmap.c')
-rw-r--r--gtk/gtkpixmap.c55
1 files changed, 41 insertions, 14 deletions
diff --git a/gtk/gtkpixmap.c b/gtk/gtkpixmap.c
index ae640f81f1..66ef1538cc 100644
--- a/gtk/gtkpixmap.c
+++ b/gtk/gtkpixmap.c
@@ -23,7 +23,9 @@ static void gtk_pixmap_class_init (GtkPixmapClass *klass);
static void gtk_pixmap_init (GtkPixmap *pixmap);
static gint gtk_pixmap_expose (GtkWidget *widget,
GdkEventExpose *event);
+static void gtk_pixmap_destroy (GtkObject *object);
+static GtkWidgetClass *parent_class;
guint
gtk_pixmap_get_type ()
@@ -51,10 +53,14 @@ gtk_pixmap_get_type ()
static void
gtk_pixmap_class_init (GtkPixmapClass *class)
{
+ GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
+ object_class = (GtkObjectClass*) class;
widget_class = (GtkWidgetClass*) class;
+ parent_class = gtk_type_class (gtk_widget_get_type ());
+ object_class->destroy = gtk_pixmap_destroy;
widget_class->expose_event = gtk_pixmap_expose;
}
@@ -82,6 +88,14 @@ gtk_pixmap_new (GdkPixmap *val,
return GTK_WIDGET (pixmap);
}
+static void
+gtk_pixmap_destroy (GtkObject *object)
+{
+ gtk_pixmap_set (GTK_PIXMAP (object), NULL, NULL);
+ if (GTK_OBJECT_CLASS (parent_class)->destroy)
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+}
+
void
gtk_pixmap_set (GtkPixmap *pixmap,
GdkPixmap *val,
@@ -92,25 +106,38 @@ gtk_pixmap_set (GtkPixmap *pixmap,
g_return_if_fail (pixmap != NULL);
g_return_if_fail (GTK_IS_PIXMAP (pixmap));
- g_return_if_fail (val != NULL);
- pixmap->pixmap = val;
- pixmap->mask = mask;
-
- if (pixmap->pixmap)
+ if (pixmap->pixmap != val)
{
- gdk_window_get_size (pixmap->pixmap, &width, &height);
- GTK_WIDGET (pixmap)->requisition.width = width + GTK_MISC (pixmap)->xpad * 2;
- GTK_WIDGET (pixmap)->requisition.height = height + GTK_MISC (pixmap)->ypad * 2;
+ if (pixmap->pixmap)
+ gdk_pixmap_unref (pixmap->pixmap);
+ pixmap->pixmap = val;
+ if (pixmap->pixmap)
+ {
+ gdk_pixmap_ref (pixmap->pixmap);
+ gdk_window_get_size (pixmap->pixmap, &width, &height);
+ GTK_WIDGET (pixmap)->requisition.width =
+ width + GTK_MISC (pixmap)->xpad * 2;
+ GTK_WIDGET (pixmap)->requisition.height =
+ height + GTK_MISC (pixmap)->ypad * 2;
+ }
+ else
+ {
+ GTK_WIDGET (pixmap)->requisition.width = 0;
+ GTK_WIDGET (pixmap)->requisition.height = 0;
+ }
+ if (GTK_WIDGET_VISIBLE (pixmap))
+ gtk_widget_queue_resize (GTK_WIDGET (pixmap));
}
- else
+
+ if (pixmap->mask != mask)
{
- GTK_WIDGET (pixmap)->requisition.width = 0;
- GTK_WIDGET (pixmap)->requisition.height = 0;
+ if (pixmap->mask)
+ gdk_bitmap_unref (pixmap->mask);
+ pixmap->mask = mask;
+ if (pixmap->mask)
+ gdk_bitmap_ref (pixmap->mask);
}
-
- if (GTK_WIDGET_VISIBLE (pixmap))
- gtk_widget_queue_resize (GTK_WIDGET (pixmap));
}
void