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