Commit 766bb22f authored by Mohammed Sadiq's avatar Mohammed Sadiq
Browse files

manager: Move buddy-icon-changed from conversation

parent c61eb171
......@@ -20,29 +20,6 @@
#include "chatty-chat-view.h"
// *** callbacks
static void
cb_update_buddy_icon (PurpleBuddy *buddy)
{
PurpleConversation *conv;
conv = purple_find_conversation_with_account (PURPLE_CONV_TYPE_IM,
buddy->name,
buddy->account);
if (conv) {
ChattyChat *chat;
chat = chatty_manager_find_purple_conv (chatty_manager_get_default (), conv);
if (chat)
g_signal_emit_by_name (G_OBJECT (chat), "avatar-changed");
}
}
// *** end callbacks
/**
* chatty_conv_container_get_active_chatty_conv:
* @notebook: a GtkNotebook
......@@ -206,42 +183,3 @@ chatty_conv_join_chat (PurpleChat *chat)
g_free (chat_name);
}
void *
chatty_conversations_get_handle (void)
{
static int handle;
return &handle;
}
/**
* chatty_init_conversations:
*
* Sets purple conversations preferenz values
* and defines libpurple signal callbacks
*
*/
void
chatty_conversations_init (void)
{
void *handle = chatty_conversations_get_handle ();
void *blist_handle = purple_blist_get_handle ();
purple_signal_connect (blist_handle, "buddy-icon-changed",
handle, PURPLE_CALLBACK (cb_update_buddy_icon), NULL);
chatty_chat_view_purple_init ();
}
void
chatty_conversations_uninit (void)
{
chatty_chat_view_purple_uninit ();
purple_prefs_disconnect_by_handle (chatty_conversations_get_handle());
purple_signals_disconnect_by_handle (chatty_conversations_get_handle());
purple_signals_unregister_by_instance (chatty_conversations_get_handle());
}
......@@ -36,9 +36,6 @@ typedef enum
void chatty_conv_im_with_buddy (PurpleAccount *account, const char *username);
void chatty_conv_show_conversation (PurpleConversation *conv);
void chatty_conv_join_chat (PurpleChat *chat);
void *chatty_conversations_get_handle (void);
void chatty_conversations_init (void);
void chatty_conversations_uninit (void);
ChattyConversation * chatty_conv_container_get_active_chatty_conv (GtkNotebook *notebook);
void chatty_conv_add_history_since_component(GHashTable *components, const char *account, const char *room);
......
......@@ -328,7 +328,7 @@ PurpleEventLoopUiOps eventloop_ui_ops =
static void
chatty_purple_quit (void)
{
chatty_conversations_uninit ();
chatty_chat_view_purple_uninit ();
purple_conversations_set_ui_ops (NULL);
purple_connections_set_ui_ops (NULL);
......@@ -345,7 +345,7 @@ chatty_purple_quit (void)
static void
chatty_purple_ui_init (void)
{
chatty_conversations_init ();
chatty_chat_view_purple_init ();
chatty_manager_purple_init (chatty_manager_get_default ());
}
......@@ -1247,6 +1247,25 @@ manager_buddy_signed_on_off_cb (PurpleBuddy *buddy)
purple_account_get_protocol_id (purple_buddy_get_account(buddy)));
}
static void
manager_buddy_icon_chaged_cb (PurpleBuddy *buddy,
ChattyManager *self)
{
PurpleConversation *conv;
conv = purple_find_conversation_with_account (PURPLE_CONV_TYPE_IM,
buddy->name,
buddy->account);
if (conv) {
ChattyChat *chat;
chat = chatty_manager_find_purple_conv (self, conv);
if (chat)
g_signal_emit_by_name (G_OBJECT (chat), "avatar-changed");
}
}
static void
manager_account_added_cb (PurpleAccount *pp_account,
......@@ -2225,6 +2244,9 @@ chatty_manager_load_buddies (ChattyManager *self)
purple_signal_connect (purple_blist_get_handle (),
"buddy-signed-off", self,
PURPLE_CALLBACK (manager_buddy_signed_on_off_cb), self);
purple_signal_connect (purple_blist_get_handle (),
"buddy-icon-changed", self,
PURPLE_CALLBACK (manager_buddy_icon_chaged_cb), self);
buddies = purple_blist_get_buddies ();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment