The NautilusAdapter patch



Hi Maciej,

here's the final patch:

Index: components/adapter/nautilus-adapter-control-embed-strategy.c
===================================================================
RCS file: /cvs/gnome/nautilus/components/adapter/nautilus-adapter-control-embed-strategy.c,v
retrieving revision 1.3
diff -u -u -p -r1.3 nautilus-adapter-control-embed-strategy.c
--- components/adapter/nautilus-adapter-control-embed-strategy.c	2000/10/05 23:47:33	1.3
+++ components/adapter/nautilus-adapter-control-embed-strategy.c	2000/10/22 13:01:00
@@ -48,6 +48,9 @@ struct NautilusAdapterControlEmbedStrate
 
 static void nautilus_adapter_control_embed_strategy_initialize_class (NautilusAdapterControlEmbedStrategyClass *klass);
 static void nautilus_adapter_control_embed_strategy_initialize       (NautilusAdapterControlEmbedStrategy      *strategy);
+static void nautilus_adapter_control_embed_strategy_activate         (NautilusAdapterEmbedStrategy           *object,
+								      gpointer                                ui_container);
+static void nautilus_adapter_control_embed_strategy_deactivate       (NautilusAdapterEmbedStrategy           *object);
 static void nautilus_adapter_control_embed_strategy_destroy          (GtkObject                              *object);
 
 static GtkWidget *nautilus_adapter_control_embed_strategy_get_widget (NautilusAdapterEmbedStrategy *strategy);
@@ -69,6 +72,8 @@ nautilus_adapter_control_embed_strategy_
 	adapter_embed_strategy_class = NAUTILUS_ADAPTER_EMBED_STRATEGY_CLASS (klass);
 
 	adapter_embed_strategy_class->get_widget = nautilus_adapter_control_embed_strategy_get_widget;
+	adapter_embed_strategy_class->activate = nautilus_adapter_control_embed_strategy_activate;
+	adapter_embed_strategy_class->deactivate = nautilus_adapter_control_embed_strategy_deactivate;
 }
 
 static void
@@ -100,6 +105,39 @@ nautilus_adapter_control_embed_strategy_
 	NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
 }
 
+static void 
+nautilus_adapter_control_embed_strategy_activate (NautilusAdapterEmbedStrategy *object,
+						  gpointer                      ui_container)
+{
+	NautilusAdapterControlEmbedStrategy *strategy;
+	Bonobo_UIContainer corba_container = ui_container;
+
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (NAUTILUS_IS_ADAPTER_CONTROL_EMBED_STRATEGY (object));
+
+	strategy = NAUTILUS_ADAPTER_CONTROL_EMBED_STRATEGY (object);
+
+	bonobo_control_frame_set_ui_container (strategy->details->control_frame,
+					       corba_container);
+
+	bonobo_control_frame_control_activate (strategy->details->control_frame);
+}
+
+static void 
+nautilus_adapter_control_embed_strategy_deactivate (NautilusAdapterEmbedStrategy *object)
+{
+	NautilusAdapterControlEmbedStrategy *strategy;
+
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (NAUTILUS_IS_ADAPTER_CONTROL_EMBED_STRATEGY (object));
+
+	strategy = NAUTILUS_ADAPTER_CONTROL_EMBED_STRATEGY (object);
+
+	/* This is not strictly necessary, but it makes sure that the component's menus
+	 * and toolbars are really unmerged even if our component is badly behaving or
+	 * leaking a reference somewhere. */
+	bonobo_control_frame_control_deactivate (strategy->details->control_frame);
+}
 
 static void
 activate_uri_callback (BonoboControlFrame *frame,
Index: components/adapter/nautilus-adapter-embed-strategy.c
===================================================================
RCS file: /cvs/gnome/nautilus/components/adapter/nautilus-adapter-embed-strategy.c,v
retrieving revision 1.2
diff -u -u -p -r1.2 nautilus-adapter-embed-strategy.c
--- components/adapter/nautilus-adapter-embed-strategy.c	2000/10/05 23:47:33	1.2
+++ components/adapter/nautilus-adapter-embed-strategy.c	2000/10/22 13:01:00
@@ -41,6 +41,8 @@
 #include <stdio.h>
 
 enum {
+	ACTIVATE,
+	DEACTIVATE,
 	OPEN_LOCATION,
 	LAST_SIGNAL
 };
@@ -65,6 +67,20 @@ nautilus_adapter_embed_strategy_initiali
 
 	object_class->destroy = nautilus_adapter_embed_strategy_destroy;
 
+	signals[ACTIVATE] =
+		gtk_signal_new ("avtivate",
+			       GTK_RUN_LAST,
+			       object_class->type,
+			       GTK_SIGNAL_OFFSET (NautilusAdapterEmbedStrategyClass, activate),
+			       gtk_marshal_NONE__POINTER,
+			       GTK_TYPE_POINTER, 0);
+	signals[DEACTIVATE] =
+		gtk_signal_new ("deavtivate",
+			       GTK_RUN_LAST,
+			       object_class->type,
+			       GTK_SIGNAL_OFFSET (NautilusAdapterEmbedStrategyClass, deactivate),
+			       gtk_marshal_NONE__NONE,
+			       GTK_TYPE_NONE, 0);
 	signals[OPEN_LOCATION] =
 		gtk_signal_new ("open_location",
 			       GTK_RUN_LAST,
@@ -96,8 +112,7 @@ nautilus_adapter_embed_strategy_destroy 
 
 
 NautilusAdapterEmbedStrategy *
-nautilus_adapter_embed_strategy_get (Bonobo_Unknown component,
-				     Bonobo_UIContainer ui_container)
+nautilus_adapter_embed_strategy_get (Bonobo_Unknown component)
 {
 	Bonobo_Control    control;
 	Bonobo_Embeddable embeddable;
@@ -112,7 +127,7 @@ nautilus_adapter_embed_strategy_get (Bon
 	if (ev._major == CORBA_NO_EXCEPTION && !CORBA_Object_is_nil (control, &ev)) {
 		CORBA_exception_free (&ev);
 		
-		return nautilus_adapter_control_embed_strategy_new (control, ui_container);
+		return nautilus_adapter_control_embed_strategy_new (control, CORBA_OBJECT_NIL);
 	}
 
 	embeddable = Bonobo_Unknown_query_interface (component,
@@ -121,7 +136,7 @@ nautilus_adapter_embed_strategy_get (Bon
 	if (ev._major == CORBA_NO_EXCEPTION && !CORBA_Object_is_nil (embeddable, &ev)) {
 		CORBA_exception_free (&ev);
 		
-		return nautilus_adapter_embeddable_embed_strategy_new (embeddable, ui_container);		
+		return nautilus_adapter_embeddable_embed_strategy_new (embeddable, CORBA_OBJECT_NIL);		
 	}
 
 	CORBA_exception_free (&ev);
@@ -136,6 +151,22 @@ nautilus_adapter_embed_strategy_get_widg
 				      get_widget, (strategy));
 }
 
+
+void 
+nautilus_adapter_embed_strategy_activate (NautilusAdapterEmbedStrategy *strategy,
+					  Bonobo_UIContainer            ui_container)
+{
+	gtk_signal_emit (GTK_OBJECT (strategy),
+			 signals[ACTIVATE],
+			 ui_container);
+}
+
+void 
+nautilus_adapter_embed_strategy_deactivate (NautilusAdapterEmbedStrategy *strategy)
+{
+	gtk_signal_emit (GTK_OBJECT (strategy),
+			 signals[DEACTIVATE]);
+}
 
 void 
 nautilus_adapter_embed_strategy_emit_open_location (NautilusAdapterEmbedStrategy *strategy,
Index: components/adapter/nautilus-adapter-embed-strategy.h
===================================================================
RCS file: /cvs/gnome/nautilus/components/adapter/nautilus-adapter-embed-strategy.h,v
retrieving revision 1.2
diff -u -u -p -r1.2 nautilus-adapter-embed-strategy.h
--- components/adapter/nautilus-adapter-embed-strategy.h	2000/10/05 23:47:33	1.2
+++ components/adapter/nautilus-adapter-embed-strategy.h	2000/10/22 13:01:00
@@ -47,6 +47,9 @@ typedef struct {
 	GtkObjectClass parent;
 
 	/* signals */
+	void       (*activate)       (NautilusAdapterEmbedStrategy *strategy,
+				      gpointer                      corba_container);
+	void       (*deactivate)     (NautilusAdapterEmbedStrategy *strategy);
 	void       (*open_location)  (NautilusAdapterEmbedStrategy *strategy,
 				      const char                   *uri);
 
@@ -59,8 +62,11 @@ typedef struct {
 GtkType                      nautilus_adapter_embed_strategy_get_type      (void);
 
 /* Instantiates the proper concrete subclass */
-NautilusAdapterEmbedStrategy *nautilus_adapter_embed_strategy_get       (Bonobo_Unknown     component,
-									 Bonobo_UIContainer ui_container);
+NautilusAdapterEmbedStrategy *nautilus_adapter_embed_strategy_get       (Bonobo_Unknown     component);
+
+void                          nautilus_adapter_embed_strategy_activate  (NautilusAdapterEmbedStrategy *strategy,
+									 Bonobo_UIContainer            ui_container);
+void                          nautilus_adapter_embed_strategy_deactivate(NautilusAdapterEmbedStrategy *strategy);
 
 GtkWidget                   *nautilus_adapter_embed_strategy_get_widget (NautilusAdapterEmbedStrategy *strategy);
 
Index: components/adapter/nautilus-adapter-embeddable-embed-strategy.c
===================================================================
RCS file: /cvs/gnome/nautilus/components/adapter/nautilus-adapter-embeddable-embed-strategy.c,v
retrieving revision 1.3
diff -u -u -p -r1.3 nautilus-adapter-embeddable-embed-strategy.c
--- components/adapter/nautilus-adapter-embeddable-embed-strategy.c	2000/10/05 23:47:33	1.3
+++ components/adapter/nautilus-adapter-embeddable-embed-strategy.c	2000/10/22 13:01:00
@@ -51,7 +51,11 @@ struct NautilusAdapterEmbeddableEmbedStr
 static void nautilus_adapter_embeddable_embed_strategy_initialize_class (NautilusAdapterEmbeddableEmbedStrategyClass *klass);
 static void nautilus_adapter_embeddable_embed_strategy_initialize       (NautilusAdapterEmbeddableEmbedStrategy      *strategy);
 static void nautilus_adapter_embeddable_embed_strategy_destroy          (GtkObject                              *object);
+static void nautilus_adapter_embeddable_embed_strategy_activate         (NautilusAdapterEmbedStrategy                *object,
+									 gpointer                                     ui_container);
+static void nautilus_adapter_embeddable_embed_strategy_deactivate       (NautilusAdapterEmbedStrategy                *object);
 
+
 static GtkWidget *nautilus_adapter_embeddable_embed_strategy_get_widget (NautilusAdapterEmbedStrategy *strategy);
 
 
@@ -71,6 +75,8 @@ nautilus_adapter_embeddable_embed_strate
 	adapter_embed_strategy_class = NAUTILUS_ADAPTER_EMBED_STRATEGY_CLASS (klass);
 
 	adapter_embed_strategy_class->get_widget = nautilus_adapter_embeddable_embed_strategy_get_widget;
+	adapter_embed_strategy_class->activate = nautilus_adapter_embeddable_embed_strategy_activate;
+	adapter_embed_strategy_class->deactivate = nautilus_adapter_embeddable_embed_strategy_deactivate;
 }
 
 static void
@@ -104,6 +110,40 @@ nautilus_adapter_embeddable_embed_strate
 	NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
 }
 
+
+static void 
+nautilus_adapter_embeddable_embed_strategy_activate (NautilusAdapterEmbedStrategy *object,
+						     gpointer                      ui_container)
+{
+	NautilusAdapterEmbeddableEmbedStrategy *strategy;
+	Bonobo_UIContainer corba_container = ui_container;
+
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (NAUTILUS_IS_ADAPTER_EMBEDDABLE_EMBED_STRATEGY (object));
+
+	strategy = NAUTILUS_ADAPTER_EMBEDDABLE_EMBED_STRATEGY (object);
+
+	bonobo_control_frame_set_ui_container (BONOBO_CONTROL_FRAME (strategy->details->view_frame),
+					       corba_container);
+
+	bonobo_control_frame_control_activate (BONOBO_CONTROL_FRAME (strategy->details->view_frame));
+}
+
+static void 
+nautilus_adapter_embeddable_embed_strategy_deactivate (NautilusAdapterEmbedStrategy *object)
+{
+	NautilusAdapterEmbeddableEmbedStrategy *strategy;
+
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (NAUTILUS_IS_ADAPTER_EMBEDDABLE_EMBED_STRATEGY (object));
+
+	strategy = NAUTILUS_ADAPTER_EMBEDDABLE_EMBED_STRATEGY (object);
+
+	/* This is not strictly necessary, but it makes sure that the component's menus
+	 * and toolbars are really unmerged even if our component is badly behaving or
+	 * leaking a reference somewhere. */
+	bonobo_control_frame_control_deactivate (BONOBO_CONTROL_FRAME (strategy->details->view_frame));
+}
 
 static void
 activate_uri_callback (BonoboControlFrame *frame,
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/22 13:01:00
@@ -29,6 +29,7 @@
 #include "nautilus-adapter.h"
 #include "nautilus-adapter-load-strategy.h"
 #include "nautilus-adapter-embed-strategy.h"
+#include "nautilus-adapter-embed-strategy-private.h"
 
 #include <bonobo/bonobo-control.h>
 #include <bonobo/bonobo-item-container.h>
@@ -56,6 +57,9 @@ static void nautilus_adapter_load_locati
 static void nautilus_adapter_stop_loading_callback  (NautilusView    *view,
 						     NautilusAdapter *adapter);
 
+static void nautilus_adapter_activate_callback      (BonoboControl   *control,
+						     gboolean         state,
+						     NautilusAdapter *adapter);
 static void nautilus_adapter_open_location_callback (NautilusAdapterEmbedStrategy *strategy,
 						     const char                   *uri,
 						     NautilusAdapter              *adapter);
@@ -110,7 +114,7 @@ nautilus_adapter_destroy (GtkObject *obj
 	NautilusAdapter *server;
 	
 	server = NAUTILUS_ADAPTER (object);
-	
+
 	if (server->details->load_strategy != NULL) {
 		nautilus_adapter_load_strategy_stop_loading (server->details->load_strategy);
 		gtk_object_unref (GTK_OBJECT (server->details->load_strategy));
@@ -125,7 +129,6 @@ nautilus_adapter_destroy (GtkObject *obj
 	NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
 }
 
-
 NautilusAdapter *
 nautilus_adapter_new (Bonobo_Unknown component)
 {
@@ -155,7 +158,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);
 
 	if (adapter->details->embed_strategy == NULL) {
 		gtk_object_unref (GTK_OBJECT (adapter));
@@ -163,6 +166,10 @@ nautilus_adapter_new (Bonobo_Unknown com
 		return NULL;
 	}
 
+	gtk_signal_connect (GTK_OBJECT (control), "activate",
+			    GTK_SIGNAL_FUNC (nautilus_adapter_activate_callback),
+			    adapter);
+
 	gtk_signal_connect (GTK_OBJECT (adapter->details->embed_strategy), "open_location", 
 			    nautilus_adapter_open_location_callback, adapter);
 
@@ -259,6 +266,26 @@ nautilus_adapter_open_location_callback 
 				     uri);
 }
 
+
+static void
+nautilus_adapter_activate_callback (BonoboControl   *control,
+				    gboolean         state,
+				    NautilusAdapter *adapter)
+{
+	g_return_if_fail (control != NULL);
+	g_return_if_fail (BONOBO_IS_CONTROL (control));
+	g_return_if_fail (adapter != NULL);
+	g_return_if_fail (NAUTILUS_IS_ADAPTER (adapter));
+
+	if (state) {
+		Bonobo_UIContainer corba_container;
+
+		corba_container = bonobo_control_get_remote_ui_container (control);
+		nautilus_adapter_embed_strategy_activate (adapter->details->embed_strategy,
+							  corba_container);
+	} else
+		nautilus_adapter_embed_strategy_deactivate (adapter->details->embed_strategy);
+}
 
 
 static void
ChangeLog:

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

	* components/adapter/nautilus-adapter-embed-strategy.h
	(NautilusAdapterEmbedStrategyClass): Added "activate" and "deactivate"
	signals.
	(nautilus_adapter_embed_strategy_get): Removed ui_container argument.
	(nautilus_adapter_embed_strategy_activate): New function; emits
	the "activate" signal.
	(nautilus_adapter_embed_strategy_deactivate): New function; emits
	the "deactivate" signal.

	* components/adapter/nautilus-adapter-control-embed-strategy.c
	(nautilus_adapter_control_embed_strategy_activate): New static function;
	this is the handler of the "activate" signal.
	(nautilus_adapter_control_embed_strategy_deactivate): New static function;
	this is the handler of the "deactivate" signal.

	* components/adapter/nautilus-adapter-embeddable-embed-strategy.c
	(nautilus_adapter_embeddable_embed_strategy_activate): New static function;
	this is the handler of the "activate" signal.
	(nautilus_adapter_embeddable_embed_strategy_deactivate): New static function;
	this is the handler of the "deactivate" signal.

	* components/adapter/nautilus-adapter.c (nautilus_adapter_activate_callback):
	New static function; connect this to the "activate" signal of the adapter
	control.

===

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


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