From 175e46dd48b3906e59df36b9faa469565783e28d Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Fri, 23 Sep 2011 11:01:36 +0200 Subject: Wait for the store to be filled before loading events https://bugzilla.gnome.org/show_bug.cgi?id=659807 --- src/empathy-main-window.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'src/empathy-main-window.c') diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index cb135c4fc..fda8a9601 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -555,6 +555,23 @@ main_window_event_removed_cb (EmpathyEventManager *manager, &data); } +static gboolean +main_window_load_events_idle_cb (gpointer user_data) +{ + EmpathyMainWindow *window = user_data; + EmpathyMainWindowPriv *priv = GET_PRIV (window); + GSList *l; + + l = empathy_event_manager_get_events (priv->event_manager); + while (l) { + main_window_event_added_cb (priv->event_manager, l->data, + window); + l = l->next; + } + + return FALSE; +} + static void main_window_row_activated_cb (EmpathyContactListView *view, GtkTreePath *path, @@ -649,6 +666,12 @@ main_window_row_inserted_cb (GtkTreeModel *model, gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), PAGE_CONTACT_LIST); gtk_widget_grab_focus (GTK_WIDGET (priv->individual_view)); + + /* The store is being filled, it will be done after an idle cb. + * So we can then get events. If we do that too soon, event's + * contact is not yet in the store and it won't get marked as + * having events. */ + g_idle_add (main_window_load_events_idle_cb, window); } } @@ -2152,7 +2175,6 @@ empathy_main_window_init (EmpathyMainWindow *window) GtkToolItem *item; gboolean show_offline; gchar *filename; - GSList *l; GtkTreeModel *model; GtkWidget *search_vbox; GtkWidget *menubar; @@ -2393,13 +2415,6 @@ empathy_main_window_init (EmpathyMainWindow *window) G_CALLBACK (main_window_account_disabled_cb), window); - l = empathy_event_manager_get_events (priv->event_manager); - while (l) { - main_window_event_added_cb (priv->event_manager, l->data, - window); - l = l->next; - } - /* Show offline ? */ show_offline = g_settings_get_boolean (priv->gsettings_ui, EMPATHY_PREFS_UI_SHOW_OFFLINE); -- cgit v1.2.3