Fix for the plug/socket workaround





Elliot discovered that the GtkPlug/Socket workaround I added for the
local case has some problems. In particular, it caused the socket to
be destroyed in the middle of realization, which Gtk+ really does not
like one bit. In fact, Gtk+ does not even like the widget hierarchy
changing in the middle of realization. The only solution I could find
is the gross hack below. I know it's ugly, but we need it for
Nautilus, and this problem will hopefully be fixed in Gtk+ itself
someday, so I hope it's OK to check in.






2000-02-01  Maciej Stachowiak  <mjs@eazel.com>

	* bonobo/bonobo/bonobo-control-frame.c, bonobo-control.c: Instead
	of using a GtkFrame to hold the socket and removing the socket in
	the local workaround case, use a GtkBox, and merely hide the
	socket in the local case. This is really gross but it's the only
	way to avoid destroying or removing the socket in the middle of
	realization.


Index: bonobo/bonobo-control-frame.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-control-frame.c,v
retrieving revision 1.12
diff -u -r1.12 bonobo-control-frame.c
--- bonobo/bonobo-control-frame.c	2000/01/29 11:02:31	1.12
+++ bonobo/bonobo-control-frame.c	2000/02/01 00:44:35
@@ -12,7 +12,7 @@
 #include <gtk/gtksignal.h>
 #include <gtk/gtkmarshal.h>
 #include <gtk/gtkplug.h>
-#include <gtk/gtkframe.h>
+#include <gtk/gtkbox.h>
 #include <bonobo/bonobo-main.h>
 #include <bonobo/bonobo-control.h>
 #include <bonobo/bonobo-control-frame.h>
@@ -200,15 +200,17 @@
 	gtk_widget_show (control_frame->priv->socket);
 
 	/*
-	 * Finally, create a frame to hold the socket; this no-window
+	 * Finally, create a box to hold the socket; this no-window
 	 * container is needed solely for the sake of bypassing
 	 * plug/socket in the local case.
 	 */
-	control_frame->priv->container = gtk_frame_new (NULL);
-	gtk_frame_set_shadow_type (GTK_FRAME (control_frame->priv->container), GTK_SHADOW_NONE);
+	control_frame->priv->container = gtk_hbox_new (1, 0);
 	gtk_container_set_border_width (GTK_CONTAINER (control_frame->priv->container), 0);
-	gtk_container_add (GTK_CONTAINER (control_frame->priv->container),
-			   control_frame->priv->socket);
+	gtk_box_pack_end (GTK_BOX (control_frame->priv->container),
+			  control_frame->priv->socket,
+			  TRUE, TRUE, 0);
+	gtk_widget_ref (control_frame->priv->container);
+	gtk_object_sink (GTK_OBJECT(control_frame->priv->container));
 	gtk_widget_show (control_frame->priv->container);
 
 	/*
@@ -260,6 +262,8 @@
 		CORBA_exception_free (&ev);
 	}
 	
+	gtk_widget_unref (control_frame->priv->container);
+
 	g_free (control_frame->priv);
 	
 	GTK_OBJECT_CLASS (bonobo_control_frame_parent_class)->destroy (object);
Index: bonobo/bonobo-control.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-control.c,v
retrieving revision 1.16
diff -u -r1.16 bonobo-control.c
--- bonobo/bonobo-control.c	2000/01/29 12:15:31	1.16
+++ bonobo/bonobo-control.c	2000/02/01 00:44:36
@@ -160,7 +160,7 @@
 
 
 
-GtkWidget *
+static GtkWidget *
 bonobo_gtk_widget_from_x11_id (guint32 xid)
 {
 	GdkWindow *window;
@@ -198,9 +198,11 @@
 		GtkWidget *socket_parent;
 		control->priv->is_local = TRUE;
 		socket_parent = local_socket->parent;
-		gtk_container_remove (GTK_CONTAINER (socket_parent), local_socket);
-		gtk_container_add (GTK_CONTAINER (socket_parent), control->priv->widget);
-		gtk_widget_show_all (control->priv->widget);
+		gtk_widget_hide(local_socket);
+
+		gtk_box_pack_end (GTK_BOX (socket_parent),
+				  control->priv->widget,
+				  TRUE, TRUE, 0);
 	} else {
 		control->priv->plug = gtk_plug_new (x11_id);
 		control->priv->plug_destroy_id = gtk_signal_connect (



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