aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorJonny Lamb <jonnylamb@gnome.org>2009-10-24 22:55:30 +0800
committerJonny Lamb <jonnylamb@gnome.org>2009-10-24 22:55:30 +0800
commit2beb2a7609f6534697a8874aaa9fc33f3bd115d8 (patch)
treee1e3e8aa8793e91df460ce8c50715d7afa08fdd8 /libempathy-gtk
parentf14693f2d70ff34f6a34477d64b85dfc92d53f04 (diff)
downloadgsoc2013-empathy-2beb2a7609f6534697a8874aaa9fc33f3bd115d8.tar
gsoc2013-empathy-2beb2a7609f6534697a8874aaa9fc33f3bd115d8.tar.gz
gsoc2013-empathy-2beb2a7609f6534697a8874aaa9fc33f3bd115d8.tar.bz2
gsoc2013-empathy-2beb2a7609f6534697a8874aaa9fc33f3bd115d8.tar.lz
gsoc2013-empathy-2beb2a7609f6534697a8874aaa9fc33f3bd115d8.tar.xz
gsoc2013-empathy-2beb2a7609f6534697a8874aaa9fc33f3bd115d8.tar.zst
gsoc2013-empathy-2beb2a7609f6534697a8874aaa9fc33f3bd115d8.zip
log-window: port to new tp-glib account API
Signed-off-by: Jonny Lamb <jonnylamb@gnome.org>
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-log-window.c76
-rw-r--r--libempathy-gtk/empathy-log-window.h4
2 files changed, 50 insertions, 30 deletions
diff --git a/libempathy-gtk/empathy-log-window.c b/libempathy-gtk/empathy-log-window.c
index 11ddca74b..c78f3a36d 100644
--- a/libempathy-gtk/empathy-log-window.c
+++ b/libempathy-gtk/empathy-log-window.c
@@ -30,8 +30,9 @@
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
+#include <telepathy-glib/account-manager.h>
+
#include <libempathy/empathy-log-manager.h>
-#include <libempathy/empathy-account-manager.h>
#include <libempathy/empathy-chatroom-manager.h>
#include <libempathy/empathy-chatroom.h>
#include <libempathy/empathy-message.h>
@@ -95,11 +96,11 @@ static void log_window_chats_setup (EmpathyLogWindow *wi
static void log_window_chats_accounts_changed_cb (GtkWidget *combobox,
EmpathyLogWindow *window);
static void log_window_chats_set_selected (EmpathyLogWindow *window,
- EmpathyAccount *account,
+ TpAccount *account,
const gchar *chat_id,
gboolean is_chatroom);
static gboolean log_window_chats_get_selected (EmpathyLogWindow *window,
- EmpathyAccount **account,
+ TpAccount **account,
gchar **chat_id,
gboolean *is_chatroom);
static void log_window_chats_get_messages (EmpathyLogWindow *window,
@@ -134,16 +135,42 @@ enum {
COL_CHAT_COUNT
};
+static void
+account_manager_prepared_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
+ EmpathyLogWindow *window = user_data;
+ guint account_num;
+ GList *accounts;
+
+ if (!tp_account_manager_prepare_finish (account_manager, result, NULL)) {
+ return;
+ }
+
+ accounts = tp_account_manager_get_valid_accounts (account_manager);
+ account_num = g_list_length (accounts);
+ g_list_free (accounts);
+
+ if (account_num > 1) {
+ gtk_widget_show (window->vbox_chats);
+ gtk_widget_show (window->account_chooser_chats);
+ } else {
+ gtk_widget_hide (window->vbox_chats);
+ gtk_widget_hide (window->account_chooser_chats);
+ }
+}
+
GtkWidget *
-empathy_log_window_show (EmpathyAccount *account,
+empathy_log_window_show (TpAccount *account,
const gchar *chat_id,
gboolean is_chatroom,
GtkWindow *parent)
{
static EmpathyLogWindow *window = NULL;
EmpathyAccountChooser *account_chooser;
- EmpathyAccountManager *account_manager;
- gint account_num;
+ TpAccountManager *account_manager;
GtkBuilder *gui;
gchar *filename;
@@ -229,18 +256,11 @@ empathy_log_window_show (EmpathyAccount *account,
window);
/* Populate */
- account_manager = empathy_account_manager_dup_singleton ();
- account_num = empathy_account_manager_get_count (account_manager);
+ account_manager = tp_account_manager_dup ();
+ tp_account_manager_prepare_async (account_manager, NULL,
+ account_manager_prepared_cb, window);
g_object_unref (account_manager);
- if (account_num > 1) {
- gtk_widget_show (window->vbox_chats);
- gtk_widget_show (window->account_chooser_chats);
- } else {
- gtk_widget_hide (window->vbox_chats);
- gtk_widget_hide (window->account_chooser_chats);
- }
-
/* Search List */
log_window_find_setup (window);
@@ -302,7 +322,7 @@ log_window_find_changed_cb (GtkTreeSelection *selection,
GtkTreeView *view;
GtkTreeModel *model;
GtkTreeIter iter;
- EmpathyAccount *account;
+ TpAccount *account;
gchar *chat_id;
gboolean is_chatroom;
gchar *date;
@@ -418,8 +438,8 @@ log_window_find_populate (EmpathyLogWindow *window,
}
date_readable = empathy_log_manager_get_date_readable (hit->date);
- account_name = empathy_account_get_display_name (hit->account);
- account_icon = empathy_account_get_icon_name (hit->account);
+ account_name = tp_account_get_display_name (hit->account);
+ account_icon = tp_account_get_icon_name (hit->account);
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
@@ -465,7 +485,7 @@ log_window_find_setup (EmpathyLogWindow *window)
store = gtk_list_store_new (COL_FIND_COUNT,
G_TYPE_STRING, /* account icon name */
G_TYPE_STRING, /* account name */
- EMPATHY_TYPE_ACCOUNT, /* account */
+ TP_TYPE_ACCOUNT, /* account */
G_TYPE_STRING, /* chat name */
G_TYPE_STRING, /* chat id */
G_TYPE_BOOLEAN, /* is chatroom */
@@ -609,7 +629,7 @@ static void
log_window_chats_populate (EmpathyLogWindow *window)
{
EmpathyAccountChooser *account_chooser;
- EmpathyAccount *account;
+ TpAccount *account;
GList *chats, *l;
GtkTreeView *view;
@@ -687,7 +707,7 @@ log_window_chats_setup (EmpathyLogWindow *window)
store = gtk_list_store_new (COL_CHAT_COUNT,
G_TYPE_STRING, /* icon */
G_TYPE_STRING, /* name */
- EMPATHY_TYPE_ACCOUNT, /* account */
+ TP_TYPE_ACCOUNT, /* account */
G_TYPE_STRING, /* id */
G_TYPE_BOOLEAN); /* is chatroom */
@@ -740,7 +760,7 @@ log_window_chats_accounts_changed_cb (GtkWidget *combobox,
static void
log_window_chats_set_selected (EmpathyLogWindow *window,
- EmpathyAccount *account,
+ TpAccount *account,
const gchar *chat_id,
gboolean is_chatroom)
{
@@ -764,7 +784,7 @@ log_window_chats_set_selected (EmpathyLogWindow *window,
}
for (ok = TRUE; ok; ok = gtk_tree_model_iter_next (model, &iter)) {
- EmpathyAccount *this_account;
+ TpAccount *this_account;
gchar *this_chat_id;
gboolean this_is_chatroom;
@@ -793,7 +813,7 @@ log_window_chats_set_selected (EmpathyLogWindow *window,
static gboolean
log_window_chats_get_selected (EmpathyLogWindow *window,
- EmpathyAccount **account,
+ TpAccount **account,
gchar **chat_id,
gboolean *is_chatroom)
{
@@ -802,7 +822,7 @@ log_window_chats_get_selected (EmpathyLogWindow *window,
GtkTreeSelection *selection;
GtkTreeIter iter;
gchar *id = NULL;
- EmpathyAccount *acc = NULL;
+ TpAccount *acc = NULL;
gboolean room = FALSE;
view = GTK_TREE_VIEW (window->treeview_chats);
@@ -840,7 +860,7 @@ static void
log_window_chats_get_messages (EmpathyLogWindow *window,
const gchar *date_to_show)
{
- EmpathyAccount *account;
+ TpAccount *account;
gchar *chat_id;
gboolean is_chatroom;
EmpathyMessage *message;
@@ -1000,7 +1020,7 @@ static void
log_window_calendar_chats_month_changed_cb (GtkWidget *calendar,
EmpathyLogWindow *window)
{
- EmpathyAccount *account;
+ TpAccount *account;
gchar *chat_id;
gboolean is_chatroom;
guint year_selected;
diff --git a/libempathy-gtk/empathy-log-window.h b/libempathy-gtk/empathy-log-window.h
index 298d96099..def0d846b 100644
--- a/libempathy-gtk/empathy-log-window.h
+++ b/libempathy-gtk/empathy-log-window.h
@@ -25,11 +25,11 @@
#ifndef __EMPATHY_LOG_WINDOW_H__
#define __EMPATHY_LOG_WINDOW_H__
-#include <libempathy/empathy-account.h>
+#include <telepathy-glib/account.h>
G_BEGIN_DECLS
-GtkWidget * empathy_log_window_show (EmpathyAccount *account,
+GtkWidget * empathy_log_window_show (TpAccount *account,
const gchar *chat_id,
gboolean chatroom,
GtkWindow *parent);