bonobo wrapper patch.



hi all,

once more, I have a bunch of patches to bonobo wrapper
cvs. 

Here is the latest patch. Miguel explained me he wanted me 
to mail him all patches. So, here it is so that everyone can 
remove it later :)

I love bonobo-wrapper.

This patch fixes a bug and does some code cleanups from the 
time I had added a feature on this thing and the feature got 
removed but most of the code stayed in it and miguel says it's 
a feature difficult to get right so it's gone for true now.
(I like stupid long sentences)



I love you all too.
LOVE is my drug.


best regards,
Mathieu.

-- 
Mathieu Lacage, mathieu@gnu.org
http://www.advogato.org/person/mathieu
ch 224, 212 Rue de Tolbiac, 75013 Paris, France



Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/bonobo/ChangeLog,v
retrieving revision 1.366
diff -u -r1.366 ChangeLog
--- ChangeLog	2000/04/30 10:52:33	1.366
+++ ChangeLog	2000/04/30 15:49:17
@@ -1,3 +1,13 @@
+2000-04-30  Mathieu Lacage <mathieu@gnu.org>
+
+	* bonobo/bonobo-wrapper.c: fixes a size negociation 
+	patch which tried to allocate 65xxx width and height
+	to the widget underlying the wrapper. this happened
+	because width and height are guint16 in GtkAllocation.
+	Also, code cleanups. Removed the old gc used to paint
+	on children and not around. This widget is nearing 
+	perfection ;)
+
 2000-04-29  Mathieu Lacage <mathieu@gnu.org>
 
 	* samples/compound-doc/sample-container.c: I am being
Index: bonobo/bonobo-wrapper.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-wrapper.c,v
retrieving revision 1.16
diff -u -r1.16 bonobo-wrapper.c
--- bonobo/bonobo-wrapper.c	2000/04/29 18:51:22	1.16
+++ bonobo/bonobo-wrapper.c	2000/04/30 15:49:19
@@ -39,8 +39,8 @@
 	/* Whether or not we should paint the cover. */
 	gboolean visible;
 
-	/* The GCs used for painting on the cover. */
-	GdkGC *gc[2];
+	/* The GC used for painting on the cover. */
+	GdkGC *gc;
 
 	/* The InputOnly window that covers the child */
 	GdkWindow *cover;
@@ -87,12 +87,9 @@
 
 	wrapper = BONOBO_WRAPPER (object);
 
-	if (wrapper->priv->gc[0] != NULL)
-		gdk_gc_destroy (wrapper->priv->gc[0]);
+	if (wrapper->priv->gc != NULL)
+		gdk_gc_destroy (wrapper->priv->gc);
 
-	if (wrapper->priv->gc[1] != NULL)
-		gdk_gc_destroy (wrapper->priv->gc[1]);
-
 	if (wrapper->priv->cover != NULL) {
 		gdk_window_set_user_data (wrapper->priv->cover, NULL);
 		gdk_window_destroy (wrapper->priv->cover);
@@ -226,22 +223,19 @@
 	gdk_window_set_user_data (widget->window, wrapper);
 
 	/*
-	 * The GCs used to draw the cover.
+	 * The GC used to draw the cover.
 	 */
 	gc_values.fill = GDK_STIPPLED;
 	gc_values.stipple = gdk_bitmap_create_from_data (widget->window,
 							 data_paint,
 							 BORDER_WIDTH, BORDER_WIDTH);
 	gc_values.subwindow_mode = GDK_CLIP_BY_CHILDREN;
-
-	wrapper->priv->gc[0] = gdk_gc_new_with_values (widget->window,
-						       &gc_values,
-						       GDK_GC_FILL | GDK_GC_STIPPLE | GDK_GC_SUBWINDOW);
-	gc_values.subwindow_mode = GDK_CLIP_BY_CHILDREN;
 
-	wrapper->priv->gc[1] = gdk_gc_new_with_values (widget->window,
-						       &gc_values,
-						       GDK_GC_FILL | GDK_GC_STIPPLE | GDK_GC_SUBWINDOW);
+	wrapper->priv->gc = gdk_gc_new_with_values (widget->window,
+						    &gc_values,
+						    GDK_GC_FILL | 
+						    GDK_GC_STIPPLE | 
+						    GDK_GC_SUBWINDOW);
 	gdk_pixmap_unref (gc_values.stipple);
 
 	/*
@@ -274,10 +268,8 @@
 
 	wrapper = BONOBO_WRAPPER (widget);
 
-	gdk_gc_destroy (wrapper->priv->gc[0]);
-	gdk_gc_destroy (wrapper->priv->gc[1]);
-	wrapper->priv->gc[0] = NULL;
-	wrapper->priv->gc[1] = NULL;
+	gdk_gc_destroy (wrapper->priv->gc);
+	wrapper->priv->gc = NULL;
 
 	gdk_window_set_user_data (wrapper->priv->cover, NULL);
 	gdk_window_destroy (wrapper->priv->cover);
@@ -355,13 +347,23 @@
 		if (!wrapper->priv->covered && wrapper->priv->visible) {
 			child_allocation.x += BORDER_WIDTH;
 			child_allocation.y += BORDER_WIDTH;
-			child_allocation.width -= BORDER_WIDTH * 2;
-			child_allocation.height -= BORDER_WIDTH * 2;
+			if (child_allocation.width < BORDER_WIDTH * 2)
+				child_allocation.width = 0;
+			else
+				child_allocation.width -= BORDER_WIDTH * 2;
+			if (child_allocation.height < BORDER_WIDTH * 2)
+				child_allocation.height = 1;
+			else
+				child_allocation.height -= BORDER_WIDTH * 2;
 		}
-
 		gtk_widget_size_allocate (wrapper->bin.child, &child_allocation);
 	}
-
+	/* The above if/then/else are necesary because you have to 
+	   make sure you don't calculate a width and height which 
+	   are around 65xxx (ie: width and height are guint16 so if
+	   you substract BORDER_WIDTH*2, you may end with a size of
+	   65xxx or so).
+	 */
 
 	gtk_signal_emit_by_name (GTK_OBJECT (widget), "draw");
 }
@@ -373,7 +375,7 @@
 
 	if (wrapper->priv->visible && !wrapper->priv->covered) {
 		gdk_draw_rectangle (widget->window,
-				    wrapper->priv->gc[1],
+				    wrapper->priv->gc,
 				    TRUE,
 				    0, 0,
 				    widget->allocation.width,
@@ -391,7 +393,7 @@
 bonobo_wrapper_expose (GtkWidget *widget, GdkEventExpose *event)
 {
 	bonobo_wrapper_paint (widget);
-	return TRUE;
+	return FALSE;
 }
 
 /**
@@ -497,3 +499,19 @@
 
 	return wrapper->priv->visible;
 }




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