Mercurial > pidgin
annotate finch/gntconv.c @ 20908:9ec0382e6c8d
Fix the searchresult thingy nosnilmot fixed in pidgin.
(re: 1b3703e5ff3c0f274efc9a1dafdcf940ef9acd72)
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Fri, 12 Oct 2007 21:39:31 +0000 |
parents | 15f61e6b15cd |
children | 89c7be36fd61 d7d3f31d52fb |
rev | line source |
---|---|
15817 | 1 /** |
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:
19778
diff
changeset
|
4 */ |
6b8bc3309ab7
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@wiktel.com>
parents:
19778
diff
changeset
|
5 |
6b8bc3309ab7
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@wiktel.com>
parents:
19778
diff
changeset
|
6 /* finch |
15817 | 7 * |
15870
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
8 * Finch is the legal property of its developers, whose names are too numerous |
15817 | 9 * to list here. Please refer to the COPYRIGHT file distributed with this |
10 * source distribution. | |
11 * | |
12 * This program is free software; you can redistribute it and/or modify | |
13 * it under the terms of the GNU General Public License as published by | |
14 * the Free Software Foundation; either version 2 of the License, or | |
15 * (at your option) any later version. | |
16 * | |
17 * This program is distributed in the hope that it will be useful, | |
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 * GNU General Public License for more details. | |
21 * | |
22 * You should have received a copy of the GNU General Public License | |
23 * along with this program; if not, write to the Free Software | |
19681
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19632
diff
changeset
|
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15817 | 25 */ |
26 #include <string.h> | |
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" |
b8572b937c09
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents:
18100
diff
changeset
|
29 |
15817 | 30 #include <cmds.h> |
31 #include <idle.h> | |
32 #include <prefs.h> | |
33 #include <util.h> | |
34 | |
35 #include "gntaccount.h" | |
36 #include "gntblist.h" | |
37 #include "gntconv.h" | |
38 #include "gntdebug.h" | |
39 #include "gntplugin.h" | |
40 #include "gntprefs.h" | |
19447
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
41 #include "gntsound.h" |
15817 | 42 #include "gntstatus.h" |
16892 | 43 #include "gntpounce.h" |
15817 | 44 |
45 #include "gnt.h" | |
46 #include "gntbox.h" | |
47 #include "gntentry.h" | |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
48 #include "gntlabel.h" |
16892 | 49 #include "gntmenu.h" |
50 #include "gntmenuitem.h" | |
51 #include "gntmenuitemcheck.h" | |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
52 #include "gnttextview.h" |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
53 #include "gnttree.h" |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
54 #include "gntutils.h" |
16892 | 55 #include "gntwindow.h" |
15817 | 56 |
16424
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
|
57 #define PREF_ROOT "/finch/conversations" |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
58 #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:
16892
diff
changeset
|
59 #define PREF_USERLIST PREF_CHAT "/userlist" |
15817 | 60 |
61 #include "config.h" | |
62 | |
17021
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
63 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:
16978
diff
changeset
|
64 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
|
65 static void generate_send_to_menu(FinchConv *ggc); |
17021
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
66 |
19778
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
67 static PurpleBlistNode * |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
68 get_conversation_blist_node(PurpleConversation *conv) |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
69 { |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
70 PurpleBlistNode *node = NULL; |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
71 |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
72 switch (purple_conversation_get_type(conv)) { |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
73 case PURPLE_CONV_TYPE_IM: |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
74 node = (PurpleBlistNode*)purple_find_buddy(conv->account, conv->name); |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
75 node = node ? node->parent : NULL; |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
76 break; |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
77 case PURPLE_CONV_TYPE_CHAT: |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
78 node = (PurpleBlistNode*)purple_blist_find_chat(conv->account, conv->name); |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
79 break; |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
80 default: |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
81 break; |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
82 } |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
83 return node; |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
84 } |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
85 |
15817 | 86 static void |
87 send_typing_notification(GntWidget *w, FinchConv *ggconv) | |
88 { | |
89 const char *text = gnt_entry_get_text(GNT_ENTRY(ggconv->entry)); | |
17813
289ac53f753f
Do not send typing notification if you are typing a /-command.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17750
diff
changeset
|
90 gboolean empty = (!text || !*text || (*text == '/')); |
16424
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
|
91 if (purple_prefs_get_bool("/finch/conversations/notify_typing")) { |
15822 | 92 PurpleConversation *conv = ggconv->active_conv; |
93 PurpleConvIm *im = PURPLE_CONV_IM(conv); | |
15817 | 94 if (!empty) { |
15822 | 95 gboolean send = (purple_conv_im_get_send_typed_timeout(im) == 0); |
15817 | 96 |
15822 | 97 purple_conv_im_stop_send_typed_timeout(im); |
98 purple_conv_im_start_send_typed_timeout(im); | |
99 if (send || (purple_conv_im_get_type_again(im) != 0 && | |
100 time(NULL) > purple_conv_im_get_type_again(im))) { | |
15817 | 101 unsigned int timeout; |
15822 | 102 timeout = serv_send_typing(purple_conversation_get_gc(conv), |
103 purple_conversation_get_name(conv), | |
104 PURPLE_TYPING); | |
105 purple_conv_im_set_type_again(im, timeout); | |
15817 | 106 } |
107 } else { | |
15822 | 108 purple_conv_im_stop_send_typed_timeout(im); |
15817 | 109 |
15822 | 110 serv_send_typing(purple_conversation_get_gc(conv), |
111 purple_conversation_get_name(conv), | |
112 PURPLE_NOT_TYPING); | |
15817 | 113 } |
114 } | |
115 } | |
116 | |
117 static gboolean | |
118 entry_key_pressed(GntWidget *w, const char *key, FinchConv *ggconv) | |
119 { | |
120 if (key[0] == '\r' && key[1] == 0) | |
121 { | |
122 const char *text = gnt_entry_get_text(GNT_ENTRY(ggconv->entry)); | |
123 if (*text == '/') | |
124 { | |
15822 | 125 PurpleConversation *conv = ggconv->active_conv; |
126 PurpleCmdStatus status; | |
15817 | 127 const char *cmdline = text + 1; |
128 char *error = NULL, *escape; | |
129 | |
130 escape = g_markup_escape_text(cmdline, -1); | |
15822 | 131 status = purple_cmd_do_command(conv, cmdline, escape, &error); |
15817 | 132 g_free(escape); |
133 | |
134 switch (status) | |
135 { | |
15822 | 136 case PURPLE_CMD_STATUS_OK: |
15817 | 137 break; |
15822 | 138 case PURPLE_CMD_STATUS_NOT_FOUND: |
139 purple_conversation_write(conv, "", _("No such command."), | |
140 PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
15817 | 141 break; |
15822 | 142 case PURPLE_CMD_STATUS_WRONG_ARGS: |
143 purple_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " | |
15817 | 144 "to that command."), |
15822 | 145 PURPLE_MESSAGE_NO_LOG, time(NULL)); |
15817 | 146 break; |
15822 | 147 case PURPLE_CMD_STATUS_FAILED: |
148 purple_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), | |
149 PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
15817 | 150 break; |
15822 | 151 case PURPLE_CMD_STATUS_WRONG_TYPE: |
152 if(purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) | |
153 purple_conversation_write(conv, "", _("That command only works in chats, not IMs."), | |
154 PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
15817 | 155 else |
15822 | 156 purple_conversation_write(conv, "", _("That command only works in IMs, not chats."), |
157 PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
15817 | 158 break; |
15822 | 159 case PURPLE_CMD_STATUS_WRONG_PRPL: |
160 purple_conversation_write(conv, "", _("That command doesn't work on this protocol."), | |
161 PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
15817 | 162 break; |
163 } | |
164 g_free(error); | |
165 } | |
19370
9c03677be7c5
Notify the user if a message is not sent in a conversation because he's disconnected.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19321
diff
changeset
|
166 else if (!purple_account_is_connected(ggconv->active_conv->account)) |
9c03677be7c5
Notify the user if a message is not sent in a conversation because he's disconnected.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19321
diff
changeset
|
167 { |
9c03677be7c5
Notify the user if a message is not sent in a conversation because he's disconnected.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19321
diff
changeset
|
168 purple_conversation_write(ggconv->active_conv, "", _("Message was not sent, because you are not signed on."), |
9c03677be7c5
Notify the user if a message is not sent in a conversation because he's disconnected.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19321
diff
changeset
|
169 PURPLE_MESSAGE_ERROR | PURPLE_MESSAGE_NO_LOG, time(NULL)); |
9c03677be7c5
Notify the user if a message is not sent in a conversation because he's disconnected.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19321
diff
changeset
|
170 } |
15817 | 171 else |
172 { | |
173 char *escape = g_markup_escape_text(text, -1); | |
15822 | 174 char *apos = purple_strreplace(escape, "'", "'"); |
15817 | 175 g_free(escape); |
176 escape = apos; | |
15822 | 177 switch (purple_conversation_get_type(ggconv->active_conv)) |
15817 | 178 { |
15822 | 179 case PURPLE_CONV_TYPE_IM: |
180 purple_conv_im_send_with_flags(PURPLE_CONV_IM(ggconv->active_conv), escape, PURPLE_MESSAGE_SEND); | |
15817 | 181 break; |
15822 | 182 case PURPLE_CONV_TYPE_CHAT: |
183 purple_conv_chat_send(PURPLE_CONV_CHAT(ggconv->active_conv), escape); | |
15817 | 184 break; |
185 default: | |
186 g_free(escape); | |
187 g_return_val_if_reached(FALSE); | |
188 } | |
189 g_free(escape); | |
15822 | 190 purple_idle_touch(); |
15817 | 191 } |
192 gnt_entry_add_to_history(GNT_ENTRY(ggconv->entry), text); | |
193 gnt_entry_clear(GNT_ENTRY(ggconv->entry)); | |
194 return TRUE; | |
195 } | |
196 | |
197 return FALSE; | |
198 } | |
199 | |
200 static void | |
201 closing_window(GntWidget *window, FinchConv *ggconv) | |
202 { | |
203 GList *list = ggconv->list; | |
204 ggconv->window = NULL; | |
205 while (list) { | |
15822 | 206 PurpleConversation *conv = list->data; |
15817 | 207 list = list->next; |
15822 | 208 purple_conversation_destroy(conv); |
15817 | 209 } |
210 } | |
211 | |
212 static void | |
213 size_changed_cb(GntWidget *widget, int width, int height) | |
214 { | |
215 int w, h; | |
216 gnt_widget_get_size(widget, &w, &h); | |
15822 | 217 purple_prefs_set_int(PREF_ROOT "/size/width", w); |
218 purple_prefs_set_int(PREF_ROOT "/size/height", h); | |
15817 | 219 } |
220 | |
221 static void | |
222 save_position_cb(GntWidget *w, int x, int y) | |
223 { | |
15822 | 224 purple_prefs_set_int(PREF_ROOT "/position/x", x); |
225 purple_prefs_set_int(PREF_ROOT "/position/y", y); | |
15817 | 226 } |
227 | |
15822 | 228 static PurpleConversation * |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
229 find_conv_with_contact(PurpleAccount *account, const char *name) |
15817 | 230 { |
15822 | 231 PurpleBlistNode *node; |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
232 PurpleBuddy *buddy = purple_find_buddy(account, name); |
15822 | 233 PurpleConversation *ret = NULL; |
15817 | 234 |
235 if (!buddy) | |
236 return NULL; | |
237 | |
15822 | 238 for (node = ((PurpleBlistNode*)buddy)->parent->child; node; node = node->next) { |
239 if (node == (PurpleBlistNode*)buddy) | |
15817 | 240 continue; |
15822 | 241 if ((ret = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, |
242 ((PurpleBuddy*)node)->name, ((PurpleBuddy*)node)->account)) != NULL) | |
15817 | 243 break; |
244 } | |
245 return ret; | |
246 } | |
247 | |
248 static char * | |
15822 | 249 get_conversation_title(PurpleConversation *conv, PurpleAccount *account) |
15817 | 250 { |
15822 | 251 return g_strdup_printf(_("%s (%s -- %s)"), purple_conversation_get_title(conv), |
252 purple_account_get_username(account), purple_account_get_protocol_name(account)); | |
15817 | 253 } |
254 | |
255 static void | |
15822 | 256 update_buddy_typing(PurpleAccount *account, const char *who, gpointer null) |
15817 | 257 { |
15822 | 258 PurpleConversation *conv; |
15817 | 259 FinchConv *ggc; |
15822 | 260 PurpleConvIm *im = NULL; |
15817 | 261 char *title, *str; |
262 | |
15822 | 263 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, who, account); |
15817 | 264 |
265 if (!conv) | |
266 return; | |
267 | |
15822 | 268 im = PURPLE_CONV_IM(conv); |
15817 | 269 ggc = conv->ui_data; |
270 | |
15822 | 271 if (purple_conv_im_get_typing_state(im) == PURPLE_TYPING) { |
15817 | 272 int scroll; |
273 str = get_conversation_title(conv, account); | |
274 title = g_strdup_printf(_("%s [%s]"), str, | |
275 gnt_ascii_only() ? "T" : "\342\243\277"); | |
276 g_free(str); | |
277 | |
278 scroll = gnt_text_view_get_lines_below(GNT_TEXT_VIEW(ggc->tv)); | |
15822 | 279 str = g_strdup_printf(_("\n%s is typing..."), purple_conversation_get_name(conv)); |
15817 | 280 /* Updating is a little buggy. So just remove and add a new one */ |
281 gnt_text_view_tag_change(GNT_TEXT_VIEW(ggc->tv), "typing", NULL, TRUE); | |
282 gnt_text_view_append_text_with_tag(GNT_TEXT_VIEW(ggc->tv), | |
283 str, GNT_TEXT_FLAG_DIM, "typing"); | |
284 g_free(str); | |
285 if (scroll <= 1) | |
286 gnt_text_view_scroll(GNT_TEXT_VIEW(ggc->tv), 0); | |
287 } else { | |
288 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
|
289 gnt_text_view_tag_change(GNT_TEXT_VIEW(ggc->tv), "typing", " ", TRUE); |
15817 | 290 } |
291 gnt_screen_rename_widget(ggc->window, title); | |
292 g_free(title); | |
293 } | |
294 | |
17021
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
295 static void |
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
296 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:
16978
diff
changeset
|
297 { |
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
298 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:
16978
diff
changeset
|
299 PURPLE_MESSAGE_SYSTEM, time(NULL)); |
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
300 } |
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
301 |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
302 static void |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
303 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
|
304 { |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
305 PurpleConversation *conv = find_conv_with_contact(buddy->account, buddy->name); |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
306 if (conv == NULL) |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
307 return; |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
308 generate_send_to_menu(conv->ui_data); |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
309 } |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
310 |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
311 static void |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
312 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
|
313 { |
20053
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19778
diff
changeset
|
314 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:
19778
diff
changeset
|
315 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:
19778
diff
changeset
|
316 PurpleConversation *conv = list->data; |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
317 PurpleConversation *cc = find_conv_with_contact(conv->account, conv->name); |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
318 if (cc) |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
319 generate_send_to_menu(cc->ui_data); |
20053
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19778
diff
changeset
|
320 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:
19778
diff
changeset
|
321 } |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19778
diff
changeset
|
322 |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19778
diff
changeset
|
323 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:
19778
diff
changeset
|
324 /* 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:
19778
diff
changeset
|
325 * 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:
19778
diff
changeset
|
326 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:
19778
diff
changeset
|
327 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:
19778
diff
changeset
|
328 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:
19778
diff
changeset
|
329 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
|
330 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:
19778
diff
changeset
|
331 |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19778
diff
changeset
|
332 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:
19778
diff
changeset
|
333 if (conv->account != gc->account || |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19778
diff
changeset
|
334 !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:
19778
diff
changeset
|
335 continue; |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19778
diff
changeset
|
336 |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19778
diff
changeset
|
337 chat = purple_blist_find_chat(conv->account, conv->name); |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19778
diff
changeset
|
338 if (chat == NULL) { |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19778
diff
changeset
|
339 if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults != NULL) |
20552
b7460582a135
Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
340 comps = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, conv->name); |
b7460582a135
Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
341 } else { |
b7460582a135
Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
342 comps = chat->components; |
20053
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19778
diff
changeset
|
343 } |
20552
b7460582a135
Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
344 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
|
345 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
|
346 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:
19778
diff
changeset
|
347 } |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
348 } |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
349 } |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
350 |
15817 | 351 static gpointer |
352 finch_conv_get_handle() | |
353 { | |
354 static int handle; | |
355 return &handle; | |
356 } | |
357 | |
358 static void | |
16892 | 359 clear_scrollback_cb(GntMenuItem *item, gpointer ggconv) |
360 { | |
361 FinchConv *ggc = ggconv; | |
362 gnt_text_view_clear(GNT_TEXT_VIEW(ggc->tv)); | |
363 } | |
364 | |
365 static void | |
366 send_file_cb(GntMenuItem *item, gpointer ggconv) | |
367 { | |
368 FinchConv *ggc = ggconv; | |
369 serv_send_file(purple_conversation_get_gc(ggc->active_conv), | |
370 purple_conversation_get_name(ggc->active_conv), NULL); | |
371 } | |
372 | |
373 static void | |
374 add_pounce_cb(GntMenuItem *item, gpointer ggconv) | |
375 { | |
376 FinchConv *ggc = ggconv; | |
377 finch_pounce_editor_show( | |
378 purple_conversation_get_account(ggc->active_conv), | |
379 purple_conversation_get_name(ggc->active_conv), NULL); | |
380 } | |
381 | |
382 static void | |
383 get_info_cb(GntMenuItem *item, gpointer ggconv) | |
384 { | |
385 FinchConv *ggc = ggconv; | |
17750
319bcb73eb4e
Use utility functions to get user info. Closes #964.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
386 finch_retrieve_user_info(purple_conversation_get_gc(ggc->active_conv), |
16892 | 387 purple_conversation_get_name(ggc->active_conv)); |
388 } | |
389 | |
390 static void | |
391 toggle_timestamps_cb(GntMenuItem *item, gpointer ggconv) | |
392 { | |
393 purple_prefs_set_bool(PREF_ROOT "/timestamps", | |
394 !purple_prefs_get_bool(PREF_ROOT "/timestamps")); | |
395 } | |
396 | |
397 static void | |
19445
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
398 toggle_logging_cb(GntMenuItem *item, gpointer ggconv) |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
399 { |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
400 FinchConv *fc = ggconv; |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
401 PurpleConversation *conv = fc->active_conv; |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
402 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
|
403 GList *iter; |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
404 |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
405 if (logging == purple_conversation_is_logging(conv)) |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
406 return; |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
407 |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
408 /* Xerox */ |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
409 if (logging) { |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
410 /* 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
|
411 purple_conversation_set_logging(conv, TRUE); |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
412 |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
413 purple_conversation_write(conv, NULL, |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
414 _("Logging started. Future messages in this conversation will be logged."), |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
415 conv->logs ? (PURPLE_MESSAGE_SYSTEM) : |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
416 (PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG), |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
417 time(NULL)); |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
418 } else { |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
419 purple_conversation_write(conv, NULL, |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
420 _("Logging stopped. Future messages in this conversation will not be logged."), |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
421 conv->logs ? (PURPLE_MESSAGE_SYSTEM) : |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
422 (PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG), |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
423 time(NULL)); |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
424 |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
425 /* 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
|
426 purple_conversation_set_logging(conv, FALSE); |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
427 } |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
428 |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
429 /* 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
|
430 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
|
431 if (iter->data == conv) |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
432 continue; |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
433 purple_conversation_set_logging(iter->data, logging); |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
434 } |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
435 } |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
436 |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
437 static void |
19447
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
438 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
|
439 { |
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
440 FinchConv *fc = ggconv; |
19778
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
441 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
|
442 fc->flags ^= FINCH_CONV_NO_SOUND; |
19778
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
443 if (node) |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
444 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
|
445 } |
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
446 |
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
447 static void |
16892 | 448 send_to_cb(GntMenuItem *m, gpointer n) |
449 { | |
450 PurpleAccount *account = g_object_get_data(G_OBJECT(m), "purple_account"); | |
451 gchar *buddy = g_object_get_data(G_OBJECT(m), "purple_buddy_name"); | |
452 PurpleConversation *conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, buddy); | |
453 finch_conversation_set_active(conv); | |
454 } | |
455 | |
456 static void | |
457 generate_send_to_menu(FinchConv *ggc) | |
458 { | |
459 GntWidget *sub, *menu = ggc->menu; | |
460 GntMenuItem *item; | |
461 GSList *buds; | |
462 GList *list = NULL; | |
463 | |
464 buds = purple_find_buddies(ggc->active_conv->account, ggc->active_conv->name); | |
465 if (!buds) | |
466 return; | |
467 | |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
468 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
|
469 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
|
470 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
|
471 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
|
472 } |
16892 | 473 sub = gnt_menu_new(GNT_MENU_POPUP); |
474 gnt_menuitem_set_submenu(item, GNT_MENU(sub)); | |
475 | |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
476 for (; buds; buds = g_slist_delete_link(buds, buds)) { |
16892 | 477 PurpleBlistNode *node = (PurpleBlistNode *)purple_buddy_get_contact((PurpleBuddy *)buds->data); |
478 for (node = node->child; node != NULL; node = node->next) { | |
479 PurpleBuddy *buddy = (PurpleBuddy *)node; | |
480 PurpleAccount *account = purple_buddy_get_account(buddy); | |
481 if (purple_account_is_connected(account)) { | |
482 /* Use the PurplePresence to get unique buddies. */ | |
483 PurplePresence *presence = purple_buddy_get_presence(buddy); | |
484 if (!g_list_find(list, presence)) | |
485 list = g_list_prepend(list, presence); | |
486 } | |
487 } | |
488 } | |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
489 for (list = g_list_reverse(list); list != NULL; list = g_list_delete_link(list, list)) { |
16892 | 490 PurplePresence *pre = list->data; |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
491 PurpleBuddy *buddy = purple_presence_get_buddy(pre); |
16892 | 492 PurpleAccount *account = purple_buddy_get_account(buddy); |
493 gchar *name = g_strdup(purple_buddy_get_name(buddy)); | |
494 gchar *text = g_strdup_printf("%s (%s)", purple_buddy_get_name(buddy), purple_account_get_username(account)); | |
495 item = gnt_menuitem_new(text); | |
496 g_free(text); | |
497 gnt_menu_add_item(GNT_MENU(sub), item); | |
498 gnt_menuitem_set_callback(item, send_to_cb, NULL); | |
499 g_object_set_data(G_OBJECT(item), "purple_account", account); | |
500 g_object_set_data_full(G_OBJECT(item), "purple_buddy_name", name, g_free); | |
501 } | |
502 } | |
503 | |
504 static void | |
505 gg_create_menu(FinchConv *ggc) | |
506 { | |
507 GntWidget *menu, *sub; | |
508 GntMenuItem *item; | |
509 | |
510 ggc->menu = menu = gnt_menu_new(GNT_MENU_TOPLEVEL); | |
511 gnt_window_set_menu(GNT_WINDOW(ggc->window), GNT_MENU(menu)); | |
512 | |
513 item = gnt_menuitem_new(_("Conversation")); | |
514 gnt_menu_add_item(GNT_MENU(menu), item); | |
515 | |
516 sub = gnt_menu_new(GNT_MENU_POPUP); | |
517 gnt_menuitem_set_submenu(item, GNT_MENU(sub)); | |
518 | |
519 item = gnt_menuitem_new(_("Clear Scrollback")); | |
520 gnt_menu_add_item(GNT_MENU(sub), item); | |
521 gnt_menuitem_set_callback(item, clear_scrollback_cb, ggc); | |
522 | |
523 item = gnt_menuitem_check_new(_("Show Timestamps")); | |
524 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item), | |
525 purple_prefs_get_bool(PREF_ROOT "/timestamps")); | |
526 gnt_menu_add_item(GNT_MENU(sub), item); | |
527 gnt_menuitem_set_callback(item, toggle_timestamps_cb, ggc); | |
528 | |
529 if (purple_conversation_get_type(ggc->active_conv) == PURPLE_CONV_TYPE_IM) { | |
16958
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:
16930
diff
changeset
|
530 PurpleAccount *account = purple_conversation_get_account(ggc->active_conv); |
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:
16930
diff
changeset
|
531 PurplePluginProtocolInfo *pinfo = account->gc ? PURPLE_PLUGIN_PROTOCOL_INFO(account->gc->prpl) : NULL; |
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:
16930
diff
changeset
|
532 |
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:
16930
diff
changeset
|
533 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:
16930
diff
changeset
|
534 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:
16930
diff
changeset
|
535 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:
16930
diff
changeset
|
536 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:
16930
diff
changeset
|
537 } |
16892 | 538 |
539 item = gnt_menuitem_new(_("Add Buddy Pounce...")); | |
540 gnt_menu_add_item(GNT_MENU(sub), item); | |
541 gnt_menuitem_set_callback(item, add_pounce_cb, ggc); | |
542 | |
16958
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:
16930
diff
changeset
|
543 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:
16930
diff
changeset
|
544 (!pinfo->can_receive_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:
16930
diff
changeset
|
545 pinfo->can_receive_file(account->gc, purple_conversation_get_name(ggc->active_conv)))) { |
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:
16930
diff
changeset
|
546 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:
16930
diff
changeset
|
547 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:
16930
diff
changeset
|
548 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:
16930
diff
changeset
|
549 } |
16892 | 550 |
551 generate_send_to_menu(ggc); | |
552 } | |
19445
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
553 |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
554 item = gnt_menuitem_check_new(_("Enable Logging")); |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
555 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
|
556 purple_conversation_is_logging(ggc->active_conv)); |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
557 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
|
558 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
|
559 |
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
560 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
|
561 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
|
562 !(ggc->flags & FINCH_CONV_NO_SOUND)); |
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
563 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
|
564 gnt_menuitem_set_callback(item, toggle_sound_cb, ggc); |
16892 | 565 } |
566 | |
567 static void | |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
568 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:
16892
diff
changeset
|
569 { |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
570 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:
16892
diff
changeset
|
571 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:
16892
diff
changeset
|
572 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:
16892
diff
changeset
|
573 } |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
574 |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
575 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:
17813
diff
changeset
|
576 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:
17813
diff
changeset
|
577 { |
f63b3a23280d
Provide a 'unseen-count' data for the conversations so the dbus-docklet can use that information.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17813
diff
changeset
|
578 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:
17813
diff
changeset
|
579 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:
17813
diff
changeset
|
580 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:
17813
diff
changeset
|
581 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:
17813
diff
changeset
|
582 } |
f63b3a23280d
Provide a 'unseen-count' data for the conversations so the dbus-docklet can use that information.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17813
diff
changeset
|
583 } |
f63b3a23280d
Provide a 'unseen-count' data for the conversations so the dbus-docklet can use that information.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17813
diff
changeset
|
584 |
f63b3a23280d
Provide a 'unseen-count' data for the conversations so the dbus-docklet can use that information.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17813
diff
changeset
|
585 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
|
586 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
|
587 { |
9eb2f4d27990
Use the completion-signal to append a ': ' after a tab-completed nick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18232
diff
changeset
|
588 if (start == entry->start) |
9eb2f4d27990
Use the completion-signal to append a ': ' after a tab-completed nick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18232
diff
changeset
|
589 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
|
590 } |
9eb2f4d27990
Use the completion-signal to append a ': ' after a tab-completed nick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18232
diff
changeset
|
591 |
9eb2f4d27990
Use the completion-signal to append a ': ' after a tab-completed nick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18232
diff
changeset
|
592 static void |
15822 | 593 finch_create_conversation(PurpleConversation *conv) |
15817 | 594 { |
595 FinchConv *ggc = conv->ui_data; | |
596 char *title; | |
15822 | 597 PurpleConversationType type; |
598 PurpleConversation *cc; | |
599 PurpleAccount *account; | |
19778
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
600 PurpleBlistNode *convnode = NULL; |
15817 | 601 |
602 if (ggc) | |
603 return; | |
604 | |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
605 cc = find_conv_with_contact(conv->account, conv->name); |
15817 | 606 if (cc && cc->ui_data) |
607 ggc = cc->ui_data; | |
608 else | |
609 ggc = g_new0(FinchConv, 1); | |
610 | |
19445
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
611 /* 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
|
612 if (ggc->list) { |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
613 purple_conversation_set_logging(conv, |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
614 purple_conversation_is_logging(ggc->list->data)); |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
615 } |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
616 |
15817 | 617 ggc->list = g_list_prepend(ggc->list, conv); |
618 ggc->active_conv = conv; | |
619 conv->ui_data = ggc; | |
620 | |
621 if (cc && cc->ui_data) { | |
622 finch_conversation_set_active(conv); | |
623 return; | |
624 } | |
625 | |
15822 | 626 account = purple_conversation_get_account(conv); |
627 type = purple_conversation_get_type(conv); | |
15817 | 628 title = get_conversation_title(conv, account); |
629 | |
16892 | 630 ggc->window = gnt_vwindow_new(FALSE); |
15817 | 631 gnt_box_set_title(GNT_BOX(ggc->window), title); |
632 gnt_box_set_toplevel(GNT_BOX(ggc->window), TRUE); | |
633 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
|
634 |
2b1af79e768f
Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
635 switch(conv->type){ |
2b1af79e768f
Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
636 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
|
637 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
|
638 break; |
2b1af79e768f
Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
639 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
|
640 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
|
641 break; |
2b1af79e768f
Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
642 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
|
643 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
|
644 break; |
2b1af79e768f
Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
645 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
|
646 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
|
647 break; |
2b1af79e768f
Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
648 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
|
649 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
|
650 break; |
2b1af79e768f
Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
651 } |
15817 | 652 |
653 ggc->tv = gnt_text_view_new(); | |
654 gnt_widget_set_name(ggc->tv, "conversation-window-textview"); | |
15822 | 655 gnt_widget_set_size(ggc->tv, purple_prefs_get_int(PREF_ROOT "/size/width"), |
656 purple_prefs_get_int(PREF_ROOT "/size/height")); | |
15817 | 657 |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
658 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:
16892
diff
changeset
|
659 GntWidget *hbox, *tree; |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
660 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:
16892
diff
changeset
|
661 hbox = gnt_hbox_new(FALSE); |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
662 gnt_box_set_pad(GNT_BOX(hbox), 0); |
17070
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
663 tree = fc->userlist = gnt_tree_new_with_columns(2); |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
664 gnt_tree_set_col_width(GNT_TREE(tree), 0, 1); /* The flag column */ |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
665 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:
16892
diff
changeset
|
666 gnt_tree_set_hash_fns(GNT_TREE(tree), g_str_hash, g_str_equal, g_free); |
19632
61473f8a5e2b
Use the proper column for searching users in the chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19509
diff
changeset
|
667 gnt_tree_set_search_column(GNT_TREE(tree), 1); |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
668 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:
16892
diff
changeset
|
669 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:
16892
diff
changeset
|
670 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:
16892
diff
changeset
|
671 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:
16892
diff
changeset
|
672 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:
16892
diff
changeset
|
673 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:
16892
diff
changeset
|
674 } else { |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
675 ggc->u.im = g_new0(FinchConvIm, 1); |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
676 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:
16892
diff
changeset
|
677 } |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
678 |
16128
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
679 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
|
680 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
|
681 |
15817 | 682 ggc->entry = gnt_entry_new(NULL); |
683 gnt_box_add_widget(GNT_BOX(ggc->window), ggc->entry); | |
684 gnt_widget_set_name(ggc->entry, "conversation-window-entry"); | |
685 gnt_entry_set_history_length(GNT_ENTRY(ggc->entry), -1); | |
686 gnt_entry_set_word_suggest(GNT_ENTRY(ggc->entry), TRUE); | |
687 gnt_entry_set_always_suggest(GNT_ENTRY(ggc->entry), FALSE); | |
688 | |
16124
ab3f93232a2d
Add a utility function to assist scrolling in a textview.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15870
diff
changeset
|
689 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
|
690 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
|
691 |
15817 | 692 g_signal_connect_after(G_OBJECT(ggc->entry), "key_pressed", 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
|
693 g_signal_connect(G_OBJECT(ggc->entry), "completion", G_CALLBACK(completion_cb), NULL); |
15817 | 694 g_signal_connect(G_OBJECT(ggc->window), "destroy", G_CALLBACK(closing_window), ggc); |
695 | |
15822 | 696 gnt_widget_set_position(ggc->window, purple_prefs_get_int(PREF_ROOT "/position/x"), |
697 purple_prefs_get_int(PREF_ROOT "/position/y")); | |
15817 | 698 gnt_widget_show(ggc->window); |
699 | |
700 g_signal_connect(G_OBJECT(ggc->tv), "size_changed", G_CALLBACK(size_changed_cb), NULL); | |
701 g_signal_connect(G_OBJECT(ggc->window), "position_set", G_CALLBACK(save_position_cb), NULL); | |
702 | |
15822 | 703 if (type == PURPLE_CONV_TYPE_IM) { |
15817 | 704 g_signal_connect(G_OBJECT(ggc->entry), "text_changed", G_CALLBACK(send_typing_notification), ggc); |
705 } | |
706 | |
19778
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
707 convnode = get_conversation_blist_node(conv); |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
708 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:
19681
diff
changeset
|
709 !finch_sound_is_enabled()) |
19447
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
710 ggc->flags |= FINCH_CONV_NO_SOUND; |
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
711 |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
712 gg_create_menu(ggc); |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
713 |
15817 | 714 g_free(title); |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
715 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:
17813
diff
changeset
|
716 g_signal_connect(G_OBJECT(ggc->window), "gained-focus", G_CALLBACK(gained_focus_cb), ggc); |
15817 | 717 } |
718 | |
719 static void | |
15822 | 720 finch_destroy_conversation(PurpleConversation *conv) |
15817 | 721 { |
722 /* do stuff here */ | |
723 FinchConv *ggc = conv->ui_data; | |
724 ggc->list = g_list_remove(ggc->list, conv); | |
725 if (ggc->list && conv == ggc->active_conv) | |
726 ggc->active_conv = ggc->list->data; | |
727 | |
728 if (ggc->list == NULL) { | |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
729 g_free(ggc->u.chat); |
18222
ef65d43190e5
Fix a few runtime warnings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
730 if (ggc->window) |
ef65d43190e5
Fix a few runtime warnings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
731 gnt_widget_destroy(ggc->window); |
15817 | 732 g_free(ggc); |
733 } | |
734 } | |
735 | |
736 static void | |
15822 | 737 finch_write_common(PurpleConversation *conv, const char *who, const char *message, |
738 PurpleMessageFlags flags, time_t mtime) | |
15817 | 739 { |
740 FinchConv *ggconv = conv->ui_data; | |
741 char *strip, *newline; | |
742 GntTextFormatFlags fl = 0; | |
743 int pos; | |
744 | |
745 g_return_if_fail(ggconv != NULL); | |
746 | |
747 if (ggconv->active_conv != conv) { | |
15822 | 748 if (flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV)) |
15817 | 749 finch_conversation_set_active(conv); |
750 else | |
751 return; | |
752 } | |
753 | |
754 pos = gnt_text_view_get_lines_below(GNT_TEXT_VIEW(ggconv->tv)); | |
755 | |
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
|
756 gnt_text_view_tag_change(GNT_TEXT_VIEW(ggconv->tv), "typing", NULL, TRUE); |
15817 | 757 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), "\n", GNT_TEXT_FLAG_NORMAL); |
758 | |
759 /* Unnecessary to print the timestamp for delayed message */ | |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
760 if (purple_prefs_get_bool("/finch/conversations/timestamps")) |
15817 | 761 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), |
15822 | 762 purple_utf8_strftime("(%H:%M:%S) ", localtime(&mtime)), GNT_TEXT_FLAG_DIM); |
15817 | 763 |
15822 | 764 if (flags & PURPLE_MESSAGE_AUTO_RESP) |
15817 | 765 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), |
766 _("<AUTO-REPLY> "), GNT_TEXT_FLAG_BOLD); | |
767 | |
20553
bed3c9affda6
Show 'buzz'/'nudge' etc. messages differently from regular messages.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20552
diff
changeset
|
768 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
|
769 !(flags & PURPLE_MESSAGE_NOTIFY)) |
15817 | 770 { |
771 char * name = NULL; | |
772 | |
15822 | 773 if (purple_message_meify((char*)message, -1)) |
15817 | 774 name = g_strdup_printf("*** %s ", who); |
775 else | |
776 name = g_strdup_printf("%s: ", who); | |
777 | |
778 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), | |
779 name, GNT_TEXT_FLAG_BOLD); | |
780 g_free(name); | |
781 } | |
782 else | |
783 fl = GNT_TEXT_FLAG_DIM; | |
784 | |
15822 | 785 if (flags & PURPLE_MESSAGE_ERROR) |
15817 | 786 fl |= GNT_TEXT_FLAG_BOLD; |
15822 | 787 if (flags & PURPLE_MESSAGE_NICK) |
15817 | 788 fl |= GNT_TEXT_FLAG_UNDERLINE; |
789 | |
790 /* XXX: Remove this workaround when textview can parse messages. */ | |
15822 | 791 newline = purple_strdup_withhtml(message); |
792 strip = purple_markup_strip_html(newline); | |
15817 | 793 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), |
794 strip, fl); | |
795 | |
796 g_free(newline); | |
797 g_free(strip); | |
798 | |
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
|
799 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
|
800 purple_conv_im_get_typing_state(PURPLE_CONV_IM(conv)) == PURPLE_TYPING) { |
15822 | 801 strip = g_strdup_printf(_("\n%s is typing..."), purple_conversation_get_name(conv)); |
15817 | 802 gnt_text_view_append_text_with_tag(GNT_TEXT_VIEW(ggconv->tv), |
803 strip, GNT_TEXT_FLAG_DIM, "typing"); | |
804 g_free(strip); | |
805 } | |
806 | |
807 if (pos <= 1) | |
808 gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), 0); | |
809 | |
15822 | 810 if (flags & (PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_NICK | PURPLE_MESSAGE_ERROR)) |
15817 | 811 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:
17813
diff
changeset
|
812 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:
17813
diff
changeset
|
813 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:
17813
diff
changeset
|
814 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:
17813
diff
changeset
|
815 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:
17813
diff
changeset
|
816 } |
15817 | 817 } |
818 | |
819 static void | |
15822 | 820 finch_write_chat(PurpleConversation *conv, const char *who, const char *message, |
821 PurpleMessageFlags flags, time_t mtime) | |
15817 | 822 { |
15822 | 823 purple_conversation_write(conv, who, message, flags, mtime); |
15817 | 824 } |
825 | |
826 static void | |
15822 | 827 finch_write_im(PurpleConversation *conv, const char *who, const char *message, |
828 PurpleMessageFlags flags, time_t mtime) | |
15817 | 829 { |
15822 | 830 PurpleAccount *account = purple_conversation_get_account(conv); |
831 if (flags & PURPLE_MESSAGE_SEND) | |
15817 | 832 { |
15822 | 833 who = purple_connection_get_display_name(purple_account_get_connection(account)); |
15817 | 834 if (!who) |
15822 | 835 who = purple_account_get_alias(account); |
15817 | 836 if (!who) |
15822 | 837 who = purple_account_get_username(account); |
15817 | 838 } |
15822 | 839 else if (flags & PURPLE_MESSAGE_RECV) |
15817 | 840 { |
15822 | 841 PurpleBuddy *buddy; |
842 who = purple_conversation_get_name(conv); | |
843 buddy = purple_find_buddy(account, who); | |
15817 | 844 if (buddy) |
15822 | 845 who = purple_buddy_get_contact_alias(buddy); |
15817 | 846 } |
847 | |
15822 | 848 purple_conversation_write(conv, who, message, flags, mtime); |
15817 | 849 } |
850 | |
851 static void | |
15822 | 852 finch_write_conv(PurpleConversation *conv, const char *who, const char *alias, |
853 const char *message, PurpleMessageFlags flags, time_t mtime) | |
15817 | 854 { |
855 const char *name; | |
856 if (alias && *alias) | |
857 name = alias; | |
858 else if (who && *who) | |
859 name = who; | |
860 else | |
861 name = NULL; | |
862 | |
863 finch_write_common(conv, name, message, flags, mtime); | |
864 } | |
865 | |
17070
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
866 static const char * |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
867 chat_flag_text(PurpleConvChatBuddyFlags flags) |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
868 { |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
869 if (flags & PURPLE_CBFLAGS_FOUNDER) |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
870 return "~"; |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
871 if (flags & PURPLE_CBFLAGS_OP) |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
872 return "@"; |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
873 if (flags & PURPLE_CBFLAGS_HALFOP) |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
874 return "%"; |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
875 if (flags & PURPLE_CBFLAGS_VOICE) |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
876 return "+"; |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
877 return " "; |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
878 } |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
879 |
15817 | 880 static void |
15822 | 881 finch_chat_add_users(PurpleConversation *conv, GList *users, gboolean new_arrivals) |
15817 | 882 { |
883 FinchConv *ggc = conv->ui_data; | |
884 GntEntry *entry = GNT_ENTRY(ggc->entry); | |
885 | |
886 if (!new_arrivals) | |
887 { | |
888 /* Print the list of users in the room */ | |
889 GString *string = g_string_new(_("List of users:\n")); | |
890 GList *iter; | |
891 | |
892 for (iter = users; iter; iter = iter->next) | |
893 { | |
15822 | 894 PurpleConvChatBuddy *cbuddy = iter->data; |
15817 | 895 char *str; |
896 | |
897 if ((str = cbuddy->alias) == NULL) | |
898 str = cbuddy->name; | |
899 g_string_append_printf(string, "[ %s ]", str); | |
900 } | |
901 | |
15822 | 902 purple_conversation_write(conv, NULL, string->str, |
903 PURPLE_MESSAGE_SYSTEM, time(NULL)); | |
15817 | 904 g_string_free(string, TRUE); |
905 } | |
906 | |
907 for (; users; users = users->next) | |
908 { | |
15822 | 909 PurpleConvChatBuddy *cbuddy = users->data; |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
910 GntTree *tree = GNT_TREE(ggc->u.chat->userlist); |
15817 | 911 gnt_entry_add_suggest(entry, cbuddy->name); |
912 gnt_entry_add_suggest(entry, cbuddy->alias); | |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
913 gnt_tree_add_row_after(tree, g_strdup(cbuddy->name), |
17070
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
914 gnt_tree_create_row(tree, chat_flag_text(cbuddy->flags), cbuddy->alias), NULL, NULL); |
15817 | 915 } |
916 } | |
917 | |
918 static void | |
15822 | 919 finch_chat_rename_user(PurpleConversation *conv, const char *old, const char *new_n, const char *new_a) |
15817 | 920 { |
921 /* Update the name for string completion */ | |
922 FinchConv *ggc = conv->ui_data; | |
923 GntEntry *entry = GNT_ENTRY(ggc->entry); | |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
924 GntTree *tree = GNT_TREE(ggc->u.chat->userlist); |
17070
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
925 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:
17021
diff
changeset
|
926 |
15817 | 927 gnt_entry_remove_suggest(entry, old); |
17070
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
928 gnt_tree_remove(tree, (gpointer)old); |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
929 |
15817 | 930 gnt_entry_add_suggest(entry, new_n); |
931 gnt_entry_add_suggest(entry, new_a); | |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
932 gnt_tree_add_row_after(tree, g_strdup(new_n), |
17070
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
933 gnt_tree_create_row(tree, chat_flag_text(cb->flags), new_a), NULL, NULL); |
15817 | 934 } |
935 | |
936 static void | |
17091
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
937 finch_chat_remove_users(PurpleConversation *conv, GList *list) |
15817 | 938 { |
939 /* Remove the name from string completion */ | |
940 FinchConv *ggc = conv->ui_data; | |
941 GntEntry *entry = GNT_ENTRY(ggc->entry); | |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
942 for (; list; list = list->next) { |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
943 GntTree *tree = GNT_TREE(ggc->u.chat->userlist); |
15817 | 944 gnt_entry_remove_suggest(entry, list->data); |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
945 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:
16892
diff
changeset
|
946 } |
15817 | 947 } |
948 | |
949 static void | |
15822 | 950 finch_chat_update_user(PurpleConversation *conv, const char *user) |
15817 | 951 { |
17070
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
952 PurpleConvChatBuddy *cb = purple_conv_chat_cb_find(PURPLE_CONV_CHAT(conv), user); |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
953 FinchConv *ggc = conv->ui_data; |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
954 gnt_tree_change_text(GNT_TREE(ggc->u.chat->userlist), (gpointer)user, 0, chat_flag_text(cb->flags)); |
15817 | 955 } |
956 | |
19446
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
957 static void |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
958 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
|
959 { |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
960 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
|
961 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
|
962 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
|
963 } |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
964 |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
965 static gboolean |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
966 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
|
967 { |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
968 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
|
969 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
|
970 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
|
971 return FALSE; |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
972 } |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
973 |
15822 | 974 static PurpleConversationUiOps conv_ui_ops = |
15817 | 975 { |
17091
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
976 finch_create_conversation, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
977 finch_destroy_conversation, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
978 finch_write_chat, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
979 finch_write_im, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
980 finch_write_conv, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
981 finch_chat_add_users, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
982 finch_chat_rename_user, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
983 finch_chat_remove_users, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
984 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
|
985 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
|
986 finch_conv_has_focus, /* has_focus */ |
17091
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
987 NULL, /* custom_smiley_add */ |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
988 NULL, /* custom_smiley_write */ |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
989 NULL, /* custom_smiley_close */ |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
990 NULL, /* send_confirm */ |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
991 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
992 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
993 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
994 NULL |
15817 | 995 }; |
996 | |
15822 | 997 PurpleConversationUiOps *finch_conv_get_ui_ops() |
15817 | 998 { |
999 return &conv_ui_ops; | |
1000 } | |
1001 | |
1002 /* Xerox */ | |
15822 | 1003 static PurpleCmdRet |
1004 say_command_cb(PurpleConversation *conv, | |
15817 | 1005 const char *cmd, char **args, char **error, void *data) |
1006 { | |
15822 | 1007 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) |
1008 purple_conv_im_send(PURPLE_CONV_IM(conv), args[0]); | |
1009 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) | |
1010 purple_conv_chat_send(PURPLE_CONV_CHAT(conv), args[0]); | |
15817 | 1011 |
15822 | 1012 return PURPLE_CMD_RET_OK; |
15817 | 1013 } |
1014 | |
1015 /* Xerox */ | |
15822 | 1016 static PurpleCmdRet |
1017 me_command_cb(PurpleConversation *conv, | |
15817 | 1018 const char *cmd, char **args, char **error, void *data) |
1019 { | |
1020 char *tmp; | |
1021 | |
1022 tmp = g_strdup_printf("/me %s", args[0]); | |
1023 | |
15822 | 1024 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) |
1025 purple_conv_im_send(PURPLE_CONV_IM(conv), tmp); | |
1026 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) | |
1027 purple_conv_chat_send(PURPLE_CONV_CHAT(conv), tmp); | |
15817 | 1028 |
1029 g_free(tmp); | |
15822 | 1030 return PURPLE_CMD_RET_OK; |
15817 | 1031 } |
1032 | |
1033 /* Xerox */ | |
15822 | 1034 static PurpleCmdRet |
1035 debug_command_cb(PurpleConversation *conv, | |
15817 | 1036 const char *cmd, char **args, char **error, void *data) |
1037 { | |
1038 char *tmp, *markup; | |
15822 | 1039 PurpleCmdStatus status; |
15817 | 1040 |
1041 if (!g_ascii_strcasecmp(args[0], "version")) { | |
16930
00c24829e243
Patch #751 from 'Dustin Howett' to change the output string from /debug version.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16893
diff
changeset
|
1042 tmp = g_strdup_printf("me is using Finch v%s.", VERSION); |
15817 | 1043 markup = g_markup_escape_text(tmp, -1); |
1044 | |
15822 | 1045 status = purple_cmd_do_command(conv, tmp, markup, error); |
15817 | 1046 |
1047 g_free(tmp); | |
1048 g_free(markup); | |
1049 return status; | |
1050 } else { | |
15822 | 1051 purple_conversation_write(conv, NULL, _("Supported debug options are: version"), |
1052 PURPLE_MESSAGE_NO_LOG|PURPLE_MESSAGE_ERROR, time(NULL)); | |
1053 return PURPLE_CMD_STATUS_OK; | |
15817 | 1054 } |
1055 } | |
1056 | |
1057 /* Xerox */ | |
15822 | 1058 static PurpleCmdRet |
1059 clear_command_cb(PurpleConversation *conv, | |
15817 | 1060 const char *cmd, char **args, char **error, void *data) |
1061 { | |
1062 FinchConv *ggconv = conv->ui_data; | |
1063 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
|
1064 purple_conversation_clear_message_history(conv); |
15822 | 1065 return PURPLE_CMD_STATUS_OK; |
15817 | 1066 } |
1067 | |
1068 /* Xerox */ | |
15822 | 1069 static PurpleCmdRet |
1070 help_command_cb(PurpleConversation *conv, | |
15817 | 1071 const char *cmd, char **args, char **error, void *data) |
1072 { | |
1073 GList *l, *text; | |
1074 GString *s; | |
1075 | |
1076 if (args[0] != NULL) { | |
1077 s = g_string_new(""); | |
15822 | 1078 text = purple_cmd_help(conv, args[0]); |
15817 | 1079 |
1080 if (text) { | |
1081 for (l = text; l; l = l->next) | |
1082 if (l->next) | |
1083 g_string_append_printf(s, "%s\n", (char *)l->data); | |
1084 else | |
1085 g_string_append_printf(s, "%s", (char *)l->data); | |
1086 } else { | |
1087 g_string_append(s, _("No such command (in this context).")); | |
1088 } | |
1089 } else { | |
1090 s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" | |
1091 "The following commands are available in this context:\n")); | |
1092 | |
15822 | 1093 text = purple_cmd_list(conv); |
15817 | 1094 for (l = text; l; l = l->next) |
1095 if (l->next) | |
1096 g_string_append_printf(s, "%s, ", (char *)l->data); | |
1097 else | |
1098 g_string_append_printf(s, "%s.", (char *)l->data); | |
1099 g_list_free(text); | |
1100 } | |
1101 | |
15822 | 1102 purple_conversation_write(conv, NULL, s->str, PURPLE_MESSAGE_NO_LOG, time(NULL)); |
15817 | 1103 g_string_free(s, TRUE); |
1104 | |
15822 | 1105 return PURPLE_CMD_STATUS_OK; |
15817 | 1106 } |
1107 | |
15822 | 1108 static PurpleCmdRet |
1109 cmd_show_window(PurpleConversation *conv, const char *cmd, char **args, char **error, gpointer data) | |
15817 | 1110 { |
1111 void (*callback)() = data; | |
1112 callback(); | |
15822 | 1113 return PURPLE_CMD_STATUS_OK; |
15817 | 1114 } |
1115 | |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
1116 static PurpleCmdRet |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
1117 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:
16892
diff
changeset
|
1118 { |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
1119 FinchConv *fc = conv->ui_data; |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
1120 FinchConvChat *ch; |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
1121 if (!fc) |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
1122 return PURPLE_CMD_STATUS_FAILED; |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
1123 |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
1124 ch = fc->u.chat; |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
1125 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:
16892
diff
changeset
|
1126 (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:
16892
diff
changeset
|
1127 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:
16892
diff
changeset
|
1128 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:
16892
diff
changeset
|
1129 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:
16892
diff
changeset
|
1130 return PURPLE_CMD_STATUS_OK; |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
1131 } |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
1132 |
15817 | 1133 void finch_conversation_init() |
1134 { | |
15822 | 1135 purple_prefs_add_none(PREF_ROOT); |
1136 purple_prefs_add_none(PREF_ROOT "/size"); | |
1137 purple_prefs_add_int(PREF_ROOT "/size/width", 70); | |
1138 purple_prefs_add_int(PREF_ROOT "/size/height", 20); | |
1139 purple_prefs_add_none(PREF_ROOT "/position"); | |
1140 purple_prefs_add_int(PREF_ROOT "/position/x", 0); | |
1141 purple_prefs_add_int(PREF_ROOT "/position/y", 0); | |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
1142 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:
16892
diff
changeset
|
1143 purple_prefs_add_bool(PREF_USERLIST, FALSE); |
15817 | 1144 |
1145 /* Xerox the commands */ | |
15822 | 1146 purple_cmd_register("say", "S", PURPLE_CMD_P_DEFAULT, |
1147 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 1148 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); |
15822 | 1149 purple_cmd_register("me", "S", PURPLE_CMD_P_DEFAULT, |
1150 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 1151 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
15822 | 1152 purple_cmd_register("debug", "w", PURPLE_CMD_P_DEFAULT, |
1153 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 1154 debug_command_cb, _("debug <option>: Send various debug information to the current conversation."), NULL); |
15822 | 1155 purple_cmd_register("clear", "", PURPLE_CMD_P_DEFAULT, |
1156 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 1157 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); |
15822 | 1158 purple_cmd_register("help", "w", PURPLE_CMD_P_DEFAULT, |
1159 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, | |
15817 | 1160 help_command_cb, _("help <command>: Help on a specific command."), NULL); |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
1161 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:
16892
diff
changeset
|
1162 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:
16892
diff
changeset
|
1163 users_command_cb, _("users: Show the list of users in the chat."), NULL); |
15817 | 1164 |
1165 /* Now some commands to bring up some other windows */ | |
15822 | 1166 purple_cmd_register("plugins", "", PURPLE_CMD_P_DEFAULT, |
1167 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 1168 cmd_show_window, _("plugins: Show the plugins window."), finch_plugins_show_all); |
15822 | 1169 purple_cmd_register("buddylist", "", PURPLE_CMD_P_DEFAULT, |
1170 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 1171 cmd_show_window, _("buddylist: Show the buddylist."), finch_blist_show); |
15822 | 1172 purple_cmd_register("accounts", "", PURPLE_CMD_P_DEFAULT, |
1173 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 1174 cmd_show_window, _("accounts: Show the accounts window."), finch_accounts_show_all); |
15822 | 1175 purple_cmd_register("debugwin", "", PURPLE_CMD_P_DEFAULT, |
1176 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 1177 cmd_show_window, _("debugwin: Show the debug window."), finch_debug_window_show); |
15822 | 1178 purple_cmd_register("prefs", "", PURPLE_CMD_P_DEFAULT, |
1179 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 1180 cmd_show_window, _("prefs: Show the preference window."), finch_prefs_show_all); |
15822 | 1181 purple_cmd_register("status", "", PURPLE_CMD_P_DEFAULT, |
1182 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 1183 cmd_show_window, _("statuses: Show the savedstatuses window."), finch_savedstatus_show_all); |
17021
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
1184 |
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
1185 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:
16978
diff
changeset
|
1186 PURPLE_CALLBACK(update_buddy_typing), NULL); |
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
1187 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:
16978
diff
changeset
|
1188 PURPLE_CALLBACK(update_buddy_typing), NULL); |
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
1189 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:
16978
diff
changeset
|
1190 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
|
1191 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
|
1192 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
|
1193 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
|
1194 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
|
1195 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
|
1196 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
|
1197 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
|
1198 PURPLE_CALLBACK(account_signed_on_off), NULL); |
15817 | 1199 } |
1200 | |
1201 void finch_conversation_uninit() | |
1202 { | |
17021
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
1203 purple_signals_disconnect_by_handle(finch_conv_get_handle()); |
15817 | 1204 } |
1205 | |
15822 | 1206 void finch_conversation_set_active(PurpleConversation *conv) |
15817 | 1207 { |
1208 FinchConv *ggconv = conv->ui_data; | |
15822 | 1209 PurpleAccount *account; |
15817 | 1210 char *title; |
1211 | |
1212 g_return_if_fail(ggconv); | |
1213 g_return_if_fail(g_list_find(ggconv->list, conv)); | |
1214 | |
1215 ggconv->active_conv = conv; | |
15822 | 1216 account = purple_conversation_get_account(conv); |
15817 | 1217 title = get_conversation_title(conv, account); |
1218 gnt_screen_rename_widget(ggconv->window, title); | |
1219 g_free(title); | |
1220 } | |
1221 | |
16128
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1222 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
|
1223 { |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1224 FinchConv *fc = conv->ui_data; |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1225 int height, width; |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1226 |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1227 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
|
1228 |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1229 if (widget) { |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1230 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
|
1231 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
|
1232 } |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1233 |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1234 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
|
1235 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
|
1236 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
|
1237 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
|
1238 } |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1239 |