aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-03-27 20:18:01 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-03-27 20:18:01 +0800
commit2a832a3135c17e437ee49420a9738a712c9f9ef6 (patch)
tree0cb56ed679948c59a8dfcb67c96ac94b8b0adab5
parent85bf02f460934eed3ad39bf830c70331a3c76ecc (diff)
downloadgsoc2013-empathy-2a832a3135c17e437ee49420a9738a712c9f9ef6.tar
gsoc2013-empathy-2a832a3135c17e437ee49420a9738a712c9f9ef6.tar.gz
gsoc2013-empathy-2a832a3135c17e437ee49420a9738a712c9f9ef6.tar.bz2
gsoc2013-empathy-2a832a3135c17e437ee49420a9738a712c9f9ef6.tar.lz
gsoc2013-empathy-2a832a3135c17e437ee49420a9738a712c9f9ef6.tar.xz
gsoc2013-empathy-2a832a3135c17e437ee49420a9738a712c9f9ef6.tar.zst
gsoc2013-empathy-2a832a3135c17e437ee49420a9738a712c9f9ef6.zip
factor out add_event_to_store()
-rw-r--r--libempathy-gtk/empathy-log-window.c91
1 files changed, 39 insertions, 52 deletions
diff --git a/libempathy-gtk/empathy-log-window.c b/libempathy-gtk/empathy-log-window.c
index e5cc066c2..f9cab21a1 100644
--- a/libempathy-gtk/empathy-log-window.c
+++ b/libempathy-gtk/empathy-log-window.c
@@ -1853,6 +1853,43 @@ populate_dates_from_search_hits (GList *accounts,
}
static void
+add_event_to_store (EmpathyLogWindow *self,
+ TpAccount *account,
+ TplEntity *entity)
+{
+ GtkListStore *store;
+ GtkTreeIter iter;
+ TplEntityType type = tpl_entity_get_entity_type (entity);
+ EmpathyContact *contact;
+ const gchar *name;
+ gchar *sort_key;
+ gboolean room = type == TPL_ENTITY_ROOM;
+
+ store = GTK_LIST_STORE (gtk_tree_view_get_model (
+ GTK_TREE_VIEW (log_window->priv->treeview_who)));
+
+ contact = empathy_contact_from_tpl_contact (account, entity);
+
+ name = empathy_contact_get_alias (contact);
+ sort_key = g_utf8_collate_key (name, -1);
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter,
+ COL_WHO_TYPE, COL_TYPE_NORMAL,
+ COL_WHO_ICON, room ? EMPATHY_IMAGE_GROUP_MESSAGE
+ : EMPATHY_IMAGE_AVATAR_DEFAULT,
+ COL_WHO_NAME, name,
+ COL_WHO_NAME_SORT_KEY, sort_key,
+ COL_WHO_ID, tpl_entity_get_identifier (entity),
+ COL_WHO_ACCOUNT, account,
+ COL_WHO_TARGET, entity,
+ -1);
+
+ g_free (sort_key);
+ g_object_unref (contact);
+}
+
+static void
populate_entities_from_search_hits (void)
{
EmpathyAccountChooser *account_chooser;
@@ -1891,32 +1928,7 @@ populate_entities_from_search_hits (void)
gtk_tree_model_foreach (model, model_has_entity, hit);
if (!has_element)
{
- TplEntityType type = tpl_entity_get_entity_type (hit->target);
- EmpathyContact *contact;
- const gchar *name;
- gchar *sort_key;
- gboolean room = type == TPL_ENTITY_ROOM;
-
- contact = empathy_contact_from_tpl_contact (hit->account,
- hit->target);
-
- name = empathy_contact_get_alias (contact);
- sort_key = g_utf8_collate_key (name, -1);
-
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter,
- COL_WHO_TYPE, COL_TYPE_NORMAL,
- COL_WHO_ICON, room ? EMPATHY_IMAGE_GROUP_MESSAGE
- : EMPATHY_IMAGE_AVATAR_DEFAULT,
- COL_WHO_NAME, name,
- COL_WHO_NAME_SORT_KEY, sort_key,
- COL_WHO_ID, tpl_entity_get_identifier (hit->target),
- COL_WHO_ACCOUNT, hit->account,
- COL_WHO_TARGET, hit->target,
- -1);
-
- g_free (sort_key);
- g_object_unref (contact);
+ add_event_to_store (log_window, hit->account, hit->target);
}
}
@@ -2362,32 +2374,7 @@ log_manager_got_entities_cb (GObject *manager,
for (l = entities; l; l = l->next)
{
- TplEntity *entity = TPL_ENTITY (l->data);
- TplEntityType type = tpl_entity_get_entity_type (entity);
- EmpathyContact *contact;
- const gchar *name;
- gchar *sort_key;
- gboolean room = type == TPL_ENTITY_ROOM;
-
- contact = empathy_contact_from_tpl_contact (ctx->account, entity);
-
- name = empathy_contact_get_alias (contact);
- sort_key = g_utf8_collate_key (name, -1);
-
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter,
- COL_WHO_TYPE, COL_TYPE_NORMAL,
- COL_WHO_ICON, room ? EMPATHY_IMAGE_GROUP_MESSAGE
- : EMPATHY_IMAGE_AVATAR_DEFAULT,
- COL_WHO_NAME, name,
- COL_WHO_NAME_SORT_KEY, sort_key,
- COL_WHO_ID, tpl_entity_get_identifier (entity),
- COL_WHO_ACCOUNT, ctx->account,
- COL_WHO_TARGET, entity,
- -1);
-
- g_free (sort_key);
- g_object_unref (contact);
+ add_event_to_store (ctx->self, ctx->account, l->data);
if (ctx->self->priv->selected_account != NULL &&
!tp_strdiff (tp_proxy_get_object_path (ctx->account),