From 31ec46f9fd5d7caa6dc407dba4d93ad655888db2 Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Tue, 19 Jun 2001 23:11:51 +0000 Subject: add auto exit unref 2001-06-19 JP Rosevear * gui/control-factory.c (control_factory_init): add auto exit unref * gui/component-factory.c (destroy_cb): destroy our selves if we have no more shells (component_factory_init): add auto exit unref svn path=/trunk/; revision=10312 --- calendar/gui/component-factory.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'calendar/gui/component-factory.c') diff --git a/calendar/gui/component-factory.c b/calendar/gui/component-factory.c index da68cabf05..17242740de 100644 --- a/calendar/gui/component-factory.c +++ b/calendar/gui/component-factory.c @@ -30,6 +30,7 @@ #include #include +#include #include "evolution-shell-component.h" #include "component-factory.h" #include "tasks-control-factory.h" @@ -269,7 +270,7 @@ xfer_folder (EvolutionShellComponent *shell_component, CORBA_exception_free (&ev); } -static gint owner_count = 0; +static GList *shells = NULL; static void owner_set_cb (EvolutionShellComponent *shell_component, @@ -278,8 +279,7 @@ owner_set_cb (EvolutionShellComponent *shell_component, gpointer user_data) { static gboolean migrated = FALSE; - - owner_count ++; + evolution_dir = g_strdup (evolution_homedir); calendar_config_init (); @@ -291,12 +291,13 @@ owner_set_cb (EvolutionShellComponent *shell_component, } static void -owner_unset_cb (EvolutionShellComponent *shell_component, - gpointer user_data) +destroy_cb (EvolutionShellComponent *shell_component, + gpointer user_data) { - owner_count --; - if (owner_count <= 0) - gtk_main_quit(); + shells = g_list_remove (shells, shell_component); + + if (g_list_length (shells) == 0) + gtk_main_quit (); } @@ -307,7 +308,7 @@ factory_fn (BonoboGenericFactory *factory, void *closure) { EvolutionShellComponent *shell_component; - + shell_component = evolution_shell_component_new (folder_types, create_view, create_folder, @@ -319,9 +320,11 @@ factory_fn (BonoboGenericFactory *factory, gtk_signal_connect (GTK_OBJECT (shell_component), "owner_set", GTK_SIGNAL_FUNC (owner_set_cb), NULL); - gtk_signal_connect (GTK_OBJECT (shell_component), "owner_unset", - GTK_SIGNAL_FUNC (owner_unset_cb), NULL); + gtk_signal_connect (GTK_OBJECT (shell_component), "destroy", + GTK_SIGNAL_FUNC (destroy_cb), NULL); + shells = g_list_append (shells, shell_component); + return BONOBO_OBJECT (shell_component); } @@ -334,6 +337,7 @@ component_factory_init (void) return; factory = bonobo_generic_factory_new (COMPONENT_FACTORY_ID, factory_fn, NULL); + bonobo_running_context_auto_exit_unref (BONOBO_OBJECT (factory)); if (factory == NULL) g_error ("Cannot initialize Evolution's calendar component."); -- cgit v1.2.3