Re: bonobo_get_object_async (take 2)...



On Fri, 2006-02-03 at 17:03 +0100, Rodrigo Moya wrote:
> On Fri, 2006-02-03 at 15:44 +0000, Mark McLoughlin wrote:
> > Hi Rodrigo,
> > 	It's pretty bad form to send completely untested patches ...
> > 
it wasn't completely untested, since it was working for me, at least for
some applets. But it was wrong though, so here's a better one. There are
no significant speed improvements, but at least if one applet fails
loading, the panel won't block waiting for it to answer or timeout.
-- 
Rodrigo Moya <rodrigo gnome-db org>
? gnome-panel/battery.c
? gnome-panel/org.gnome.Panel.desktop-service
? gnome-panel/org.gnome.Panel.service
? gnome-panel/org.gnome.Panel.service.in
? help/C/Makefile
? help/C/Makefile.in
? help/C/clock/Makefile
? help/C/clock/Makefile.in
? help/C/clock/clock-C.omf.out
? help/C/clock/omf_timestamp
? help/C/fish/Makefile
? help/C/fish/Makefile.in
? help/C/fish/fish-applet-2-C.omf.out
? help/C/fish/omf_timestamp
? help/C/window-list/Makefile
? help/C/window-list/Makefile.in
? help/C/window-list/omf_timestamp
? help/C/window-list/window-list-C.omf.out
? help/C/workspace-switcher/Makefile
? help/C/workspace-switcher/Makefile.in
? help/C/workspace-switcher/omf_timestamp
? help/C/workspace-switcher/workspace-switcher-C.omf.out
? help/de/clock/Makefile
? help/de/clock/Makefile.in
? help/de/clock/clock-de.omf.out
? help/de/clock/omf_timestamp
? help/es/Makefile
? help/es/Makefile.in
? help/es/clock/Makefile
? help/es/clock/Makefile.in
? help/es/clock/clock-es.omf.out
? help/es/clock/omf_timestamp
? help/es/fish/Makefile
? help/es/fish/Makefile.in
? help/es/fish/fish-applet-2-es.omf.out
? help/es/fish/omf_timestamp
? help/es/window-list/Makefile
? help/es/window-list/Makefile.in
? help/es/window-list/omf_timestamp
? help/es/window-list/window-list-es.omf.out
? help/es/workspace-switcher/Makefile
? help/es/workspace-switcher/Makefile.in
? help/es/workspace-switcher/omf_timestamp
? help/es/workspace-switcher/workspace-switcher-es.omf.out
? help/fr/Makefile
? help/fr/Makefile.in
? help/fr/clock/Makefile
? help/fr/clock/Makefile.in
? help/fr/clock/clock-fr.omf.out
? help/fr/clock/omf_timestamp
? help/fr/fish/Makefile
? help/fr/fish/Makefile.in
? help/fr/fish/fish-applet-2-fr.omf.out
? help/fr/fish/omf_timestamp
? help/fr/window-list/Makefile
? help/fr/window-list/Makefile.in
? help/fr/window-list/omf_timestamp
? help/fr/window-list/window-list-fr.omf.out
? help/fr/workspace-switcher/Makefile
? help/fr/workspace-switcher/Makefile.in
? help/fr/workspace-switcher/omf_timestamp
? help/fr/workspace-switcher/workspace-switcher-fr.omf.out
? help/it/Makefile
? help/it/Makefile.in
? help/it/clock/Makefile
? help/it/clock/Makefile.in
? help/it/clock/clock-it.omf.out
? help/it/clock/omf_timestamp
? help/it/fish/Makefile
? help/it/fish/Makefile.in
? help/it/fish/fish-applet-2-it.omf.out
? help/it/fish/omf_timestamp
? help/it/window-list/Makefile
? help/it/window-list/Makefile.in
? help/it/window-list/omf_timestamp
? help/it/window-list/window-list-it.omf.out
? help/it/workspace-switcher/Makefile
? help/it/workspace-switcher/Makefile.in
? help/it/workspace-switcher/omf_timestamp
? help/it/workspace-switcher/workspace-switcher-it.omf.out
? help/ja/clock/Makefile
? help/ja/clock/Makefile.in
? help/ja/clock/clock-ja.omf.out
? help/ja/clock/omf_timestamp
? help/ko/clock/Makefile
? help/ko/clock/Makefile.in
? help/ko/clock/clock-ko.omf.out
? help/ko/clock/omf_timestamp
? help/sv/clock/Makefile
? help/sv/clock/Makefile.in
? help/sv/clock/clock-sv.omf.out
? help/sv/clock/omf_timestamp
? help/uk/Makefile
? help/uk/Makefile.in
? help/uk/clock/Makefile
? help/uk/clock/Makefile.in
? help/uk/clock/clock-uk.omf.out
? help/uk/clock/omf_timestamp
? help/uk/fish/Makefile
? help/uk/fish/Makefile.in
? help/uk/fish/fish-applet-2-uk.omf.out
? help/uk/fish/omf_timestamp
? help/uk/window-list/Makefile
? help/uk/window-list/Makefile.in
? help/uk/window-list/omf_timestamp
? help/uk/window-list/window-list-uk.omf.out
? help/uk/workspace-switcher/Makefile
? help/uk/workspace-switcher/Makefile.in
? help/uk/workspace-switcher/omf_timestamp
? help/uk/workspace-switcher/workspace-switcher-uk.omf.out
? help/zh_CN/clock/Makefile
? help/zh_CN/clock/Makefile.in
? help/zh_CN/clock/clock-zh_CN.omf.out
? help/zh_CN/clock/omf_timestamp
? help/zh_TW/clock/Makefile
? help/zh_TW/clock/Makefile.in
? help/zh_TW/clock/clock-zh_TW.omf.out
? help/zh_TW/clock/omf_timestamp
? po/stamp-it
Index: gnome-panel/ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-panel/gnome-panel/ChangeLog,v
retrieving revision 1.2765
diff -u -p -r1.2765 ChangeLog
--- gnome-panel/ChangeLog	13 Feb 2006 20:10:29 -0000	1.2765
+++ gnome-panel/ChangeLog	15 Feb 2006 01:48:37 -0000
@@ -1,3 +1,14 @@
+2006-02-14  Michael Meeks <mmeeks novell com>
+
+	* panel-applet-frame.c (panel_applet_frame_activated): changed
+	signature to match b-a-s async mechanism. Once we get a correct object,
+	resolve the moniker item on it.
+	(panel_applet_frame_load): use bonobo_activation_activate_from_id_async
+	instead of not really async bonobo_get_object_async.
+	(panel_applet_frame_construct_moniker): removed.
+	(panel_applet_frame_construct_item): new function to build the moniker
+	item to activate the applet.
+
 ==================== 2.13.91 ====================
 
 2006-02-12  Vincent Untz  <vuntz gnome org>
Index: gnome-panel/panel-applet-frame.c
===================================================================
RCS file: /cvs/gnome/gnome-panel/gnome-panel/panel-applet-frame.c,v
retrieving revision 1.144
diff -u -p -r1.144 panel-applet-frame.c
--- gnome-panel/panel-applet-frame.c	22 Jan 2006 15:30:17 -0000	1.144
+++ gnome-panel/panel-applet-frame.c	15 Feb 2006 01:48:37 -0000
@@ -101,9 +101,9 @@ static char *panel_applet_frame_construc
 						   const char       *iid,
 						   const char       *id);
 
-static void panel_applet_frame_activated (Bonobo_Unknown     object,
-					  CORBA_Environment *ev,
-					  gpointer          *data);
+static void panel_applet_frame_activated (CORBA_Object object,
+					  const char   *error_reason,
+					  gpointer     data);
 
 void
 panel_applet_frame_sync_menu_state (PanelAppletFrame *frame)
@@ -324,7 +324,6 @@ panel_applet_frame_load (const gchar *ii
 {
 	PanelAppletFrame           *frame;
 	CORBA_Environment           ev;
-	char                       *moniker;
 	PanelAppletFrameActivating *frame_act;
 
 	g_return_if_fail (iid != NULL);
@@ -345,15 +344,11 @@ panel_applet_frame_load (const gchar *ii
 	frame_act->exactpos = exactpos;
 	frame_act->id       = g_strdup (id);
 
-	moniker = panel_applet_frame_construct_moniker (frame, panel, iid, id);
-
 	CORBA_exception_init (&ev);
 
-	bonobo_get_object_async (moniker, "IDL:Bonobo/Control:1.0", &ev,
-				 (BonoboMonikerAsyncFn) panel_applet_frame_activated,
-				 frame_act);
-
-	g_free (moniker);
+	bonobo_activation_activate_from_id_async (iid, 0,
+						  (BonoboActivationCallback) panel_applet_frame_activated,
+						  frame_act, &ev);
 }
 
 void
@@ -369,14 +364,9 @@ panel_applet_frame_load_from_gconf (Pane
 	g_return_if_fail (id != NULL);
 
 	key = panel_gconf_full_key (PANEL_GCONF_APPLETS, id, "bonobo_iid");
-	applet_iid = gconf_client_get_string (panel_gconf_get_client (),
-					      key, NULL);
+	applet_iid = gconf_client_get_string (panel_gconf_get_client (), key, NULL);
 
-	if (!applet_iid)
-		return;
-
-	panel_applet_frame_load (applet_iid, panel_widget,
-				 locked, position, TRUE, id);
+	panel_applet_frame_load (applet_iid, panel_widget, locked, position, TRUE, id);
 
 	g_free (applet_iid);
 }
@@ -1192,10 +1182,9 @@ panel_applet_frame_get_size_string (Pane
 }
 
 static char *
-panel_applet_frame_construct_moniker (PanelAppletFrame *frame,
-				      PanelWidget      *panel,
-				      const char       *iid,
-				      const char       *id)
+panel_applet_frame_construct_item (PanelAppletFrame *frame,
+				   PanelWidget      *panel,
+				   const char       *id)
 {
 	char *retval;
 	char *bg_str;
@@ -1210,9 +1199,9 @@ panel_applet_frame_construct_moniker (Pa
 	locked_down = panel_lockdown_get_locked_down ();
 
 	retval = g_strdup_printf (
-			"%s!prefs_key=/apps/panel/applets/%s/prefs;"
+			"prefs_key=/apps/panel/applets/%s/prefs;"
 			"background=%s;orient=%s;size=%s;locked_down=%s",
-			iid, id, bg_str,
+			id, bg_str,
 			panel_applet_frame_get_orient_string (frame, panel),
 			panel_applet_frame_get_size_string (frame, panel),
 			locked_down ? "true" : "false");
@@ -1237,41 +1226,71 @@ panel_applet_frame_event_listener (Bonob
 }
 
 static void
-panel_applet_frame_activated (Bonobo_Unknown     object,
-			      CORBA_Environment *ev,
-			      gpointer          *data)
+panel_applet_frame_activated (CORBA_Object object,
+			      const char   *error_reason,
+			      gpointer     data)
 {
 	PanelAppletFrameActivating *frame_act;
 	PanelAppletFrame   *frame;
 	GtkWidget          *widget;
 	BonoboControlFrame *control_frame;
 	Bonobo_Control      control;
+	Bonobo_ItemContainer container;
 	CORBA_Environment   corba_ev;
 	AppletInfo         *info;
-	char               *error;
+	char               *error, *item_name;
 
 	frame_act = (PanelAppletFrameActivating *) data;
 	frame = frame_act->frame;
 
 	/* according to the source of bonobo control == NULL && no
 	   exception can happen, so handle it */
-	if (BONOBO_EX (ev) || object == CORBA_OBJECT_NIL) {
-		error = bonobo_exception_get_text (ev);
+	if (error_reason != NULL || object == CORBA_OBJECT_NIL) {
 		g_warning (G_STRLOC ": failed to load applet %s:\n%s",
-			   frame->priv->iid, error);
+			   frame->priv->iid, error_reason);
 		panel_applet_frame_loading_failed (frame, frame_act->id);
 		g_free (frame_act->id);
 		g_free (frame_act);
-		g_free (error);
 		return;
 	}
 
-	frame->priv->control = CORBA_Object_duplicate (object, NULL);
+	CORBA_exception_init (&corba_ev);
 
-	widget = bonobo_widget_new_control_from_objref (object,
-							CORBA_OBJECT_NIL);
+	item_name = panel_applet_frame_construct_item (frame, frame->priv->panel, frame_act->id);
 
+	g_warning ("Patent Meeks activation code");
+	frame->priv->control = CORBA_OBJECT_NIL;
+	container = Bonobo_Unknown_queryInterface (object, "IDL:Bonobo/ItemContainer:1.0", &corba_ev);
+	if (!BONOBO_EX (&corba_ev) && container != CORBA_OBJECT_NIL) {
+		Bonobo_Unknown containee;
+
+		containee = Bonobo_ItemContainer_getObjectByName (container, item_name, TRUE, &corba_ev);
+
+		if (!BONOBO_EX(&corba_ev) && containee != CORBA_OBJECT_NIL) {
+			frame->priv->control = Bonobo_Unknown_queryInterface (containee, "IDL:Bonobo/Control:1.0", &corba_ev);
+			if (BONOBO_EX (&corba_ev))
+				object = CORBA_OBJECT_NIL;
+			bonobo_object_release_unref (containee, NULL);
+		}
+	}
+	g_free (item_name);
+	
+	if (!frame->priv->control) {
+		error = bonobo_exception_get_text (&corba_ev);
+		g_warning (G_STRLOC ": failed to get Bonobo/Control interface on applet %s:\n%s",
+                           frame->priv->iid, error);
+		panel_applet_frame_loading_failed (frame, frame_act->id);
+                g_free (frame_act->id);
+		g_free (frame_act);
+		g_free (error);
+		return;
+	}
+
+	widget = bonobo_widget_new_control_from_objref (frame->priv->control,
+							CORBA_OBJECT_NIL);
+	
 	bonobo_object_release_unref (object, NULL);
+	bonobo_object_release_unref (container, NULL);
 
 	if (!widget) {
 		g_warning (G_STRLOC ": failed to load applet %s",


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