/soc/2013/ankitkv/gobjectification: bdc5207ad4b7: pidgin: Don't ...
Ankit Vani
a at nevitus.org
Sun Nov 17 13:33:07 EST 2013
Changeset: bdc5207ad4b77e065caba37afabf30940d9d8639
Author: Ankit Vani <a at nevitus.org>
Date: 2013-11-17 23:05 +0530
Branch: soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/bdc5207ad4b7
Description:
pidgin: Don't assume a conversation is always an IM or a chat
diffstat:
pidgin/gtkblist.c | 2 +-
pidgin/gtkconv.c | 56 +++++++++++++++++++++++-------------------
pidgin/plugins/extplacement.c | 2 +-
3 files changed, 32 insertions(+), 28 deletions(-)
diffs (242 lines):
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -4867,7 +4867,7 @@ conversation_created_cb(PurpleConversati
purple_signal_connect(pidgin_conversations_get_handle(), "conversation-displayed",
ui, PURPLE_CALLBACK(displayed_msg_update_ui_cb), buddy);
}
- } else {
+ } else if (PURPLE_IS_CHAT_CONVERSATION(conv)) {
PurpleChat *chat = purple_blist_find_chat(account, purple_conversation_get_name(conv));
struct _pidgin_blist_node *ui;
if (!chat)
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -253,7 +253,7 @@ get_conversation_blist_node(PurpleConver
if (PURPLE_IS_IM_CONVERSATION(conv)) {
node = PURPLE_BLIST_NODE(purple_blist_find_buddy(account, purple_conversation_get_name(conv)));
node = node ? node->parent : NULL;
- } else {
+ } else if (PURPLE_IS_CHAT_CONVERSATION(conv)) {
node = PURPLE_BLIST_NODE(purple_blist_find_chat(account, purple_conversation_get_name(conv)));
}
@@ -291,7 +291,7 @@ close_conv_cb(GtkButton *button, PidginC
close_this_sucker(gtkconv);
else
hide_conv(gtkconv, TRUE);
- } else {
+ } else if (PURPLE_IS_CHAT_CONVERSATION(conv)) {
PurpleChat *chat = purple_blist_find_chat(account, name);
if (!chat ||
!purple_blist_node_get_bool(&chat->node, "gtk-persistent"))
@@ -701,7 +701,7 @@ add_remove_cb(GtkWidget *widget, PidginC
pidgin_dialogs_remove_buddy(b);
else if (account != NULL && purple_account_is_connected(account))
purple_blist_request_add_buddy(account, (char *)name, NULL, NULL);
- } else {
+ } else if (PURPLE_IS_CHAT_CONVERSATION(conv)) {
PurpleChat *c;
c = purple_blist_find_chat(account, name);
@@ -734,7 +734,7 @@ info_cb(GtkWidget *widget, PidginConvers
pidgin_retrieve_user_info(purple_conversation_get_connection(conv),
purple_conversation_get_name(conv));
gtk_widget_grab_focus(gtkconv->entry);
- } else {
+ } else if (PURPLE_IS_CHAT_CONVERSATION(conv)) {
/* Get info of the person currently selected in the GtkTreeView */
PidginChatPane *gtkchat;
GtkTreeIter iter;
@@ -1133,7 +1133,13 @@ menu_view_log_cb(GtkAction *action, gpoi
GSList *cur;
conv = pidgin_conv_window_get_active_conversation(win);
- type = PURPLE_IS_IM_CONVERSATION(conv) ? PURPLE_LOG_IM : PURPLE_LOG_CHAT;
+
+ if (PURPLE_IS_IM_CONVERSATION(conv))
+ type = PURPLE_LOG_IM;
+ else if (PURPLE_IS_CHAT_CONVERSATION(conv))
+ type = PURPLE_LOG_CHAT;
+ else
+ return;
gtkblist = pidgin_blist_get_default_gtk_blist();
@@ -1285,7 +1291,7 @@ menu_alias_cb(GtkAction *action, gpointe
b = purple_blist_find_buddy(account, name);
if (b != NULL)
pidgin_dialogs_alias_buddy(b);
- } else {
+ } else if (PURPLE_IS_CHAT_CONVERSATION(conv)) {
PurpleChat *c;
c = purple_blist_find_chat(account, name);
@@ -1438,7 +1444,7 @@ menu_logging_cb(GtkAction *action, gpoin
purple_blist_node_remove_setting(node, "enable-logging");
else
purple_blist_node_set_bool(node, "enable-logging", logging);
- } else {
+ } else if (PURPLE_IS_CHAT_CONVERSATION(conv)) {
if (logging == purple_prefs_get_bool("/purple/logging/log_chats"))
purple_blist_node_remove_setting(node, "enable-logging");
else
@@ -2645,7 +2651,7 @@ update_tab_icon(PurpleConversation *conv
gtk_widget_queue_draw(gtkconv->infopane);
if (pidgin_conv_window_is_active_conversation(conv) &&
- (PURPLE_IS_CHAT_CONVERSATION(conv) || gtkconv->u.im->anim == NULL))
+ (!PURPLE_IS_IM_CONVERSATION(conv) || gtkconv->u.im->anim == NULL))
{
l = pidgin_conv_get_tab_icons(conv);
@@ -5802,7 +5808,7 @@ buddy_update_cb(PurpleBlistNode *bnode,
PidginWindow *win = list->data;
PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win);
- if (PURPLE_IS_CHAT_CONVERSATION(conv))
+ if (!PURPLE_IS_IM_CONVERSATION(conv))
continue;
pidgin_conv_update_fields(conv, PIDGIN_CONV_MENU);
@@ -5867,13 +5873,12 @@ private_gtkconv_new(PurpleConversation *
PidginConversation *gtkconv;
const char *theme_name;
PurpleTheme *theme = NULL;
- gboolean is_chat = PURPLE_IS_CHAT_CONVERSATION(conv);
GtkWidget *pane = NULL;
GtkWidget *tab_cont;
PurpleBlistNode *convnode;
GtkTargetList *targets;
- if (!is_chat && (gtkconv = pidgin_conv_find_gtkconv(conv))) {
+ if (PURPLE_IS_IM_CONVERSATION(conv) && (gtkconv = pidgin_conv_find_gtkconv(conv))) {
purple_conversation_set_ui_data(conv, gtkconv);
if (!g_list_find(gtkconv->convs, conv))
gtkconv->convs = g_list_prepend(gtkconv->convs, conv);
@@ -5898,18 +5903,17 @@ private_gtkconv_new(PurpleConversation *
gtkconv->theme = PIDGIN_CONV_THEME(g_object_ref(theme));
gtkconv->last_flags = 0;
-
- if (!is_chat) {
+ if (PURPLE_IS_IM_CONVERSATION(conv)) {
gtkconv->u.im = g_malloc0(sizeof(PidginImPane));
- } else {
+ } else if (PURPLE_IS_CHAT_CONVERSATION(conv)) {
gtkconv->u.chat = g_malloc0(sizeof(PidginChatPane));
}
pane = setup_common_pane(gtkconv);
if (pane == NULL) {
- if (is_chat)
+ if (PURPLE_IS_CHAT_CONVERSATION(conv))
g_free(gtkconv->u.chat);
- else
+ else if (PURPLE_IS_IM_CONVERSATION(conv))
g_free(gtkconv->u.im);
g_free(gtkconv);
@@ -6101,7 +6105,7 @@ pidgin_conv_destroy(PurpleConversation *
g_source_remove(gtkconv->u.im->typing_timer);
g_free(gtkconv->u.im);
- } else {
+ } else if (PURPLE_IS_CHAT_CONVERSATION(conv)) {
purple_signals_disconnect_by_handle(gtkconv->u.chat);
g_free(gtkconv->u.chat);
}
@@ -7314,7 +7318,7 @@ gray_stuff_out(PidginConversation *gtkco
gtk_action_set_visible(win->menu->insert_link, TRUE);
gtk_action_set_visible(win->menu->insert_image, TRUE);
- } else {
+ } else if (PURPLE_IS_CHAT_CONVERSATION(conv)) {
/* Show stuff that applies to Chats, hide stuff that applies to IMs */
/* Deal with menu items */
@@ -7347,7 +7351,7 @@ gray_stuff_out(PidginConversation *gtkco
* and what features that account supports.
*/
if ((gc != NULL) &&
- (PURPLE_IS_IM_CONVERSATION(conv) ||
+ (!PURPLE_IS_CHAT_CONVERSATION(conv) ||
!purple_chat_conversation_has_left(PURPLE_CHAT_CONVERSATION(conv)) ))
{
PurpleConnectionFlags features = purple_conversation_get_features(conv);
@@ -7407,7 +7411,7 @@ gray_stuff_out(PidginConversation *gtkco
(account != NULL) &&
(purple_blist_find_buddy(account, purple_conversation_get_name(conv)) != NULL));
}
- else
+ else if (PURPLE_IS_CHAT_CONVERSATION(conv))
{
gtk_action_set_sensitive(win->menu->add, (prpl_info->join_chat != NULL));
gtk_action_set_sensitive(win->menu->remove, (prpl_info->join_chat != NULL));
@@ -8608,7 +8612,7 @@ gboolean pidgin_conv_attach_to_conversat
list = g_list_sort(list, message_compare);
gtkconv->attach_current = list;
list = g_list_last(list);
- } else {
+ } else if (PURPLE_IS_CHAT_CONVERSATION(conv)) {
gtkconv->attach_current = g_list_last(list);
}
@@ -9647,7 +9651,7 @@ before_switch_conv_cb(GtkNotebook *noteb
g_return_if_fail(conv != NULL);
- if (PURPLE_IS_CHAT_CONVERSATION(conv))
+ if (!PURPLE_IS_IM_CONVERSATION(conv))
return;
gtkconv = PIDGIN_CONVERSATION(conv);
@@ -9872,7 +9876,7 @@ alias_cb(GtkEntry *entry, gpointer user_
purple_buddy_set_local_alias(buddy, gtk_entry_get_text(entry));
}
serv_alias_buddy(buddy);
- } else {
+ } else if (PURPLE_IS_CHAT_CONVERSATION(conv)) {
gtk_entry_set_text(GTK_ENTRY(gtkconv->u.chat->topic_text), gtk_entry_get_text(entry));
topic_callback(NULL, gtkconv);
}
@@ -9903,7 +9907,7 @@ infopane_entry_activate(PidginConversati
return FALSE;
text = purple_buddy_get_contact_alias(buddy);
- } else {
+ } else if (PURPLE_IS_CHAT_CONVERSATION(conv)) {
PurpleConnection *gc;
PurplePluginProtocolInfo *prpl_info = NULL;
@@ -10843,7 +10847,7 @@ conv_placement_last_created_win_type_con
purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/y", y);
purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/width", event->width);
purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/height", event->height);
- } else {
+ } else if (PURPLE_IS_CHAT_CONVERSATION(conv->active_conv)) {
purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/chat/x", x);
purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/chat/y", y);
purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/chat/width", event->width);
@@ -10920,7 +10924,7 @@ conv_get_group(PidginConversation *conv)
if (buddy != NULL)
group = purple_buddy_get_group(buddy);
- } else {
+ } else if (PURPLE_IS_CHAT_CONVERSATION(conv->active_conv)) {
PurpleChat *chat;
chat = purple_blist_find_chat(purple_conversation_get_account(conv->active_conv),
diff --git a/pidgin/plugins/extplacement.c b/pidgin/plugins/extplacement.c
--- a/pidgin/plugins/extplacement.c
+++ b/pidgin/plugins/extplacement.c
@@ -58,7 +58,7 @@ conv_placement_by_number(PidginConversat
win = l->data;
if (purple_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate") &&
- PURPLE_IS_IM_CONVERSATION(pidgin_conv_window_get_active_conversation(win)) != PURPLE_IS_IM_CONVERSATION(conv->active_conv))
+ G_TYPE_FROM_INSTANCE(pidgin_conv_window_get_active_conversation(win)) != G_TYPE_FROM_INSTANCE(conv->active_conv))
continue;
count = pidgin_conv_window_get_gtkconv_count(win);
More information about the Commits
mailing list