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