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