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