aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-04-06 20:19:24 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-04-06 20:23:14 +0800
commitf19891b168ec7d5f67b54571a91b1118901c0771 (patch)
tree101aa564996c3da6bfdf5f93fc36d8b5499f0931 /libempathy-gtk
parent73d8a18c6def748d78e91f0dda1145771c620b53 (diff)
downloadgsoc2013-empathy-f19891b168ec7d5f67b54571a91b1118901c0771.tar
gsoc2013-empathy-f19891b168ec7d5f67b54571a91b1118901c0771.tar.gz
gsoc2013-empathy-f19891b168ec7d5f67b54571a91b1118901c0771.tar.bz2
gsoc2013-empathy-f19891b168ec7d5f67b54571a91b1118901c0771.tar.lz
gsoc2013-empathy-f19891b168ec7d5f67b54571a91b1118901c0771.tar.xz
gsoc2013-empathy-f19891b168ec7d5f67b54571a91b1118901c0771.tar.zst
gsoc2013-empathy-f19891b168ec7d5f67b54571a91b1118901c0771.zip
log-window: no need to use a ctx struct
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-log-window.c51
1 files changed, 11 insertions, 40 deletions
diff --git a/libempathy-gtk/empathy-log-window.c b/libempathy-gtk/empathy-log-window.c
index 8bb92b82e..f6b5edf16 100644
--- a/libempathy-gtk/empathy-log-window.c
+++ b/libempathy-gtk/empathy-log-window.c
@@ -786,37 +786,11 @@ log_window_chats_changed_cb (GtkTreeSelection *selection,
log_window_chats_get_messages (window, NULL);
}
-typedef struct
-{
- EmpathyLogWindow *window;
- TpAccount *account;
-} GetEntitiesCtx;
-
-static GetEntitiesCtx *
-get_entities_ctx_new (EmpathyLogWindow *window,
- TpAccount *account)
-{
- GetEntitiesCtx *ctx = g_slice_new (GetEntitiesCtx);
-
- /* EmpathyLogWindow isn't a proper GObject so we can't ref it */
- ctx->window = window;
- ctx->account = g_object_ref (account);
- return ctx;
-}
-
-static void
-get_entities_ctx_free (GetEntitiesCtx *ctx)
-{
- g_object_unref (ctx->account);
- g_slice_free (GetEntitiesCtx, ctx);
-}
-
static void
log_manager_got_entities_cb (GObject *manager,
GAsyncResult *result,
gpointer user_data)
{
- GetEntitiesCtx *ctx = user_data;
GList *entities;
GList *l;
GtkTreeView *view;
@@ -826,8 +800,7 @@ log_manager_got_entities_cb (GObject *manager,
GtkTreeIter iter;
GError *error = NULL;
gboolean select_account = FALSE;
-
- view = GTK_TREE_VIEW (ctx->window->treeview_chats);
+ TpAccount *account = user_data;
if (log_window == NULL)
goto out;
@@ -839,7 +812,7 @@ log_manager_got_entities_cb (GObject *manager,
goto out;
}
- view = GTK_TREE_VIEW (ctx->window->treeview_chats);
+ view = GTK_TREE_VIEW (log_window->treeview_chats);
model = gtk_tree_view_get_model (view);
selection = gtk_tree_view_get_selection (view);
store = GTK_LIST_STORE (model);
@@ -853,13 +826,13 @@ log_manager_got_entities_cb (GObject *manager,
gtk_list_store_set (store, &iter,
COL_CHAT_ICON, "empathy-available", /* FIXME */
COL_CHAT_NAME, tpl_entity_get_alias (entity),
- COL_CHAT_ACCOUNT, ctx->account,
+ COL_CHAT_ACCOUNT, account,
COL_CHAT_TARGET, entity,
-1);
- if (ctx->window->selected_account != NULL &&
- !tp_strdiff (tp_proxy_get_object_path (ctx->account),
- tp_proxy_get_object_path (ctx->window->selected_account)))
+ if (log_window->selected_account != NULL &&
+ !tp_strdiff (tp_proxy_get_object_path (account),
+ tp_proxy_get_object_path (log_window->selected_account)))
select_account = TRUE;
/* FIXME: Update COL_CHAT_ICON/NAME */
@@ -872,15 +845,15 @@ log_manager_got_entities_cb (GObject *manager,
/* Unblock signals */
g_signal_handlers_unblock_by_func (selection,
log_window_chats_changed_cb,
- ctx->window);
+ log_window);
/* We display the selected account if we populate the model with chats from
* this account. */
if (select_account)
- log_window_chats_set_selected (ctx->window);
+ log_window_chats_set_selected (log_window);
out:
- get_entities_ctx_free (ctx);
+ g_object_unref (account);
}
static void
@@ -893,7 +866,6 @@ log_window_chats_populate (EmpathyLogWindow *window)
GtkTreeModel *model;
GtkTreeSelection *selection;
GtkListStore *store;
- GetEntitiesCtx *ctx;
account_chooser = EMPATHY_ACCOUNT_CHOOSER (window->account_chooser_chats);
account = empathy_account_chooser_dup_account (account_chooser);
@@ -915,10 +887,9 @@ log_window_chats_populate (EmpathyLogWindow *window)
gtk_list_store_clear (store);
- ctx = get_entities_ctx_new (window, account);
-
+ /* Pass the account reference to the callback */
tpl_log_manager_get_entities_async (window->log_manager, account,
- log_manager_got_entities_cb, ctx);
+ log_manager_got_entities_cb, account);
}
static void