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