From 5b52672a1524bd6fda554c2abab496f856a5bbee Mon Sep 17 00:00:00 2001 From: Ettore Perazzoli Date: Sun, 24 Jun 2001 10:39:51 +0000 Subject: Add code to query the ::Activity interface in the EvolutionShellComponent class and get the test component to use it. svn path=/trunk/; revision=10448 --- shell/ChangeLog | 21 +++++++++++++++ shell/evolution-shell-client.c | 58 ++++++++++++++++++++++++++++++++++++++-- shell/evolution-shell-client.h | 2 ++ shell/evolution-test-component.c | 32 +++++++--------------- 4 files changed, 88 insertions(+), 25 deletions(-) (limited to 'shell') diff --git a/shell/ChangeLog b/shell/ChangeLog index fd68f5916c..02545d0c2c 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,24 @@ +2001-06-24 Ettore Perazzoli + + * evolution-test-component.c: Remove the `activity_interface' + global. + (timeout_callback_3): Get the ::Activity interface using + `evolution_shell_client_get_activity_interface()' on + `parent_shell' instead. + (timeout_callback_2): Likewise. + (timeout_callback_2): Likewise. + (timeout_callback_1): Likewise. + (owner_set_callback): Don't query interface here. Check if the + shell has an ::Activity interface by using + `evolution_shell_client_get_activity_interface()' here as well. + + * evolution-shell-client.c: New member `activity_interface' in + `EvolutionShellClientPrivate'. + (destroy): unref/release it. + (evolution_shell_client_construct): Initialize it by querying the + shell CORBA Object for the ::Activity interface. + (evolution_shell_client_get_activity_interface): New. + 2001-06-23 Jason Leach * e-shell-folder-selection-dialog.c diff --git a/shell/evolution-shell-client.c b/shell/evolution-shell-client.c index 50a92bff21..54df7eb981 100644 --- a/shell/evolution-shell-client.c +++ b/shell/evolution-shell-client.c @@ -35,7 +35,7 @@ struct _EvolutionShellClientPrivate { - int dummy; + GNOME_Evolution_Activity activity_interface; }; #define PARENT_TYPE bonobo_object_client_get_type () @@ -222,10 +222,24 @@ destroy (GtkObject *object) { EvolutionShellClient *shell_client; EvolutionShellClientPrivate *priv; + CORBA_Environment ev; shell_client = EVOLUTION_SHELL_CLIENT (object); priv = shell_client->priv; + CORBA_exception_init (&ev); + + if (priv->activity_interface != CORBA_OBJECT_NIL) { + Bonobo_Unknown_unref (priv->activity_interface, &ev); + if (ev._major != CORBA_NO_EXCEPTION) + g_warning ("EvolutionShellClient::destroy: " + "Error unreffing the ::Activity interface -- %s\n", + ev._repo_id); + CORBA_Object_release (priv->activity_interface, &ev); + } + + CORBA_exception_free (&ev); + g_free (priv); (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); @@ -250,7 +264,7 @@ init (EvolutionShellClient *shell_client) EvolutionShellClientPrivate *priv; priv = g_new (EvolutionShellClientPrivate, 1); - priv->dummy = 0; + priv->activity_interface = CORBA_OBJECT_NIL; shell_client->priv = priv; } @@ -267,11 +281,31 @@ void evolution_shell_client_construct (EvolutionShellClient *shell_client, GNOME_Evolution_Shell corba_shell) { + CORBA_Environment ev; + EvolutionShellClientPrivate *priv; + g_return_if_fail (shell_client != NULL); g_return_if_fail (EVOLUTION_IS_SHELL_CLIENT (shell_client)); g_return_if_fail (corba_shell != CORBA_OBJECT_NIL); bonobo_object_construct (BONOBO_OBJECT (shell_client), (CORBA_Object) corba_shell); + + CORBA_exception_init (&ev); + + priv = shell_client->priv; + g_return_if_fail (priv->activity_interface == CORBA_OBJECT_NIL); + + priv->activity_interface = Bonobo_Unknown_queryInterface (bonobo_object_corba_objref (BONOBO_OBJECT (shell_client)), + "IDL:GNOME/Evolution/Activity:1.0", + &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + g_warning ("EvolutionShellClient: Error querying interface ::Activity -- %s", ev._repo_id); + priv->activity_interface = CORBA_OBJECT_NIL; + } else if (CORBA_Object_is_nil (priv->activity_interface, &ev)) { + g_warning ("No ::Activity interface for ShellClient %p", shell_client); + } + + CORBA_exception_free (&ev); } /** @@ -330,6 +364,26 @@ evolution_shell_client_user_select_folder (EvolutionShellClient *shell_client, uri_return, physical_uri_return); } + +/** + * evolution_shell_client_get_activity_interface: + * @shell_client: An EvolutionShellClient object + * + * Get the GNOME::Evolution::Activity for the shell associated to + * @shell_client. + * + * Return value: A CORBA Object represeting the GNOME::Evolution::Activity + * interface. + **/ +GNOME_Evolution_Activity +evolution_shell_client_get_activity_interface (EvolutionShellClient *shell_client) +{ + g_return_val_if_fail (shell_client != NULL, CORBA_OBJECT_NIL); + g_return_val_if_fail (EVOLUTION_IS_SHELL_CLIENT (shell_client), CORBA_OBJECT_NIL); + + return shell_client->priv->activity_interface; +} + /** * evolution_shell_client_get_local_storage: diff --git a/shell/evolution-shell-client.h b/shell/evolution-shell-client.h index ae6fbfd748..aee891cc08 100644 --- a/shell/evolution-shell-client.h +++ b/shell/evolution-shell-client.h @@ -67,6 +67,8 @@ void evolution_shell_client_user_select_folder (EvolutionShe char **uri_return, char **physical_uri_return); +GNOME_Evolution_Activity evolution_shell_client_get_activity_interface (EvolutionShellClient *shell_client); + GNOME_Evolution_LocalStorage evolution_shell_client_get_local_storage (EvolutionShellClient *shell_client); #ifdef __cplusplus diff --git a/shell/evolution-test-component.c b/shell/evolution-test-component.c index 1b5b428059..40ea6b6e7c 100644 --- a/shell/evolution-test-component.c +++ b/shell/evolution-test-component.c @@ -45,7 +45,6 @@ static const EvolutionShellComponentFolderType folder_types[] = { static EvolutionShellClient *parent_shell = NULL; -static GNOME_Evolution_Activity activity_interface = CORBA_OBJECT_NIL; static CORBA_long activity_id = 0; @@ -133,9 +132,8 @@ timeout_callback_3 (void *data) CORBA_exception_init (&ev); - GNOME_Evolution_Activity_operationFinished (activity_interface, - activity_id, - &ev); + GNOME_Evolution_Activity_operationFinished (evolution_shell_client_get_activity_interface (parent_shell), + activity_id, &ev); if (ev._major != CORBA_NO_EXCEPTION) { g_warning ("Cannot report operation as finished; exception returned -- %s\n", @@ -160,7 +158,7 @@ timeout_callback_2 (void *data) CORBA_exception_init (&ev); - GNOME_Evolution_Activity_operationProgressing (activity_interface, + GNOME_Evolution_Activity_operationProgressing (evolution_shell_client_get_activity_interface (parent_shell), activity_id, "Operation Foo in progress", (CORBA_float) progress / 100.0, @@ -191,13 +189,13 @@ timeout_callback_1 (void *data) CORBA_boolean suggest_display; CORBA_Environment ev; GNOME_Evolution_AnimatedIcon *animated_icon; + GNOME_Evolution_Activity activity_interface; - CORBA_exception_init (&ev); - - if (CORBA_Object_is_nil (activity_interface, &ev)) { - CORBA_exception_free (&ev); + activity_interface = evolution_shell_client_get_activity_interface (parent_shell); + if (activity_interface== CORBA_OBJECT_NIL) return FALSE; - } + + CORBA_exception_init (&ev); g_print ("Component becoming busy -- %s\n", COMPONENT_ID); @@ -284,26 +282,14 @@ owner_set_callback (EvolutionShellComponent *shell_component, EvolutionShellClient *shell_client, const char *evolution_homedir) { - CORBA_Environment ev; - g_assert (parent_shell == NULL); g_print ("We have an owner -- home directory is `%s'\n", evolution_homedir); parent_shell = shell_client; - CORBA_exception_init (&ev); - - activity_interface = Bonobo_Unknown_queryInterface (bonobo_object_corba_objref (BONOBO_OBJECT (shell_client)), - "IDL:GNOME/Evolution/Activity:1.0", - &ev); - if (ev._major != CORBA_NO_EXCEPTION) - activity_interface = CORBA_OBJECT_NIL; - - if (CORBA_Object_is_nil (activity_interface, &ev)) + if (evolution_shell_client_get_activity_interface (parent_shell) == CORBA_OBJECT_NIL) g_warning ("Shell doesn't have a ::Activity interface -- weird!"); - - CORBA_exception_free (&ev); } static int -- cgit v1.2.3