[evolution] Postpone ENameSelector loading as much as possible
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Postpone ENameSelector loading as much as possible
- Date: Thu, 23 Jun 2011 16:32:25 +0000 (UTC)
commit 4778e69589b8d5fca5b59cdb664b8e6e39a4697f
Author: Milan Crha <mcrha redhat com>
Date: Thu Jun 23 18:30:36 2011 +0200
Postpone ENameSelector loading as much as possible
Also fixes few memory leaks around ENameSelector and cancels
loading of its address books when not needed any more.
.../contact-list-editor/e-contact-list-editor.c | 10 ++--------
calendar/gui/dialogs/alarm-dialog.c | 5 +++++
calendar/gui/dialogs/e-delegate-dialog.c | 2 ++
calendar/gui/dialogs/memo-page.c | 6 ++++++
calendar/gui/e-meeting-list-view.c | 14 ++++++++++++++
composer/e-composer-header-table.c | 15 +++++++++++++++
6 files changed, 44 insertions(+), 8 deletions(-)
---
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
index a4f30ca..a6a9cec 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c
+++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
@@ -1133,7 +1133,6 @@ setup_custom_widgets (EContactListEditor *editor)
GtkWidget *combo_box;
ESourceList *source_list;
ENameSelectorEntry *name_selector_entry;
- ENameSelector *name_selector;
GtkWidget *old, *parent;
EContactListEditorPrivate *priv;
GError *error = NULL;
@@ -1162,14 +1161,8 @@ setup_custom_widgets (EContactListEditor *editor)
old = CONTACT_LIST_EDITOR_WIDGET (editor, "email-entry");
g_return_if_fail (old != NULL);
- name_selector = e_name_selector_new ();
-
- e_name_selector_model_add_section (
- e_name_selector_peek_model (name_selector),
- "Members", _("_Members"), NULL);
-
name_selector_entry = e_name_selector_peek_section_entry (
- name_selector, "Members");
+ priv->name_selector, "Members");
gtk_widget_set_name (
GTK_WIDGET (name_selector_entry),
@@ -1316,6 +1309,7 @@ contact_list_editor_dispose (GObject *object)
EContactListEditorPrivate *priv = editor->priv;
if (priv->name_selector) {
+ e_name_selector_cancel_loading (priv->name_selector);
g_object_unref (priv->name_selector);
priv->name_selector = NULL;
}
diff --git a/calendar/gui/dialogs/alarm-dialog.c b/calendar/gui/dialogs/alarm-dialog.c
index 564c4dd..ec57b11 100644
--- a/calendar/gui/dialogs/alarm-dialog.c
+++ b/calendar/gui/dialogs/alarm-dialog.c
@@ -903,6 +903,7 @@ setup_select_names (Dialog *dialog)
ENameSelectorDialog *name_selector_dialog;
dialog->name_selector = e_name_selector_new ();
+ e_name_selector_load_books (dialog->name_selector);
name_selector_model = e_name_selector_peek_model (dialog->name_selector);
e_name_selector_model_add_section (name_selector_model, section_name, section_name, NULL);
@@ -1229,6 +1230,10 @@ alarm_dialog_run (GtkWidget *parent, ECalClient *cal_client, ECalComponentAlarm
if (response_id == GTK_RESPONSE_OK)
dialog_to_alarm (&dialog);
+ if (dialog.name_selector) {
+ e_name_selector_cancel_loading (dialog.name_selector);
+ g_object_unref (dialog.name_selector);
+ }
gtk_widget_destroy (dialog.toplevel);
g_object_unref (dialog.builder);
diff --git a/calendar/gui/dialogs/e-delegate-dialog.c b/calendar/gui/dialogs/e-delegate-dialog.c
index 2bca1c9..da6eeea 100644
--- a/calendar/gui/dialogs/e-delegate-dialog.c
+++ b/calendar/gui/dialogs/e-delegate-dialog.c
@@ -96,6 +96,7 @@ e_delegate_dialog_finalize (GObject *object)
edd = E_DELEGATE_DIALOG (object);
priv = edd->priv;
+ e_name_selector_cancel_loading (priv->name_selector);
g_object_unref (priv->name_selector);
/* Destroy the actual dialog. */
@@ -137,6 +138,7 @@ e_delegate_dialog_construct (EDelegateDialog *edd, const gchar *name, const gcha
}
priv->name_selector = e_name_selector_new ();
+ e_name_selector_load_books (priv->name_selector);
name_selector_model = e_name_selector_peek_model (priv->name_selector);
e_name_selector_model_add_section (name_selector_model, section_name, section_name, NULL);
diff --git a/calendar/gui/dialogs/memo-page.c b/calendar/gui/dialogs/memo-page.c
index d720e91..3a53421 100644
--- a/calendar/gui/dialogs/memo-page.c
+++ b/calendar/gui/dialogs/memo-page.c
@@ -202,6 +202,12 @@ memo_page_finalize (GObject *object)
priv = MEMO_PAGE (object)->priv;
+ if (priv->name_selector) {
+ e_name_selector_cancel_loading (priv->name_selector);
+ g_object_unref (priv->name_selector);
+ priv->name_selector = NULL;
+ }
+
if (priv->main != NULL) {
g_object_unref (priv->main);
priv->main = NULL;
diff --git a/calendar/gui/e-meeting-list-view.c b/calendar/gui/e-meeting-list-view.c
index 11f47e6..5283b5e 100644
--- a/calendar/gui/e-meeting-list-view.c
+++ b/calendar/gui/e-meeting-list-view.c
@@ -82,6 +82,7 @@ e_meeting_list_view_finalize (GObject *obj)
EMeetingListViewPrivate *priv = view->priv;
if (priv->name_selector) {
+ e_name_selector_cancel_loading (priv->name_selector);
g_object_unref (priv->name_selector);
priv->name_selector = NULL;
}
@@ -127,6 +128,17 @@ add_section (ENameSelector *name_selector, const gchar *name)
}
static void
+meeting_list_view_realize_cb (EMeetingListView *view)
+{
+ g_return_if_fail (view != NULL);
+ g_return_if_fail (view->priv != NULL);
+
+ g_signal_handlers_disconnect_by_func (view, meeting_list_view_realize_cb, NULL);
+
+ e_name_selector_load_books (view->priv->name_selector);
+}
+
+static void
e_meeting_list_view_init (EMeetingListView *view)
{
EMeetingListViewPrivate *priv;
@@ -149,6 +161,8 @@ e_meeting_list_view_init (EMeetingListView *view)
g_signal_connect (name_selector_dialog, "response",
G_CALLBACK (name_selector_dialog_close_cb), view);
+ /* postpone name_selector loading, do that only when really needed */
+ g_signal_connect (view, "realize", G_CALLBACK (meeting_list_view_realize_cb), NULL);
}
static GList *
diff --git a/composer/e-composer-header-table.c b/composer/e-composer-header-table.c
index 78404a6..c87abcf 100644
--- a/composer/e-composer-header-table.c
+++ b/composer/e-composer-header-table.c
@@ -825,6 +825,7 @@ composer_header_table_dispose (GObject *object)
}
if (priv->name_selector != NULL) {
+ e_name_selector_cancel_loading (priv->name_selector);
g_object_unref (priv->name_selector);
priv->name_selector = NULL;
}
@@ -991,6 +992,17 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class)
}
static void
+composer_header_table_realize_cb (EComposerHeaderTable *table)
+{
+ g_return_if_fail (table != NULL);
+ g_return_if_fail (table->priv != NULL);
+
+ g_signal_handlers_disconnect_by_func (table, composer_header_table_realize_cb, NULL);
+
+ e_name_selector_load_books (table->priv->name_selector);
+}
+
+static void
e_composer_header_table_init (EComposerHeaderTable *table)
{
EComposerHeader *header;
@@ -1064,6 +1076,9 @@ e_composer_header_table_init (EComposerHeaderTable *table)
header->input_widget, "visible",
G_BINDING_SYNC_CREATE);
}
+
+ /* postpone name_selector loading, do that only when really needed */
+ g_signal_connect (table, "realize", G_CALLBACK (composer_header_table_realize_cb), NULL);
}
GtkWidget *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]