aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-component-registry.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/e-component-registry.c')
-rw-r--r--shell/e-component-registry.c40
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);
}