diff options
author | Not Zed <NotZed@Ximian.com> | 2004-06-24 16:14:51 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2004-06-24 16:14:51 +0800 |
commit | 8317d34210847481717b2bb4345df70c97376d73 (patch) | |
tree | 4c32f00ff8c1dc69b8ceba38f9ecd2a38b837721 /shell/e-component-registry.c | |
parent | ed34d79a98aa6ed0e89a6b3da14ee5b1267f81b3 (diff) | |
download | gsoc2013-evolution-8317d34210847481717b2bb4345df70c97376d73.tar.gz gsoc2013-evolution-8317d34210847481717b2bb4345df70c97376d73.tar.zst gsoc2013-evolution-8317d34210847481717b2bb4345df70c97376d73.zip |
** See bug #57367.
2004-06-24 Not Zed <NotZed@Ximian.com>
** See bug #57367.
* e-shell-window.c (e_shell_window_new): fix gconf client leak and
clean up some logic.
* e-shell.c (e_shell_construct): dont activate the components
individually, component registry does that implictly.
* e-component-registry.c (init): dont call query_components here.
(query_components): setup a run-once guard. before adding a
component info to the list, make sure we can activate it.
(component_info_new): take the interface as a construct argument
now.
(e_component_registry_peek_list): perform the component list query
if we haven't already.
(e_component_registry_peek_info): same.
(e_component_registry_activate): just always return
the reffed component, it isn't added unless it was already activated.
svn path=/trunk/; revision=26490
Diffstat (limited to 'shell/e-component-registry.c')
-rw-r--r-- | shell/e-component-registry.c | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/shell/e-component-registry.c b/shell/e-component-registry.c index 9abe47197c..d83c0ae572 100644 --- a/shell/e-component-registry.c +++ b/shell/e-component-registry.c @@ -45,6 +45,8 @@ static GObjectClass *parent_class = NULL; struct _EComponentRegistryPrivate { GSList *infos; + + int init:1; }; @@ -52,6 +54,7 @@ struct _EComponentRegistryPrivate { static EComponentInfo * component_info_new (const char *id, + GNOME_Evolution_Component iface, const char *alias, const char *button_label, const char *menu_label, @@ -63,6 +66,7 @@ component_info_new (const char *id, EComponentInfo *info = g_new0 (EComponentInfo, 1); info->id = g_strdup (id); + info->iface = bonobo_object_dup_ref(iface, NULL); info->alias = g_strdup (alias); info->button_label = g_strdup (button_label); info->menu_label = g_strdup (menu_label); @@ -151,6 +155,11 @@ query_components (EComponentRegistry *registry) char *query; int i; + if (registry->priv->init) + return; + + registry->priv->init = TRUE; + CORBA_exception_init (&ev); query = g_strdup_printf ("repo_ids.has ('IDL:GNOME/Evolution/Component:%s')", BASE_VERSION); info_list = bonobo_activation_query (query, NULL, &ev); @@ -179,8 +188,20 @@ query_components (EComponentRegistry *registry) GdkPixbuf *icon = NULL, *menuicon = NULL; EComponentInfo *info; int sort_order; + GNOME_Evolution_Component iface; id = info_list->_buffer[i].iid; + iface = bonobo_activation_activate_from_id (id, 0, NULL, &ev); + if (BONOBO_EX (&ev) || iface == CORBA_OBJECT_NIL) { + char *ex_text = bonobo_exception_get_text (&ev); + + g_warning("Cannot activate '%s': %s\n", id, ex_text); + g_free(ex_text); + CORBA_exception_free(&ev); + CORBA_exception_init(&ev); + continue; + } + label = bonobo_server_info_prop_lookup (& info_list->_buffer[i], "evolution:button_label", language_list); if (label == NULL) label = g_strdup (_("Unknown")); @@ -206,7 +227,7 @@ query_components (EComponentRegistry *registry) else sort_order = atoi (sort_order_string); - info = component_info_new (id, alias, label, menu_label, + info = component_info_new (id, iface, alias, label, menu_label, menu_accelerator, sort_order, icon, menuicon); set_schemas (info, & info_list->_buffer [i]); @@ -214,6 +235,7 @@ query_components (EComponentRegistry *registry) if (icon != NULL) g_object_unref (icon); + bonobo_object_release_unref(iface, NULL); } g_slist_free(language_list); @@ -259,8 +281,6 @@ static void init (EComponentRegistry *registry) { registry->priv = g_new0 (EComponentRegistryPrivate, 1); - - query_components (registry); } @@ -276,6 +296,8 @@ e_component_registry_peek_list (EComponentRegistry *registry) { g_return_val_if_fail (E_IS_COMPONENT_REGISTRY (registry), NULL); + query_components(registry); + return registry->priv->infos; } @@ -289,6 +311,8 @@ e_component_registry_peek_info (EComponentRegistry *registry, g_return_val_if_fail (E_IS_COMPONENT_REGISTRY (registry), NULL); + query_components(registry); + for (p = registry->priv->infos; p != NULL; p = p->next) { EComponentInfo *info = p->data; @@ -327,15 +351,7 @@ e_component_registry_activate (EComponentRegistry *registry, return CORBA_OBJECT_NIL; } - if (info->iface != CORBA_OBJECT_NIL) - return bonobo_object_dup_ref (info->iface, NULL); - - info->iface = bonobo_activation_activate_from_id (info->id, 0, NULL, ev); - if (BONOBO_EX (ev) || info->iface == CORBA_OBJECT_NIL) { - info->iface = CORBA_OBJECT_NIL; - return CORBA_OBJECT_NIL; - } - + /* it isn't in the registry unless it is already activated */ return bonobo_object_dup_ref (info->iface, NULL); } |