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