[PATCH] Bugfix for GtkToggleButton



Hello,

I've found a bug in GtkToggleButton. The bug occurs when a toggle button
is set both active and insensitive. In that case it's drawn as
non-active. http://Tomas.Ogren.mw.mw/tmp/gtk.png demonstrates this.

This bug occurs because GtkToggleButton uses its parent's (GtkButton)
expose handler, which don't care about the active flag of
GtkToggleButton.

I'm not sure this patch is the cleanest way to fix the bug, but I assume
you get the point :) It's against gtk+ 1.2 but I think that HEAD has the
bug too.

//andersca
andersca gnu org
Index: gtktogglebutton.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktogglebutton.c,v
retrieving revision 1.24
diff -u -r1.24 gtktogglebutton.c
--- gtktogglebutton.c	1999/02/24 07:36:40	1.24
+++ gtktogglebutton.c	2000/11/20 06:25:14
@@ -401,11 +401,26 @@
 gtk_toggle_button_expose (GtkWidget      *widget,
 			  GdkEventExpose *event)
 {
-  if (!GTK_WIDGET_NO_WINDOW (widget) &&
-      GTK_WIDGET_CLASS (parent_class)->expose_event)
-    return GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
-  else
-    return FALSE;
+  GtkBin *bin;
+  GdkEventExpose child_event;
+
+  g_return_val_if_fail (widget != NULL, FALSE);
+  g_return_val_if_fail (GTK_IS_BUTTON (widget), FALSE);
+  g_return_val_if_fail (event != NULL, FALSE);
+  
+  if (GTK_WIDGET_DRAWABLE (widget))
+    {
+      bin = GTK_BIN (widget);
+      
+      gtk_toggle_button_paint (widget, &event->area);
+      
+      child_event = *event;
+      if (bin->child && GTK_WIDGET_NO_WINDOW (bin->child) &&
+	  gtk_widget_intersect (bin->child, &event->area, &child_event.area))
+	gtk_widget_event (bin->child, (GdkEvent*) &child_event);
+    }
+
+  return FALSE;
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]