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