Mercurial > pidgin
annotate finch/gntconv.c @ 23469:5f9e6f8b2aea
Correctly update MSN OIM tokens when an invalid token error is
returned.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sat, 07 Jun 2008 06:12:44 +0000 |
parents | cb241bc04f9b |
children | ea341703b1d3 |
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" | |
22248
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
39 #include "gntlog.h" |
15817 | 40 #include "gntplugin.h" |
23231
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
41 #include "gntpounce.h" |
15817 | 42 #include "gntprefs.h" |
23231
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
43 #include "gntrequest.h" |
19447
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
44 #include "gntsound.h" |
15817 | 45 #include "gntstatus.h" |
46 | |
47 #include "gnt.h" | |
48 #include "gntbox.h" | |
49 #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
|
50 #include "gntlabel.h" |
16892 | 51 #include "gntmenu.h" |
52 #include "gntmenuitem.h" | |
53 #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
|
54 #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
|
55 #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
|
56 #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
|
57 #include "gntutils.h" |
16892 | 58 #include "gntwindow.h" |
15817 | 59 |
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
|
60 #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
|
61 #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
|
62 #define PREF_USERLIST PREF_CHAT "/userlist" |
15817 | 63 |
64 #include "config.h" | |
65 | |
17021
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
66 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
|
67 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
|
68 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
|
69 |
21738
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_receive; |
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_send; |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
72 static int color_message_highlight; |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
73 static int color_message_action; |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
74 static int color_timestamp; |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
75 |
22215
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
76 static PurpleBuddy * |
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
77 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
|
78 { |
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
79 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
|
80 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
|
81 } |
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
82 |
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
83 static PurpleChat * |
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
84 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
|
85 { |
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
86 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
|
87 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
|
88 } |
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
89 |
19778
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
90 static PurpleBlistNode * |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
91 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
|
92 { |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
93 PurpleBlistNode *node = NULL; |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
94 |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
95 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
|
96 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
|
97 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
|
98 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
|
99 break; |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
100 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
|
101 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
|
102 break; |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
103 default: |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
104 break; |
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 return node; |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
107 } |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
108 |
15817 | 109 static void |
110 send_typing_notification(GntWidget *w, FinchConv *ggconv) | |
111 { | |
112 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
|
113 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
|
114 if (purple_prefs_get_bool("/finch/conversations/notify_typing")) { |
15822 | 115 PurpleConversation *conv = ggconv->active_conv; |
116 PurpleConvIm *im = PURPLE_CONV_IM(conv); | |
15817 | 117 if (!empty) { |
15822 | 118 gboolean send = (purple_conv_im_get_send_typed_timeout(im) == 0); |
15817 | 119 |
15822 | 120 purple_conv_im_stop_send_typed_timeout(im); |
121 purple_conv_im_start_send_typed_timeout(im); | |
122 if (send || (purple_conv_im_get_type_again(im) != 0 && | |
123 time(NULL) > purple_conv_im_get_type_again(im))) { | |
15817 | 124 unsigned int timeout; |
15822 | 125 timeout = serv_send_typing(purple_conversation_get_gc(conv), |
126 purple_conversation_get_name(conv), | |
127 PURPLE_TYPING); | |
128 purple_conv_im_set_type_again(im, timeout); | |
15817 | 129 } |
130 } else { | |
15822 | 131 purple_conv_im_stop_send_typed_timeout(im); |
15817 | 132 |
15822 | 133 serv_send_typing(purple_conversation_get_gc(conv), |
134 purple_conversation_get_name(conv), | |
135 PURPLE_NOT_TYPING); | |
15817 | 136 } |
137 } | |
138 } | |
139 | |
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
|
140 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
|
141 entry_key_pressed(GntWidget *w, FinchConv *ggconv) |
15817 | 142 { |
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
|
143 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
|
144 if (*text == '/') |
15817 | 145 { |
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
|
146 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
|
147 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
|
148 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
|
149 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
|
150 |
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 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
|
152 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
|
153 g_free(escape); |
15817 | 154 |
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
|
155 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
|
156 { |
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_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
|
158 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
|
159 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
|
160 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
|
161 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
|
162 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
|
163 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
|
164 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
|
165 "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
|
166 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
|
167 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
|
168 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
|
169 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
|
170 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
|
171 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
|
172 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
|
173 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
|
174 purple_conversation_write(conv, "", _("That command only works in chats, not IMs."), |
15822 | 175 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
|
176 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
|
177 purple_conversation_write(conv, "", _("That command only works in IMs, not chats."), |
15822 | 178 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
|
179 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
|
180 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
|
181 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
|
182 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
|
183 break; |
15817 | 184 } |
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
|
185 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
|
186 } |
22215
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
187 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
|
188 { |
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 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
|
190 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
|
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 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
|
193 { |
d7d3f31d52fb
I feel good when I am able to send messages, instead of just typing them.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20740
diff
changeset
|
194 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
|
195 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
|
196 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
|
197 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
|
198 switch (purple_conversation_get_type(ggconv->active_conv)) |
15817 | 199 { |
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
|
200 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
|
201 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
|
202 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
|
203 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
|
204 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
|
205 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
|
206 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
|
207 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
|
208 g_return_if_reached(); |
15817 | 209 } |
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
|
210 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
|
211 purple_idle_touch(); |
15817 | 212 } |
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
|
213 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
|
214 gnt_entry_clear(GNT_ENTRY(ggconv->entry)); |
15817 | 215 } |
216 | |
217 static void | |
218 closing_window(GntWidget *window, FinchConv *ggconv) | |
219 { | |
220 GList *list = ggconv->list; | |
221 ggconv->window = NULL; | |
222 while (list) { | |
15822 | 223 PurpleConversation *conv = list->data; |
15817 | 224 list = list->next; |
15822 | 225 purple_conversation_destroy(conv); |
15817 | 226 } |
227 } | |
228 | |
229 static void | |
230 size_changed_cb(GntWidget *widget, int width, int height) | |
231 { | |
232 int w, h; | |
233 gnt_widget_get_size(widget, &w, &h); | |
15822 | 234 purple_prefs_set_int(PREF_ROOT "/size/width", w); |
235 purple_prefs_set_int(PREF_ROOT "/size/height", h); | |
15817 | 236 } |
237 | |
238 static void | |
239 save_position_cb(GntWidget *w, int x, int y) | |
240 { | |
15822 | 241 purple_prefs_set_int(PREF_ROOT "/position/x", x); |
242 purple_prefs_set_int(PREF_ROOT "/position/y", y); | |
15817 | 243 } |
244 | |
15822 | 245 static PurpleConversation * |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
246 find_conv_with_contact(PurpleAccount *account, const char *name) |
15817 | 247 { |
15822 | 248 PurpleBlistNode *node; |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
249 PurpleBuddy *buddy = purple_find_buddy(account, name); |
15822 | 250 PurpleConversation *ret = NULL; |
15817 | 251 |
252 if (!buddy) | |
253 return NULL; | |
254 | |
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
|
255 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
|
256 node; node = purple_blist_node_get_sibling_next(node)) { |
15822 | 257 if (node == (PurpleBlistNode*)buddy) |
15817 | 258 continue; |
15822 | 259 if ((ret = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, |
22219
797230b3e48e
Add accessor and update finch to not touch the internals of PurpleBuddy and PurpleChat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22217
diff
changeset
|
260 purple_buddy_get_name((PurpleBuddy*)node), purple_buddy_get_account((PurpleBuddy*)node))) != NULL) |
15817 | 261 break; |
262 } | |
263 return ret; | |
264 } | |
265 | |
266 static char * | |
15822 | 267 get_conversation_title(PurpleConversation *conv, PurpleAccount *account) |
15817 | 268 { |
15822 | 269 return g_strdup_printf(_("%s (%s -- %s)"), purple_conversation_get_title(conv), |
270 purple_account_get_username(account), purple_account_get_protocol_name(account)); | |
15817 | 271 } |
272 | |
273 static void | |
15822 | 274 update_buddy_typing(PurpleAccount *account, const char *who, gpointer null) |
15817 | 275 { |
15822 | 276 PurpleConversation *conv; |
15817 | 277 FinchConv *ggc; |
15822 | 278 PurpleConvIm *im = NULL; |
15817 | 279 char *title, *str; |
280 | |
15822 | 281 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, who, account); |
15817 | 282 |
283 if (!conv) | |
284 return; | |
285 | |
15822 | 286 im = PURPLE_CONV_IM(conv); |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
287 ggc = FINCH_GET_DATA(conv); |
15817 | 288 |
15822 | 289 if (purple_conv_im_get_typing_state(im) == PURPLE_TYPING) { |
15817 | 290 int scroll; |
291 str = get_conversation_title(conv, account); | |
292 title = g_strdup_printf(_("%s [%s]"), str, | |
293 gnt_ascii_only() ? "T" : "\342\243\277"); | |
294 g_free(str); | |
295 | |
296 scroll = gnt_text_view_get_lines_below(GNT_TEXT_VIEW(ggc->tv)); | |
22437
ca6bc025aabb
Patch from Kyle Turman to show the alias when available in the typing notification. Closes #4957.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22429
diff
changeset
|
297 str = g_strdup_printf(_("\n%s is typing..."), purple_conversation_get_title(conv)); |
15817 | 298 /* Updating is a little buggy. So just remove and add a new one */ |
299 gnt_text_view_tag_change(GNT_TEXT_VIEW(ggc->tv), "typing", NULL, TRUE); | |
300 gnt_text_view_append_text_with_tag(GNT_TEXT_VIEW(ggc->tv), | |
301 str, GNT_TEXT_FLAG_DIM, "typing"); | |
302 g_free(str); | |
303 if (scroll <= 1) | |
304 gnt_text_view_scroll(GNT_TEXT_VIEW(ggc->tv), 0); | |
305 } else { | |
306 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
|
307 gnt_text_view_tag_change(GNT_TEXT_VIEW(ggc->tv), "typing", " ", TRUE); |
15817 | 308 } |
309 gnt_screen_rename_widget(ggc->window, title); | |
310 g_free(title); | |
311 } | |
312 | |
17021
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
313 static void |
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
314 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
|
315 { |
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
316 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
|
317 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
|
318 } |
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
319 |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
320 static void |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
321 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
|
322 { |
22219
797230b3e48e
Add accessor and update finch to not touch the internals of PurpleBuddy and PurpleChat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22217
diff
changeset
|
323 PurpleConversation *conv = find_conv_with_contact(purple_buddy_get_account(buddy), purple_buddy_get_name(buddy)); |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
324 if (conv == NULL) |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
325 return; |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
326 generate_send_to_menu(FINCH_GET_DATA(conv)); |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
327 } |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
328 |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
329 static void |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
330 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
|
331 { |
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
|
332 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
|
333 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
|
334 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
|
335 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
|
336 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
|
337 if (cc) |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
338 generate_send_to_menu(FINCH_GET_DATA(cc)); |
20053
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19778
diff
changeset
|
339 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
|
340 } |
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 |
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 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
|
343 /* 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
|
344 * 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
|
345 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
|
346 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
|
347 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
|
348 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
|
349 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
|
350 |
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 list = list->next; |
22215
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
352 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
|
353 !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
|
354 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
|
355 |
22215
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
356 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
|
357 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
|
358 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
|
359 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
|
360 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
|
361 } else { |
22219
797230b3e48e
Add accessor and update finch to not touch the internals of PurpleBuddy and PurpleChat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22217
diff
changeset
|
362 comps = purple_chat_get_components(chat); |
20053
fb2880587f34
If there's a chat open when an account gets disconnected because of an error,
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19778
diff
changeset
|
363 } |
20552
b7460582a135
Fix #104 (Reconnect to network should reconnect chats also). This has been
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20074
diff
changeset
|
364 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
|
365 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
|
366 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
|
367 } |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
368 } |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
369 } |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
370 |
15817 | 371 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
|
372 finch_conv_get_handle(void) |
15817 | 373 { |
374 static int handle; | |
375 return &handle; | |
376 } | |
377 | |
378 static void | |
16892 | 379 clear_scrollback_cb(GntMenuItem *item, gpointer ggconv) |
380 { | |
381 FinchConv *ggc = ggconv; | |
382 gnt_text_view_clear(GNT_TEXT_VIEW(ggc->tv)); | |
383 } | |
384 | |
385 static void | |
386 send_file_cb(GntMenuItem *item, gpointer ggconv) | |
387 { | |
388 FinchConv *ggc = ggconv; | |
389 serv_send_file(purple_conversation_get_gc(ggc->active_conv), | |
390 purple_conversation_get_name(ggc->active_conv), NULL); | |
391 } | |
392 | |
393 static void | |
394 add_pounce_cb(GntMenuItem *item, gpointer ggconv) | |
395 { | |
396 FinchConv *ggc = ggconv; | |
397 finch_pounce_editor_show( | |
398 purple_conversation_get_account(ggc->active_conv), | |
399 purple_conversation_get_name(ggc->active_conv), NULL); | |
400 } | |
401 | |
402 static void | |
403 get_info_cb(GntMenuItem *item, gpointer ggconv) | |
404 { | |
405 FinchConv *ggc = ggconv; | |
17750
319bcb73eb4e
Use utility functions to get user info. Closes #964.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17091
diff
changeset
|
406 finch_retrieve_user_info(purple_conversation_get_gc(ggc->active_conv), |
16892 | 407 purple_conversation_get_name(ggc->active_conv)); |
408 } | |
409 | |
410 static void | |
411 toggle_timestamps_cb(GntMenuItem *item, gpointer ggconv) | |
412 { | |
413 purple_prefs_set_bool(PREF_ROOT "/timestamps", | |
414 !purple_prefs_get_bool(PREF_ROOT "/timestamps")); | |
415 } | |
416 | |
417 static void | |
19445
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
418 toggle_logging_cb(GntMenuItem *item, gpointer ggconv) |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
419 { |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
420 FinchConv *fc = ggconv; |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
421 PurpleConversation *conv = fc->active_conv; |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
422 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
|
423 GList *iter; |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
424 |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
425 if (logging == purple_conversation_is_logging(conv)) |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
426 return; |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
427 |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
428 /* Xerox */ |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
429 if (logging) { |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
430 /* 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
|
431 purple_conversation_set_logging(conv, TRUE); |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
432 |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
433 purple_conversation_write(conv, NULL, |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
434 _("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
|
435 PURPLE_MESSAGE_SYSTEM, time(NULL)); |
19445
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
436 } else { |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
437 purple_conversation_write(conv, NULL, |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
438 _("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
|
439 PURPLE_MESSAGE_SYSTEM, time(NULL)); |
19445
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
440 |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
441 /* 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
|
442 purple_conversation_set_logging(conv, FALSE); |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
443 } |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
444 |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
445 /* 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
|
446 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
|
447 if (iter->data == conv) |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
448 continue; |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
449 purple_conversation_set_logging(iter->data, logging); |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
450 } |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
451 } |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
452 |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
453 static void |
19447
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
454 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
|
455 { |
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
456 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
|
457 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
|
458 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
|
459 if (node) |
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
460 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
|
461 } |
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
462 |
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
463 static void |
16892 | 464 send_to_cb(GntMenuItem *m, gpointer n) |
465 { | |
466 PurpleAccount *account = g_object_get_data(G_OBJECT(m), "purple_account"); | |
467 gchar *buddy = g_object_get_data(G_OBJECT(m), "purple_buddy_name"); | |
468 PurpleConversation *conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, buddy); | |
469 finch_conversation_set_active(conv); | |
470 } | |
471 | |
472 static void | |
22248
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
473 view_log_cb(GntMenuItem *n, gpointer ggc) |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
474 { |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
475 FinchConv *fc; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
476 PurpleConversation *conv; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
477 PurpleLogType type; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
478 const char *name; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
479 PurpleAccount *account; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
480 GSList *buddies; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
481 GSList *cur; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
482 |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
483 fc = ggc; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
484 conv = fc->active_conv; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
485 |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
486 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
487 type = PURPLE_LOG_IM; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
488 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
489 type = PURPLE_LOG_CHAT; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
490 else |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
491 return; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
492 |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
493 name = purple_conversation_get_name(conv); |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
494 account = purple_conversation_get_account(conv); |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
495 |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
496 buddies = purple_find_buddies(account, name); |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
497 for (cur = buddies; cur != NULL; cur = cur->next) { |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
498 PurpleBlistNode *node = cur->data; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
499 if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL))) { |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
500 finch_log_show_contact((PurpleContact *)node->parent); |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
501 g_slist_free(buddies); |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
502 return; |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
503 } |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
504 } |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
505 g_slist_free(buddies); |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
506 |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
507 finch_log_show(type, name, account); |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
508 } |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
509 |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
510 static void |
16892 | 511 generate_send_to_menu(FinchConv *ggc) |
512 { | |
513 GntWidget *sub, *menu = ggc->menu; | |
514 GntMenuItem *item; | |
515 GSList *buds; | |
516 GList *list = NULL; | |
517 | |
22215
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
518 buds = purple_find_buddies(purple_conversation_get_account(ggc->active_conv), |
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
519 purple_conversation_get_name(ggc->active_conv)); |
16892 | 520 if (!buds) |
521 return; | |
522 | |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
523 if ((item = ggc->u.im->sendto) == NULL) { |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
524 item = gnt_menuitem_new(_("Send To")); |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
525 gnt_menu_add_item(GNT_MENU(menu), item); |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
526 ggc->u.im->sendto = item; |
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
527 } |
16892 | 528 sub = gnt_menu_new(GNT_MENU_POPUP); |
529 gnt_menuitem_set_submenu(item, GNT_MENU(sub)); | |
530 | |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
531 for (; buds; buds = g_slist_delete_link(buds, buds)) { |
16892 | 532 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
|
533 for (node = purple_blist_node_get_first_child(node); node != NULL; |
6bb29f94862c
Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
534 node = purple_blist_node_get_sibling_next(node)) { |
16892 | 535 PurpleBuddy *buddy = (PurpleBuddy *)node; |
536 PurpleAccount *account = purple_buddy_get_account(buddy); | |
537 if (purple_account_is_connected(account)) { | |
538 /* Use the PurplePresence to get unique buddies. */ | |
539 PurplePresence *presence = purple_buddy_get_presence(buddy); | |
540 if (!g_list_find(list, presence)) | |
541 list = g_list_prepend(list, presence); | |
542 } | |
543 } | |
544 } | |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
545 for (list = g_list_reverse(list); list != NULL; list = g_list_delete_link(list, list)) { |
16892 | 546 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
|
547 PurpleBuddy *buddy = purple_presence_get_buddy(pre); |
16892 | 548 PurpleAccount *account = purple_buddy_get_account(buddy); |
549 gchar *name = g_strdup(purple_buddy_get_name(buddy)); | |
550 gchar *text = g_strdup_printf("%s (%s)", purple_buddy_get_name(buddy), purple_account_get_username(account)); | |
551 item = gnt_menuitem_new(text); | |
552 g_free(text); | |
553 gnt_menu_add_item(GNT_MENU(sub), item); | |
554 gnt_menuitem_set_callback(item, send_to_cb, NULL); | |
555 g_object_set_data(G_OBJECT(item), "purple_account", account); | |
556 g_object_set_data_full(G_OBJECT(item), "purple_buddy_name", name, g_free); | |
557 } | |
558 } | |
559 | |
560 static void | |
23231
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
561 invite_select_cb(FinchConv *fc, PurpleRequestFields *fields) |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
562 { |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
563 PurpleConversation *conv = fc->active_conv; |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
564 const char *buddy = purple_request_fields_get_string(fields, "screenname"); |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
565 const char *message = purple_request_fields_get_string(fields, "message"); |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
566 serv_chat_invite(purple_conversation_get_gc(conv), |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
567 purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)), |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
568 message, buddy); |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
569 |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
570 } |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
571 |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
572 static void |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
573 invite_cb(GntMenuItem *item, gpointer ggconv) |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
574 { |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
575 PurpleRequestFields *fields; |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
576 PurpleRequestFieldGroup *group; |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
577 PurpleRequestField *field; |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
578 |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
579 fields = purple_request_fields_new(); |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
580 |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
581 group = purple_request_field_group_new(NULL); |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
582 purple_request_fields_add_group(fields, group); |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
583 |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
584 field = purple_request_field_string_new("screenname", _("Name"), NULL, FALSE); |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
585 purple_request_field_set_type_hint(field, "screenname"); |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
586 purple_request_field_set_required(field, TRUE); |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
587 purple_request_field_group_add_field(group, field); |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
588 field = purple_request_field_string_new("message", _("Invite message"), NULL, FALSE); |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
589 purple_request_field_group_add_field(group, field); |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
590 purple_request_fields(finch_conv_get_handle(), _("Invite"), |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
591 NULL, |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
592 _("Please enter the name of the user " |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
593 "you wish to invite,\nalong with an optional invite message."), |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
594 fields, |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
595 _("OK"), G_CALLBACK(invite_select_cb), |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
596 _("Cancel"), NULL, |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
597 NULL, NULL, NULL, |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
598 ggconv); |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
599 } |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
600 |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
601 static void |
16892 | 602 gg_create_menu(FinchConv *ggc) |
603 { | |
604 GntWidget *menu, *sub; | |
605 GntMenuItem *item; | |
606 | |
607 ggc->menu = menu = gnt_menu_new(GNT_MENU_TOPLEVEL); | |
608 gnt_window_set_menu(GNT_WINDOW(ggc->window), GNT_MENU(menu)); | |
609 | |
610 item = gnt_menuitem_new(_("Conversation")); | |
611 gnt_menu_add_item(GNT_MENU(menu), item); | |
612 | |
613 sub = gnt_menu_new(GNT_MENU_POPUP); | |
614 gnt_menuitem_set_submenu(item, GNT_MENU(sub)); | |
615 | |
616 item = gnt_menuitem_new(_("Clear Scrollback")); | |
617 gnt_menu_add_item(GNT_MENU(sub), item); | |
618 gnt_menuitem_set_callback(item, clear_scrollback_cb, ggc); | |
619 | |
620 item = gnt_menuitem_check_new(_("Show Timestamps")); | |
621 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item), | |
622 purple_prefs_get_bool(PREF_ROOT "/timestamps")); | |
623 gnt_menu_add_item(GNT_MENU(sub), item); | |
624 gnt_menuitem_set_callback(item, toggle_timestamps_cb, ggc); | |
625 | |
626 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
|
627 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
|
628 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
|
629 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
|
630 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
|
631 |
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
|
632 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
|
633 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
|
634 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
|
635 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
|
636 } |
16892 | 637 |
638 item = gnt_menuitem_new(_("Add Buddy Pounce...")); | |
639 gnt_menu_add_item(GNT_MENU(sub), item); | |
640 gnt_menuitem_set_callback(item, add_pounce_cb, ggc); | |
641 | |
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
|
642 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
|
643 (!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
|
644 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
|
645 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
|
646 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
|
647 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
|
648 } |
16892 | 649 |
650 generate_send_to_menu(ggc); | |
23231
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
651 } else if (purple_conversation_get_type(ggc->active_conv) == PURPLE_CONV_TYPE_CHAT) { |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
652 item = gnt_menuitem_new(_("Invite...")); |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
653 gnt_menu_add_item(GNT_MENU(sub), item); |
cb241bc04f9b
Add an invite menu for chats
Richard Nelson <wabz@pidgin.im>
parents:
22697
diff
changeset
|
654 gnt_menuitem_set_callback(item, invite_cb, ggc); |
16892 | 655 } |
19445
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
656 |
22248
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
657 item = gnt_menuitem_new(_("View Log...")); |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
658 gnt_menu_add_item(GNT_MENU(sub), item); |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
659 gnt_menuitem_set_callback(item, view_log_cb, ggc); |
88796aff14d6
Add a finch log viewer. This is largely copied from Pidgin.
Richard Nelson <wabz@pidgin.im>
parents:
22219
diff
changeset
|
660 |
19445
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
661 item = gnt_menuitem_check_new(_("Enable Logging")); |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
662 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
|
663 purple_conversation_is_logging(ggc->active_conv)); |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
664 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
|
665 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
|
666 |
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
667 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
|
668 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
|
669 !(ggc->flags & FINCH_CONV_NO_SOUND)); |
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
670 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
|
671 gnt_menuitem_set_callback(item, toggle_sound_cb, ggc); |
16892 | 672 } |
673 | |
674 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
|
675 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
|
676 { |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
677 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
|
678 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
|
679 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
|
680 } |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
681 |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
682 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
|
683 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
|
684 { |
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
|
685 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
|
686 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
|
687 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
|
688 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
|
689 } |
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
|
690 } |
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
|
691 |
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
|
692 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
|
693 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
|
694 { |
9eb2f4d27990
Use the completion-signal to append a ': ' after a tab-completed nick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18232
diff
changeset
|
695 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
|
696 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
|
697 } |
9eb2f4d27990
Use the completion-signal to append a ': ' after a tab-completed nick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18232
diff
changeset
|
698 |
9eb2f4d27990
Use the completion-signal to append a ': ' after a tab-completed nick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18232
diff
changeset
|
699 static void |
15822 | 700 finch_create_conversation(PurpleConversation *conv) |
15817 | 701 { |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
702 FinchConv *ggc = FINCH_GET_DATA(conv); |
15817 | 703 char *title; |
15822 | 704 PurpleConversationType type; |
705 PurpleConversation *cc; | |
706 PurpleAccount *account; | |
19778
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
707 PurpleBlistNode *convnode = NULL; |
15817 | 708 |
22429
b0b8c94118c8
Make sure an existing conversation selected from the 'Send IM' dialog is given the focus.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22280
diff
changeset
|
709 if (ggc) { |
b0b8c94118c8
Make sure an existing conversation selected from the 'Send IM' dialog is given the focus.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22280
diff
changeset
|
710 gnt_window_present(ggc->window); |
15817 | 711 return; |
22429
b0b8c94118c8
Make sure an existing conversation selected from the 'Send IM' dialog is given the focus.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22280
diff
changeset
|
712 } |
15817 | 713 |
22215
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
714 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
|
715 cc = find_conv_with_contact(account, purple_conversation_get_name(conv)); |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
716 if (cc && FINCH_GET_DATA(cc)) |
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
717 ggc = FINCH_GET_DATA(cc); |
15817 | 718 else |
719 ggc = g_new0(FinchConv, 1); | |
720 | |
19445
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
721 /* 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
|
722 if (ggc->list) { |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
723 purple_conversation_set_logging(conv, |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
724 purple_conversation_is_logging(ggc->list->data)); |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
725 } |
6759eb4387a5
Separate logging support for each conversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19370
diff
changeset
|
726 |
15817 | 727 ggc->list = g_list_prepend(ggc->list, conv); |
728 ggc->active_conv = conv; | |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
729 FINCH_SET_DATA(conv, ggc); |
15817 | 730 |
22697
c7c97c62e131
Fix a crash which I think happens when the same buddy is in the buddylist
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22437
diff
changeset
|
731 if (cc && FINCH_GET_DATA(cc) && cc != conv) { |
15817 | 732 finch_conversation_set_active(conv); |
733 return; | |
734 } | |
735 | |
15822 | 736 type = purple_conversation_get_type(conv); |
15817 | 737 title = get_conversation_title(conv, account); |
738 | |
16892 | 739 ggc->window = gnt_vwindow_new(FALSE); |
15817 | 740 gnt_box_set_title(GNT_BOX(ggc->window), title); |
741 gnt_box_set_toplevel(GNT_BOX(ggc->window), TRUE); | |
742 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
|
743 |
22215
07c2b8fa7bb4
Update finch to not touch the internals of PurpleConversation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22214
diff
changeset
|
744 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
|
745 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
|
746 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
|
747 break; |
2b1af79e768f
Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
748 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
|
749 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
|
750 break; |
2b1af79e768f
Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
751 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
|
752 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
|
753 break; |
2b1af79e768f
Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
754 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
|
755 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
|
756 break; |
2b1af79e768f
Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
757 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
|
758 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
|
759 break; |
2b1af79e768f
Plucked revision from finchfeat to give different names to windows for
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18222
diff
changeset
|
760 } |
15817 | 761 |
762 ggc->tv = gnt_text_view_new(); | |
763 gnt_widget_set_name(ggc->tv, "conversation-window-textview"); | |
15822 | 764 gnt_widget_set_size(ggc->tv, purple_prefs_get_int(PREF_ROOT "/size/width"), |
765 purple_prefs_get_int(PREF_ROOT "/size/height")); | |
15817 | 766 |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
767 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
|
768 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
|
769 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
|
770 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
|
771 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
|
772 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
|
773 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
|
774 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
|
775 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
|
776 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
|
777 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
|
778 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
|
779 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
|
780 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
|
781 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
|
782 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
|
783 } else { |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
784 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
|
785 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
|
786 } |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
787 |
16128
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
788 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
|
789 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
|
790 |
15817 | 791 ggc->entry = gnt_entry_new(NULL); |
792 gnt_box_add_widget(GNT_BOX(ggc->window), ggc->entry); | |
793 gnt_widget_set_name(ggc->entry, "conversation-window-entry"); | |
794 gnt_entry_set_history_length(GNT_ENTRY(ggc->entry), -1); | |
795 gnt_entry_set_word_suggest(GNT_ENTRY(ggc->entry), TRUE); | |
796 gnt_entry_set_always_suggest(GNT_ENTRY(ggc->entry), FALSE); | |
797 | |
16124
ab3f93232a2d
Add a utility function to assist scrolling in a textview.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
15870
diff
changeset
|
798 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
|
799 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
|
800 |
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
|
801 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
|
802 g_signal_connect(G_OBJECT(ggc->entry), "completion", G_CALLBACK(completion_cb), NULL); |
15817 | 803 g_signal_connect(G_OBJECT(ggc->window), "destroy", G_CALLBACK(closing_window), ggc); |
804 | |
15822 | 805 gnt_widget_set_position(ggc->window, purple_prefs_get_int(PREF_ROOT "/position/x"), |
806 purple_prefs_get_int(PREF_ROOT "/position/y")); | |
15817 | 807 gnt_widget_show(ggc->window); |
808 | |
809 g_signal_connect(G_OBJECT(ggc->tv), "size_changed", G_CALLBACK(size_changed_cb), NULL); | |
810 g_signal_connect(G_OBJECT(ggc->window), "position_set", G_CALLBACK(save_position_cb), NULL); | |
811 | |
15822 | 812 if (type == PURPLE_CONV_TYPE_IM) { |
15817 | 813 g_signal_connect(G_OBJECT(ggc->entry), "text_changed", G_CALLBACK(send_typing_notification), ggc); |
814 } | |
815 | |
19778
959b3aaba0b6
Remember the 'Enable Sounds' setting for a conversation. Closes #312.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19681
diff
changeset
|
816 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
|
817 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
|
818 !finch_sound_is_enabled()) |
19447
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
819 ggc->flags |= FINCH_CONV_NO_SOUND; |
1a9b30a95fa6
Fix #2767 (per-conversation/chat mute option).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19446
diff
changeset
|
820 |
19321
39d3a81a5850
Update the 'send to' menu in conversation windows when necessary.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18637
diff
changeset
|
821 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
|
822 |
15817 | 823 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
|
824 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
|
825 g_signal_connect(G_OBJECT(ggc->window), "gained-focus", G_CALLBACK(gained_focus_cb), ggc); |
15817 | 826 } |
827 | |
828 static void | |
15822 | 829 finch_destroy_conversation(PurpleConversation *conv) |
15817 | 830 { |
831 /* do stuff here */ | |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
832 FinchConv *ggc = FINCH_GET_DATA(conv); |
15817 | 833 ggc->list = g_list_remove(ggc->list, conv); |
834 if (ggc->list && conv == ggc->active_conv) | |
835 ggc->active_conv = ggc->list->data; | |
836 | |
837 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
|
838 g_free(ggc->u.chat); |
18222
ef65d43190e5
Fix a few runtime warnings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
839 if (ggc->window) |
ef65d43190e5
Fix a few runtime warnings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
840 gnt_widget_destroy(ggc->window); |
15817 | 841 g_free(ggc); |
842 } | |
843 } | |
844 | |
845 static void | |
15822 | 846 finch_write_common(PurpleConversation *conv, const char *who, const char *message, |
847 PurpleMessageFlags flags, time_t mtime) | |
15817 | 848 { |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
849 FinchConv *ggconv = FINCH_GET_DATA(conv); |
15817 | 850 char *strip, *newline; |
851 GntTextFormatFlags fl = 0; | |
852 int pos; | |
853 | |
854 g_return_if_fail(ggconv != NULL); | |
855 | |
22280
d680613669cc
Ignore the recv/send flags when the system flag is set for a message.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22279
diff
changeset
|
856 if (flags & PURPLE_MESSAGE_SYSTEM) { |
d680613669cc
Ignore the recv/send flags when the system flag is set for a message.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22279
diff
changeset
|
857 flags &= ~(PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV); |
d680613669cc
Ignore the recv/send flags when the system flag is set for a message.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22279
diff
changeset
|
858 } |
d680613669cc
Ignore the recv/send flags when the system flag is set for a message.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22279
diff
changeset
|
859 |
15817 | 860 if (ggconv->active_conv != conv) { |
15822 | 861 if (flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV)) |
15817 | 862 finch_conversation_set_active(conv); |
863 else | |
864 return; | |
865 } | |
866 | |
867 pos = gnt_text_view_get_lines_below(GNT_TEXT_VIEW(ggconv->tv)); | |
868 | |
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
|
869 gnt_text_view_tag_change(GNT_TEXT_VIEW(ggconv->tv), "typing", NULL, TRUE); |
15817 | 870 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), "\n", GNT_TEXT_FLAG_NORMAL); |
871 | |
872 /* 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
|
873 if (purple_prefs_get_bool("/finch/conversations/timestamps")) |
15817 | 874 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
|
875 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
|
876 |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
877 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), " ", GNT_TEXT_FLAG_NORMAL); |
15817 | 878 |
15822 | 879 if (flags & PURPLE_MESSAGE_AUTO_RESP) |
15817 | 880 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), |
881 _("<AUTO-REPLY> "), GNT_TEXT_FLAG_BOLD); | |
882 | |
20553
bed3c9affda6
Show 'buzz'/'nudge' etc. messages differently from regular messages.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20552
diff
changeset
|
883 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
|
884 !(flags & PURPLE_MESSAGE_NOTIFY)) |
15817 | 885 { |
886 char * name = NULL; | |
21743
5ff16647c50d
Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21738
diff
changeset
|
887 GntTextFormatFlags msgflags = GNT_TEXT_FLAG_NORMAL; |
5ff16647c50d
Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21738
diff
changeset
|
888 gboolean me = FALSE; |
15817 | 889 |
21738
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
890 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
|
891 name = g_strdup_printf("*** %s", who); |
22279
40707fbabcbc
Highlighted message color has a higher priority over an action message color.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22248
diff
changeset
|
892 if (!(flags & PURPLE_MESSAGE_SEND) && |
40707fbabcbc
Highlighted message color has a higher priority over an action message color.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22248
diff
changeset
|
893 (flags & PURPLE_MESSAGE_NICK)) |
40707fbabcbc
Highlighted message color has a higher priority over an action message color.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22248
diff
changeset
|
894 msgflags = gnt_color_pair(color_message_highlight); |
40707fbabcbc
Highlighted message color has a higher priority over an action message color.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22248
diff
changeset
|
895 else |
40707fbabcbc
Highlighted message color has a higher priority over an action message color.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22248
diff
changeset
|
896 msgflags = gnt_color_pair(color_message_action); |
21743
5ff16647c50d
Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21738
diff
changeset
|
897 me = TRUE; |
21738
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
898 } else { |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
899 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
|
900 if (flags & PURPLE_MESSAGE_SEND) |
21743
5ff16647c50d
Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21738
diff
changeset
|
901 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
|
902 else if (flags & PURPLE_MESSAGE_NICK) |
5ff16647c50d
Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21738
diff
changeset
|
903 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
|
904 else |
21743
5ff16647c50d
Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21738
diff
changeset
|
905 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
|
906 } |
21743
5ff16647c50d
Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21738
diff
changeset
|
907 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
|
908 name, msgflags); |
5ff16647c50d
Do not append ':' after expanding a /me.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21738
diff
changeset
|
909 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), me ? " " : ": ", GNT_TEXT_FLAG_NORMAL); |
15817 | 910 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
|
911 } else |
15817 | 912 fl = GNT_TEXT_FLAG_DIM; |
913 | |
15822 | 914 if (flags & PURPLE_MESSAGE_ERROR) |
15817 | 915 fl |= GNT_TEXT_FLAG_BOLD; |
916 | |
917 /* XXX: Remove this workaround when textview can parse messages. */ | |
15822 | 918 newline = purple_strdup_withhtml(message); |
919 strip = purple_markup_strip_html(newline); | |
15817 | 920 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), |
921 strip, fl); | |
922 | |
923 g_free(newline); | |
924 g_free(strip); | |
925 | |
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
|
926 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
|
927 purple_conv_im_get_typing_state(PURPLE_CONV_IM(conv)) == PURPLE_TYPING) { |
22437
ca6bc025aabb
Patch from Kyle Turman to show the alias when available in the typing notification. Closes #4957.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22429
diff
changeset
|
928 strip = g_strdup_printf(_("\n%s is typing..."), purple_conversation_get_title(conv)); |
15817 | 929 gnt_text_view_append_text_with_tag(GNT_TEXT_VIEW(ggconv->tv), |
930 strip, GNT_TEXT_FLAG_DIM, "typing"); | |
931 g_free(strip); | |
932 } | |
933 | |
934 if (pos <= 1) | |
935 gnt_text_view_scroll(GNT_TEXT_VIEW(ggconv->tv), 0); | |
936 | |
15822 | 937 if (flags & (PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_NICK | PURPLE_MESSAGE_ERROR)) |
15817 | 938 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
|
939 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
|
940 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
|
941 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
|
942 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
|
943 } |
15817 | 944 } |
945 | |
946 static void | |
15822 | 947 finch_write_chat(PurpleConversation *conv, const char *who, const char *message, |
948 PurpleMessageFlags flags, time_t mtime) | |
15817 | 949 { |
15822 | 950 purple_conversation_write(conv, who, message, flags, mtime); |
15817 | 951 } |
952 | |
953 static void | |
15822 | 954 finch_write_im(PurpleConversation *conv, const char *who, const char *message, |
955 PurpleMessageFlags flags, time_t mtime) | |
15817 | 956 { |
15822 | 957 PurpleAccount *account = purple_conversation_get_account(conv); |
958 if (flags & PURPLE_MESSAGE_SEND) | |
15817 | 959 { |
15822 | 960 who = purple_connection_get_display_name(purple_account_get_connection(account)); |
15817 | 961 if (!who) |
15822 | 962 who = purple_account_get_alias(account); |
15817 | 963 if (!who) |
15822 | 964 who = purple_account_get_username(account); |
15817 | 965 } |
15822 | 966 else if (flags & PURPLE_MESSAGE_RECV) |
15817 | 967 { |
15822 | 968 PurpleBuddy *buddy; |
969 who = purple_conversation_get_name(conv); | |
970 buddy = purple_find_buddy(account, who); | |
15817 | 971 if (buddy) |
15822 | 972 who = purple_buddy_get_contact_alias(buddy); |
15817 | 973 } |
974 | |
15822 | 975 purple_conversation_write(conv, who, message, flags, mtime); |
15817 | 976 } |
977 | |
978 static void | |
15822 | 979 finch_write_conv(PurpleConversation *conv, const char *who, const char *alias, |
980 const char *message, PurpleMessageFlags flags, time_t mtime) | |
15817 | 981 { |
982 const char *name; | |
983 if (alias && *alias) | |
984 name = alias; | |
985 else if (who && *who) | |
986 name = who; | |
987 else | |
988 name = NULL; | |
989 | |
990 finch_write_common(conv, name, message, flags, mtime); | |
991 } | |
992 | |
17070
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
993 static const char * |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
994 chat_flag_text(PurpleConvChatBuddyFlags flags) |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
995 { |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
996 if (flags & PURPLE_CBFLAGS_FOUNDER) |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
997 return "~"; |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
998 if (flags & PURPLE_CBFLAGS_OP) |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
999 return "@"; |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
1000 if (flags & PURPLE_CBFLAGS_HALFOP) |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
1001 return "%"; |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
1002 if (flags & PURPLE_CBFLAGS_VOICE) |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
1003 return "+"; |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
1004 return " "; |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
1005 } |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
1006 |
15817 | 1007 static void |
15822 | 1008 finch_chat_add_users(PurpleConversation *conv, GList *users, gboolean new_arrivals) |
15817 | 1009 { |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
1010 FinchConv *ggc = FINCH_GET_DATA(conv); |
15817 | 1011 GntEntry *entry = GNT_ENTRY(ggc->entry); |
1012 | |
1013 if (!new_arrivals) | |
1014 { | |
1015 /* Print the list of users in the room */ | |
1016 GString *string = g_string_new(_("List of users:\n")); | |
1017 GList *iter; | |
1018 | |
1019 for (iter = users; iter; iter = iter->next) | |
1020 { | |
15822 | 1021 PurpleConvChatBuddy *cbuddy = iter->data; |
15817 | 1022 char *str; |
1023 | |
1024 if ((str = cbuddy->alias) == NULL) | |
1025 str = cbuddy->name; | |
1026 g_string_append_printf(string, "[ %s ]", str); | |
1027 } | |
1028 | |
15822 | 1029 purple_conversation_write(conv, NULL, string->str, |
1030 PURPLE_MESSAGE_SYSTEM, time(NULL)); | |
15817 | 1031 g_string_free(string, TRUE); |
1032 } | |
1033 | |
1034 for (; users; users = users->next) | |
1035 { | |
15822 | 1036 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
|
1037 GntTree *tree = GNT_TREE(ggc->u.chat->userlist); |
15817 | 1038 gnt_entry_add_suggest(entry, cbuddy->name); |
1039 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
|
1040 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
|
1041 gnt_tree_create_row(tree, chat_flag_text(cbuddy->flags), cbuddy->alias), NULL, NULL); |
15817 | 1042 } |
1043 } | |
1044 | |
1045 static void | |
15822 | 1046 finch_chat_rename_user(PurpleConversation *conv, const char *old, const char *new_n, const char *new_a) |
15817 | 1047 { |
1048 /* Update the name for string completion */ | |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
1049 FinchConv *ggc = FINCH_GET_DATA(conv); |
15817 | 1050 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
|
1051 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
|
1052 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
|
1053 |
15817 | 1054 gnt_entry_remove_suggest(entry, old); |
17070
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
1055 gnt_tree_remove(tree, (gpointer)old); |
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
1056 |
15817 | 1057 gnt_entry_add_suggest(entry, new_n); |
1058 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
|
1059 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
|
1060 gnt_tree_create_row(tree, chat_flag_text(cb->flags), new_a), NULL, NULL); |
15817 | 1061 } |
1062 | |
1063 static void | |
17091
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
1064 finch_chat_remove_users(PurpleConversation *conv, GList *list) |
15817 | 1065 { |
1066 /* Remove the name from string completion */ | |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
1067 FinchConv *ggc = FINCH_GET_DATA(conv); |
15817 | 1068 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
|
1069 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
|
1070 GntTree *tree = GNT_TREE(ggc->u.chat->userlist); |
15817 | 1071 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
|
1072 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
|
1073 } |
15817 | 1074 } |
1075 | |
1076 static void | |
15822 | 1077 finch_chat_update_user(PurpleConversation *conv, const char *user) |
15817 | 1078 { |
17070
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
1079 PurpleConvChatBuddy *cb = purple_conv_chat_cb_find(PURPLE_CONV_CHAT(conv), user); |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
1080 FinchConv *ggc = FINCH_GET_DATA(conv); |
17070
f2137f75fd10
Show user flags in chat userlist.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17021
diff
changeset
|
1081 gnt_tree_change_text(GNT_TREE(ggc->u.chat->userlist), (gpointer)user, 0, chat_flag_text(cb->flags)); |
15817 | 1082 } |
1083 | |
19446
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1084 static void |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1085 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
|
1086 { |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1087 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
|
1088 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
|
1089 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
|
1090 } |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1091 |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1092 static gboolean |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1093 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
|
1094 { |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1095 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
|
1096 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
|
1097 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
|
1098 return FALSE; |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1099 } |
5d200fce4170
Add two missing conversation-uiops functions. (has_focus and present)
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19445
diff
changeset
|
1100 |
15822 | 1101 static PurpleConversationUiOps conv_ui_ops = |
15817 | 1102 { |
17091
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
1103 finch_create_conversation, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
1104 finch_destroy_conversation, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
1105 finch_write_chat, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
1106 finch_write_im, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
1107 finch_write_conv, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
1108 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
|
1109 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
|
1110 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
|
1111 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
|
1112 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
|
1113 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
|
1114 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
|
1115 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
|
1116 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
|
1117 NULL, /* send_confirm */ |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
1118 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
1119 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
1120 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
17070
diff
changeset
|
1121 NULL |
15817 | 1122 }; |
1123 | |
15822 | 1124 PurpleConversationUiOps *finch_conv_get_ui_ops() |
15817 | 1125 { |
1126 return &conv_ui_ops; | |
1127 } | |
1128 | |
1129 /* Xerox */ | |
15822 | 1130 static PurpleCmdRet |
1131 say_command_cb(PurpleConversation *conv, | |
15817 | 1132 const char *cmd, char **args, char **error, void *data) |
1133 { | |
15822 | 1134 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) |
1135 purple_conv_im_send(PURPLE_CONV_IM(conv), args[0]); | |
1136 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) | |
1137 purple_conv_chat_send(PURPLE_CONV_CHAT(conv), args[0]); | |
15817 | 1138 |
15822 | 1139 return PURPLE_CMD_RET_OK; |
15817 | 1140 } |
1141 | |
1142 /* Xerox */ | |
15822 | 1143 static PurpleCmdRet |
1144 me_command_cb(PurpleConversation *conv, | |
15817 | 1145 const char *cmd, char **args, char **error, void *data) |
1146 { | |
1147 char *tmp; | |
1148 | |
1149 tmp = g_strdup_printf("/me %s", args[0]); | |
1150 | |
15822 | 1151 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) |
1152 purple_conv_im_send(PURPLE_CONV_IM(conv), tmp); | |
1153 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) | |
1154 purple_conv_chat_send(PURPLE_CONV_CHAT(conv), tmp); | |
15817 | 1155 |
1156 g_free(tmp); | |
15822 | 1157 return PURPLE_CMD_RET_OK; |
15817 | 1158 } |
1159 | |
1160 /* Xerox */ | |
15822 | 1161 static PurpleCmdRet |
1162 debug_command_cb(PurpleConversation *conv, | |
15817 | 1163 const char *cmd, char **args, char **error, void *data) |
1164 { | |
1165 char *tmp, *markup; | |
15822 | 1166 PurpleCmdStatus status; |
15817 | 1167 |
1168 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
|
1169 tmp = g_strdup_printf("me is using Finch v%s.", DISPLAY_VERSION); |
15817 | 1170 markup = g_markup_escape_text(tmp, -1); |
1171 | |
15822 | 1172 status = purple_cmd_do_command(conv, tmp, markup, error); |
15817 | 1173 |
1174 g_free(tmp); | |
1175 g_free(markup); | |
1176 return status; | |
1177 } else { | |
15822 | 1178 purple_conversation_write(conv, NULL, _("Supported debug options are: version"), |
1179 PURPLE_MESSAGE_NO_LOG|PURPLE_MESSAGE_ERROR, time(NULL)); | |
1180 return PURPLE_CMD_STATUS_OK; | |
15817 | 1181 } |
1182 } | |
1183 | |
1184 /* Xerox */ | |
15822 | 1185 static PurpleCmdRet |
1186 clear_command_cb(PurpleConversation *conv, | |
15817 | 1187 const char *cmd, char **args, char **error, void *data) |
1188 { | |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
1189 FinchConv *ggconv = FINCH_GET_DATA(conv); |
15817 | 1190 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
|
1191 purple_conversation_clear_message_history(conv); |
15822 | 1192 return PURPLE_CMD_STATUS_OK; |
15817 | 1193 } |
1194 | |
1195 /* Xerox */ | |
15822 | 1196 static PurpleCmdRet |
1197 help_command_cb(PurpleConversation *conv, | |
15817 | 1198 const char *cmd, char **args, char **error, void *data) |
1199 { | |
1200 GList *l, *text; | |
1201 GString *s; | |
1202 | |
1203 if (args[0] != NULL) { | |
1204 s = g_string_new(""); | |
15822 | 1205 text = purple_cmd_help(conv, args[0]); |
15817 | 1206 |
1207 if (text) { | |
1208 for (l = text; l; l = l->next) | |
1209 if (l->next) | |
1210 g_string_append_printf(s, "%s\n", (char *)l->data); | |
1211 else | |
1212 g_string_append_printf(s, "%s", (char *)l->data); | |
1213 } else { | |
1214 g_string_append(s, _("No such command (in this context).")); | |
1215 } | |
1216 } else { | |
1217 s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" | |
1218 "The following commands are available in this context:\n")); | |
1219 | |
15822 | 1220 text = purple_cmd_list(conv); |
15817 | 1221 for (l = text; l; l = l->next) |
1222 if (l->next) | |
1223 g_string_append_printf(s, "%s, ", (char *)l->data); | |
1224 else | |
1225 g_string_append_printf(s, "%s.", (char *)l->data); | |
1226 g_list_free(text); | |
1227 } | |
1228 | |
15822 | 1229 purple_conversation_write(conv, NULL, s->str, PURPLE_MESSAGE_NO_LOG, time(NULL)); |
15817 | 1230 g_string_free(s, TRUE); |
1231 | |
15822 | 1232 return PURPLE_CMD_STATUS_OK; |
15817 | 1233 } |
1234 | |
15822 | 1235 static PurpleCmdRet |
1236 cmd_show_window(PurpleConversation *conv, const char *cmd, char **args, char **error, gpointer data) | |
15817 | 1237 { |
22007
c38d72677c8a
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents:
21743
diff
changeset
|
1238 void (*callback)(void) = data; |
15817 | 1239 callback(); |
15822 | 1240 return PURPLE_CMD_STATUS_OK; |
15817 | 1241 } |
1242 | |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
1243 static PurpleCmdRet |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
1244 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
|
1245 { |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
1246 FinchConv *fc = FINCH_GET_DATA(conv); |
16893
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
1247 FinchConvChat *ch; |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
1248 if (!fc) |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
1249 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
|
1250 |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
1251 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
|
1252 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
|
1253 (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
|
1254 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
|
1255 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
|
1256 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
|
1257 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
|
1258 } |
b799918b6cdc
Add a /users command to toggle the userlist in chat windows.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16892
diff
changeset
|
1259 |
15817 | 1260 void finch_conversation_init() |
1261 { | |
21738
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
1262 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
|
1263 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
|
1264 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
|
1265 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
|
1266 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
|
1267 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
|
1268 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
|
1269 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
|
1270 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
|
1271 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
|
1272 if (!color_timestamp) |
e3e64d1e4869
Add color to the conversation window to indicate various message attributes
Richard Nelson <wabz@pidgin.im>
parents:
21284
diff
changeset
|
1273 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
|
1274 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
|
1275 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
|
1276 color_message_action = gnt_color_add_pair(COLOR_YELLOW, -1); |
15822 | 1277 purple_prefs_add_none(PREF_ROOT); |
1278 purple_prefs_add_none(PREF_ROOT "/size"); | |
1279 purple_prefs_add_int(PREF_ROOT "/size/width", 70); | |
1280 purple_prefs_add_int(PREF_ROOT "/size/height", 20); | |
1281 purple_prefs_add_none(PREF_ROOT "/position"); | |
1282 purple_prefs_add_int(PREF_ROOT "/position/x", 0); | |
1283 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
|
1284 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
|
1285 purple_prefs_add_bool(PREF_USERLIST, FALSE); |
15817 | 1286 |
1287 /* Xerox the commands */ | |
15822 | 1288 purple_cmd_register("say", "S", PURPLE_CMD_P_DEFAULT, |
1289 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 1290 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); |
15822 | 1291 purple_cmd_register("me", "S", PURPLE_CMD_P_DEFAULT, |
1292 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 1293 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
15822 | 1294 purple_cmd_register("debug", "w", PURPLE_CMD_P_DEFAULT, |
1295 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 1296 debug_command_cb, _("debug <option>: Send various debug information to the current conversation."), NULL); |
15822 | 1297 purple_cmd_register("clear", "", PURPLE_CMD_P_DEFAULT, |
1298 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 1299 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); |
15822 | 1300 purple_cmd_register("help", "w", PURPLE_CMD_P_DEFAULT, |
1301 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, | |
15817 | 1302 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
|
1303 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
|
1304 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
|
1305 users_command_cb, _("users: Show the list of users in the chat."), NULL); |
15817 | 1306 |
1307 /* Now some commands to bring up some other windows */ | |
15822 | 1308 purple_cmd_register("plugins", "", PURPLE_CMD_P_DEFAULT, |
1309 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 1310 cmd_show_window, _("plugins: Show the plugins window."), finch_plugins_show_all); |
15822 | 1311 purple_cmd_register("buddylist", "", PURPLE_CMD_P_DEFAULT, |
1312 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 1313 cmd_show_window, _("buddylist: Show the buddylist."), finch_blist_show); |
15822 | 1314 purple_cmd_register("accounts", "", PURPLE_CMD_P_DEFAULT, |
1315 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 1316 cmd_show_window, _("accounts: Show the accounts window."), finch_accounts_show_all); |
15822 | 1317 purple_cmd_register("debugwin", "", PURPLE_CMD_P_DEFAULT, |
1318 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 1319 cmd_show_window, _("debugwin: Show the debug window."), finch_debug_window_show); |
15822 | 1320 purple_cmd_register("prefs", "", PURPLE_CMD_P_DEFAULT, |
1321 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 1322 cmd_show_window, _("prefs: Show the preference window."), finch_prefs_show_all); |
15822 | 1323 purple_cmd_register("status", "", PURPLE_CMD_P_DEFAULT, |
1324 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, | |
15817 | 1325 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
|
1326 |
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
1327 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
|
1328 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
|
1329 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
|
1330 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
|
1331 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
|
1332 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
|
1333 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
|
1334 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
|
1335 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
|
1336 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
|
1337 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
|
1338 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
|
1339 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
|
1340 PURPLE_CALLBACK(account_signed_on_off), NULL); |
15817 | 1341 } |
1342 | |
1343 void finch_conversation_uninit() | |
1344 { | |
17021
d6e855aedc30
Notify when you leave a chat, after /part or /kick.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16978
diff
changeset
|
1345 purple_signals_disconnect_by_handle(finch_conv_get_handle()); |
15817 | 1346 } |
1347 | |
15822 | 1348 void finch_conversation_set_active(PurpleConversation *conv) |
15817 | 1349 { |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
1350 FinchConv *ggconv = FINCH_GET_DATA(conv); |
15822 | 1351 PurpleAccount *account; |
15817 | 1352 char *title; |
1353 | |
1354 g_return_if_fail(ggconv); | |
1355 g_return_if_fail(g_list_find(ggconv->list, conv)); | |
1356 | |
1357 ggconv->active_conv = conv; | |
15822 | 1358 account = purple_conversation_get_account(conv); |
15817 | 1359 title = get_conversation_title(conv, account); |
1360 gnt_screen_rename_widget(ggconv->window, title); | |
1361 g_free(title); | |
1362 } | |
1363 | |
16128
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1364 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
|
1365 { |
22217
ad357ca94de9
We will probably eventually use purple_object_[get|set]_ui_data. Until then, this will do.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22215
diff
changeset
|
1366 FinchConv *fc = FINCH_GET_DATA(conv); |
16128
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1367 int height, width; |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1368 |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1369 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
|
1370 |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1371 if (widget) { |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1372 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
|
1373 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
|
1374 } |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1375 |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1376 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
|
1377 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
|
1378 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
|
1379 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
|
1380 } |
7a2ffa981c1a
Allow adding information widgets in the conversation window.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16124
diff
changeset
|
1381 |