annotate finch/gntconv.c @ 28074:29e07dedfacc

merge of '4d4cd3cf315192de81786fd9f785ac12a08ad369' and '91c2c35882594486a0d021d1f070d2a5e417d60c'
author Paul Aurich <paul@darkrain42.org>
date Thu, 30 Jul 2009 05:24:52 +0000
parents f7c5bb2f6623
children 574fd92ff3e5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * @file gntconv.c GNT Conversation API
16194
0f0832c13fcb Rename the Doxygen group from gntui to finch and define the finch group
Richard Laager <rlaager@wiktel.com>
parents: 16128
diff changeset
3 * @ingroup finch
20251
6b8bc3309ab7 applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@wiktel.com>
parents: 19980
diff changeset
4 */
6b8bc3309ab7 applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@wiktel.com>
parents: 19980
diff changeset
5
6b8bc3309ab7 applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@wiktel.com>
parents: 19980
diff changeset
6 /* finch
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 *
15871
66dff3dfdea6 Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
8 * Finch is the legal property of its developers, whose names are too numerous
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * to list here. Please refer to the COPYRIGHT file distributed with this
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * source distribution.
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * This program is free software; you can redistribute it and/or modify
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * it under the terms of the GNU General Public License as published by
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * (at your option) any later version.
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * This program is distributed in the hope that it will be useful,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * GNU General Public License for more details.
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 * along with this program; if not, write to the Free Software
19680
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19631
diff changeset
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include <string.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27
18210
b8572b937c09 #include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents: 18100
diff changeset
28 #include "finch.h"
27663
f7c5bb2f6623 Don't include an internal header in the public finch headers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27598
diff changeset
29 #include <internal.h>
18210
b8572b937c09 #include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents: 18100
diff changeset
30
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include <cmds.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include <idle.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include <prefs.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #include <util.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 #include "gntaccount.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 #include "gntblist.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 #include "gntconv.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 #include "gntdebug.h"
22248
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
40 #include "gntlog.h"
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 #include "gntplugin.h"
23233
cb241bc04f9b Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents: 22680
diff changeset
42 #include "gntpounce.h"
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 #include "gntprefs.h"
23233
cb241bc04f9b Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents: 22680
diff changeset
44 #include "gntrequest.h"
19447
1a9b30a95fa6 Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19446
diff changeset
45 #include "gntsound.h"
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 #include "gntstatus.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 #include "gnt.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 #include "gntbox.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 #include "gntentry.h"
16904
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
51 #include "gntlabel.h"
16903
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
52 #include "gntmenu.h"
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
53 #include "gntmenuitem.h"
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
54 #include "gntmenuitemcheck.h"
21738
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
55 #include "gntstyle.h"
16904
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
56 #include "gnttextview.h"
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
57 #include "gnttree.h"
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
58 #include "gntutils.h"
16903
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
59 #include "gntwindow.h"
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60
16427
4999bbc52881 Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents: 16194
diff changeset
61 #define PREF_ROOT "/finch/conversations"
16904
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
62 #define PREF_CHAT PREF_ROOT "/chats"
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
63 #define PREF_USERLIST PREF_CHAT "/userlist"
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 #include "config.h"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66
17032
d6e855aedc30 Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16989
diff changeset
67 static void finch_write_common(PurpleConversation *conv, const char *who,
d6e855aedc30 Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16989
diff changeset
68 const char *message, PurpleMessageFlags flags, time_t mtime);
19321
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
69 static void generate_send_to_menu(FinchConv *ggc);
17032
d6e855aedc30 Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16989
diff changeset
70
21738
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
71 static int color_message_receive;
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
72 static int color_message_send;
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
73 static int color_message_highlight;
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
74 static int color_message_action;
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
75 static int color_timestamp;
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
76
22215
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
77 static PurpleBuddy *
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
78 find_buddy_for_conversation(PurpleConversation *conv)
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
79 {
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
80 return purple_find_buddy(purple_conversation_get_account(conv),
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
81 purple_conversation_get_name(conv));
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
82 }
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
83
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
84 static PurpleChat *
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
85 find_chat_for_conversation(PurpleConversation *conv)
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
86 {
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
87 return purple_blist_find_chat(purple_conversation_get_account(conv),
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
88 purple_conversation_get_name(conv));
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
89 }
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
90
19980
959b3aaba0b6 Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
91 static PurpleBlistNode *
959b3aaba0b6 Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
92 get_conversation_blist_node(PurpleConversation *conv)
959b3aaba0b6 Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
93 {
959b3aaba0b6 Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
94 PurpleBlistNode *node = NULL;
959b3aaba0b6 Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
95
959b3aaba0b6 Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
96 switch (purple_conversation_get_type(conv)) {
959b3aaba0b6 Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
97 case PURPLE_CONV_TYPE_IM:
22215
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
98 node = (PurpleBlistNode*)find_buddy_for_conversation(conv);
22212
6bb29f94862c Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
99 node = node ? purple_blist_node_get_parent(node) : NULL;
19980
959b3aaba0b6 Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
100 break;
959b3aaba0b6 Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
101 case PURPLE_CONV_TYPE_CHAT:
22215
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
102 node = (PurpleBlistNode*)find_chat_for_conversation(conv);
19980
959b3aaba0b6 Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
103 break;
959b3aaba0b6 Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
104 default:
959b3aaba0b6 Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
105 break;
959b3aaba0b6 Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
106 }
959b3aaba0b6 Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
107 return node;
959b3aaba0b6 Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
108 }
959b3aaba0b6 Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
109
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 send_typing_notification(GntWidget *w, FinchConv *ggconv)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 const char *text = gnt_entry_get_text(GNT_ENTRY(ggconv->entry));
17529
289ac53f753f Do not send typing notification if you are typing a /-command.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17275
diff changeset
114 gboolean empty = (!text || !*text || (*text == '/'));
16427
4999bbc52881 Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents: 16194
diff changeset
115 if (purple_prefs_get_bool("/finch/conversations/notify_typing")) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
116 PurpleConversation *conv = ggconv->active_conv;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
117 PurpleConvIm *im = PURPLE_CONV_IM(conv);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 if (!empty) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
119 gboolean send = (purple_conv_im_get_send_typed_timeout(im) == 0);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
121 purple_conv_im_stop_send_typed_timeout(im);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
122 purple_conv_im_start_send_typed_timeout(im);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
123 if (send || (purple_conv_im_get_type_again(im) != 0 &&
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
124 time(NULL) > purple_conv_im_get_type_again(im))) {
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 unsigned int timeout;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
126 timeout = serv_send_typing(purple_conversation_get_gc(conv),
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
127 purple_conversation_get_name(conv),
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
128 PURPLE_TYPING);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
129 purple_conv_im_set_type_again(im, timeout);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131 } else {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
132 purple_conv_im_stop_send_typed_timeout(im);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
134 serv_send_typing(purple_conversation_get_gc(conv),
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
135 purple_conversation_get_name(conv),
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
136 PURPLE_NOT_TYPING);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140
21281
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
141 static void
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
142 entry_key_pressed(GntWidget *w, FinchConv *ggconv)
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 {
21281
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
144 const char *text = gnt_entry_get_text(GNT_ENTRY(ggconv->entry));
23363
54aaea893a89 Send '//message' as '/message', instead of looking for a 'message' command.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23311
diff changeset
145 if (*text == '/' && *(text + 1) != '/')
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 {
21281
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
147 PurpleConversation *conv = ggconv->active_conv;
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
148 PurpleCmdStatus status;
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
149 const char *cmdline = text + 1;
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
150 char *error = NULL, *escape;
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
151
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
152 escape = g_markup_escape_text(cmdline, -1);
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
153 status = purple_cmd_do_command(conv, cmdline, escape, &error);
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
154 g_free(escape);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155
21281
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
156 switch (status)
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
157 {
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
158 case PURPLE_CMD_STATUS_OK:
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
159 break;
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
160 case PURPLE_CMD_STATUS_NOT_FOUND:
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
161 purple_conversation_write(conv, "", _("No such command."),
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
162 PURPLE_MESSAGE_NO_LOG, time(NULL));
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
163 break;
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
164 case PURPLE_CMD_STATUS_WRONG_ARGS:
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
165 purple_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments "
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
166 "to that command."),
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
167 PURPLE_MESSAGE_NO_LOG, time(NULL));
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
168 break;
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
169 case PURPLE_CMD_STATUS_FAILED:
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
170 purple_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."),
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
171 PURPLE_MESSAGE_NO_LOG, time(NULL));
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
172 break;
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
173 case PURPLE_CMD_STATUS_WRONG_TYPE:
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
174 if(purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM)
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
175 purple_conversation_write(conv, "", _("That command only works in chats, not IMs."),
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
176 PURPLE_MESSAGE_NO_LOG, time(NULL));
21281
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
177 else
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
178 purple_conversation_write(conv, "", _("That command only works in IMs, not chats."),
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
179 PURPLE_MESSAGE_NO_LOG, time(NULL));
21281
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
180 break;
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
181 case PURPLE_CMD_STATUS_WRONG_PRPL:
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
182 purple_conversation_write(conv, "", _("That command doesn't work on this protocol."),
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
183 PURPLE_MESSAGE_NO_LOG, time(NULL));
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
184 break;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 }
21281
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
186 g_free(error);
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
187 }
22215
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
188 else if (!purple_account_is_connected(purple_conversation_get_account(ggconv->active_conv)))
21281
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
189 {
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
190 purple_conversation_write(ggconv->active_conv, "", _("Message was not sent, because you are not signed on."),
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
191 PURPLE_MESSAGE_ERROR | PURPLE_MESSAGE_NO_LOG, time(NULL));
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
192 }
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
193 else
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
194 {
27516
4fc04d98e1e8 Use purple_markup_escape_text instead of the glib version.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26623
diff changeset
195 char *escape = purple_markup_escape_text((*text == '/' ? text + 1 : text), -1);
21281
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
196 switch (purple_conversation_get_type(ggconv->active_conv))
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 {
21281
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
198 case PURPLE_CONV_TYPE_IM:
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
199 purple_conv_im_send_with_flags(PURPLE_CONV_IM(ggconv->active_conv), escape, PURPLE_MESSAGE_SEND);
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
200 break;
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
201 case PURPLE_CONV_TYPE_CHAT:
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
202 purple_conv_chat_send(PURPLE_CONV_CHAT(ggconv->active_conv), escape);
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
203 break;
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
204 default:
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
205 g_free(escape);
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
206 g_return_if_reached();
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 }
21281
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
208 g_free(escape);
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
209 purple_idle_touch();
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 }
21281
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
211 gnt_entry_add_to_history(GNT_ENTRY(ggconv->entry), text);
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
212 gnt_entry_clear(GNT_ENTRY(ggconv->entry));
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 closing_window(GntWidget *window, FinchConv *ggconv)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 GList *list = ggconv->list;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 ggconv->window = NULL;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 while (list) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
221 PurpleConversation *conv = list->data;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 list = list->next;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
223 purple_conversation_destroy(conv);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 size_changed_cb(GntWidget *widget, int width, int height)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 int w, h;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 gnt_widget_get_size(widget, &w, &h);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
232 purple_prefs_set_int(PREF_ROOT "/size/width", w);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
233 purple_prefs_set_int(PREF_ROOT "/size/height", h);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 save_position_cb(GntWidget *w, int x, int y)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
239 purple_prefs_set_int(PREF_ROOT "/position/x", x);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
240 purple_prefs_set_int(PREF_ROOT "/position/y", y);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
243 static PurpleConversation *
19321
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
244 find_conv_with_contact(PurpleAccount *account, const char *name)
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
246 PurpleBlistNode *node;
19321
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
247 PurpleBuddy *buddy = purple_find_buddy(account, name);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
248 PurpleConversation *ret = NULL;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250 if (!buddy)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 return NULL;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252
22212
6bb29f94862c Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
253 for (node = purple_blist_node_get_first_child(purple_blist_node_get_parent((PurpleBlistNode*)buddy));
6bb29f94862c Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
254 node; node = purple_blist_node_get_sibling_next(node)) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
255 if (node == (PurpleBlistNode*)buddy)
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 continue;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
257 if ((ret = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM,
22219
797230b3e48e Add accessor and update finch to not touch the internals of PurpleBuddy and PurpleChat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22217
diff changeset
258 purple_buddy_get_name((PurpleBuddy*)node), purple_buddy_get_account((PurpleBuddy*)node))) != NULL)
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259 break;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261 return ret;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 static char *
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
265 get_conversation_title(PurpleConversation *conv, PurpleAccount *account)
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
267 return g_strdup_printf(_("%s (%s -- %s)"), purple_conversation_get_title(conv),
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
268 purple_account_get_username(account), purple_account_get_protocol_name(account));
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 static void
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
272 update_buddy_typing(PurpleAccount *account, const char *who, gpointer null)
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
274 PurpleConversation *conv;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275 FinchConv *ggc;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
276 PurpleConvIm *im = NULL;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 char *title, *str;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
279 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, who, account);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281 if (!conv)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 return;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
284 im = PURPLE_CONV_IM(conv);
22217
ad357ca94de9 We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22215
diff changeset
285 ggc = FINCH_GET_DATA(conv);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
287 if (purple_conv_im_get_typing_state(im) == PURPLE_TYPING) {
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288 int scroll;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 str = get_conversation_title(conv, account);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290 title = g_strdup_printf(_("%s [%s]"), str,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291 gnt_ascii_only() ? "T" : "\342\243\277");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292 g_free(str);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 scroll = gnt_text_view_get_lines_below(GNT_TEXT_VIEW(ggc->tv));
22426
ca6bc025aabb Patch from Kyle Turman to show the alias when available in the typing notification. Closes #4957.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22418
diff changeset
295 str = g_strdup_printf(_("\n%s is typing..."), purple_conversation_get_title(conv));
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 /* Updating is a little buggy. So just remove and add a new one */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297 gnt_text_view_tag_change(GNT_TEXT_VIEW(ggc->tv), "typing", NULL, TRUE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298 gnt_text_view_append_text_with_tag(GNT_TEXT_VIEW(ggc->tv),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299 str, GNT_TEXT_FLAG_DIM, "typing");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300 g_free(str);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
301 if (scroll <= 1)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
302 gnt_text_view_scroll(GNT_TEXT_VIEW(ggc->tv), 0);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303 } else {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304 title = get_conversation_title(conv, account);
18637
3597903cf8ff Just show an empty line, instead of bouncing the text down when the user
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18427
diff changeset
305 gnt_text_view_tag_change(GNT_TEXT_VIEW(ggc->tv), "typing", " ", TRUE);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307 gnt_screen_rename_widget(ggc->window, title);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308 g_free(title);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
309 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
310
17032
d6e855aedc30 Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16989
diff changeset
311 static void
d6e855aedc30 Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16989
diff changeset
312 chat_left_cb(PurpleConversation *conv, gpointer null)
d6e855aedc30 Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16989
diff changeset
313 {
d6e855aedc30 Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16989
diff changeset
314 finch_write_common(conv, NULL, _("You have left this chat."),
d6e855aedc30 Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16989
diff changeset
315 PURPLE_MESSAGE_SYSTEM, time(NULL));
d6e855aedc30 Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16989
diff changeset
316 }
d6e855aedc30 Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16989
diff changeset
317
19321
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
318 static void
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
319 buddy_signed_on_off(PurpleBuddy *buddy, gpointer null)
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
320 {
22219
797230b3e48e Add accessor and update finch to not touch the internals of PurpleBuddy and PurpleChat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22217
diff changeset
321 PurpleConversation *conv = find_conv_with_contact(purple_buddy_get_account(buddy), purple_buddy_get_name(buddy));
19321
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
322 if (conv == NULL)
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
323 return;
22217
ad357ca94de9 We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22215
diff changeset
324 generate_send_to_menu(FINCH_GET_DATA(conv));
19321
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
325 }
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
326
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
327 static void
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
328 account_signed_on_off(PurpleConnection *gc, gpointer null)
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
329 {
20053
fb2880587f34 If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19980
diff changeset
330 GList *list = purple_get_ims();
fb2880587f34 If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19980
diff changeset
331 while (list) {
fb2880587f34 If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19980
diff changeset
332 PurpleConversation *conv = list->data;
22215
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
333 PurpleConversation *cc = find_conv_with_contact(
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
334 purple_conversation_get_account(conv), purple_conversation_get_name(conv));
19321
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
335 if (cc)
22217
ad357ca94de9 We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22215
diff changeset
336 generate_send_to_menu(FINCH_GET_DATA(cc));
20053
fb2880587f34 If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19980
diff changeset
337 list = list->next;
fb2880587f34 If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19980
diff changeset
338 }
fb2880587f34 If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19980
diff changeset
339
fb2880587f34 If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19980
diff changeset
340 if (PURPLE_CONNECTION_IS_CONNECTED(gc)) {
fb2880587f34 If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19980
diff changeset
341 /* We just signed on. Let's see if there's any chat that we have open,
fb2880587f34 If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19980
diff changeset
342 * and hadn't left before the disconnect. */
fb2880587f34 If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19980
diff changeset
343 list = purple_get_chats();
fb2880587f34 If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19980
diff changeset
344 while (list) {
fb2880587f34 If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19980
diff changeset
345 PurpleConversation *conv = list->data;
fb2880587f34 If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19980
diff changeset
346 PurpleChat *chat;
20552
b7460582a135 Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20074
diff changeset
347 GHashTable *comps = NULL;
20053
fb2880587f34 If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19980
diff changeset
348
fb2880587f34 If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19980
diff changeset
349 list = list->next;
22215
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
350 if (purple_conversation_get_account(conv) != purple_connection_get_account(gc) ||
20053
fb2880587f34 If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19980
diff changeset
351 !purple_conversation_get_data(conv, "want-to-rejoin"))
fb2880587f34 If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19980
diff changeset
352 continue;
fb2880587f34 If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19980
diff changeset
353
22215
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
354 chat = find_chat_for_conversation(conv);
20053
fb2880587f34 If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19980
diff changeset
355 if (chat == NULL) {
22214
2b426862ffbf Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22213
diff changeset
356 PurplePluginProtocolInfo *info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc));
2b426862ffbf Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22213
diff changeset
357 if (info->chat_info_defaults != NULL)
22215
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
358 comps = info->chat_info_defaults(gc, purple_conversation_get_name(conv));
20552
b7460582a135 Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20074
diff changeset
359 } else {
22219
797230b3e48e Add accessor and update finch to not touch the internals of PurpleBuddy and PurpleChat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22217
diff changeset
360 comps = purple_chat_get_components(chat);
20053
fb2880587f34 If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19980
diff changeset
361 }
20552
b7460582a135 Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20074
diff changeset
362 serv_join_chat(gc, comps);
b7460582a135 Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20074
diff changeset
363 if (chat == NULL && comps != NULL)
b7460582a135 Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20074
diff changeset
364 g_hash_table_destroy(comps);
20053
fb2880587f34 If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19980
diff changeset
365 }
19321
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
366 }
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
367 }
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
368
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
369 static gpointer
22007
c38d72677c8a Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents: 21743
diff changeset
370 finch_conv_get_handle(void)
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372 static int handle;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373 return &handle;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
376 static void
16903
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
377 clear_scrollback_cb(GntMenuItem *item, gpointer ggconv)
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
378 {
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
379 FinchConv *ggc = ggconv;
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
380 gnt_text_view_clear(GNT_TEXT_VIEW(ggc->tv));
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
381 }
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
382
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
383 static void
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
384 send_file_cb(GntMenuItem *item, gpointer ggconv)
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
385 {
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
386 FinchConv *ggc = ggconv;
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
387 serv_send_file(purple_conversation_get_gc(ggc->active_conv),
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
388 purple_conversation_get_name(ggc->active_conv), NULL);
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
389 }
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
390
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
391 static void
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
392 add_pounce_cb(GntMenuItem *item, gpointer ggconv)
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
393 {
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
394 FinchConv *ggc = ggconv;
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
395 finch_pounce_editor_show(
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
396 purple_conversation_get_account(ggc->active_conv),
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
397 purple_conversation_get_name(ggc->active_conv), NULL);
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
398 }
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
399
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
400 static void
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
401 get_info_cb(GntMenuItem *item, gpointer ggconv)
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
402 {
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
403 FinchConv *ggc = ggconv;
17275
319bcb73eb4e Use utility functions to get user info. Closes #964.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17104
diff changeset
404 finch_retrieve_user_info(purple_conversation_get_gc(ggc->active_conv),
16903
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
405 purple_conversation_get_name(ggc->active_conv));
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
406 }
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
407
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
408 static void
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
409 toggle_timestamps_cb(GntMenuItem *item, gpointer ggconv)
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
410 {
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
411 purple_prefs_set_bool(PREF_ROOT "/timestamps",
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
412 !purple_prefs_get_bool(PREF_ROOT "/timestamps"));
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
413 }
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
414
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
415 static void
19445
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
416 toggle_logging_cb(GntMenuItem *item, gpointer ggconv)
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
417 {
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
418 FinchConv *fc = ggconv;
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
419 PurpleConversation *conv = fc->active_conv;
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
420 gboolean logging = gnt_menuitem_check_get_checked(GNT_MENU_ITEM_CHECK(item));
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
421 GList *iter;
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
422
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
423 if (logging == purple_conversation_is_logging(conv))
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
424 return;
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
425
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
426 /* Xerox */
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
427 if (logging) {
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
428 /* Enable logging first so the message below can be logged. */
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
429 purple_conversation_set_logging(conv, TRUE);
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
430
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
431 purple_conversation_write(conv, NULL,
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
432 _("Logging started. Future messages in this conversation will be logged."),
22215
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
433 PURPLE_MESSAGE_SYSTEM, time(NULL));
19445
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
434 } else {
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
435 purple_conversation_write(conv, NULL,
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
436 _("Logging stopped. Future messages in this conversation will not be logged."),
22215
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
437 PURPLE_MESSAGE_SYSTEM, time(NULL));
19445
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
438
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
439 /* Disable the logging second, so that the above message can be logged. */
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
440 purple_conversation_set_logging(conv, FALSE);
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
441 }
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
442
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
443 /* Each conversation with the same person will have the same logging setting */
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
444 for (iter = fc->list; iter; iter = iter->next) {
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
445 if (iter->data == conv)
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
446 continue;
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
447 purple_conversation_set_logging(iter->data, logging);
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
448 }
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
449 }
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
450
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
451 static void
19447
1a9b30a95fa6 Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19446
diff changeset
452 toggle_sound_cb(GntMenuItem *item, gpointer ggconv)
1a9b30a95fa6 Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19446
diff changeset
453 {
1a9b30a95fa6 Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19446
diff changeset
454 FinchConv *fc = ggconv;
19980
959b3aaba0b6 Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
455 PurpleBlistNode *node = get_conversation_blist_node(fc->active_conv);
19447
1a9b30a95fa6 Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19446
diff changeset
456 fc->flags ^= FINCH_CONV_NO_SOUND;
19980
959b3aaba0b6 Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
457 if (node)
959b3aaba0b6 Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
458 purple_blist_node_set_bool(node, "gnt-mute-sound", !!(fc->flags & FINCH_CONV_NO_SOUND));
19447
1a9b30a95fa6 Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19446
diff changeset
459 }
1a9b30a95fa6 Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19446
diff changeset
460
1a9b30a95fa6 Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19446
diff changeset
461 static void
16903
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
462 send_to_cb(GntMenuItem *m, gpointer n)
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
463 {
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
464 PurpleAccount *account = g_object_get_data(G_OBJECT(m), "purple_account");
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
465 gchar *buddy = g_object_get_data(G_OBJECT(m), "purple_buddy_name");
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
466 PurpleConversation *conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, buddy);
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
467 finch_conversation_set_active(conv);
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
468 }
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
469
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
470 static void
22248
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
471 view_log_cb(GntMenuItem *n, gpointer ggc)
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
472 {
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
473 FinchConv *fc;
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
474 PurpleConversation *conv;
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
475 PurpleLogType type;
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
476 const char *name;
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
477 PurpleAccount *account;
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
478 GSList *buddies;
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
479 GSList *cur;
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
480
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
481 fc = ggc;
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
482 conv = fc->active_conv;
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
483
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
484 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM)
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
485 type = PURPLE_LOG_IM;
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
486 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT)
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
487 type = PURPLE_LOG_CHAT;
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
488 else
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
489 return;
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
490
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
491 name = purple_conversation_get_name(conv);
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
492 account = purple_conversation_get_account(conv);
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
493
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
494 buddies = purple_find_buddies(account, name);
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
495 for (cur = buddies; cur != NULL; cur = cur->next) {
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
496 PurpleBlistNode *node = cur->data;
25295
53c27ca1bb71 Struct hiding for Finch. PurpleChat:alias and PurpleContact:totalsize are still used.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24176
diff changeset
497 if ((node != NULL) &&
53c27ca1bb71 Struct hiding for Finch. PurpleChat:alias and PurpleContact:totalsize are still used.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24176
diff changeset
498 (purple_blist_node_get_sibling_prev(node) || purple_blist_node_get_sibling_next(node))) {
53c27ca1bb71 Struct hiding for Finch. PurpleChat:alias and PurpleContact:totalsize are still used.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24176
diff changeset
499 finch_log_show_contact((PurpleContact *)purple_blist_node_get_parent(node));
22248
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
500 g_slist_free(buddies);
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
501 return;
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
502 }
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
503 }
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
504 g_slist_free(buddies);
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
505
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
506 finch_log_show(type, name, account);
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
507 }
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
508
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
509 static void
16903
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
510 generate_send_to_menu(FinchConv *ggc)
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
511 {
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
512 GntWidget *sub, *menu = ggc->menu;
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
513 GntMenuItem *item;
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
514 GSList *buds;
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
515 GList *list = NULL;
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
516
22215
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
517 buds = purple_find_buddies(purple_conversation_get_account(ggc->active_conv),
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
518 purple_conversation_get_name(ggc->active_conv));
16903
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
519 if (!buds)
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
520 return;
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
521
19321
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
522 if ((item = ggc->u.im->sendto) == NULL) {
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
523 item = gnt_menuitem_new(_("Send To"));
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
524 gnt_menu_add_item(GNT_MENU(menu), item);
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
525 ggc->u.im->sendto = item;
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
526 }
16903
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
527 sub = gnt_menu_new(GNT_MENU_POPUP);
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
528 gnt_menuitem_set_submenu(item, GNT_MENU(sub));
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
529
19321
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
530 for (; buds; buds = g_slist_delete_link(buds, buds)) {
25318
0e08c847517d Update some casts (that the script didn't fix correctly) to GObject macros.
Richard Laager <rlaager@wiktel.com>
parents: 25295
diff changeset
531 PurpleBlistNode *node = PURPLE_BLIST_NODE(purple_buddy_get_contact(PURPLE_BUDDY(buds->data)));
22212
6bb29f94862c Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
532 for (node = purple_blist_node_get_first_child(node); node != NULL;
6bb29f94862c Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
533 node = purple_blist_node_get_sibling_next(node)) {
16903
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
534 PurpleBuddy *buddy = (PurpleBuddy *)node;
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
535 PurpleAccount *account = purple_buddy_get_account(buddy);
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
536 if (purple_account_is_connected(account)) {
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
537 /* Use the PurplePresence to get unique buddies. */
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
538 PurplePresence *presence = purple_buddy_get_presence(buddy);
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
539 if (!g_list_find(list, presence))
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
540 list = g_list_prepend(list, presence);
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
541 }
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
542 }
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
543 }
19321
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
544 for (list = g_list_reverse(list); list != NULL; list = g_list_delete_link(list, list)) {
16903
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
545 PurplePresence *pre = list->data;
16904
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
546 PurpleBuddy *buddy = purple_presence_get_buddy(pre);
16903
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
547 PurpleAccount *account = purple_buddy_get_account(buddy);
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
548 gchar *name = g_strdup(purple_buddy_get_name(buddy));
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
549 gchar *text = g_strdup_printf("%s (%s)", purple_buddy_get_name(buddy), purple_account_get_username(account));
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
550 item = gnt_menuitem_new(text);
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
551 g_free(text);
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
552 gnt_menu_add_item(GNT_MENU(sub), item);
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
553 gnt_menuitem_set_callback(item, send_to_cb, NULL);
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
554 g_object_set_data(G_OBJECT(item), "purple_account", account);
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
555 g_object_set_data_full(G_OBJECT(item), "purple_buddy_name", name, g_free);
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
556 }
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
557 }
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
558
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
559 static void
23233
cb241bc04f9b Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents: 22680
diff changeset
560 invite_cb(GntMenuItem *item, gpointer ggconv)
cb241bc04f9b Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents: 22680
diff changeset
561 {
26623
15ae2dea92b3 Open a chat-invite dialog when a buddy is dragged onto a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25318
diff changeset
562 FinchConv *fc = ggconv;
15ae2dea92b3 Open a chat-invite dialog when a buddy is dragged onto a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25318
diff changeset
563 PurpleConversation *conv = fc->active_conv;
15ae2dea92b3 Open a chat-invite dialog when a buddy is dragged onto a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25318
diff changeset
564 purple_conv_chat_invite_user(PURPLE_CONV_CHAT(conv), NULL, NULL, TRUE);
23233
cb241bc04f9b Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents: 22680
diff changeset
565 }
cb241bc04f9b Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents: 22680
diff changeset
566
cb241bc04f9b Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents: 22680
diff changeset
567 static void
16903
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
568 gg_create_menu(FinchConv *ggc)
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
569 {
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
570 GntWidget *menu, *sub;
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
571 GntMenuItem *item;
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
572
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
573 ggc->menu = menu = gnt_menu_new(GNT_MENU_TOPLEVEL);
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
574 gnt_window_set_menu(GNT_WINDOW(ggc->window), GNT_MENU(menu));
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
575
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
576 item = gnt_menuitem_new(_("Conversation"));
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
577 gnt_menu_add_item(GNT_MENU(menu), item);
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
578
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
579 sub = gnt_menu_new(GNT_MENU_POPUP);
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
580 gnt_menuitem_set_submenu(item, GNT_MENU(sub));
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
581
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
582 item = gnt_menuitem_new(_("Clear Scrollback"));
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
583 gnt_menu_add_item(GNT_MENU(sub), item);
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
584 gnt_menuitem_set_callback(item, clear_scrollback_cb, ggc);
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
585
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
586 item = gnt_menuitem_check_new(_("Show Timestamps"));
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
587 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item),
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
588 purple_prefs_get_bool(PREF_ROOT "/timestamps"));
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
589 gnt_menu_add_item(GNT_MENU(sub), item);
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
590 gnt_menuitem_set_callback(item, toggle_timestamps_cb, ggc);
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
591
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
592 if (purple_conversation_get_type(ggc->active_conv) == PURPLE_CONV_TYPE_IM) {
16969
1a336cfc410e Change a string, and make sure non-functional items are not added in the conversation window menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16941
diff changeset
593 PurpleAccount *account = purple_conversation_get_account(ggc->active_conv);
22213
16ff37f64e29 Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22212
diff changeset
594 PurpleConnection *gc = purple_account_get_connection(account);
22214
2b426862ffbf Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22213
diff changeset
595 PurplePluginProtocolInfo *pinfo =
2b426862ffbf Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22213
diff changeset
596 gc ? PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)) : NULL;
16969
1a336cfc410e Change a string, and make sure non-functional items are not added in the conversation window menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16941
diff changeset
597
1a336cfc410e Change a string, and make sure non-functional items are not added in the conversation window menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16941
diff changeset
598 if (pinfo && pinfo->get_info) {
1a336cfc410e Change a string, and make sure non-functional items are not added in the conversation window menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16941
diff changeset
599 item = gnt_menuitem_new(_("Get Info"));
1a336cfc410e Change a string, and make sure non-functional items are not added in the conversation window menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16941
diff changeset
600 gnt_menu_add_item(GNT_MENU(sub), item);
1a336cfc410e Change a string, and make sure non-functional items are not added in the conversation window menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16941
diff changeset
601 gnt_menuitem_set_callback(item, get_info_cb, ggc);
1a336cfc410e Change a string, and make sure non-functional items are not added in the conversation window menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16941
diff changeset
602 }
16903
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
603
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
604 item = gnt_menuitem_new(_("Add Buddy Pounce..."));
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
605 gnt_menu_add_item(GNT_MENU(sub), item);
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
606 gnt_menuitem_set_callback(item, add_pounce_cb, ggc);
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
607
16969
1a336cfc410e Change a string, and make sure non-functional items are not added in the conversation window menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16941
diff changeset
608 if (pinfo && pinfo->send_file &&
1a336cfc410e Change a string, and make sure non-functional items are not added in the conversation window menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16941
diff changeset
609 (!pinfo->can_receive_file ||
22213
16ff37f64e29 Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22212
diff changeset
610 pinfo->can_receive_file(gc, purple_conversation_get_name(ggc->active_conv)))) {
16969
1a336cfc410e Change a string, and make sure non-functional items are not added in the conversation window menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16941
diff changeset
611 item = gnt_menuitem_new(_("Send File"));
1a336cfc410e Change a string, and make sure non-functional items are not added in the conversation window menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16941
diff changeset
612 gnt_menu_add_item(GNT_MENU(sub), item);
1a336cfc410e Change a string, and make sure non-functional items are not added in the conversation window menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16941
diff changeset
613 gnt_menuitem_set_callback(item, send_file_cb, ggc);
1a336cfc410e Change a string, and make sure non-functional items are not added in the conversation window menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16941
diff changeset
614 }
16903
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
615
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
616 generate_send_to_menu(ggc);
23233
cb241bc04f9b Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents: 22680
diff changeset
617 } else if (purple_conversation_get_type(ggc->active_conv) == PURPLE_CONV_TYPE_CHAT) {
cb241bc04f9b Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents: 22680
diff changeset
618 item = gnt_menuitem_new(_("Invite..."));
cb241bc04f9b Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents: 22680
diff changeset
619 gnt_menu_add_item(GNT_MENU(sub), item);
cb241bc04f9b Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents: 22680
diff changeset
620 gnt_menuitem_set_callback(item, invite_cb, ggc);
16903
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
621 }
19445
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
622
22248
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
623 item = gnt_menuitem_new(_("View Log..."));
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
624 gnt_menu_add_item(GNT_MENU(sub), item);
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
625 gnt_menuitem_set_callback(item, view_log_cb, ggc);
88796aff14d6 Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents: 22219
diff changeset
626
19445
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
627 item = gnt_menuitem_check_new(_("Enable Logging"));
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
628 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item),
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
629 purple_conversation_is_logging(ggc->active_conv));
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
630 gnt_menu_add_item(GNT_MENU(sub), item);
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
631 gnt_menuitem_set_callback(item, toggle_logging_cb, ggc);
19447
1a9b30a95fa6 Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19446
diff changeset
632
1a9b30a95fa6 Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19446
diff changeset
633 item = gnt_menuitem_check_new(_("Enable Sounds"));
1a9b30a95fa6 Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19446
diff changeset
634 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item),
1a9b30a95fa6 Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19446
diff changeset
635 !(ggc->flags & FINCH_CONV_NO_SOUND));
1a9b30a95fa6 Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19446
diff changeset
636 gnt_menu_add_item(GNT_MENU(sub), item);
1a9b30a95fa6 Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19446
diff changeset
637 gnt_menuitem_set_callback(item, toggle_sound_cb, ggc);
16903
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
638 }
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
639
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
640 static void
16904
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
641 create_conv_from_userlist(GntWidget *widget, FinchConv *fc)
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
642 {
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
643 PurpleAccount *account = purple_conversation_get_account(fc->active_conv);
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
644 char *name = gnt_tree_get_selection_data(GNT_TREE(widget));
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
645 purple_conversation_new(PURPLE_CONV_TYPE_IM, account, name);
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
646 }
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
647
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
648 static void
18100
f63b3a23280d Provide a 'unseen-count' data for the conversations so the dbus-docklet can use that information.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17529
diff changeset
649 gained_focus_cb(GntWindow *window, FinchConv *fc)
f63b3a23280d Provide a 'unseen-count' data for the conversations so the dbus-docklet can use that information.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17529
diff changeset
650 {
f63b3a23280d Provide a 'unseen-count' data for the conversations so the dbus-docklet can use that information.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17529
diff changeset
651 GList *iter;
f63b3a23280d Provide a 'unseen-count' data for the conversations so the dbus-docklet can use that information.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17529
diff changeset
652 for (iter = fc->list; iter; iter = iter->next) {
f63b3a23280d Provide a 'unseen-count' data for the conversations so the dbus-docklet can use that information.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17529
diff changeset
653 purple_conversation_set_data(iter->data, "unseen-count", 0);
f63b3a23280d Provide a 'unseen-count' data for the conversations so the dbus-docklet can use that information.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17529
diff changeset
654 purple_conversation_update(iter->data, PURPLE_CONV_UPDATE_UNSEEN);
f63b3a23280d Provide a 'unseen-count' data for the conversations so the dbus-docklet can use that information.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17529
diff changeset
655 }
f63b3a23280d Provide a 'unseen-count' data for the conversations so the dbus-docklet can use that information.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17529
diff changeset
656 }
f63b3a23280d Provide a 'unseen-count' data for the conversations so the dbus-docklet can use that information.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17529
diff changeset
657
f63b3a23280d Provide a 'unseen-count' data for the conversations so the dbus-docklet can use that information.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17529
diff changeset
658 static void
18383
9eb2f4d27990 Use the completion-signal to append a ': ' after a tab-completed nick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18232
diff changeset
659 completion_cb(GntEntry *entry, const char *start, const char *end)
9eb2f4d27990 Use the completion-signal to append a ': ' after a tab-completed nick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18232
diff changeset
660 {
23415
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
661 if (start == entry->start && *start != '/')
18383
9eb2f4d27990 Use the completion-signal to append a ': ' after a tab-completed nick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18232
diff changeset
662 gnt_widget_key_pressed(GNT_WIDGET(entry), ": ");
9eb2f4d27990 Use the completion-signal to append a ': ' after a tab-completed nick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18232
diff changeset
663 }
9eb2f4d27990 Use the completion-signal to append a ': ' after a tab-completed nick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18232
diff changeset
664
9eb2f4d27990 Use the completion-signal to append a ': ' after a tab-completed nick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18232
diff changeset
665 static void
23415
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
666 gg_setup_commands(FinchConv *fconv, gboolean remove_first)
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
667 {
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
668 GList *commands;
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
669 char command[256] = "/";
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
670
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
671 if (remove_first) {
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
672 commands = purple_cmd_list(NULL);
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
673 for (; commands; commands = g_list_delete_link(commands, commands)) {
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
674 g_strlcpy(command + 1, commands->data, sizeof(command) - 1);
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
675 gnt_entry_remove_suggest(GNT_ENTRY(fconv->entry), command);
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
676 }
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
677 }
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
678
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
679 commands = purple_cmd_list(fconv->active_conv);
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
680 for (; commands; commands = g_list_delete_link(commands, commands)) {
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
681 g_strlcpy(command + 1, commands->data, sizeof(command) - 1);
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
682 gnt_entry_add_suggest(GNT_ENTRY(fconv->entry), command);
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
683 }
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
684 }
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
685
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
686 static void
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
687 cmd_added_cb(const char *cmd, PurpleCmdPriority prior, PurpleCmdFlag flags,
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
688 FinchConv *fconv)
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
689 {
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
690 gg_setup_commands(fconv, TRUE);
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
691 }
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
692
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
693 static void
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
694 cmd_removed_cb(const char *cmd, FinchConv *fconv)
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
695 {
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
696 char command[256] = "/";
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
697 g_strlcpy(command + 1, cmd, sizeof(command) - 1);
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
698 gnt_entry_remove_suggest(GNT_ENTRY(fconv->entry), command);
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
699 gg_setup_commands(fconv, TRUE);
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
700 }
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
701
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
702 static void
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
703 finch_create_conversation(PurpleConversation *conv)
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
704 {
22217
ad357ca94de9 We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22215
diff changeset
705 FinchConv *ggc = FINCH_GET_DATA(conv);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
706 char *title;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
707 PurpleConversationType type;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
708 PurpleConversation *cc;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
709 PurpleAccount *account;
19980
959b3aaba0b6 Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
710 PurpleBlistNode *convnode = NULL;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
711
22418
b0b8c94118c8 Make sure an existing conversation selected from the 'Send IM' dialog is given the focus.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22280
diff changeset
712 if (ggc) {
b0b8c94118c8 Make sure an existing conversation selected from the 'Send IM' dialog is given the focus.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22280
diff changeset
713 gnt_window_present(ggc->window);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
714 return;
22418
b0b8c94118c8 Make sure an existing conversation selected from the 'Send IM' dialog is given the focus.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22280
diff changeset
715 }
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
716
22215
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
717 account = purple_conversation_get_account(conv);
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
718 cc = find_conv_with_contact(account, purple_conversation_get_name(conv));
22217
ad357ca94de9 We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22215
diff changeset
719 if (cc && FINCH_GET_DATA(cc))
ad357ca94de9 We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22215
diff changeset
720 ggc = FINCH_GET_DATA(cc);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
721 else
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
722 ggc = g_new0(FinchConv, 1);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
723
19445
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
724 /* Each conversation with the same person will have the same logging setting */
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
725 if (ggc->list) {
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
726 purple_conversation_set_logging(conv,
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
727 purple_conversation_is_logging(ggc->list->data));
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
728 }
6759eb4387a5 Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
729
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
730 ggc->list = g_list_prepend(ggc->list, conv);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
731 ggc->active_conv = conv;
22217
ad357ca94de9 We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22215
diff changeset
732 FINCH_SET_DATA(conv, ggc);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
733
22680
c7c97c62e131 Fix a crash which I think happens when the same buddy is in the buddylist
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22426
diff changeset
734 if (cc && FINCH_GET_DATA(cc) && cc != conv) {
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
735 finch_conversation_set_active(conv);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
736 return;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
737 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
738
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
739 type = purple_conversation_get_type(conv);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
740 title = get_conversation_title(conv, account);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
741
16903
373466e3151a Conversation menus
Richard Nelson <wabz@pidgin.im>
parents: 16427
diff changeset
742 ggc->window = gnt_vwindow_new(FALSE);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
743 gnt_box_set_title(GNT_BOX(ggc->window), title);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
744 gnt_box_set_toplevel(GNT_BOX(ggc->window), TRUE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
745 gnt_box_set_pad(GNT_BOX(ggc->window), 0);
18232
2b1af79e768f Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
746
22215
07c2b8fa7bb4 Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22214
diff changeset
747 switch (purple_conversation_get_type(conv)) {
18232
2b1af79e768f Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
748 case PURPLE_CONV_TYPE_UNKNOWN:
2b1af79e768f Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
749 gnt_widget_set_name(ggc->window, "conversation-window-unknown" );
2b1af79e768f Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
750 break;
2b1af79e768f Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
751 case PURPLE_CONV_TYPE_IM:
2b1af79e768f Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
752 gnt_widget_set_name(ggc->window, "conversation-window-im" );
2b1af79e768f Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
753 break;
2b1af79e768f Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
754 case PURPLE_CONV_TYPE_CHAT:
2b1af79e768f Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
755 gnt_widget_set_name(ggc->window, "conversation-window-chat" );
2b1af79e768f Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
756 break;
2b1af79e768f Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
757 case PURPLE_CONV_TYPE_MISC:
2b1af79e768f Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
758 gnt_widget_set_name(ggc->window, "conversation-window-misc" );
2b1af79e768f Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
759 break;
2b1af79e768f Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
760 case PURPLE_CONV_TYPE_ANY:
2b1af79e768f Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
761 gnt_widget_set_name(ggc->window, "conversation-window-any" );
2b1af79e768f Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
762 break;
2b1af79e768f Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
763 }
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
764
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
765 ggc->tv = gnt_text_view_new();
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
766 gnt_widget_set_name(ggc->tv, "conversation-window-textview");
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
767 gnt_widget_set_size(ggc->tv, purple_prefs_get_int(PREF_ROOT "/size/width"),
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
768 purple_prefs_get_int(PREF_ROOT "/size/height"));
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
769
16904
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
770 if (type == PURPLE_CONV_TYPE_CHAT) {
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
771 GntWidget *hbox, *tree;
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
772 FinchConvChat *fc = ggc->u.chat = g_new0(FinchConvChat, 1);
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
773 hbox = gnt_hbox_new(FALSE);
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
774 gnt_box_set_pad(GNT_BOX(hbox), 0);
17083
f2137f75fd10 Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17032
diff changeset
775 tree = fc->userlist = gnt_tree_new_with_columns(2);
f2137f75fd10 Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17032
diff changeset
776 gnt_tree_set_col_width(GNT_TREE(tree), 0, 1); /* The flag column */
16904
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
777 gnt_tree_set_compare_func(GNT_TREE(tree), (GCompareFunc)g_utf8_collate);
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
778 gnt_tree_set_hash_fns(GNT_TREE(tree), g_str_hash, g_str_equal, g_free);
19631
61473f8a5e2b Use the proper column for searching users in the chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19509
diff changeset
779 gnt_tree_set_search_column(GNT_TREE(tree), 1);
16904
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
780 GNT_WIDGET_SET_FLAGS(tree, GNT_WIDGET_NO_BORDER);
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
781 gnt_box_add_widget(GNT_BOX(hbox), ggc->tv);
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
782 gnt_box_add_widget(GNT_BOX(hbox), tree);
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
783 gnt_box_add_widget(GNT_BOX(ggc->window), hbox);
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
784 g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(create_conv_from_userlist), ggc);
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
785 gnt_widget_set_visible(tree, purple_prefs_get_bool(PREF_USERLIST));
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
786 } else {
19321
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
787 ggc->u.im = g_new0(FinchConvIm, 1);
16904
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
788 gnt_box_add_widget(GNT_BOX(ggc->window), ggc->tv);
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
789 }
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
790
16128
7a2ffa981c1a Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16124
diff changeset
791 ggc->info = gnt_vbox_new(FALSE);
7a2ffa981c1a Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16124
diff changeset
792 gnt_box_add_widget(GNT_BOX(ggc->window), ggc->info);
7a2ffa981c1a Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16124
diff changeset
793
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
794 ggc->entry = gnt_entry_new(NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
795 gnt_box_add_widget(GNT_BOX(ggc->window), ggc->entry);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
796 gnt_widget_set_name(ggc->entry, "conversation-window-entry");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
797 gnt_entry_set_history_length(GNT_ENTRY(ggc->entry), -1);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
798 gnt_entry_set_word_suggest(GNT_ENTRY(ggc->entry), TRUE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
799 gnt_entry_set_always_suggest(GNT_ENTRY(ggc->entry), FALSE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
800
16124
ab3f93232a2d Add a utility function to assist scrolling in a textview.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15871
diff changeset
801 gnt_text_view_attach_scroll_widget(GNT_TEXT_VIEW(ggc->tv), ggc->entry);
18427
be8c4eba38f6 Use the utility function for the conversation and debug windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18383
diff changeset
802 gnt_text_view_attach_pager_widget(GNT_TEXT_VIEW(ggc->tv), ggc->entry);
be8c4eba38f6 Use the utility function for the conversation and debug windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18383
diff changeset
803
21281
d7d3f31d52fb I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20740
diff changeset
804 g_signal_connect_after(G_OBJECT(ggc->entry), "activate", G_CALLBACK(entry_key_pressed), ggc);
18383
9eb2f4d27990 Use the completion-signal to append a ': ' after a tab-completed nick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18232
diff changeset
805 g_signal_connect(G_OBJECT(ggc->entry), "completion", G_CALLBACK(completion_cb), NULL);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
806 g_signal_connect(G_OBJECT(ggc->window), "destroy", G_CALLBACK(closing_window), ggc);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
807
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
808 gnt_widget_set_position(ggc->window, purple_prefs_get_int(PREF_ROOT "/position/x"),
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
809 purple_prefs_get_int(PREF_ROOT "/position/y"));
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
810 gnt_widget_show(ggc->window);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
811
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
812 g_signal_connect(G_OBJECT(ggc->tv), "size_changed", G_CALLBACK(size_changed_cb), NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
813 g_signal_connect(G_OBJECT(ggc->window), "position_set", G_CALLBACK(save_position_cb), NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
814
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
815 if (type == PURPLE_CONV_TYPE_IM) {
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
816 g_signal_connect(G_OBJECT(ggc->entry), "text_changed", G_CALLBACK(send_typing_notification), ggc);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
817 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
818
19980
959b3aaba0b6 Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
819 convnode = get_conversation_blist_node(conv);
959b3aaba0b6 Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
820 if ((convnode && purple_blist_node_get_bool(convnode, "gnt-mute-sound")) ||
959b3aaba0b6 Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19680
diff changeset
821 !finch_sound_is_enabled())
19447
1a9b30a95fa6 Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19446
diff changeset
822 ggc->flags |= FINCH_CONV_NO_SOUND;
1a9b30a95fa6 Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19446
diff changeset
823
19321
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
824 gg_create_menu(ggc);
23415
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
825 gg_setup_commands(ggc, FALSE);
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
826
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
827 purple_signal_connect(purple_cmds_get_handle(), "cmd-added", ggc,
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
828 G_CALLBACK(cmd_added_cb), ggc);
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
829 purple_signal_connect(purple_cmds_get_handle(), "cmd-removed", ggc,
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
830 G_CALLBACK(cmd_removed_cb), ggc);
19321
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
831
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
832 g_free(title);
16904
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
833 gnt_box_give_focus_to_child(GNT_BOX(ggc->window), ggc->entry);
18100
f63b3a23280d Provide a 'unseen-count' data for the conversations so the dbus-docklet can use that information.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17529
diff changeset
834 g_signal_connect(G_OBJECT(ggc->window), "gained-focus", G_CALLBACK(gained_focus_cb), ggc);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
835 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
836
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
837 static void
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
838 finch_destroy_conversation(PurpleConversation *conv)
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
839 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
840 /* do stuff here */
22217
ad357ca94de9 We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22215
diff changeset
841 FinchConv *ggc = FINCH_GET_DATA(conv);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
842 ggc->list = g_list_remove(ggc->list, conv);
23415
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
843 if (ggc->list && conv == ggc->active_conv) {
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
844 ggc->active_conv = ggc->list->data;
23415
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
845 gg_setup_commands(ggc, TRUE);
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
846 }
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
847
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
848 if (ggc->list == NULL) {
16904
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
849 g_free(ggc->u.chat);
23415
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
850 purple_signals_disconnect_by_handle(ggc);
18222
ef65d43190e5 Fix a few runtime warnings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18210
diff changeset
851 if (ggc->window)
ef65d43190e5 Fix a few runtime warnings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18210
diff changeset
852 gnt_widget_destroy(ggc->window);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
853 g_free(ggc);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
854 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
855 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
856
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
857 static void
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
858 finch_write_common(PurpleConversation *conv, const char *who, const char *message,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
859 PurpleMessageFlags flags, time_t mtime)
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
860 {
22217
ad357ca94de9 We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22215
diff changeset
861 FinchConv *ggconv = FINCH_GET_DATA(conv);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
862 char *strip, *newline;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
863 GntTextFormatFlags fl = 0;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
864 int pos;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
865
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
866 g_return_if_fail(ggconv != NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
867
24176
c1e58cfd1107 Set the urgent flag for conversation windows on receiving a /buzz etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23833
diff changeset
868 if ((flags & PURPLE_MESSAGE_SYSTEM) && !(flags & PURPLE_MESSAGE_NOTIFY)) {
22280
d680613669cc Ignore the recv/send flags when the system flag is set for a message.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22279
diff changeset
869 flags &= ~(PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV);
d680613669cc Ignore the recv/send flags when the system flag is set for a message.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22279
diff changeset
870 }
d680613669cc Ignore the recv/send flags when the system flag is set for a message.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22279
diff changeset
871
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
872 if (ggconv->active_conv != conv) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
873 if (flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV))
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
874 finch_conversation_set_active(conv);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
875 else
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
876 return;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
877 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
878
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
879 pos = gnt_text_view_get_lines_below(GNT_TEXT_VIEW(ggconv->tv));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
880
18637
3597903cf8ff Just show an empty line, instead of bouncing the text down when the user
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18427
diff changeset
881 gnt_text_view_tag_change(GNT_TEXT_VIEW(ggconv->tv), "typing", NULL, TRUE);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
882 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), "\n", GNT_TEXT_FLAG_NORMAL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
883
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
884 /* Unnecessary to print the timestamp for delayed message */
27598
37741237d146 Show the current time if the timestamp is zero.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 27516
diff changeset
885 if (purple_prefs_get_bool("/finch/conversations/timestamps")) {
37741237d146 Show the current time if the timestamp is zero.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 27516
diff changeset
886 if (!mtime)
37741237d146 Show the current time if the timestamp is zero.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 27516
diff changeset
887 time(&mtime);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
888 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv),
21738
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
889 purple_utf8_strftime("(%H:%M:%S)", localtime(&mtime)), gnt_color_pair(color_timestamp));
27598
37741237d146 Show the current time if the timestamp is zero.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 27516
diff changeset
890 }
21738
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
891
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
892 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), " ", GNT_TEXT_FLAG_NORMAL);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
893
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
894 if (flags & PURPLE_MESSAGE_AUTO_RESP)
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
895 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
896 _("<AUTO-REPLY> "), GNT_TEXT_FLAG_BOLD);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
897
20553
bed3c9affda6 Show 'buzz'/'nudge' etc. messages differently from regular messages.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20552
diff changeset
898 if (who && *who && (flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV)) &&
bed3c9affda6 Show 'buzz'/'nudge' etc. messages differently from regular messages.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20552
diff changeset
899 !(flags & PURPLE_MESSAGE_NOTIFY))
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
900 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
901 char * name = NULL;
21743
5ff16647c50d Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21738
diff changeset
902 GntTextFormatFlags msgflags = GNT_TEXT_FLAG_NORMAL;
5ff16647c50d Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21738
diff changeset
903 gboolean me = FALSE;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
904
21738
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
905 if (purple_message_meify((char*)message, -1)) {
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
906 name = g_strdup_printf("*** %s", who);
22279
40707fbabcbc Highlighted message color has a higher priority over an action message color.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22248
diff changeset
907 if (!(flags & PURPLE_MESSAGE_SEND) &&
40707fbabcbc Highlighted message color has a higher priority over an action message color.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22248
diff changeset
908 (flags & PURPLE_MESSAGE_NICK))
40707fbabcbc Highlighted message color has a higher priority over an action message color.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22248
diff changeset
909 msgflags = gnt_color_pair(color_message_highlight);
40707fbabcbc Highlighted message color has a higher priority over an action message color.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22248
diff changeset
910 else
40707fbabcbc Highlighted message color has a higher priority over an action message color.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22248
diff changeset
911 msgflags = gnt_color_pair(color_message_action);
21743
5ff16647c50d Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21738
diff changeset
912 me = TRUE;
21738
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
913 } else {
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
914 name = g_strdup_printf("%s", who);
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
915 if (flags & PURPLE_MESSAGE_SEND)
21743
5ff16647c50d Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21738
diff changeset
916 msgflags = gnt_color_pair(color_message_send);
5ff16647c50d Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21738
diff changeset
917 else if (flags & PURPLE_MESSAGE_NICK)
5ff16647c50d Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21738
diff changeset
918 msgflags = gnt_color_pair(color_message_highlight);
21738
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
919 else
21743
5ff16647c50d Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21738
diff changeset
920 msgflags = gnt_color_pair(color_message_receive);
21738
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
921 }
21743
5ff16647c50d Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21738
diff changeset
922 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv),
5ff16647c50d Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21738
diff changeset
923 name, msgflags);
5ff16647c50d Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21738
diff changeset
924 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), me ? " " : ": ", GNT_TEXT_FLAG_NORMAL);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
925 g_free(name);
21738
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
926 } else
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
927 fl = GNT_TEXT_FLAG_DIM;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
928
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
929 if (flags & PURPLE_MESSAGE_ERROR)
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
930 fl |= GNT_TEXT_FLAG_BOLD;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
931
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
932 /* XXX: Remove this workaround when textview can parse messages. */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
933 newline = purple_strdup_withhtml(message);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
934 strip = purple_markup_strip_html(newline);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
935 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
936 strip, fl);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
937
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
938 g_free(newline);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
939 g_free(strip);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
940
18637
3597903cf8ff Just show an empty line, instead of bouncing the text down when the user
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18427
diff changeset
941 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM &&
3597903cf8ff Just show an empty line, instead of bouncing the text down when the user
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18427
diff changeset
942 purple_conv_im_get_typing_state(PURPLE_CONV_IM(conv)) == PURPLE_TYPING) {
22426
ca6bc025aabb Patch from Kyle Turman to show the alias when available in the typing notification. Closes #4957.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22418
diff changeset
943 strip = g_strdup_printf(_("\n%s is typing..."), purple_conversation_get_title(conv));
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
944 gnt_text_view_append_text_with_tag(GNT_TEXT_VIEW(ggconv->tv),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
945 strip, GNT_TEXT_FLAG_DIM, "typing");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
946 g_free(strip);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
947 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
948
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
949 if (pos <= 1)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
950 gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), 0);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
951
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
952 if (flags & (PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_NICK | PURPLE_MESSAGE_ERROR))
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
953 gnt_widget_set_urgent(ggconv->tv);
18100
f63b3a23280d Provide a 'unseen-count' data for the conversations so the dbus-docklet can use that information.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17529
diff changeset
954 if (flags & PURPLE_MESSAGE_RECV && !gnt_widget_has_focus(ggconv->window)) {
f63b3a23280d Provide a 'unseen-count' data for the conversations so the dbus-docklet can use that information.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17529
diff changeset
955 int count = GPOINTER_TO_INT(purple_conversation_get_data(conv, "unseen-count"));
f63b3a23280d Provide a 'unseen-count' data for the conversations so the dbus-docklet can use that information.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17529
diff changeset
956 purple_conversation_set_data(conv, "unseen-count", GINT_TO_POINTER(count + 1));
f63b3a23280d Provide a 'unseen-count' data for the conversations so the dbus-docklet can use that information.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17529
diff changeset
957 purple_conversation_update(conv, PURPLE_CONV_UPDATE_UNSEEN);
f63b3a23280d Provide a 'unseen-count' data for the conversations so the dbus-docklet can use that information.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17529
diff changeset
958 }
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
959 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
960
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
961 static void
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
962 finch_write_chat(PurpleConversation *conv, const char *who, const char *message,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
963 PurpleMessageFlags flags, time_t mtime)
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
964 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
965 purple_conversation_write(conv, who, message, flags, mtime);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
966 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
967
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
968 static void
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
969 finch_write_im(PurpleConversation *conv, const char *who, const char *message,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
970 PurpleMessageFlags flags, time_t mtime)
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
971 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
972 PurpleAccount *account = purple_conversation_get_account(conv);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
973 if (flags & PURPLE_MESSAGE_SEND)
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
974 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
975 who = purple_connection_get_display_name(purple_account_get_connection(account));
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
976 if (!who)
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
977 who = purple_account_get_alias(account);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
978 if (!who)
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
979 who = purple_account_get_username(account);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
980 }
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
981 else if (flags & PURPLE_MESSAGE_RECV)
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
982 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
983 PurpleBuddy *buddy;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
984 who = purple_conversation_get_name(conv);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
985 buddy = purple_find_buddy(account, who);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
986 if (buddy)
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
987 who = purple_buddy_get_contact_alias(buddy);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
988 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
989
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
990 purple_conversation_write(conv, who, message, flags, mtime);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
991 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
992
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
993 static void
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
994 finch_write_conv(PurpleConversation *conv, const char *who, const char *alias,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
995 const char *message, PurpleMessageFlags flags, time_t mtime)
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
996 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
997 const char *name;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
998 if (alias && *alias)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
999 name = alias;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1000 else if (who && *who)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1001 name = who;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1002 else
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1003 name = NULL;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1004
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1005 finch_write_common(conv, name, message, flags, mtime);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1006 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1007
17083
f2137f75fd10 Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17032
diff changeset
1008 static const char *
f2137f75fd10 Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17032
diff changeset
1009 chat_flag_text(PurpleConvChatBuddyFlags flags)
f2137f75fd10 Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17032
diff changeset
1010 {
f2137f75fd10 Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17032
diff changeset
1011 if (flags & PURPLE_CBFLAGS_FOUNDER)
f2137f75fd10 Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17032
diff changeset
1012 return "~";
f2137f75fd10 Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17032
diff changeset
1013 if (flags & PURPLE_CBFLAGS_OP)
f2137f75fd10 Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17032
diff changeset
1014 return "@";
f2137f75fd10 Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17032
diff changeset
1015 if (flags & PURPLE_CBFLAGS_HALFOP)
f2137f75fd10 Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17032
diff changeset
1016 return "%";
f2137f75fd10 Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17032
diff changeset
1017 if (flags & PURPLE_CBFLAGS_VOICE)
f2137f75fd10 Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17032
diff changeset
1018 return "+";
f2137f75fd10 Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17032
diff changeset
1019 return " ";
f2137f75fd10 Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17032
diff changeset
1020 }
f2137f75fd10 Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17032
diff changeset
1021
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1022 static void
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1023 finch_chat_add_users(PurpleConversation *conv, GList *users, gboolean new_arrivals)
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1024 {
22217
ad357ca94de9 We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22215
diff changeset
1025 FinchConv *ggc = FINCH_GET_DATA(conv);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1026 GntEntry *entry = GNT_ENTRY(ggc->entry);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1027
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1028 if (!new_arrivals)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1029 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1030 /* Print the list of users in the room */
23442
f4b2fecfb557 Show the count of users when joining a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23415
diff changeset
1031 GString *string = g_string_new(NULL);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1032 GList *iter;
23442
f4b2fecfb557 Show the count of users when joining a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23415
diff changeset
1033 int count = g_list_length(users);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1034
23442
f4b2fecfb557 Show the count of users when joining a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23415
diff changeset
1035 g_string_printf(string,
f4b2fecfb557 Show the count of users when joining a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23415
diff changeset
1036 ngettext("List of %d user:\n", "List of %d users:\n", count), count);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1037 for (iter = users; iter; iter = iter->next)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1038 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1039 PurpleConvChatBuddy *cbuddy = iter->data;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1040 char *str;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1041
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1042 if ((str = cbuddy->alias) == NULL)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1043 str = cbuddy->name;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1044 g_string_append_printf(string, "[ %s ]", str);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1045 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1046
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1047 purple_conversation_write(conv, NULL, string->str,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1048 PURPLE_MESSAGE_SYSTEM, time(NULL));
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1049 g_string_free(string, TRUE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1050 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1051
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1052 for (; users; users = users->next)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1053 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1054 PurpleConvChatBuddy *cbuddy = users->data;
16904
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1055 GntTree *tree = GNT_TREE(ggc->u.chat->userlist);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1056 gnt_entry_add_suggest(entry, cbuddy->name);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1057 gnt_entry_add_suggest(entry, cbuddy->alias);
16904
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1058 gnt_tree_add_row_after(tree, g_strdup(cbuddy->name),
17083
f2137f75fd10 Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17032
diff changeset
1059 gnt_tree_create_row(tree, chat_flag_text(cbuddy->flags), cbuddy->alias), NULL, NULL);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1060 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1061 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1062
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1063 static void
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1064 finch_chat_rename_user(PurpleConversation *conv, const char *old, const char *new_n, const char *new_a)
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1065 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1066 /* Update the name for string completion */
22217
ad357ca94de9 We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22215
diff changeset
1067 FinchConv *ggc = FINCH_GET_DATA(conv);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1068 GntEntry *entry = GNT_ENTRY(ggc->entry);
16904
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1069 GntTree *tree = GNT_TREE(ggc->u.chat->userlist);
17083
f2137f75fd10 Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17032
diff changeset
1070 PurpleConvChatBuddy *cb = purple_conv_chat_cb_find(PURPLE_CONV_CHAT(conv), new_n);
f2137f75fd10 Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17032
diff changeset
1071
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1072 gnt_entry_remove_suggest(entry, old);
17083
f2137f75fd10 Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17032
diff changeset
1073 gnt_tree_remove(tree, (gpointer)old);
f2137f75fd10 Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17032
diff changeset
1074
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1075 gnt_entry_add_suggest(entry, new_n);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1076 gnt_entry_add_suggest(entry, new_a);
16904
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1077 gnt_tree_add_row_after(tree, g_strdup(new_n),
17083
f2137f75fd10 Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17032
diff changeset
1078 gnt_tree_create_row(tree, chat_flag_text(cb->flags), new_a), NULL, NULL);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1079 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1080
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1081 static void
17104
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 17083
diff changeset
1082 finch_chat_remove_users(PurpleConversation *conv, GList *list)
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1083 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1084 /* Remove the name from string completion */
22217
ad357ca94de9 We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22215
diff changeset
1085 FinchConv *ggc = FINCH_GET_DATA(conv);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1086 GntEntry *entry = GNT_ENTRY(ggc->entry);
16904
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1087 for (; list; list = list->next) {
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1088 GntTree *tree = GNT_TREE(ggc->u.chat->userlist);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1089 gnt_entry_remove_suggest(entry, list->data);
16904
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1090 gnt_tree_remove(tree, list->data);
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1091 }
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1092 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1093
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1094 static void
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1095 finch_chat_update_user(PurpleConversation *conv, const char *user)
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1096 {
17083
f2137f75fd10 Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17032
diff changeset
1097 PurpleConvChatBuddy *cb = purple_conv_chat_cb_find(PURPLE_CONV_CHAT(conv), user);
22217
ad357ca94de9 We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22215
diff changeset
1098 FinchConv *ggc = FINCH_GET_DATA(conv);
17083
f2137f75fd10 Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17032
diff changeset
1099 gnt_tree_change_text(GNT_TREE(ggc->u.chat->userlist), (gpointer)user, 0, chat_flag_text(cb->flags));
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1100 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1101
19446
5d200fce4170 Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19445
diff changeset
1102 static void
5d200fce4170 Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19445
diff changeset
1103 finch_conv_present(PurpleConversation *conv)
5d200fce4170 Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19445
diff changeset
1104 {
5d200fce4170 Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19445
diff changeset
1105 FinchConv *fc = FINCH_CONV(conv);
5d200fce4170 Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19445
diff changeset
1106 if (fc && fc->window)
20718
803f0ee0c231 void functions shouldn't 'return'. Thanks tmcmahon2. Fixes #3151 (gntconv.c fails to compile in Solaris 9)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20553
diff changeset
1107 gnt_window_present(fc->window);
19446
5d200fce4170 Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19445
diff changeset
1108 }
5d200fce4170 Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19445
diff changeset
1109
5d200fce4170 Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19445
diff changeset
1110 static gboolean
5d200fce4170 Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19445
diff changeset
1111 finch_conv_has_focus(PurpleConversation *conv)
5d200fce4170 Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19445
diff changeset
1112 {
5d200fce4170 Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19445
diff changeset
1113 FinchConv *fc = FINCH_CONV(conv);
5d200fce4170 Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19445
diff changeset
1114 if (fc && fc->window)
5d200fce4170 Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19445
diff changeset
1115 return gnt_widget_has_focus(fc->window);
5d200fce4170 Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19445
diff changeset
1116 return FALSE;
5d200fce4170 Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19445
diff changeset
1117 }
5d200fce4170 Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19445
diff changeset
1118
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1119 static PurpleConversationUiOps conv_ui_ops =
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1120 {
17104
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 17083
diff changeset
1121 finch_create_conversation,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 17083
diff changeset
1122 finch_destroy_conversation,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 17083
diff changeset
1123 finch_write_chat,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 17083
diff changeset
1124 finch_write_im,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 17083
diff changeset
1125 finch_write_conv,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 17083
diff changeset
1126 finch_chat_add_users,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 17083
diff changeset
1127 finch_chat_rename_user,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 17083
diff changeset
1128 finch_chat_remove_users,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 17083
diff changeset
1129 finch_chat_update_user,
19446
5d200fce4170 Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19445
diff changeset
1130 finch_conv_present, /* present */
5d200fce4170 Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19445
diff changeset
1131 finch_conv_has_focus, /* has_focus */
17104
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 17083
diff changeset
1132 NULL, /* custom_smiley_add */
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 17083
diff changeset
1133 NULL, /* custom_smiley_write */
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 17083
diff changeset
1134 NULL, /* custom_smiley_close */
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 17083
diff changeset
1135 NULL, /* send_confirm */
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 17083
diff changeset
1136 NULL,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 17083
diff changeset
1137 NULL,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 17083
diff changeset
1138 NULL,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 17083
diff changeset
1139 NULL
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1140 };
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1141
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1142 PurpleConversationUiOps *finch_conv_get_ui_ops()
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1143 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1144 return &conv_ui_ops;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1145 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1146
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1147 /* Xerox */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1148 static PurpleCmdRet
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1149 say_command_cb(PurpleConversation *conv,
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1150 const char *cmd, char **args, char **error, void *data)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1151 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1152 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1153 purple_conv_im_send(PURPLE_CONV_IM(conv), args[0]);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1154 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1155 purple_conv_chat_send(PURPLE_CONV_CHAT(conv), args[0]);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1156
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1157 return PURPLE_CMD_RET_OK;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1158 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1159
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1160 /* Xerox */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1161 static PurpleCmdRet
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1162 me_command_cb(PurpleConversation *conv,
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1163 const char *cmd, char **args, char **error, void *data)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1164 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1165 char *tmp;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1166
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1167 tmp = g_strdup_printf("/me %s", args[0]);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1168
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1169 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1170 purple_conv_im_send(PURPLE_CONV_IM(conv), tmp);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1171 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1172 purple_conv_chat_send(PURPLE_CONV_CHAT(conv), tmp);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1173
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1174 g_free(tmp);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1175 return PURPLE_CMD_RET_OK;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1176 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1177
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1178 /* Xerox */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1179 static PurpleCmdRet
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1180 debug_command_cb(PurpleConversation *conv,
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1181 const char *cmd, char **args, char **error, void *data)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1182 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1183 char *tmp, *markup;
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1184 PurpleCmdStatus status;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1185
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1186 if (!g_ascii_strcasecmp(args[0], "version")) {
21030
3cc856ca2338 Add a --with-extraversion option to ./configure so packagers can fine tune
Stu Tomlinson <stu@nosnilmot.com>
parents: 21000
diff changeset
1187 tmp = g_strdup_printf("me is using Finch v%s.", DISPLAY_VERSION);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1188 markup = g_markup_escape_text(tmp, -1);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1189
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1190 status = purple_cmd_do_command(conv, tmp, markup, error);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1191
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1192 g_free(tmp);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1193 g_free(markup);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1194 return status;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1195 } else {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1196 purple_conversation_write(conv, NULL, _("Supported debug options are: version"),
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1197 PURPLE_MESSAGE_NO_LOG|PURPLE_MESSAGE_ERROR, time(NULL));
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1198 return PURPLE_CMD_STATUS_OK;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1199 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1200 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1201
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1202 /* Xerox */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1203 static PurpleCmdRet
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1204 clear_command_cb(PurpleConversation *conv,
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1205 const char *cmd, char **args, char **error, void *data)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1206 {
22217
ad357ca94de9 We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22215
diff changeset
1207 FinchConv *ggconv = FINCH_GET_DATA(conv);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1208 gnt_text_view_clear(GNT_TEXT_VIEW(ggconv->tv));
19422
a277162b976e Clear the message history in the /clear callback.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19370
diff changeset
1209 purple_conversation_clear_message_history(conv);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1210 return PURPLE_CMD_STATUS_OK;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1211 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1212
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1213 /* Xerox */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1214 static PurpleCmdRet
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1215 help_command_cb(PurpleConversation *conv,
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1216 const char *cmd, char **args, char **error, void *data)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1217 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1218 GList *l, *text;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1219 GString *s;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1220
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1221 if (args[0] != NULL) {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1222 s = g_string_new("");
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1223 text = purple_cmd_help(conv, args[0]);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1224
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1225 if (text) {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1226 for (l = text; l; l = l->next)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1227 if (l->next)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1228 g_string_append_printf(s, "%s\n", (char *)l->data);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1229 else
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1230 g_string_append_printf(s, "%s", (char *)l->data);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1231 } else {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1232 g_string_append(s, _("No such command (in this context)."));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1233 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1234 } else {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1235 s = g_string_new(_("Use \"/help &lt;command&gt;\" for help on a specific command.\n"
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1236 "The following commands are available in this context:\n"));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1237
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1238 text = purple_cmd_list(conv);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1239 for (l = text; l; l = l->next)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1240 if (l->next)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1241 g_string_append_printf(s, "%s, ", (char *)l->data);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1242 else
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1243 g_string_append_printf(s, "%s.", (char *)l->data);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1244 g_list_free(text);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1245 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1246
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1247 purple_conversation_write(conv, NULL, s->str, PURPLE_MESSAGE_NO_LOG, time(NULL));
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1248 g_string_free(s, TRUE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1249
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1250 return PURPLE_CMD_STATUS_OK;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1251 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1252
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1253 static PurpleCmdRet
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1254 cmd_show_window(PurpleConversation *conv, const char *cmd, char **args, char **error, gpointer data)
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1255 {
22007
c38d72677c8a Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents: 21743
diff changeset
1256 void (*callback)(void) = data;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1257 callback();
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1258 return PURPLE_CMD_STATUS_OK;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1259 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1260
23833
240d847e9e88 Fix compiling with glib < 2.6
Stu Tomlinson <stu@nosnilmot.com>
parents: 23442
diff changeset
1261 #if GLIB_CHECK_VERSION(2,6,0)
16904
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1262 static PurpleCmdRet
23311
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1263 cmd_message_color(PurpleConversation *conv, const char *cmd, char **args, char **error, gpointer data)
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1264 {
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1265 int *msgclass = NULL;
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1266 int fg, bg;
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1267
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1268 if (strcmp(args[0], "receive") == 0)
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1269 msgclass = &color_message_receive;
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1270 else if (strcmp(args[0], "send") == 0)
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1271 msgclass = &color_message_send;
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1272 else if (strcmp(args[0], "highlight") == 0)
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1273 msgclass = &color_message_highlight;
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1274 else if (strcmp(args[0], "action") == 0)
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1275 msgclass = &color_message_action;
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1276 else if (strcmp(args[0], "timestamp") == 0)
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1277 msgclass = &color_timestamp;
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1278 else {
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1279 if (error)
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1280 *error = g_strdup_printf(_("%s is not a valid message class. See '/help msgcolor' for valid message classes."), args[0]);
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1281 return PURPLE_CMD_STATUS_FAILED;
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1282 }
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1283
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1284 fg = gnt_colors_get_color(args[1]);
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1285 if (fg == -EINVAL) {
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1286 if (error)
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1287 *error = g_strdup_printf(_("%s is not a valid color. See '/help msgcolor' for valid colors."), args[1]);
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1288 return PURPLE_CMD_STATUS_FAILED;
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1289 }
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1290
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1291 bg = gnt_colors_get_color(args[2]);
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1292 if (bg == -EINVAL) {
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1293 if (error)
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1294 *error = g_strdup_printf(_("%s is not a valid color. See '/help msgcolor' for valid colors."), args[2]);
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1295 return PURPLE_CMD_STATUS_FAILED;
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1296 }
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1297
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1298 init_pair(*msgclass, fg, bg);
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1299
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1300 return PURPLE_CMD_STATUS_OK;
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1301 }
23833
240d847e9e88 Fix compiling with glib < 2.6
Stu Tomlinson <stu@nosnilmot.com>
parents: 23442
diff changeset
1302 #endif
23311
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1303
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1304 static PurpleCmdRet
16904
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1305 users_command_cb(PurpleConversation *conv, const char *cmd, char **args, char **error, gpointer data)
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1306 {
22217
ad357ca94de9 We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22215
diff changeset
1307 FinchConv *fc = FINCH_GET_DATA(conv);
16904
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1308 FinchConvChat *ch;
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1309 if (!fc)
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1310 return PURPLE_CMD_STATUS_FAILED;
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1311
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1312 ch = fc->u.chat;
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1313 gnt_widget_set_visible(ch->userlist,
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1314 (GNT_WIDGET_IS_FLAG_SET(ch->userlist, GNT_WIDGET_INVISIBLE)));
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1315 gnt_box_readjust(GNT_BOX(fc->window));
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1316 gnt_box_give_focus_to_child(GNT_BOX(fc->window), fc->entry);
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1317 purple_prefs_set_bool(PREF_USERLIST, !(GNT_WIDGET_IS_FLAG_SET(ch->userlist, GNT_WIDGET_INVISIBLE)));
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1318 return PURPLE_CMD_STATUS_OK;
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1319 }
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1320
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1321 void finch_conversation_init()
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1322 {
21738
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
1323 color_message_send = gnt_style_get_color(NULL, "color-message-sent");
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
1324 if (!color_message_send)
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
1325 color_message_send = gnt_color_add_pair(COLOR_CYAN, -1);
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
1326 color_message_receive = gnt_style_get_color(NULL, "color-message-received");
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
1327 if (!color_message_receive)
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
1328 color_message_receive = gnt_color_add_pair(COLOR_RED, -1);
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
1329 color_message_highlight = gnt_style_get_color(NULL, "color-message-highlight");
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
1330 if (!color_message_highlight)
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
1331 color_message_highlight = gnt_color_add_pair(COLOR_GREEN, -1);
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
1332 color_timestamp = gnt_style_get_color(NULL, "color-timestamp");
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
1333 if (!color_timestamp)
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
1334 color_timestamp = gnt_color_add_pair(COLOR_BLUE, -1);
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
1335 color_message_action = gnt_style_get_color(NULL, "color-message-action");
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
1336 if (!color_message_action)
e3e64d1e4869 Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents: 21284
diff changeset
1337 color_message_action = gnt_color_add_pair(COLOR_YELLOW, -1);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1338 purple_prefs_add_none(PREF_ROOT);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1339 purple_prefs_add_none(PREF_ROOT "/size");
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1340 purple_prefs_add_int(PREF_ROOT "/size/width", 70);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1341 purple_prefs_add_int(PREF_ROOT "/size/height", 20);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1342 purple_prefs_add_none(PREF_ROOT "/position");
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1343 purple_prefs_add_int(PREF_ROOT "/position/x", 0);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1344 purple_prefs_add_int(PREF_ROOT "/position/y", 0);
16904
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1345 purple_prefs_add_none(PREF_CHAT);
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1346 purple_prefs_add_bool(PREF_USERLIST, FALSE);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1347
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1348 /* Xerox the commands */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1349 purple_cmd_register("say", "S", PURPLE_CMD_P_DEFAULT,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1350 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL,
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1351 say_command_cb, _("say &lt;message&gt;: Send a message normally as if you weren't using a command."), NULL);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1352 purple_cmd_register("me", "S", PURPLE_CMD_P_DEFAULT,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1353 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL,
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1354 me_command_cb, _("me &lt;action&gt;: Send an IRC style action to a buddy or chat."), NULL);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1355 purple_cmd_register("debug", "w", PURPLE_CMD_P_DEFAULT,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1356 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL,
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1357 debug_command_cb, _("debug &lt;option&gt;: Send various debug information to the current conversation."), NULL);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1358 purple_cmd_register("clear", "", PURPLE_CMD_P_DEFAULT,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1359 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL,
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1360 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1361 purple_cmd_register("help", "w", PURPLE_CMD_P_DEFAULT,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1362 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, NULL,
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1363 help_command_cb, _("help &lt;command&gt;: Help on a specific command."), NULL);
16904
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1364 purple_cmd_register("users", "", PURPLE_CMD_P_DEFAULT,
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1365 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, NULL,
b799918b6cdc Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16903
diff changeset
1366 users_command_cb, _("users: Show the list of users in the chat."), NULL);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1367
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1368 /* Now some commands to bring up some other windows */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1369 purple_cmd_register("plugins", "", PURPLE_CMD_P_DEFAULT,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1370 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL,
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1371 cmd_show_window, _("plugins: Show the plugins window."), finch_plugins_show_all);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1372 purple_cmd_register("buddylist", "", PURPLE_CMD_P_DEFAULT,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1373 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL,
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1374 cmd_show_window, _("buddylist: Show the buddylist."), finch_blist_show);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1375 purple_cmd_register("accounts", "", PURPLE_CMD_P_DEFAULT,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1376 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL,
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1377 cmd_show_window, _("accounts: Show the accounts window."), finch_accounts_show_all);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1378 purple_cmd_register("debugwin", "", PURPLE_CMD_P_DEFAULT,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1379 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL,
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1380 cmd_show_window, _("debugwin: Show the debug window."), finch_debug_window_show);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1381 purple_cmd_register("prefs", "", PURPLE_CMD_P_DEFAULT,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1382 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL,
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1383 cmd_show_window, _("prefs: Show the preference window."), finch_prefs_show_all);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1384 purple_cmd_register("status", "", PURPLE_CMD_P_DEFAULT,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1385 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL,
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1386 cmd_show_window, _("statuses: Show the savedstatuses window."), finch_savedstatus_show_all);
17032
d6e855aedc30 Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16989
diff changeset
1387
23833
240d847e9e88 Fix compiling with glib < 2.6
Stu Tomlinson <stu@nosnilmot.com>
parents: 23442
diff changeset
1388 #if GLIB_CHECK_VERSION(2,6,0)
23311
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1389 /* Allow customizing the message colors using a command during run-time */
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1390 purple_cmd_register("msgcolor", "www", PURPLE_CMD_P_DEFAULT,
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1391 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL,
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1392 cmd_message_color, _("msgcolor &lt;class&gt; &lt;foreground&gt; &lt;background&gt;: "
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1393 "Set the color for different classes of messages in the conversation window.<br>"
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1394 " &lt;class&gt;: receive, send, highlight, action, timestamp<br>"
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1395 " &lt;foreground/background&gt;: black, red, green, blue, white, gray, darkgray, magenta, cyan, default<br><br>"
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1396 "EXAMPLE:<br> msgcolor send cyan default"),
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1397 NULL);
23833
240d847e9e88 Fix compiling with glib < 2.6
Stu Tomlinson <stu@nosnilmot.com>
parents: 23442
diff changeset
1398 #endif
23311
ea341703b1d3 msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23233
diff changeset
1399
17032
d6e855aedc30 Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16989
diff changeset
1400 purple_signal_connect(purple_conversations_get_handle(), "buddy-typing", finch_conv_get_handle(),
d6e855aedc30 Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16989
diff changeset
1401 PURPLE_CALLBACK(update_buddy_typing), NULL);
d6e855aedc30 Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16989
diff changeset
1402 purple_signal_connect(purple_conversations_get_handle(), "buddy-typing-stopped", finch_conv_get_handle(),
d6e855aedc30 Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16989
diff changeset
1403 PURPLE_CALLBACK(update_buddy_typing), NULL);
d6e855aedc30 Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16989
diff changeset
1404 purple_signal_connect(purple_conversations_get_handle(), "chat-left", finch_conv_get_handle(),
d6e855aedc30 Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16989
diff changeset
1405 PURPLE_CALLBACK(chat_left_cb), NULL);
19321
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
1406 purple_signal_connect(purple_blist_get_handle(), "buddy-signed-on", finch_conv_get_handle(),
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
1407 PURPLE_CALLBACK(buddy_signed_on_off), NULL);
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
1408 purple_signal_connect(purple_blist_get_handle(), "buddy-signed-off", finch_conv_get_handle(),
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
1409 PURPLE_CALLBACK(buddy_signed_on_off), NULL);
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
1410 purple_signal_connect(purple_connections_get_handle(), "signed-on", finch_conv_get_handle(),
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
1411 PURPLE_CALLBACK(account_signed_on_off), NULL);
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
1412 purple_signal_connect(purple_connections_get_handle(), "signed-off", finch_conv_get_handle(),
39d3a81a5850 Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18637
diff changeset
1413 PURPLE_CALLBACK(account_signed_on_off), NULL);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1414 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1415
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1416 void finch_conversation_uninit()
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1417 {
17032
d6e855aedc30 Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16989
diff changeset
1418 purple_signals_disconnect_by_handle(finch_conv_get_handle());
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1419 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1420
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1421 void finch_conversation_set_active(PurpleConversation *conv)
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1422 {
22217
ad357ca94de9 We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22215
diff changeset
1423 FinchConv *ggconv = FINCH_GET_DATA(conv);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1424 PurpleAccount *account;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1425 char *title;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1426
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1427 g_return_if_fail(ggconv);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1428 g_return_if_fail(g_list_find(ggconv->list, conv));
23415
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
1429 if (ggconv->active_conv == conv)
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
1430 return;
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1431
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1432 ggconv->active_conv = conv;
23415
a2c625152c52 Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23363
diff changeset
1433 gg_setup_commands(ggconv, TRUE);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15818
diff changeset
1434 account = purple_conversation_get_account(conv);
15818
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1435 title = get_conversation_title(conv, account);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1436 gnt_screen_rename_widget(ggconv->window, title);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1437 g_free(title);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1438 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1439
16128
7a2ffa981c1a Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16124
diff changeset
1440 void finch_conversation_set_info_widget(PurpleConversation *conv, GntWidget *widget)
7a2ffa981c1a Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16124
diff changeset
1441 {
22217
ad357ca94de9 We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22215
diff changeset
1442 FinchConv *fc = FINCH_GET_DATA(conv);
16128
7a2ffa981c1a Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16124
diff changeset
1443 int height, width;
7a2ffa981c1a Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16124
diff changeset
1444
7a2ffa981c1a Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16124
diff changeset
1445 gnt_box_remove_all(GNT_BOX(fc->info));
7a2ffa981c1a Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16124
diff changeset
1446
7a2ffa981c1a Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16124
diff changeset
1447 if (widget) {
7a2ffa981c1a Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16124
diff changeset
1448 gnt_box_add_widget(GNT_BOX(fc->info), widget);
7a2ffa981c1a Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16124
diff changeset
1449 gnt_box_readjust(GNT_BOX(fc->info));
7a2ffa981c1a Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16124
diff changeset
1450 }
7a2ffa981c1a Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16124
diff changeset
1451
7a2ffa981c1a Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16124
diff changeset
1452 gnt_widget_get_size(fc->window, &width, &height);
7a2ffa981c1a Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16124
diff changeset
1453 gnt_box_readjust(GNT_BOX(fc->window));
7a2ffa981c1a Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16124
diff changeset
1454 gnt_screen_resize_widget(fc->window, width, height);
7a2ffa981c1a Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16124
diff changeset
1455 gnt_box_give_focus_to_child(GNT_BOX(fc->window), fc->entry);
7a2ffa981c1a Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16124
diff changeset
1456 }
7a2ffa981c1a Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16124
diff changeset
1457