Various bug fixes



The following patch fixes three significant bugs that Nautilus runs
into. First, the plug/socket local bypass thing sometimes results in
the socket appearing as a floating grey box in the middle of the
UI. Second, the text/plain component had a division by zero error
whenever you use the ProgressiveDataSink interface. And finally, the
text-plain component never exited dude to foolishly using a
gtk_signal_connect_after on the "destroy" signal, which for obvious
reasons can't work.

I'll check this in Sunday or Monday or so unless thee are objections.


Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/bonobo/ChangeLog,v
retrieving revision 1.569
diff -u -p -r1.569 ChangeLog
--- ChangeLog	2000/10/07 01:40:52	1.569
+++ ChangeLog	2000/10/07 02:18:38
@@ -1,3 +1,34 @@
+2000-10-06  Maciej Stachowiak  <mjs eazel com>
+
+	* bonobo/bonobo-control.c: 
+	(impl_Bonobo_Control_set_window): In the local bypass case, don't
+	just `gtk_widget_hide' the GtkSocket, destroy it, or it might come
+	back as a floating mystery gray box.
+	(idle_destroy_socket): But we can't just destroy it, because you
+	can't destroy a widget from a handler for the "realized" signal,
+	or bad things happen.
+	(remove_destroy_idle): But we need to remove the idle callback if
+	the socket gets destroyed.
+	(bonobo_control_destroy): Or if the control gets destroyed.
+
+	* bonobo/bonobo-control-frame.c:
+	(bonobo_control_frame_socket_destroy): handle the socket being
+	destroyed.
+	(bonobo_control_frame_create_socket): factor out the code to
+	recreate the socket
+	(bonobo_control_frame_construct): use the above
+	(bonobo_control_frame_bind_to_control): create socket as needed.
+
+	* components/text-plain/bonobo-text-plain.c
+	(progressive_update): Avoid dividing by zero when the total size
+	has not been set.
+
+	(embeddable_factory): Connect the "destroy" signal with
+	`gtk_signal_connect', not `gtk_signal_connect_after'; `after'
+	connections to the "destroy" signal don't work because the default
+	destroy handler disconnects all signal handlers. This is needed to
+	make bonobo-text-plain exit when it should.
+
 2000-10-07  Michael Meeks  <michael helixcode com>
 
 	* bonobo/bonobo-win.c (reinstate_fn): prune widget info (
Index: bonobo/bonobo-control-frame.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-control-frame.c,v
retrieving revision 1.36
diff -u -p -r1.36 bonobo-control-frame.c
--- bonobo/bonobo-control-frame.c	2000/10/05 05:08:18	1.36
+++ bonobo/bonobo-control-frame.c	2000/10/07 02:18:38
@@ -180,6 +180,7 @@ bonobo_control_frame_autoactivate_focus_
 	return FALSE;
 }
 
+
 static void
 bonobo_control_frame_socket_state_changed (GtkWidget    *socket,
 					   GtkStateType  previous_state,
@@ -195,6 +196,16 @@ bonobo_control_frame_socket_state_change
 		GTK_WIDGET_STATE (control_frame->priv->socket));
 }
 
+
+static void
+bonobo_control_frame_socket_destroy (GtkWidget          *socket,
+				     BonoboControlFrame *control_frame)
+{
+	gtk_widget_unref (control_frame->priv->socket);
+	control_frame->priv->socket = NULL;
+}
+
+
 static void
 bonobo_control_frame_set_remote_window (GtkWidget          *socket,
 					BonoboControlFrame *control_frame)
@@ -229,6 +240,70 @@ bonobo_control_frame_set_remote_window (
 	CORBA_exception_free (&ev);
 }
 
+static void
+bonobo_control_frame_create_socket (BonoboControlFrame  *control_frame)
+{
+	/*
+	 * Now create the GtkSocket which will be used to embed
+	 * the Control.
+	 */
+	control_frame->priv->socket = bonobo_socket_new ();
+	gtk_widget_show (control_frame->priv->socket);
+
+	/*
+	 * Connect to the focus events on the socket so
+	 * that we can provide the autoactivation feature.
+	 */
+	gtk_signal_connect (GTK_OBJECT (control_frame->priv->socket),
+			    "focus_in_event",
+			    GTK_SIGNAL_FUNC (bonobo_control_frame_autoactivate_focus_in),
+			    control_frame);
+
+	gtk_signal_connect (GTK_OBJECT (control_frame->priv->socket),
+			    "focus_out_event",
+			    GTK_SIGNAL_FUNC (bonobo_control_frame_autoactivate_focus_out),
+			    control_frame);
+
+	/*
+	 * Setup a handler to proxy state changes.
+	 */
+	gtk_signal_connect (GTK_OBJECT (control_frame->priv->socket),
+			    "state_changed",
+			    bonobo_control_frame_socket_state_changed,
+			    control_frame);
+
+	/*
+	 * Setup a handler for socket destroy.
+	 */
+	gtk_signal_connect (GTK_OBJECT (control_frame->priv->socket),
+			    "destroy",
+			    bonobo_control_frame_socket_destroy,
+			    control_frame);
+
+	/*
+	 * Ref the socket so we can handle the case of the control destroying it for bypass.
+	 */
+	gtk_object_ref (GTK_OBJECT (control_frame->priv->socket));
+
+
+	/*
+	 * Pack into the hack box
+	 */
+	gtk_box_pack_start (GTK_BOX (control_frame->priv->container),
+			    control_frame->priv->socket,
+			    TRUE, TRUE, 0);
+
+	/*
+	 * When the socket is realized, we pass its Window ID to our
+	 * Control.
+	 */
+	gtk_signal_connect (GTK_OBJECT (control_frame->priv->socket),
+			    "realize",
+			    GTK_SIGNAL_FUNC (bonobo_control_frame_set_remote_window),
+			    control_frame);
+}
+				
+
 /**
  * bonobo_control_frame_construct:
  * @control_frame: The #BonoboControlFrame object to be initialized.
@@ -262,56 +337,17 @@ bonobo_control_frame_construct (BonoboCo
 	control_frame->priv->ui_container = ui_container;
 
 	/*
-	 * Now create the GtkSocket which will be used to embed
-	 * the Control.
-	 */
-	control_frame->priv->socket = bonobo_socket_new ();
-	gtk_widget_show (control_frame->priv->socket);
-
-	/*
-	 * Connect to the focus events on the socket so
-	 * that we can provide the autoactivation feature.
-	 */
-	gtk_signal_connect (GTK_OBJECT (control_frame->priv->socket),
-			    "focus_in_event",
-			    GTK_SIGNAL_FUNC (bonobo_control_frame_autoactivate_focus_in),
-			    control_frame);
-
-	gtk_signal_connect (GTK_OBJECT (control_frame->priv->socket),
-			    "focus_out_event",
-			    GTK_SIGNAL_FUNC (bonobo_control_frame_autoactivate_focus_out),
-			    control_frame);
-
-	/*
-	 * Setup a handler to proxy state changes.
-	 */
-	gtk_signal_connect (GTK_OBJECT (control_frame->priv->socket),
-			    "state_changed",
-			    bonobo_control_frame_socket_state_changed,
-			    control_frame);
-
-	/*
 	 * 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_hbox_new (FALSE, 0);
 	gtk_container_set_border_width (GTK_CONTAINER (control_frame->priv->container), 0);
-	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);
 
-	/*
-	 * When the socket is realized, we pass its Window ID to our
-	 * Control.
-	 */
-	gtk_signal_connect (GTK_OBJECT (control_frame->priv->socket),
-			    "realize",
-			    GTK_SIGNAL_FUNC (bonobo_control_frame_set_remote_window),
-			    control_frame);
+	bonobo_control_frame_create_socket (control_frame);
 
 	return control_frame;
 }
@@ -732,10 +768,17 @@ bonobo_control_frame_bind_to_control (Bo
 		bonobo_object_check_env (BONOBO_OBJECT (control_frame), control, &ev);
 	CORBA_exception_free (&ev);
 
+	/* 
+	 * Re-create the socket if it got destroyed by the Control before.
+	 */
+	if (control_frame->priv->socket == NULL) 
+		bonobo_control_frame_create_socket (control_frame);
+
 	/*
 	 * If the socket is realized, then we transfer the
 	 * window ID to the remote control.
 	 */
+
 	if (GTK_WIDGET_REALIZED (control_frame->priv->socket))
 		bonobo_control_frame_set_remote_window (control_frame->priv->socket,
 							control_frame);
Index: bonobo/bonobo-control.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-control.c,v
retrieving revision 1.44
diff -u -p -r1.44 bonobo-control.c
--- bonobo/bonobo-control.c	2000/10/05 05:08:18	1.44
+++ bonobo/bonobo-control.c	2000/10/07 02:18:38
@@ -39,8 +39,10 @@ struct _BonoboControlPrivate {
 	gboolean                    active;
 
 	GtkWidget                  *plug;
+	GtkWidget                  *socket;
 	gboolean                    is_local;
 	gboolean                    xid_received;
+	guint                       destroy_idle_id;
 			
 	BonoboUIComponent          *ui_component;
 	gboolean                    automerge;
@@ -249,7 +251,29 @@ bonobo_gtk_widget_from_x11_id (guint32 x
 	}
 }
 
+static gboolean
+idle_destroy_socket (BonoboControl *control)
+{
+	control->priv->destroy_idle_id = 0;
+
+	gtk_widget_destroy (control->priv->socket);
+
+	return FALSE;
+}
+
+
 static void
+remove_destroy_idle (GtkWidget *socket,
+		     BonoboControl *control)
+{
+	if (control->priv->destroy_idle_id != 0) {
+		gtk_idle_remove (control->priv->destroy_idle_id);
+	}
+
+	control->priv->destroy_idle_id = 0;
+}
+
+static void
 impl_Bonobo_Control_set_window (PortableServer_Servant   servant,
 				Bonobo_Control_windowid  id,
 				CORBA_Environment       *ev)
@@ -313,6 +337,15 @@ impl_Bonobo_Control_set_window (Portable
 		socket_parent = local_socket->parent;
 		gtk_widget_hide (local_socket);
 
+		control->priv->socket = local_socket;
+		control->priv->destroy_idle_id = gtk_idle_add (idle_destroy_socket, control);
+
+		gtk_signal_connect (GTK_OBJECT (local_socket),
+				    "destroy",
+				    remove_destroy_idle,
+				    control);
+
+
 		gtk_box_pack_end (GTK_BOX (socket_parent),
 				  control->priv->widget,
 				  TRUE, TRUE, 0);
@@ -550,6 +583,11 @@ bonobo_control_destroy (GtkObject *objec
 	CORBA_Environment ev;
 
 	CORBA_exception_init (&ev);
+
+	if (control->priv->destroy_idle_id != 0) {
+		gtk_idle_remove (control->priv->destroy_idle_id);
+	}
+	control->priv->destroy_idle_id = 0;
 
 	if (control->priv->active)
 		Bonobo_ControlFrame_activated (control->priv->control_frame,
Index: components/text-plain/bonobo-text-plain.c
===================================================================
RCS file: /cvs/gnome/bonobo/components/text-plain/bonobo-text-plain.c,v
retrieving revision 1.54
diff -u -p -r1.54 bonobo-text-plain.c
--- components/text-plain/bonobo-text-plain.c	2000/10/05 20:34:39	1.54
+++ components/text-plain/bonobo-text-plain.c	2000/10/07 02:18:38
@@ -272,11 +272,12 @@ progressive_update (bonobo_object_data_t
 		gtk_text_set_point (GTK_TEXT (view_data->text), 0);
 
 #ifndef NO_PROGRESS_METER
-		gtk_progress_bar_update (
-			GTK_PROGRESS_BAR (view_data->progress),
-			(float) bonobo_object_data->text_len /
-			bonobo_object_data->total_size);
-								 
+		if (bonobo_object_data->total_size != 0) {
+	                gtk_progress_bar_update (GTK_PROGRESS_BAR (view_data->progress),
+						 (float) bonobo_object_data->text_len /
+						 bonobo_object_data->total_size);
+		}
+
 #endif /* ! NO_PROGRESS_METER */
 
 		gtk_text_thaw (GTK_TEXT (view_data->text));
@@ -319,6 +320,7 @@ bonobo_object_destroy_cb (BonoboEmbeddab
 	g_free (bonobo_object_data);
 
 	running_objects--;
+	
 	if (running_objects > 0)
 		return;
 
@@ -855,9 +857,9 @@ embeddable_factory (BonoboEmbeddableFact
 	}
 	running_objects++;
 
-	gtk_signal_connect_after (GTK_OBJECT (bonobo_object), "destroy",
-				  GTK_SIGNAL_FUNC (bonobo_object_destroy_cb),
-				  bonobo_object_data);
+	gtk_signal_connect (GTK_OBJECT (bonobo_object), "destroy",
+			    GTK_SIGNAL_FUNC (bonobo_object_destroy_cb),
+			    bonobo_object_data);
 
 	gtk_signal_connect (GTK_OBJECT (bonobo_object), "system_exception",
 			    GTK_SIGNAL_FUNC (embeddable_system_exception_cb),




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