The final solution of the NautilusAdapter problem



Hi Maciej,

I worked a bit on this NautilusAdapter thing and I came to the
conclusion that the best way to solve it is to use my old patch
for it. IMO this is the only clean way to do it since what we need
to do here is to set an initial UI_Container when we create the
ControlFrame.

The biggest problem is this here where a Bonobo-only solution won't
work anyways:

===
 NautilusAdapter *
-nautilus_adapter_new (Bonobo_Unknown component)
+nautilus_adapter_new (Bonobo_Unknown component, Bonobo_UIContainer ui_container)
 {
 	NautilusAdapter      *adapter;
 	BonoboControl        *control;
@@ -155,7 +155,7 @@ nautilus_adapter_new (Bonobo_Unknown com
 
 	/* Get the class to handle embedding this kind of component. */
 	adapter->details->embed_strategy = nautilus_adapter_embed_strategy_get
-		(component, bonobo_control_get_remote_ui_container (control));
+		(component, ui_container);
 
 	if (adapter->details->embed_strategy == NULL) {
 		gtk_object_unref (GTK_OBJECT (adapter));
===

We're passing the initial UI_Container to nautilus_adapter_embed_strategy_get(),
but if we use bonobo_control_get_remote_ui_container (control)) here, this will
always trigger a g_warning() - so we either need to give nautilus_adapter_new()
the UI_Container as argument (as my patch does) or pass CORBA_OBJECT_NIL to
nautilus_adapter_embed_strategy_get (but in this case this CORBA_OBJECT_NIL
will be passed down to bonobo_control_frame_new() which is IMO not the best way
to do this).

Here's my old patch again:

Index: components/adapter/nautilus-adapter-factory-server.c
===================================================================
RCS file: /cvs/gnome/nautilus/components/adapter/nautilus-adapter-factory-server.c,v
retrieving revision 1.4
diff -u -u -p -r1.4 nautilus-adapter-factory-server.c
--- components/adapter/nautilus-adapter-factory-server.c	2000/09/27 00:07:29	1.4
+++ components/adapter/nautilus-adapter-factory-server.c	2000/10/14 20:30:55
@@ -50,6 +50,7 @@ typedef struct {
 static Nautilus_View
 impl_Nautilus_ComponentAdapterFactory_create_adapter (PortableServer_Servant           servant,
 						      const Bonobo_Unknown             component,
+						      const Bonobo_UIContainer         ui_container,
 						      CORBA_Environment               *ev);
 
 static void
@@ -132,16 +133,17 @@ adapter_object_destroyed (GtkObject *ada
 
 
 static Nautilus_View
-impl_Nautilus_ComponentAdapterFactory_create_adapter (PortableServer_Servant  servant,
-						      const Bonobo_Unknown    component,
-						      CORBA_Environment      *ev)
+impl_Nautilus_ComponentAdapterFactory_create_adapter (PortableServer_Servant   servant,
+						      const Bonobo_Unknown     component,
+						      const Bonobo_UIContainer ui_container,
+						      CORBA_Environment       *ev)
 {
 	impl_POA_Nautilus_ComponentAdapterFactory *factory_servant;
 	NautilusAdapter *adapter;
 
 	factory_servant = (impl_POA_Nautilus_ComponentAdapterFactory *) servant;
 
-	adapter = nautilus_adapter_new (component);
+	adapter = nautilus_adapter_new (component, ui_container);
 
 	if (adapter == NULL) {
 		return CORBA_OBJECT_NIL;
Index: components/adapter/nautilus-adapter.c
===================================================================
RCS file: /cvs/gnome/nautilus/components/adapter/nautilus-adapter.c,v
retrieving revision 1.7
diff -u -u -p -r1.7 nautilus-adapter.c
--- components/adapter/nautilus-adapter.c	2000/10/05 23:47:33	1.7
+++ components/adapter/nautilus-adapter.c	2000/10/14 20:30:55
@@ -127,7 +127,7 @@ nautilus_adapter_destroy (GtkObject *obj
 
 
 NautilusAdapter *
-nautilus_adapter_new (Bonobo_Unknown component)
+nautilus_adapter_new (Bonobo_Unknown component, Bonobo_UIContainer ui_container)
 {
 	NautilusAdapter      *adapter;
 	BonoboControl        *control;
@@ -155,7 +155,7 @@ nautilus_adapter_new (Bonobo_Unknown com
 
 	/* Get the class to handle embedding this kind of component. */
 	adapter->details->embed_strategy = nautilus_adapter_embed_strategy_get
-		(component, bonobo_control_get_remote_ui_container (control));
+		(component, ui_container);
 
 	if (adapter->details->embed_strategy == NULL) {
 		gtk_object_unref (GTK_OBJECT (adapter));
Index: components/adapter/nautilus-adapter.h
===================================================================
RCS file: /cvs/gnome/nautilus/components/adapter/nautilus-adapter.h,v
retrieving revision 1.2
diff -u -u -p -r1.2 nautilus-adapter.h
--- components/adapter/nautilus-adapter.h	2000/09/20 14:21:28	1.2
+++ components/adapter/nautilus-adapter.h	2000/10/14 20:30:55
@@ -50,7 +50,8 @@ typedef struct {
 /* GtkObject support */
 GtkType          nautilus_adapter_get_type          (void);
 
-NautilusAdapter *nautilus_adapter_new               (Bonobo_Unknown component);
+NautilusAdapter *nautilus_adapter_new               (Bonobo_Unknown component,
+						     Bonobo_UIContainer ui_container);
 
 NautilusView    *nautilus_adapter_get_nautilus_view (NautilusAdapter *adapter);
 #endif /* NAUTILUS_ADAPTER_H */
Index: libnautilus-adapter/nautilus-adapter-factory.idl
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-adapter/nautilus-adapter-factory.idl,v
retrieving revision 1.2
diff -u -u -p -r1.2 nautilus-adapter-factory.idl
--- libnautilus-adapter/nautilus-adapter-factory.idl	2000/09/15 08:33:12	1.2
+++ libnautilus-adapter/nautilus-adapter-factory.idl	2000/10/14 20:30:59
@@ -36,7 +36,8 @@ module Nautilus {
 
 	interface ComponentAdapterFactory : Bonobo::Unknown {
 		/* FIXME: should use exceptions to report reasons for failure. */
-		Nautilus::View create_adapter (in Bonobo::Unknown component);
+		Nautilus::View create_adapter (in Bonobo::Unknown component,
+					       in Bonobo::UIContainer ui_container);
 	};
 
 };
Index: src/nautilus-component-adapter-factory.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-component-adapter-factory.c,v
retrieving revision 1.4
diff -u -u -p -r1.4 nautilus-component-adapter-factory.c
--- src/nautilus-component-adapter-factory.c	2000/09/26 00:52:21	1.4
+++ src/nautilus-component-adapter-factory.c	2000/10/14 20:31:02
@@ -119,7 +119,8 @@ nautilus_component_adapter_factory_get (
 
 Nautilus_View
 nautilus_component_adapter_factory_create_adapter (NautilusComponentAdapterFactory *factory,
-						   BonoboObjectClient              *component)
+						   BonoboObjectClient              *component,
+						   Bonobo_UIContainer               ui_container)
 {
 	Nautilus_View nautilus_view;
 	Bonobo_Control bonobo_control;
@@ -163,6 +164,7 @@ nautilus_component_adapter_factory_creat
 		nautilus_view = Nautilus_ComponentAdapterFactory_create_adapter 
 			(factory->details->corba_factory,
 			 bonobo_object_corba_objref (BONOBO_OBJECT (component)),
+			 ui_container,
 			 &ev);
 
 		if (ev._major != CORBA_NO_EXCEPTION) {
Index: src/nautilus-component-adapter-factory.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-component-adapter-factory.h,v
retrieving revision 1.1
diff -u -u -p -r1.1 nautilus-component-adapter-factory.h
--- src/nautilus-component-adapter-factory.h	2000/09/07 09:10:57	1.1
+++ src/nautilus-component-adapter-factory.h	2000/10/14 20:31:02
@@ -66,7 +66,8 @@ GtkType                          nautilu
 NautilusComponentAdapterFactory *nautilus_component_adapter_factory_get       (void);
 
 Nautilus_View nautilus_component_adapter_factory_create_adapter               (NautilusComponentAdapterFactory *factory,
-									       BonoboObjectClient              *component);
+									       BonoboObjectClient              *component,
+									       Bonobo_UIContainer               ui_container);
 
 
 #endif /* NAUTILUS_COMPONENT_ADAPTER_FACTORY_H */
Index: src/nautilus-view-frame.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-view-frame.c,v
retrieving revision 1.100
diff -u -u -p -r1.100 nautilus-view-frame.c
--- src/nautilus-view-frame.c	2000/10/13 05:56:11	1.100
+++ src/nautilus-view-frame.c	2000/10/14 20:31:03
@@ -612,7 +657,8 @@ nautilus_view_frame_set_to_component (Na
 
 	adapted = nautilus_component_adapter_factory_create_adapter 
 		(nautilus_component_adapter_factory_get (),
-		 component);
+		 component,
+		 bonobo_object_corba_objref (BONOBO_OBJECT (view->details->ui_container)));
 	bonobo_object_unref (BONOBO_OBJECT (component));
 
 	/* Handle case where we don't know how to host this component. */
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.2365
diff -u -u -r1.2365 ChangeLog
--- ChangeLog	2000/10/14 07:23:39	1.2365
+++ ChangeLog	2000/10/14 20:52:36
@@ -1,3 +1,19 @@
+2000-10-14  Martin Baulig  <baulig suse de>
+
+	* libnautilus-adapter/nautilus-adapter-factory.idl (create_adapter):
+	Added Bonobo::UIContainer argument.
+	* components/adapter/nautilus-adapter-factory-server.c
+	(impl_Nautilus_ComponentAdapterFactory_create_adapter): Added
+	`const Bonobo_UIContainer' argument.
+	* components/adapter/nautilus-adapter.c (nautilus_adapter_new): Added
+	`Bonobo_UIContainer' argument and use it as second argument in the call
+	to nautilus_adapter_embed_strategy_get().
+	* src/nautilus-component-adapter-factory.c
+	(nautilus_component_adapter_factory_create_adapter): Added
+	`Bonobo_UIContainer' argument.
+	* src/nautilus-view-frame.c (nautilus_view_frame_set_to_component): Pass
+	nautilus_component_adapter_factory_create_adapter() our Bonobo_UIContainer.
+
 2000-10-14  Andy Hertzfeld  <andy eazel com>
 
 	* src/nautilus-throbber.c: (nautilus_throbber_initialize_class),
And here the ChangeLog again:

===
2000-10-14  Martin Baulig  <baulig suse de>

	* libnautilus-adapter/nautilus-adapter-factory.idl (create_adapter):
	Added Bonobo::UIContainer argument.
	* components/adapter/nautilus-adapter-factory-server.c
	(impl_Nautilus_ComponentAdapterFactory_create_adapter): Added
	`const Bonobo_UIContainer' argument.
	* components/adapter/nautilus-adapter.c (nautilus_adapter_new): Added
	`Bonobo_UIContainer' argument and use it as second argument in the call
	to nautilus_adapter_embed_strategy_get().
	* src/nautilus-component-adapter-factory.c
	(nautilus_component_adapter_factory_create_adapter): Added
	`Bonobo_UIContainer' argument.
	* src/nautilus-view-frame.c (nautilus_view_frame_set_to_component): Pass
	nautilus_component_adapter_factory_create_adapter() our Bonobo_UIContainer.
===

However, I think we should still add the bonobo_control_frame_set_ui_container,
but this is now a totally different thing - it's just for the case that you
want to move the Control from one window to another, for instance.

Btw. is there a reason why Nautilus doesn't auto-activate embedded Controls ?

-- 
Martin Baulig
martin gnome org (private)
baulig suse de (work)


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