From 38a616e8b77cbe8bce87c97e66f7b542eda24235 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Wed, 2 Dec 2009 00:57:44 -0500 Subject: Add an EShell:module-directory constructor property. This tells EShell where to look for EModules. Best practice is to define the directory in your CPPFLAGS and then pass it to EShell at instantiation time, like so: Makefile.am: evolution_CPPFLAGS = \ -DMODULEDIR=\""$(moduledir)"\" ... main.c: shell = g_object_new ( E_TYPE_SHELL, "module-directory", MODULEDIR, ...); --- shell/e-shell.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- shell/e-shell.h | 1 + shell/main.c | 1 + 3 files changed, 67 insertions(+), 6 deletions(-) (limited to 'shell') diff --git a/shell/e-shell.c b/shell/e-shell.c index 544b960e6c..130e0f0912 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -52,6 +52,7 @@ struct _EShellPrivate { gpointer preparing_for_quit; /* weak pointer */ gchar *geometry; + gchar *module_directory; guint auto_reconnect : 1; guint network_available : 1; @@ -63,6 +64,7 @@ struct _EShellPrivate { enum { PROP_0, PROP_GEOMETRY, + PROP_MODULE_DIRECTORY, PROP_NETWORK_AVAILABLE, PROP_ONLINE, PROP_SHELL_SETTINGS @@ -373,15 +375,18 @@ shell_request_quit (EShell *shell) static void shell_load_modules (EShell *shell) { - GList *modules; + const gchar *module_directory; + GList *modules = NULL; /* Load all shared library modules. */ - modules = e_module_load_all_in_directory (EVOLUTION_MODULEDIR); - while (modules != NULL) { - g_type_module_unuse (G_TYPE_MODULE (modules->data)); - modules = g_list_delete_link (modules, modules); - } + module_directory = e_shell_get_module_directory (shell); + g_return_if_fail (module_directory != NULL); + + modules = e_module_load_all_in_directory (module_directory); + + g_list_foreach (modules, (GFunc) g_type_module_unuse, NULL); + g_list_free (modules); } /* Helper for shell_add_backend() */ @@ -479,6 +484,15 @@ shell_set_geometry (EShell *shell, shell->priv->geometry = g_strdup (geometry); } +static void +shell_set_module_directory (EShell *shell, + const gchar *module_directory) +{ + g_return_if_fail (shell->priv->module_directory == NULL); + + shell->priv->module_directory = g_strdup (module_directory); +} + static void shell_set_property (GObject *object, guint property_id, @@ -492,6 +506,12 @@ shell_set_property (GObject *object, g_value_get_string (value)); return; + case PROP_MODULE_DIRECTORY: + shell_set_module_directory ( + E_SHELL (object), + g_value_get_string (value)); + return; + case PROP_NETWORK_AVAILABLE: e_shell_set_network_available ( E_SHELL (object), @@ -515,6 +535,12 @@ shell_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { + case PROP_MODULE_DIRECTORY: + g_value_set_string ( + value, e_shell_get_module_directory ( + E_SHELL (object))); + return; + case PROP_NETWORK_AVAILABLE: g_value_set_boolean ( value, e_shell_get_network_available ( @@ -588,6 +614,7 @@ shell_finalize (GObject *object) e_file_lock_destroy (); g_free (priv->geometry); + g_free (priv->module_directory); /* Chain up to parent's finalize() method. */ G_OBJECT_CLASS (parent_class)->finalize (object); @@ -746,6 +773,22 @@ shell_class_init (EShellClass *class) G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); + /** + * EShell:module-directory + * + * The directory from which to load #EModules. + **/ + g_object_class_install_property ( + object_class, + PROP_MODULE_DIRECTORY, + g_param_spec_string ( + "module-directory", + _("Module Directory"), + _("The directory from which to load EModules"), + NULL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); + /** * EShell:network-available * @@ -1503,6 +1546,22 @@ e_shell_send_receive (EShell *shell, g_signal_emit (shell, signals[SEND_RECEIVE], 0, parent); } +/** + * e_shell_get_module_directory: + * @shell: an #EShell + * + * Returns the directory from which #EModules were loaded. + * + * Returns: the #EModule directory + **/ +const gchar * +e_shell_get_module_directory (EShell *shell) +{ + g_return_val_if_fail (E_IS_SHELL (shell), NULL); + + return shell->priv->module_directory; +} + /** * e_shell_get_network_available: * @shell: an #EShell diff --git a/shell/e-shell.h b/shell/e-shell.h index 7d1904a828..1a324806a2 100644 --- a/shell/e-shell.h +++ b/shell/e-shell.h @@ -114,6 +114,7 @@ GList * e_shell_get_watched_windows (EShell *shell); GtkWindow * e_shell_get_active_window (EShell *shell); void e_shell_send_receive (EShell *shell, GtkWindow *parent); +const gchar * e_shell_get_module_directory (EShell *shell); gboolean e_shell_get_network_available (EShell *shell); void e_shell_set_network_available (EShell *shell, gboolean network_available); diff --git a/shell/main.c b/shell/main.c index 7a09f60d12..c1a4e5decf 100644 --- a/shell/main.c +++ b/shell/main.c @@ -435,6 +435,7 @@ create_default_shell (void) E_TYPE_SHELL, "name", "org.gnome.Evolution", "geometry", geometry, + "module-directory", EVOLUTION_MODULEDIR, "online", online, NULL); -- cgit