[evolution] Get EConfig and EEvent hooks working again.
- From: Matthew Barnes <mbarnes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution] Get EConfig and EEvent hooks working again.
- Date: Mon, 31 Aug 2009 16:59:59 +0000 (UTC)
commit f5991437c3e620708f1701310bd1e67b40ca3b42
Author: Matthew Barnes <mbarnes redhat com>
Date: Mon Aug 31 12:53:52 2009 -0400
Get EConfig and EEvent hooks working again.
There were a number of problems:
- Walk the GType tree to find EPluginHook subclasses, instead of
just registering the immediate children.
- Some EConfig and EEvent subclasses were not being configured
properly (particularly the mail and calendar subclasses).
- Add preference window pages after the main loop starts to make
sure all plugins and plugin hooks are installed first.
e-util/e-config.c | 4 ++-
e-util/e-plugin.c | 22 ++++++++++++++++---
modules/addressbook/autocompletion-config.c | 18 +++------------
modules/addressbook/autocompletion-config.h | 2 +-
modules/addressbook/e-book-shell-backend.c | 30 +++++++++++++++++++++++---
modules/calendar/e-cal-config-hook.c | 8 +++++-
modules/calendar/e-cal-event-hook.c | 10 ++++----
modules/calendar/e-cal-shell-backend.c | 13 ++++++++---
modules/mail/e-mail-config-hook.c | 8 +++++-
modules/mail/e-mail-event-hook.c | 8 +++++-
modules/mail/e-mail-shell-backend.c | 13 ++++++++---
shell/e-shell-backend.h | 2 +-
widgets/misc/e-preferences-window.c | 6 +++++
13 files changed, 100 insertions(+), 44 deletions(-)
---
diff --git a/e-util/e-config.c b/e-util/e-config.c
index 9974da7..3695069 100644
--- a/e-util/e-config.c
+++ b/e-util/e-config.c
@@ -1654,7 +1654,9 @@ e_config_hook_get_type(void)
* target map enumates the target types available for the implenting
* class.
**/
-void e_config_hook_class_add_target_map(EConfigHookClass *klass, const EConfigHookTargetMap *map)
+void
+e_config_hook_class_add_target_map (EConfigHookClass *klass,
+ const EConfigHookTargetMap *map)
{
g_hash_table_insert(klass->target_map, (gpointer)map->type, (gpointer)map);
}
diff --git a/e-util/e-plugin.c b/e-util/e-plugin.c
index 5c5e55b..5d77dec 100644
--- a/e-util/e-plugin.c
+++ b/e-util/e-plugin.c
@@ -508,14 +508,27 @@ plugin_load_subclasses (void)
}
g_free (children);
+}
- /* Load EPluginHook subclasses. */
+static void
+plugin_load_hook_subclasses (GType parent_type)
+{
+ GType *children;
+ guint n_children, ii;
- children = g_type_children (E_TYPE_PLUGIN_HOOK, &n_children);
+ children = g_type_children (parent_type, &n_children);
for (ii = 0; ii < n_children; ii++) {
EPluginHookClass *hook_class;
EPluginHookClass *dupe_class;
+ gpointer key;
+
+ /* First load the child's children. */
+ plugin_load_hook_subclasses (children[ii]);
+
+ /* Skip abstract types. */
+ if (G_TYPE_IS_ABSTRACT (children[ii]))
+ continue;
hook_class = g_type_class_ref (children[ii]);
@@ -542,8 +555,8 @@ plugin_load_subclasses (void)
continue;
}
- g_hash_table_insert (
- eph_types, (gpointer) hook_class->id, hook_class);
+ key = (gpointer) hook_class->id;
+ g_hash_table_insert (eph_types, key, hook_class);
}
g_free (children);
@@ -571,6 +584,7 @@ e_plugin_load_plugins(void)
* subclasses be registered prior to loading any plugins.
* It greatly simplifies the loading process. */
plugin_load_subclasses ();
+ plugin_load_hook_subclasses (E_TYPE_PLUGIN_HOOK);
client = gconf_client_get_default ();
ep_disabled = gconf_client_get_list (
diff --git a/modules/addressbook/autocompletion-config.c b/modules/addressbook/autocompletion-config.c
index ac6a7d1..eb0c802 100644
--- a/modules/addressbook/autocompletion-config.c
+++ b/modules/addressbook/autocompletion-config.c
@@ -32,7 +32,6 @@
#include "e-util/e-binding.h"
#include "e-util/e-datetime-format.h"
-#include "widgets/misc/e-preferences-window.h"
static void
source_selection_changed_cb (ESourceSelector *source_selector)
@@ -129,19 +128,18 @@ add_section (GtkWidget *container,
return widget;
}
-void
-autocompletion_config_init (EShell *shell)
+GtkWidget *
+autocompletion_config_new (EShell *shell)
{
EShellSettings *shell_settings;
ESourceList *source_list;
GtkWidget *scrolled_window;
GtkWidget *source_selector;
- GtkWidget *preferences_window;
GtkWidget *itembox;
GtkWidget *widget;
GtkWidget *vbox;
- g_return_if_fail (E_IS_SHELL (shell));
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
shell_settings = e_shell_get_shell_settings (shell);
@@ -190,13 +188,5 @@ autocompletion_config_init (EShell *shell)
initialize_selection (E_SOURCE_SELECTOR (source_selector));
- preferences_window = e_shell_get_preferences_window (shell);
-
- e_preferences_window_add_page (
- E_PREFERENCES_WINDOW (preferences_window),
- "contacts",
- "preferences-autocompletion",
- _("Contacts"),
- vbox,
- 200);
+ return vbox;
}
diff --git a/modules/addressbook/autocompletion-config.h b/modules/addressbook/autocompletion-config.h
index 5769bdc..7f94a07 100644
--- a/modules/addressbook/autocompletion-config.h
+++ b/modules/addressbook/autocompletion-config.h
@@ -30,7 +30,7 @@
G_BEGIN_DECLS
-void autocompletion_config_init (EShell *shell);
+GtkWidget * autocompletion_config_new (EShell *shell);
G_END_DECLS
diff --git a/modules/addressbook/e-book-shell-backend.c b/modules/addressbook/e-book-shell-backend.c
index f96cb0d..1005a6b 100644
--- a/modules/addressbook/e-book-shell-backend.c
+++ b/modules/addressbook/e-book-shell-backend.c
@@ -30,10 +30,11 @@
#include <libedataserver/e-source.h>
#include <libedataserver/e-source-group.h>
+#include "e-util/e-import.h"
#include "shell/e-shell.h"
#include "shell/e-shell-window.h"
+#include "widgets/misc/e-preferences-window.h"
-#include "e-util/e-import.h"
#include "addressbook/gui/widgets/eab-gui-util.h"
#include "addressbook/gui/contact-editor/e-contact-editor.h"
#include "addressbook/gui/contact-list-editor/e-contact-list-editor.h"
@@ -359,6 +360,26 @@ static GtkActionEntry source_entries[] = {
};
static gboolean
+book_shell_backend_init_preferences (EShell *shell)
+{
+ GtkWidget *preferences_window;
+
+ /* This is a main loop idle callback. */
+
+ preferences_window = e_shell_get_preferences_window (shell);
+
+ e_preferences_window_add_page (
+ E_PREFERENCES_WINDOW (preferences_window),
+ "contacts",
+ "preferences-autocompletion",
+ _("Contacts"),
+ autocompletion_config_new (shell),
+ 200);
+
+ return FALSE;
+}
+
+static gboolean
book_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
const gchar *uri)
{
@@ -507,10 +528,11 @@ book_shell_backend_constructed (GObject *object)
G_CALLBACK (book_shell_backend_window_created_cb),
shell_backend);
- /* Initialize settings before initializing preferences,
- * since the preferences bind to the shell settings. */
e_book_shell_backend_init_settings (shell);
- autocompletion_config_init (shell);
+
+ /* Initialize preferences after the main loop starts so
+ * that all EPlugins and EPluginHooks are loaded first. */
+ g_idle_add ((GSourceFunc) book_shell_backend_init_preferences, shell);
}
static void
diff --git a/modules/calendar/e-cal-config-hook.c b/modules/calendar/e-cal-config-hook.c
index 4a05224..e3d9678 100644
--- a/modules/calendar/e-cal-config-hook.c
+++ b/modules/calendar/e-cal-config-hook.c
@@ -35,11 +35,15 @@ static const EConfigHookTargetMap targets[] = {
};
static void
-cal_config_hook_class_init (EPluginHookClass *class)
+cal_config_hook_class_init (EConfigHookClass *class)
{
+ EPluginHookClass *plugin_hook_class;
gint ii;
- class->id = "org.gnome.evolution.calendar.config:1.0";
+ plugin_hook_class = E_PLUGIN_HOOK_CLASS (class);
+ plugin_hook_class->id = "org.gnome.evolution.calendar.config:1.0";
+
+ class->config_class = g_type_class_ref (e_cal_config_get_type ());
for (ii = 0; targets[ii].type != NULL; ii++)
e_config_hook_class_add_target_map (
diff --git a/modules/calendar/e-cal-event-hook.c b/modules/calendar/e-cal-event-hook.c
index b263727..d90162d 100644
--- a/modules/calendar/e-cal-event-hook.c
+++ b/modules/calendar/e-cal-event-hook.c
@@ -35,15 +35,15 @@ static const EEventHookTargetMap targets[] = {
};
static void
-cal_event_hook_class_init (EPluginHookClass *class)
+cal_event_hook_class_init (EEventHookClass *class)
{
- EEventHookClass *event_hook_class;
+ EPluginHookClass *plugin_hook_class;
gint ii;
- event_hook_class = (EEventHookClass *) class;
- event_hook_class->event = (EEvent *) e_cal_event_peek ();
+ plugin_hook_class = E_PLUGIN_HOOK_CLASS (class);
+ plugin_hook_class->id = "org.gnome.evolution.calendar.events:1.0";
- class->id = "org.gnome.evolution.calendar.events:1.0";
+ class->event = (EEvent *) e_cal_event_peek ();
for (ii = 0; targets[ii].type != NULL; ii++)
e_event_hook_class_add_target_map (
diff --git a/modules/calendar/e-cal-shell-backend.c b/modules/calendar/e-cal-shell-backend.c
index 5149574..6511d0e 100644
--- a/modules/calendar/e-cal-shell-backend.c
+++ b/modules/calendar/e-cal-shell-backend.c
@@ -523,11 +523,13 @@ cal_shell_backend_init_importers (void)
e_import_class_add_importer (import_class, importer, NULL, NULL);
}
-static void
+static gboolean
cal_shell_backend_init_preferences (EShell *shell)
{
GtkWidget *preferences_window;
+ /* This is a main loop idle callback. */
+
preferences_window = e_shell_get_preferences_window (shell);
e_preferences_window_add_page (
@@ -537,6 +539,8 @@ cal_shell_backend_init_preferences (EShell *shell)
_("Calendar and Tasks"),
calendar_prefs_dialog_new (shell),
600);
+
+ return FALSE;
}
static gboolean
@@ -770,10 +774,11 @@ cal_shell_backend_constructed (GObject *object)
cal_shell_backend_init_importers ();
- /* Initialize settings before initializing preferences,
- * since the preferences bind to the shell settings. */
e_cal_shell_backend_init_settings (shell);
- cal_shell_backend_init_preferences (shell);
+
+ /* Initialize preferences after the main loop starts so
+ * that all EPlugins and EPluginHooks are loaded first. */
+ g_idle_add ((GSourceFunc) cal_shell_backend_init_preferences, shell);
}
static void
diff --git a/modules/mail/e-mail-config-hook.c b/modules/mail/e-mail-config-hook.c
index 4b37a6b..def986f 100644
--- a/modules/mail/e-mail-config-hook.c
+++ b/modules/mail/e-mail-config-hook.c
@@ -36,11 +36,15 @@ static const EConfigHookTargetMap targets[] = {
};
static void
-mail_config_hook_class_init (EPluginHookClass *class)
+mail_config_hook_class_init (EConfigHookClass *class)
{
+ EPluginHookClass *plugin_hook_class;
gint ii;
- class->id = "org.gnome.evolution.mail.config:1.0";
+ plugin_hook_class = E_PLUGIN_HOOK_CLASS (class);
+ plugin_hook_class->id = "org.gnome.evolution.mail.config:1.0";
+
+ class->config_class = g_type_class_ref (em_config_get_type ());
for (ii = 0; targets[ii].type != NULL; ii++)
e_config_hook_class_add_target_map (
diff --git a/modules/mail/e-mail-event-hook.c b/modules/mail/e-mail-event-hook.c
index a6be6d2..becc806 100644
--- a/modules/mail/e-mail-event-hook.c
+++ b/modules/mail/e-mail-event-hook.c
@@ -60,11 +60,15 @@ static const EEventHookTargetMap targets[] = {
};
static void
-mail_event_hook_class_init (EPluginHookClass *class)
+mail_event_hook_class_init (EEventHookClass *class)
{
+ EPluginHookClass *plugin_hook_class;
gint ii;
- class->id = "org.gnome.evolution.mail.events:1.0";
+ plugin_hook_class = E_PLUGIN_HOOK_CLASS (class);
+ plugin_hook_class->id = "org.gnome.evolution.mail.events:1.0";
+
+ class->event = (EEvent *) em_event_peek ();
for (ii = 0; targets[ii].type != NULL; ii++)
e_event_hook_class_add_target_map (
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c
index fd1e726..fd99edc 100644
--- a/modules/mail/e-mail-shell-backend.c
+++ b/modules/mail/e-mail-shell-backend.c
@@ -187,12 +187,14 @@ static GtkActionEntry source_entries[] = {
G_CALLBACK (action_mail_folder_new_cb) }
};
-static void
+static gboolean
mail_shell_backend_init_preferences (EShell *shell)
{
EAccountList *account_list;
GtkWidget *preferences_window;
+ /* This is a main loop idle callback. */
+
account_list = e_get_account_list ();
preferences_window = e_shell_get_preferences_window (shell);
@@ -227,6 +229,8 @@ mail_shell_backend_init_preferences (EShell *shell)
_("Network Preferences"),
em_network_prefs_new (),
500);
+
+ return FALSE;
}
static void
@@ -848,10 +852,11 @@ mail_shell_backend_constructed (GObject *object)
data_dir = e_shell_backend_get_data_dir (shell_backend);
e_mail_store_init (data_dir);
- /* Initialize settings before initializing preferences,
- * since the preferences bind to the shell settings. */
e_mail_shell_settings_init (shell);
- mail_shell_backend_init_preferences (shell);
+
+ /* Initialize preferences after the main loop starts so
+ * that all EPlugins and EPluginHooks are loaded first. */
+ g_idle_add ((GSourceFunc) mail_shell_backend_init_preferences, shell);
}
static void
diff --git a/shell/e-shell-backend.h b/shell/e-shell-backend.h
index 6dbbb33..026a035 100644
--- a/shell/e-shell-backend.h
+++ b/shell/e-shell-backend.h
@@ -118,7 +118,7 @@ struct _EShellBackendClass {
GError **error);
};
-GType e_shell_backend_get_type (void);
+GType e_shell_backend_get_type (void);
gint e_shell_backend_compare (EShellBackend *shell_backend_a,
EShellBackend *shell_backend_b);
const gchar * e_shell_backend_get_config_dir (EShellBackend *shell_backend);
diff --git a/widgets/misc/e-preferences-window.c b/widgets/misc/e-preferences-window.c
index af2d07d..52bda8e 100644
--- a/widgets/misc/e-preferences-window.c
+++ b/widgets/misc/e-preferences-window.c
@@ -369,6 +369,12 @@ e_preferences_window_add_page (EPreferencesWindow *window,
gtk_widget_show (widget);
gtk_notebook_append_page (notebook, widget, NULL);
+
+ /* Force GtkIconView to recalculate the text wrap width,
+ * otherwise we get a really narrow icon list on the left
+ * side of the preferences window. */
+ gtk_icon_view_set_item_width (icon_view, -1);
+ gtk_widget_queue_resize (GTK_WIDGET (window));
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]