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