Mercurial > pidgin
annotate finch/gntconv.c @ 18192:dc7e7b8bdc8c
- Add chunks of the certificate scheme registration interface
author | William Ehlhardt <williamehlhardt@gmail.com> |
---|---|
date | Wed, 20 Jun 2007 01:47:55 +0000 |
parents | f63b3a23280d |
children | b8572b937c09 |
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 |
15817 | 4 * |
15870
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
5 * finch |
15817 | 6 * |
15870
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
7 * Finch is the legal property of its developers, whose names are too numerous |
15817 | 8 * to list here. Please refer to the COPYRIGHT file distributed with this |
9 * source distribution. | |
10 * | |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
25 #include <string.h> | |
26 | |
27 #include <cmds.h> | |
28 #include <idle.h> | |
29 #include <prefs.h> | |
30 #include <util.h> | |
31 | |
15822 | 32 #include "finch.h" |
15817 | 33 #include "gntaccount.h" |
34 #include "gntblist.h" | |
35 #include "gntconv.h" | |
36 #include "gntdebug.h" | |
37 #include "gntplugin.h" | |
38 #include "gntprefs.h" | |
39 #include "gntstatus.h" | |
16892 | 40 #include "gntpounce.h" |
15817 | 41 |
42 #include "gnt.h" | |
43 #include "gntbox.h" | |
44 #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
|
45 #include "gntlabel.h" |
16892 | 46 #include "gntmenu.h" |
47 #include "gntmenuitem.h" | |
48 #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
|
49 #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
|
50 #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
|
51 #include "gntutils.h" |
16892 | 52 #include "gntwindow.h" |
15817 | 53 |
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
|
54 #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
|
55 #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
|
56 #define PREF_USERLIST PREF_CHAT "/userlist" |
15817 | 57 |
58 #include "config.h" | |
59 | |
17021
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
60 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
|
61 const char *message, PurpleMessageFlags flags, time_t mtime); |
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
62 |
15817 | 63 static void |
64 send_typing_notification(GntWidget *w, FinchConv *ggconv) | |
65 { | |
66 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
|
67 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
|
68 if (purple_prefs_get_bool("/finch/conversations/notify_typing")) { |
15822 | 69 PurpleConversation *conv = ggconv->active_conv; |
70 PurpleConvIm *im = PURPLE_CONV_IM(conv); | |
15817 | 71 if (!empty) { |
15822 | 72 gboolean send = (purple_conv_im_get_send_typed_timeout(im) == 0); |
15817 | 73 |
15822 | 74 purple_conv_im_stop_send_typed_timeout(im); |
75 purple_conv_im_start_send_typed_timeout(im); | |
76 if (send || (purple_conv_im_get_type_again(im) != 0 && | |
77 time(NULL) > purple_conv_im_get_type_again(im))) { | |
15817 | 78 unsigned int timeout; |
15822 | 79 timeout = serv_send_typing(purple_conversation_get_gc(conv), |
80 purple_conversation_get_name(conv), | |
81 PURPLE_TYPING); | |
82 purple_conv_im_set_type_again(im, timeout); | |
15817 | 83 } |
84 } else { | |
15822 | 85 purple_conv_im_stop_send_typed_timeout(im); |
15817 | 86 |
15822 | 87 serv_send_typing(purple_conversation_get_gc(conv), |
88 purple_conversation_get_name(conv), | |
89 PURPLE_NOT_TYPING); | |
15817 | 90 } |
91 } | |
92 } | |
93 | |
94 static gboolean | |
95 entry_key_pressed(GntWidget *w, const char *key, FinchConv *ggconv) | |
96 { | |
97 if (key[0] == '\r' && key[1] == 0) | |
98 { | |
99 const char *text = gnt_entry_get_text(GNT_ENTRY(ggconv->entry)); | |
100 if (*text == '/') | |
101 { | |
15822 | 102 PurpleConversation *conv = ggconv->active_conv; |
103 PurpleCmdStatus status; | |
15817 | 104 const char *cmdline = text + 1; |
105 char *error = NULL, *escape; | |
106 | |
107 escape = g_markup_escape_text(cmdline, -1); | |
15822 | 108 status = purple_cmd_do_command(conv, cmdline, escape, &error); |
15817 | 109 g_free(escape); |
110 | |
111 switch (status) | |
112 { | |
15822 | 113 case PURPLE_CMD_STATUS_OK: |
15817 | 114 break; |
15822 | 115 case PURPLE_CMD_STATUS_NOT_FOUND: |
116 purple_conversation_write(conv, "", _("No such command."), | |
117 PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
15817 | 118 break; |
15822 | 119 case PURPLE_CMD_STATUS_WRONG_ARGS: |
120 purple_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " | |
15817 | 121 "to that command."), |
15822 | 122 PURPLE_MESSAGE_NO_LOG, time(NULL)); |
15817 | 123 break; |
15822 | 124 case PURPLE_CMD_STATUS_FAILED: |
125 purple_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), | |
126 PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
15817 | 127 break; |
15822 | 128 case PURPLE_CMD_STATUS_WRONG_TYPE: |
129 if(purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) | |
130 purple_conversation_write(conv, "", _("That command only works in chats, not IMs."), | |
131 PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
15817 | 132 else |
15822 | 133 purple_conversation_write(conv, "", _("That command only works in IMs, not chats."), |
134 PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
15817 | 135 break; |
15822 | 136 case PURPLE_CMD_STATUS_WRONG_PRPL: |
137 purple_conversation_write(conv, "", _("That command doesn't work on this protocol."), | |
138 PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
15817 | 139 break; |
140 } | |
141 g_free(error); | |
142 #if 0 | |
143 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), | |
144 _("Commands are not supported yet. Message was NOT sent."), | |
145 GNT_TEXT_FLAG_DIM | GNT_TEXT_FLAG_UNDERLINE); | |
146 gnt_text_view_next_line(GNT_TEXT_VIEW(ggconv->tv)); | |
147 gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), 0); | |
148 #endif | |
149 } | |
150 else | |
151 { | |
152 char *escape = g_markup_escape_text(text, -1); | |
15822 | 153 char *apos = purple_strreplace(escape, "'", "'"); |
15817 | 154 g_free(escape); |
155 escape = apos; | |
15822 | 156 switch (purple_conversation_get_type(ggconv->active_conv)) |
15817 | 157 { |
15822 | 158 case PURPLE_CONV_TYPE_IM: |
159 purple_conv_im_send_with_flags(PURPLE_CONV_IM(ggconv->active_conv), escape, PURPLE_MESSAGE_SEND); | |
15817 | 160 break; |
15822 | 161 case PURPLE_CONV_TYPE_CHAT: |
162 purple_conv_chat_send(PURPLE_CONV_CHAT(ggconv->active_conv), escape); | |
15817 | 163 break; |
164 default: | |
165 g_free(escape); | |
166 g_return_val_if_reached(FALSE); | |
167 } | |
168 g_free(escape); | |
15822 | 169 purple_idle_touch(); |
15817 | 170 } |
171 gnt_entry_add_to_history(GNT_ENTRY(ggconv->entry), text); | |
172 gnt_entry_clear(GNT_ENTRY(ggconv->entry)); | |
173 return TRUE; | |
174 } | |
175 | |
176 return FALSE; | |
177 } | |
178 | |
179 static void | |
180 closing_window(GntWidget *window, FinchConv *ggconv) | |
181 { | |
182 GList *list = ggconv->list; | |
183 ggconv->window = NULL; | |
184 while (list) { | |
15822 | 185 PurpleConversation *conv = list->data; |
15817 | 186 list = list->next; |
15822 | 187 purple_conversation_destroy(conv); |
15817 | 188 } |
189 } | |
190 | |
191 static void | |
192 size_changed_cb(GntWidget *widget, int width, int height) | |
193 { | |
194 int w, h; | |
195 gnt_widget_get_size(widget, &w, &h); | |
15822 | 196 purple_prefs_set_int(PREF_ROOT "/size/width", w); |
197 purple_prefs_set_int(PREF_ROOT "/size/height", h); | |
15817 | 198 } |
199 | |
200 static void | |
201 save_position_cb(GntWidget *w, int x, int y) | |
202 { | |
15822 | 203 purple_prefs_set_int(PREF_ROOT "/position/x", x); |
204 purple_prefs_set_int(PREF_ROOT "/position/y", y); | |
15817 | 205 } |
206 | |
15822 | 207 static PurpleConversation * |
208 find_conv_with_contact(PurpleConversation *conv) | |
15817 | 209 { |
15822 | 210 PurpleBlistNode *node; |
211 PurpleBuddy *buddy = purple_find_buddy(conv->account, conv->name); | |
212 PurpleConversation *ret = NULL; | |
15817 | 213 |
214 if (!buddy) | |
215 return NULL; | |
216 | |
15822 | 217 for (node = ((PurpleBlistNode*)buddy)->parent->child; node; node = node->next) { |
218 if (node == (PurpleBlistNode*)buddy) | |
15817 | 219 continue; |
15822 | 220 if ((ret = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, |
221 ((PurpleBuddy*)node)->name, ((PurpleBuddy*)node)->account)) != NULL) | |
15817 | 222 break; |
223 } | |
224 return ret; | |
225 } | |
226 | |
227 static char * | |
15822 | 228 get_conversation_title(PurpleConversation *conv, PurpleAccount *account) |
15817 | 229 { |
15822 | 230 return g_strdup_printf(_("%s (%s -- %s)"), purple_conversation_get_title(conv), |
231 purple_account_get_username(account), purple_account_get_protocol_name(account)); | |
15817 | 232 } |
233 | |
234 static void | |
15822 | 235 update_buddy_typing(PurpleAccount *account, const char *who, gpointer null) |
15817 | 236 { |
15822 | 237 PurpleConversation *conv; |
15817 | 238 FinchConv *ggc; |
15822 | 239 PurpleConvIm *im = NULL; |
15817 | 240 char *title, *str; |
241 | |
15822 | 242 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, who, account); |
15817 | 243 |
244 if (!conv) | |
245 return; | |
246 | |
15822 | 247 im = PURPLE_CONV_IM(conv); |
15817 | 248 ggc = conv->ui_data; |
249 | |
15822 | 250 if (purple_conv_im_get_typing_state(im) == PURPLE_TYPING) { |
15817 | 251 int scroll; |
252 str = get_conversation_title(conv, account); | |
253 title = g_strdup_printf(_("%s [%s]"), str, | |
254 gnt_ascii_only() ? "T" : "\342\243\277"); | |
255 g_free(str); | |
256 | |
257 scroll = gnt_text_view_get_lines_below(GNT_TEXT_VIEW(ggc->tv)); | |
15822 | 258 str = g_strdup_printf(_("\n%s is typing..."), purple_conversation_get_name(conv)); |
15817 | 259 /* Updating is a little buggy. So just remove and add a new one */ |
260 gnt_text_view_tag_change(GNT_TEXT_VIEW(ggc->tv), "typing", NULL, TRUE); | |
261 gnt_text_view_append_text_with_tag(GNT_TEXT_VIEW(ggc->tv), | |
262 str, GNT_TEXT_FLAG_DIM, "typing"); | |
263 g_free(str); | |
264 if (scroll <= 1) | |
265 gnt_text_view_scroll(GNT_TEXT_VIEW(ggc->tv), 0); | |
266 } else { | |
267 title = get_conversation_title(conv, account); | |
268 gnt_text_view_tag_change(GNT_TEXT_VIEW(ggc->tv), "typing", NULL, TRUE); | |
269 } | |
270 gnt_screen_rename_widget(ggc->window, title); | |
271 g_free(title); | |
272 } | |
273 | |
17021
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
274 static void |
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
275 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
|
276 { |
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
277 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
|
278 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
|
279 } |
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
280 |
15817 | 281 static gpointer |
282 finch_conv_get_handle() | |
283 { | |
284 static int handle; | |
285 return &handle; | |
286 } | |
287 | |
288 static void | |
16892 | 289 clear_scrollback_cb(GntMenuItem *item, gpointer ggconv) |
290 { | |
291 FinchConv *ggc = ggconv; | |
292 gnt_text_view_clear(GNT_TEXT_VIEW(ggc->tv)); | |
293 } | |
294 | |
295 static void | |
296 send_file_cb(GntMenuItem *item, gpointer ggconv) | |
297 { | |
298 FinchConv *ggc = ggconv; | |
299 serv_send_file(purple_conversation_get_gc(ggc->active_conv), | |
300 purple_conversation_get_name(ggc->active_conv), NULL); | |
301 } | |
302 | |
303 static void | |
304 add_pounce_cb(GntMenuItem *item, gpointer ggconv) | |
305 { | |
306 FinchConv *ggc = ggconv; | |
307 finch_pounce_editor_show( | |
308 purple_conversation_get_account(ggc->active_conv), | |
309 purple_conversation_get_name(ggc->active_conv), NULL); | |
310 } | |
311 | |
312 static void | |
313 get_info_cb(GntMenuItem *item, gpointer ggconv) | |
314 { | |
315 FinchConv *ggc = ggconv; | |
17750
319bcb73eb4e
Use utility functions to get user info. Closes #964.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
316 finch_retrieve_user_info(purple_conversation_get_gc(ggc->active_conv), |
16892 | 317 purple_conversation_get_name(ggc->active_conv)); |
318 } | |
319 | |
320 static void | |
321 toggle_timestamps_cb(GntMenuItem *item, gpointer ggconv) | |
322 { | |
323 purple_prefs_set_bool(PREF_ROOT "/timestamps", | |
324 !purple_prefs_get_bool(PREF_ROOT "/timestamps")); | |
325 } | |
326 | |
327 static void | |
328 send_to_cb(GntMenuItem *m, gpointer n) | |
329 { | |
330 PurpleAccount *account = g_object_get_data(G_OBJECT(m), "purple_account"); | |
331 gchar *buddy = g_object_get_data(G_OBJECT(m), "purple_buddy_name"); | |
332 PurpleConversation *conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, buddy); | |
333 finch_conversation_set_active(conv); | |
334 } | |
335 | |
336 static void | |
337 generate_send_to_menu(FinchConv *ggc) | |
338 { | |
339 GntWidget *sub, *menu = ggc->menu; | |
340 GntMenuItem *item; | |
341 GSList *buds; | |
342 GList *list = NULL; | |
343 | |
344 buds = purple_find_buddies(ggc->active_conv->account, ggc->active_conv->name); | |
345 if (!buds) | |
346 return; | |
347 | |
348 item = gnt_menuitem_new(_("Send To")); | |
349 gnt_menu_add_item(GNT_MENU(menu), item); | |
350 sub = gnt_menu_new(GNT_MENU_POPUP); | |
351 gnt_menuitem_set_submenu(item, GNT_MENU(sub)); | |
352 | |
353 for (; buds; buds = buds->next) { | |
354 PurpleBlistNode *node = (PurpleBlistNode *)purple_buddy_get_contact((PurpleBuddy *)buds->data); | |
355 for (node = node->child; node != NULL; node = node->next) { | |
356 PurpleBuddy *buddy = (PurpleBuddy *)node; | |
357 PurpleAccount *account = purple_buddy_get_account(buddy); | |
358 if (purple_account_is_connected(account)) { | |
359 /* Use the PurplePresence to get unique buddies. */ | |
360 PurplePresence *presence = purple_buddy_get_presence(buddy); | |
361 if (!g_list_find(list, presence)) | |
362 list = g_list_prepend(list, presence); | |
363 } | |
364 } | |
365 } | |
366 for (list = g_list_last(list); list != NULL; list = list->prev) { | |
367 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
|
368 PurpleBuddy *buddy = purple_presence_get_buddy(pre); |
16892 | 369 PurpleAccount *account = purple_buddy_get_account(buddy); |
370 gchar *name = g_strdup(purple_buddy_get_name(buddy)); | |
371 gchar *text = g_strdup_printf("%s (%s)", purple_buddy_get_name(buddy), purple_account_get_username(account)); | |
372 item = gnt_menuitem_new(text); | |
373 g_free(text); | |
374 gnt_menu_add_item(GNT_MENU(sub), item); | |
375 gnt_menuitem_set_callback(item, send_to_cb, NULL); | |
376 g_object_set_data(G_OBJECT(item), "purple_account", account); | |
377 g_object_set_data_full(G_OBJECT(item), "purple_buddy_name", name, g_free); | |
378 } | |
379 g_list_free(list); | |
380 g_slist_free(buds); | |
381 } | |
382 | |
383 static void | |
384 gg_create_menu(FinchConv *ggc) | |
385 { | |
386 GntWidget *menu, *sub; | |
387 GntMenuItem *item; | |
388 | |
389 ggc->menu = menu = gnt_menu_new(GNT_MENU_TOPLEVEL); | |
390 gnt_window_set_menu(GNT_WINDOW(ggc->window), GNT_MENU(menu)); | |
391 | |
392 item = gnt_menuitem_new(_("Conversation")); | |
393 gnt_menu_add_item(GNT_MENU(menu), item); | |
394 | |
395 sub = gnt_menu_new(GNT_MENU_POPUP); | |
396 gnt_menuitem_set_submenu(item, GNT_MENU(sub)); | |
397 | |
398 item = gnt_menuitem_new(_("Clear Scrollback")); | |
399 gnt_menu_add_item(GNT_MENU(sub), item); | |
400 gnt_menuitem_set_callback(item, clear_scrollback_cb, ggc); | |
401 | |
402 item = gnt_menuitem_check_new(_("Show Timestamps")); | |
403 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item), | |
404 purple_prefs_get_bool(PREF_ROOT "/timestamps")); | |
405 gnt_menu_add_item(GNT_MENU(sub), item); | |
406 gnt_menuitem_set_callback(item, toggle_timestamps_cb, ggc); | |
407 | |
408 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
|
409 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
|
410 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
|
411 |
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
|
412 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
|
413 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
|
414 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
|
415 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
|
416 } |
16892 | 417 |
418 item = gnt_menuitem_new(_("Add Buddy Pounce...")); | |
419 gnt_menu_add_item(GNT_MENU(sub), item); | |
420 gnt_menuitem_set_callback(item, add_pounce_cb, ggc); | |
421 | |
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
|
422 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
|
423 (!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
|
424 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
|
425 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
|
426 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
|
427 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
|
428 } |
16892 | 429 |
430 generate_send_to_menu(ggc); | |
431 } | |
432 } | |
433 | |
434 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
|
435 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
|
436 { |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
437 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
|
438 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
|
439 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
|
440 } |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
441 |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
442 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
|
443 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
|
444 { |
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
|
445 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
|
446 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
|
447 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
|
448 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
|
449 } |
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
|
450 } |
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
|
451 |
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
|
452 static void |
15822 | 453 finch_create_conversation(PurpleConversation *conv) |
15817 | 454 { |
455 FinchConv *ggc = conv->ui_data; | |
456 char *title; | |
15822 | 457 PurpleConversationType type; |
458 PurpleConversation *cc; | |
459 PurpleAccount *account; | |
15817 | 460 |
461 if (ggc) | |
462 return; | |
463 | |
464 cc = find_conv_with_contact(conv); | |
465 if (cc && cc->ui_data) | |
466 ggc = cc->ui_data; | |
467 else | |
468 ggc = g_new0(FinchConv, 1); | |
469 | |
470 ggc->list = g_list_prepend(ggc->list, conv); | |
471 ggc->active_conv = conv; | |
472 conv->ui_data = ggc; | |
473 | |
474 if (cc && cc->ui_data) { | |
475 finch_conversation_set_active(conv); | |
476 return; | |
477 } | |
478 | |
15822 | 479 account = purple_conversation_get_account(conv); |
480 type = purple_conversation_get_type(conv); | |
15817 | 481 title = get_conversation_title(conv, account); |
482 | |
16892 | 483 ggc->window = gnt_vwindow_new(FALSE); |
15817 | 484 gnt_box_set_title(GNT_BOX(ggc->window), title); |
485 gnt_box_set_toplevel(GNT_BOX(ggc->window), TRUE); | |
486 gnt_box_set_pad(GNT_BOX(ggc->window), 0); | |
487 gnt_widget_set_name(ggc->window, "conversation-window"); | |
488 | |
16892 | 489 gg_create_menu(ggc); |
490 | |
15817 | 491 ggc->tv = gnt_text_view_new(); |
492 gnt_widget_set_name(ggc->tv, "conversation-window-textview"); | |
15822 | 493 gnt_widget_set_size(ggc->tv, purple_prefs_get_int(PREF_ROOT "/size/width"), |
494 purple_prefs_get_int(PREF_ROOT "/size/height")); | |
15817 | 495 |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
496 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
|
497 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
|
498 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
|
499 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
|
500 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
|
501 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
|
502 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
|
503 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
|
504 gnt_tree_set_hash_fns(GNT_TREE(tree), g_str_hash, g_str_equal, g_free); |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
505 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
|
506 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
|
507 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
|
508 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
|
509 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
|
510 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
|
511 } else { |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
512 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
|
513 } |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
514 |
16128
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
515 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
|
516 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
|
517 |
15817 | 518 ggc->entry = gnt_entry_new(NULL); |
519 gnt_box_add_widget(GNT_BOX(ggc->window), ggc->entry); | |
520 gnt_widget_set_name(ggc->entry, "conversation-window-entry"); | |
521 gnt_entry_set_history_length(GNT_ENTRY(ggc->entry), -1); | |
522 gnt_entry_set_word_suggest(GNT_ENTRY(ggc->entry), TRUE); | |
523 gnt_entry_set_always_suggest(GNT_ENTRY(ggc->entry), FALSE); | |
524 | |
16124
ab3f93232a2d
Add a utility function to assist scrolling in a textview.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15870
diff
changeset
|
525 gnt_text_view_attach_scroll_widget(GNT_TEXT_VIEW(ggc->tv), ggc->entry); |
15817 | 526 g_signal_connect_after(G_OBJECT(ggc->entry), "key_pressed", G_CALLBACK(entry_key_pressed), ggc); |
527 g_signal_connect(G_OBJECT(ggc->window), "destroy", G_CALLBACK(closing_window), ggc); | |
528 | |
15822 | 529 gnt_widget_set_position(ggc->window, purple_prefs_get_int(PREF_ROOT "/position/x"), |
530 purple_prefs_get_int(PREF_ROOT "/position/y")); | |
15817 | 531 gnt_widget_show(ggc->window); |
532 | |
533 g_signal_connect(G_OBJECT(ggc->tv), "size_changed", G_CALLBACK(size_changed_cb), NULL); | |
534 g_signal_connect(G_OBJECT(ggc->window), "position_set", G_CALLBACK(save_position_cb), NULL); | |
535 | |
15822 | 536 if (type == PURPLE_CONV_TYPE_IM) { |
15817 | 537 g_signal_connect(G_OBJECT(ggc->entry), "text_changed", G_CALLBACK(send_typing_notification), ggc); |
538 } | |
539 | |
540 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
|
541 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
|
542 g_signal_connect(G_OBJECT(ggc->window), "gained-focus", G_CALLBACK(gained_focus_cb), ggc); |
15817 | 543 } |
544 | |
545 static void | |
15822 | 546 finch_destroy_conversation(PurpleConversation *conv) |
15817 | 547 { |
548 /* do stuff here */ | |
549 FinchConv *ggc = conv->ui_data; | |
550 ggc->list = g_list_remove(ggc->list, conv); | |
551 if (ggc->list && conv == ggc->active_conv) | |
552 ggc->active_conv = ggc->list->data; | |
553 | |
554 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
|
555 g_free(ggc->u.chat); |
15817 | 556 gnt_widget_destroy(ggc->window); |
557 g_free(ggc); | |
558 } | |
559 } | |
560 | |
561 static void | |
15822 | 562 finch_write_common(PurpleConversation *conv, const char *who, const char *message, |
563 PurpleMessageFlags flags, time_t mtime) | |
15817 | 564 { |
565 FinchConv *ggconv = conv->ui_data; | |
566 char *strip, *newline; | |
567 GntTextFormatFlags fl = 0; | |
568 int pos; | |
569 gboolean notify; | |
570 | |
571 g_return_if_fail(ggconv != NULL); | |
572 | |
573 if (ggconv->active_conv != conv) { | |
15822 | 574 if (flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV)) |
15817 | 575 finch_conversation_set_active(conv); |
576 else | |
577 return; | |
578 } | |
579 | |
580 pos = gnt_text_view_get_lines_below(GNT_TEXT_VIEW(ggconv->tv)); | |
581 | |
582 notify = !!gnt_text_view_tag_change(GNT_TEXT_VIEW(ggconv->tv), "typing", NULL, TRUE); | |
583 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), "\n", GNT_TEXT_FLAG_NORMAL); | |
584 | |
585 /* 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
|
586 if (purple_prefs_get_bool("/finch/conversations/timestamps")) |
15817 | 587 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), |
15822 | 588 purple_utf8_strftime("(%H:%M:%S) ", localtime(&mtime)), GNT_TEXT_FLAG_DIM); |
15817 | 589 |
15822 | 590 if (flags & PURPLE_MESSAGE_AUTO_RESP) |
15817 | 591 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), |
592 _("<AUTO-REPLY> "), GNT_TEXT_FLAG_BOLD); | |
593 | |
15822 | 594 if (who && *who && (flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV))) |
15817 | 595 { |
596 char * name = NULL; | |
597 | |
15822 | 598 if (purple_message_meify((char*)message, -1)) |
15817 | 599 name = g_strdup_printf("*** %s ", who); |
600 else | |
601 name = g_strdup_printf("%s: ", who); | |
602 | |
603 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), | |
604 name, GNT_TEXT_FLAG_BOLD); | |
605 g_free(name); | |
606 } | |
607 else | |
608 fl = GNT_TEXT_FLAG_DIM; | |
609 | |
15822 | 610 if (flags & PURPLE_MESSAGE_ERROR) |
15817 | 611 fl |= GNT_TEXT_FLAG_BOLD; |
15822 | 612 if (flags & PURPLE_MESSAGE_NICK) |
15817 | 613 fl |= GNT_TEXT_FLAG_UNDERLINE; |
614 | |
615 /* XXX: Remove this workaround when textview can parse messages. */ | |
15822 | 616 newline = purple_strdup_withhtml(message); |
617 strip = purple_markup_strip_html(newline); | |
15817 | 618 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), |
619 strip, fl); | |
620 | |
621 g_free(newline); | |
622 g_free(strip); | |
623 | |
624 if (notify) { | |
15822 | 625 strip = g_strdup_printf(_("\n%s is typing..."), purple_conversation_get_name(conv)); |
15817 | 626 gnt_text_view_append_text_with_tag(GNT_TEXT_VIEW(ggconv->tv), |
627 strip, GNT_TEXT_FLAG_DIM, "typing"); | |
628 g_free(strip); | |
629 } | |
630 | |
631 if (pos <= 1) | |
632 gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), 0); | |
633 | |
15822 | 634 if (flags & (PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_NICK | PURPLE_MESSAGE_ERROR)) |
15817 | 635 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
|
636 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
|
637 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
|
638 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
|
639 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
|
640 } |
15817 | 641 } |
642 | |
643 static void | |
15822 | 644 finch_write_chat(PurpleConversation *conv, const char *who, const char *message, |
645 PurpleMessageFlags flags, time_t mtime) | |
15817 | 646 { |
15822 | 647 purple_conversation_write(conv, who, message, flags, mtime); |
15817 | 648 } |
649 | |
650 static void | |
15822 | 651 finch_write_im(PurpleConversation *conv, const char *who, const char *message, |
652 PurpleMessageFlags flags, time_t mtime) | |
15817 | 653 { |
15822 | 654 PurpleAccount *account = purple_conversation_get_account(conv); |
655 if (flags & PURPLE_MESSAGE_SEND) | |
15817 | 656 { |
15822 | 657 who = purple_connection_get_display_name(purple_account_get_connection(account)); |
15817 | 658 if (!who) |
15822 | 659 who = purple_account_get_alias(account); |
15817 | 660 if (!who) |
15822 | 661 who = purple_account_get_username(account); |
15817 | 662 } |
15822 | 663 else if (flags & PURPLE_MESSAGE_RECV) |
15817 | 664 { |
15822 | 665 PurpleBuddy *buddy; |
666 who = purple_conversation_get_name(conv); | |
667 buddy = purple_find_buddy(account, who); | |
15817 | 668 if (buddy) |
15822 | 669 who = purple_buddy_get_contact_alias(buddy); |
15817 | 670 } |
671 | |
15822 | 672 purple_conversation_write(conv, who, message, flags, mtime); |
15817 | 673 } |
674 | |
675 static void | |
15822 | 676 finch_write_conv(PurpleConversation *conv, const char *who, const char *alias, |
677 const char *message, PurpleMessageFlags flags, time_t mtime) | |
15817 | 678 { |
679 const char *name; | |
680 if (alias && *alias) | |
681 name = alias; | |
682 else if (who && *who) | |
683 name = who; | |
684 else | |
685 name = NULL; | |
686 | |
687 finch_write_common(conv, name, message, flags, mtime); | |
688 } | |
689 | |
17070
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
690 static const char * |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
691 chat_flag_text(PurpleConvChatBuddyFlags flags) |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
692 { |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
693 if (flags & PURPLE_CBFLAGS_FOUNDER) |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
694 return "~"; |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
695 if (flags & PURPLE_CBFLAGS_OP) |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
696 return "@"; |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
697 if (flags & PURPLE_CBFLAGS_HALFOP) |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
698 return "%"; |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
699 if (flags & PURPLE_CBFLAGS_VOICE) |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
700 return "+"; |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
701 return " "; |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
702 } |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
703 |
15817 | 704 static void |
15822 | 705 finch_chat_add_users(PurpleConversation *conv, GList *users, gboolean new_arrivals) |
15817 | 706 { |
707 FinchConv *ggc = conv->ui_data; | |
708 GntEntry *entry = GNT_ENTRY(ggc->entry); | |
709 | |
710 if (!new_arrivals) | |
711 { | |
712 /* Print the list of users in the room */ | |
713 GString *string = g_string_new(_("List of users:\n")); | |
714 GList *iter; | |
715 | |
716 for (iter = users; iter; iter = iter->next) | |
717 { | |
15822 | 718 PurpleConvChatBuddy *cbuddy = iter->data; |
15817 | 719 char *str; |
720 | |
721 if ((str = cbuddy->alias) == NULL) | |
722 str = cbuddy->name; | |
723 g_string_append_printf(string, "[ %s ]", str); | |
724 } | |
725 | |
15822 | 726 purple_conversation_write(conv, NULL, string->str, |
727 PURPLE_MESSAGE_SYSTEM, time(NULL)); | |
15817 | 728 g_string_free(string, TRUE); |
729 } | |
730 | |
731 for (; users; users = users->next) | |
732 { | |
15822 | 733 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
|
734 GntTree *tree = GNT_TREE(ggc->u.chat->userlist); |
15817 | 735 gnt_entry_add_suggest(entry, cbuddy->name); |
736 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
|
737 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
|
738 gnt_tree_create_row(tree, chat_flag_text(cbuddy->flags), cbuddy->alias), NULL, NULL); |
15817 | 739 } |
740 } | |
741 | |
742 static void | |
15822 | 743 finch_chat_rename_user(PurpleConversation *conv, const char *old, const char *new_n, const char *new_a) |
15817 | 744 { |
745 /* Update the name for string completion */ | |
746 FinchConv *ggc = conv->ui_data; | |
747 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
|
748 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
|
749 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
|
750 |
15817 | 751 gnt_entry_remove_suggest(entry, old); |
17070
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
752 gnt_tree_remove(tree, (gpointer)old); |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
753 |
15817 | 754 gnt_entry_add_suggest(entry, new_n); |
755 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
|
756 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
|
757 gnt_tree_create_row(tree, chat_flag_text(cb->flags), new_a), NULL, NULL); |
15817 | 758 } |
759 | |
760 static void | |
17091
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
761 finch_chat_remove_users(PurpleConversation *conv, GList *list) |
15817 | 762 { |
763 /* Remove the name from string completion */ | |
764 FinchConv *ggc = conv->ui_data; | |
765 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
|
766 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
|
767 GntTree *tree = GNT_TREE(ggc->u.chat->userlist); |
15817 | 768 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
|
769 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
|
770 } |
15817 | 771 } |
772 | |
773 static void | |
15822 | 774 finch_chat_update_user(PurpleConversation *conv, const char *user) |
15817 | 775 { |
17070
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
776 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
|
777 FinchConv *ggc = conv->ui_data; |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
778 gnt_tree_change_text(GNT_TREE(ggc->u.chat->userlist), (gpointer)user, 0, chat_flag_text(cb->flags)); |
15817 | 779 } |
780 | |
15822 | 781 static PurpleConversationUiOps conv_ui_ops = |
15817 | 782 { |
17091
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
783 finch_create_conversation, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
784 finch_destroy_conversation, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
785 finch_write_chat, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
786 finch_write_im, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
787 finch_write_conv, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
788 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
|
789 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
|
790 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
|
791 finch_chat_update_user, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
792 NULL, /* present */ |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
793 NULL, /* has_focus */ |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
794 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
|
795 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
|
796 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
|
797 NULL, /* send_confirm */ |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
798 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
799 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
800 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
801 NULL |
15817 | 802 }; |
803 | |
15822 | 804 PurpleConversationUiOps *finch_conv_get_ui_ops() |
15817 | 805 { |
806 return &conv_ui_ops; | |
807 } | |
808 | |
809 /* Xerox */ | |
15822 | 810 static PurpleCmdRet |
811 say_command_cb(PurpleConversation *conv, | |
15817 | 812 const char *cmd, char **args, char **error, void *data) |
813 { | |
15822 | 814 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) |
815 purple_conv_im_send(PURPLE_CONV_IM(conv), args[0]); | |
816 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) | |
817 purple_conv_chat_send(PURPLE_CONV_CHAT(conv), args[0]); | |
15817 | 818 |
15822 | 819 return PURPLE_CMD_RET_OK; |
15817 | 820 } |
821 | |
822 /* Xerox */ | |
15822 | 823 static PurpleCmdRet |
824 me_command_cb(PurpleConversation *conv, | |
15817 | 825 const char *cmd, char **args, char **error, void *data) |
826 { | |
827 char *tmp; | |
828 | |
829 tmp = g_strdup_printf("/me %s", args[0]); | |
830 | |
15822 | 831 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) |
832 purple_conv_im_send(PURPLE_CONV_IM(conv), tmp); | |
833 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) | |
834 purple_conv_chat_send(PURPLE_CONV_CHAT(conv), tmp); | |
15817 | 835 |
836 g_free(tmp); | |
15822 | 837 return PURPLE_CMD_RET_OK; |
15817 | 838 } |
839 | |
840 /* Xerox */ | |
15822 | 841 static PurpleCmdRet |
842 debug_command_cb(PurpleConversation *conv, | |
15817 | 843 const char *cmd, char **args, char **error, void *data) |
844 { | |
845 char *tmp, *markup; | |
15822 | 846 PurpleCmdStatus status; |
15817 | 847 |
848 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
|
849 tmp = g_strdup_printf("me is using Finch v%s.", VERSION); |
15817 | 850 markup = g_markup_escape_text(tmp, -1); |
851 | |
15822 | 852 status = purple_cmd_do_command(conv, tmp, markup, error); |
15817 | 853 |
854 g_free(tmp); | |
855 g_free(markup); | |
856 return status; | |
857 } else { | |
15822 | 858 purple_conversation_write(conv, NULL, _("Supported debug options are: version"), |
859 PURPLE_MESSAGE_NO_LOG|PURPLE_MESSAGE_ERROR, time(NULL)); | |
860 return PURPLE_CMD_STATUS_OK; | |
15817 | 861 } |
862 } | |
863 | |
864 /* Xerox */ | |
15822 | 865 static PurpleCmdRet |
866 clear_command_cb(PurpleConversation *conv, | |
15817 | 867 const char *cmd, char **args, char **error, void *data) |
868 { | |
869 FinchConv *ggconv = conv->ui_data; | |
870 gnt_text_view_clear(GNT_TEXT_VIEW(ggconv->tv)); | |
15822 | 871 return PURPLE_CMD_STATUS_OK; |
15817 | 872 } |
873 | |
874 /* Xerox */ | |
15822 | 875 static PurpleCmdRet |
876 help_command_cb(PurpleConversation *conv, | |
15817 | 877 const char *cmd, char **args, char **error, void *data) |
878 { | |
879 GList *l, *text; | |
880 GString *s; | |
881 | |
882 if (args[0] != NULL) { | |
883 s = g_string_new(""); | |
15822 | 884 text = purple_cmd_help(conv, args[0]); |
15817 | 885 |
886 if (text) { | |
887 for (l = text; l; l = l->next) | |
888 if (l->next) | |
889 g_string_append_printf(s, "%s\n", (char *)l->data); | |
890 else | |
891 g_string_append_printf(s, "%s", (char *)l->data); | |
892 } else { | |
893 g_string_append(s, _("No such command (in this context).")); | |
894 } | |
895 } else { | |
896 s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" | |
897 "The following commands are available in this context:\n")); | |
898 | |
15822 | 899 text = purple_cmd_list(conv); |
15817 | 900 for (l = text; l; l = l->next) |
901 if (l->next) | |
902 g_string_append_printf(s, "%s, ", (char *)l->data); | |
903 else | |
904 g_string_append_printf(s, "%s.", (char *)l->data); | |
905 g_list_free(text); | |
906 } | |
907 | |
15822 | 908 purple_conversation_write(conv, NULL, s->str, PURPLE_MESSAGE_NO_LOG, time(NULL)); |
15817 | 909 g_string_free(s, TRUE); |
910 | |
15822 | 911 return PURPLE_CMD_STATUS_OK; |
15817 | 912 } |
913 | |
15822 | 914 static PurpleCmdRet |
915 cmd_show_window(PurpleConversation *conv, const char *cmd, char **args, char **error, gpointer data) | |
15817 | 916 { |
917 void (*callback)() = data; | |
918 callback(); | |
15822 | 919 return PURPLE_CMD_STATUS_OK; |
15817 | 920 } |
921 | |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
922 static PurpleCmdRet |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
923 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
|
924 { |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
925 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
|
926 FinchConvChat *ch; |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
927 if (!fc) |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
928 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
|
929 |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
930 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
|
931 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
|
932 (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
|
933 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
|
934 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
|
935 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
|
936 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
|
937 } |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
938 |
15817 | 939 void finch_conversation_init() |
940 { | |
15822 | 941 purple_prefs_add_none(PREF_ROOT); |
942 purple_prefs_add_none(PREF_ROOT "/size"); | |
943 purple_prefs_add_int(PREF_ROOT "/size/width", 70); | |
944 purple_prefs_add_int(PREF_ROOT "/size/height", 20); | |
945 purple_prefs_add_none(PREF_ROOT "/position"); | |
946 purple_prefs_add_int(PREF_ROOT "/position/x", 0); | |
947 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
|
948 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
|
949 purple_prefs_add_bool(PREF_USERLIST, FALSE); |
15817 | 950 |
951 /* Xerox the commands */ | |
15822 | 952 purple_cmd_register("say", "S", PURPLE_CMD_P_DEFAULT, |
953 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 954 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); |
15822 | 955 purple_cmd_register("me", "S", PURPLE_CMD_P_DEFAULT, |
956 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 957 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
15822 | 958 purple_cmd_register("debug", "w", PURPLE_CMD_P_DEFAULT, |
959 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 960 debug_command_cb, _("debug <option>: Send various debug information to the current conversation."), NULL); |
15822 | 961 purple_cmd_register("clear", "", PURPLE_CMD_P_DEFAULT, |
962 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 963 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); |
15822 | 964 purple_cmd_register("help", "w", PURPLE_CMD_P_DEFAULT, |
965 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, | |
15817 | 966 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
|
967 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
|
968 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
|
969 users_command_cb, _("users: Show the list of users in the chat."), NULL); |
15817 | 970 |
971 /* Now some commands to bring up some other windows */ | |
15822 | 972 purple_cmd_register("plugins", "", PURPLE_CMD_P_DEFAULT, |
973 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 974 cmd_show_window, _("plugins: Show the plugins window."), finch_plugins_show_all); |
15822 | 975 purple_cmd_register("buddylist", "", PURPLE_CMD_P_DEFAULT, |
976 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 977 cmd_show_window, _("buddylist: Show the buddylist."), finch_blist_show); |
15822 | 978 purple_cmd_register("accounts", "", PURPLE_CMD_P_DEFAULT, |
979 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 980 cmd_show_window, _("accounts: Show the accounts window."), finch_accounts_show_all); |
15822 | 981 purple_cmd_register("debugwin", "", PURPLE_CMD_P_DEFAULT, |
982 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 983 cmd_show_window, _("debugwin: Show the debug window."), finch_debug_window_show); |
15822 | 984 purple_cmd_register("prefs", "", PURPLE_CMD_P_DEFAULT, |
985 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 986 cmd_show_window, _("prefs: Show the preference window."), finch_prefs_show_all); |
15822 | 987 purple_cmd_register("status", "", PURPLE_CMD_P_DEFAULT, |
988 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 989 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
|
990 |
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
991 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
|
992 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
|
993 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
|
994 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
|
995 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
|
996 PURPLE_CALLBACK(chat_left_cb), NULL); |
15817 | 997 } |
998 | |
999 void finch_conversation_uninit() | |
1000 { | |
17021
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
1001 purple_signals_disconnect_by_handle(finch_conv_get_handle()); |
15817 | 1002 } |
1003 | |
15822 | 1004 void finch_conversation_set_active(PurpleConversation *conv) |
15817 | 1005 { |
1006 FinchConv *ggconv = conv->ui_data; | |
15822 | 1007 PurpleAccount *account; |
15817 | 1008 char *title; |
1009 | |
1010 g_return_if_fail(ggconv); | |
1011 g_return_if_fail(g_list_find(ggconv->list, conv)); | |
1012 | |
1013 ggconv->active_conv = conv; | |
15822 | 1014 account = purple_conversation_get_account(conv); |
15817 | 1015 title = get_conversation_title(conv, account); |
1016 gnt_screen_rename_widget(ggconv->window, title); | |
1017 g_free(title); | |
1018 } | |
1019 | |
16128
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1020 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
|
1021 { |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1022 FinchConv *fc = conv->ui_data; |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1023 int height, width; |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1024 |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1025 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
|
1026 |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1027 if (widget) { |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1028 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
|
1029 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
|
1030 } |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1031 |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1032 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
|
1033 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
|
1034 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
|
1035 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
|
1036 } |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1037 |