Mercurial > pidgin.yaz
annotate finch/gntconv.c @ 28758:3161c687d7bc
Don't call aim_src_clientready() until we have activated our feedbag
(and also until after we have our bos rights, but I'm not sure if that
matters). This fixes the bug where AIM block lists recently stopped
working. I imagine AIM permit lists were also broken, as well as the
three ICQ privacy lists.
It's conceivable that this will also fix the bug where your contact
list is sometimes empty, but I have no evidence to support that either
way.
This change will be in the next release of Pidgin, 2.6.3, which will
probably be released within the next week.
Thanks to AOL for telling me what we were doing wrong.
Fixes #10489
Fixes #10499
Fixes #10509
Refs #10411
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 15 Oct 2009 23:42:27 +0000 |
parents | f15b14df260d |
children | 71dc3b5edbe7 |
rev | line source |
---|---|
15818 | 1 /** |
2 * @file gntconv.c GNT Conversation API | |
16194
0f0832c13fcb
Rename the Doxygen group from gntui to finch and define the finch group
Richard Laager <rlaager@wiktel.com>
parents:
16128
diff
changeset
|
3 * @ingroup finch |
20251
6b8bc3309ab7
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@wiktel.com>
parents:
19980
diff
changeset
|
4 */ |
6b8bc3309ab7
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@wiktel.com>
parents:
19980
diff
changeset
|
5 |
6b8bc3309ab7
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@wiktel.com>
parents:
19980
diff
changeset
|
6 /* finch |
15818 | 7 * |
15871
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
8 * Finch is the legal property of its developers, whose names are too numerous |
15818 | 9 * to list here. Please refer to the COPYRIGHT file distributed with this |
10 * source distribution. | |
11 * | |
12 * This program is free software; you can redistribute it and/or modify | |
13 * it under the terms of the GNU General Public License as published by | |
14 * the Free Software Foundation; either version 2 of the License, or | |
15 * (at your option) any later version. | |
16 * | |
17 * This program is distributed in the hope that it will be useful, | |
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 * GNU General Public License for more details. | |
21 * | |
22 * You should have received a copy of the GNU General Public License | |
23 * along with this program; if not, write to the Free Software | |
19680
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19631
diff
changeset
|
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15818 | 25 */ |
26 #include <string.h> | |
27 | |
18210
b8572b937c09
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents:
18100
diff
changeset
|
28 #include "finch.h" |
27663
f7c5bb2f6623
Don't include an internal header in the public finch headers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27598
diff
changeset
|
29 #include <internal.h> |
18210
b8572b937c09
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents:
18100
diff
changeset
|
30 |
15818 | 31 #include <cmds.h> |
28628
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
32 #include <core.h> |
15818 | 33 #include <idle.h> |
34 #include <prefs.h> | |
35 #include <util.h> | |
36 | |
37 #include "gntaccount.h" | |
38 #include "gntblist.h" | |
39 #include "gntconv.h" | |
40 #include "gntdebug.h" | |
22248
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
41 #include "gntlog.h" |
15818 | 42 #include "gntplugin.h" |
23233
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22680
diff
changeset
|
43 #include "gntpounce.h" |
15818 | 44 #include "gntprefs.h" |
23233
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22680
diff
changeset
|
45 #include "gntrequest.h" |
19447
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
46 #include "gntsound.h" |
15818 | 47 #include "gntstatus.h" |
48 | |
49 #include "gnt.h" | |
50 #include "gntbox.h" | |
51 #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
|
52 #include "gntlabel.h" |
16903 | 53 #include "gntmenu.h" |
54 #include "gntmenuitem.h" | |
55 #include "gntmenuitemcheck.h" | |
21738
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
56 #include "gntstyle.h" |
16904
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16903
diff
changeset
|
57 #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
|
58 #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
|
59 #include "gntutils.h" |
16903 | 60 #include "gntwindow.h" |
15818 | 61 |
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
|
62 #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
|
63 #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
|
64 #define PREF_USERLIST PREF_CHAT "/userlist" |
15818 | 65 |
66 #include "config.h" | |
67 | |
17032
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16989
diff
changeset
|
68 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
|
69 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
|
70 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
|
71 |
21738
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
72 static int color_message_receive; |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
73 static int color_message_send; |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
74 static int color_message_highlight; |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
75 static int color_message_action; |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
76 static int color_timestamp; |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
77 |
22215
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
78 static PurpleBuddy * |
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
79 find_buddy_for_conversation(PurpleConversation *conv) |
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
80 { |
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
81 return purple_find_buddy(purple_conversation_get_account(conv), |
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
82 purple_conversation_get_name(conv)); |
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
83 } |
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
84 |
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
85 static PurpleChat * |
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
86 find_chat_for_conversation(PurpleConversation *conv) |
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
87 { |
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
88 return purple_blist_find_chat(purple_conversation_get_account(conv), |
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
89 purple_conversation_get_name(conv)); |
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
90 } |
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
91 |
19980
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
92 static PurpleBlistNode * |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
93 get_conversation_blist_node(PurpleConversation *conv) |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
94 { |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
95 PurpleBlistNode *node = NULL; |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
96 |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
97 switch (purple_conversation_get_type(conv)) { |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
98 case PURPLE_CONV_TYPE_IM: |
22215
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
99 node = (PurpleBlistNode*)find_buddy_for_conversation(conv); |
22212
6bb29f94862c
Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
100 node = node ? purple_blist_node_get_parent(node) : NULL; |
19980
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
101 break; |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
102 case PURPLE_CONV_TYPE_CHAT: |
22215
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
103 node = (PurpleBlistNode*)find_chat_for_conversation(conv); |
19980
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
104 break; |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
105 default: |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
106 break; |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
107 } |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
108 return node; |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
109 } |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
110 |
15818 | 111 static void |
112 send_typing_notification(GntWidget *w, FinchConv *ggconv) | |
113 { | |
114 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
|
115 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
|
116 if (purple_prefs_get_bool("/finch/conversations/notify_typing")) { |
15823 | 117 PurpleConversation *conv = ggconv->active_conv; |
118 PurpleConvIm *im = PURPLE_CONV_IM(conv); | |
15818 | 119 if (!empty) { |
15823 | 120 gboolean send = (purple_conv_im_get_send_typed_timeout(im) == 0); |
15818 | 121 |
15823 | 122 purple_conv_im_stop_send_typed_timeout(im); |
123 purple_conv_im_start_send_typed_timeout(im); | |
124 if (send || (purple_conv_im_get_type_again(im) != 0 && | |
125 time(NULL) > purple_conv_im_get_type_again(im))) { | |
15818 | 126 unsigned int timeout; |
15823 | 127 timeout = serv_send_typing(purple_conversation_get_gc(conv), |
128 purple_conversation_get_name(conv), | |
129 PURPLE_TYPING); | |
130 purple_conv_im_set_type_again(im, timeout); | |
15818 | 131 } |
132 } else { | |
15823 | 133 purple_conv_im_stop_send_typed_timeout(im); |
15818 | 134 |
15823 | 135 serv_send_typing(purple_conversation_get_gc(conv), |
136 purple_conversation_get_name(conv), | |
137 PURPLE_NOT_TYPING); | |
15818 | 138 } |
139 } | |
140 } | |
141 | |
21281
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
142 static void |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
143 entry_key_pressed(GntWidget *w, FinchConv *ggconv) |
15818 | 144 { |
21281
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
145 const char *text = gnt_entry_get_text(GNT_ENTRY(ggconv->entry)); |
23363
54aaea893a89
Send '//message' as '/message', instead of looking for a 'message' command.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23311
diff
changeset
|
146 if (*text == '/' && *(text + 1) != '/') |
15818 | 147 { |
21281
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
148 PurpleConversation *conv = ggconv->active_conv; |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
149 PurpleCmdStatus status; |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
150 const char *cmdline = text + 1; |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
151 char *error = NULL, *escape; |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
152 |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
153 escape = g_markup_escape_text(cmdline, -1); |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
154 status = purple_cmd_do_command(conv, cmdline, escape, &error); |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
155 g_free(escape); |
15818 | 156 |
21281
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
157 switch (status) |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
158 { |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
159 case PURPLE_CMD_STATUS_OK: |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
160 break; |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
161 case PURPLE_CMD_STATUS_NOT_FOUND: |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
162 purple_conversation_write(conv, "", _("No such command."), |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
163 PURPLE_MESSAGE_NO_LOG, time(NULL)); |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
164 break; |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
165 case PURPLE_CMD_STATUS_WRONG_ARGS: |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
166 purple_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
167 "to that command."), |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
168 PURPLE_MESSAGE_NO_LOG, time(NULL)); |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
169 break; |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
170 case PURPLE_CMD_STATUS_FAILED: |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
171 purple_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
172 PURPLE_MESSAGE_NO_LOG, time(NULL)); |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
173 break; |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
174 case PURPLE_CMD_STATUS_WRONG_TYPE: |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
175 if(purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
176 purple_conversation_write(conv, "", _("That command only works in chats, not IMs."), |
15823 | 177 PURPLE_MESSAGE_NO_LOG, time(NULL)); |
21281
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
178 else |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
179 purple_conversation_write(conv, "", _("That command only works in IMs, not chats."), |
15823 | 180 PURPLE_MESSAGE_NO_LOG, time(NULL)); |
21281
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
181 break; |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
182 case PURPLE_CMD_STATUS_WRONG_PRPL: |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
183 purple_conversation_write(conv, "", _("That command doesn't work on this protocol."), |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
184 PURPLE_MESSAGE_NO_LOG, time(NULL)); |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
185 break; |
15818 | 186 } |
21281
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
187 g_free(error); |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
188 } |
22215
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
189 else if (!purple_account_is_connected(purple_conversation_get_account(ggconv->active_conv))) |
21281
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
190 { |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
191 purple_conversation_write(ggconv->active_conv, "", _("Message was not sent, because you are not signed on."), |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
192 PURPLE_MESSAGE_ERROR | PURPLE_MESSAGE_NO_LOG, time(NULL)); |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
193 } |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
194 else |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
195 { |
27516
4fc04d98e1e8
Use purple_markup_escape_text instead of the glib version.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26623
diff
changeset
|
196 char *escape = purple_markup_escape_text((*text == '/' ? text + 1 : text), -1); |
21281
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
197 switch (purple_conversation_get_type(ggconv->active_conv)) |
15818 | 198 { |
21281
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
199 case PURPLE_CONV_TYPE_IM: |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
200 purple_conv_im_send_with_flags(PURPLE_CONV_IM(ggconv->active_conv), escape, PURPLE_MESSAGE_SEND); |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
201 break; |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
202 case PURPLE_CONV_TYPE_CHAT: |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
203 purple_conv_chat_send(PURPLE_CONV_CHAT(ggconv->active_conv), escape); |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
204 break; |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
205 default: |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
206 g_free(escape); |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
207 g_return_if_reached(); |
15818 | 208 } |
21281
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
209 g_free(escape); |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
210 purple_idle_touch(); |
15818 | 211 } |
21281
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
212 gnt_entry_add_to_history(GNT_ENTRY(ggconv->entry), text); |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
213 gnt_entry_clear(GNT_ENTRY(ggconv->entry)); |
15818 | 214 } |
215 | |
216 static void | |
217 closing_window(GntWidget *window, FinchConv *ggconv) | |
218 { | |
219 GList *list = ggconv->list; | |
220 ggconv->window = NULL; | |
221 while (list) { | |
15823 | 222 PurpleConversation *conv = list->data; |
15818 | 223 list = list->next; |
15823 | 224 purple_conversation_destroy(conv); |
15818 | 225 } |
226 } | |
227 | |
228 static void | |
229 size_changed_cb(GntWidget *widget, int width, int height) | |
230 { | |
231 int w, h; | |
232 gnt_widget_get_size(widget, &w, &h); | |
15823 | 233 purple_prefs_set_int(PREF_ROOT "/size/width", w); |
234 purple_prefs_set_int(PREF_ROOT "/size/height", h); | |
15818 | 235 } |
236 | |
237 static void | |
238 save_position_cb(GntWidget *w, int x, int y) | |
239 { | |
15823 | 240 purple_prefs_set_int(PREF_ROOT "/position/x", x); |
241 purple_prefs_set_int(PREF_ROOT "/position/y", y); | |
15818 | 242 } |
243 | |
15823 | 244 static PurpleConversation * |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
245 find_conv_with_contact(PurpleAccount *account, const char *name) |
15818 | 246 { |
15823 | 247 PurpleBlistNode *node; |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
248 PurpleBuddy *buddy = purple_find_buddy(account, name); |
15823 | 249 PurpleConversation *ret = NULL; |
15818 | 250 |
251 if (!buddy) | |
252 return NULL; | |
253 | |
22212
6bb29f94862c
Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
254 for (node = purple_blist_node_get_first_child(purple_blist_node_get_parent((PurpleBlistNode*)buddy)); |
6bb29f94862c
Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
255 node; node = purple_blist_node_get_sibling_next(node)) { |
15823 | 256 if (node == (PurpleBlistNode*)buddy) |
15818 | 257 continue; |
15823 | 258 if ((ret = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, |
22219
797230b3e48e
Add accessor and update finch to not touch the internals of PurpleBuddy and PurpleChat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22217
diff
changeset
|
259 purple_buddy_get_name((PurpleBuddy*)node), purple_buddy_get_account((PurpleBuddy*)node))) != NULL) |
15818 | 260 break; |
261 } | |
262 return ret; | |
263 } | |
264 | |
265 static char * | |
15823 | 266 get_conversation_title(PurpleConversation *conv, PurpleAccount *account) |
15818 | 267 { |
15823 | 268 return g_strdup_printf(_("%s (%s -- %s)"), purple_conversation_get_title(conv), |
269 purple_account_get_username(account), purple_account_get_protocol_name(account)); | |
15818 | 270 } |
271 | |
272 static void | |
15823 | 273 update_buddy_typing(PurpleAccount *account, const char *who, gpointer null) |
15818 | 274 { |
15823 | 275 PurpleConversation *conv; |
15818 | 276 FinchConv *ggc; |
15823 | 277 PurpleConvIm *im = NULL; |
15818 | 278 char *title, *str; |
279 | |
15823 | 280 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, who, account); |
15818 | 281 |
282 if (!conv) | |
283 return; | |
284 | |
15823 | 285 im = PURPLE_CONV_IM(conv); |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
286 ggc = FINCH_GET_DATA(conv); |
15818 | 287 |
15823 | 288 if (purple_conv_im_get_typing_state(im) == PURPLE_TYPING) { |
15818 | 289 int scroll; |
290 str = get_conversation_title(conv, account); | |
291 title = g_strdup_printf(_("%s [%s]"), str, | |
292 gnt_ascii_only() ? "T" : "\342\243\277"); | |
293 g_free(str); | |
294 | |
295 scroll = gnt_text_view_get_lines_below(GNT_TEXT_VIEW(ggc->tv)); | |
22426
ca6bc025aabb
Patch from Kyle Turman to show the alias when available in the typing notification. Closes #4957.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22418
diff
changeset
|
296 str = g_strdup_printf(_("\n%s is typing..."), purple_conversation_get_title(conv)); |
15818 | 297 /* Updating is a little buggy. So just remove and add a new one */ |
298 gnt_text_view_tag_change(GNT_TEXT_VIEW(ggc->tv), "typing", NULL, TRUE); | |
299 gnt_text_view_append_text_with_tag(GNT_TEXT_VIEW(ggc->tv), | |
300 str, GNT_TEXT_FLAG_DIM, "typing"); | |
301 g_free(str); | |
302 if (scroll <= 1) | |
303 gnt_text_view_scroll(GNT_TEXT_VIEW(ggc->tv), 0); | |
304 } else { | |
305 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
|
306 gnt_text_view_tag_change(GNT_TEXT_VIEW(ggc->tv), "typing", " ", TRUE); |
15818 | 307 } |
308 gnt_screen_rename_widget(ggc->window, title); | |
309 g_free(title); | |
310 } | |
311 | |
17032
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16989
diff
changeset
|
312 static void |
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16989
diff
changeset
|
313 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
|
314 { |
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16989
diff
changeset
|
315 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
|
316 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
|
317 } |
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16989
diff
changeset
|
318 |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
319 static void |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
320 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
|
321 { |
22219
797230b3e48e
Add accessor and update finch to not touch the internals of PurpleBuddy and PurpleChat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22217
diff
changeset
|
322 PurpleConversation *conv = find_conv_with_contact(purple_buddy_get_account(buddy), purple_buddy_get_name(buddy)); |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
323 if (conv == NULL) |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
324 return; |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
325 generate_send_to_menu(FINCH_GET_DATA(conv)); |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
326 } |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
327 |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
328 static void |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
329 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
|
330 { |
20053
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19980
diff
changeset
|
331 GList *list = purple_get_ims(); |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19980
diff
changeset
|
332 while (list) { |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19980
diff
changeset
|
333 PurpleConversation *conv = list->data; |
22215
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
334 PurpleConversation *cc = find_conv_with_contact( |
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
335 purple_conversation_get_account(conv), purple_conversation_get_name(conv)); |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
336 if (cc) |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
337 generate_send_to_menu(FINCH_GET_DATA(cc)); |
20053
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19980
diff
changeset
|
338 list = list->next; |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19980
diff
changeset
|
339 } |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19980
diff
changeset
|
340 |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19980
diff
changeset
|
341 if (PURPLE_CONNECTION_IS_CONNECTED(gc)) { |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19980
diff
changeset
|
342 /* We just signed on. Let's see if there's any chat that we have open, |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19980
diff
changeset
|
343 * and hadn't left before the disconnect. */ |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19980
diff
changeset
|
344 list = purple_get_chats(); |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19980
diff
changeset
|
345 while (list) { |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19980
diff
changeset
|
346 PurpleConversation *conv = list->data; |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19980
diff
changeset
|
347 PurpleChat *chat; |
20552
b7460582a135
Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
348 GHashTable *comps = NULL; |
20053
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19980
diff
changeset
|
349 |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19980
diff
changeset
|
350 list = list->next; |
22215
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
351 if (purple_conversation_get_account(conv) != purple_connection_get_account(gc) || |
20053
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19980
diff
changeset
|
352 !purple_conversation_get_data(conv, "want-to-rejoin")) |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19980
diff
changeset
|
353 continue; |
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19980
diff
changeset
|
354 |
22215
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
355 chat = find_chat_for_conversation(conv); |
20053
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19980
diff
changeset
|
356 if (chat == NULL) { |
22214
2b426862ffbf
Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22213
diff
changeset
|
357 PurplePluginProtocolInfo *info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); |
2b426862ffbf
Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22213
diff
changeset
|
358 if (info->chat_info_defaults != NULL) |
22215
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
359 comps = info->chat_info_defaults(gc, purple_conversation_get_name(conv)); |
20552
b7460582a135
Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
360 } else { |
22219
797230b3e48e
Add accessor and update finch to not touch the internals of PurpleBuddy and PurpleChat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22217
diff
changeset
|
361 comps = purple_chat_get_components(chat); |
20053
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19980
diff
changeset
|
362 } |
20552
b7460582a135
Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
363 serv_join_chat(gc, comps); |
b7460582a135
Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
364 if (chat == NULL && comps != NULL) |
b7460582a135
Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
365 g_hash_table_destroy(comps); |
20053
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19980
diff
changeset
|
366 } |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
367 } |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
368 } |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
369 |
15818 | 370 static gpointer |
22007
c38d72677c8a
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents:
21743
diff
changeset
|
371 finch_conv_get_handle(void) |
15818 | 372 { |
373 static int handle; | |
374 return &handle; | |
375 } | |
376 | |
377 static void | |
16903 | 378 clear_scrollback_cb(GntMenuItem *item, gpointer ggconv) |
379 { | |
380 FinchConv *ggc = ggconv; | |
381 gnt_text_view_clear(GNT_TEXT_VIEW(ggc->tv)); | |
382 } | |
383 | |
384 static void | |
385 send_file_cb(GntMenuItem *item, gpointer ggconv) | |
386 { | |
387 FinchConv *ggc = ggconv; | |
388 serv_send_file(purple_conversation_get_gc(ggc->active_conv), | |
389 purple_conversation_get_name(ggc->active_conv), NULL); | |
390 } | |
391 | |
392 static void | |
393 add_pounce_cb(GntMenuItem *item, gpointer ggconv) | |
394 { | |
395 FinchConv *ggc = ggconv; | |
396 finch_pounce_editor_show( | |
397 purple_conversation_get_account(ggc->active_conv), | |
398 purple_conversation_get_name(ggc->active_conv), NULL); | |
399 } | |
400 | |
401 static void | |
402 get_info_cb(GntMenuItem *item, gpointer ggconv) | |
403 { | |
404 FinchConv *ggc = ggconv; | |
17275
319bcb73eb4e
Use utility functions to get user info. Closes #964.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17104
diff
changeset
|
405 finch_retrieve_user_info(purple_conversation_get_gc(ggc->active_conv), |
16903 | 406 purple_conversation_get_name(ggc->active_conv)); |
407 } | |
408 | |
409 static void | |
410 toggle_timestamps_cb(GntMenuItem *item, gpointer ggconv) | |
411 { | |
412 purple_prefs_set_bool(PREF_ROOT "/timestamps", | |
413 !purple_prefs_get_bool(PREF_ROOT "/timestamps")); | |
414 } | |
415 | |
416 static void | |
19445
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
417 toggle_logging_cb(GntMenuItem *item, gpointer ggconv) |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
418 { |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
419 FinchConv *fc = ggconv; |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
420 PurpleConversation *conv = fc->active_conv; |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
421 gboolean logging = gnt_menuitem_check_get_checked(GNT_MENU_ITEM_CHECK(item)); |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
422 GList *iter; |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
423 |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
424 if (logging == purple_conversation_is_logging(conv)) |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
425 return; |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
426 |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
427 /* Xerox */ |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
428 if (logging) { |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
429 /* Enable logging first so the message below can be logged. */ |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
430 purple_conversation_set_logging(conv, TRUE); |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
431 |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
432 purple_conversation_write(conv, NULL, |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
433 _("Logging started. Future messages in this conversation will be logged."), |
22215
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
434 PURPLE_MESSAGE_SYSTEM, time(NULL)); |
19445
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
435 } else { |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
436 purple_conversation_write(conv, NULL, |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
437 _("Logging stopped. Future messages in this conversation will not be logged."), |
22215
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
438 PURPLE_MESSAGE_SYSTEM, time(NULL)); |
19445
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
439 |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
440 /* Disable the logging second, so that the above message can be logged. */ |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
441 purple_conversation_set_logging(conv, FALSE); |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
442 } |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
443 |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
444 /* Each conversation with the same person will have the same logging setting */ |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
445 for (iter = fc->list; iter; iter = iter->next) { |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
446 if (iter->data == conv) |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
447 continue; |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
448 purple_conversation_set_logging(iter->data, logging); |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
449 } |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
450 } |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
451 |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
452 static void |
19447
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
453 toggle_sound_cb(GntMenuItem *item, gpointer ggconv) |
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
454 { |
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
455 FinchConv *fc = ggconv; |
19980
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
456 PurpleBlistNode *node = get_conversation_blist_node(fc->active_conv); |
19447
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
457 fc->flags ^= FINCH_CONV_NO_SOUND; |
19980
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
458 if (node) |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
459 purple_blist_node_set_bool(node, "gnt-mute-sound", !!(fc->flags & FINCH_CONV_NO_SOUND)); |
19447
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
460 } |
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
461 |
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
462 static void |
16903 | 463 send_to_cb(GntMenuItem *m, gpointer n) |
464 { | |
465 PurpleAccount *account = g_object_get_data(G_OBJECT(m), "purple_account"); | |
466 gchar *buddy = g_object_get_data(G_OBJECT(m), "purple_buddy_name"); | |
467 PurpleConversation *conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, buddy); | |
468 finch_conversation_set_active(conv); | |
469 } | |
470 | |
471 static void | |
22248
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
472 view_log_cb(GntMenuItem *n, gpointer ggc) |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
473 { |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
474 FinchConv *fc; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
475 PurpleConversation *conv; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
476 PurpleLogType type; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
477 const char *name; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
478 PurpleAccount *account; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
479 GSList *buddies; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
480 GSList *cur; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
481 |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
482 fc = ggc; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
483 conv = fc->active_conv; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
484 |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
485 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
486 type = PURPLE_LOG_IM; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
487 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
488 type = PURPLE_LOG_CHAT; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
489 else |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
490 return; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
491 |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
492 name = purple_conversation_get_name(conv); |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
493 account = purple_conversation_get_account(conv); |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
494 |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
495 buddies = purple_find_buddies(account, name); |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
496 for (cur = buddies; cur != NULL; cur = cur->next) { |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
497 PurpleBlistNode *node = cur->data; |
25295
53c27ca1bb71
Struct hiding for Finch. PurpleChat:alias and PurpleContact:totalsize are still used.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24176
diff
changeset
|
498 if ((node != NULL) && |
53c27ca1bb71
Struct hiding for Finch. PurpleChat:alias and PurpleContact:totalsize are still used.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24176
diff
changeset
|
499 (purple_blist_node_get_sibling_prev(node) || purple_blist_node_get_sibling_next(node))) { |
53c27ca1bb71
Struct hiding for Finch. PurpleChat:alias and PurpleContact:totalsize are still used.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24176
diff
changeset
|
500 finch_log_show_contact((PurpleContact *)purple_blist_node_get_parent(node)); |
22248
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
501 g_slist_free(buddies); |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
502 return; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
503 } |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
504 } |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
505 g_slist_free(buddies); |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
506 |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
507 finch_log_show(type, name, account); |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
508 } |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
509 |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
510 static void |
16903 | 511 generate_send_to_menu(FinchConv *ggc) |
512 { | |
513 GntWidget *sub, *menu = ggc->menu; | |
514 GntMenuItem *item; | |
515 GSList *buds; | |
516 GList *list = NULL; | |
517 | |
22215
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
518 buds = purple_find_buddies(purple_conversation_get_account(ggc->active_conv), |
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
519 purple_conversation_get_name(ggc->active_conv)); |
16903 | 520 if (!buds) |
521 return; | |
522 | |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
523 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
|
524 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
|
525 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
|
526 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
|
527 } |
16903 | 528 sub = gnt_menu_new(GNT_MENU_POPUP); |
529 gnt_menuitem_set_submenu(item, GNT_MENU(sub)); | |
530 | |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
531 for (; buds; buds = g_slist_delete_link(buds, buds)) { |
25318
0e08c847517d
Update some casts (that the script didn't fix correctly) to GObject macros.
Richard Laager <rlaager@wiktel.com>
parents:
25295
diff
changeset
|
532 PurpleBlistNode *node = PURPLE_BLIST_NODE(purple_buddy_get_contact(PURPLE_BUDDY(buds->data))); |
22212
6bb29f94862c
Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
533 for (node = purple_blist_node_get_first_child(node); node != NULL; |
6bb29f94862c
Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
534 node = purple_blist_node_get_sibling_next(node)) { |
16903 | 535 PurpleBuddy *buddy = (PurpleBuddy *)node; |
536 PurpleAccount *account = purple_buddy_get_account(buddy); | |
537 if (purple_account_is_connected(account)) { | |
538 /* Use the PurplePresence to get unique buddies. */ | |
539 PurplePresence *presence = purple_buddy_get_presence(buddy); | |
540 if (!g_list_find(list, presence)) | |
541 list = g_list_prepend(list, presence); | |
542 } | |
543 } | |
544 } | |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
545 for (list = g_list_reverse(list); list != NULL; list = g_list_delete_link(list, list)) { |
16903 | 546 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
|
547 PurpleBuddy *buddy = purple_presence_get_buddy(pre); |
16903 | 548 PurpleAccount *account = purple_buddy_get_account(buddy); |
549 gchar *name = g_strdup(purple_buddy_get_name(buddy)); | |
550 gchar *text = g_strdup_printf("%s (%s)", purple_buddy_get_name(buddy), purple_account_get_username(account)); | |
551 item = gnt_menuitem_new(text); | |
552 g_free(text); | |
553 gnt_menu_add_item(GNT_MENU(sub), item); | |
554 gnt_menuitem_set_callback(item, send_to_cb, NULL); | |
555 g_object_set_data(G_OBJECT(item), "purple_account", account); | |
556 g_object_set_data_full(G_OBJECT(item), "purple_buddy_name", name, g_free); | |
557 } | |
558 } | |
559 | |
560 static void | |
23233
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22680
diff
changeset
|
561 invite_cb(GntMenuItem *item, gpointer ggconv) |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22680
diff
changeset
|
562 { |
26623
15ae2dea92b3
Open a chat-invite dialog when a buddy is dragged onto a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25318
diff
changeset
|
563 FinchConv *fc = ggconv; |
15ae2dea92b3
Open a chat-invite dialog when a buddy is dragged onto a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25318
diff
changeset
|
564 PurpleConversation *conv = fc->active_conv; |
15ae2dea92b3
Open a chat-invite dialog when a buddy is dragged onto a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25318
diff
changeset
|
565 purple_conv_chat_invite_user(PURPLE_CONV_CHAT(conv), NULL, NULL, TRUE); |
23233
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22680
diff
changeset
|
566 } |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22680
diff
changeset
|
567 |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22680
diff
changeset
|
568 static void |
16903 | 569 gg_create_menu(FinchConv *ggc) |
570 { | |
571 GntWidget *menu, *sub; | |
572 GntMenuItem *item; | |
573 | |
574 ggc->menu = menu = gnt_menu_new(GNT_MENU_TOPLEVEL); | |
575 gnt_window_set_menu(GNT_WINDOW(ggc->window), GNT_MENU(menu)); | |
576 | |
577 item = gnt_menuitem_new(_("Conversation")); | |
578 gnt_menu_add_item(GNT_MENU(menu), item); | |
579 | |
580 sub = gnt_menu_new(GNT_MENU_POPUP); | |
581 gnt_menuitem_set_submenu(item, GNT_MENU(sub)); | |
582 | |
583 item = gnt_menuitem_new(_("Clear Scrollback")); | |
584 gnt_menu_add_item(GNT_MENU(sub), item); | |
585 gnt_menuitem_set_callback(item, clear_scrollback_cb, ggc); | |
586 | |
587 item = gnt_menuitem_check_new(_("Show Timestamps")); | |
588 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item), | |
589 purple_prefs_get_bool(PREF_ROOT "/timestamps")); | |
590 gnt_menu_add_item(GNT_MENU(sub), item); | |
591 gnt_menuitem_set_callback(item, toggle_timestamps_cb, ggc); | |
592 | |
593 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
|
594 PurpleAccount *account = purple_conversation_get_account(ggc->active_conv); |
22213
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22212
diff
changeset
|
595 PurpleConnection *gc = purple_account_get_connection(account); |
22214
2b426862ffbf
Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22213
diff
changeset
|
596 PurplePluginProtocolInfo *pinfo = |
2b426862ffbf
Add accessor and update finch to not touch the internals of PurpleConnection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22213
diff
changeset
|
597 gc ? PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)) : NULL; |
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
|
598 |
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
|
599 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
|
600 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
|
601 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
|
602 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
|
603 } |
16903 | 604 |
605 item = gnt_menuitem_new(_("Add Buddy Pounce...")); | |
606 gnt_menu_add_item(GNT_MENU(sub), item); | |
607 gnt_menuitem_set_callback(item, add_pounce_cb, ggc); | |
608 | |
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
|
609 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
|
610 (!pinfo->can_receive_file || |
22213
16ff37f64e29
Update finch to not touch the internals of PurpleAccount. This also includes a change I made to reduce the Cyclomatic Complexity of one of the functions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22212
diff
changeset
|
611 pinfo->can_receive_file(gc, purple_conversation_get_name(ggc->active_conv)))) { |
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
|
612 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
|
613 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
|
614 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
|
615 } |
16903 | 616 |
617 generate_send_to_menu(ggc); | |
23233
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22680
diff
changeset
|
618 } else if (purple_conversation_get_type(ggc->active_conv) == PURPLE_CONV_TYPE_CHAT) { |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22680
diff
changeset
|
619 item = gnt_menuitem_new(_("Invite...")); |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22680
diff
changeset
|
620 gnt_menu_add_item(GNT_MENU(sub), item); |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22680
diff
changeset
|
621 gnt_menuitem_set_callback(item, invite_cb, ggc); |
16903 | 622 } |
19445
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
623 |
22248
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
624 item = gnt_menuitem_new(_("View Log...")); |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
625 gnt_menu_add_item(GNT_MENU(sub), item); |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
626 gnt_menuitem_set_callback(item, view_log_cb, ggc); |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
627 |
19445
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
628 item = gnt_menuitem_check_new(_("Enable Logging")); |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
629 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item), |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
630 purple_conversation_is_logging(ggc->active_conv)); |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
631 gnt_menu_add_item(GNT_MENU(sub), item); |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
632 gnt_menuitem_set_callback(item, toggle_logging_cb, ggc); |
19447
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
633 |
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
634 item = gnt_menuitem_check_new(_("Enable Sounds")); |
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
635 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item), |
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
636 !(ggc->flags & FINCH_CONV_NO_SOUND)); |
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
637 gnt_menu_add_item(GNT_MENU(sub), item); |
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
638 gnt_menuitem_set_callback(item, toggle_sound_cb, ggc); |
16903 | 639 } |
640 | |
641 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
|
642 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
|
643 { |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16903
diff
changeset
|
644 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
|
645 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
|
646 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
|
647 } |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16903
diff
changeset
|
648 |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16903
diff
changeset
|
649 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
|
650 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
|
651 { |
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
|
652 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
|
653 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
|
654 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
|
655 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
|
656 } |
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
|
657 } |
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
|
658 |
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
|
659 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
|
660 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
|
661 { |
23415
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
662 if (start == entry->start && *start != '/') |
18383
9eb2f4d27990
Use the completion-signal to append a ': ' after a tab-completed nick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18232
diff
changeset
|
663 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
|
664 } |
9eb2f4d27990
Use the completion-signal to append a ': ' after a tab-completed nick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18232
diff
changeset
|
665 |
9eb2f4d27990
Use the completion-signal to append a ': ' after a tab-completed nick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18232
diff
changeset
|
666 static void |
23415
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
667 gg_setup_commands(FinchConv *fconv, gboolean remove_first) |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
668 { |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
669 GList *commands; |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
670 char command[256] = "/"; |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
671 |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
672 if (remove_first) { |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
673 commands = purple_cmd_list(NULL); |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
674 for (; commands; commands = g_list_delete_link(commands, commands)) { |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
675 g_strlcpy(command + 1, commands->data, sizeof(command) - 1); |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
676 gnt_entry_remove_suggest(GNT_ENTRY(fconv->entry), command); |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
677 } |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
678 } |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
679 |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
680 commands = purple_cmd_list(fconv->active_conv); |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
681 for (; commands; commands = g_list_delete_link(commands, commands)) { |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
682 g_strlcpy(command + 1, commands->data, sizeof(command) - 1); |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
683 gnt_entry_add_suggest(GNT_ENTRY(fconv->entry), command); |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
684 } |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
685 } |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
686 |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
687 static void |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
688 cmd_added_cb(const char *cmd, PurpleCmdPriority prior, PurpleCmdFlag flags, |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
689 FinchConv *fconv) |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
690 { |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
691 gg_setup_commands(fconv, TRUE); |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
692 } |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
693 |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
694 static void |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
695 cmd_removed_cb(const char *cmd, FinchConv *fconv) |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
696 { |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
697 char command[256] = "/"; |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
698 g_strlcpy(command + 1, cmd, sizeof(command) - 1); |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
699 gnt_entry_remove_suggest(GNT_ENTRY(fconv->entry), command); |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
700 gg_setup_commands(fconv, TRUE); |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
701 } |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
702 |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
703 static void |
15823 | 704 finch_create_conversation(PurpleConversation *conv) |
15818 | 705 { |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
706 FinchConv *ggc = FINCH_GET_DATA(conv); |
15818 | 707 char *title; |
15823 | 708 PurpleConversationType type; |
709 PurpleConversation *cc; | |
710 PurpleAccount *account; | |
19980
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
711 PurpleBlistNode *convnode = NULL; |
15818 | 712 |
22418
b0b8c94118c8
Make sure an existing conversation selected from the 'Send IM' dialog is given the focus.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22280
diff
changeset
|
713 if (ggc) { |
b0b8c94118c8
Make sure an existing conversation selected from the 'Send IM' dialog is given the focus.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22280
diff
changeset
|
714 gnt_window_present(ggc->window); |
15818 | 715 return; |
22418
b0b8c94118c8
Make sure an existing conversation selected from the 'Send IM' dialog is given the focus.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22280
diff
changeset
|
716 } |
15818 | 717 |
22215
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
718 account = purple_conversation_get_account(conv); |
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
719 cc = find_conv_with_contact(account, purple_conversation_get_name(conv)); |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
720 if (cc && FINCH_GET_DATA(cc)) |
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
721 ggc = FINCH_GET_DATA(cc); |
15818 | 722 else |
723 ggc = g_new0(FinchConv, 1); | |
724 | |
19445
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
725 /* Each conversation with the same person will have the same logging setting */ |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
726 if (ggc->list) { |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
727 purple_conversation_set_logging(conv, |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
728 purple_conversation_is_logging(ggc->list->data)); |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
729 } |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
730 |
15818 | 731 ggc->list = g_list_prepend(ggc->list, conv); |
732 ggc->active_conv = conv; | |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
733 FINCH_SET_DATA(conv, ggc); |
15818 | 734 |
22680
c7c97c62e131
Fix a crash which I think happens when the same buddy is in the buddylist
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22426
diff
changeset
|
735 if (cc && FINCH_GET_DATA(cc) && cc != conv) { |
15818 | 736 finch_conversation_set_active(conv); |
737 return; | |
738 } | |
739 | |
15823 | 740 type = purple_conversation_get_type(conv); |
15818 | 741 title = get_conversation_title(conv, account); |
742 | |
16903 | 743 ggc->window = gnt_vwindow_new(FALSE); |
15818 | 744 gnt_box_set_title(GNT_BOX(ggc->window), title); |
745 gnt_box_set_toplevel(GNT_BOX(ggc->window), TRUE); | |
746 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
|
747 |
22215
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
748 switch (purple_conversation_get_type(conv)) { |
18232
2b1af79e768f
Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
749 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
|
750 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
|
751 break; |
2b1af79e768f
Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
752 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
|
753 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
|
754 break; |
2b1af79e768f
Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
755 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
|
756 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
|
757 break; |
2b1af79e768f
Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
758 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
|
759 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
|
760 break; |
2b1af79e768f
Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
761 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
|
762 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
|
763 break; |
2b1af79e768f
Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
764 } |
15818 | 765 |
766 ggc->tv = gnt_text_view_new(); | |
767 gnt_widget_set_name(ggc->tv, "conversation-window-textview"); | |
15823 | 768 gnt_widget_set_size(ggc->tv, purple_prefs_get_int(PREF_ROOT "/size/width"), |
769 purple_prefs_get_int(PREF_ROOT "/size/height")); | |
15818 | 770 |
16904
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16903
diff
changeset
|
771 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
|
772 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
|
773 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
|
774 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
|
775 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
|
776 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
|
777 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
|
778 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
|
779 gnt_tree_set_hash_fns(GNT_TREE(tree), g_str_hash, g_str_equal, g_free); |
19631
61473f8a5e2b
Use the proper column for searching users in the chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19509
diff
changeset
|
780 gnt_tree_set_search_column(GNT_TREE(tree), 1); |
16904
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16903
diff
changeset
|
781 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
|
782 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
|
783 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
|
784 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
|
785 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
|
786 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
|
787 } else { |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
788 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
|
789 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
|
790 } |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16903
diff
changeset
|
791 |
16128
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
792 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
|
793 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
|
794 |
15818 | 795 ggc->entry = gnt_entry_new(NULL); |
796 gnt_box_add_widget(GNT_BOX(ggc->window), ggc->entry); | |
797 gnt_widget_set_name(ggc->entry, "conversation-window-entry"); | |
798 gnt_entry_set_history_length(GNT_ENTRY(ggc->entry), -1); | |
799 gnt_entry_set_word_suggest(GNT_ENTRY(ggc->entry), TRUE); | |
800 gnt_entry_set_always_suggest(GNT_ENTRY(ggc->entry), FALSE); | |
801 | |
16124
ab3f93232a2d
Add a utility function to assist scrolling in a textview.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15871
diff
changeset
|
802 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
|
803 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
|
804 |
21281
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
805 g_signal_connect_after(G_OBJECT(ggc->entry), "activate", 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
|
806 g_signal_connect(G_OBJECT(ggc->entry), "completion", G_CALLBACK(completion_cb), NULL); |
15818 | 807 g_signal_connect(G_OBJECT(ggc->window), "destroy", G_CALLBACK(closing_window), ggc); |
808 | |
15823 | 809 gnt_widget_set_position(ggc->window, purple_prefs_get_int(PREF_ROOT "/position/x"), |
810 purple_prefs_get_int(PREF_ROOT "/position/y")); | |
15818 | 811 gnt_widget_show(ggc->window); |
812 | |
813 g_signal_connect(G_OBJECT(ggc->tv), "size_changed", G_CALLBACK(size_changed_cb), NULL); | |
814 g_signal_connect(G_OBJECT(ggc->window), "position_set", G_CALLBACK(save_position_cb), NULL); | |
815 | |
15823 | 816 if (type == PURPLE_CONV_TYPE_IM) { |
15818 | 817 g_signal_connect(G_OBJECT(ggc->entry), "text_changed", G_CALLBACK(send_typing_notification), ggc); |
818 } | |
819 | |
19980
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
820 convnode = get_conversation_blist_node(conv); |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
821 if ((convnode && purple_blist_node_get_bool(convnode, "gnt-mute-sound")) || |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19680
diff
changeset
|
822 !finch_sound_is_enabled()) |
19447
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
823 ggc->flags |= FINCH_CONV_NO_SOUND; |
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
824 |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
825 gg_create_menu(ggc); |
23415
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
826 gg_setup_commands(ggc, FALSE); |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
827 |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
828 purple_signal_connect(purple_cmds_get_handle(), "cmd-added", ggc, |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
829 G_CALLBACK(cmd_added_cb), ggc); |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
830 purple_signal_connect(purple_cmds_get_handle(), "cmd-removed", ggc, |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
831 G_CALLBACK(cmd_removed_cb), ggc); |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
832 |
15818 | 833 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
|
834 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
|
835 g_signal_connect(G_OBJECT(ggc->window), "gained-focus", G_CALLBACK(gained_focus_cb), ggc); |
15818 | 836 } |
837 | |
838 static void | |
15823 | 839 finch_destroy_conversation(PurpleConversation *conv) |
15818 | 840 { |
841 /* do stuff here */ | |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
842 FinchConv *ggc = FINCH_GET_DATA(conv); |
15818 | 843 ggc->list = g_list_remove(ggc->list, conv); |
23415
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
844 if (ggc->list && conv == ggc->active_conv) { |
15818 | 845 ggc->active_conv = ggc->list->data; |
23415
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
846 gg_setup_commands(ggc, TRUE); |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
847 } |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
848 |
15818 | 849 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
|
850 g_free(ggc->u.chat); |
23415
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
851 purple_signals_disconnect_by_handle(ggc); |
18222
ef65d43190e5
Fix a few runtime warnings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
852 if (ggc->window) |
ef65d43190e5
Fix a few runtime warnings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
853 gnt_widget_destroy(ggc->window); |
15818 | 854 g_free(ggc); |
855 } | |
856 } | |
857 | |
858 static void | |
15823 | 859 finch_write_common(PurpleConversation *conv, const char *who, const char *message, |
860 PurpleMessageFlags flags, time_t mtime) | |
15818 | 861 { |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
862 FinchConv *ggconv = FINCH_GET_DATA(conv); |
15818 | 863 char *strip, *newline; |
864 GntTextFormatFlags fl = 0; | |
865 int pos; | |
866 | |
867 g_return_if_fail(ggconv != NULL); | |
868 | |
24176
c1e58cfd1107
Set the urgent flag for conversation windows on receiving a /buzz etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23833
diff
changeset
|
869 if ((flags & PURPLE_MESSAGE_SYSTEM) && !(flags & PURPLE_MESSAGE_NOTIFY)) { |
22280
d680613669cc
Ignore the recv/send flags when the system flag is set for a message.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22279
diff
changeset
|
870 flags &= ~(PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV); |
d680613669cc
Ignore the recv/send flags when the system flag is set for a message.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22279
diff
changeset
|
871 } |
d680613669cc
Ignore the recv/send flags when the system flag is set for a message.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22279
diff
changeset
|
872 |
15818 | 873 if (ggconv->active_conv != conv) { |
15823 | 874 if (flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV)) |
15818 | 875 finch_conversation_set_active(conv); |
876 else | |
877 return; | |
878 } | |
879 | |
880 pos = gnt_text_view_get_lines_below(GNT_TEXT_VIEW(ggconv->tv)); | |
881 | |
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
|
882 gnt_text_view_tag_change(GNT_TEXT_VIEW(ggconv->tv), "typing", NULL, TRUE); |
15818 | 883 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), "\n", GNT_TEXT_FLAG_NORMAL); |
884 | |
885 /* Unnecessary to print the timestamp for delayed message */ | |
27598
37741237d146
Show the current time if the timestamp is zero.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27516
diff
changeset
|
886 if (purple_prefs_get_bool("/finch/conversations/timestamps")) { |
37741237d146
Show the current time if the timestamp is zero.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27516
diff
changeset
|
887 if (!mtime) |
37741237d146
Show the current time if the timestamp is zero.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27516
diff
changeset
|
888 time(&mtime); |
15818 | 889 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), |
21738
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
890 purple_utf8_strftime("(%H:%M:%S)", localtime(&mtime)), gnt_color_pair(color_timestamp)); |
27598
37741237d146
Show the current time if the timestamp is zero.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27516
diff
changeset
|
891 } |
21738
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
892 |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
893 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), " ", GNT_TEXT_FLAG_NORMAL); |
15818 | 894 |
15823 | 895 if (flags & PURPLE_MESSAGE_AUTO_RESP) |
15818 | 896 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), |
897 _("<AUTO-REPLY> "), GNT_TEXT_FLAG_BOLD); | |
898 | |
20553
bed3c9affda6
Show 'buzz'/'nudge' etc. messages differently from regular messages.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20552
diff
changeset
|
899 if (who && *who && (flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV)) && |
bed3c9affda6
Show 'buzz'/'nudge' etc. messages differently from regular messages.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20552
diff
changeset
|
900 !(flags & PURPLE_MESSAGE_NOTIFY)) |
15818 | 901 { |
902 char * name = NULL; | |
21743
5ff16647c50d
Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21738
diff
changeset
|
903 GntTextFormatFlags msgflags = GNT_TEXT_FLAG_NORMAL; |
5ff16647c50d
Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21738
diff
changeset
|
904 gboolean me = FALSE; |
15818 | 905 |
21738
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
906 if (purple_message_meify((char*)message, -1)) { |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
907 name = g_strdup_printf("*** %s", who); |
22279
40707fbabcbc
Highlighted message color has a higher priority over an action message color.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22248
diff
changeset
|
908 if (!(flags & PURPLE_MESSAGE_SEND) && |
40707fbabcbc
Highlighted message color has a higher priority over an action message color.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22248
diff
changeset
|
909 (flags & PURPLE_MESSAGE_NICK)) |
40707fbabcbc
Highlighted message color has a higher priority over an action message color.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22248
diff
changeset
|
910 msgflags = gnt_color_pair(color_message_highlight); |
40707fbabcbc
Highlighted message color has a higher priority over an action message color.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22248
diff
changeset
|
911 else |
40707fbabcbc
Highlighted message color has a higher priority over an action message color.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22248
diff
changeset
|
912 msgflags = gnt_color_pair(color_message_action); |
21743
5ff16647c50d
Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21738
diff
changeset
|
913 me = TRUE; |
21738
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
914 } else { |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
915 name = g_strdup_printf("%s", who); |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
916 if (flags & PURPLE_MESSAGE_SEND) |
21743
5ff16647c50d
Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21738
diff
changeset
|
917 msgflags = gnt_color_pair(color_message_send); |
5ff16647c50d
Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21738
diff
changeset
|
918 else if (flags & PURPLE_MESSAGE_NICK) |
5ff16647c50d
Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21738
diff
changeset
|
919 msgflags = gnt_color_pair(color_message_highlight); |
21738
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
920 else |
21743
5ff16647c50d
Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21738
diff
changeset
|
921 msgflags = gnt_color_pair(color_message_receive); |
21738
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
922 } |
21743
5ff16647c50d
Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21738
diff
changeset
|
923 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), |
5ff16647c50d
Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21738
diff
changeset
|
924 name, msgflags); |
5ff16647c50d
Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21738
diff
changeset
|
925 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), me ? " " : ": ", GNT_TEXT_FLAG_NORMAL); |
15818 | 926 g_free(name); |
21738
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
927 } else |
15818 | 928 fl = GNT_TEXT_FLAG_DIM; |
929 | |
15823 | 930 if (flags & PURPLE_MESSAGE_ERROR) |
15818 | 931 fl |= GNT_TEXT_FLAG_BOLD; |
932 | |
933 /* XXX: Remove this workaround when textview can parse messages. */ | |
15823 | 934 newline = purple_strdup_withhtml(message); |
935 strip = purple_markup_strip_html(newline); | |
15818 | 936 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), |
937 strip, fl); | |
938 | |
939 g_free(newline); | |
940 g_free(strip); | |
941 | |
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
|
942 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
|
943 purple_conv_im_get_typing_state(PURPLE_CONV_IM(conv)) == PURPLE_TYPING) { |
22426
ca6bc025aabb
Patch from Kyle Turman to show the alias when available in the typing notification. Closes #4957.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22418
diff
changeset
|
944 strip = g_strdup_printf(_("\n%s is typing..."), purple_conversation_get_title(conv)); |
15818 | 945 gnt_text_view_append_text_with_tag(GNT_TEXT_VIEW(ggconv->tv), |
946 strip, GNT_TEXT_FLAG_DIM, "typing"); | |
947 g_free(strip); | |
948 } | |
949 | |
950 if (pos <= 1) | |
951 gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), 0); | |
952 | |
15823 | 953 if (flags & (PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_NICK | PURPLE_MESSAGE_ERROR)) |
15818 | 954 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
|
955 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
|
956 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
|
957 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
|
958 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
|
959 } |
15818 | 960 } |
961 | |
962 static void | |
15823 | 963 finch_write_chat(PurpleConversation *conv, const char *who, const char *message, |
964 PurpleMessageFlags flags, time_t mtime) | |
15818 | 965 { |
15823 | 966 purple_conversation_write(conv, who, message, flags, mtime); |
15818 | 967 } |
968 | |
969 static void | |
15823 | 970 finch_write_im(PurpleConversation *conv, const char *who, const char *message, |
971 PurpleMessageFlags flags, time_t mtime) | |
15818 | 972 { |
15823 | 973 PurpleAccount *account = purple_conversation_get_account(conv); |
974 if (flags & PURPLE_MESSAGE_SEND) | |
15818 | 975 { |
15823 | 976 who = purple_connection_get_display_name(purple_account_get_connection(account)); |
15818 | 977 if (!who) |
15823 | 978 who = purple_account_get_alias(account); |
15818 | 979 if (!who) |
15823 | 980 who = purple_account_get_username(account); |
15818 | 981 } |
15823 | 982 else if (flags & PURPLE_MESSAGE_RECV) |
15818 | 983 { |
15823 | 984 PurpleBuddy *buddy; |
985 who = purple_conversation_get_name(conv); | |
986 buddy = purple_find_buddy(account, who); | |
15818 | 987 if (buddy) |
15823 | 988 who = purple_buddy_get_contact_alias(buddy); |
15818 | 989 } |
990 | |
15823 | 991 purple_conversation_write(conv, who, message, flags, mtime); |
15818 | 992 } |
993 | |
994 static void | |
15823 | 995 finch_write_conv(PurpleConversation *conv, const char *who, const char *alias, |
996 const char *message, PurpleMessageFlags flags, time_t mtime) | |
15818 | 997 { |
998 const char *name; | |
999 if (alias && *alias) | |
1000 name = alias; | |
1001 else if (who && *who) | |
1002 name = who; | |
1003 else | |
1004 name = NULL; | |
1005 | |
1006 finch_write_common(conv, name, message, flags, mtime); | |
1007 } | |
1008 | |
17083
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17032
diff
changeset
|
1009 static const char * |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17032
diff
changeset
|
1010 chat_flag_text(PurpleConvChatBuddyFlags flags) |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17032
diff
changeset
|
1011 { |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17032
diff
changeset
|
1012 if (flags & PURPLE_CBFLAGS_FOUNDER) |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17032
diff
changeset
|
1013 return "~"; |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17032
diff
changeset
|
1014 if (flags & PURPLE_CBFLAGS_OP) |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17032
diff
changeset
|
1015 return "@"; |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17032
diff
changeset
|
1016 if (flags & PURPLE_CBFLAGS_HALFOP) |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17032
diff
changeset
|
1017 return "%"; |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17032
diff
changeset
|
1018 if (flags & PURPLE_CBFLAGS_VOICE) |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17032
diff
changeset
|
1019 return "+"; |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17032
diff
changeset
|
1020 return " "; |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17032
diff
changeset
|
1021 } |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17032
diff
changeset
|
1022 |
15818 | 1023 static void |
15823 | 1024 finch_chat_add_users(PurpleConversation *conv, GList *users, gboolean new_arrivals) |
15818 | 1025 { |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
1026 FinchConv *ggc = FINCH_GET_DATA(conv); |
15818 | 1027 GntEntry *entry = GNT_ENTRY(ggc->entry); |
1028 | |
1029 if (!new_arrivals) | |
1030 { | |
1031 /* Print the list of users in the room */ | |
23442
f4b2fecfb557
Show the count of users when joining a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23415
diff
changeset
|
1032 GString *string = g_string_new(NULL); |
15818 | 1033 GList *iter; |
23442
f4b2fecfb557
Show the count of users when joining a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23415
diff
changeset
|
1034 int count = g_list_length(users); |
15818 | 1035 |
23442
f4b2fecfb557
Show the count of users when joining a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23415
diff
changeset
|
1036 g_string_printf(string, |
f4b2fecfb557
Show the count of users when joining a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23415
diff
changeset
|
1037 ngettext("List of %d user:\n", "List of %d users:\n", count), count); |
15818 | 1038 for (iter = users; iter; iter = iter->next) |
1039 { | |
15823 | 1040 PurpleConvChatBuddy *cbuddy = iter->data; |
15818 | 1041 char *str; |
1042 | |
1043 if ((str = cbuddy->alias) == NULL) | |
1044 str = cbuddy->name; | |
1045 g_string_append_printf(string, "[ %s ]", str); | |
1046 } | |
1047 | |
15823 | 1048 purple_conversation_write(conv, NULL, string->str, |
1049 PURPLE_MESSAGE_SYSTEM, time(NULL)); | |
15818 | 1050 g_string_free(string, TRUE); |
1051 } | |
1052 | |
1053 for (; users; users = users->next) | |
1054 { | |
15823 | 1055 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
|
1056 GntTree *tree = GNT_TREE(ggc->u.chat->userlist); |
15818 | 1057 gnt_entry_add_suggest(entry, cbuddy->name); |
1058 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
|
1059 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
|
1060 gnt_tree_create_row(tree, chat_flag_text(cbuddy->flags), cbuddy->alias), NULL, NULL); |
15818 | 1061 } |
1062 } | |
1063 | |
1064 static void | |
15823 | 1065 finch_chat_rename_user(PurpleConversation *conv, const char *old, const char *new_n, const char *new_a) |
15818 | 1066 { |
1067 /* Update the name for string completion */ | |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
1068 FinchConv *ggc = FINCH_GET_DATA(conv); |
15818 | 1069 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
|
1070 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
|
1071 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
|
1072 |
15818 | 1073 gnt_entry_remove_suggest(entry, old); |
17083
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17032
diff
changeset
|
1074 gnt_tree_remove(tree, (gpointer)old); |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17032
diff
changeset
|
1075 |
15818 | 1076 gnt_entry_add_suggest(entry, new_n); |
1077 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
|
1078 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
|
1079 gnt_tree_create_row(tree, chat_flag_text(cb->flags), new_a), NULL, NULL); |
15818 | 1080 } |
1081 | |
1082 static void | |
17104
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17083
diff
changeset
|
1083 finch_chat_remove_users(PurpleConversation *conv, GList *list) |
15818 | 1084 { |
1085 /* Remove the name from string completion */ | |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
1086 FinchConv *ggc = FINCH_GET_DATA(conv); |
15818 | 1087 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
|
1088 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
|
1089 GntTree *tree = GNT_TREE(ggc->u.chat->userlist); |
15818 | 1090 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
|
1091 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
|
1092 } |
15818 | 1093 } |
1094 | |
1095 static void | |
15823 | 1096 finch_chat_update_user(PurpleConversation *conv, const char *user) |
15818 | 1097 { |
17083
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17032
diff
changeset
|
1098 PurpleConvChatBuddy *cb = purple_conv_chat_cb_find(PURPLE_CONV_CHAT(conv), user); |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
1099 FinchConv *ggc = FINCH_GET_DATA(conv); |
17083
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17032
diff
changeset
|
1100 gnt_tree_change_text(GNT_TREE(ggc->u.chat->userlist), (gpointer)user, 0, chat_flag_text(cb->flags)); |
15818 | 1101 } |
1102 | |
19446
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1103 static void |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1104 finch_conv_present(PurpleConversation *conv) |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1105 { |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1106 FinchConv *fc = FINCH_CONV(conv); |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1107 if (fc && fc->window) |
20718
803f0ee0c231
void functions shouldn't 'return'. Thanks tmcmahon2. Fixes #3151 (gntconv.c fails to compile in Solaris 9)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20553
diff
changeset
|
1108 gnt_window_present(fc->window); |
19446
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1109 } |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1110 |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1111 static gboolean |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1112 finch_conv_has_focus(PurpleConversation *conv) |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1113 { |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1114 FinchConv *fc = FINCH_CONV(conv); |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1115 if (fc && fc->window) |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1116 return gnt_widget_has_focus(fc->window); |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1117 return FALSE; |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1118 } |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1119 |
15823 | 1120 static PurpleConversationUiOps conv_ui_ops = |
15818 | 1121 { |
17104
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17083
diff
changeset
|
1122 finch_create_conversation, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17083
diff
changeset
|
1123 finch_destroy_conversation, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17083
diff
changeset
|
1124 finch_write_chat, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17083
diff
changeset
|
1125 finch_write_im, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17083
diff
changeset
|
1126 finch_write_conv, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17083
diff
changeset
|
1127 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
|
1128 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
|
1129 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
|
1130 finch_chat_update_user, |
19446
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1131 finch_conv_present, /* present */ |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1132 finch_conv_has_focus, /* has_focus */ |
17104
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17083
diff
changeset
|
1133 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
|
1134 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
|
1135 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
|
1136 NULL, /* send_confirm */ |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17083
diff
changeset
|
1137 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17083
diff
changeset
|
1138 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17083
diff
changeset
|
1139 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17083
diff
changeset
|
1140 NULL |
15818 | 1141 }; |
1142 | |
15823 | 1143 PurpleConversationUiOps *finch_conv_get_ui_ops() |
15818 | 1144 { |
1145 return &conv_ui_ops; | |
1146 } | |
1147 | |
1148 /* Xerox */ | |
15823 | 1149 static PurpleCmdRet |
1150 say_command_cb(PurpleConversation *conv, | |
15818 | 1151 const char *cmd, char **args, char **error, void *data) |
1152 { | |
15823 | 1153 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) |
1154 purple_conv_im_send(PURPLE_CONV_IM(conv), args[0]); | |
1155 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) | |
1156 purple_conv_chat_send(PURPLE_CONV_CHAT(conv), args[0]); | |
15818 | 1157 |
15823 | 1158 return PURPLE_CMD_RET_OK; |
15818 | 1159 } |
1160 | |
1161 /* Xerox */ | |
15823 | 1162 static PurpleCmdRet |
1163 me_command_cb(PurpleConversation *conv, | |
15818 | 1164 const char *cmd, char **args, char **error, void *data) |
1165 { | |
1166 char *tmp; | |
1167 | |
1168 tmp = g_strdup_printf("/me %s", args[0]); | |
1169 | |
15823 | 1170 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) |
1171 purple_conv_im_send(PURPLE_CONV_IM(conv), tmp); | |
1172 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) | |
1173 purple_conv_chat_send(PURPLE_CONV_CHAT(conv), tmp); | |
15818 | 1174 |
1175 g_free(tmp); | |
15823 | 1176 return PURPLE_CMD_RET_OK; |
15818 | 1177 } |
1178 | |
1179 /* Xerox */ | |
15823 | 1180 static PurpleCmdRet |
1181 debug_command_cb(PurpleConversation *conv, | |
15818 | 1182 const char *cmd, char **args, char **error, void *data) |
1183 { | |
1184 char *tmp, *markup; | |
1185 | |
1186 if (!g_ascii_strcasecmp(args[0], "version")) { | |
28628
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1187 tmp = g_strdup_printf("Using Finch v%s with libpurple v%s.", |
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1188 DISPLAY_VERSION, purple_core_get_version()); |
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1189 } else if (!g_ascii_strcasecmp(args[0], "plugins")) { |
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1190 /* Show all the loaded plugins, including the protocol plugins and plugin loaders. |
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1191 * This is intentional, since third party prpls are often sources of bugs, and some |
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1192 * plugin loaders (e.g. mono) can also be buggy. |
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1193 */ |
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1194 GString *str = g_string_new("Loaded Plugins: "); |
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1195 const GList *plugins = purple_plugins_get_loaded(); |
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1196 if (plugins) { |
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1197 for (; plugins; plugins = plugins->next) { |
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1198 str = g_string_append(str, purple_plugin_get_name(plugins->data)); |
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1199 if (plugins->next) |
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1200 str = g_string_append(str, ", "); |
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1201 } |
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1202 } else { |
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1203 str = g_string_append(str, "(none)"); |
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1204 } |
15818 | 1205 |
28628
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1206 tmp = g_string_free(str, FALSE); |
15818 | 1207 } else { |
28628
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1208 purple_conversation_write(conv, NULL, _("Supported debug options are: plugins version"), |
15823 | 1209 PURPLE_MESSAGE_NO_LOG|PURPLE_MESSAGE_ERROR, time(NULL)); |
28629
f15b14df260d
Return the proper enum values from command callbacks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28628
diff
changeset
|
1210 return PURPLE_CMD_RET_OK; |
15818 | 1211 } |
28628
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1212 |
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1213 markup = g_markup_escape_text(tmp, -1); |
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1214 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) |
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1215 purple_conv_im_send(PURPLE_CONV_IM(conv), markup); |
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1216 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) |
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1217 purple_conv_chat_send(PURPLE_CONV_CHAT(conv), markup); |
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1218 |
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1219 g_free(tmp); |
574fd92ff3e5
'/debug plugins' will announce the list of loaded plugins.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
27663
diff
changeset
|
1220 g_free(markup); |
28629
f15b14df260d
Return the proper enum values from command callbacks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28628
diff
changeset
|
1221 return PURPLE_CMD_RET_OK; |
15818 | 1222 } |
1223 | |
1224 /* Xerox */ | |
15823 | 1225 static PurpleCmdRet |
1226 clear_command_cb(PurpleConversation *conv, | |
15818 | 1227 const char *cmd, char **args, char **error, void *data) |
1228 { | |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
1229 FinchConv *ggconv = FINCH_GET_DATA(conv); |
15818 | 1230 gnt_text_view_clear(GNT_TEXT_VIEW(ggconv->tv)); |
19422
a277162b976e
Clear the message history in the /clear callback.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
1231 purple_conversation_clear_message_history(conv); |
28629
f15b14df260d
Return the proper enum values from command callbacks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28628
diff
changeset
|
1232 return PURPLE_CMD_RET_OK; |
15818 | 1233 } |
1234 | |
1235 /* Xerox */ | |
15823 | 1236 static PurpleCmdRet |
1237 help_command_cb(PurpleConversation *conv, | |
15818 | 1238 const char *cmd, char **args, char **error, void *data) |
1239 { | |
1240 GList *l, *text; | |
1241 GString *s; | |
1242 | |
1243 if (args[0] != NULL) { | |
1244 s = g_string_new(""); | |
15823 | 1245 text = purple_cmd_help(conv, args[0]); |
15818 | 1246 |
1247 if (text) { | |
1248 for (l = text; l; l = l->next) | |
1249 if (l->next) | |
1250 g_string_append_printf(s, "%s\n", (char *)l->data); | |
1251 else | |
1252 g_string_append_printf(s, "%s", (char *)l->data); | |
1253 } else { | |
1254 g_string_append(s, _("No such command (in this context).")); | |
1255 } | |
1256 } else { | |
1257 s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" | |
1258 "The following commands are available in this context:\n")); | |
1259 | |
15823 | 1260 text = purple_cmd_list(conv); |
15818 | 1261 for (l = text; l; l = l->next) |
1262 if (l->next) | |
1263 g_string_append_printf(s, "%s, ", (char *)l->data); | |
1264 else | |
1265 g_string_append_printf(s, "%s.", (char *)l->data); | |
1266 g_list_free(text); | |
1267 } | |
1268 | |
15823 | 1269 purple_conversation_write(conv, NULL, s->str, PURPLE_MESSAGE_NO_LOG, time(NULL)); |
15818 | 1270 g_string_free(s, TRUE); |
1271 | |
28629
f15b14df260d
Return the proper enum values from command callbacks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28628
diff
changeset
|
1272 return PURPLE_CMD_RET_OK; |
15818 | 1273 } |
1274 | |
15823 | 1275 static PurpleCmdRet |
1276 cmd_show_window(PurpleConversation *conv, const char *cmd, char **args, char **error, gpointer data) | |
15818 | 1277 { |
22007
c38d72677c8a
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents:
21743
diff
changeset
|
1278 void (*callback)(void) = data; |
15818 | 1279 callback(); |
28629
f15b14df260d
Return the proper enum values from command callbacks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28628
diff
changeset
|
1280 return PURPLE_CMD_RET_OK; |
15818 | 1281 } |
1282 | |
23833
240d847e9e88
Fix compiling with glib < 2.6
Stu Tomlinson <stu@nosnilmot.com>
parents:
23442
diff
changeset
|
1283 #if GLIB_CHECK_VERSION(2,6,0) |
16904
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16903
diff
changeset
|
1284 static PurpleCmdRet |
23311
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1285 cmd_message_color(PurpleConversation *conv, const char *cmd, char **args, char **error, gpointer data) |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1286 { |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1287 int *msgclass = NULL; |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1288 int fg, bg; |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1289 |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1290 if (strcmp(args[0], "receive") == 0) |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1291 msgclass = &color_message_receive; |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1292 else if (strcmp(args[0], "send") == 0) |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1293 msgclass = &color_message_send; |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1294 else if (strcmp(args[0], "highlight") == 0) |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1295 msgclass = &color_message_highlight; |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1296 else if (strcmp(args[0], "action") == 0) |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1297 msgclass = &color_message_action; |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1298 else if (strcmp(args[0], "timestamp") == 0) |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1299 msgclass = &color_timestamp; |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1300 else { |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1301 if (error) |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1302 *error = g_strdup_printf(_("%s is not a valid message class. See '/help msgcolor' for valid message classes."), args[0]); |
28629
f15b14df260d
Return the proper enum values from command callbacks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28628
diff
changeset
|
1303 return PURPLE_CMD_RET_FAILED; |
23311
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1304 } |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1305 |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1306 fg = gnt_colors_get_color(args[1]); |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1307 if (fg == -EINVAL) { |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1308 if (error) |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1309 *error = g_strdup_printf(_("%s is not a valid color. See '/help msgcolor' for valid colors."), args[1]); |
28629
f15b14df260d
Return the proper enum values from command callbacks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28628
diff
changeset
|
1310 return PURPLE_CMD_RET_FAILED; |
23311
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1311 } |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1312 |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1313 bg = gnt_colors_get_color(args[2]); |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1314 if (bg == -EINVAL) { |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1315 if (error) |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1316 *error = g_strdup_printf(_("%s is not a valid color. See '/help msgcolor' for valid colors."), args[2]); |
28629
f15b14df260d
Return the proper enum values from command callbacks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28628
diff
changeset
|
1317 return PURPLE_CMD_RET_FAILED; |
23311
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1318 } |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1319 |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1320 init_pair(*msgclass, fg, bg); |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1321 |
28629
f15b14df260d
Return the proper enum values from command callbacks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28628
diff
changeset
|
1322 return PURPLE_CMD_RET_OK; |
23311
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1323 } |
23833
240d847e9e88
Fix compiling with glib < 2.6
Stu Tomlinson <stu@nosnilmot.com>
parents:
23442
diff
changeset
|
1324 #endif |
23311
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1325 |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1326 static PurpleCmdRet |
16904
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16903
diff
changeset
|
1327 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
|
1328 { |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
1329 FinchConv *fc = FINCH_GET_DATA(conv); |
16904
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16903
diff
changeset
|
1330 FinchConvChat *ch; |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16903
diff
changeset
|
1331 if (!fc) |
28629
f15b14df260d
Return the proper enum values from command callbacks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28628
diff
changeset
|
1332 return PURPLE_CMD_RET_FAILED; |
16904
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16903
diff
changeset
|
1333 |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16903
diff
changeset
|
1334 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
|
1335 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
|
1336 (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
|
1337 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
|
1338 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
|
1339 purple_prefs_set_bool(PREF_USERLIST, !(GNT_WIDGET_IS_FLAG_SET(ch->userlist, GNT_WIDGET_INVISIBLE))); |
28629
f15b14df260d
Return the proper enum values from command callbacks.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28628
diff
changeset
|
1340 return PURPLE_CMD_RET_OK; |
16904
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16903
diff
changeset
|
1341 } |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16903
diff
changeset
|
1342 |
15818 | 1343 void finch_conversation_init() |
1344 { | |
21738
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
1345 color_message_send = gnt_style_get_color(NULL, "color-message-sent"); |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
1346 if (!color_message_send) |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
1347 color_message_send = gnt_color_add_pair(COLOR_CYAN, -1); |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
1348 color_message_receive = gnt_style_get_color(NULL, "color-message-received"); |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
1349 if (!color_message_receive) |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
1350 color_message_receive = gnt_color_add_pair(COLOR_RED, -1); |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
1351 color_message_highlight = gnt_style_get_color(NULL, "color-message-highlight"); |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
1352 if (!color_message_highlight) |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
1353 color_message_highlight = gnt_color_add_pair(COLOR_GREEN, -1); |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
1354 color_timestamp = gnt_style_get_color(NULL, "color-timestamp"); |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
1355 if (!color_timestamp) |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
1356 color_timestamp = gnt_color_add_pair(COLOR_BLUE, -1); |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
1357 color_message_action = gnt_style_get_color(NULL, "color-message-action"); |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
1358 if (!color_message_action) |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
1359 color_message_action = gnt_color_add_pair(COLOR_YELLOW, -1); |
15823 | 1360 purple_prefs_add_none(PREF_ROOT); |
1361 purple_prefs_add_none(PREF_ROOT "/size"); | |
1362 purple_prefs_add_int(PREF_ROOT "/size/width", 70); | |
1363 purple_prefs_add_int(PREF_ROOT "/size/height", 20); | |
1364 purple_prefs_add_none(PREF_ROOT "/position"); | |
1365 purple_prefs_add_int(PREF_ROOT "/position/x", 0); | |
1366 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
|
1367 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
|
1368 purple_prefs_add_bool(PREF_USERLIST, FALSE); |
15818 | 1369 |
1370 /* Xerox the commands */ | |
15823 | 1371 purple_cmd_register("say", "S", PURPLE_CMD_P_DEFAULT, |
1372 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15818 | 1373 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); |
15823 | 1374 purple_cmd_register("me", "S", PURPLE_CMD_P_DEFAULT, |
1375 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15818 | 1376 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
15823 | 1377 purple_cmd_register("debug", "w", PURPLE_CMD_P_DEFAULT, |
1378 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15818 | 1379 debug_command_cb, _("debug <option>: Send various debug information to the current conversation."), NULL); |
15823 | 1380 purple_cmd_register("clear", "", PURPLE_CMD_P_DEFAULT, |
1381 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15818 | 1382 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); |
15823 | 1383 purple_cmd_register("help", "w", PURPLE_CMD_P_DEFAULT, |
1384 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, | |
15818 | 1385 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
|
1386 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
|
1387 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
|
1388 users_command_cb, _("users: Show the list of users in the chat."), NULL); |
15818 | 1389 |
1390 /* Now some commands to bring up some other windows */ | |
15823 | 1391 purple_cmd_register("plugins", "", PURPLE_CMD_P_DEFAULT, |
1392 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15818 | 1393 cmd_show_window, _("plugins: Show the plugins window."), finch_plugins_show_all); |
15823 | 1394 purple_cmd_register("buddylist", "", PURPLE_CMD_P_DEFAULT, |
1395 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15818 | 1396 cmd_show_window, _("buddylist: Show the buddylist."), finch_blist_show); |
15823 | 1397 purple_cmd_register("accounts", "", PURPLE_CMD_P_DEFAULT, |
1398 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15818 | 1399 cmd_show_window, _("accounts: Show the accounts window."), finch_accounts_show_all); |
15823 | 1400 purple_cmd_register("debugwin", "", PURPLE_CMD_P_DEFAULT, |
1401 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15818 | 1402 cmd_show_window, _("debugwin: Show the debug window."), finch_debug_window_show); |
15823 | 1403 purple_cmd_register("prefs", "", PURPLE_CMD_P_DEFAULT, |
1404 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15818 | 1405 cmd_show_window, _("prefs: Show the preference window."), finch_prefs_show_all); |
15823 | 1406 purple_cmd_register("status", "", PURPLE_CMD_P_DEFAULT, |
1407 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15818 | 1408 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
|
1409 |
23833
240d847e9e88
Fix compiling with glib < 2.6
Stu Tomlinson <stu@nosnilmot.com>
parents:
23442
diff
changeset
|
1410 #if GLIB_CHECK_VERSION(2,6,0) |
23311
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1411 /* Allow customizing the message colors using a command during run-time */ |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1412 purple_cmd_register("msgcolor", "www", PURPLE_CMD_P_DEFAULT, |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1413 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1414 cmd_message_color, _("msgcolor <class> <foreground> <background>: " |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1415 "Set the color for different classes of messages in the conversation window.<br>" |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1416 " <class>: receive, send, highlight, action, timestamp<br>" |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1417 " <foreground/background>: black, red, green, blue, white, gray, darkgray, magenta, cyan, default<br><br>" |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1418 "EXAMPLE:<br> msgcolor send cyan default"), |
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1419 NULL); |
23833
240d847e9e88
Fix compiling with glib < 2.6
Stu Tomlinson <stu@nosnilmot.com>
parents:
23442
diff
changeset
|
1420 #endif |
23311
ea341703b1d3
msgcolor command to change colors of messages in conversations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23233
diff
changeset
|
1421 |
17032
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16989
diff
changeset
|
1422 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
|
1423 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
|
1424 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
|
1425 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
|
1426 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
|
1427 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
|
1428 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
|
1429 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
|
1430 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
|
1431 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
|
1432 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
|
1433 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
|
1434 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
|
1435 PURPLE_CALLBACK(account_signed_on_off), NULL); |
15818 | 1436 } |
1437 | |
1438 void finch_conversation_uninit() | |
1439 { | |
17032
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16989
diff
changeset
|
1440 purple_signals_disconnect_by_handle(finch_conv_get_handle()); |
15818 | 1441 } |
1442 | |
15823 | 1443 void finch_conversation_set_active(PurpleConversation *conv) |
15818 | 1444 { |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
1445 FinchConv *ggconv = FINCH_GET_DATA(conv); |
15823 | 1446 PurpleAccount *account; |
15818 | 1447 char *title; |
1448 | |
1449 g_return_if_fail(ggconv); | |
1450 g_return_if_fail(g_list_find(ggconv->list, conv)); | |
23415
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
1451 if (ggconv->active_conv == conv) |
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
1452 return; |
15818 | 1453 |
1454 ggconv->active_conv = conv; | |
23415
a2c625152c52
Tab-completion for commands in finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23363
diff
changeset
|
1455 gg_setup_commands(ggconv, TRUE); |
15823 | 1456 account = purple_conversation_get_account(conv); |
15818 | 1457 title = get_conversation_title(conv, account); |
1458 gnt_screen_rename_widget(ggconv->window, title); | |
1459 g_free(title); | |
1460 } | |
1461 | |
16128
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1462 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
|
1463 { |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
1464 FinchConv *fc = FINCH_GET_DATA(conv); |
16128
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1465 int height, width; |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1466 |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1467 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
|
1468 |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1469 if (widget) { |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1470 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
|
1471 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
|
1472 } |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1473 |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1474 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
|
1475 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
|
1476 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
|
1477 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
|
1478 } |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1479 |