aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-shell.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-03-22 10:22:57 +0800
committerMichael Meeks <michael.meeks@novell.com>2010-04-07 19:13:36 +0800
commit13fb16f2793ee91099b1f2960c1875896991f1c4 (patch)
tree9d5832e48bd514baeb24e158db0693f5a1202f7f /shell/e-shell.c
parent83e36a49baa491609bda692e36006123a7aa079f (diff)
downloadgsoc2013-evolution-13fb16f2793ee91099b1f2960c1875896991f1c4.tar
gsoc2013-evolution-13fb16f2793ee91099b1f2960c1875896991f1c4.tar.gz
gsoc2013-evolution-13fb16f2793ee91099b1f2960c1875896991f1c4.tar.bz2
gsoc2013-evolution-13fb16f2793ee91099b1f2960c1875896991f1c4.tar.lz
gsoc2013-evolution-13fb16f2793ee91099b1f2960c1875896991f1c4.tar.xz
gsoc2013-evolution-13fb16f2793ee91099b1f2960c1875896991f1c4.tar.zst
gsoc2013-evolution-13fb16f2793ee91099b1f2960c1875896991f1c4.zip
Demonstrate extending the EExtension API.
Introduce e_extensible_list_extensions(), which provides extensible objects access to their own extensions, or a subset of them. Convert EShellBackend to an abstract EExtension subtype. EShell will load its extensions with e_extensible_load_extensions(), and then obtain a list of EShellBackend extensions as follows: shell_backends = e_extensible_list_extensions ( E_EXTENSIBLE (shell), E_TYPE_SHELL_BACKEND); Because EShellBackend is abstract, its GType is skipped while traversing the GType hierarchy to find EShell extensions.
Diffstat (limited to 'shell/e-shell.c')
-rw-r--r--shell/e-shell.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/shell/e-shell.c b/shell/e-shell.c
index c9dfd156e6..f877bca4ec 100644
--- a/shell/e-shell.c
+++ b/shell/e-shell.c
@@ -52,7 +52,7 @@ struct _EShellPrivate {
GtkWidget *preferences_window;
/* Shell Backends */
- GList *loaded_backends;
+ GList *loaded_backends; /* not referenced */
GHashTable *backends_by_name;
GHashTable *backends_by_scheme;
@@ -407,23 +407,14 @@ shell_split_and_insert_items (GHashTable *hash_table,
}
static void
-shell_add_backend (GType type,
- EShell *shell)
+shell_process_backend (EShellBackend *shell_backend,
+ EShell *shell)
{
EShellBackendClass *class;
- EShellBackend *shell_backend;
GHashTable *backends_by_name;
GHashTable *backends_by_scheme;
const gchar *string;
- shell_backend = g_object_new (type, "shell", shell, NULL);
-
- shell->priv->loaded_backends = g_list_insert_sorted (
- shell->priv->loaded_backends, shell_backend,
- (GCompareFunc) e_shell_backend_compare);
-
- /* Bookkeeping */
-
class = E_SHELL_BACKEND_GET_CLASS (shell_backend);
backends_by_name = shell->priv->backends_by_name;
backends_by_scheme = shell->priv->backends_by_scheme;
@@ -601,10 +592,6 @@ shell_dispose (GObject *object)
priv->preferences_window = NULL;
}
- g_list_foreach (priv->loaded_backends, (GFunc) g_object_unref, NULL);
- g_list_free (priv->loaded_backends);
- priv->loaded_backends = NULL;
-
if (priv->preparing_for_line_change != NULL) {
g_object_remove_weak_pointer (
G_OBJECT (priv->preparing_for_line_change),
@@ -629,6 +616,8 @@ shell_finalize (GObject *object)
if (!unique_app_is_running (UNIQUE_APP (object)))
e_file_lock_destroy ();
+ g_list_free (priv->loaded_backends);
+
g_free (priv->geometry);
g_free (priv->module_directory);
@@ -640,6 +629,7 @@ static void
shell_constructed (GObject *object)
{
EShellPrivate *priv;
+ GList *list;
priv = E_SHELL_GET_PRIVATE (object);
@@ -659,11 +649,13 @@ shell_constructed (GObject *object)
shell_load_modules (E_SHELL (object));
- e_type_traverse (
- E_TYPE_SHELL_BACKEND, (ETypeFunc)
- shell_add_backend, object);
-
- e_extensible_load_extensions (E_EXTENSIBLE (object));
+ /* Process shell backends. */
+ list = g_list_sort (
+ e_extensible_list_extensions (
+ E_EXTENSIBLE (object), E_TYPE_SHELL_BACKEND),
+ (GCompareFunc) e_shell_backend_compare);
+ g_list_foreach (list, (GFunc) shell_process_backend, object);
+ priv->loaded_backends = list;
}
static UniqueResponse