Re: GtkLabel inside GtkEventBox causes gtk_label_set_text() to misbehave




Dave Cole <dave@dccs.com.au> writes:

> I am not sure if this is a bug or not, but it is certainly unexpected.
> 
> If you put a label inside an event box, when you call
> gtk_label_set_text(), the old label text is not erased before the new
> label is drawn.  Labels inside buttons are redrawn correctly though.

The new label being drawn on top of the old label is pretty
clearly a bug to me. ;-)

Here's the patch I'm applying. Thanks for the report.

                                        Owen

Index: gtkeventbox.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkeventbox.c,v
retrieving revision 1.15
diff -u -r1.15 gtkeventbox.c
--- gtkeventbox.c	1998/11/30 19:05:46	1.15
+++ gtkeventbox.c	1999/01/15 15:16:10
@@ -27,10 +27,12 @@
 						    GtkRequisition   *requisition);
 static void gtk_event_box_size_allocate            (GtkWidget        *widget,
 						    GtkAllocation    *allocation);
-static void gtk_event_box_draw                     (GtkWidget    *widget,
-						   GdkRectangle *area);
-static gint gtk_event_box_expose                   (GtkWidget      *widget,
-						   GdkEventExpose *event);
+static void gtk_event_box_paint                    (GtkWidget         *widget,
+						    GdkRectangle      *area)
+static void gtk_event_box_draw                     (GtkWidget         *widget,
+						   GdkRectangle       *area);
+static gint gtk_event_box_expose                   (GtkWidget         *widget,
+						   GdkEventExpose     *event);
 
 
 GtkType
@@ -182,8 +184,18 @@
 }
 
 static void
+gtk_event_box_paint (GtkWidget    *widget,
+		     GdkRectangle *area)
+{
+  gtk_paint_flat_box (widget->style, widget->window,
+		      widget->state, GTK_SHADOW_NONE,
+		      area, widget, "eventbox",
+		      0, 0, -1, -1);
+}
+
+static void
 gtk_event_box_draw (GtkWidget    *widget,
-		   GdkRectangle *area)
+		    GdkRectangle *area)
 {
   GtkBin *bin;
   GdkRectangle tmp_area;
@@ -198,6 +210,8 @@
       tmp_area = *area;
       tmp_area.x -= GTK_CONTAINER (widget)->border_width;
       tmp_area.y -= GTK_CONTAINER (widget)->border_width;
+
+      gtk_event_box_paint (widget, &tmp_area);
       
       if (bin->child)
 	{
@@ -222,6 +236,8 @@
     {
       bin = GTK_BIN (widget);
 
+      gtk_event_box_paint (widget, &event->area);
+      
       child_event = *event;
       if (bin->child &&
 	  GTK_WIDGET_NO_WINDOW (bin->child) &&



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