Mercurial > pidgin.yaz
annotate src/gtkconv.c @ 10313:455c0830d108
[gaim-migrate @ 11511]
" There was a mistake in the name of this header
file. Actually it was declared as #include
"gaim-disclosure.h" when it should have been #include
"gtkgaim-disclosure.h"..." --Norberto Lopes
I don't have the evolution stuff installed, so i didn't notice this.
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Fri, 03 Dec 2004 12:19:03 +0000 |
parents | ec140184437b |
children | 61852117568f |
rev | line source |
---|---|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
1 /** |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
2 * @file gtkconv.c GTK+ Conversation API |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
3 * @ingroup gtkui |
4359 | 4 * |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
5 * gaim |
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
6 * |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
10 * |
4359 | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 * | |
25 */ | |
9791 | 26 #include "internal.h" |
27 #include "gtkgaim.h" | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
28 |
4359 | 29 #ifndef _WIN32 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
30 # include <X11/Xlib.h> |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
31 #endif |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
32 |
4359 | 33 #ifdef USE_GTKSPELL |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
34 # include <gtkspell/gtkspell.h> |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
35 # ifdef _WIN32 |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
36 # include "wspell.h" |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
37 # endif |
4359 | 38 #endif |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
39 |
4359 | 40 #include <gdk/gdkkeysyms.h> |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
41 |
9699 | 42 #include "account.h" |
9130 | 43 #include "cmds.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
44 #include "debug.h" |
6982 | 45 #include "imgstore.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
46 #include "log.h" |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5402
diff
changeset
|
47 #include "notify.h" |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
48 #include "prefs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
49 #include "prpl.h" |
6038 | 50 #include "request.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
51 #include "sound.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
52 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
53 |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
54 #include "gtkdnd-hints.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
55 #include "gtkblist.h" |
5717 | 56 #include "gtkconv.h" |
9709 | 57 #include "gtkdialogs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
58 #include "gtkimhtml.h" |
8317 | 59 #include "gtkimhtmltoolbar.h" |
7431 | 60 #include "gtklog.h" |
5907
18486c860a46
[gaim-migrate @ 6339]
Christian Hammond <chipx86@chipx86.com>
parents:
5902
diff
changeset
|
61 #include "gtkpounce.h" |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
62 #include "gtkprivacy.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
63 #include "gtkutils.h" |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
64 #include "gtkstock.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
65 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
66 /* XXX */ |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
67 #include "gaim.h" |
4359 | 68 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
69 #define AUTO_RESPONSE "<AUTO-REPLY> : " |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
70 |
10175 | 71 #define SEND_COLOR "#16569E" |
72 #define RECV_COLOR "#A82F2F" | |
7854 | 73 |
10108 | 74 #define LUMINANCE(c) (float)((0.3*(c.red))+(0.59*(c.green))+(0.11*(c.blue))) |
75 | |
76 /* These colors come from the default GNOME palette */ | |
77 static GdkColor nick_colors[] = { | |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
78 {0, 47616, 46336, 43776}, /* Basic 3D Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
79 {0, 32768, 32000, 29696}, /* Basic 3D Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
80 {0, 22016, 20992, 18432}, /* 3D Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
81 {0, 33536, 42496, 32512}, /* Green Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
82 {0, 23808, 29952, 21760}, /* Green Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
83 {0, 17408, 22016, 12800}, /* Green Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
84 {0, 57344, 46592, 44800}, /* Red Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
85 {0, 49408, 26112, 23040}, /* Red Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
86 {0, 34816, 17920, 12544}, /* Red Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
87 {0, 49408, 14336, 8704}, /* Red Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
88 {0, 34816, 32512, 41728}, /* Purple Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
89 {0, 25088, 23296, 33024}, /* Purple Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
90 {0, 18688, 16384, 26112}, /* Purple Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
91 {0, 40192, 47104, 53760}, /* Blue Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
92 {0, 29952, 36864, 44544}, /* Blue Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
93 {0, 57344, 49920, 40448}, /* Face Skin Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
94 {0, 45824, 37120, 26880}, /* Face skin Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
95 {0, 33280, 26112, 18176}, /* Face Skin Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
96 {0, 57088, 16896, 7680}, /* Accent Red */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
97 {0, 39168, 0, 0}, /* Accent Red Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
98 {0, 60928, 54784, 32768}, /* Accent Yellow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
99 {0, 17920, 40960, 17920}, /* Accent Green */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
100 {0, 9728, 50944, 9728} /* Accent Green Dark */ |
4359 | 101 }; |
6291 | 102 |
4359 | 103 #define NUM_NICK_COLORS (sizeof(nick_colors) / sizeof(*nick_colors)) |
104 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
105 typedef struct |
4359 | 106 { |
107 GtkWidget *window; | |
108 | |
109 GtkWidget *entry; | |
110 GtkWidget *message; | |
111 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
112 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
113 |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
114 } InviteBuddyInfo; |
4359 | 115 |
116 static GtkWidget *invite_dialog = NULL; | |
117 | |
118 /* Prototypes. <-- because Paco-Paco hates this comment. */ | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
119 static void got_typing_keypress(GaimConversation *conv, gboolean first); |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
120 static GList *generate_invite_user_names(GaimConnection *gc); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
121 static void add_chat_buddy_common(GaimConversation *conv, |
9554 | 122 const char *name); |
9605 | 123 static gboolean tab_complete(GaimConversation *conv); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
124 static void update_typing_icon(GaimConversation *conv); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
125 static gboolean update_send_as_selection(GaimConvWindow *win); |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
126 static char *item_factory_translate_func (const char *path, gpointer func_data); |
4359 | 127 |
128 /************************************************************************** | |
129 * Callbacks | |
130 **************************************************************************/ | |
131 static gint | |
132 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
133 { | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
134 GaimConvWindow *win = (GaimConvWindow *)d; |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
135 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
136 gaim_conv_window_destroy(win); |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
137 |
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
138 return TRUE; |
4359 | 139 } |
140 | |
141 static gint | |
142 close_conv_cb(GtkWidget *w, gpointer d) | |
143 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
144 GaimConversation *conv = (GaimConversation *)d; |
4359 | 145 |
146 gaim_conversation_destroy(conv); | |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
147 |
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
148 return TRUE; |
4359 | 149 } |
150 | |
8914 | 151 static gboolean |
152 size_allocate_cb(GtkWidget *w, GtkAllocation *allocation, GaimConversation *conv) | |
153 { | |
154 GaimGtkConversation *gtkconv; | |
9048 | 155 GaimConvWindow *win = gaim_conversation_get_window(conv); |
9459 | 156 gboolean saveheight; |
8914 | 157 |
158 if (!GTK_WIDGET_VISIBLE(w)) | |
159 return FALSE; | |
160 | |
161 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
162 return FALSE; | |
163 | |
164 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
165 | |
9459 | 166 /* we only save the new height if the formatting toolbar visibility matches the pref */ |
167 saveheight = (gtkconv->show_formatting_toolbar == gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")); | |
168 | |
9048 | 169 /* I find that I resize the window when it has a bunch of conversations in it, mostly so that the tab bar |
170 * will fit, but then I don't want new windows taking up the entire screen. I check to see if there is only one | |
171 * conversation in the window. This way we'll be setting new windows to the size of the last resized new window. */ | |
172 | |
8914 | 173 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
174 { | |
10175 | 175 if (w == gtkconv->imhtml && (gaim_conv_window_get_conversation_count(win) == 1)) |
8914 | 176 { |
177 gaim_prefs_set_int("/gaim/gtk/conversations/im/default_width", allocation->width); | |
9459 | 178 if (saveheight) |
179 gaim_prefs_set_int("/gaim/gtk/conversations/im/default_height", allocation->height); | |
8914 | 180 } |
181 if (w == gtkconv->entry) | |
182 gaim_prefs_set_int("/gaim/gtk/conversations/im/entry_height", allocation->height); | |
183 } | |
184 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
185 { | |
10175 | 186 if (w == gtkconv->imhtml && (gaim_conv_window_get_conversation_count(win) == 1)) |
8914 | 187 { |
188 gaim_prefs_set_int("/gaim/gtk/conversations/chat/default_width", allocation->width); | |
9459 | 189 if (saveheight) |
190 gaim_prefs_set_int("/gaim/gtk/conversations/chat/default_height", allocation->height); | |
8914 | 191 } |
192 if (w == gtkconv->entry) | |
193 gaim_prefs_set_int("/gaim/gtk/conversations/chat/entry_height", allocation->height); | |
194 } | |
195 | |
196 return FALSE; | |
197 } | |
198 | |
7446
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
199 /* Courtesy of Galeon! */ |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
200 static void |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
201 tab_close_button_state_changed_cb(GtkWidget *widget, GtkStateType prev_state) |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
202 { |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
203 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
204 gtk_widget_set_state(widget, GTK_STATE_NORMAL); |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
205 } |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
206 |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
207 static void |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
208 default_formatize(GaimConversation *conv) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
209 { |
8061 | 210 GaimGtkConversation *c = GAIM_GTK_CONVERSATION(conv); |
211 GaimConnection *gc = gaim_conversation_get_gc(conv); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
212 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
213 if (gc && gc->flags & GAIM_CONNECTION_HTML) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
214 { |
9025 | 215 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_formatting")) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
216 { |
9025 | 217 char *color; |
218 GdkColor fg_color, bg_color; | |
219 | |
220 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold")) | |
221 gtk_imhtml_toggle_bold(GTK_IMHTML(c->entry)); | |
222 | |
223 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_italic")) | |
224 gtk_imhtml_toggle_italic(GTK_IMHTML(c->entry)); | |
225 | |
226 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_underline")) | |
227 gtk_imhtml_toggle_underline(GTK_IMHTML(c->entry)); | |
228 | |
229 gtk_imhtml_toggle_fontface(GTK_IMHTML(c->entry), | |
230 gaim_prefs_get_string("/gaim/gtk/conversations/font_face")); | |
231 | |
232 if (!(gc->flags & GAIM_CONNECTION_NO_FONTSIZE)) | |
233 gtk_imhtml_font_set_size(GTK_IMHTML(c->entry), | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
234 gaim_prefs_get_int("/gaim/gtk/conversations/font_size")); |
9025 | 235 |
236 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), "") != 0) | |
237 { | |
238 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), | |
239 &fg_color); | |
240 color = g_strdup_printf("#%02x%02x%02x", | |
241 fg_color.red / 256, | |
242 fg_color.green / 256, | |
243 fg_color.blue / 256); | |
244 } | |
245 else | |
246 color = g_strdup(""); | |
247 | |
8061 | 248 gtk_imhtml_toggle_forecolor(GTK_IMHTML(c->entry), color); |
249 g_free(color); | |
9025 | 250 |
251 if(!(gc->flags & GAIM_CONNECTION_NO_BGCOLOR) && | |
252 strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) | |
253 { | |
254 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), | |
255 &bg_color); | |
256 color = g_strdup_printf("#%02x%02x%02x", | |
257 bg_color.red / 256, | |
258 bg_color.green / 256, | |
259 bg_color.blue / 256); | |
260 } | |
261 else | |
262 color = g_strdup(""); | |
263 | |
8061 | 264 gtk_imhtml_toggle_backcolor(GTK_IMHTML(c->entry), color); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
265 g_free(color); |
8061 | 266 } |
8677 | 267 |
9025 | 268 |
8677 | 269 if (gc->flags & GAIM_CONNECTION_FORMATTING_WBFO) |
270 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), TRUE); | |
271 else | |
272 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), FALSE); | |
8061 | 273 } |
274 } | |
9130 | 275 |
276 static const char * | |
277 gaim_gtk_get_cmd_prefix(void) | |
278 { | |
279 return "/"; | |
280 } | |
281 | |
9167 | 282 static GaimCmdRet |
9829 | 283 say_command_cb(GaimConversation *conv, |
284 const char *cmd, char **args, char **error, void *data) | |
285 { | |
286 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) | |
287 gaim_conv_im_send(GAIM_CONV_IM(conv), args[0]); | |
288 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
289 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), args[0]); | |
290 | |
291 return GAIM_CMD_RET_OK; | |
292 } | |
293 | |
294 static GaimCmdRet | |
9167 | 295 me_command_cb(GaimConversation *conv, |
9597 | 296 const char *cmd, char **args, char **error, void *data) |
9167 | 297 { |
298 char *tmp; | |
299 | |
300 tmp = g_strdup_printf("/me %s", args[0]); | |
9175 | 301 |
9167 | 302 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
303 gaim_conv_im_send(GAIM_CONV_IM(conv), tmp); | |
304 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
305 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), tmp); | |
306 | |
307 g_free(tmp); | |
308 return GAIM_CMD_RET_OK; | |
309 } | |
310 | |
9212 | 311 static GaimCmdRet |
312 debug_command_cb(GaimConversation *conv, | |
9597 | 313 const char *cmd, char **args, char **error, void *data) |
9212 | 314 { |
315 char *tmp, *markup; | |
316 GaimCmdStatus status; | |
317 | |
318 if (!g_ascii_strcasecmp(args[0], "version")) { | |
319 tmp = g_strdup_printf(_("me is using Gaim v%s."), VERSION); | |
320 markup = gaim_escape_html(tmp); | |
321 | |
322 status = gaim_cmd_do_command(conv, tmp, markup, error); | |
323 | |
324 g_free(tmp); | |
325 g_free(markup); | |
326 return status; | |
327 } else { | |
328 gaim_conversation_write(conv, NULL, _("Supported debug options are: version"), | |
329 GAIM_MESSAGE_NO_LOG|GAIM_MESSAGE_ERROR, time(NULL)); | |
330 return GAIM_CMD_STATUS_OK; | |
331 } | |
332 } | |
333 | |
9213 | 334 static GaimCmdRet |
335 help_command_cb(GaimConversation *conv, | |
9597 | 336 const char *cmd, char **args, char **error, void *data) |
9213 | 337 { |
9597 | 338 GList *l, *text; |
9213 | 339 GString *s; |
9597 | 340 |
341 if (args[0] != NULL) { | |
342 s = g_string_new(""); | |
343 text = gaim_cmd_help(conv, args[0]); | |
344 | |
345 if (text) { | |
346 for (l = text; l; l = l->next) | |
347 if (l->next) | |
9816 | 348 g_string_append_printf(s, "%s\n", (char *)l->data); |
9597 | 349 else |
9816 | 350 g_string_append_printf(s, "%s", (char *)l->data); |
9597 | 351 } else { |
352 g_string_append(s, _("No such command (in this context).")); | |
353 } | |
354 } else { | |
355 s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" | |
356 "The following commands are available in this context:\n")); | |
357 | |
358 text = gaim_cmd_list(conv); | |
359 for (l = text; l; l = l->next) | |
9213 | 360 if (l->next) |
9597 | 361 g_string_append_printf(s, "%s, ", (char *)l->data); |
9213 | 362 else |
9597 | 363 g_string_append_printf(s, "%s.", (char *)l->data); |
9213 | 364 } |
365 | |
366 gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL)); | |
367 g_string_free(s, TRUE); | |
368 | |
369 return GAIM_CMD_STATUS_OK; | |
370 } | |
371 | |
4359 | 372 static void |
9374 | 373 send_history_add(GaimConversation *conv, const char *message) |
374 { | |
375 GList *first; | |
376 | |
377 first = g_list_first(conv->send_history); | |
378 | |
379 if (first->data) | |
380 g_free(first->data); | |
381 | |
382 first->data = g_strdup(message); | |
383 | |
384 conv->send_history = g_list_prepend(first, NULL); | |
385 } | |
386 | |
9832 | 387 static gboolean |
388 check_for_and_do_command(GaimConversation *conv) | |
389 { | |
390 GaimGtkConversation *gtkconv; | |
391 char *cmd; | |
392 const char *prefix; | |
393 GaimAccount *account; | |
394 GtkTextIter start; | |
395 | |
396 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
397 account = gaim_conversation_get_account(conv); | |
398 prefix = gaim_gtk_get_cmd_prefix(); | |
399 | |
400 cmd = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); | |
401 gtk_text_buffer_get_start_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &start); | |
402 | |
403 if (cmd && (strncmp(cmd, prefix, strlen(prefix)) == 0) | |
404 && !gtk_text_iter_get_child_anchor(&start)) { | |
405 GaimCmdStatus status; | |
406 char *error, *cmdline, *markup, *send_history; | |
407 GtkTextIter end; | |
408 | |
409 send_history = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); | |
410 send_history_add(conv, send_history); | |
411 g_free(send_history); | |
412 | |
413 cmdline = cmd + strlen(prefix); | |
414 | |
415 gtk_text_iter_forward_chars(&start, g_utf8_strlen(prefix, -1)); | |
416 gtk_text_buffer_get_end_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &end); | |
417 markup = gtk_imhtml_get_markup_range(GTK_IMHTML(gtkconv->entry), &start, &end); | |
418 status = gaim_cmd_do_command(conv, cmdline, markup, &error); | |
419 g_free(cmd); | |
420 g_free(markup); | |
421 | |
422 switch (status) { | |
423 case GAIM_CMD_STATUS_OK: | |
424 return TRUE; | |
425 case GAIM_CMD_STATUS_NOT_FOUND: | |
426 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/passthrough_unknown_commands")) { | |
427 gaim_conversation_write(conv, "", _("No such command."), | |
428 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
429 | |
430 return TRUE; | |
431 } | |
432 return FALSE; | |
433 case GAIM_CMD_STATUS_WRONG_ARGS: | |
434 gaim_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " | |
435 "to that command."), | |
436 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
437 return TRUE; | |
438 case GAIM_CMD_STATUS_FAILED: | |
439 gaim_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), | |
440 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
441 if(error) | |
442 g_free(error); | |
443 return TRUE; | |
444 case GAIM_CMD_STATUS_WRONG_TYPE: | |
445 if(gaim_conversation_get_type(conv) == GAIM_CONV_IM) | |
446 gaim_conversation_write(conv, "", _("That command only works in Chats, not IMs."), | |
447 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
448 else | |
449 gaim_conversation_write(conv, "", _("That command only works in IMs, not Chats."), | |
450 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
451 return TRUE; | |
452 case GAIM_CMD_STATUS_WRONG_PRPL: | |
453 gaim_conversation_write(conv, "", _("That command doesn't work on this protocol."), | |
454 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
455 return TRUE; | |
456 } | |
457 } | |
458 | |
459 g_free(cmd); | |
460 return FALSE; | |
461 } | |
462 | |
9374 | 463 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
464 send_cb(GtkWidget *widget, GaimConversation *conv) |
4359 | 465 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
466 GaimGtkConversation *gtkconv; |
8655 | 467 GaimAccount *account; |
8677 | 468 GaimConnection *gc; |
8448 | 469 char *buf, *clean; |
4359 | 470 |
471 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
8655 | 472 account = gaim_conversation_get_account(conv); |
9130 | 473 |
9471 | 474 if (!gaim_account_is_connected(account)) |
475 return; | |
476 | |
9474 | 477 if ((gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) && |
478 gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv))) | |
9471 | 479 return; |
480 | |
9832 | 481 if (check_for_and_do_command(conv)) { |
482 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); | |
483 default_formatize(conv); | |
484 return; | |
9130 | 485 } |
486 | |
8442 | 487 buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
8962 | 488 clean = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); |
8448 | 489 |
4359 | 490 gtk_widget_grab_focus(gtkconv->entry); |
491 | |
8448 | 492 if (strlen(clean) == 0) { |
493 g_free(clean); | |
4359 | 494 return; |
495 } | |
496 | |
8677 | 497 gc = gaim_account_get_connection(account); |
498 if (gc && (gc->flags & GAIM_CONNECTION_NO_NEWLINES)) { | |
499 char **bufs; | |
500 int i; | |
501 | |
502 bufs = gtk_imhtml_get_markup_lines(GTK_IMHTML(gtkconv->entry)); | |
503 for (i = 0; bufs[i]; i++) { | |
9374 | 504 send_history_add(conv, bufs[i]); |
8677 | 505 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
506 gaim_conv_im_send(GAIM_CONV_IM(conv), bufs[i]); | |
507 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
508 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), bufs[i]); | |
509 } | |
510 | |
511 g_strfreev(bufs); | |
512 | |
513 } else { | |
9374 | 514 send_history_add(conv, buf); |
8677 | 515 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
516 gaim_conv_im_send(GAIM_CONV_IM(conv), buf); | |
517 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
518 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), buf); | |
519 } | |
4359 | 520 |
8677 | 521 g_free(clean); |
4359 | 522 g_free(buf); |
523 | |
8061 | 524 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
525 default_formatize(conv); | |
4359 | 526 } |
527 | |
528 static void | |
7928 | 529 add_remove_cb(GtkWidget *widget, GaimConversation *conv) |
4359 | 530 { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
531 GaimAccount *account; |
4359 | 532 const char *name; |
533 | |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
534 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
535 name = gaim_conversation_get_name(conv); |
7879 | 536 |
537 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { | |
7859 | 538 GaimBuddy *b; |
539 | |
540 b = gaim_find_buddy(account, name); | |
541 if (b != NULL) | |
9730 | 542 gaim_gtkdialogs_remove_buddy(b); |
7859 | 543 else if (account != NULL && gaim_account_is_connected(account)) |
544 gaim_blist_request_add_buddy(account, (char *)name, NULL, NULL); | |
7879 | 545 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { |
7859 | 546 GaimChat *c; |
547 | |
548 c = gaim_blist_find_chat(account, name); | |
549 if (c != NULL) | |
9730 | 550 gaim_gtkdialogs_remove_chat(c); |
7859 | 551 else if (account != NULL && gaim_account_is_connected(account)) |
9754 | 552 gaim_blist_request_add_chat(account, NULL, NULL, name); |
7859 | 553 } |
4359 | 554 |
555 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
556 } | |
557 | |
7975 | 558 static void chat_do_info(GaimConversation *conv, const char *who) |
559 { | |
560 GaimPluginProtocolInfo *prpl_info = NULL; | |
561 GaimConnection *gc; | |
562 | |
563 if ((gc = gaim_conversation_get_gc(conv))) { | |
564 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
565 | |
566 /* | |
567 * If there are special needs for getting info on users in | |
568 * buddy chat "rooms"... | |
569 */ | |
570 if (prpl_info->get_cb_info != NULL) | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
571 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
572 prpl_info->get_cb_info(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
573 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
574 } |
7975 | 575 else |
576 prpl_info->get_info(gc, who); | |
577 } | |
578 } | |
579 | |
580 | |
4359 | 581 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
582 info_cb(GtkWidget *widget, GaimConversation *conv) |
4359 | 583 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
584 GaimGtkConversation *gtkconv; |
4359 | 585 |
586 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
587 | |
7879 | 588 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { |
589 serv_get_info(gaim_conversation_get_gc(conv), | |
590 gaim_conversation_get_name(conv)); | |
591 | |
592 gtk_widget_grab_focus(gtkconv->entry); | |
593 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { | |
594 /* Get info of the person currently selected in the GtkTreeView */ | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
595 GaimGtkChatPane *gtkchat; |
4359 | 596 GtkTreeIter iter; |
597 GtkTreeModel *model; | |
598 GtkTreeSelection *sel; | |
9554 | 599 char *name; |
4359 | 600 |
601 gtkchat = gtkconv->u.chat; | |
602 | |
603 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
604 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
605 | |
606 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
9498 | 607 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
4359 | 608 else |
609 return; | |
610 | |
7975 | 611 chat_do_info(conv, name); |
9554 | 612 g_free(name); |
4359 | 613 } |
614 } | |
615 | |
616 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
617 block_cb(GtkWidget *widget, GaimConversation *conv) |
4359 | 618 { |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
619 GaimAccount *account; |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
620 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
621 account = gaim_conversation_get_account(conv); |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
622 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
623 if (account != NULL && gaim_account_is_connected(account)) |
6399
d726a36628e8
[gaim-migrate @ 6904]
Christian Hammond <chipx86@chipx86.com>
parents:
6398
diff
changeset
|
624 gaim_gtk_request_add_block(account, gaim_conversation_get_name(conv)); |
4359 | 625 |
626 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
627 } | |
628 | |
629 static void | |
9468 | 630 send_file_cb(GtkWidget *widget, GaimConversation *conv) |
631 { | |
632 serv_send_file(gaim_conversation_get_gc(conv), gaim_conversation_get_name(conv), NULL); | |
633 } | |
634 | |
635 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
636 do_invite(GtkWidget *w, int resp, InviteBuddyInfo *info) |
4359 | 637 { |
638 const char *buddy, *message; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
639 GaimGtkConversation *gtkconv; |
4359 | 640 |
641 gtkconv = GAIM_GTK_CONVERSATION(info->conv); | |
642 | |
643 if (resp == GTK_RESPONSE_OK) { | |
644 buddy = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry)); | |
645 message = gtk_entry_get_text(GTK_ENTRY(info->message)); | |
646 | |
10113 | 647 if (!g_ascii_strcasecmp(buddy, "")) |
4359 | 648 return; |
649 | |
650 serv_chat_invite(gaim_conversation_get_gc(info->conv), | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
651 gaim_conv_chat_get_id(GAIM_CONV_CHAT(info->conv)), |
4359 | 652 message, buddy); |
653 } | |
654 | |
655 gtk_widget_destroy(invite_dialog); | |
656 invite_dialog = NULL; | |
657 | |
658 g_free(info); | |
659 } | |
660 | |
661 static void | |
9909 | 662 invite_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, |
663 GtkSelectionData *sd, guint inf, guint t, gpointer data) | |
664 { | |
665 InviteBuddyInfo *info = (InviteBuddyInfo *)data; | |
666 const char *convprotocol; | |
667 | |
668 convprotocol = gaim_account_get_protocol_id(gaim_conversation_get_account(info->conv)); | |
669 | |
670 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) | |
671 { | |
672 GaimBlistNode *node = NULL; | |
673 GaimBuddy *buddy; | |
674 | |
675 memcpy(&node, sd->data, sizeof(node)); | |
676 | |
677 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
678 buddy = gaim_contact_get_priority_buddy((GaimContact *)node); | |
679 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
680 buddy = (GaimBuddy *)node; | |
681 else | |
682 return; | |
683 | |
684 if (strcmp(convprotocol, gaim_account_get_protocol_id(buddy->account))) | |
685 { | |
686 gaim_notify_error(NULL, NULL, | |
687 _("That buddy is not on the same protocol as this " | |
688 "chat"), NULL); | |
689 } | |
690 else | |
691 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), buddy->name); | |
692 | |
693 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
694 } | |
695 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) | |
696 { | |
697 char *protocol = NULL; | |
698 char *username = NULL; | |
699 GaimAccount *account; | |
700 | |
701 if (gaim_gtk_parse_x_im_contact(sd->data, FALSE, &account, | |
702 &protocol, &username, NULL)) | |
703 { | |
704 if (account == NULL) | |
705 { | |
706 gaim_notify_error(NULL, NULL, | |
707 _("You are not currently signed on with an account that " | |
708 "can invite that buddy."), NULL); | |
709 } | |
710 else if (strcmp(convprotocol, gaim_account_get_protocol_id(account))) | |
711 { | |
712 gaim_notify_error(NULL, NULL, | |
713 _("That buddy is not on the same protocol as this " | |
714 "chat"), NULL); | |
715 } | |
716 else | |
717 { | |
718 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), username); | |
719 } | |
720 } | |
721 | |
722 if (username != NULL) g_free(username); | |
723 if (protocol != NULL) g_free(protocol); | |
724 | |
725 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
726 } | |
727 } | |
728 | |
729 static const GtkTargetEntry dnd_targets[] = | |
730 { | |
731 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, 0}, | |
732 {"application/x-im-contact", 0, 1} | |
733 }; | |
734 | |
735 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
736 invite_cb(GtkWidget *widget, GaimConversation *conv) |
4359 | 737 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
738 InviteBuddyInfo *info = NULL; |
4359 | 739 |
740 if (invite_dialog == NULL) { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
741 GaimConnection *gc; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
742 GaimConvWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
743 GaimGtkWindow *gtkwin; |
4359 | 744 GtkWidget *label; |
745 GtkWidget *vbox, *hbox; | |
746 GtkWidget *table; | |
747 GtkWidget *img; | |
748 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
749 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
750 GTK_ICON_SIZE_DIALOG); |
4359 | 751 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
752 info = g_new0(InviteBuddyInfo, 1); |
4359 | 753 info->conv = conv; |
754 | |
755 gc = gaim_conversation_get_gc(conv); | |
756 win = gaim_conversation_get_window(conv); | |
757 gtkwin = GAIM_GTK_WINDOW(win); | |
758 | |
759 /* Create the new dialog. */ | |
760 invite_dialog = gtk_dialog_new_with_buttons( | |
7859 | 761 _("Invite Buddy Into Chat Room"), |
7879 | 762 GTK_WINDOW(gtkwin->window), 0, |
763 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
9443
3584cdab1d0b
[gaim-migrate @ 10264]
Christian Hammond <chipx86@chipx86.com>
parents:
9374
diff
changeset
|
764 GAIM_STOCK_INVITE, GTK_RESPONSE_OK, NULL); |
4359 | 765 |
766 gtk_dialog_set_default_response(GTK_DIALOG(invite_dialog), | |
767 GTK_RESPONSE_OK); | |
768 gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), 6); | |
769 gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE); | |
770 gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE); | |
771 | |
9909 | 772 info->window = GTK_WIDGET(invite_dialog); |
773 | |
4359 | 774 /* Setup the outside spacing. */ |
775 vbox = GTK_DIALOG(invite_dialog)->vbox; | |
776 | |
777 gtk_box_set_spacing(GTK_BOX(vbox), 12); | |
778 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); | |
779 | |
780 /* Setup the inner hbox and put the dialog's icon in it. */ | |
781 hbox = gtk_hbox_new(FALSE, 12); | |
782 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
783 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
784 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
785 | |
786 /* Setup the right vbox. */ | |
787 vbox = gtk_vbox_new(FALSE, 0); | |
788 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
789 | |
790 /* Put our happy label in it. */ | |
791 label = gtk_label_new(_("Please enter the name of the user you wish " | |
792 "to invite, along with an optional invite " | |
793 "message.")); | |
794 gtk_widget_set_size_request(label, 350, -1); | |
795 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
796 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
797 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
798 | |
799 /* hbox for the table, and to give it some spacing on the left. */ | |
800 hbox = gtk_hbox_new(FALSE, 6); | |
801 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
802 | |
803 /* Setup the table we're going to use to lay stuff out. */ | |
804 table = gtk_table_new(2, 2, FALSE); | |
805 gtk_table_set_row_spacings(GTK_TABLE(table), 6); | |
806 gtk_table_set_col_spacings(GTK_TABLE(table), 6); | |
807 gtk_container_set_border_width(GTK_CONTAINER(table), 12); | |
808 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); | |
809 | |
810 /* Now the Buddy label */ | |
811 label = gtk_label_new(NULL); | |
812 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Buddy:")); | |
813 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
814 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
815 | |
816 /* Now the Buddy drop-down entry field. */ | |
817 info->entry = gtk_combo_new(); | |
818 gtk_combo_set_case_sensitive(GTK_COMBO(info->entry), FALSE); | |
819 gtk_entry_set_activates_default( | |
820 GTK_ENTRY(GTK_COMBO(info->entry)->entry), TRUE); | |
821 | |
822 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | |
823 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry); | |
824 | |
825 /* Fill in the names. */ | |
826 gtk_combo_set_popdown_strings(GTK_COMBO(info->entry), | |
827 generate_invite_user_names(gc)); | |
828 | |
829 | |
830 /* Now the label for "Message" */ | |
831 label = gtk_label_new(NULL); | |
832 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Message:")); | |
833 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
834 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
835 | |
836 | |
837 /* And finally, the Message entry field. */ | |
838 info->message = gtk_entry_new(); | |
839 gtk_entry_set_activates_default(GTK_ENTRY(info->message), TRUE); | |
840 | |
841 gtk_table_attach_defaults(GTK_TABLE(table), info->message, 1, 2, 1, 2); | |
842 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->message); | |
843 | |
844 /* Connect the signals. */ | |
845 g_signal_connect(G_OBJECT(invite_dialog), "response", | |
846 G_CALLBACK(do_invite), info); | |
9909 | 847 /* Setup drag-and-drop */ |
848 gtk_drag_dest_set(info->window, | |
849 GTK_DEST_DEFAULT_MOTION | | |
850 GTK_DEST_DEFAULT_DROP, | |
851 dnd_targets, | |
852 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
853 GDK_ACTION_COPY); | |
854 gtk_drag_dest_set(info->entry, | |
855 GTK_DEST_DEFAULT_MOTION | | |
856 GTK_DEST_DEFAULT_DROP, | |
857 dnd_targets, | |
858 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
859 GDK_ACTION_COPY); | |
860 | |
861 g_signal_connect(G_OBJECT(info->window), "drag_data_received", | |
862 G_CALLBACK(invite_dnd_recv), info); | |
863 g_signal_connect(G_OBJECT(info->entry), "drag_data_received", | |
864 G_CALLBACK(invite_dnd_recv), info); | |
865 | |
4359 | 866 } |
867 | |
868 gtk_widget_show_all(invite_dialog); | |
869 | |
870 if (info != NULL) | |
871 gtk_widget_grab_focus(GTK_COMBO(info->entry)->entry); | |
872 } | |
873 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
874 static void |
7748 | 875 menu_new_conv_cb(gpointer data, guint action, GtkWidget *widget) |
876 { | |
9714 | 877 gaim_gtkdialogs_im(); |
7748 | 878 } |
879 | |
880 static void | |
9504 | 881 savelog_writefile_cb(void *user_data, const char *filename) |
9489 | 882 { |
9504 | 883 GaimConversation *conv = (GaimConversation *)user_data; |
9489 | 884 FILE *fp; |
885 const char *name; | |
886 | |
887 if ((fp = fopen(filename, "w+")) == NULL) { | |
9504 | 888 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9489 | 889 return; |
890 } | |
891 | |
892 name = gaim_conversation_get_name(conv); | |
893 fprintf(fp, _("<h1>Conversation with %s</h1>\n"), name); | |
894 fprintf(fp, "%s", conv->history->str); | |
895 fclose(fp); | |
896 } | |
897 | |
898 static void | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
899 menu_save_as_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
900 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
901 GaimConvWindow *win = (GaimConvWindow *)data; |
9489 | 902 GaimConversation *conv = gaim_conv_window_get_active_conversation(win); |
903 gchar *buf; | |
904 | |
905 buf = g_strdup_printf("%s.html", gaim_normalize(conv->account, conv->name)); | |
9504 | 906 |
907 gaim_request_file(conv, _("Save Conversation"), buf, TRUE, | |
908 G_CALLBACK(savelog_writefile_cb), NULL, conv); | |
9489 | 909 |
910 g_free(buf); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
911 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
912 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
913 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
914 menu_view_log_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
915 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
916 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
917 GaimConversation *conv; |
9917 | 918 GaimLogType type; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
919 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
920 conv = gaim_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
921 |
9917 | 922 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
923 type = GAIM_LOG_IM; | |
924 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
925 type = GAIM_LOG_CHAT; | |
926 else | |
927 return; | |
928 | |
929 gaim_gtk_log_show(type, gaim_conversation_get_name(conv), | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
930 gaim_conversation_get_account(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
931 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
932 |
8974 | 933 static void |
934 menu_clear_cb(gpointer data, guint action, GtkWidget *widget) | |
935 { | |
936 GaimConvWindow *win = (GaimConvWindow *)data; | |
937 GaimConversation *conv; | |
938 GaimGtkConversation *gtkconv; | |
939 | |
940 conv = gaim_conv_window_get_active_conversation(win); | |
941 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
942 | |
943 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); | |
944 g_string_free(conv->history, TRUE); | |
945 conv->history = g_string_new(""); | |
946 } | |
947 | |
7295 | 948 struct _search { |
949 GaimGtkConversation *gtkconv; | |
950 GtkWidget *entry; | |
951 }; | |
952 | |
7929 | 953 static void do_search_cb(GtkWidget *widget, gint resp, struct _search *s) |
7295 | 954 { |
7929 | 955 switch (resp) { |
956 case GTK_RESPONSE_OK: | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
957 gtk_imhtml_search_find(GTK_IMHTML(s->gtkconv->imhtml), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
958 gtk_entry_get_text(GTK_ENTRY(s->entry))); |
7929 | 959 break; |
960 | |
961 case GTK_RESPONSE_DELETE_EVENT: | |
962 case GTK_RESPONSE_CLOSE: | |
963 gtk_imhtml_search_clear(GTK_IMHTML(s->gtkconv->imhtml)); | |
964 gtk_widget_destroy(s->gtkconv->dialogs.search); | |
965 s->gtkconv->dialogs.search = NULL; | |
966 g_free(s); | |
967 break; | |
968 } | |
7295 | 969 } |
970 | |
971 static void | |
7751 | 972 menu_find_cb(gpointer data, guint action, GtkWidget *widget) |
7295 | 973 { |
974 GaimConvWindow *win = (GaimConvWindow *)data; | |
975 GaimConversation *conv = gaim_conv_window_get_active_conversation(win); | |
976 GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(win); | |
977 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); | |
7929 | 978 GtkWidget *hbox; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
979 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
980 GTK_ICON_SIZE_DIALOG); |
7929 | 981 GtkWidget *label; |
7295 | 982 struct _search *s; |
983 | |
7798 | 984 if (gtkconv->dialogs.search) { |
985 gtk_window_present(GTK_WINDOW(gtkconv->dialogs.search)); | |
7295 | 986 return; |
7798 | 987 } |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
988 |
7295 | 989 s = g_malloc(sizeof(struct _search)); |
990 s->gtkconv = gtkconv; | |
7929 | 991 |
992 gtkconv->dialogs.search = gtk_dialog_new_with_buttons(_("Find"), | |
993 GTK_WINDOW(gtkwin->window), GTK_DIALOG_DESTROY_WITH_PARENT, | |
994 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
995 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
996 gtk_dialog_set_default_response(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
997 GTK_RESPONSE_OK); |
7929 | 998 g_signal_connect(G_OBJECT(gtkconv->dialogs.search), "response", |
999 G_CALLBACK(do_search_cb), s); | |
1000 | |
1001 gtk_container_set_border_width(GTK_CONTAINER(gtkconv->dialogs.search), 6); | |
1002 gtk_window_set_resizable(GTK_WINDOW(gtkconv->dialogs.search), FALSE); | |
1003 gtk_dialog_set_has_separator(GTK_DIALOG(gtkconv->dialogs.search), FALSE); | |
1004 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(gtkconv->dialogs.search)->vbox), 12); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1005 gtk_container_set_border_width( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1006 GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), 6); |
7929 | 1007 |
1008 hbox = gtk_hbox_new(FALSE, 12); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1009 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1010 hbox); |
7929 | 1011 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
1012 | |
1013 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1014 gtk_dialog_set_response_sensitive(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1015 GTK_RESPONSE_OK, FALSE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1016 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1017 label = gtk_label_new(NULL); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1018 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:")); |
7929 | 1019 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1020 | |
1021 s->entry = gtk_entry_new(); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1022 gtk_entry_set_activates_default(GTK_ENTRY(s->entry), TRUE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1023 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(s->entry)); |
7929 | 1024 g_signal_connect(G_OBJECT(s->entry), "changed", |
1025 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
1026 gtkconv->dialogs.search); | |
1027 gtk_box_pack_start(GTK_BOX(hbox), s->entry, FALSE, FALSE, 0); | |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
1028 |
7295 | 1029 gtk_widget_show_all(gtkconv->dialogs.search); |
7929 | 1030 gtk_widget_grab_focus(s->entry); |
7295 | 1031 } |
1032 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1033 static void |
9468 | 1034 menu_send_file_cb(gpointer data, guint action, GtkWidget *widget) |
1035 { | |
1036 GaimConvWindow *win = (GaimConvWindow *)data; | |
1037 GaimConversation *conv = gaim_conv_window_get_active_conversation(win); | |
1038 | |
1039 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { | |
1040 serv_send_file(gaim_conversation_get_gc(conv), gaim_conversation_get_name(conv), NULL); | |
1041 } | |
1042 | |
1043 } | |
1044 | |
1045 static void | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1046 menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1047 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1048 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1049 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1050 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1051 conv = gaim_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1052 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1053 gaim_gtkpounce_dialog_show(gaim_conversation_get_account(conv), |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1054 gaim_conversation_get_name(conv), NULL); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1055 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1056 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1057 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1058 menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1059 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1060 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1061 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1062 GaimGtkConversation *gtkconv; |
8756 | 1063 GtkIMHtmlToolbar *toolbar; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1064 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1065 conv = gaim_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1066 gtkconv = GAIM_GTK_CONVERSATION(conv); |
8756 | 1067 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1068 | |
1069 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), | |
1070 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1071 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1072 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1073 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1074 menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1075 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1076 GaimConvWindow *win = (GaimConvWindow *)data; |
8756 | 1077 GaimConversation *conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1078 GaimGtkConversation *gtkconv; |
8756 | 1079 GtkIMHtmlToolbar *toolbar; |
1080 | |
1081 conv = gaim_conv_window_get_active_conversation(win); | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1082 gtkconv = GAIM_GTK_CONVERSATION(gaim_conv_window_get_active_conversation(win)); |
8756 | 1083 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1084 | |
1085 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), | |
1086 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1087 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1088 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1089 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1090 menu_alias_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1091 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1092 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1093 GaimConversation *conv; |
7879 | 1094 GaimAccount *account; |
1095 const char *name; | |
1096 | |
1097 conv = gaim_conv_window_get_active_conversation(win); | |
1098 account = gaim_conversation_get_account(conv); | |
1099 name = gaim_conversation_get_name(conv); | |
1100 | |
1101 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { | |
1102 GaimBuddy *b; | |
1103 | |
1104 b = gaim_find_buddy(account, name); | |
1105 if (b != NULL) | |
9730 | 1106 gaim_gtkdialogs_alias_buddy(b); |
7879 | 1107 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { |
1108 GaimChat *c; | |
1109 | |
1110 c = gaim_blist_find_chat(account, name); | |
1111 if (c != NULL) | |
9730 | 1112 gaim_gtkdialogs_alias_chat(c); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1113 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1114 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1115 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1116 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1117 menu_get_info_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1118 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1119 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1120 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1121 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1122 conv = gaim_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1123 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1124 info_cb(NULL, conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1125 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1126 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1127 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1128 menu_invite_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1129 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1130 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1131 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1132 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1133 conv = gaim_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1134 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1135 invite_cb(NULL, conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1136 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1137 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1138 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1139 menu_warn_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1140 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1141 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1142 GaimConversation *conv; |
10025 | 1143 GaimConnection *gc; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1144 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1145 conv = gaim_conv_window_get_active_conversation(win); |
10025 | 1146 gc = gaim_conversation_get_gc(conv); |
1147 | |
1148 gaim_gtkdialogs_warn(gc, gaim_conversation_get_name(conv)); | |
1149 | |
1150 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1151 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1152 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1153 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1154 menu_block_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1155 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1156 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1157 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1158 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1159 conv = gaim_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1160 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1161 block_cb(NULL, conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1162 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1163 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1164 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1165 menu_add_remove_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1166 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1167 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1168 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1169 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1170 conv = gaim_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1171 |
7928 | 1172 add_remove_cb(NULL, conv); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1173 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1174 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1175 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1176 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1177 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1178 GaimConvWindow *win = (GaimConvWindow *)data; |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1179 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1180 close_conv_cb(NULL, gaim_conv_window_get_active_conversation(win)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1181 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1182 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1183 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1184 menu_logging_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1185 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1186 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1187 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1188 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1189 conv = gaim_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1190 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1191 if (conv == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1192 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1193 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1194 gaim_conversation_set_logging(conv, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1195 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1196 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1197 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1198 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1199 menu_toolbar_cb(gpointer data, guint action, GtkWidget *widget) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1200 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1201 GaimConvWindow *win = (GaimConvWindow *)data; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1202 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1203 GaimGtkConversation *gtkconv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1204 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1205 conv = gaim_conv_window_get_active_conversation(win); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1206 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1207 if (conv == NULL) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1208 return; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1209 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1210 gtkconv = GAIM_GTK_CONVERSATION(conv); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1211 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1212 gtkconv->show_formatting_toolbar = |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1213 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1214 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1215 if (gtkconv->show_formatting_toolbar) |
8317 | 1216 gtk_widget_show(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1217 else |
8317 | 1218 gtk_widget_hide(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1219 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1220 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1221 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1222 menu_sounds_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1223 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1224 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1225 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1226 GaimGtkConversation *gtkconv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1227 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1228 conv = gaim_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1229 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1230 if (!conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1231 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1232 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1233 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1234 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1235 gtkconv->make_sound = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1236 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1237 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1238 |
7961 | 1239 static void |
9188 | 1240 menu_timestamps_cb(gpointer data, guint action, GtkWidget *widget) |
1241 { | |
1242 GaimConvWindow *win = (GaimConvWindow *)data; | |
1243 GaimConversation *conv; | |
1244 GaimGtkConversation *gtkconv; | |
1245 | |
1246 conv = gaim_conv_window_get_active_conversation(win); | |
1247 | |
1248 if (!conv) | |
1249 return; | |
1250 | |
1251 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1252 | |
1253 gtkconv->show_timestamps = | |
1254 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
1255 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
1256 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); | |
1257 } | |
1258 | |
1259 static void | |
7961 | 1260 chat_do_im(GaimConversation *conv, const char *who) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1261 { |
7961 | 1262 GaimPluginProtocolInfo *prpl_info = NULL; |
1263 char *real_who; | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1264 GaimConversation *conv2; |
7961 | 1265 GaimAccount *account; |
1266 | |
1267 account = gaim_conversation_get_account(conv); | |
1268 | |
1269 if(account && account->gc) | |
1270 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
1271 | |
1272 if(prpl_info && prpl_info->get_cb_real_name) | |
1273 real_who = prpl_info->get_cb_real_name(account->gc, | |
1274 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); | |
1275 else | |
1276 real_who = g_strdup(who); | |
1277 | |
1278 if(!real_who) | |
1279 return; | |
1280 | |
10246 | 1281 conv2 = gaim_find_conversation_with_account(GAIM_CONV_IM, real_who, account); |
7961 | 1282 |
1283 if (conv2 != NULL) | |
1284 gaim_conv_window_show(gaim_conversation_get_window(conv2)); | |
1285 else | |
1286 conv2 = gaim_conversation_new(GAIM_CONV_IM, account, real_who); | |
1287 | |
1288 g_free(real_who); | |
1289 } | |
1290 | |
1291 | |
1292 static void | |
1293 chat_im_button_cb(GtkWidget *widget, GaimConversation *conv) | |
1294 { | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1295 GaimGtkConversation *gtkconv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1296 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1297 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1298 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1299 GtkTreeSelection *sel; |
9554 | 1300 char *name; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1301 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1302 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1303 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1304 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1305 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1306 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1307 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1308 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) |
9498 | 1309 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1310 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1311 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1312 |
7961 | 1313 chat_do_im(conv, name); |
9554 | 1314 g_free(name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1315 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1316 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1317 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1318 ignore_cb(GtkWidget *w, GaimConversation *conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1319 { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1320 GaimGtkConversation *gtkconv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1321 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1322 GaimConvChat *chat; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1323 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1324 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1325 GtkTreeSelection *sel; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1326 const char *name; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1327 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1328 chat = GAIM_CONV_CHAT(conv); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1329 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1330 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1331 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1332 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1333 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1334 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1335 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { |
9498 | 1336 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1337 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1338 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1339 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1340 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1341 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1342 if (gaim_conv_chat_is_user_ignored(chat, name)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1343 gaim_conv_chat_unignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1344 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1345 gaim_conv_chat_ignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1346 |
9554 | 1347 add_chat_buddy_common(conv, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1348 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1349 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1350 static void |
7398 | 1351 menu_chat_im_cb(GtkWidget *w, GaimConversation *conv) |
1352 { | |
1353 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); | |
1354 | |
1355 chat_do_im(conv, who); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1356 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1357 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1358 static void |
9468 | 1359 menu_chat_send_file_cb(GtkWidget *w, GaimConversation *conv) |
1360 { | |
1361 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); | |
1362 GaimConnection *gc = gaim_conversation_get_gc(conv); | |
1363 | |
1364 serv_send_file(gc, who, NULL); | |
1365 } | |
1366 | |
1367 static void | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1368 menu_chat_info_cb(GtkWidget *w, GaimConversation *conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1369 { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1370 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1371 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1372 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1373 |
7975 | 1374 chat_do_info(conv, who); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1375 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1376 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1377 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1378 menu_chat_get_away_cb(GtkWidget *w, GaimConversation *conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1379 { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1380 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1381 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1382 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1383 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1384 gc = gaim_conversation_get_gc(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1385 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1386 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1387 if (gc != NULL) { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1388 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1389 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1390 /* |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1391 * May want to expand this to work similarly to menu_info_cb? |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1392 */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1393 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1394 if (prpl_info->get_cb_away != NULL) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1395 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1396 prpl_info->get_cb_away(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1397 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1398 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1399 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1400 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1401 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1402 static void |
7928 | 1403 menu_chat_add_remove_cb(GtkWidget *w, GaimConversation *conv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1404 { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1405 GaimAccount *account; |
6695 | 1406 GaimBuddy *b; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1407 char *name; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1408 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1409 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1410 name = g_object_get_data(G_OBJECT(w), "user_data"); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1411 b = gaim_find_buddy(account, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1412 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1413 if (b != NULL) |
9730 | 1414 gaim_gtkdialogs_remove_buddy(b); |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1415 else if (account != NULL && gaim_account_is_connected(account)) |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1416 gaim_blist_request_add_buddy(account, name, NULL, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1417 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1418 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1419 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1420 |
8143 | 1421 static GtkWidget * |
1422 create_chat_menu(GaimConversation *conv, gchar *who, | |
1423 GaimPluginProtocolInfo *prpl_info, GaimConnection *gc) | |
1424 { | |
1425 static GtkWidget *menu = NULL; | |
1426 GtkWidget *button; | |
1427 | |
1428 /* | |
1429 * If a menu already exists, destroy it before creating a new one, | |
1430 * thus freeing-up the memory it occupied. | |
1431 */ | |
1432 if (menu) | |
1433 gtk_widget_destroy(menu); | |
1434 | |
1435 menu = gtk_menu_new(); | |
1436 | |
10221 | 1437 button = gaim_new_item_from_stock(menu, _("IM"), GAIM_STOCK_IM, |
1438 G_CALLBACK(menu_chat_im_cb), conv, 0, 0, NULL); | |
8143 | 1439 g_object_set_data(G_OBJECT(button), "user_data", who); |
1440 | |
9468 | 1441 if (gc && prpl_info && prpl_info->send_file |
1442 && (!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, who))) { | |
10223 | 1443 button = gaim_new_item_from_stock(menu, _("Send File"), |
10221 | 1444 GAIM_STOCK_FILE_TRANSFER, G_CALLBACK(menu_chat_send_file_cb), |
1445 conv, 0, 0, NULL); | |
9468 | 1446 g_object_set_data(G_OBJECT(button), "user_data", who); |
1447 } | |
9498 | 1448 |
8143 | 1449 if (gaim_conv_chat_is_user_ignored(GAIM_CONV_CHAT(conv), who)) |
10221 | 1450 button = gaim_new_item_from_stock(menu, _("Un-Ignore"), GAIM_STOCK_IGNORE, |
1451 G_CALLBACK(ignore_cb), conv, 0, 0, NULL); | |
8143 | 1452 else |
10221 | 1453 button = gaim_new_item_from_stock(menu, _("Ignore"), GAIM_STOCK_IGNORE, |
1454 G_CALLBACK(ignore_cb), conv, 0, 0, NULL); | |
8143 | 1455 g_object_set_data(G_OBJECT(button), "user_data", who); |
1456 | |
8170 | 1457 if (gc && (prpl_info->get_info || prpl_info->get_cb_info)) { |
10221 | 1458 button = gaim_new_item_from_stock(menu, _("Info"), GAIM_STOCK_INFO, |
1459 G_CALLBACK(menu_chat_info_cb), conv, 0, 0, NULL); | |
8143 | 1460 g_object_set_data(G_OBJECT(button), "user_data", who); |
1461 } | |
1462 | |
1463 if (gc && prpl_info->get_cb_away) { | |
10221 | 1464 button = gaim_new_item_from_stock(menu, _("Get Away Message"), GAIM_STOCK_AWAY, |
1465 G_CALLBACK(menu_chat_get_away_cb), conv, 0, 0, NULL); | |
8143 | 1466 g_object_set_data(G_OBJECT(button), "user_data", who); |
1467 } | |
1468 | |
8170 | 1469 /* XXX: jabber can only add buddies from here in certain circumstances */ |
8143 | 1470 /* Added by Jonas <jonas@birme.se> */ |
1471 if (gc) { | |
1472 if (gaim_find_buddy(gc->account, who)) | |
10221 | 1473 button = gaim_new_item_from_stock(menu, _("Remove"), GTK_STOCK_REMOVE, |
10224 | 1474 G_CALLBACK(menu_chat_add_remove_cb), conv, 0, 0, NULL); |
8143 | 1475 else |
10221 | 1476 button = gaim_new_item_from_stock(menu, _("Add"), GTK_STOCK_ADD, |
10224 | 1477 G_CALLBACK(menu_chat_add_remove_cb), conv, 0, 0, NULL); |
8143 | 1478 } |
1479 /* End Jonas */ | |
1480 | |
1481 return menu; | |
1482 } | |
1483 | |
1484 | |
1485 static gint | |
1486 gtkconv_chat_popup_menu_cb(GtkWidget *widget, GaimConversation *conv) | |
1487 { | |
1488 GaimGtkConversation *gtkconv; | |
1489 GaimPluginProtocolInfo *prpl_info = NULL; | |
1490 GaimGtkChatPane *gtkchat; | |
1491 GaimConnection *gc; | |
1492 GaimAccount *account; | |
1493 GtkTreeSelection *sel; | |
1494 GtkTreeIter iter; | |
1495 GtkTreeModel *model; | |
1496 GtkWidget *menu; | |
1497 gchar *who; | |
1498 | |
1499 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1500 gtkchat = gtkconv->u.chat; | |
1501 account = gaim_conversation_get_account(conv); | |
1502 gc = account->gc; | |
1503 | |
1504 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
1505 | |
1506 if (gc != NULL) | |
1507 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1508 | |
1509 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
1510 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1511 return FALSE; | |
1512 | |
9498 | 1513 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
8143 | 1514 menu = create_chat_menu (conv, who, prpl_info, gc); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1515 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1516 gaim_gtk_treeview_popup_menu_position_func, widget, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1517 0, GDK_CURRENT_TIME); |
8143 | 1518 |
1519 return TRUE; | |
1520 } | |
1521 | |
1522 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1523 static gint |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1524 right_click_chat_cb(GtkWidget *widget, GdkEventButton *event, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1525 GaimConversation *conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1526 { |
8143 | 1527 GaimGtkConversation *gtkconv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1528 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1529 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1530 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1531 GaimAccount *account; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1532 GtkTreePath *path; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1533 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1534 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1535 GtkTreeViewColumn *column; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1536 gchar *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1537 int x, y; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1538 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1539 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1540 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1541 account = gaim_conversation_get_account(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1542 gc = account->gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1543 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1544 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1545 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1546 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(gtkchat->list), |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1547 event->x, event->y, &path, &column, &x, &y); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1548 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1549 if (path == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1550 return FALSE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1551 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1552 if (gc != NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1553 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1554 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1555 gtk_tree_selection_select_path(GTK_TREE_SELECTION( |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1556 gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list))), path); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1557 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1558 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path); |
9498 | 1559 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1560 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1561 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { |
7398 | 1562 chat_do_im(conv, who); |
9554 | 1563 g_free(who); |
7398 | 1564 } else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { |
8143 | 1565 GtkWidget *menu = create_chat_menu (conv, who, prpl_info, gc); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1566 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1567 event->button, event->time); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1568 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1569 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1570 return TRUE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1571 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1572 |
8133 | 1573 static void |
1574 move_to_next_unread_tab(GaimConversation *conv) | |
1575 { | |
1576 GaimConversation *next_conv = NULL; | |
1577 GaimConvWindow *win; | |
1578 GList *l; | |
1579 int index, i; | |
1580 | |
1581 win = gaim_conversation_get_window(conv); | |
1582 index = gaim_conversation_get_index(conv); | |
1583 | |
1584 /* First check the tabs after this position. */ | |
1585 for (l = g_list_nth(gaim_conv_window_get_conversations(win), index); | |
1586 l != NULL; | |
1587 l = l->next) { | |
1588 | |
1589 next_conv = (GaimConversation *)l->data; | |
1590 | |
1591 if (gaim_conversation_get_unseen(next_conv) > 0) | |
1592 break; | |
1593 | |
1594 next_conv = NULL; | |
1595 } | |
1596 | |
1597 if (next_conv == NULL) { | |
1598 | |
1599 /* Now check before this position. */ | |
1600 for (l = gaim_conv_window_get_conversations(win), i = 0; | |
1601 l != NULL && i < index; | |
1602 l = l->next) { | |
1603 | |
1604 next_conv = (GaimConversation *)l->data; | |
1605 | |
1606 if (gaim_conversation_get_unseen(next_conv) > 0) | |
1607 break; | |
1608 | |
1609 next_conv = NULL; | |
1610 } | |
1611 | |
1612 if (next_conv == NULL) { | |
1613 /* Okay, just grab the next conversation tab. */ | |
1614 if (index == gaim_conv_window_get_conversation_count(win) - 1) | |
1615 next_conv = gaim_conv_window_get_conversation_at(win, 0); | |
1616 else | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1617 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1618 next_conv = gaim_conv_window_get_conversation_at(win, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1619 index + 1); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1620 } |
8133 | 1621 } |
1622 } | |
1623 | |
1624 if (next_conv != NULL && next_conv != conv) { | |
1625 gaim_conv_window_switch_conversation(win, | |
1626 gaim_conversation_get_index(next_conv)); | |
1627 } | |
1628 } | |
1629 | |
4359 | 1630 static gboolean |
8105 | 1631 entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data) |
4359 | 1632 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1633 GaimConvWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1634 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1635 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1636 GaimGtkWindow *gtkwin; |
8105 | 1637 int numconvs; |
1638 int curconv; | |
1639 | |
1640 conv = (GaimConversation *)data; | |
1641 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1642 win = gaim_conversation_get_window(conv); | |
1643 gtkwin = GAIM_GTK_WINDOW(win); | |
1644 numconvs = gaim_conv_window_get_conversation_count(win); | |
1645 curconv = gaim_conversation_get_index(conv); | |
1646 | |
1647 /* If CTRL was held down... */ | |
1648 if (event->state & GDK_CONTROL_MASK) { | |
4359 | 1649 switch (event->keyval) { |
1650 case GDK_Up: | |
1651 if (!conv->send_history) | |
1652 break; | |
1653 | |
1654 if (!conv->send_history->prev) { | |
1655 GtkTextIter start, end; | |
1656 | |
1657 if (conv->send_history->data) | |
1658 g_free(conv->send_history->data); | |
1659 | |
1660 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
1661 &start); | |
1662 gtk_text_buffer_get_end_iter(gtkconv->entry_buffer, &end); | |
1663 | |
1664 conv->send_history->data = | |
8506 | 1665 gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
4359 | 1666 } |
8677 | 1667 |
4359 | 1668 if (conv->send_history->next && |
1669 conv->send_history->next->data) { | |
8677 | 1670 GtkTextIter iter; |
1671 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
4359 | 1672 |
1673 conv->send_history = conv->send_history->next; | |
8061 | 1674 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1675 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1676 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1677 0, NULL); |
8677 | 1678 /* this is mainly just a hack so the formatting at the |
1679 * cursor gets picked up. */ | |
1680 gtk_text_buffer_get_end_iter(buffer, &iter); | |
1681 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); | |
4359 | 1682 } |
1683 | |
8105 | 1684 return TRUE; |
4359 | 1685 break; |
1686 | |
1687 case GDK_Down: | |
1688 if (!conv->send_history) | |
1689 break; | |
1690 | |
8105 | 1691 if (conv->send_history->prev && |
1692 conv->send_history->prev->data) { | |
8677 | 1693 GtkTextIter iter; |
1694 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
8105 | 1695 |
4359 | 1696 conv->send_history = conv->send_history->prev; |
8105 | 1697 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1698 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1699 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1700 0, NULL); |
8677 | 1701 /* this is mainly just a hack so the formatting at the |
1702 * cursor gets picked up. */ | |
1703 gtk_text_buffer_get_end_iter(buffer, &iter); | |
1704 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); | |
4359 | 1705 } |
1706 | |
8105 | 1707 return TRUE; |
4359 | 1708 break; |
8105 | 1709 |
8108 | 1710 case GDK_Page_Down: |
8143 | 1711 case ']': |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1712 gaim_conv_window_switch_conversation(win, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1713 (curconv + 1) % numconvs); |
8105 | 1714 |
1715 return TRUE; | |
1716 break; | |
1717 | |
8108 | 1718 case GDK_Page_Up: |
8143 | 1719 case '[': |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1720 gaim_conv_window_switch_conversation(win, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1721 (curconv + numconvs - 1) % numconvs); |
8133 | 1722 |
1723 return TRUE; | |
1724 break; | |
1725 | |
8108 | 1726 case GDK_Tab: |
8133 | 1727 move_to_next_unread_tab(conv); |
8108 | 1728 |
1729 return TRUE; | |
1730 break; | |
1731 | |
1732 case 'z': | |
1733 gtk_window_iconify(GTK_WINDOW(gtkwin->window)); | |
8105 | 1734 |
1735 return TRUE; | |
1736 break; | |
1737 | |
1738 } /* End of switch */ | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1739 } |
8758 | 1740 |
8105 | 1741 /* If ALT (or whatever) was held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1742 else if (event->state & GDK_MOD1_MASK) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1743 { |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8730
diff
changeset
|
1744 /* XXX - Make sure the conv exists before switching to it */ |
8105 | 1745 if (event->keyval > '0' && event->keyval <= '9') { |
1746 int switchto = event->keyval - '1'; | |
1747 if (switchto < numconvs) | |
1748 gaim_conv_window_switch_conversation(win, switchto); | |
4359 | 1749 |
1750 return TRUE; | |
1751 } | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1752 } |
8758 | 1753 |
8105 | 1754 /* If neither CTRL nor ALT were held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1755 else |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1756 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1757 switch (event->keyval) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1758 { |
10115 | 1759 case GDK_Tab: |
9605 | 1760 return tab_complete(conv); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1761 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1762 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1763 case GDK_Page_Up: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1764 gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml)); |
8105 | 1765 return TRUE; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1766 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1767 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1768 case GDK_Page_Down: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1769 gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml)); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1770 return TRUE; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1771 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1772 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1773 } |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1774 } |
4359 | 1775 return FALSE; |
1776 } | |
1777 | |
1778 /* | |
1779 * NOTE: | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1780 * This guy just kills a single right click from being propagated any |
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1781 * further. I have no idea *why* we need this, but we do ... It |
4359 | 1782 * prevents right clicks on the GtkTextView in a convo dialog from |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1783 * going all the way down to the notebook. I suspect a bug in |
4359 | 1784 * GtkTextView, but I'm not ready to point any fingers yet. |
1785 */ | |
1786 static gboolean | |
1787 entry_stop_rclick_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
1788 { | |
1789 if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { | |
1790 /* Right single click */ | |
1791 g_signal_stop_emission_by_name(G_OBJECT(widget), "button_press_event"); | |
1792 | |
1793 return TRUE; | |
1794 } | |
1795 | |
1796 return FALSE; | |
1797 } | |
1798 | |
8173 | 1799 /* |
1800 * If someone tries to type into the conversation backlog of a | |
1801 * conversation window then we yank focus from the conversation backlog | |
1802 * and give it to the text entry box so that people can type | |
1803 * all the live long day and it will get entered into the entry box. | |
1804 */ | |
6057 | 1805 static gboolean |
8105 | 1806 refocus_entry_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
6057 | 1807 { |
1808 GaimGtkConversation *gtkconv = data; | |
1809 | |
8237 | 1810 /* If we have a valid key for the conversation display, then exit */ |
8224 | 1811 if ((event->state & GDK_CONTROL_MASK) || |
8237 | 1812 (event->keyval == GDK_F10) || |
1813 (event->keyval == GDK_Shift_L) || | |
1814 (event->keyval == GDK_Shift_R) || | |
1815 (event->keyval == GDK_Escape) || | |
8177 | 1816 (event->keyval == GDK_Up) || |
1817 (event->keyval == GDK_Down) || | |
1818 (event->keyval == GDK_Left) || | |
8191 | 1819 (event->keyval == GDK_Right) || |
1820 (event->keyval == GDK_Home) || | |
9297 | 1821 (event->keyval == GDK_End) || |
1822 (event->keyval == GDK_Tab) || | |
1823 (event->keyval == GDK_ISO_Left_Tab)) | |
8177 | 1824 return FALSE; |
1825 | |
1826 if (event->type == GDK_KEY_RELEASE) | |
1827 gtk_widget_grab_focus(gtkconv->entry); | |
1828 | |
1829 gtk_widget_event(gtkconv->entry, (GdkEvent *)event); | |
1830 | |
1831 return TRUE; | |
6057 | 1832 } |
1833 | |
4359 | 1834 static void |
4673 | 1835 menu_conv_sel_send_cb(GObject *m, gpointer data) |
4359 | 1836 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1837 GaimConvWindow *win = g_object_get_data(m, "user_data"); |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
1838 GaimAccount *account = g_object_get_data(m, "gaim_account"); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1839 GaimConversation *conv; |
8456 | 1840 GaimGtkConversation *gtkconv; |
4359 | 1841 |
10059
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1842 if (gtk_check_menu_item_get_active((GtkCheckMenuItem*) m) == FALSE) |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1843 return; |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1844 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1845 conv = gaim_conv_window_get_active_conversation(win); |
4359 | 1846 |
4491 | 1847 gaim_conversation_set_account(conv, account); |
8456 | 1848 |
1849 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1850 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), | |
9699 | 1851 gaim_account_get_protocol_name(conv->account)); |
4359 | 1852 } |
1853 | |
1854 static void | |
1855 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, | |
1856 gchar *new_text, gint new_text_length, gpointer user_data) | |
1857 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1858 GaimConversation *conv = (GaimConversation *)user_data; |
4359 | 1859 |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
1860 g_return_if_fail(conv != NULL); |
4359 | 1861 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
1862 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 1863 return; |
1864 | |
1865 got_typing_keypress(conv, (gtk_text_iter_is_start(position) && | |
1866 gtk_text_iter_is_end(position))); | |
1867 } | |
1868 | |
1869 static void | |
1870 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, | |
1871 GtkTextIter *end_pos, gpointer user_data) | |
1872 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1873 GaimConversation *conv = (GaimConversation *)user_data; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1874 GaimConvIm *im; |
4359 | 1875 |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
1876 g_return_if_fail(conv != NULL); |
4359 | 1877 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
1878 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 1879 return; |
1880 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1881 im = GAIM_CONV_IM(conv); |
4359 | 1882 |
1883 if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) { | |
1884 | |
1885 /* We deleted all the text, so turn off typing. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1886 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1887 gaim_conv_im_stop_type_again_timeout(im); |
4359 | 1888 |
1889 serv_send_typing(gaim_conversation_get_gc(conv), | |
6695 | 1890 gaim_conversation_get_name(conv), |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
1891 GAIM_NOT_TYPING); |
4359 | 1892 } |
1893 else { | |
1894 /* We're deleting, but not all of it, so it counts as typing. */ | |
1895 got_typing_keypress(conv, FALSE); | |
1896 } | |
1897 } | |
1898 | |
1899 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1900 notebook_init_grab(GaimGtkWindow *gtkwin, GtkWidget *widget) |
4359 | 1901 { |
1902 static GdkCursor *cursor = NULL; | |
1903 | |
1904 gtkwin->in_drag = TRUE; | |
1905 | |
1906 if (gtkwin->drag_leave_signal) { | |
1907 g_signal_handler_disconnect(G_OBJECT(widget), | |
1908 gtkwin->drag_leave_signal); | |
1909 | |
1910 gtkwin->drag_leave_signal = 0; | |
1911 } | |
1912 | |
1913 if (cursor == NULL) | |
1914 cursor = gdk_cursor_new(GDK_FLEUR); | |
1915 | |
1916 /* Grab the pointer */ | |
1917 gtk_grab_add(gtkwin->notebook); | |
5114
e245e686f62f
[gaim-migrate @ 5477]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5106
diff
changeset
|
1918 #ifndef _WIN32 |
e245e686f62f
[gaim-migrate @ 5477]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5106
diff
changeset
|
1919 /* Currently for win32 GTK+ (as of 2.2.1), gdk_pointer_is_grabbed will |
e245e686f62f
[gaim-migrate @ 5477]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5106
diff
changeset
|
1920 always be true after a button press. */ |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1921 if (!gdk_pointer_is_grabbed()) |
5114
e245e686f62f
[gaim-migrate @ 5477]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5106
diff
changeset
|
1922 #endif |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1923 gdk_pointer_grab(gtkwin->notebook->window, FALSE, |
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1924 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, |
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1925 NULL, cursor, GDK_CURRENT_TIME); |
4359 | 1926 } |
1927 | |
1928 static gboolean | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1929 notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, GaimConvWindow *win) |
4359 | 1930 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1931 GaimGtkWindow *gtkwin; |
4359 | 1932 |
1933 gtkwin = GAIM_GTK_WINDOW(win); | |
1934 | |
1935 /* | |
1936 * Make sure the user moved the mouse far enough for the | |
1937 * drag to be initiated. | |
1938 */ | |
1939 if (gtkwin->in_predrag) { | |
1940 if (e->x_root < gtkwin->drag_min_x || | |
1941 e->x_root >= gtkwin->drag_max_x || | |
1942 e->y_root < gtkwin->drag_min_y || | |
1943 e->y_root >= gtkwin->drag_max_y) { | |
1944 | |
1945 gtkwin->in_predrag = FALSE; | |
1946 notebook_init_grab(gtkwin, widget); | |
1947 } | |
1948 } | |
1949 else { /* Otherwise, draw the arrows. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1950 GaimConvWindow *dest_win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1951 GaimGtkWindow *dest_gtkwin; |
4359 | 1952 GtkNotebook *dest_notebook; |
1953 GtkWidget *tab, *last_vis_tab = NULL; | |
1954 gint nb_x, nb_y, page_num, i, last_vis_tab_loc = -1; | |
1955 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; | |
1956 gboolean horiz_tabs = FALSE, tab_found = FALSE; | |
1957 GList *l; | |
1958 | |
1959 /* Get the window that the cursor is over. */ | |
1960 dest_win = gaim_gtkwin_get_at_xy(e->x_root, e->y_root); | |
1961 | |
1962 if (dest_win == NULL) { | |
1963 dnd_hints_hide_all(); | |
1964 | |
1965 return TRUE; | |
1966 } | |
1967 | |
1968 dest_gtkwin = GAIM_GTK_WINDOW(dest_win); | |
1969 | |
1970 dest_notebook = GTK_NOTEBOOK(dest_gtkwin->notebook); | |
1971 | |
1972 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); | |
1973 | |
1974 arrow1_x = arrow2_x = nb_x; | |
1975 arrow1_y = arrow2_y = nb_y; | |
1976 | |
1977 page_num = gaim_gtkconv_get_dest_tab_at_xy(dest_win, | |
1978 e->x_root, e->y_root); | |
1979 | |
1980 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || | |
1981 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { | |
1982 | |
1983 horiz_tabs = TRUE; | |
1984 } | |
1985 | |
1986 /* Find out where to put the arrows. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1987 for (l = gaim_conv_window_get_conversations(dest_win), i = 0; |
4359 | 1988 l != NULL; |
1989 l = l->next, i++) { | |
1990 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1991 GaimConversation *conv = l->data; |
4359 | 1992 |
1993 tab = GAIM_GTK_CONVERSATION(conv)->tabby; | |
1994 | |
1995 /* | |
1996 * If this is the correct tab, record the positions | |
1997 * for the arrows. | |
1998 */ | |
1999 if (i == page_num) { | |
2000 if (horiz_tabs) { | |
2001 arrow1_x = arrow2_x = nb_x + tab->allocation.x; | |
2002 arrow1_y = nb_y + tab->allocation.y; | |
2003 arrow2_y = nb_y + tab->allocation.y + | |
2004 tab->allocation.height; | |
2005 } | |
2006 else { | |
2007 arrow1_x = nb_x + tab->allocation.x; | |
2008 arrow2_x = nb_x + tab->allocation.x + | |
2009 tab->allocation.width; | |
2010 arrow1_y = arrow2_y = nb_y + tab->allocation.y; | |
2011 } | |
2012 | |
2013 tab_found = TRUE; | |
2014 break; | |
2015 } | |
2016 else { /* Keep track of the right-most tab that we see. */ | |
2017 if (horiz_tabs && tab->allocation.x > last_vis_tab_loc) { | |
2018 last_vis_tab = tab; | |
2019 last_vis_tab_loc = tab->allocation.x; | |
2020 } | |
2021 else if (!horiz_tabs && tab->allocation.y > last_vis_tab_loc) { | |
2022 last_vis_tab = tab; | |
2023 last_vis_tab_loc = tab->allocation.y; | |
2024 } | |
2025 } | |
2026 } | |
2027 | |
2028 /* | |
2029 * If we didn't find the tab, then we'll just place the | |
2030 * arrows to the right/bottom of the last visible tab. | |
2031 */ | |
2032 if (!tab_found && last_vis_tab) { | |
2033 if (horiz_tabs) { | |
2034 arrow1_x = arrow2_x = nb_x + last_vis_tab->allocation.x + | |
2035 last_vis_tab->allocation.width; | |
2036 arrow1_y = nb_y + last_vis_tab->allocation.y; | |
2037 arrow2_y = nb_y + last_vis_tab->allocation.y + | |
2038 last_vis_tab->allocation.height; | |
2039 } | |
2040 else { | |
2041 arrow1_x = nb_x + last_vis_tab->allocation.x; | |
2042 arrow2_x = nb_x + last_vis_tab->allocation.x + | |
2043 last_vis_tab->allocation.width; | |
2044 arrow1_y = arrow2_y = nb_y + last_vis_tab->allocation.y + | |
2045 last_vis_tab->allocation.height; | |
2046 } | |
2047 } | |
2048 | |
2049 if (horiz_tabs) { | |
2050 dnd_hints_show(HINT_ARROW_DOWN, arrow1_x, arrow1_y); | |
2051 dnd_hints_show(HINT_ARROW_UP, arrow2_x, arrow2_y); | |
2052 } | |
2053 else { | |
2054 dnd_hints_show(HINT_ARROW_RIGHT, arrow1_x, arrow1_y); | |
2055 dnd_hints_show(HINT_ARROW_LEFT, arrow2_x, arrow2_y); | |
2056 } | |
2057 } | |
2058 | |
2059 return TRUE; | |
2060 } | |
2061 | |
2062 static gboolean | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2063 notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, GaimConvWindow *win) |
4359 | 2064 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2065 GaimGtkWindow *gtkwin; |
4359 | 2066 |
2067 gtkwin = GAIM_GTK_WINDOW(win); | |
2068 | |
2069 if (gtkwin->in_drag) | |
2070 return FALSE; | |
2071 | |
2072 if (e->x_root < gtkwin->drag_min_x || | |
2073 e->x_root >= gtkwin->drag_max_x || | |
2074 e->y_root < gtkwin->drag_min_y || | |
2075 e->y_root >= gtkwin->drag_max_y) { | |
2076 | |
2077 gtkwin->in_predrag = FALSE; | |
2078 notebook_init_grab(gtkwin, widget); | |
2079 } | |
2080 | |
2081 return TRUE; | |
2082 } | |
2083 | |
2084 /* | |
2085 * THANK YOU GALEON! | |
2086 */ | |
2087 static gboolean | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2088 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, GaimConvWindow *win) |
4359 | 2089 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2090 GaimGtkWindow *gtkwin; |
4359 | 2091 gint nb_x, nb_y, x_rel, y_rel; |
2092 GList *l; | |
2093 int tab_clicked; | |
2094 | |
2095 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
2096 return FALSE; | |
2097 | |
2098 gtkwin = GAIM_GTK_WINDOW(win); | |
2099 | |
2100 if (gtkwin->in_drag) { | |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
2101 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
2102 "Already in the middle of a window drag at tab_press_cb\n"); |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
2103 return TRUE; |
4359 | 2104 } |
2105 | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2106 /* |
4359 | 2107 * Make sure a tab was actually clicked. The arrow buttons |
2108 * mess things up. | |
2109 */ | |
2110 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root); | |
2111 | |
2112 if (tab_clicked == -1) | |
2113 return FALSE; | |
2114 | |
2115 /* | |
2116 * Get the relative position of the press event, with regards to | |
2117 * the position of the notebook. | |
2118 */ | |
2119 gdk_window_get_origin(gtkwin->notebook->window, &nb_x, &nb_y); | |
2120 | |
2121 x_rel = e->x_root - nb_x; | |
2122 y_rel = e->y_root - nb_y; | |
2123 | |
2124 /* Reset the min/max x/y */ | |
2125 gtkwin->drag_min_x = 0; | |
2126 gtkwin->drag_min_y = 0; | |
2127 gtkwin->drag_max_x = 0; | |
2128 gtkwin->drag_max_y = 0; | |
2129 | |
2130 /* Find out which tab was dragged. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2131 for (l = gaim_conv_window_get_conversations(win); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2132 GaimConversation *conv = l->data; |
4359 | 2133 GtkWidget *tab = GAIM_GTK_CONVERSATION(conv)->tabby; |
2134 | |
2135 if (!GTK_WIDGET_VISIBLE(tab)) | |
2136 continue; | |
2137 | |
2138 if (tab->allocation.x > x_rel || tab->allocation.y > y_rel) | |
2139 break; | |
2140 | |
2141 /* Save the borders of the tab. */ | |
2142 gtkwin->drag_min_x = tab->allocation.x + nb_x; | |
2143 gtkwin->drag_min_y = tab->allocation.y + nb_y; | |
2144 gtkwin->drag_max_x = tab->allocation.width + gtkwin->drag_min_x; | |
2145 gtkwin->drag_max_y = tab->allocation.height + gtkwin->drag_min_y; | |
2146 } | |
2147 | |
2148 /* Make sure the click occurred in the tab. */ | |
2149 if (e->x_root < gtkwin->drag_min_x || | |
2150 e->x_root >= gtkwin->drag_max_x || | |
2151 e->y_root < gtkwin->drag_min_y || | |
2152 e->y_root >= gtkwin->drag_max_y) { | |
2153 | |
2154 return FALSE; | |
2155 } | |
2156 | |
2157 gtkwin->in_predrag = TRUE; | |
2158 | |
2159 /* Connect the new motion signals. */ | |
2160 gtkwin->drag_motion_signal = | |
2161 g_signal_connect(G_OBJECT(widget), "motion_notify_event", | |
2162 G_CALLBACK(notebook_motion_cb), win); | |
2163 | |
2164 gtkwin->drag_leave_signal = | |
2165 g_signal_connect(G_OBJECT(widget), "leave_notify_event", | |
2166 G_CALLBACK(notebook_leave_cb), win); | |
2167 | |
2168 return FALSE; | |
2169 } | |
2170 | |
2171 static gboolean | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2172 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, GaimConvWindow *win) |
4359 | 2173 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2174 GaimConvWindow *dest_win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2175 GaimGtkWindow *gtkwin; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2176 GaimGtkWindow *dest_gtkwin; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2177 GaimConversation *conv; |
4359 | 2178 GtkNotebook *dest_notebook; |
2179 gint dest_page_num; | |
2180 | |
2181 /* | |
2182 * Don't check to make sure that the event's window matches the | |
2183 * widget's, because we may be getting an event passed on from the | |
2184 * close button. | |
2185 */ | |
2186 if (e->button != 1 && e->type != GDK_BUTTON_RELEASE) | |
2187 return FALSE; | |
2188 | |
2189 if (gdk_pointer_is_grabbed()) { | |
2190 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
2191 gtk_grab_remove(widget); | |
2192 } | |
2193 | |
2194 gtkwin = GAIM_GTK_WINDOW(win); | |
2195 | |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
2196 if (!gtkwin->in_predrag && !gtkwin->in_drag) |
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
2197 return FALSE; |
4359 | 2198 |
2199 /* Disconnect the motion signal. */ | |
2200 if (gtkwin->drag_motion_signal) { | |
2201 g_signal_handler_disconnect(G_OBJECT(widget), | |
2202 gtkwin->drag_motion_signal); | |
2203 | |
2204 gtkwin->drag_motion_signal = 0; | |
2205 } | |
2206 | |
2207 /* | |
2208 * If we're in a pre-drag, we'll also need to disconnect the leave | |
2209 * signal. | |
2210 */ | |
2211 if (gtkwin->in_predrag) { | |
2212 gtkwin->in_predrag = FALSE; | |
2213 | |
2214 if (gtkwin->drag_leave_signal) { | |
2215 g_signal_handler_disconnect(G_OBJECT(widget), | |
2216 gtkwin->drag_leave_signal); | |
2217 | |
2218 gtkwin->drag_leave_signal = 0; | |
2219 } | |
2220 } | |
2221 | |
2222 /* If we're not in drag... */ | |
2223 /* We're perfectly normal people! */ | |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
2224 if (!gtkwin->in_drag) |
4359 | 2225 return FALSE; |
2226 | |
2227 gtkwin->in_drag = FALSE; | |
2228 | |
2229 dnd_hints_hide_all(); | |
2230 | |
4369
7e1fb422e5fd
[gaim-migrate @ 4635]
Christian Hammond <chipx86@chipx86.com>
parents:
4368
diff
changeset
|
2231 dest_win = gaim_gtkwin_get_at_xy(e->x_root, e->y_root); |
4359 | 2232 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2233 conv = gaim_conv_window_get_active_conversation(win); |
4359 | 2234 |
2235 if (dest_win == NULL) { | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2236 if (gaim_conv_window_get_conversation_count(win) < 2) |
4359 | 2237 return FALSE; |
2238 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2239 if (gaim_conv_window_get_conversation_count(win) > 1) { |
4359 | 2240 /* Make a new window to stick this to. */ |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2241 GaimGtkConversation *gtkconv; |
4748
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
2242 gint win_width, win_height; |
5121 | 2243 |
2244 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4359 | 2245 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2246 dest_win = gaim_conv_window_new(); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2247 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2248 gaim_conv_window_add_conversation(dest_win, |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2249 gaim_conv_window_remove_conversation(win, |
5139
d0182ae31ab8
[gaim-migrate @ 5503]
Christian Hammond <chipx86@chipx86.com>
parents:
5133
diff
changeset
|
2250 gaim_conversation_get_index(conv))); |
5121 | 2251 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2252 dest_gtkwin = GAIM_GTK_WINDOW(dest_win); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2253 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2254 gtk_window_get_size(GTK_WINDOW(dest_gtkwin->window), |
4748
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
2255 &win_width, &win_height); |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
2256 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2257 gtk_window_move(GTK_WINDOW(dest_gtkwin->window), |
4748
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
2258 e->x_root - (win_width / 2), |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
2259 e->y_root - (win_height / 2)); |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
2260 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2261 gaim_conv_window_show(dest_win); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2262 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2263 } else { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2264 dest_gtkwin = GAIM_GTK_WINDOW(dest_win); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2265 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2266 /* Get the destination notebook. */ |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2267 dest_notebook = GTK_NOTEBOOK(gtkwin->notebook); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2268 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2269 /* Get the destination page number. */ |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2270 dest_page_num = gaim_gtkconv_get_dest_tab_at_xy(dest_win, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2271 e->x_root, e->y_root); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2272 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2273 if (win == dest_win) { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2274 gaim_conv_window_move_conversation(win, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2275 gaim_conversation_get_index(conv), dest_page_num); |
4359 | 2276 } |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2277 else { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2278 size_t pos; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2279 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2280 gaim_conv_window_remove_conversation(win, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2281 gaim_conversation_get_index(conv)); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2282 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2283 pos = gaim_conv_window_add_conversation(dest_win, conv); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2284 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2285 if (pos != dest_page_num) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2286 gaim_conv_window_move_conversation(dest_win, pos, dest_page_num); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2287 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2288 gaim_conv_window_switch_conversation(dest_win, dest_page_num); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2289 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2290 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2291 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); |
4359 | 2292 } |
2293 | |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2294 gaim_signal_emit(gaim_gtk_conversations_get_handle(), "conversation-drag-ended", |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2295 win, dest_win); |
4359 | 2296 |
2297 return TRUE; | |
2298 } | |
2299 | |
8189 | 2300 /************************************************************************** |
2301 * A bunch of buddy icon functions | |
2302 **************************************************************************/ | |
2303 static GdkPixbuf * | |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2304 get_tab_icon(GaimConversation *conv, gboolean small_icon) |
7143 | 2305 { |
10116 | 2306 GaimAccount *account = NULL; |
2307 const char *name = NULL; | |
7143 | 2308 GdkPixbuf *status = NULL; |
2309 | |
10116 | 2310 g_return_val_if_fail(conv != NULL, NULL); |
2311 | |
2312 account = gaim_conversation_get_account(conv); | |
2313 name = gaim_conversation_get_name(conv); | |
2314 | |
2315 g_return_val_if_fail(account != NULL, NULL); | |
2316 g_return_val_if_fail(name != NULL, NULL); | |
2317 | |
7143 | 2318 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { |
2319 GaimBuddy *b = gaim_find_buddy(account, name); | |
2320 if (b != NULL) { | |
2321 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)b, | |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2322 (small_icon ? GAIM_STATUS_ICON_SMALL : GAIM_STATUS_ICON_LARGE)); |
7143 | 2323 } |
2324 } | |
2325 | |
2326 if (!status) { | |
2327 GdkPixbuf *pixbuf; | |
2328 pixbuf = create_prpl_icon(account); | |
2329 | |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2330 if (small_icon && pixbuf != NULL) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2331 { |
7143 | 2332 status = gdk_pixbuf_scale_simple(pixbuf, 15, 15, |
2333 GDK_INTERP_BILINEAR); | |
2334 g_object_unref(pixbuf); | |
2335 } | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2336 else |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2337 status = pixbuf; |
7143 | 2338 } |
2339 return status; | |
2340 } | |
2341 | |
8189 | 2342 static void |
2343 update_tab_icon(GaimConversation *conv) | |
2344 { | |
2345 GaimGtkConversation *gtkconv; | |
2346 GaimConvWindow *win = gaim_conversation_get_window(conv); | |
2347 GaimAccount *account; | |
2348 const char *name; | |
2349 GdkPixbuf *status = NULL; | |
2350 | |
10116 | 2351 g_return_if_fail(conv != NULL); |
2352 | |
8189 | 2353 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2354 name = gaim_conversation_get_name(conv); | |
2355 account = gaim_conversation_get_account(conv); | |
2356 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2357 status = get_tab_icon(conv, TRUE); |
8189 | 2358 |
10116 | 2359 g_return_if_fail(status != NULL); |
2360 | |
8189 | 2361 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon), status); |
2362 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->menu_icon), status); | |
2363 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2364 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2365 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2366 |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2367 if (gaim_conv_window_get_active_conversation(win) == conv && |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2368 gtkconv->u.im->anim == NULL) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2369 { |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2370 status = get_tab_icon(conv, FALSE); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2371 |
8189 | 2372 gtk_window_set_icon(GTK_WINDOW(GAIM_GTK_WINDOW(win)->window), status); |
2373 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2374 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2375 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2376 } |
8189 | 2377 } |
2378 | |
9318 | 2379 static void |
2380 get_icon_scale_size(GdkPixbufAnimation *icon, GaimBuddyIconSpec *spec, int *width, int *height) | |
2381 { | |
2382 *width = gdk_pixbuf_animation_get_width(icon); | |
2383 *height = gdk_pixbuf_animation_get_height(icon); | |
2384 | |
2385 /* this should eventually get smarter about preserving the aspect | |
2386 * ratio when scaling, but gimmie a break, I just woke up */ | |
2387 if(spec && spec->scale_rules & GAIM_ICON_SCALE_DISPLAY) { | |
2388 if(*width < spec->min_width) | |
2389 *width = spec->min_width; | |
2390 else if(*width > spec->max_width) | |
2391 *width = spec->max_width; | |
2392 | |
2393 if(*height < spec->min_height) | |
2394 *height = spec->min_height; | |
9319 | 2395 else if(*height > spec->max_height) |
9318 | 2396 *height = spec->max_height; |
2397 } | |
2398 | |
2399 /* and now for some arbitrary sanity checks */ | |
2400 if(*width > 100) | |
2401 *width = 100; | |
2402 if(*height > 100) | |
2403 *height = 100; | |
2404 } | |
2405 | |
8189 | 2406 static gboolean |
2407 redraw_icon(gpointer data) | |
2408 { | |
2409 GaimConversation *conv = (GaimConversation *)data; | |
2410 GaimGtkConversation *gtkconv; | |
9318 | 2411 GaimAccount *account; |
2412 GaimPluginProtocolInfo *prpl_info = NULL; | |
8189 | 2413 |
2414 GdkPixbuf *buf; | |
2415 GdkPixbuf *scale; | |
2416 GdkPixmap *pm; | |
2417 GdkBitmap *bm; | |
2418 gint delay; | |
9318 | 2419 int scale_width, scale_height; |
8189 | 2420 |
2421 if (!g_list_find(gaim_get_ims(), conv)) { | |
2422 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", | |
2423 "Conversation not found in redraw_icon. I think this " | |
2424 "is a bug.\n"); | |
2425 return FALSE; | |
2426 } | |
2427 | |
2428 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
9318 | 2429 account = gaim_conversation_get_account(conv); |
2430 if(account && account->gc) | |
2431 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
8189 | 2432 |
2433 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); | |
2434 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
2435 | |
9318 | 2436 get_icon_scale_size(gtkconv->u.im->anim, prpl_info ? &prpl_info->icon_spec : |
2437 NULL, &scale_width, &scale_height); | |
2438 | |
2439 /* this code is ugly, and scares me */ | |
8189 | 2440 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 2441 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
8189 | 2442 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 2443 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
8189 | 2444 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
2445 GDK_INTERP_NEAREST); | |
2446 | |
2447 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
2448 g_object_unref(G_OBJECT(scale)); | |
2449 gtk_image_set_from_pixmap(GTK_IMAGE(gtkconv->u.im->icon), pm, bm); | |
2450 g_object_unref(G_OBJECT(pm)); | |
2451 gtk_widget_queue_draw(gtkconv->u.im->icon); | |
2452 | |
2453 if (bm) | |
2454 g_object_unref(G_OBJECT(bm)); | |
2455 | |
9131 | 2456 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
2457 if (delay <= 0) | |
2458 delay = 100; | |
2459 | |
2460 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, conv); | |
8189 | 2461 |
2462 return FALSE; | |
2463 } | |
2464 | |
2465 static void | |
2466 start_anim(GtkObject *obj, GaimConversation *conv) | |
2467 { | |
2468 GaimGtkConversation *gtkconv; | |
2469 int delay; | |
2470 | |
2471 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
2472 return; | |
2473 | |
2474 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2475 | |
8228 | 2476 if (gtkconv->u.im->anim == NULL) |
2477 return; | |
2478 | |
8202 | 2479 if (gtkconv->u.im->icon_timer != 0) |
2480 return; | |
2481 | |
8189 | 2482 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) |
2483 return; | |
2484 | |
2485 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter) / 10; | |
2486 | |
8758 | 2487 gtkconv->u.im->icon_timer = g_timeout_add(delay * 10, redraw_icon, conv); |
8189 | 2488 } |
2489 | |
2490 static void | |
2491 stop_anim(GtkObject *obj, GaimConversation *conv) | |
2492 { | |
2493 GaimGtkConversation *gtkconv; | |
2494 | |
2495 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
2496 return; | |
2497 | |
2498 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2499 | |
2500 if (gtkconv->u.im->icon_timer != 0) | |
2501 g_source_remove(gtkconv->u.im->icon_timer); | |
2502 | |
2503 gtkconv->u.im->icon_timer = 0; | |
2504 } | |
2505 | |
2506 static void | |
2507 toggle_icon_animate_cb(GtkWidget *w, GaimConversation *conv) | |
2508 { | |
2509 GaimGtkConversation *gtkconv; | |
2510 | |
2511 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
2512 return; | |
2513 | |
2514 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2515 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2516 gtkconv->u.im->animate = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2517 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)); |
8189 | 2518 |
2519 if (gtkconv->u.im->animate) | |
2520 start_anim(NULL, conv); | |
2521 else | |
2522 stop_anim(NULL, conv); | |
2523 } | |
9845 | 2524 |
8189 | 2525 static void |
2526 remove_icon(GaimGtkConversation *gtkconv) | |
2527 { | |
2528 g_return_if_fail(gtkconv != NULL); | |
2529 | |
9887 | 2530 if (gtkconv->u.im->icon_container != NULL) |
2531 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
8189 | 2532 |
2533 if (gtkconv->u.im->anim != NULL) | |
2534 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
2535 | |
2536 if (gtkconv->u.im->icon_timer != 0) | |
2537 g_source_remove(gtkconv->u.im->icon_timer); | |
2538 | |
2539 if (gtkconv->u.im->iter != NULL) | |
2540 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
2541 | |
2542 gtkconv->u.im->icon_timer = 0; | |
2543 gtkconv->u.im->icon = NULL; | |
2544 gtkconv->u.im->anim = NULL; | |
2545 gtkconv->u.im->iter = NULL; | |
9687 | 2546 gtkconv->u.im->show_icon = FALSE; |
8189 | 2547 } |
2548 | |
9497 | 2549 static void |
9504 | 2550 saveicon_writefile_cb(void *user_data, const char *filename) |
9497 | 2551 { |
9504 | 2552 GaimConversation *conv = (GaimConversation *)user_data; |
9497 | 2553 FILE *fp; |
2554 GaimBuddyIcon *icon; | |
2555 const void *data; | |
2556 size_t len; | |
2557 | |
2558 if ((fp = fopen(filename, "wb")) == NULL) { | |
9504 | 2559 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9497 | 2560 return; |
2561 } | |
2562 | |
2563 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); | |
2564 data = gaim_buddy_icon_get_data(icon, &len); | |
2565 | |
2566 if ((len <= 0) || (data == NULL)) { | |
9504 | 2567 gaim_notify_error(conv, NULL, _("Unable to save icon file to disk."), NULL); |
9497 | 2568 return; |
2569 } | |
2570 | |
2571 fwrite(data, 1, len, fp); | |
2572 fclose(fp); | |
2573 } | |
2574 | |
2575 static void | |
2576 icon_menu_save_cb(GtkWidget *widget, GaimConversation *conv) | |
2577 { | |
2578 gchar *buf; | |
2579 | |
2580 g_return_if_fail(conv != NULL); | |
9504 | 2581 |
9706 | 2582 /* |
2583 * XXX - The file extension needs to be set to something that doesn't suck... | |
2584 * Maybe do what gtkimhtml.c does when saving an image? | |
2585 */ | |
9497 | 2586 buf = g_strdup_printf("%s.icon", gaim_normalize(conv->account, conv->name)); |
9504 | 2587 |
2588 gaim_request_file(conv, _("Save Icon"), buf, TRUE, | |
2589 G_CALLBACK(saveicon_writefile_cb), NULL, conv); | |
9497 | 2590 |
2591 g_free(buf); | |
2592 } | |
2593 | |
8189 | 2594 static gboolean |
2595 icon_menu(GtkObject *obj, GdkEventButton *e, GaimConversation *conv) | |
2596 { | |
2597 GaimGtkConversation *gtkconv; | |
2598 static GtkWidget *menu = NULL; | |
2599 GtkWidget *button; | |
2600 | |
2601 if (e->button != 3 || e->type != GDK_BUTTON_PRESS) | |
2602 return FALSE; | |
2603 | |
2604 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2605 | |
2606 /* | |
2607 * If a menu already exists, destroy it before creating a new one, | |
2608 * thus freeing-up the memory it occupied. | |
2609 */ | |
2610 if (menu != NULL) | |
2611 gtk_widget_destroy(menu); | |
2612 | |
2613 menu = gtk_menu_new(); | |
2614 | |
2615 if (gtkconv->u.im->anim && | |
2616 !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) | |
2617 { | |
2618 gaim_new_check_item(menu, _("Animate"), | |
2619 G_CALLBACK(toggle_icon_animate_cb), conv, | |
2620 gtkconv->u.im->icon_timer); | |
2621 } | |
2622 | |
2623 button = gtk_menu_item_new_with_label(_("Hide Icon")); | |
2624 g_signal_connect_swapped(G_OBJECT(button), "activate", | |
2625 G_CALLBACK(remove_icon), gtkconv); | |
2626 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); | |
2627 gtk_widget_show(button); | |
2628 | |
2629 gaim_new_item_from_stock(menu, _("Save Icon As..."), GTK_STOCK_SAVE_AS, | |
9497 | 2630 G_CALLBACK(icon_menu_save_cb), conv, |
8189 | 2631 0, 0, NULL); |
2632 | |
2633 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time); | |
2634 | |
2635 return TRUE; | |
2636 } | |
2637 /************************************************************************** | |
2638 * End of the bunch of buddy icon functions | |
2639 **************************************************************************/ | |
2640 | |
7887 | 2641 /* |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2642 * Makes sure all the menu items and all the buttons are hidden/shown and |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8730
diff
changeset
|
2643 * sensitive/insensitive. This is called after changing tabs and when an |
7887 | 2644 * account signs on or off. |
2645 */ | |
4359 | 2646 static void |
7887 | 2647 gray_stuff_out(GaimConversation *conv) |
4359 | 2648 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2649 GaimConvWindow *win; |
7887 | 2650 GaimGtkWindow *gtkwin; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2651 GaimGtkConversation *gtkconv; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2652 GaimConnection *gc; |
7887 | 2653 GaimPluginProtocolInfo *prpl_info = NULL; |
7222 | 2654 GdkPixbuf *window_icon = NULL; |
8439 | 2655 GtkIMHtmlButtons buttons; |
9812 | 2656 GaimAccount *account; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
2657 |
7887 | 2658 win = gaim_conversation_get_window(conv); |
4359 | 2659 gtkwin = GAIM_GTK_WINDOW(win); |
2660 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
7887 | 2661 gc = gaim_conversation_get_gc(conv); |
9909 | 2662 account = gaim_conversation_get_account(conv); |
8439 | 2663 |
7879 | 2664 if (gc != NULL) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
2665 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
2666 |
7887 | 2667 if (gtkwin->menu.send_as != NULL) |
2668 g_timeout_add(0, (GSourceFunc)update_send_as_selection, win); | |
2669 | |
2670 /* | |
2671 * Handle hiding and showing stuff based on what type of conv this is. | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2672 * Stuff that Gaim IMs support in general should be shown for IM |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8730
diff
changeset
|
2673 * conversations. Stuff that Gaim chats support in general should be |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2674 * shown for chat conversations. It doesn't matter whether the PRPL |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2675 * supports it or not--that only affects if the button or menu item |
7929 | 2676 * is sensitive or not. |
7887 | 2677 */ |
4359 | 2678 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { |
7887 | 2679 /* Show stuff that applies to IMs, hide stuff that applies to chats */ |
2680 | |
2681 /* Deal with buttons */ | |
2682 gtk_widget_show(gtkconv->info); | |
2683 gtk_widget_show(gtkconv->send); | |
2684 gtk_widget_show(gtkconv->u.im->block); | |
9468 | 2685 gtk_widget_show(gtkconv->u.im->send_file); |
7887 | 2686 |
2687 /* Deal with menu items */ | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2688 gtk_widget_show(gtkwin->menu.view_log); |
9468 | 2689 gtk_widget_show(gtkwin->menu.send_file); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2690 gtk_widget_show(gtkwin->menu.add_pounce); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2691 gtk_widget_show(gtkwin->menu.get_info); |
7887 | 2692 gtk_widget_show(gtkwin->menu.warn); |
7859 | 2693 gtk_widget_hide(gtkwin->menu.invite); |
7887 | 2694 gtk_widget_show(gtkwin->menu.alias); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2695 gtk_widget_show(gtkwin->menu.block); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2696 |
9812 | 2697 if (gaim_find_buddy(account, gaim_conversation_get_name(conv)) == NULL) { |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2698 gtk_widget_show(gtkwin->menu.add); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2699 gtk_widget_hide(gtkwin->menu.remove); |
7929 | 2700 gtk_widget_show(gtkconv->add); |
2701 gtk_widget_hide(gtkconv->remove); | |
7859 | 2702 } else { |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2703 gtk_widget_show(gtkwin->menu.remove); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2704 gtk_widget_hide(gtkwin->menu.add); |
7929 | 2705 gtk_widget_hide(gtkconv->add); |
2706 gtk_widget_show(gtkconv->remove); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2707 } |
7887 | 2708 |
2709 gtk_widget_show(gtkwin->menu.insert_link); | |
9287 | 2710 gtk_widget_show(gtkwin->menu.insert_image); |
7887 | 2711 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { |
9470 | 2712 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ |
7887 | 2713 |
2714 /* Deal with buttons */ | |
7952 | 2715 gtk_widget_show(gtkconv->info); |
7887 | 2716 gtk_widget_show(gtkconv->send); |
2717 gtk_widget_show(gtkconv->u.chat->invite); | |
2718 | |
2719 /* Deal with menu items */ | |
9917 | 2720 gtk_widget_show(gtkwin->menu.view_log); |
9468 | 2721 gtk_widget_hide(gtkwin->menu.send_file); |
7859 | 2722 gtk_widget_hide(gtkwin->menu.add_pounce); |
2723 gtk_widget_hide(gtkwin->menu.get_info); | |
7887 | 2724 gtk_widget_hide(gtkwin->menu.warn); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2725 gtk_widget_show(gtkwin->menu.invite); |
7887 | 2726 gtk_widget_show(gtkwin->menu.alias); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2727 gtk_widget_hide(gtkwin->menu.block); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2728 |
9812 | 2729 if (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) == NULL) { |
2730 /* If the chat is NOT in the buddy list */ | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2731 gtk_widget_show(gtkwin->menu.add); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2732 gtk_widget_hide(gtkwin->menu.remove); |
7929 | 2733 gtk_widget_show(gtkconv->add); |
2734 gtk_widget_hide(gtkconv->remove); | |
7859 | 2735 } else { |
9812 | 2736 /* If the chat IS in the buddy list */ |
2737 gtk_widget_hide(gtkwin->menu.add); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2738 gtk_widget_show(gtkwin->menu.remove); |
7929 | 2739 gtk_widget_hide(gtkconv->add); |
2740 gtk_widget_show(gtkconv->remove); | |
7887 | 2741 } |
2742 | |
2743 gtk_widget_show(gtkwin->menu.insert_link); | |
2744 gtk_widget_hide(gtkwin->menu.insert_image); | |
2745 } | |
2746 | |
2747 /* | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2748 * Handle graying stuff out based on whether an account is connected |
7887 | 2749 * and what features that account supports. |
2750 */ | |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
2751 if ((gc != NULL) && |
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
2752 ( (gaim_conversation_get_type(conv) != GAIM_CONV_CHAT) || |
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
2753 !gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)) )) { |
7887 | 2754 /* Account is online */ |
2755 | |
2756 /* Deal with buttons */ | |
2757 gtk_widget_set_sensitive(gtkconv->info, (prpl_info->get_info != NULL)); | |
7929 | 2758 |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2759 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2760 { |
9812 | 2761 gtk_widget_set_sensitive(gtkconv->add, (prpl_info->add_buddy != NULL)); |
2762 gtk_widget_set_sensitive(gtkconv->remove, (prpl_info->remove_buddy != NULL)); | |
2763 gtk_widget_set_sensitive(gtkconv->send, (prpl_info->send_im != NULL)); | |
2764 gtk_widget_set_sensitive(gtkconv->u.im->block, (prpl_info->add_deny != NULL)); | |
9468 | 2765 gtk_widget_set_sensitive(gtkconv->u.im->send_file, |
9812 | 2766 (prpl_info->send_file && (!prpl_info->can_receive_file || |
2767 prpl_info->can_receive_file(gc, gaim_conversation_get_name(conv))))); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2768 } |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2769 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2770 { |
9812 | 2771 /* Only allow adding/removing if this is a chat and not a conference */ |
2772 gtk_widget_set_sensitive(gtkconv->add, (prpl_info->join_chat != NULL)); | |
2773 gtk_widget_set_sensitive(gtkconv->remove, (prpl_info->join_chat != NULL)); | |
2774 gtk_widget_set_sensitive(gtkconv->send, (prpl_info->chat_send != NULL)); | |
2775 gtk_widget_set_sensitive(gtkconv->u.chat->invite, (prpl_info->chat_invite != NULL)); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2776 } |
7887 | 2777 |
2778 /* Deal with the toolbar */ | |
8420 | 2779 if (gc->flags & GAIM_CONNECTION_HTML) { |
8677 | 2780 buttons = GTK_IMHTML_ALL; /* Everything on */ |
8420 | 2781 if (!(prpl_info->options & OPT_PROTO_IM_IMAGE)) |
8422 | 2782 buttons &= ~GTK_IMHTML_IMAGE; |
8420 | 2783 if (gc->flags & GAIM_CONNECTION_NO_BGCOLOR) |
8422 | 2784 buttons &= ~GTK_IMHTML_BACKCOLOR; |
8691
0eb5161ef333
[gaim-migrate @ 9444]
Christian Hammond <chipx86@chipx86.com>
parents:
8690
diff
changeset
|
2785 if (gc->flags & GAIM_CONNECTION_NO_FONTSIZE) { |
0eb5161ef333
[gaim-migrate @ 9444]
Christian Hammond <chipx86@chipx86.com>
parents:
8690
diff
changeset
|
2786 buttons &= ~GTK_IMHTML_GROW; |
0eb5161ef333
[gaim-migrate @ 9444]
Christian Hammond <chipx86@chipx86.com>
parents:
8690
diff
changeset
|
2787 buttons &= ~GTK_IMHTML_SHRINK; |
0eb5161ef333
[gaim-migrate @ 9444]
Christian Hammond <chipx86@chipx86.com>
parents:
8690
diff
changeset
|
2788 } |
9041 | 2789 if (gc->flags & GAIM_CONNECTION_NO_URLDESC) |
2790 buttons &= ~GTK_IMHTML_LINKDESC; | |
8420 | 2791 } else { |
8422 | 2792 buttons = GTK_IMHTML_SMILEY; |
8420 | 2793 } |
2794 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons); | |
9812 | 2795 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), gaim_account_get_protocol_id(account)); |
8422 | 2796 |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
2797 /* Deal with menu items */ |
7887 | 2798 gtk_widget_set_sensitive(gtkwin->menu.view_log, TRUE); |
2799 gtk_widget_set_sensitive(gtkwin->menu.add_pounce, TRUE); | |
2800 gtk_widget_set_sensitive(gtkwin->menu.get_info, (prpl_info->get_info != NULL)); | |
2801 gtk_widget_set_sensitive(gtkwin->menu.warn, (prpl_info->warn != NULL)); | |
9812 | 2802 gtk_widget_set_sensitive(gtkwin->menu.invite, (prpl_info->chat_invite != NULL)); |
2803 gtk_widget_set_sensitive(gtkwin->menu.block, (prpl_info->add_deny != NULL)); | |
2804 gtk_widget_set_sensitive(gtkwin->menu.insert_link, (gc->flags & GAIM_CONNECTION_HTML)); | |
2805 gtk_widget_set_sensitive(gtkwin->menu.insert_image, (prpl_info->options & OPT_PROTO_IM_IMAGE)); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
2806 |
7887 | 2807 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { |
9812 | 2808 gtk_widget_set_sensitive(gtkwin->menu.add, (prpl_info->add_buddy != NULL)); |
2809 gtk_widget_set_sensitive(gtkwin->menu.remove, (prpl_info->remove_buddy != NULL)); | |
9468 | 2810 gtk_widget_set_sensitive(gtkwin->menu.send_file, |
9812 | 2811 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || |
2812 prpl_info->can_receive_file(gc, gaim_conversation_get_name(conv))))); | |
2813 gtk_widget_set_sensitive(gtkwin->menu.alias, | |
2814 (gaim_find_buddy(account, gaim_conversation_get_name(conv)) != NULL)); | |
7887 | 2815 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { |
9812 | 2816 gtk_widget_set_sensitive(gtkwin->menu.add, (prpl_info->join_chat != NULL)); |
2817 gtk_widget_set_sensitive(gtkwin->menu.remove, (prpl_info->join_chat != NULL)); | |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
2818 gtk_widget_set_sensitive(gtkwin->menu.alias, |
9812 | 2819 (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) != NULL)); |
7887 | 2820 } |
2821 } else { | |
2822 /* Account is offline */ | |
9812 | 2823 /* Or it's a chat that we've left. */ |
7887 | 2824 |
2825 /* Deal with buttons */ | |
7929 | 2826 gtk_widget_set_sensitive(gtkconv->add, FALSE); |
2827 gtk_widget_set_sensitive(gtkconv->remove, FALSE); | |
7887 | 2828 gtk_widget_set_sensitive(gtkconv->info, FALSE); |
2829 gtk_widget_set_sensitive(gtkconv->send, FALSE); | |
2830 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { | |
2831 gtk_widget_set_sensitive(gtkconv->u.im->block, FALSE); | |
9468 | 2832 gtk_widget_set_sensitive(gtkconv->u.im->send_file, FALSE); |
7887 | 2833 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { |
2834 gtk_widget_set_sensitive(gtkconv->u.chat->invite, FALSE); | |
2835 } | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2836 |
7887 | 2837 /* Then deal with menu items */ |
2838 gtk_widget_set_sensitive(gtkwin->menu.view_log, TRUE); | |
9468 | 2839 gtk_widget_set_sensitive(gtkwin->menu.send_file, FALSE); |
7887 | 2840 gtk_widget_set_sensitive(gtkwin->menu.add_pounce, TRUE); |
2841 gtk_widget_set_sensitive(gtkwin->menu.get_info, FALSE); | |
2842 gtk_widget_set_sensitive(gtkwin->menu.warn, FALSE); | |
2843 gtk_widget_set_sensitive(gtkwin->menu.invite, FALSE); | |
2844 gtk_widget_set_sensitive(gtkwin->menu.alias, FALSE); | |
2845 gtk_widget_set_sensitive(gtkwin->menu.block, FALSE); | |
2846 gtk_widget_set_sensitive(gtkwin->menu.add, FALSE); | |
2847 gtk_widget_set_sensitive(gtkwin->menu.remove, FALSE); | |
7929 | 2848 gtk_widget_set_sensitive(gtkwin->menu.insert_link, TRUE); |
7887 | 2849 gtk_widget_set_sensitive(gtkwin->menu.insert_image, FALSE); |
2850 } | |
2851 | |
2852 /* | |
2853 * Update the window's icon | |
2854 */ | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2855 if ((gaim_conversation_get_type(conv) == GAIM_CONV_IM) && |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2856 (gtkconv->u.im->anim)) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2857 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2858 window_icon = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2859 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); |
7887 | 2860 g_object_ref(window_icon); |
2861 } else { | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2862 window_icon = get_tab_icon(conv, FALSE); |
4359 | 2863 } |
7887 | 2864 gtk_window_set_icon(GTK_WINDOW(gtkwin->window), window_icon); |
2865 g_object_unref(G_OBJECT(window_icon)); | |
2866 } | |
2867 | |
2868 static void | |
8189 | 2869 before_switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, |
2870 gpointer user_data) | |
2871 { | |
2872 GaimConvWindow *win; | |
2873 GaimConversation *conv; | |
2874 GaimGtkConversation *gtkconv; | |
2875 | |
2876 win = (GaimConvWindow *)user_data; | |
2877 conv = gaim_conv_window_get_active_conversation(win); | |
2878 | |
2879 g_return_if_fail(conv != NULL); | |
2880 | |
8192 | 2881 if (gaim_conversation_get_type(conv) != GAIM_CONV_IM) |
2882 return; | |
2883 | |
8189 | 2884 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2885 | |
2886 stop_anim(NULL, conv); | |
2887 } | |
2888 | |
2889 static void | |
7887 | 2890 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, |
2891 gpointer user_data) | |
2892 { | |
2893 GaimConvWindow *win; | |
2894 GaimConversation *conv; | |
2895 GaimGtkConversation *gtkconv; | |
2896 GaimGtkWindow *gtkwin; | |
2897 | |
2898 win = (GaimConvWindow *)user_data; | |
2899 conv = gaim_conv_window_get_conversation_at(win, page_num); | |
2900 | |
2901 g_return_if_fail(conv != NULL); | |
2902 | |
2903 gtkwin = GAIM_GTK_WINDOW(win); | |
2904 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2905 | |
2906 gaim_conversation_set_unseen(conv, GAIM_UNSEEN_NONE); | |
2907 | |
2908 /* Update the menubar */ | |
2909 gray_stuff_out(conv); | |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
2910 |
4736 | 2911 update_typing_icon(conv); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
2912 |
4359 | 2913 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.logging), |
7143 | 2914 gaim_conversation_is_logging(conv)); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
2915 |
4359 | 2916 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.sounds), |
7143 | 2917 gtkconv->make_sound); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
2918 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
2919 gtk_check_menu_item_set_active( |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
2920 GTK_CHECK_MENU_ITEM(gtkwin->menu.show_formatting_toolbar), |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
2921 gtkconv->show_formatting_toolbar); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
2922 |
9188 | 2923 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.show_timestamps), |
2924 gtkconv->show_timestamps); | |
2925 | |
8189 | 2926 /* |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2927 * We pause icons when they are not visible. If this icon should |
9297 | 2928 * be animated then start it back up again. |
8189 | 2929 */ |
8192 | 2930 if ((gaim_conversation_get_type(conv) == GAIM_CONV_IM) && |
2931 (gtkconv->u.im->animate)) | |
8189 | 2932 start_anim(NULL, conv); |
2933 | |
4965 | 2934 gtk_window_set_title(GTK_WINDOW(gtkwin->window), |
7143 | 2935 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); |
4359 | 2936 } |
2937 | |
2938 /************************************************************************** | |
2939 * Utility functions | |
2940 **************************************************************************/ | |
2941 | |
2942 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2943 got_typing_keypress(GaimConversation *conv, gboolean first) |
4359 | 2944 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2945 GaimConvIm *im; |
4685 | 2946 |
4359 | 2947 /* |
2948 * We know we got something, so we at least have to make sure we don't | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2949 * send GAIM_TYPED any time soon. |
4359 | 2950 */ |
2951 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2952 im = GAIM_CONV_IM(conv); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2953 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2954 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2955 gaim_conv_im_stop_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2956 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2957 gaim_conv_im_start_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2958 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2959 if (first || (gaim_conv_im_get_type_again(im) != 0 && |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2960 time(NULL) > gaim_conv_im_get_type_again(im))) { |
4359 | 2961 |
2962 int timeout = serv_send_typing(gaim_conversation_get_gc(conv), | |
2963 (char *)gaim_conversation_get_name(conv), | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2964 GAIM_TYPING); |
4359 | 2965 |
2966 if (timeout) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2967 gaim_conv_im_set_type_again(im, time(NULL) + timeout); |
4359 | 2968 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2969 gaim_conv_im_set_type_again(im, 0); |
4359 | 2970 } |
2971 } | |
2972 | |
4736 | 2973 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2974 update_typing_icon(GaimConversation *conv) |
4736 | 2975 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2976 GaimGtkWindow *gtkwin; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2977 GaimConvIm *im = NULL; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2978 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4736 | 2979 |
2980 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv)); | |
2981 | |
2982 if(gaim_conversation_get_type(conv) == GAIM_CONV_IM) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2983 im = GAIM_CONV_IM(conv); |
4736 | 2984 |
2985 if(gtkwin->menu.typing_icon) { | |
2986 gtk_widget_destroy(gtkwin->menu.typing_icon); | |
2987 gtkwin->menu.typing_icon = NULL; | |
2988 } | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2989 if(im && gaim_conv_im_get_typing_state(im) == GAIM_TYPING) { |
4736 | 2990 gtkwin->menu.typing_icon = gtk_image_menu_item_new(); |
2991 gtk_image_menu_item_set_image( | |
2992 GTK_IMAGE_MENU_ITEM(gtkwin->menu.typing_icon), | |
2993 gtk_image_new_from_stock(GAIM_STOCK_TYPING, | |
2994 GTK_ICON_SIZE_MENU)); | |
4757 | 2995 gtk_tooltips_set_tip(gtkconv->tooltips, gtkwin->menu.typing_icon, |
4736 | 2996 _("User is typing..."), NULL); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2997 } else if(im && gaim_conv_im_get_typing_state(im) == GAIM_TYPED) { |
4736 | 2998 gtkwin->menu.typing_icon = gtk_image_menu_item_new(); |
2999 gtk_image_menu_item_set_image( | |
3000 GTK_IMAGE_MENU_ITEM(gtkwin->menu.typing_icon), | |
3001 gtk_image_new_from_stock(GAIM_STOCK_TYPED, | |
3002 GTK_ICON_SIZE_MENU)); | |
4757 | 3003 gtk_tooltips_set_tip(gtkconv->tooltips, gtkwin->menu.typing_icon, |
4736 | 3004 _("User has typed something and paused"), NULL); |
3005 } | |
3006 | |
3007 if(gtkwin->menu.typing_icon) { | |
3008 gtk_menu_item_set_right_justified( | |
3009 GTK_MENU_ITEM(gtkwin->menu.typing_icon), TRUE); | |
3010 gtk_widget_show_all(gtkwin->menu.typing_icon); | |
3011 gtk_menu_shell_append(GTK_MENU_SHELL(gtkwin->menu.menubar), | |
3012 gtkwin->menu.typing_icon); | |
3013 } | |
3014 } | |
3015 | |
4685 | 3016 static gboolean |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3017 update_send_as_selection(GaimConvWindow *win) |
4359 | 3018 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3019 GaimAccount *account; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3020 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3021 GaimGtkWindow *gtkwin; |
4359 | 3022 GtkWidget *menu; |
3023 GList *child; | |
3024 | |
7090
04f9f7440bc3
[gaim-migrate @ 7655]
Christian Hammond <chipx86@chipx86.com>
parents:
7089
diff
changeset
|
3025 if (g_list_find(gaim_get_windows(), win) == NULL) |
04f9f7440bc3
[gaim-migrate @ 7655]
Christian Hammond <chipx86@chipx86.com>
parents:
7089
diff
changeset
|
3026 return FALSE; |
4849 | 3027 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3028 conv = gaim_conv_window_get_active_conversation(win); |
4359 | 3029 |
5860
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
3030 if (conv == NULL) |
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
3031 return FALSE; |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
3032 |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
3033 account = gaim_conversation_get_account(conv); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
3034 gtkwin = GAIM_GTK_WINDOW(win); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
3035 |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
3036 if (gtkwin->menu.send_as == NULL) |
4685 | 3037 return FALSE; |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
3038 |
4359 | 3039 gtk_widget_show(gtkwin->menu.send_as); |
3040 | |
3041 menu = gtk_menu_item_get_submenu( | |
3042 GTK_MENU_ITEM(gtkwin->menu.send_as)); | |
3043 | |
3044 for (child = gtk_container_get_children(GTK_CONTAINER(menu)); | |
3045 child != NULL; | |
3046 child = child->next) { | |
3047 | |
3048 GtkWidget *item = child->data; | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3049 GaimAccount *item_account = g_object_get_data(G_OBJECT(item), |
4673 | 3050 "gaim_account"); |
3051 | |
3052 if (account == item_account) { | |
4359 | 3053 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); |
3054 break; | |
3055 } | |
3056 } | |
6030
54c37db13279
[gaim-migrate @ 6480]
Christian Hammond <chipx86@chipx86.com>
parents:
6016
diff
changeset
|
3057 |
4685 | 3058 return FALSE; |
4359 | 3059 } |
3060 | |
3061 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3062 generate_send_as_items(GaimConvWindow *win, GaimConversation *deleted_conv) |
4359 | 3063 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3064 GaimGtkWindow *gtkwin; |
4359 | 3065 GtkWidget *menu; |
3066 GtkWidget *menuitem; | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3067 GList *gcs; |
4359 | 3068 GList *convs; |
3069 GSList *group = NULL; | |
3070 gboolean first_offline = TRUE; | |
3071 gboolean found_online = FALSE; | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3072 GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
4359 | 3073 |
3074 gtkwin = GAIM_GTK_WINDOW(win); | |
3075 | |
3076 if (gtkwin->menu.send_as != NULL) | |
3077 gtk_widget_destroy(gtkwin->menu.send_as); | |
3078 | |
3079 /* See if we have > 1 connection active. */ | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3080 if (g_list_length(gaim_connections_get_all()) < 2) { |
4359 | 3081 /* Now make sure we don't have any Offline entries. */ |
3082 gboolean found_offline = FALSE; | |
3083 | |
3084 for (convs = gaim_get_conversations(); | |
3085 convs != NULL; | |
3086 convs = convs->next) { | |
3087 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3088 GaimConversation *conv; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3089 GaimAccount *account; |
4491 | 3090 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3091 conv = (GaimConversation *)convs->data; |
4491 | 3092 account = gaim_conversation_get_account(conv); |
3093 | |
6495
8ce66049ce68
[gaim-migrate @ 7010]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
3094 if (account != NULL && account->gc == NULL) { |
4359 | 3095 found_offline = TRUE; |
3096 break; | |
3097 } | |
3098 } | |
3099 | |
3100 if (!found_offline) { | |
3101 gtkwin->menu.send_as = NULL; | |
3102 return; | |
3103 } | |
3104 } | |
3105 | |
3106 /* Build the Send As menu */ | |
3107 gtkwin->menu.send_as = gtk_menu_item_new_with_mnemonic(_("_Send As")); | |
3108 gtk_widget_show(gtkwin->menu.send_as); | |
3109 | |
3110 menu = gtk_menu_new(); | |
7857
43f63ff8a6d8
[gaim-migrate @ 8511]
Christian Hammond <chipx86@chipx86.com>
parents:
7855
diff
changeset
|
3111 gtk_menu_shell_insert(GTK_MENU_SHELL(gtkwin->menu.menubar), |
43f63ff8a6d8
[gaim-migrate @ 8511]
Christian Hammond <chipx86@chipx86.com>
parents:
7855
diff
changeset
|
3112 gtkwin->menu.send_as, 2); |
4359 | 3113 gtk_menu_item_set_submenu(GTK_MENU_ITEM(gtkwin->menu.send_as), menu); |
3114 | |
3115 gtk_widget_show(menu); | |
3116 | |
3117 /* Fill it with entries. */ | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3118 for (gcs = gaim_connections_get_all(); gcs != NULL; gcs = gcs->next) { |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3119 |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3120 GaimConnection *gc; |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3121 GaimAccount *account; |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3122 GtkWidget *box; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3123 GtkWidget *label; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3124 GtkWidget *image; |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3125 GdkPixbuf *pixbuf, *scale; |
4359 | 3126 |
3127 found_online = TRUE; | |
3128 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3129 gc = (GaimConnection *)gcs->data; |
4359 | 3130 |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3131 /* Create a pixmap for the protocol icon. */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3132 pixbuf = create_prpl_icon(gc->account); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3133 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3134 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3135 /* Now convert it to GtkImage */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3136 if (pixbuf == NULL) |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3137 image = gtk_image_new(); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3138 else |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3139 image = gtk_image_new_from_pixbuf(scale); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3140 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3141 gtk_size_group_add_widget(sg, image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3142 |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3143 g_object_unref(G_OBJECT(scale)); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3144 g_object_unref(G_OBJECT(pixbuf)); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3145 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3146 account = gaim_connection_get_account(gc); |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3147 |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3148 /* Make our menu item */ |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3149 menuitem = gtk_radio_menu_item_new_with_label(group, |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3150 gaim_account_get_username(account)); |
4793 | 3151 group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
4359 | 3152 |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3153 /* Do some evil, see some evil, speak some evil. */ |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3154 box = gtk_hbox_new(FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3155 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3156 label = gtk_bin_get_child(GTK_BIN(menuitem)); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3157 g_object_ref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3158 gtk_container_remove(GTK_CONTAINER(menuitem), label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3159 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3160 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3161 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3162 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3163 g_object_unref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3164 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3165 gtk_container_add(GTK_CONTAINER(menuitem), box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3166 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3167 gtk_widget_show(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3168 gtk_widget_show(image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3169 gtk_widget_show(box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3170 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3171 /* Set our data and callbacks. */ |
4359 | 3172 g_object_set_data(G_OBJECT(menuitem), "user_data", win); |
4673 | 3173 g_object_set_data(G_OBJECT(menuitem), "gaim_account", gc->account); |
4359 | 3174 |
4786 | 3175 g_signal_connect(G_OBJECT(menuitem), "activate", |
4673 | 3176 G_CALLBACK(menu_conv_sel_send_cb), NULL); |
4359 | 3177 |
3178 gtk_widget_show(menuitem); | |
3179 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
3180 } | |
3181 | |
3182 /* | |
3183 * Fill it with any accounts that still has an open (yet disabled) window | |
3184 * (signed off accounts with a window open). | |
3185 */ | |
3186 for (convs = gaim_get_conversations(); | |
3187 convs != NULL; | |
3188 convs = convs->next) { | |
3189 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3190 GaimConversation *conv; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3191 GaimAccount *account; |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3192 GtkWidget *box; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3193 GtkWidget *label; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3194 GtkWidget *image; |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3195 GdkPixbuf *pixbuf, *scale; |
4359 | 3196 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3197 conv = (GaimConversation *)convs->data; |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
3198 |
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
3199 if (conv == deleted_conv) |
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
3200 continue; |
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
3201 |
4491 | 3202 account = gaim_conversation_get_account(conv); |
3203 | |
6495
8ce66049ce68
[gaim-migrate @ 7010]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
3204 if (account != NULL && account->gc == NULL) { |
4359 | 3205 if (first_offline && found_online) { |
3206 menuitem = gtk_separator_menu_item_new(); | |
3207 gtk_widget_show(menuitem); | |
3208 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
3209 | |
3210 first_offline = FALSE; | |
3211 } | |
3212 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3213 /* Create a pixmap for the protocol icon. */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3214 pixbuf = create_prpl_icon(account); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3215 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3216 GDK_INTERP_BILINEAR); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3217 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3218 /* Now convert it to GtkImage */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3219 if (pixbuf == NULL) |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3220 image = gtk_image_new(); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3221 else |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3222 image = gtk_image_new_from_pixbuf(scale); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3223 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3224 gtk_size_group_add_widget(sg, image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3225 |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3226 if (scale != NULL) g_object_unref(scale); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3227 if (pixbuf != NULL) g_object_unref(pixbuf); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3228 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3229 /* Make our menu item */ |
4359 | 3230 menuitem = gtk_radio_menu_item_new_with_label(group, |
4491 | 3231 account->username); |
4793 | 3232 group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
4359 | 3233 |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3234 /* Do some evil, see some evil, speak some evil. */ |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3235 box = gtk_hbox_new(FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3236 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3237 label = gtk_bin_get_child(GTK_BIN(menuitem)); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3238 g_object_ref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3239 gtk_container_remove(GTK_CONTAINER(menuitem), label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3240 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3241 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3242 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3243 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3244 g_object_unref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3245 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3246 gtk_container_add(GTK_CONTAINER(menuitem), box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3247 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3248 gtk_widget_show(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3249 gtk_widget_show(image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3250 gtk_widget_show(box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3251 |
4359 | 3252 gtk_widget_set_sensitive(menuitem, FALSE); |
4786 | 3253 g_object_set_data(G_OBJECT(menuitem), "user_data", win); |
4674 | 3254 g_object_set_data(G_OBJECT(menuitem), "gaim_account", account); |
4359 | 3255 |
4786 | 3256 g_signal_connect(G_OBJECT(menuitem), "activate", |
5902
6889b89cab90
[gaim-migrate @ 6334]
Christian Hammond <chipx86@chipx86.com>
parents:
5901
diff
changeset
|
3257 G_CALLBACK(menu_conv_sel_send_cb), NULL); |
4786 | 3258 |
4359 | 3259 gtk_widget_show(menuitem); |
3260 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
3261 } | |
3262 } | |
3263 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3264 g_object_unref(sg); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3265 |
4359 | 3266 gtk_widget_show(gtkwin->menu.send_as); |
3267 update_send_as_selection(win); | |
3268 } | |
3269 | |
3270 static GList * | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3271 generate_invite_user_names(GaimConnection *gc) |
4359 | 3272 { |
6695 | 3273 GaimBlistNode *gnode,*cnode,*bnode; |
4359 | 3274 static GList *tmp = NULL; |
3275 | |
3276 if (tmp) | |
3277 g_list_free(tmp); | |
3278 | |
3279 tmp = g_list_append(NULL, ""); | |
3280 | |
3281 if (gc != NULL) { | |
4785 | 3282 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
3283 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
3284 continue; | |
6695 | 3285 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
3286 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 3287 continue; |
6695 | 3288 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
3289 GaimBuddy *buddy; | |
3290 | |
3291 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
3292 continue; | |
3293 | |
3294 buddy = (GaimBuddy *)bnode; | |
3295 | |
3296 if (buddy->account == gc->account && | |
3297 GAIM_BUDDY_IS_ONLINE(buddy)) | |
3298 tmp = g_list_append(tmp, buddy->name); | |
3299 } | |
4359 | 3300 } |
3301 } | |
3302 } | |
3303 | |
3304 return tmp; | |
3305 } | |
3306 | |
9498 | 3307 static GdkPixbuf * |
9554 | 3308 get_chat_buddy_status_icon(GaimConvChat *chat, const char *name, GaimConvChatBuddyFlags flags) |
9498 | 3309 { |
9554 | 3310 GdkPixbuf *pixbuf, *scale, *scale2; |
9498 | 3311 char *filename; |
10274 | 3312 const char *image = NULL; |
9554 | 3313 |
3314 if (flags & GAIM_CBFLAGS_FOUNDER) { | |
10274 | 3315 image = "founder.png"; |
9554 | 3316 } else if (flags & GAIM_CBFLAGS_OP) { |
10274 | 3317 image = "op.png"; |
9554 | 3318 } else if (flags & GAIM_CBFLAGS_HALFOP) { |
10274 | 3319 image = "halfop.png"; |
9554 | 3320 } else if (flags & GAIM_CBFLAGS_VOICE) { |
10274 | 3321 image = "voice.png"; |
9554 | 3322 } else if ((!flags) && gaim_conv_chat_is_user_ignored(chat, name)) { |
10274 | 3323 image = "ignored.png"; |
3324 } else { | |
3325 return NULL; | |
9554 | 3326 } |
10274 | 3327 |
3328 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
3329 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
3330 g_free(filename); | |
3331 | |
3332 if (!pixbuf) | |
3333 return NULL; | |
3334 | |
3335 scale = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); | |
3336 g_object_unref(pixbuf); | |
3337 | |
3338 if (flags && gaim_conv_chat_is_user_ignored(chat, name)) { | |
3339 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "ignored.png", NULL); | |
9498 | 3340 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
3341 g_free(filename); | |
10274 | 3342 scale2 = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); |
9498 | 3343 g_object_unref(pixbuf); |
10274 | 3344 gdk_pixbuf_composite(scale2, scale, 0, 0, 15, 15, 0, 0, 1, 1, GDK_INTERP_BILINEAR, 192); |
3345 g_object_unref(scale2); | |
9498 | 3346 } |
3347 | |
10274 | 3348 return scale; |
9498 | 3349 } |
3350 | |
4359 | 3351 static void |
9554 | 3352 add_chat_buddy_common(GaimConversation *conv, const char *name) |
4359 | 3353 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3354 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3355 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3356 GaimConvChat *chat; |
9554 | 3357 GaimConvChatBuddyFlags flags; |
4359 | 3358 GtkTreeIter iter; |
3359 GtkListStore *ls; | |
9498 | 3360 GdkPixbuf *pixbuf; |
4359 | 3361 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3362 chat = GAIM_CONV_CHAT(conv); |
4359 | 3363 gtkconv = GAIM_GTK_CONVERSATION(conv); |
3364 gtkchat = gtkconv->u.chat; | |
3365 | |
3366 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); | |
3367 | |
9554 | 3368 flags = gaim_conv_chat_user_get_flags(chat, name); |
3369 pixbuf = get_chat_buddy_status_icon(chat, name, flags); | |
9498 | 3370 |
4359 | 3371 gtk_list_store_append(ls, &iter); |
9498 | 3372 gtk_list_store_set(ls, &iter, CHAT_USERS_ICON_COLUMN, pixbuf, |
9554 | 3373 CHAT_USERS_NAME_COLUMN, name, CHAT_USERS_FLAGS_COLUMN, flags, -1); |
9498 | 3374 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_NAME_COLUMN, |
4359 | 3375 GTK_SORT_ASCENDING); |
9554 | 3376 if (pixbuf) |
3377 g_object_unref(pixbuf); | |
4359 | 3378 } |
3379 | |
9605 | 3380 static gboolean |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3381 tab_complete(GaimConversation *conv) |
4359 | 3382 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3383 GaimGtkConversation *gtkconv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3384 GaimConvChat *chat; |
4359 | 3385 GtkTextIter cursor, word_start, start_buffer; |
3386 int start; | |
3387 int most_matched = -1; | |
3388 char *entered, *partial = NULL; | |
3389 char *text; | |
8021 | 3390 char *nick_partial; |
9605 | 3391 const char *prefix; |
4359 | 3392 GList *matches = NULL; |
9605 | 3393 GList *list = NULL; |
3394 GList *l = NULL; | |
3395 gboolean command = FALSE; | |
4359 | 3396 |
3397 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3398 | |
3399 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3400 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3401 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3402 | |
3403 word_start = cursor; | |
3404 | |
3405 /* if there's nothing there just return */ | |
3406 if (!gtk_text_iter_compare(&cursor, &start_buffer)) | |
9605 | 3407 return (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) ? TRUE : FALSE; |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
3408 |
4359 | 3409 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, |
3410 &cursor, FALSE); | |
3411 | |
3412 /* if we're at the end of ": " we need to move back 2 spaces */ | |
3413 start = strlen(text) - 1; | |
3414 | |
8021 | 3415 if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) { |
4359 | 3416 gtk_text_iter_backward_chars(&word_start, 2); |
8021 | 3417 start-=2; |
3418 } | |
4359 | 3419 |
3420 /* find the start of the word that we're tabbing */ | |
3421 while (start >= 0 && text[start] != ' ') { | |
3422 gtk_text_iter_backward_char(&word_start); | |
3423 start--; | |
3424 } | |
3425 | |
9605 | 3426 prefix = gaim_gtk_get_cmd_prefix(); |
3427 if (start == -1 && (strlen(text) >= strlen(prefix)) && !strncmp(text, prefix, strlen(prefix))) { | |
3428 command = TRUE; | |
3429 gtk_text_iter_forward_chars(&word_start, strlen(prefix)); | |
3430 } | |
3431 | |
4359 | 3432 g_free(text); |
3433 | |
3434 entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, | |
3435 &cursor, FALSE); | |
3436 | |
8021 | 3437 if (!g_utf8_strlen(entered, -1)) { |
4359 | 3438 g_free(entered); |
9605 | 3439 return (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) ? TRUE : FALSE; |
4359 | 3440 } |
3441 | |
8021 | 3442 nick_partial = g_malloc(strlen(entered)+1); |
3443 | |
9605 | 3444 if (command) { |
3445 list = gaim_cmd_list(conv); | |
3446 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { | |
3447 chat = GAIM_CONV_CHAT(conv); | |
3448 list = gaim_conv_chat_get_users(chat); | |
3449 } else { | |
3450 g_free(nick_partial); | |
3451 g_free(entered); | |
3452 return FALSE; | |
3453 } | |
3454 | |
3455 for (l = list; l; l = l->next) { | |
3456 char *name; | |
3457 | |
3458 if (command) | |
3459 name = l->data; | |
3460 else { | |
3461 GaimConvChatBuddy *cb = l->data; | |
3462 name = cb->name; | |
3463 } | |
3464 | |
3465 strncpy(nick_partial, name, strlen(entered)); | |
8172 | 3466 nick_partial[strlen(entered)] = '\0'; |
8021 | 3467 if(gaim_utf8_strcasecmp(nick_partial, entered)) |
3468 continue; | |
4359 | 3469 |
3470 /* if we're here, it's a possible completion */ | |
3471 | |
3472 if (most_matched == -1) { | |
3473 /* | |
3474 * this will only get called once, since from now | |
3475 * on most_matched is >= 0 | |
3476 */ | |
9605 | 3477 most_matched = strlen(name); |
3478 partial = g_strdup(name); | |
4359 | 3479 } |
3480 else if (most_matched) { | |
9605 | 3481 char *tmp = g_strdup(name); |
8021 | 3482 |
3483 while (gaim_utf8_strcasecmp(tmp, partial)) { | |
3484 partial[most_matched] = '\0'; | |
3485 if(most_matched < strlen(tmp)) | |
3486 tmp[most_matched] = '\0'; | |
4359 | 3487 most_matched--; |
8021 | 3488 } |
8079 | 3489 most_matched++; |
8021 | 3490 |
3491 g_free(tmp); | |
4359 | 3492 } |
3493 | |
9605 | 3494 matches = g_list_append(matches, name); |
4359 | 3495 } |
3496 | |
8021 | 3497 g_free(nick_partial); |
3498 | |
4359 | 3499 /* we're only here if we're doing new style */ |
3500 | |
3501 /* if there weren't any matches, return */ | |
3502 if (!matches) { | |
3503 /* if matches isn't set partials won't be either */ | |
3504 g_free(entered); | |
9605 | 3505 if (command) |
3506 g_list_free(list); | |
3507 return (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) ? TRUE : FALSE; | |
4359 | 3508 } |
3509 | |
3510 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); | |
3511 | |
3512 if (!matches->next) { | |
3513 /* there was only one match. fill it in. */ | |
3514 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3515 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3516 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3517 | |
3518 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
3519 char *tmp = g_strdup_printf("%s: ", (char *)matches->data); | |
3520 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, tmp, -1); | |
3521 g_free(tmp); | |
3522 } | |
3523 else | |
3524 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
3525 matches->data, -1); | |
3526 | |
3527 matches = g_list_remove(matches, matches->data); | |
3528 } | |
3529 else { | |
3530 /* | |
3531 * there were lots of matches, fill in as much as possible | |
3532 * and display all of them | |
3533 */ | |
3534 char *addthis = g_malloc0(1); | |
3535 | |
3536 while (matches) { | |
3537 char *tmp = addthis; | |
3538 addthis = g_strconcat(tmp, matches->data, " ", NULL); | |
3539 g_free(tmp); | |
3540 matches = g_list_remove(matches, matches->data); | |
3541 } | |
3542 | |
6982 | 3543 gaim_conversation_write(conv, NULL, addthis, GAIM_MESSAGE_NO_LOG, |
4359 | 3544 time(NULL)); |
3545 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, partial, -1); | |
3546 g_free(addthis); | |
3547 } | |
3548 | |
9605 | 3549 if (command) |
3550 g_list_free(list); | |
4359 | 3551 g_free(entered); |
3552 g_free(partial); | |
9605 | 3553 |
3554 return TRUE; | |
4359 | 3555 } |
3556 | |
3557 static GtkItemFactoryEntry menu_items[] = | |
3558 { | |
3559 /* Conversation menu */ | |
4596 | 3560 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>" }, |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3561 |
7887 | 3562 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, |
7859 | 3563 0, "<StockItem>", GAIM_STOCK_IM }, |
3564 | |
3565 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>" }, | |
3566 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3567 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3568 "<StockItem>", GTK_STOCK_FIND }, |
7859 | 3569 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, NULL }, |
4596 | 3570 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, |
4359 | 3571 "<StockItem>", GTK_STOCK_SAVE_AS }, |
8974 | 3572 { N_("/Conversation/Clear"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3573 |
4359 | 3574 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>" }, |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3575 |
9468 | 3576 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER }, |
5907
18486c860a46
[gaim-migrate @ 6339]
Christian Hammond <chipx86@chipx86.com>
parents:
5902
diff
changeset
|
3577 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, |
18486c860a46
[gaim-migrate @ 6339]
Christian Hammond <chipx86@chipx86.com>
parents:
5902
diff
changeset
|
3578 0, NULL }, |
7859 | 3579 { N_("/Conversation/_Get Info"), NULL, menu_get_info_cb, 0, |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3580 "<StockItem>", GAIM_STOCK_INFO }, |
7859 | 3581 { N_("/Conversation/_Warn..."), NULL, menu_warn_cb, 0, |
3582 "<StockItem>", GAIM_STOCK_WARN }, | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3583 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3584 "<StockItem>", GAIM_STOCK_INVITE }, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3585 |
5907
18486c860a46
[gaim-migrate @ 6339]
Christian Hammond <chipx86@chipx86.com>
parents:
5902
diff
changeset
|
3586 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>" }, |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3587 |
7859 | 3588 { N_("/Conversation/A_lias..."), NULL, menu_alias_cb, 0, |
3589 "<StockItem>", GAIM_STOCK_EDIT }, | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3590 { N_("/Conversation/_Block..."), NULL, menu_block_cb, 0, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3591 "<StockItem>", GAIM_STOCK_BLOCK }, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3592 { N_("/Conversation/_Add..."), NULL, menu_add_remove_cb, 0, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3593 "<StockItem>", GTK_STOCK_ADD }, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3594 { N_("/Conversation/_Remove..."), NULL, menu_add_remove_cb, 0, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3595 "<StockItem>", GTK_STOCK_REMOVE }, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3596 |
7859 | 3597 { "/Conversation/sep3", NULL, NULL, 0, "<Separator>" }, |
3598 | |
8756 | 3599 { N_("/Conversation/Insert Lin_k..."), NULL, menu_insert_link_cb, 0, |
7859 | 3600 "<StockItem>", GAIM_STOCK_LINK }, |
9287 | 3601 { N_("/Conversation/Insert Imag_e..."), NULL, menu_insert_image_cb, 0, |
7859 | 3602 "<StockItem>", GAIM_STOCK_IMAGE }, |
3603 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3604 { "/Conversation/sep4", NULL, NULL, 0, "<Separator>" }, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3605 |
4596 | 3606 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, |
4359 | 3607 "<StockItem>", GTK_STOCK_CLOSE }, |
3608 | |
3609 /* Options */ | |
4596 | 3610 { N_("/_Options"), NULL, NULL, 0, "<Branch>" }, |
3611 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>" }, | |
3612 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>" }, | |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
3613 { N_("/Options/Show Formatting _Toolbar"), NULL, menu_toolbar_cb, 0, "<CheckItem>" }, |
9188 | 3614 { N_("/Options/Show T_imestamps"), "F2", menu_timestamps_cb, 0, "<CheckItem>" }, |
4359 | 3615 }; |
3616 | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
3617 static const int menu_item_count = |
4359 | 3618 sizeof(menu_items) / sizeof(*menu_items); |
3619 | |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
3620 static char * |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
3621 item_factory_translate_func (const char *path, gpointer func_data) |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
3622 { |
7386 | 3623 return _((char *)path); |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
3624 } |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
3625 |
4359 | 3626 static GtkWidget * |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3627 setup_menubar(GaimConvWindow *win) |
4359 | 3628 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3629 GaimGtkWindow *gtkwin; |
5116 | 3630 GtkAccelGroup *accel_group; |
4359 | 3631 gtkwin = GAIM_GTK_WINDOW(win); |
3632 | |
6398
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
3633 accel_group = gtk_accel_group_new (); |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
3634 gtk_window_add_accel_group (GTK_WINDOW (gtkwin->window), accel_group); |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
3635 g_object_unref (accel_group); |
5116 | 3636 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3637 gtkwin->menu.item_factory = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3638 gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3639 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3640 gtk_item_factory_set_translate_func(gtkwin->menu.item_factory, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3641 item_factory_translate_func, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3642 NULL, NULL); |
4630 | 3643 |
3644 gtk_item_factory_create_items(gtkwin->menu.item_factory, menu_item_count, | |
4359 | 3645 menu_items, win); |
7420 | 3646 g_signal_connect(G_OBJECT(accel_group), "accel-changed", |
3647 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
4359 | 3648 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3649 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3650 gtkwin->menu.menubar = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3651 gtk_item_factory_get_widget(gtkwin->menu.item_factory, "<main>"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3652 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3653 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3654 gtkwin->menu.view_log = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3655 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
7295 | 3656 N_("/Conversation/View Log")); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3657 /* --- */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3658 |
9468 | 3659 gtkwin->menu.send_file = |
3660 gtk_item_factory_get_widget(gtkwin->menu.item_factory, | |
3661 N_("/Conversation/Send File...")); | |
9498 | 3662 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3663 gtkwin->menu.add_pounce = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3664 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3665 N_("/Conversation/Add Buddy Pounce...")); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3666 |
7879 | 3667 /* --- */ |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3668 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3669 gtkwin->menu.get_info = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3670 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
7859 | 3671 N_("/Conversation/Get Info")); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3672 |
7879 | 3673 gtkwin->menu.warn = |
3674 gtk_item_factory_get_widget(gtkwin->menu.item_factory, | |
3675 N_("/Conversation/Warn...")); | |
3676 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3677 gtkwin->menu.invite = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3678 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3679 N_("/Conversation/Invite...")); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3680 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3681 /* --- */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3682 |
7879 | 3683 gtkwin->menu.alias = |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3684 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
7879 | 3685 N_("/Conversation/Alias...")); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3686 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3687 gtkwin->menu.block = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3688 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3689 N_("/Conversation/Block...")); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3690 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3691 gtkwin->menu.add = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3692 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3693 N_("/Conversation/Add...")); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3694 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3695 gtkwin->menu.remove = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3696 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3697 N_("/Conversation/Remove...")); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3698 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3699 /* --- */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3700 |
7879 | 3701 gtkwin->menu.insert_link = |
3702 gtk_item_factory_get_widget(gtkwin->menu.item_factory, | |
3703 N_("/Conversation/Insert Link...")); | |
3704 | |
3705 gtkwin->menu.insert_image = | |
3706 gtk_item_factory_get_widget(gtkwin->menu.item_factory, | |
3707 N_("/Conversation/Insert Image...")); | |
3708 | |
3709 /* --- */ | |
3710 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3711 gtkwin->menu.logging = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3712 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3713 N_("/Options/Enable Logging")); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3714 gtkwin->menu.sounds = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3715 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3716 N_("/Options/Enable Sounds")); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
3717 gtkwin->menu.show_formatting_toolbar = |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
3718 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
3719 N_("/Options/Show Formatting Toolbar")); |
9188 | 3720 gtkwin->menu.show_timestamps = |
3721 gtk_item_factory_get_widget(gtkwin->menu.item_factory, | |
3722 N_("/Options/Show Timestamps")); | |
4359 | 3723 |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
3724 generate_send_as_items(win, NULL); |
4359 | 3725 |
3726 gtk_widget_show(gtkwin->menu.menubar); | |
4931 | 3727 |
3728 return gtkwin->menu.menubar; | |
4359 | 3729 } |
3730 | |
9759 | 3731 GtkWidget * |
3732 gaim_gtkconv_button_new(const char *icon, const char *text, const char *tooltip, GtkTooltips *tooltips, void *callback, void *data) | |
9749 | 3733 { |
3734 GtkWidget *button; | |
3735 int buttons; | |
3736 | |
3737 buttons = gaim_prefs_get_int("/gaim/gtk/conversations/button_type"); | |
3738 button = gaim_pixbuf_button_from_stock( | |
3739 (buttons == GAIM_BUTTON_IMAGE ? NULL : text), | |
3740 (buttons == GAIM_BUTTON_TEXT ? NULL : icon), | |
9750 | 3741 GAIM_BUTTON_VERTICAL); |
9766 | 3742 if (tooltip != NULL) |
3743 gtk_tooltips_set_tip(tooltips, button, tooltip, NULL); | |
9749 | 3744 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
9766 | 3745 if (callback != NULL) |
3746 g_signal_connect(G_OBJECT(button), "clicked", | |
3747 G_CALLBACK(callback), data); | |
9749 | 3748 |
3749 return button; | |
3750 } | |
3751 | |
4359 | 3752 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3753 setup_im_buttons(GaimConversation *conv, GtkWidget *parent) |
4359 | 3754 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3755 GaimConnection *gc; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3756 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3757 GaimGtkImPane *gtkim; |
8811 | 3758 GaimButtonStyle button_type; |
9749 | 3759 GList *children; |
4359 | 3760 |
3761 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3762 gtkim = gtkconv->u.im; | |
3763 gc = gaim_conversation_get_gc(conv); | |
3764 | |
9749 | 3765 /* Remove anything else in our parent */ |
3766 children = gtk_container_get_children(GTK_CONTAINER(parent)); | |
3767 while (children != NULL) { | |
9885 | 3768 if(children->data != gtkim->icon_container) |
3769 gtk_container_remove(GTK_CONTAINER(parent), children->data); | |
9749 | 3770 children = g_list_remove(children, children->data); |
3771 } | |
3772 | |
9750 | 3773 /* The buttons, from left to right */ |
9749 | 3774 |
3775 /* Block button */ | |
9759 | 3776 gtkim->block = gaim_gtkconv_button_new(GAIM_STOCK_BLOCK, _("Block"), |
9749 | 3777 _("Block the user"), |
3778 gtkconv->tooltips, block_cb, conv); | |
9750 | 3779 gtk_box_pack_start(GTK_BOX(parent), gtkim->block, TRUE, TRUE, 0); |
9749 | 3780 gtk_size_group_add_widget(gtkconv->sg, gtkim->block); |
3781 | |
3782 /* Send File button */ | |
9759 | 3783 gtkim->send_file = gaim_gtkconv_button_new(GAIM_STOCK_FILE_TRANSFER, _("Send File"), |
9749 | 3784 _("Send a file to the user"), |
3785 gtkconv->tooltips, send_file_cb, conv); | |
9750 | 3786 gtk_box_pack_start(GTK_BOX(parent), gtkim->send_file, TRUE, TRUE, 0); |
9749 | 3787 gtk_size_group_add_widget(gtkconv->sg, gtkim->send_file); |
3788 | |
3789 /* Add button */ | |
9759 | 3790 gtkconv->add = gaim_gtkconv_button_new(GTK_STOCK_ADD, _("Add"), |
9749 | 3791 _("Add the user to your buddy list"), |
3792 gtkconv->tooltips, add_remove_cb, conv); | |
9750 | 3793 gtk_box_pack_start(GTK_BOX(parent), gtkconv->add, TRUE, TRUE, 0); |
9749 | 3794 gtk_size_group_add_widget(gtkconv->sg, gtkconv->add); |
3795 | |
3796 /* Remove button */ | |
9759 | 3797 gtkconv->remove = gaim_gtkconv_button_new(GTK_STOCK_REMOVE, _("Remove"), |
9749 | 3798 _("Remove the user from your buddy list"), |
3799 gtkconv->tooltips, add_remove_cb, conv); | |
9750 | 3800 gtk_box_pack_start(GTK_BOX(parent), gtkconv->remove, TRUE, TRUE, 0); |
9749 | 3801 gtk_size_group_add_widget(gtkconv->sg, gtkconv->remove); |
3802 | |
3803 /* Info button */ | |
9759 | 3804 gtkconv->info = gaim_gtkconv_button_new(GAIM_STOCK_INFO, _("Info"), |
9749 | 3805 _("Get the user's information"), |
3806 gtkconv->tooltips, info_cb, conv); | |
9750 | 3807 gtk_box_pack_start(GTK_BOX(parent), gtkconv->info, TRUE, TRUE, 0); |
9749 | 3808 gtk_size_group_add_widget(gtkconv->sg, gtkconv->info); |
4359 | 3809 |
3810 /* Send button */ | |
9759 | 3811 gtkconv->send = gaim_gtkconv_button_new(GAIM_STOCK_SEND, _("Send"), |
9749 | 3812 _("Send message"), |
3813 gtkconv->tooltips, send_cb, conv); | |
4359 | 3814 gtk_box_pack_end(GTK_BOX(parent), gtkconv->send, FALSE, FALSE, 0); |
3815 | |
3816 /* Separator */ | |
3817 gtkim->sep2 = gtk_vseparator_new(); | |
3818 gtk_box_pack_end(GTK_BOX(parent), gtkim->sep2, FALSE, TRUE, 0); | |
3819 gtk_widget_show(gtkim->sep2); | |
3820 | |
3821 gaim_gtkconv_update_buttons_by_protocol(conv); | |
3822 | |
8811 | 3823 /* Check if the buttons should be visible or not */ |
9150 | 3824 button_type = gaim_prefs_get_int("/gaim/gtk/conversations/button_type"); |
8811 | 3825 if (button_type == GAIM_BUTTON_NONE) |
9749 | 3826 gtk_widget_hide(parent); |
8811 | 3827 else |
9749 | 3828 gtk_widget_show(parent); |
4359 | 3829 } |
3830 | |
3831 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3832 setup_chat_buttons(GaimConversation *conv, GtkWidget *parent) |
4359 | 3833 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3834 GaimConnection *gc; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3835 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3836 GaimGtkChatPane *gtkchat; |
8811 | 3837 GaimButtonStyle button_type; |
9750 | 3838 GList *children; |
4359 | 3839 |
3840 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3841 gtkchat = gtkconv->u.chat; | |
3842 gc = gaim_conversation_get_gc(conv); | |
3843 | |
9750 | 3844 /* Remove anything else in our parent */ |
3845 children = gtk_container_get_children(GTK_CONTAINER(parent)); | |
3846 while (children != NULL) { | |
3847 gtk_container_remove(GTK_CONTAINER(parent), children->data); | |
3848 children = g_list_remove(children, children->data); | |
3849 } | |
3850 | |
3851 /* The buttons, from left to right */ | |
3852 | |
3853 /* Invite */ | |
9759 | 3854 gtkchat->invite = gaim_gtkconv_button_new(GAIM_STOCK_INVITE, _("Invite"), |
9817 | 3855 _("Invite a user"), |
9750 | 3856 gtkconv->tooltips, invite_cb, conv); |
3857 gtk_box_pack_start(GTK_BOX(parent), gtkchat->invite, TRUE, TRUE, 0); | |
3858 gtk_size_group_add_widget(gtkconv->sg, gtkchat->invite); | |
3859 | |
3860 /* Add button */ | |
9759 | 3861 gtkconv->add = gaim_gtkconv_button_new(GTK_STOCK_ADD, _("Add"), |
9750 | 3862 _("Add the chat to your buddy list"), |
3863 gtkconv->tooltips, add_remove_cb, conv); | |
3864 gtk_box_pack_start(GTK_BOX(parent), gtkconv->add, TRUE, TRUE, 0); | |
3865 gtk_size_group_add_widget(gtkconv->sg, gtkconv->add); | |
3866 | |
3867 /* Remove button */ | |
9759 | 3868 gtkconv->remove = gaim_gtkconv_button_new(GTK_STOCK_REMOVE, _("Remove"), |
9750 | 3869 _("Remove the chat from your buddy list"), |
3870 gtkconv->tooltips, add_remove_cb, conv); | |
3871 gtk_box_pack_start(GTK_BOX(parent), gtkconv->remove, TRUE, TRUE, 0); | |
3872 gtk_size_group_add_widget(gtkconv->sg, gtkconv->remove); | |
7996
334ab1319406
[gaim-migrate @ 8673]
Christian Hammond <chipx86@chipx86.com>
parents:
7995
diff
changeset
|
3873 |
4359 | 3874 /* Send button */ |
9759 | 3875 gtkconv->send = gaim_gtkconv_button_new(GAIM_STOCK_SEND, _("Send"), |
9750 | 3876 _("Send message"), |
3877 gtkconv->tooltips, send_cb, conv); | |
4359 | 3878 gtk_box_pack_end(GTK_BOX(parent), gtkconv->send, FALSE, FALSE, 0); |
9750 | 3879 gtk_size_group_add_widget(gtkconv->sg, gtkconv->send); |
4359 | 3880 |
3881 /* Separator */ | |
7996
334ab1319406
[gaim-migrate @ 8673]
Christian Hammond <chipx86@chipx86.com>
parents:
7995
diff
changeset
|
3882 gtkchat->sep = gtk_vseparator_new(); |
334ab1319406
[gaim-migrate @ 8673]
Christian Hammond <chipx86@chipx86.com>
parents:
7995
diff
changeset
|
3883 gtk_box_pack_end(GTK_BOX(parent), gtkchat->sep, FALSE, TRUE, 0); |
334ab1319406
[gaim-migrate @ 8673]
Christian Hammond <chipx86@chipx86.com>
parents:
7995
diff
changeset
|
3884 gtk_widget_show(gtkchat->sep); |
4359 | 3885 |
7996
334ab1319406
[gaim-migrate @ 8673]
Christian Hammond <chipx86@chipx86.com>
parents:
7995
diff
changeset
|
3886 gaim_gtkconv_update_buttons_by_protocol(conv); |
334ab1319406
[gaim-migrate @ 8673]
Christian Hammond <chipx86@chipx86.com>
parents:
7995
diff
changeset
|
3887 |
8811 | 3888 /* Check if the buttons should be visible or not */ |
9150 | 3889 button_type = gaim_prefs_get_int("/gaim/gtk/conversations/button_type"); |
8811 | 3890 if (button_type == GAIM_BUTTON_NONE) |
3891 gtk_widget_hide(gtkconv->bbox); | |
3892 else | |
3893 gtk_widget_show(gtkconv->bbox); | |
4359 | 3894 } |
3895 | |
3896 | |
7971 | 3897 static void topic_callback(GtkWidget *w, GaimConversation *conv) |
3898 { | |
3899 GaimPluginProtocolInfo *prpl_info = NULL; | |
3900 GaimConnection *gc; | |
3901 GaimGtkConversation *gtkconv; | |
3902 GaimGtkChatPane *gtkchat; | |
8858 | 3903 const char *new_topic; |
3904 const char *current_topic; | |
7971 | 3905 |
3906 gc = gaim_conversation_get_gc(conv); | |
3907 | |
3908 if(!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) | |
3909 return; | |
3910 | |
3911 if(prpl_info->set_chat_topic == NULL) | |
3912 return; | |
3913 | |
3914 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3915 gtkchat = gtkconv->u.chat; | |
8858 | 3916 new_topic = gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text)); |
3917 current_topic = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(conv)); | |
3918 | |
3919 if(current_topic && !g_utf8_collate(new_topic, current_topic)) | |
7971 | 3920 return; |
3921 | |
8858 | 3922 prpl_info->set_chat_topic(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), |
3923 new_topic); | |
7971 | 3924 } |
3925 | |
9554 | 3926 static gint |
3927 sort_chat_users(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata) | |
3928 { | |
3929 GaimConvChatBuddyFlags f1 = 0, f2 = 0; | |
3930 char *user1 = NULL, *user2 = NULL; | |
3931 gint ret = 0; | |
3932 | |
3933 gtk_tree_model_get(model, a, CHAT_USERS_NAME_COLUMN, &user1, CHAT_USERS_FLAGS_COLUMN, &f1, -1); | |
3934 gtk_tree_model_get(model, b, CHAT_USERS_NAME_COLUMN, &user2, CHAT_USERS_FLAGS_COLUMN, &f2, -1); | |
3935 | |
3936 if (user1 == NULL || user2 == NULL) { | |
3937 if (!(user1 == NULL && user2 == NULL)) | |
3938 ret = (user1 == NULL) ? -1: 1; | |
3939 } else if (f1 != f2) { | |
3940 /* sort more important users first */ | |
3941 ret = (f1 > f2) ? -1 : 1; | |
3942 } else { | |
3943 ret = g_utf8_collate(user1, user2); | |
3944 } | |
3945 | |
3946 g_free(user1); | |
3947 g_free(user2); | |
3948 | |
3949 return ret; | |
3950 } | |
3951 | |
4359 | 3952 static GtkWidget * |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3953 setup_chat_pane(GaimConversation *conv) |
4359 | 3954 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3955 GaimPluginProtocolInfo *prpl_info = NULL; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3956 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3957 GaimGtkChatPane *gtkchat; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3958 GaimConnection *gc; |
4359 | 3959 GtkWidget *vpaned, *hpaned; |
10175 | 3960 GtkWidget *vbox, *hbox, *frame; |
4359 | 3961 GtkWidget *lbox, *bbox; |
3962 GtkWidget *label; | |
3963 GtkWidget *list; | |
3964 GtkWidget *button; | |
7949 | 3965 GtkWidget *sw; |
4359 | 3966 GtkListStore *ls; |
3967 GtkCellRenderer *rend; | |
3968 GtkTreeViewColumn *col; | |
9080 | 3969 GList *focus_chain = NULL; |
4359 | 3970 |
3971 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3972 gtkchat = gtkconv->u.chat; | |
3973 gc = gaim_conversation_get_gc(conv); | |
3974 | |
3975 /* Setup the outer pane. */ | |
3976 vpaned = gtk_vpaned_new(); | |
3977 gtk_widget_show(vpaned); | |
3978 | |
3979 /* Setup the top part of the pane. */ | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3980 vbox = gtk_vbox_new(FALSE, 6); |
8914 | 3981 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, TRUE); |
4359 | 3982 gtk_widget_show(vbox); |
3983 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3984 if (gc != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3985 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3986 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3987 if (prpl_info->options & OPT_PROTO_CHAT_TOPIC) |
4359 | 3988 { |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3989 hbox = gtk_hbox_new(FALSE, 6); |
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3990 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4359 | 3991 gtk_widget_show(hbox); |
3992 | |
3993 label = gtk_label_new(_("Topic:")); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3994 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
4359 | 3995 gtk_widget_show(label); |
3996 | |
3997 gtkchat->topic_text = gtk_entry_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3998 |
7971 | 3999 if(prpl_info->set_chat_topic == NULL) { |
4000 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); | |
4001 } else { | |
4002 g_signal_connect(GTK_OBJECT(gtkchat->topic_text), "activate", | |
4003 G_CALLBACK(topic_callback), conv); | |
4004 } | |
4005 | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4006 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 0); |
4359 | 4007 gtk_widget_show(gtkchat->topic_text); |
4008 } | |
4009 | |
4010 /* Setup the horizontal pane. */ | |
4011 hpaned = gtk_hpaned_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4012 gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0); |
4359 | 4013 gtk_widget_show(hpaned); |
4014 | |
10175 | 4015 /* Setup gtkihmtml. */ |
4016 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
4017 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
4018 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
4019 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); | |
4020 gtk_paned_pack1(GTK_PANED(hpaned), frame, TRUE, TRUE); | |
4021 gtk_widget_show(frame); | |
4022 | |
4023 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
4024 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
4025 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_height")); |
10175 | 4026 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
8914 | 4027 G_CALLBACK(size_allocate_cb), conv); |
4028 | |
4359 | 4029 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", |
4030 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8105 | 4031 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
6057 | 4032 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 4033 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
4034 G_CALLBACK(refocus_entry_cb), gtkconv); | |
4359 | 4035 |
4036 /* Build the right pane. */ | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4037 lbox = gtk_vbox_new(FALSE, 6); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
4038 gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); |
4359 | 4039 gtk_widget_show(lbox); |
4040 | |
4041 /* Setup the label telling how many people are in the room. */ | |
4042 gtkchat->count = gtk_label_new(_("0 people in room")); | |
4043 gtk_box_pack_start(GTK_BOX(lbox), gtkchat->count, FALSE, FALSE, 0); | |
4044 gtk_widget_show(gtkchat->count); | |
4045 | |
4046 /* Setup the list of users. */ | |
7949 | 4047 sw = gtk_scrolled_window_new(NULL, NULL); |
4048 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
8076 | 4049 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
7949 | 4050 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
4051 gtk_box_pack_start(GTK_BOX(lbox), sw, TRUE, TRUE, 0); | |
4052 gtk_widget_show(sw); | |
4359 | 4053 |
9554 | 4054 ls = gtk_list_store_new(CHAT_USERS_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, |
4055 G_TYPE_INT); | |
4056 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_NAME_COLUMN, | |
4057 sort_chat_users, NULL, NULL); | |
9498 | 4058 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_NAME_COLUMN, |
4359 | 4059 GTK_SORT_ASCENDING); |
4060 | |
4061 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
4062 | |
9498 | 4063 rend = gtk_cell_renderer_pixbuf_new(); |
4064 | |
4359 | 4065 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
9498 | 4066 "pixbuf", CHAT_USERS_ICON_COLUMN, NULL); |
9554 | 4067 gtk_tree_view_column_set_clickable(GTK_TREE_VIEW_COLUMN(col), TRUE); |
4068 | |
9498 | 4069 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); |
4359 | 4070 |
4071 g_signal_connect(G_OBJECT(list), "button_press_event", | |
4072 G_CALLBACK(right_click_chat_cb), conv); | |
8143 | 4073 g_signal_connect(G_OBJECT(list), "popup-menu", |
4074 G_CALLBACK(gtkconv_chat_popup_menu_cb), conv); | |
4359 | 4075 |
9498 | 4076 rend = gtk_cell_renderer_text_new(); |
4077 | |
4359 | 4078 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
9498 | 4079 "text", CHAT_USERS_NAME_COLUMN, NULL); |
4359 | 4080 gtk_tree_view_column_set_clickable(GTK_TREE_VIEW_COLUMN(col), TRUE); |
4081 | |
4082 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
4083 | |
4084 gtk_widget_set_size_request(list, 150, -1); | |
4085 | |
4086 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); | |
4087 gtk_widget_show(list); | |
4088 | |
4089 gtkchat->list = list; | |
4090 | |
7949 | 4091 gtk_container_add(GTK_CONTAINER(sw), list); |
4359 | 4092 |
4093 /* Setup the user list toolbar. */ | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4094 bbox = gtk_hbox_new(TRUE, 6); |
4359 | 4095 gtk_box_pack_start(GTK_BOX(lbox), bbox, FALSE, FALSE, 0); |
4096 gtk_widget_show(bbox); | |
4097 | |
4098 /* IM */ | |
10221 | 4099 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IM, |
4359 | 4100 GAIM_BUTTON_VERTICAL); |
4101 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
4102 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
4103 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("IM the user"), NULL); |
4359 | 4104 g_signal_connect(G_OBJECT(button), "clicked", |
7961 | 4105 G_CALLBACK(chat_im_button_cb), conv); |
4359 | 4106 |
4107 gtk_widget_show(button); | |
4108 | |
4109 /* Ignore */ | |
4110 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IGNORE, | |
4111 GAIM_BUTTON_VERTICAL); | |
4112 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
4113 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
4114 gtk_tooltips_set_tip(gtkconv->tooltips, button, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
4115 _("Ignore the user"), NULL); |
4359 | 4116 g_signal_connect(G_OBJECT(button), "clicked", |
4117 G_CALLBACK(ignore_cb), conv); | |
4118 gtk_widget_show(button); | |
4119 | |
4120 /* Info */ | |
4121 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_INFO, | |
4122 GAIM_BUTTON_VERTICAL); | |
4123 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
4124 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
4125 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
4126 _("Get the user's information"), NULL); |
4359 | 4127 g_signal_connect(G_OBJECT(button), "clicked", |
4128 G_CALLBACK(info_cb), conv); | |
4129 | |
4130 gtk_widget_show(button); | |
4131 | |
4132 gtkconv->info = button; | |
4133 | |
10175 | 4134 /* Setup the bottom half of the conversation window */ |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4135 vbox = gtk_vbox_new(FALSE, 6); |
8914 | 4136 gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4137 gtk_widget_show(vbox); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4138 |
9332 | 4139 gtkconv->lower_hbox = gtk_hbox_new(FALSE, 6); |
4140 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, TRUE, TRUE, 0); | |
4141 gtk_widget_show(gtkconv->lower_hbox); | |
4142 | |
4143 vbox = gtk_vbox_new(FALSE, 6); | |
4144 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox, TRUE, TRUE, 0); | |
4145 gtk_widget_show(vbox); | |
4146 | |
10175 | 4147 /* Setup the toolbar, entry widget and all signals */ |
4148 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 4149 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
10175 | 4150 gtk_widget_show(frame); |
4151 | |
9005 | 4152 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 4153 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 4154 gaim_account_get_protocol_name(conv->account)); |
10175 | 4155 gtk_widget_set_size_request(gtkconv->entry, -1, |
4156 gaim_prefs_get_int("/gaim/gtk/conversations/chat/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4157 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4158 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
7949 | 4159 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", conv); |
4160 | |
4161 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
8105 | 4162 G_CALLBACK(entry_key_press_cb), conv); |
10115 | 4163 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", |
4164 G_CALLBACK(send_cb), conv); | |
4359 | 4165 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
4166 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8914 | 4167 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
4168 G_CALLBACK(size_allocate_cb), conv); | |
4359 | 4169 |
10175 | 4170 default_formatize(conv); |
4359 | 4171 |
4172 /* Setup the bottom button box. */ | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4173 gtkconv->bbox = gtk_hbox_new(FALSE, 6); |
4359 | 4174 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->bbox, FALSE, FALSE, 0); |
4175 setup_chat_buttons(conv, gtkconv->bbox); | |
4176 | |
9080 | 4177 /* |
4178 * Focus for chat windows should be as follows: | |
4179 * Tab title -> chat topic -> conversation scrollback -> user list -> | |
4180 * user list buttons -> entry -> buttons at bottom | |
4181 */ | |
4182 focus_chain = g_list_prepend(focus_chain, gtkconv->bbox); | |
9332 | 4183 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 4184 gtk_container_set_focus_chain(GTK_CONTAINER(vbox), focus_chain); |
4185 | |
4359 | 4186 return vpaned; |
4187 } | |
4188 | |
4189 static GtkWidget * | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4190 setup_im_pane(GaimConversation *conv) |
4359 | 4191 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4192 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4193 GaimGtkImPane *gtkim; |
10175 | 4194 GtkWidget *frame; |
4359 | 4195 GtkWidget *paned; |
10175 | 4196 GtkWidget *vbox; |
4197 GtkWidget *vbox2; | |
9080 | 4198 GList *focus_chain = NULL; |
4359 | 4199 |
4200 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4201 gtkim = gtkconv->u.im; | |
4202 | |
10175 | 4203 /* Setup the outer pane */ |
4359 | 4204 paned = gtk_vpaned_new(); |
4205 gtk_widget_show(paned); | |
4206 | |
10175 | 4207 /* Setup the top part of the pane */ |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4208 vbox = gtk_vbox_new(FALSE, 6); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
4209 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
4359 | 4210 gtk_widget_show(vbox); |
4211 | |
10175 | 4212 /* Setup the gtkimhtml widget */ |
4213 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
4214 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
4215 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
4216 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); | |
4217 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); | |
4218 gtk_widget_show(frame); | |
4219 | |
4220 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
4221 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
4222 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_height")); |
10175 | 4223 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
8914 | 4224 G_CALLBACK(size_allocate_cb), conv); |
4359 | 4225 |
4226 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
4227 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8105 | 4228 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
6057 | 4229 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 4230 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
4231 G_CALLBACK(refocus_entry_cb), gtkconv); | |
4359 | 4232 |
10175 | 4233 /* Setup the bottom half of the conversation window */ |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4234 vbox2 = gtk_vbox_new(FALSE, 6); |
8914 | 4235 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4236 gtk_widget_show(vbox2); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4237 |
9332 | 4238 gtkconv->lower_hbox = gtk_hbox_new(FALSE, 6); |
4239 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->lower_hbox, TRUE, TRUE, 0); | |
4240 gtk_widget_show(gtkconv->lower_hbox); | |
4241 | |
4242 vbox2 = gtk_vbox_new(FALSE, 6); | |
4243 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox2, TRUE, TRUE, 0); | |
4244 gtk_widget_show(vbox2); | |
8821 | 4245 |
10175 | 4246 /* Setup the toolbar, entry widget and all signals */ |
4247 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 4248 gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); |
10175 | 4249 gtk_widget_show(frame); |
4250 | |
9005 | 4251 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 4252 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 4253 gaim_account_get_protocol_name(conv->account)); |
10175 | 4254 gtk_widget_set_size_request(gtkconv->entry, -1, |
4255 gaim_prefs_get_int("/gaim/gtk/conversations/im/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4256 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4257 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
7949 | 4258 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", conv); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4259 |
4359 | 4260 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", |
10115 | 4261 G_CALLBACK(entry_key_press_cb), conv); |
4262 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", G_CALLBACK(send_cb), conv); | |
4359 | 4263 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
4264 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8914 | 4265 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
4266 G_CALLBACK(size_allocate_cb), conv); | |
4359 | 4267 |
4268 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
4269 G_CALLBACK(insert_text_cb), conv); | |
4270 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", | |
4271 G_CALLBACK(delete_text_cb), conv); | |
4272 | |
8481 | 4273 /* had to move this after the imtoolbar is attached so that the |
4274 * signals get fired to toggle the buttons on the toolbar as well. | |
4275 */ | |
4276 default_formatize(conv); | |
4359 | 4277 |
9749 | 4278 /* Setup the bottom button box. */ |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4279 gtkconv->bbox = gtk_hbox_new(FALSE, 6); |
4359 | 4280 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->bbox, FALSE, FALSE, 0); |
4281 setup_im_buttons(conv, gtkconv->bbox); | |
9749 | 4282 |
8758 | 4283 gtkconv->u.im->animate = gaim_prefs_get_bool("/gaim/gtk/conversations/im/animate_buddy_icons"); |
9687 | 4284 gtkconv->u.im->show_icon = TRUE; |
4359 | 4285 |
9080 | 4286 /* |
4287 * Focus for IM windows should be as follows: | |
4288 * Tab title -> conversation scrollback -> entry -> buttons at bottom | |
4289 */ | |
4290 focus_chain = g_list_prepend(focus_chain, gtkconv->bbox); | |
9332 | 4291 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 4292 gtk_container_set_focus_chain(GTK_CONTAINER(vbox2), focus_chain); |
8143 | 4293 |
4359 | 4294 return paned; |
4295 } | |
4296 | |
4297 static void | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4298 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
4299 GtkSelectionData *sd, guint info, guint t, |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4300 GaimConversation *conv) |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4301 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4302 GaimConvWindow *win = conv->window; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4303 GaimConversation *c; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4304 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4305 { |
4781 | 4306 GaimBlistNode *n = NULL; |
6695 | 4307 GaimBuddy *b; |
9622 | 4308 unsigned int index; |
4309 | |
4781 | 4310 memcpy(&n, sd->data, sizeof(n)); |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
4311 |
6695 | 4312 if (GAIM_BLIST_NODE_IS_CONTACT(n)) |
4313 b = gaim_contact_get_priority_buddy((GaimContact*)n); | |
4314 else if (GAIM_BLIST_NODE_IS_BUDDY(n)) | |
4315 b = (GaimBuddy*)n; | |
4316 else | |
4781 | 4317 return; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
4318 |
9622 | 4319 /* |
4320 * If we already have an open conversation with this buddy, then | |
4321 * just move the conv to this window. Otherwise, create a new | |
4322 * conv and add it to this window. | |
4323 */ | |
10246 | 4324 c = gaim_find_conversation(GAIM_CONV_IM, b->name); |
9622 | 4325 if (c != NULL) { |
4326 GaimConvWindow *oldwin; | |
4327 oldwin = gaim_conversation_get_window(c); | |
4328 index = gaim_conversation_get_index(c); | |
4329 if (oldwin != win) { | |
4330 gaim_conv_window_remove_conversation(oldwin, index); | |
4331 gaim_conv_window_add_conversation(win, c); | |
4332 } | |
4333 } else { | |
4334 c = gaim_conversation_new(GAIM_CONV_IM, b->account, b->name); | |
4335 gaim_conv_window_add_conversation(win, c); | |
4336 } | |
4337 | |
4338 /* Make this conversation the active conversation */ | |
4339 index = gaim_conversation_get_index(c); | |
4340 gaim_conv_window_switch_conversation(win, index); | |
8802
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
4341 |
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
4342 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
4702 | 4343 } |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4344 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4345 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4346 char *protocol = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4347 char *username = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4348 GaimAccount *account; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4349 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4350 if (gaim_gtk_parse_x_im_contact(sd->data, FALSE, &account, |
7718 | 4351 &protocol, &username, NULL)) |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4352 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4353 if (account == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4354 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4355 gaim_notify_error(NULL, NULL, |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4356 _("You are not currently signed on with an account that " |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4357 "can add that buddy."), NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4358 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4359 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4360 { |
7718 | 4361 c = gaim_conversation_new(GAIM_CONV_IM, account, username); |
4362 gaim_conv_window_add_conversation(win, c); | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4363 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4364 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4365 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4366 if (username != NULL) g_free(username); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4367 if (protocol != NULL) g_free(protocol); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4368 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4369 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4370 } |
9525 | 4371 else if (sd->target == gdk_atom_intern("text/uri-list", FALSE)) { |
10229 | 4372 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
4373 gaim_dnd_file_manage(sd, gaim_conversation_get_account(conv), gaim_conversation_get_name(conv)); | |
10145 | 4374 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
9495 | 4375 } |
10145 | 4376 else |
4377 gtk_drag_finish(dc, FALSE, FALSE, t); | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4378 } |
4359 | 4379 |
4380 /************************************************************************** | |
4381 * GTK+ window ops | |
4382 **************************************************************************/ | |
4383 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4384 gaim_gtk_new_window(GaimConvWindow *win) |
4359 | 4385 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4386 GaimGtkWindow *gtkwin; |
4359 | 4387 GtkPositionType pos; |
4388 GtkWidget *testidea; | |
4389 GtkWidget *menubar; | |
4390 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4391 gtkwin = g_malloc0(sizeof(GaimGtkWindow)); |
4359 | 4392 |
4393 win->ui_data = gtkwin; | |
4394 | |
4395 /* Create the window. */ | |
4396 gtkwin->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
4397 gtk_window_set_role(GTK_WINDOW(gtkwin->window), "conversation"); | |
9614 | 4398 gtk_window_set_resizable(GTK_WINDOW(gtkwin->window), TRUE); |
4510
4c394222c732
[gaim-migrate @ 4786]
Christian Hammond <chipx86@chipx86.com>
parents:
4505
diff
changeset
|
4399 gtk_container_set_border_width(GTK_CONTAINER(gtkwin->window), 0); |
9614 | 4400 GTK_WINDOW(gtkwin->window)->allow_shrink = TRUE; |
4359 | 4401 |
4402 g_signal_connect(G_OBJECT(gtkwin->window), "delete_event", | |
4403 G_CALLBACK(close_win_cb), win); | |
4404 | |
4405 /* Create the notebook. */ | |
4406 gtkwin->notebook = gtk_notebook_new(); | |
4407 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4408 pos = gaim_prefs_get_int("/gaim/gtk/conversations/tab_side"); |
4359 | 4409 |
4410 #if 0 | |
4411 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(gtkwin->notebook), 0); | |
4412 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(gtkwin->notebook), 0); | |
4413 #endif | |
4414 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(gtkwin->notebook), pos); | |
4415 gtk_notebook_set_scrollable(GTK_NOTEBOOK(gtkwin->notebook), TRUE); | |
4416 gtk_notebook_popup_enable(GTK_NOTEBOOK(gtkwin->notebook)); | |
4818 | 4417 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gtkwin->notebook), FALSE); |
4418 | |
4359 | 4419 gtk_widget_show(gtkwin->notebook); |
4420 | |
8189 | 4421 g_signal_connect(G_OBJECT(gtkwin->notebook), "switch_page", |
4422 G_CALLBACK(before_switch_conv_cb), win); | |
4359 | 4423 g_signal_connect_after(G_OBJECT(gtkwin->notebook), "switch_page", |
4424 G_CALLBACK(switch_conv_cb), win); | |
4425 | |
4426 /* Setup the tab drag and drop signals. */ | |
4486 | 4427 gtk_widget_add_events(gtkwin->notebook, |
4428 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
4429 g_signal_connect(G_OBJECT(gtkwin->notebook), "button_press_event", | |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
4430 G_CALLBACK(notebook_press_cb), win); |
4486 | 4431 g_signal_connect(G_OBJECT(gtkwin->notebook), "button_release_event", |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
4432 G_CALLBACK(notebook_release_cb), win); |
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
4433 |
4359 | 4434 testidea = gtk_vbox_new(FALSE, 0); |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
4435 |
4359 | 4436 /* Setup the menubar. */ |
4437 menubar = setup_menubar(win); | |
4438 gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
4439 | |
4440 gtk_box_pack_start(GTK_BOX(testidea), gtkwin->notebook, TRUE, TRUE, 0); | |
4441 | |
4442 gtk_container_add(GTK_CONTAINER(gtkwin->window), testidea); | |
4443 | |
4444 gtk_widget_show(testidea); | |
4445 } | |
4446 | |
4447 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4448 gaim_gtk_destroy_window(GaimConvWindow *win) |
4359 | 4449 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4450 GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 4451 |
4452 gtk_widget_destroy(gtkwin->window); | |
4453 | |
4630 | 4454 g_object_unref(G_OBJECT(gtkwin->menu.item_factory)); |
4455 | |
4359 | 4456 g_free(gtkwin); |
4457 win->ui_data = NULL; | |
4458 } | |
4459 | |
4460 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4461 gaim_gtk_show(GaimConvWindow *win) |
4359 | 4462 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4463 GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 4464 |
4465 gtk_widget_show(gtkwin->window); | |
4466 } | |
4467 | |
4468 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4469 gaim_gtk_hide(GaimConvWindow *win) |
4359 | 4470 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4471 GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 4472 |
4473 gtk_widget_hide(gtkwin->window); | |
4474 } | |
4475 | |
4476 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4477 gaim_gtk_raise(GaimConvWindow *win) |
4359 | 4478 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4479 GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 4480 |
9728 | 4481 gtk_widget_show(gtkwin->window); |
4482 gtk_window_deiconify(GTK_WINDOW(gtkwin->window)); | |
4483 gdk_window_raise(gtkwin->window->window); | |
4359 | 4484 } |
4485 | |
4486 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4487 gaim_gtk_flash(GaimConvWindow *win) |
4359 | 4488 { |
4489 #ifdef _WIN32 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4490 GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 4491 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4492 wgaim_conv_im_blink(gtkwin->window); |
4359 | 4493 #endif |
4494 } | |
4495 | |
4496 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4497 gaim_gtk_switch_conversation(GaimConvWindow *win, unsigned int index) |
4359 | 4498 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4499 GaimGtkWindow *gtkwin; |
4359 | 4500 |
4501 gtkwin = GAIM_GTK_WINDOW(win); | |
4502 | |
4503 gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), index); | |
4504 } | |
4505 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4506 static const GtkTargetEntry te[] = |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4507 { |
10145 | 4508 GTK_IMHTML_DND_TARGETS, |
4509 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, GTK_IMHTML_DRAG_NUM}, | |
4510 {"application/x-im-contact", 0, GTK_IMHTML_DRAG_NUM + 1} | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4511 }; |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4512 |
4359 | 4513 static void |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4514 gaim_gtk_add_conversation(GaimConvWindow *win, GaimConversation *conv) |
4359 | 4515 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4516 GaimGtkWindow *gtkwin; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4517 GaimGtkConversation *gtkconv, *focus_gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4518 GaimConversation *focus_conv; |
4359 | 4519 GtkWidget *pane = NULL; |
4520 GtkWidget *tab_cont; | |
6771
8eebba08b44b
[gaim-migrate @ 7308]
Christian Hammond <chipx86@chipx86.com>
parents:
6760
diff
changeset
|
4521 GtkWidget *tabby, *menu_tabby; |
10053
a4ceacb1816d
[gaim-migrate @ 11016]
Luke Schierer <lschiere@pidgin.im>
parents:
10025
diff
changeset
|
4522 GtkWidget *close_image; |
4359 | 4523 gboolean new_ui; |
4383
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
4524 GaimConversationType conv_type; |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
4525 const char *name; |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
4526 |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
4527 name = gaim_conversation_get_name(conv); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
4528 conv_type = gaim_conversation_get_type(conv); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
4529 gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 4530 |
4531 if (conv->ui_data != NULL) { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4532 gtkconv = (GaimGtkConversation *)conv->ui_data; |
4359 | 4533 |
4534 tab_cont = gtkconv->tab_cont; | |
4535 | |
4536 new_ui = FALSE; | |
4537 } | |
4538 else { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4539 gtkconv = g_malloc0(sizeof(GaimGtkConversation)); |
4359 | 4540 conv->ui_data = gtkconv; |
4541 | |
4542 /* Setup some initial variables. */ | |
9749 | 4543 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); |
4359 | 4544 gtkconv->tooltips = gtk_tooltips_new(); |
4545 | |
7879 | 4546 if (conv_type == GAIM_CONV_IM) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4547 gtkconv->u.im = g_malloc0(sizeof(GaimGtkImPane)); |
4359 | 4548 gtkconv->u.im->a_virgin = TRUE; |
4549 | |
4550 pane = setup_im_pane(conv); | |
4551 } | |
7879 | 4552 else if (conv_type == GAIM_CONV_CHAT) { |
4553 gtkconv->u.chat = g_malloc0(sizeof(GaimGtkChatPane)); | |
4554 | |
4555 pane = setup_chat_pane(conv); | |
4556 } | |
4359 | 4557 |
4558 if (pane == NULL) { | |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
4559 if (conv_type == GAIM_CONV_CHAT) g_free(gtkconv->u.chat); |
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
4560 else if (conv_type == GAIM_CONV_IM) g_free(gtkconv->u.im); |
4359 | 4561 |
4562 g_free(gtkconv); | |
4563 conv->ui_data = NULL; | |
4564 | |
4565 return; | |
4566 } | |
4567 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4568 /* Setup drag-and-drop */ |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4569 gtk_drag_dest_set(pane, |
9300 | 4570 GTK_DEST_DEFAULT_MOTION | |
4571 GTK_DEST_DEFAULT_DROP, | |
4572 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4573 GDK_ACTION_COPY); | |
4574 gtk_drag_dest_set(pane, | |
4575 GTK_DEST_DEFAULT_MOTION | | |
4576 GTK_DEST_DEFAULT_DROP, | |
4577 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4578 GDK_ACTION_COPY); | |
4579 gtk_drag_dest_set(gtkconv->imhtml, 0, | |
4580 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4581 GDK_ACTION_COPY); | |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
4582 |
9300 | 4583 gtk_drag_dest_set(gtkconv->entry, 0, |
4584 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4585 GDK_ACTION_COPY); | |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
4586 |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4587 g_signal_connect(G_OBJECT(pane), "drag_data_received", |
9300 | 4588 G_CALLBACK(conv_dnd_recv), conv); |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4589 g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received", |
9300 | 4590 G_CALLBACK(conv_dnd_recv), conv); |
8105 | 4591 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", |
9300 | 4592 G_CALLBACK(conv_dnd_recv), conv); |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
4593 |
4359 | 4594 /* Setup the container for the tab. */ |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4595 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, 6); |
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4596 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), 6); |
4359 | 4597 gtk_container_add(GTK_CONTAINER(tab_cont), pane); |
4598 gtk_widget_show(pane); | |
4599 | |
4600 new_ui = TRUE; | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
4601 |
4359 | 4602 gtkconv->make_sound = TRUE; |
5902
6889b89cab90
[gaim-migrate @ 6334]
Christian Hammond <chipx86@chipx86.com>
parents:
5901
diff
changeset
|
4603 |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
4604 gtkconv->show_formatting_toolbar = gaim_prefs_get_bool( |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
4605 "/gaim/gtk/conversations/show_formatting_toolbar"); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
4606 |
8329
9dd7c75ed433
[gaim-migrate @ 9053]
Christian Hammond <chipx86@chipx86.com>
parents:
8319
diff
changeset
|
4607 if (gtkconv->show_formatting_toolbar) |
9dd7c75ed433
[gaim-migrate @ 9053]
Christian Hammond <chipx86@chipx86.com>
parents:
8319
diff
changeset
|
4608 gtk_widget_show(gtkconv->toolbar); |
10190 | 4609 else |
4610 gtk_widget_hide(gtkconv->toolbar); | |
8329
9dd7c75ed433
[gaim-migrate @ 9053]
Christian Hammond <chipx86@chipx86.com>
parents:
8319
diff
changeset
|
4611 |
9188 | 4612 gtkconv->show_timestamps = gaim_prefs_get_bool( |
4613 "/gaim/gtk/conversations/show_timestamps"); | |
4614 | |
4615 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
4616 gtkconv->show_timestamps); | |
4617 | |
8176 | 4618 g_signal_connect_swapped(G_OBJECT(pane), "focus", |
9080 | 4619 G_CALLBACK(gtk_widget_grab_focus), |
4620 gtkconv->entry); | |
4359 | 4621 } |
4622 | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4623 gtkconv->tabby = tabby = gtk_hbox_new(FALSE, 6); |
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4624 gtkconv->menu_tabby = menu_tabby = gtk_hbox_new(FALSE, 6); |
4359 | 4625 |
4626 /* Close button. */ | |
4627 gtkconv->close = gtk_button_new(); | |
4628 gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), 16, 16); | |
7446
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
4629 gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); |
10053
a4ceacb1816d
[gaim-migrate @ 11016]
Luke Schierer <lschiere@pidgin.im>
parents:
10025
diff
changeset
|
4630 close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); |
a4ceacb1816d
[gaim-migrate @ 11016]
Luke Schierer <lschiere@pidgin.im>
parents:
10025
diff
changeset
|
4631 gtk_widget_show(close_image); |
a4ceacb1816d
[gaim-migrate @ 11016]
Luke Schierer <lschiere@pidgin.im>
parents:
10025
diff
changeset
|
4632 gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image); |
4359 | 4633 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
4634 _("Close conversation"), NULL); |
4359 | 4635 |
4636 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4637 G_CALLBACK(close_conv_cb), conv); |
4359 | 4638 |
7446
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
4639 /* |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
4640 * I love Galeon. They have a fix for that stupid annoying visible |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
4641 * border bug. I love you guys! -- ChipX86 |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
4642 */ |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
4643 g_signal_connect(G_OBJECT(gtkconv->close), "state_changed", |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
4644 G_CALLBACK(tab_close_button_state_changed_cb), NULL); |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
4645 |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
4646 /* Status icon. */ |
6440 | 4647 gtkconv->icon = gtk_image_new(); |
6771
8eebba08b44b
[gaim-migrate @ 7308]
Christian Hammond <chipx86@chipx86.com>
parents:
6760
diff
changeset
|
4648 gtkconv->menu_icon = gtk_image_new(); |
6440 | 4649 update_tab_icon(conv); |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
4650 |
4359 | 4651 /* Tab label. */ |
4652 gtkconv->tab_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
6771
8eebba08b44b
[gaim-migrate @ 7308]
Christian Hammond <chipx86@chipx86.com>
parents:
6760
diff
changeset
|
4653 gtkconv->menu_label = gtk_label_new(gaim_conversation_get_title(conv)); |
4359 | 4654 #if 0 |
4655 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
4656 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
4657 #endif | |
4658 | |
4659 /* Pack it all together. */ | |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
4660 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4661 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_icon, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4662 FALSE, FALSE, 0); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4663 |
8946 | 4664 gtk_widget_show_all(gtkconv->icon); |
4665 gtk_widget_show_all(gtkconv->menu_icon); | |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
4666 |
4359 | 4667 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); |
6771
8eebba08b44b
[gaim-migrate @ 7308]
Christian Hammond <chipx86@chipx86.com>
parents:
6760
diff
changeset
|
4668 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_label, TRUE, TRUE, 0); |
4445 | 4669 gtk_widget_show(gtkconv->tab_label); |
6771
8eebba08b44b
[gaim-migrate @ 7308]
Christian Hammond <chipx86@chipx86.com>
parents:
6760
diff
changeset
|
4670 gtk_widget_show(gtkconv->menu_label); |
8eebba08b44b
[gaim-migrate @ 7308]
Christian Hammond <chipx86@chipx86.com>
parents:
6760
diff
changeset
|
4671 gtk_misc_set_alignment(GTK_MISC(gtkconv->menu_label), 0, 0); |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
4672 |
4445 | 4673 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4674 if (gaim_prefs_get_bool("/gaim/gtk/conversations/close_on_tabs")) |
10053
a4ceacb1816d
[gaim-migrate @ 11016]
Luke Schierer <lschiere@pidgin.im>
parents:
10025
diff
changeset
|
4675 gtk_widget_show(gtkconv->close); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4676 |
4445 | 4677 gtk_widget_show(tabby); |
6771
8eebba08b44b
[gaim-migrate @ 7308]
Christian Hammond <chipx86@chipx86.com>
parents:
6760
diff
changeset
|
4678 gtk_widget_show(menu_tabby); |
4359 | 4679 |
7143 | 4680 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
4681 gaim_gtkconv_update_buddy_icon(conv); | |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
4682 |
9297 | 4683 /* Add this pane to the conversation's notebook. */ |
9606 | 4684 gtk_notebook_append_page_menu(GTK_NOTEBOOK(gtkwin->notebook), tab_cont, tabby, menu_tabby); |
4359 | 4685 |
4686 gtk_widget_show(tab_cont); | |
4687 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4688 if (gaim_conv_window_get_conversation_count(win) == 1) { |
4818 | 4689 /* Er, bug in notebooks? Switch to the page manually. */ |
4359 | 4690 gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), 0); |
4851 | 4691 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4692 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gtkwin->notebook), |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4693 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4694 } |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4695 else |
4818 | 4696 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gtkwin->notebook), TRUE); |
4359 | 4697 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4698 focus_conv = g_list_nth_data(gaim_conv_window_get_conversations(win), |
5204 | 4699 gtk_notebook_get_current_page(GTK_NOTEBOOK(gtkwin->notebook))); |
4700 focus_gtkconv = GAIM_GTK_CONVERSATION(focus_conv); | |
4701 gtk_widget_grab_focus(focus_gtkconv->entry); | |
4359 | 4702 |
4703 if (!new_ui) | |
4704 g_object_unref(gtkconv->tab_cont); | |
4705 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4706 if (gaim_conv_window_get_conversation_count(win) == 1) |
4685 | 4707 g_timeout_add(0, (GSourceFunc)update_send_as_selection, win); |
4359 | 4708 } |
4709 | |
4710 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4711 gaim_gtk_remove_conversation(GaimConvWindow *win, GaimConversation *conv) |
4359 | 4712 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4713 GaimGtkWindow *gtkwin; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4714 GaimGtkConversation *gtkconv; |
4359 | 4715 unsigned int index; |
4818 | 4716 GaimConversationType conv_type; |
4717 | |
4718 conv_type = gaim_conversation_get_type(conv); | |
4359 | 4719 index = gaim_conversation_get_index(conv); |
4720 | |
4721 gtkwin = GAIM_GTK_WINDOW(win); | |
4722 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4723 | |
4724 g_object_ref(gtkconv->tab_cont); | |
4725 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
4726 | |
4727 gtk_notebook_remove_page(GTK_NOTEBOOK(gtkwin->notebook), index); | |
4728 | |
4818 | 4729 /* go back to tabless if need be */ |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4730 if (gaim_conv_window_get_conversation_count(win) <= 2) { |
4818 | 4731 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gtkwin->notebook), |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4732 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); |
4818 | 4733 } |
4734 | |
4735 | |
4359 | 4736 /* If this window is setup with an inactive gc, regenerate the menu. */ |
4818 | 4737 if (conv_type == GAIM_CONV_IM && |
4359 | 4738 gaim_conversation_get_gc(conv) == NULL) { |
4739 | |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
4740 generate_send_as_items(win, conv); |
4359 | 4741 } |
4742 } | |
4743 | |
4744 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4745 gaim_gtk_move_conversation(GaimConvWindow *win, GaimConversation *conv, |
4359 | 4746 unsigned int new_index) |
4747 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4748 GaimGtkWindow *gtkwin; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4749 GaimGtkConversation *gtkconv; |
4359 | 4750 |
4751 gtkwin = GAIM_GTK_WINDOW(win); | |
4752 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4753 | |
4415
c90039137172
[gaim-migrate @ 4688]
Christian Hammond <chipx86@chipx86.com>
parents:
4409
diff
changeset
|
4754 if (new_index > gaim_conversation_get_index(conv)) |
c90039137172
[gaim-migrate @ 4688]
Christian Hammond <chipx86@chipx86.com>
parents:
4409
diff
changeset
|
4755 new_index--; |
c90039137172
[gaim-migrate @ 4688]
Christian Hammond <chipx86@chipx86.com>
parents:
4409
diff
changeset
|
4756 |
4359 | 4757 gtk_notebook_reorder_child(GTK_NOTEBOOK(gtkwin->notebook), |
4758 gtkconv->tab_cont, new_index); | |
4759 } | |
4760 | |
4761 static int | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4762 gaim_gtk_get_active_index(const GaimConvWindow *win) |
4359 | 4763 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4764 GaimGtkWindow *gtkwin; |
5680
71cc0d5376c2
[gaim-migrate @ 6098]
Christian Hammond <chipx86@chipx86.com>
parents:
5678
diff
changeset
|
4765 int index; |
4359 | 4766 |
4767 gtkwin = GAIM_GTK_WINDOW(win); | |
4768 | |
5680
71cc0d5376c2
[gaim-migrate @ 6098]
Christian Hammond <chipx86@chipx86.com>
parents:
5678
diff
changeset
|
4769 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(gtkwin->notebook)); |
71cc0d5376c2
[gaim-migrate @ 6098]
Christian Hammond <chipx86@chipx86.com>
parents:
5678
diff
changeset
|
4770 |
71cc0d5376c2
[gaim-migrate @ 6098]
Christian Hammond <chipx86@chipx86.com>
parents:
5678
diff
changeset
|
4771 /* |
71cc0d5376c2
[gaim-migrate @ 6098]
Christian Hammond <chipx86@chipx86.com>
parents:
5678
diff
changeset
|
4772 * A fix, because the first conversation may be active, but not |
71cc0d5376c2
[gaim-migrate @ 6098]
Christian Hammond <chipx86@chipx86.com>
parents:
5678
diff
changeset
|
4773 * appear in the notebook just yet. -- ChipX86 |
71cc0d5376c2
[gaim-migrate @ 6098]
Christian Hammond <chipx86@chipx86.com>
parents:
5678
diff
changeset
|
4774 */ |
71cc0d5376c2
[gaim-migrate @ 6098]
Christian Hammond <chipx86@chipx86.com>
parents:
5678
diff
changeset
|
4775 return (index == -1 ? 0 : index); |
4359 | 4776 } |
4777 | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4778 static gboolean |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4779 gaim_gtk_has_focus(GaimConvWindow *win) |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4780 { |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4781 GaimGtkWindow *gtkwin; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4782 gboolean has_focus = FALSE; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4783 |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4784 gtkwin = GAIM_GTK_WINDOW(win); |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4785 g_object_get(G_OBJECT(gtkwin->window), "has-toplevel-focus", &has_focus, NULL); |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4786 |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4787 return has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4788 } |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4789 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4790 static GaimConvWindowUiOps window_ui_ops = |
4359 | 4791 { |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
4792 gaim_gtk_conversations_get_conv_ui_ops, |
4359 | 4793 gaim_gtk_new_window, |
4794 gaim_gtk_destroy_window, | |
4795 gaim_gtk_show, | |
4796 gaim_gtk_hide, | |
4797 gaim_gtk_raise, | |
4798 gaim_gtk_flash, | |
4799 gaim_gtk_switch_conversation, | |
4800 gaim_gtk_add_conversation, | |
4801 gaim_gtk_remove_conversation, | |
4802 gaim_gtk_move_conversation, | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4803 gaim_gtk_get_active_index, |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4804 gaim_gtk_has_focus |
4359 | 4805 }; |
4806 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4807 GaimConvWindowUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
4808 gaim_gtk_conversations_get_win_ui_ops(void) |
4359 | 4809 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
4810 return &window_ui_ops; |
4359 | 4811 } |
4812 | |
4813 /************************************************************************** | |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
4814 * Conversation UI operations |
4359 | 4815 **************************************************************************/ |
4816 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4817 gaim_gtkconv_destroy(GaimConversation *conv) |
4359 | 4818 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4819 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4359 | 4820 |
9504 | 4821 /* If the "Save Conversation" or "Save Icon" dialogs are open then close them */ |
4822 gaim_request_close_with_handle(conv); | |
4359 | 4823 |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4824 gtk_widget_destroy(gtkconv->tab_cont); |
4892 | 4825 g_object_unref(gtkconv->tab_cont); |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4826 |
4359 | 4827 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { |
4755 | 4828 if (gtkconv->u.im->icon_timer != 0) |
4829 g_source_remove(gtkconv->u.im->icon_timer); | |
4830 | |
4359 | 4831 if (gtkconv->u.im->anim != NULL) |
4793 | 4832 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); |
4359 | 4833 |
4834 g_free(gtkconv->u.im); | |
4835 } | |
4836 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { | |
4837 g_free(gtkconv->u.chat); | |
4838 } | |
4839 | |
4633 | 4840 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
4841 | |
4359 | 4842 g_free(gtkconv); |
4843 } | |
4844 | |
4845 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4846 gaim_gtkconv_write_im(GaimConversation *conv, const char *who, |
6982 | 4847 const char *message, GaimMessageFlags flags, |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4848 time_t mtime) |
4359 | 4849 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4850 GaimGtkConversation *gtkconv; |
8630 | 4851 GaimConvWindow *gaimwin; |
4852 GaimGtkWindow *gtkwin; | |
4853 gboolean has_focus; | |
4359 | 4854 |
4855 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
8630 | 4856 gaimwin = gaim_conversation_get_window(conv); |
4857 gtkwin = GAIM_GTK_WINDOW(gaimwin); | |
4858 | |
4859 g_object_get(G_OBJECT(gtkwin->window), "has-toplevel-focus", &has_focus, NULL); | |
4359 | 4860 |
6621 | 4861 if (!(flags & GAIM_MESSAGE_NO_LOG) && |
9301 | 4862 gaim_prefs_get_bool("/gaim/gtk/conversations/im/raise_on_events")) { |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4863 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4864 gaim_conv_window_raise(gaim_conversation_get_window(conv)); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4865 } |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4866 |
4382
76223649765b
[gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents:
4378
diff
changeset
|
4867 /* Play a sound, if specified in prefs. */ |
8630 | 4868 if (gtkconv->make_sound && !((gaim_conv_window_get_active_conversation(gaimwin) == conv) && |
8633 | 4869 !gaim_prefs_get_bool("/gaim/gtk/sound/conv_focus") && has_focus)) { |
6621 | 4870 if (flags & GAIM_MESSAGE_RECV) { |
4359 | 4871 if (gtkconv->u.im->a_virgin && |
5820 | 4872 gaim_prefs_get_bool("/gaim/gtk/sound/enabled/first_im_recv")) { |
4359 | 4873 |
4561 | 4874 gaim_sound_play_event(GAIM_SOUND_FIRST_RECEIVE); |
4359 | 4875 } |
4876 else | |
4561 | 4877 gaim_sound_play_event(GAIM_SOUND_RECEIVE); |
4359 | 4878 } |
4879 else { | |
4561 | 4880 gaim_sound_play_event(GAIM_SOUND_SEND); |
4359 | 4881 } |
4882 } | |
4883 | |
4884 gtkconv->u.im->a_virgin = FALSE; | |
4885 | |
6982 | 4886 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4887 } |
4888 | |
4889 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4890 gaim_gtkconv_write_chat(GaimConversation *conv, const char *who, |
6621 | 4891 const char *message, GaimMessageFlags flags, time_t mtime) |
4359 | 4892 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4893 GaimGtkConversation *gtkconv; |
8630 | 4894 GaimConvWindow *gaimwin; |
4895 GaimGtkWindow *gtkwin; | |
4896 gboolean has_focus; | |
4359 | 4897 |
4898 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
8630 | 4899 gaimwin = gaim_conversation_get_window(conv); |
4900 gtkwin = GAIM_GTK_WINDOW(gaimwin); | |
4901 | |
4902 g_object_get(G_OBJECT(gtkwin->window), "has-toplevel-focus", &has_focus, NULL); | |
4359 | 4903 |
4382
76223649765b
[gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents:
4378
diff
changeset
|
4904 /* Play a sound, if specified in prefs. */ |
8630 | 4905 if (gtkconv->make_sound && !((gaim_conv_window_get_active_conversation(gaimwin) == conv) && |
9704 | 4906 !gaim_prefs_get_bool("/gaim/gtk/sound/conv_focus") && has_focus) && |
4907 !(flags & GAIM_MESSAGE_DELAYED) && | |
4908 !(flags & GAIM_MESSAGE_SYSTEM)) { | |
4909 | |
6621 | 4910 if (!(flags & GAIM_MESSAGE_WHISPER) && (flags & GAIM_MESSAGE_SEND)) |
4561 | 4911 gaim_sound_play_event(GAIM_SOUND_CHAT_YOU_SAY); |
9704 | 4912 else if (flags & GAIM_MESSAGE_RECV) { |
6621 | 4913 if ((flags & GAIM_MESSAGE_NICK) && |
9584 | 4914 gaim_prefs_get_bool("/gaim/gtk/sound/enabled/nick_said")) { |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4915 |
4561 | 4916 gaim_sound_play_event(GAIM_SOUND_CHAT_NICK); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4917 } |
4359 | 4918 else |
4561 | 4919 gaim_sound_play_event(GAIM_SOUND_CHAT_SAY); |
4359 | 4920 } |
4921 } | |
4922 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4923 if (gaim_prefs_get_bool("/gaim/gtk/conversations/chat/color_nicks")) |
6621 | 4924 flags |= GAIM_MESSAGE_COLORIZE; |
4359 | 4925 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4926 /* Raise the window, if specified in prefs. */ |
6621 | 4927 if (!(flags & GAIM_MESSAGE_NO_LOG) && |
9150 | 4928 /* we may want to change this */ |
9301 | 4929 gaim_prefs_get_bool("/gaim/gtk/conversations/chat/raise_on_events")) { |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4930 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4931 gaim_conv_window_raise(gaim_conversation_get_window(conv)); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4932 } |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4933 |
6982 | 4934 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4935 } |
4936 | |
4937 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4938 gaim_gtkconv_write_conv(GaimConversation *conv, const char *who, |
6982 | 4939 const char *message, GaimMessageFlags flags, |
4359 | 4940 time_t mtime) |
4941 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4942 GaimGtkConversation *gtkconv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4943 GaimConvWindow *win; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
4944 GaimConnection *gc; |
4359 | 4945 int gtk_font_options = 0; |
7440 | 4946 char buf[BUF_LONG]; |
4359 | 4947 char buf2[BUF_LONG]; |
4948 char mdate[64]; | |
4949 char color[10]; | |
4950 char *str; | |
4951 char *with_font_tag; | |
4896 | 4952 char *sml_attrib = NULL; |
6982 | 4953 size_t length = strlen(message) + 1; |
4895 | 4954 |
4359 | 4955 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4956 gc = gaim_conversation_get_gc(conv); | |
4957 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4958 win = gaim_conversation_get_window(conv); |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4959 |
9301 | 4960 if (!(flags & GAIM_MESSAGE_NO_LOG) && |
4961 ((gaim_conversation_get_type(conv) == GAIM_CONV_CHAT && | |
4962 gaim_prefs_get_bool("/gaim/gtk/conversations/chat/raise_on_events")) || | |
4963 (gaim_conversation_get_type(conv) == GAIM_CONV_IM && | |
4964 gaim_prefs_get_bool("/gaim/gtk/conversations/im/raise_on_events")))) { | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4965 gaim_conv_window_show(win); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4966 } |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4967 |
8677 | 4968 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) |
4969 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", 0); | |
4970 | |
5133 | 4971 if(time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ |
4972 strftime(mdate, sizeof(mdate), "%Y-%m-%d %H:%M:%S", localtime(&mtime)); | |
4973 else | |
4974 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); | |
4359 | 4975 |
4896 | 4976 if(gc) |
9699 | 4977 sml_attrib = g_strdup_printf("sml=\"%s\"", |
4978 gaim_account_get_protocol_name(conv->account)); | |
7440 | 4979 |
4359 | 4980 gtk_font_options ^= GTK_IMHTML_NO_COMMENTS; |
4981 | |
9049 | 4982 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_colors")) |
4983 gtk_font_options ^= GTK_IMHTML_NO_COLOURS; | |
4984 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_fonts")) | |
4985 gtk_font_options ^= GTK_IMHTML_NO_FONTS; | |
4986 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_font_sizes")) | |
4987 gtk_font_options ^= GTK_IMHTML_NO_SIZES; | |
4359 | 4988 |
7956 | 4989 /* this is gonna crash one day, I can feel it. */ |
4990 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(conv->account)))->options & | |
7431 | 4991 OPT_PROTO_USE_POINTSIZE) { |
5367 | 4992 gtk_font_options ^= GTK_IMHTML_USE_POINTSIZE; |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4993 } |
4359 | 4994 |
6621 | 4995 if (flags & GAIM_MESSAGE_SYSTEM) { |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4996 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")) |
8380 | 4997 g_snprintf(buf, BUF_LONG, "<FONT SIZE=\"2\">(%s)</FONT> <B>%s</B>", |
7431 | 4998 mdate, message); |
4359 | 4999 else |
5000 g_snprintf(buf, BUF_LONG, "<B>%s</B>", message); | |
7440 | 5001 |
4359 | 5002 g_snprintf(buf2, sizeof(buf2), |
8690 | 5003 "<FONT %s><FONT SIZE=\"2\"><!--(%s) --></FONT><B>%s</B></FONT>", |
7850 | 5004 sml_attrib, mdate, message); |
7440 | 5005 |
8962 | 5006 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
7440 | 5007 |
7583 | 5008 /* Add the message to a conversations scrollback buffer */ |
5009 conv->history = g_string_append(conv->history, buf); | |
5010 conv->history = g_string_append(conv->history, "<BR>\n"); | |
7440 | 5011 |
8722 | 5012 } else if (flags & GAIM_MESSAGE_ERROR) { |
5013 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")) | |
9627 | 5014 g_snprintf(buf, BUF_LONG, "<FONT COLOR=\"#ff0000\"><FONT SIZE=\"2\">(%s)</FONT> <B>%s</B></FONT>", |
8722 | 5015 mdate, message); |
5016 else | |
5017 g_snprintf(buf, BUF_LONG, "<FONT COLOR=\"#ff0000\"><B>%s</B></FONT>", message); | |
9554 | 5018 |
8722 | 5019 g_snprintf(buf2, sizeof(buf2), |
9627 | 5020 "<FONT COLOR=\"#ff0000\"><FONT %s><FONT SIZE=\"2\"><!--(%s) --></FONT><B>%s</B></FONT></FONT>", |
8722 | 5021 sml_attrib, mdate, message); |
9554 | 5022 |
8962 | 5023 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
5024 | |
8722 | 5025 /* Add the message to a conversations scrollback buffer */ |
5026 conv->history = g_string_append(conv->history, buf); | |
5027 conv->history = g_string_append(conv->history, "<BR>\n"); | |
7431 | 5028 } else if (flags & GAIM_MESSAGE_NO_LOG) { |
4359 | 5029 g_snprintf(buf, BUF_LONG, |
8690 | 5030 "<B><FONT %s COLOR=\"#777777\">%s</FONT></B>", |
7850 | 5031 sml_attrib, message); |
7440 | 5032 |
8962 | 5033 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf, 0); |
4359 | 5034 } |
5035 else { | |
4895 | 5036 char *new_message = g_memdup(message, length); |
9613 | 5037 char *who_escaped = (who ? g_markup_escape_text(who, strlen(who)) : g_strdup("")); |
7440 | 5038 |
6621 | 5039 if (flags & GAIM_MESSAGE_WHISPER) { |
4359 | 5040 str = g_malloc(1024); |
7440 | 5041 |
4359 | 5042 /* If we're whispering, it's not an autoresponse. */ |
7564 | 5043 if (gaim_message_meify(new_message, length)) { |
8908 | 5044 g_snprintf(str, 1024, "***%s", who_escaped); |
4359 | 5045 strcpy(color, "#6C2585"); |
5046 } | |
5047 else { | |
8908 | 5048 g_snprintf(str, 1024, "*%s*:", who_escaped); |
4359 | 5049 strcpy(color, "#00FF00"); |
5050 } | |
7440 | 5051 } |
4359 | 5052 else { |
7564 | 5053 if (gaim_message_meify(new_message, length)) { |
4359 | 5054 str = g_malloc(1024); |
7440 | 5055 |
6621 | 5056 if (flags & GAIM_MESSAGE_AUTO_RESP) |
8908 | 5057 g_snprintf(str, 1024, "%s ***%s", AUTO_RESPONSE, who_escaped); |
4359 | 5058 else |
8908 | 5059 g_snprintf(str, 1024, "***%s", who_escaped); |
7440 | 5060 |
6621 | 5061 if (flags & GAIM_MESSAGE_NICK) |
4359 | 5062 strcpy(color, "#AF7F00"); |
5063 else | |
5064 strcpy(color, "#062585"); | |
5065 } | |
5066 else { | |
5067 str = g_malloc(1024); | |
6621 | 5068 if (flags & GAIM_MESSAGE_AUTO_RESP) |
8908 | 5069 g_snprintf(str, 1024, "%s %s", who_escaped, AUTO_RESPONSE); |
4359 | 5070 else |
8908 | 5071 g_snprintf(str, 1024, "%s:", who_escaped); |
6621 | 5072 if (flags & GAIM_MESSAGE_NICK) |
4359 | 5073 strcpy(color, "#AF7F00"); |
6621 | 5074 else if (flags & GAIM_MESSAGE_RECV) { |
10108 | 5075 if (flags & GAIM_MESSAGE_COLORIZE) { |
5076 GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml); | |
5077 GdkColor col = nick_colors[g_str_hash(who) % NUM_NICK_COLORS]; | |
5078 float scale = ((1-(LUMINANCE(style->base[GTK_STATE_NORMAL]) / LUMINANCE(style->white))) * | |
5079 (LUMINANCE(style->white)/MAX(MAX(col.red, col.blue), col.green))); | |
5080 if (scale > 1) { /* The colors are chosen to look fine on white; we should never have to darken */ | |
5081 col.red = col.red * scale; | |
5082 col.green = col.green * scale; | |
5083 col.blue = col.blue * scale; | |
5084 } | |
5085 | |
5086 g_snprintf(color, sizeof(color), "#%02X%02X%02X", | |
5087 col.red >> 8, col.green >> 8, col.blue >> 8); | |
5088 } else | |
7854 | 5089 strcpy(color, RECV_COLOR); |
4359 | 5090 } |
6621 | 5091 else if (flags & GAIM_MESSAGE_SEND) |
7854 | 5092 strcpy(color, SEND_COLOR); |
4359 | 5093 } |
8908 | 5094 |
5095 if(who_escaped) | |
5096 g_free(who_escaped); | |
4359 | 5097 } |
7440 | 5098 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5099 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")) |
4359 | 5100 g_snprintf(buf, BUF_LONG, |
8380 | 5101 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\">(%s)</FONT> " |
7431 | 5102 "<B>%s</B></FONT> ", color, |
5103 sml_attrib ? sml_attrib : "", mdate, str); | |
4359 | 5104 else |
5105 g_snprintf(buf, BUF_LONG, | |
7431 | 5106 "<FONT COLOR=\"%s\" %s><B>%s</B></FONT> ", color, |
5107 sml_attrib ? sml_attrib : "", str); | |
7440 | 5108 |
4359 | 5109 g_snprintf(buf2, BUF_LONG, |
8380 | 5110 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
7431 | 5111 "<B>%s</B></FONT> ", |
5112 color, sml_attrib ? sml_attrib : "", mdate, str); | |
7440 | 5113 |
4359 | 5114 g_free(str); |
5115 | |
8962 | 5116 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), |
5117 buf2, 0); | |
4359 | 5118 |
4895 | 5119 if(gc){ |
4896 | 5120 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : ""); |
4895 | 5121 char *post = "</font>"; |
5122 int pre_len = strlen(pre); | |
5123 int post_len = strlen(post); | |
7440 | 5124 |
4895 | 5125 with_font_tag = g_malloc(length + pre_len + post_len + 1); |
7440 | 5126 |
4895 | 5127 strcpy(with_font_tag, pre); |
5128 memcpy(with_font_tag + pre_len, new_message, length); | |
5129 strcpy(with_font_tag + pre_len + length, post); | |
7440 | 5130 |
4895 | 5131 length += pre_len + post_len; |
5132 g_free(pre); | |
5133 } | |
4608 | 5134 else |
4895 | 5135 with_font_tag = g_memdup(new_message, length); |
7440 | 5136 |
8962 | 5137 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), |
5138 with_font_tag, gtk_font_options); | |
7440 | 5139 |
8557 | 5140 conv->history = g_string_append(conv->history, buf); |
5141 conv->history = g_string_append(conv->history, new_message); | |
5142 conv->history = g_string_append(conv->history, "<BR>\n"); | |
7440 | 5143 |
5144 g_free(with_font_tag); | |
7447 | 5145 g_free(new_message); |
7440 | 5146 } |
5147 | |
6062 | 5148 |
5012 | 5149 if(sml_attrib) |
5150 g_free(sml_attrib); | |
4359 | 5151 } |
5152 | |
5153 static void | |
9846 | 5154 gaim_gtkconv_chat_add_user(GaimConversation *conv, const char *user, gboolean new_arrival) |
4359 | 5155 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5156 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5157 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5158 GaimGtkChatPane *gtkchat; |
4359 | 5159 char tmp[BUF_LONG]; |
5160 int num_users; | |
5161 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5162 chat = GAIM_CONV_CHAT(conv); |
4359 | 5163 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5164 gtkchat = gtkconv->u.chat; | |
5165 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5166 num_users = g_list_length(gaim_conv_chat_get_users(chat)); |
4359 | 5167 |
5168 g_snprintf(tmp, sizeof(tmp), | |
5169 ngettext("%d person in room", "%d people in room", | |
5170 num_users), | |
5171 num_users); | |
5172 | |
5173 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); | |
5174 | |
9846 | 5175 if (gtkconv->make_sound && new_arrival) |
4561 | 5176 gaim_sound_play_event(GAIM_SOUND_CHAT_JOIN); |
4359 | 5177 |
9554 | 5178 add_chat_buddy_common(conv, user); |
4359 | 5179 } |
5180 | |
5181 static void | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5182 gaim_gtkconv_chat_add_users(GaimConversation *conv, GList *users) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5183 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5184 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5185 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5186 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5187 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5188 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5189 int num_users; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5190 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5191 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5192 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5193 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5194 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5195 num_users = g_list_length(gaim_conv_chat_get_users(chat)); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5196 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5197 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5198 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5199 num_users), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5200 num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5201 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5202 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5203 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5204 for (l = users; l != NULL; l = l->next) { |
9554 | 5205 add_chat_buddy_common(conv, (char *)l->data); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5206 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5207 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5208 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5209 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5210 gaim_gtkconv_chat_rename_user(GaimConversation *conv, const char *old_name, |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5211 const char *new_name) |
4359 | 5212 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5213 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5214 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5215 GaimGtkChatPane *gtkchat; |
4359 | 5216 GtkTreeIter iter; |
5217 GtkTreeModel *model; | |
5218 int f = 1; | |
5219 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5220 chat = GAIM_CONV_CHAT(conv); |
4359 | 5221 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5222 gtkchat = gtkconv->u.chat; | |
5223 | |
9554 | 5224 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
5225 | |
5226 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
5227 return; | |
5228 | |
5229 while (f != 0) { | |
5230 char *val; | |
5231 | |
5232 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
5233 | |
5234 if (!gaim_utf8_strcasecmp(old_name, val)) { | |
5235 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
5236 g_free(val); | |
4359 | 5237 break; |
5238 } | |
9554 | 5239 |
5240 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5241 | |
5242 g_free(val); | |
4359 | 5243 } |
5244 | |
9554 | 5245 if (!gaim_conv_chat_find_user(chat, old_name)) |
4359 | 5246 return; |
5247 | |
9554 | 5248 add_chat_buddy_common(conv, new_name); |
4359 | 5249 } |
5250 | |
5251 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5252 gaim_gtkconv_chat_remove_user(GaimConversation *conv, const char *user) |
4359 | 5253 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5254 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5255 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5256 GaimGtkChatPane *gtkchat; |
4359 | 5257 GtkTreeIter iter; |
5258 GtkTreeModel *model; | |
5259 char tmp[BUF_LONG]; | |
5260 int num_users; | |
5261 int f = 1; | |
5262 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5263 chat = GAIM_CONV_CHAT(conv); |
4359 | 5264 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5265 gtkchat = gtkconv->u.chat; | |
5266 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5267 num_users = g_list_length(gaim_conv_chat_get_users(chat)) - 1; |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5268 |
9554 | 5269 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
5270 | |
5271 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
5272 return; | |
5273 | |
5274 while (f != 0) { | |
5275 char *val; | |
5276 | |
5277 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
5278 | |
5279 if (!gaim_utf8_strcasecmp(user, val)) { | |
5280 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
5281 g_free(val); | |
4359 | 5282 break; |
5283 } | |
9554 | 5284 |
5285 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5286 | |
5287 g_free(val); | |
4359 | 5288 } |
5289 | |
9554 | 5290 if (!gaim_conv_chat_find_user(chat, user)) |
4359 | 5291 return; |
5292 | |
5293 g_snprintf(tmp, sizeof(tmp), | |
9554 | 5294 ngettext("%d person in room", "%d people in room", |
5295 num_users), num_users); | |
4359 | 5296 |
5297 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); | |
5298 | |
5299 if (gtkconv->make_sound) | |
4561 | 5300 gaim_sound_play_event(GAIM_SOUND_CHAT_LEAVE); |
4359 | 5301 } |
5302 | |
5303 static void | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5304 gaim_gtkconv_chat_remove_users(GaimConversation *conv, GList *users) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5305 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5306 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5307 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5308 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5309 GtkTreeIter iter; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5310 GtkTreeModel *model; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5311 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5312 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5313 int num_users; |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5314 gboolean f; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5315 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5316 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5317 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5318 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5319 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5320 num_users = g_list_length(gaim_conv_chat_get_users(chat)) - |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5321 g_list_length(users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5322 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5323 for (l = users; l != NULL; l = l->next) { |
9554 | 5324 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
5325 | |
5326 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), | |
5327 &iter)) | |
5328 continue; | |
5329 | |
5330 do { | |
5331 char *val; | |
5332 | |
5333 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, | |
5334 CHAT_USERS_NAME_COLUMN, &val, -1); | |
5335 | |
9696 | 5336 if (!gaim_utf8_strcasecmp((char *)l->data, val)) { |
5337 #if GTK_CHECK_VERSION(2,2,0) | |
9554 | 5338 f = gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
9696 | 5339 #else |
5340 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
5341 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5342 #endif | |
5343 } | |
9554 | 5344 else |
5345 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5346 | |
5347 g_free(val); | |
5348 } while (f); | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5349 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5350 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5351 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5352 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5353 num_users), num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5354 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5355 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5356 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5357 |
9554 | 5358 static void |
5359 gaim_gtkconv_chat_update_user(GaimConversation *conv, const char *user) | |
5360 { | |
5361 GaimConvChat *chat; | |
5362 GaimGtkConversation *gtkconv; | |
5363 GaimGtkChatPane *gtkchat; | |
5364 GtkTreeIter iter; | |
5365 GtkTreeModel *model; | |
5366 int f = 1; | |
5367 | |
5368 chat = GAIM_CONV_CHAT(conv); | |
5369 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5370 gtkchat = gtkconv->u.chat; | |
5371 | |
5372 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
5373 | |
5374 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
5375 return; | |
5376 | |
5377 while (f != 0) { | |
5378 char *val; | |
5379 | |
5380 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
5381 | |
5382 if (!gaim_utf8_strcasecmp(user, val)) { | |
5383 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
5384 g_free(val); | |
5385 break; | |
5386 } | |
5387 | |
5388 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5389 | |
5390 g_free(val); | |
5391 } | |
5392 | |
5393 if (!gaim_conv_chat_find_user(chat, user)) | |
5394 return; | |
5395 | |
5396 add_chat_buddy_common(conv, user); | |
5397 } | |
5398 | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5399 static gboolean |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5400 gaim_gtkconv_has_focus(GaimConversation *conv) |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5401 { |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5402 GaimConvWindow *win; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5403 GaimGtkWindow *gtkwin; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5404 gboolean has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5405 |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5406 win = gaim_conversation_get_window(conv); |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5407 gtkwin = GAIM_GTK_WINDOW(win); |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5408 |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5409 g_object_get(G_OBJECT(gtkwin->window), "has-toplevel-focus", &has_focus, NULL); |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5410 |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5411 return has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5412 } |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5413 |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5414 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5415 gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type) |
4359 | 5416 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5417 GaimConvWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5418 GaimGtkWindow *gtkwin; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5419 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5420 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5421 GaimConvChat *chat; |
4359 | 5422 |
10116 | 5423 g_return_if_fail(conv != NULL); |
5424 | |
4359 | 5425 win = gaim_conversation_get_window(conv); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5426 gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 5427 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5428 | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5429 if (type == GAIM_CONV_UPDATE_ACCOUNT) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5430 { |
4359 | 5431 gaim_conversation_autoset_title(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5432 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5433 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5434 gaim_gtkconv_update_buddy_icon(conv); |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5435 |
4359 | 5436 gaim_gtkconv_update_buttons_by_protocol(conv); |
5437 | |
4685 | 5438 g_timeout_add(0, (GSourceFunc)update_send_as_selection, win); |
4359 | 5439 |
5440 smiley_themeize(gtkconv->imhtml); | |
6394 | 5441 |
6395 | 5442 update_tab_icon(conv); |
4359 | 5443 } |
5444 else if (type == GAIM_CONV_UPDATE_TYPING || | |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5445 type == GAIM_CONV_UPDATE_UNSEEN || |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5446 type == GAIM_CONV_UPDATE_TITLE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5447 { |
9472 | 5448 char *title; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5449 GaimConvIm *im = NULL; |
9472 | 5450 GaimConnection *gc = gaim_conversation_get_gc(conv); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5451 char color[8]; |
4736 | 5452 |
4359 | 5453 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5454 im = GAIM_CONV_IM(conv); |
4359 | 5455 |
9472 | 5456 if (!gc || ((gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) |
5457 && gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)))) | |
5458 title = g_strdup_printf("(%s)", gaim_conversation_get_title(conv)); | |
5459 | |
5460 else | |
5461 title = g_strdup(gaim_conversation_get_title(conv)); | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5462 |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5463 *color = '\0'; |
4359 | 5464 |
5465 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | |
5466 gtk_widget_realize(gtkconv->tab_label); | |
5467 | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5468 if (im != NULL && gaim_conv_im_get_typing_state(im) == GAIM_TYPING) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5469 { |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5470 strcpy(color, "#47A046"); |
4359 | 5471 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5472 else if (im != NULL && gaim_conv_im_get_typing_state(im) == GAIM_TYPED) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5473 { |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5474 strcpy(color, "#D1940C"); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5475 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5476 else if (gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_NICK) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5477 { |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5478 strcpy(color, "#314E6C"); |
4359 | 5479 } |
8252 | 5480 else if (gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_TEXT) |
5481 { | |
5482 strcpy(color, "#DF421E"); | |
5483 } | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5484 else if (gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_EVENT) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5485 { |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5486 strcpy(color, "#868272"); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5487 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5488 |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5489 if (*color != '\0') |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5490 { |
8536 | 5491 char *html_title,*label; |
5492 | |
5493 html_title = gaim_escape_html(title); | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5494 |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5495 label = g_strdup_printf("<span color=\"%s\">%s</span>", |
8536 | 5496 color, html_title); |
5497 g_free(html_title); | |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5498 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); |
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5499 g_free(label); |
4359 | 5500 } |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5501 else |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5502 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5503 |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5504 if (conv == gaim_conv_window_get_active_conversation(win)) |
4736 | 5505 update_typing_icon(conv); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5506 |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5507 if (type == GAIM_CONV_UPDATE_TITLE) { |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5508 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5509 if (conv == gaim_conv_window_get_active_conversation(win)) |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5510 gtk_window_set_title(GTK_WINDOW(gtkwin->window), title); |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5511 } |
9472 | 5512 |
5513 g_free(title); | |
4359 | 5514 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5515 else if (type == GAIM_CONV_UPDATE_TOPIC) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5516 { |
7154 | 5517 const char *topic; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5518 chat = GAIM_CONV_CHAT(conv); |
4359 | 5519 gtkchat = gtkconv->u.chat; |
5520 | |
7154 | 5521 topic = gaim_conv_chat_get_topic(chat); |
5522 | |
9554 | 5523 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : ""); |
7154 | 5524 gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->topic_text, |
9554 | 5525 topic ? topic : "", NULL); |
4359 | 5526 } |
5527 else if (type == GAIM_CONV_ACCOUNT_ONLINE || | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5528 type == GAIM_CONV_ACCOUNT_OFFLINE) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5529 { |
7929 | 5530 gray_stuff_out(gaim_conv_window_get_active_conversation(win)); |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
5531 generate_send_as_items(win, NULL); |
8946 | 5532 update_tab_icon(conv); |
9472 | 5533 gaim_conversation_autoset_title(conv); |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
5534 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5535 else if (type == GAIM_CONV_UPDATE_AWAY) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5536 { |
8946 | 5537 update_tab_icon(conv); |
4359 | 5538 } |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5539 else if (type == GAIM_CONV_UPDATE_ADD || type == GAIM_CONV_UPDATE_REMOVE || |
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5540 type == GAIM_CONV_UPDATE_CHATLEFT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5541 { |
9472 | 5542 gaim_conversation_autoset_title(conv); |
7929 | 5543 gray_stuff_out(conv); |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
5544 } |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5545 else if (type == GAIM_CONV_UPDATE_ICON) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5546 { |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5547 gaim_gtkconv_update_buddy_icon(conv); |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5548 } |
4359 | 5549 } |
5550 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5551 static GaimConversationUiOps conversation_ui_ops = |
4359 | 5552 { |
5553 gaim_gtkconv_destroy, /* destroy_conversation */ | |
5554 gaim_gtkconv_write_chat, /* write_chat */ | |
5555 gaim_gtkconv_write_im, /* write_im */ | |
5556 gaim_gtkconv_write_conv, /* write_conv */ | |
5557 gaim_gtkconv_chat_add_user, /* chat_add_user */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5558 gaim_gtkconv_chat_add_users, /* chat_add_users */ |
4359 | 5559 gaim_gtkconv_chat_rename_user, /* chat_rename_user */ |
5560 gaim_gtkconv_chat_remove_user, /* chat_remove_user */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5561 gaim_gtkconv_chat_remove_users, /* chat_remove_users */ |
9554 | 5562 gaim_gtkconv_chat_update_user, /* chat_update_user */ |
4359 | 5563 NULL, /* update_progress */ |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5564 gaim_gtkconv_has_focus, /* has_focus */ |
4359 | 5565 gaim_gtkconv_updated /* updated */ |
5566 }; | |
5567 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5568 GaimConversationUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5569 gaim_gtk_conversations_get_conv_ui_ops(void) |
4359 | 5570 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
5571 return &conversation_ui_ops; |
4359 | 5572 } |
5573 | |
5574 /************************************************************************** | |
5575 * Public conversation utility functions | |
5576 **************************************************************************/ | |
5577 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5578 gaim_gtkconv_update_buddy_icon(GaimConversation *conv) |
4359 | 5579 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5580 GaimGtkConversation *gtkconv; |
7143 | 5581 GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv)); |
4359 | 5582 |
5583 char filename[256]; | |
5584 FILE *file; | |
5585 GError *err = NULL; | |
5586 | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5587 const void *data; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5588 size_t len; |
4359 | 5589 |
5590 GdkPixbuf *buf; | |
5591 | |
5592 GtkWidget *event; | |
5593 GtkWidget *frame; | |
5594 GdkPixbuf *scale; | |
5595 GdkPixmap *pm; | |
5596 GdkBitmap *bm; | |
9318 | 5597 int scale_width, scale_height; |
9332 | 5598 GtkRequisition requisition; |
9318 | 5599 |
5600 GaimAccount *account; | |
5601 GaimPluginProtocolInfo *prpl_info = NULL; | |
4359 | 5602 |
8821 | 5603 GaimButtonStyle button_type; |
5604 | |
9324 | 5605 GaimBuddyIcon *icon; |
5606 | |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5607 g_return_if_fail(conv != NULL); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5608 g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv)); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5609 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_IM); |
4359 | 5610 |
5611 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10175 | 5612 |
9687 | 5613 if (!gtkconv->u.im->show_icon) |
5614 return; | |
5615 | |
9318 | 5616 account = gaim_conversation_get_account(conv); |
5617 if(account && account->gc) | |
5618 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
4359 | 5619 |
9845 | 5620 /* Remove the current icon stuff */ |
9885 | 5621 if (gtkconv->u.im->icon_container != NULL) |
5622 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
5623 gtkconv->u.im->icon_container = NULL; | |
9845 | 5624 |
5625 if (gtkconv->u.im->anim != NULL) | |
5626 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
5627 | |
9887 | 5628 gtkconv->u.im->anim = NULL; |
5629 | |
9845 | 5630 if (gtkconv->u.im->icon_timer != 0) |
5631 g_source_remove(gtkconv->u.im->icon_timer); | |
5632 | |
5633 gtkconv->u.im->icon_timer = 0; | |
5634 | |
5635 if (gtkconv->u.im->iter != NULL) | |
5636 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4359 | 5637 |
10116 | 5638 gtkconv->u.im->iter = NULL; |
5639 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5640 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
4359 | 5641 return; |
5642 | |
5643 if (gaim_conversation_get_gc(conv) == NULL) | |
5644 return; | |
5645 | |
9324 | 5646 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); |
5647 | |
5648 if (icon == NULL) | |
5649 return; | |
5650 | |
5651 data = gaim_buddy_icon_get_data(icon, &len); | |
5652 | |
5653 /* this is such an evil hack, i don't know why i'm even considering it. | |
5654 * we'll do it differently when gdk-pixbuf-loader isn't leaky anymore. */ | |
5655 /* gdk-pixbuf-loader was leaky? is it still? */ | |
5656 g_snprintf(filename, sizeof(filename), | |
5657 "%s" G_DIR_SEPARATOR_S "gaimicon-%s.%d", | |
5658 g_get_tmp_dir(), gaim_conversation_get_name(conv), getpid()); | |
5659 | |
5660 if (!(file = fopen(filename, "wb"))) | |
5661 return; | |
5662 | |
5663 fwrite(data, 1, len, file); | |
5664 fclose(file); | |
5665 | |
5666 gtkconv->u.im->anim = gdk_pixbuf_animation_new_from_file(filename, &err); | |
5667 /* make sure we remove the file as soon as possible */ | |
5668 unlink(filename); | |
5669 | |
4359 | 5670 if (err) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5671 gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5672 "Buddy icon error: %s\n", err->message); |
4359 | 5673 g_error_free(err); |
5674 } | |
5675 | |
5676 if (!gtkconv->u.im->anim) | |
5677 return; | |
5678 | |
5679 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | |
5680 gtkconv->u.im->iter = NULL; | |
5681 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5682 } else { | |
5683 gtkconv->u.im->iter = | |
8496 | 5684 gdk_pixbuf_animation_get_iter(gtkconv->u.im->anim, NULL); /* LEAK */ |
4359 | 5685 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); |
8189 | 5686 if (gtkconv->u.im->animate) |
5687 start_anim(NULL, conv); | |
4359 | 5688 } |
5689 | |
9318 | 5690 get_icon_scale_size(gtkconv->u.im->anim, prpl_info ? &prpl_info->icon_spec : |
5691 NULL, &scale_width, &scale_height); | |
4359 | 5692 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 5693 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
4359 | 5694 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 5695 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
4359 | 5696 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
5697 GDK_INTERP_NEAREST); | |
5698 | |
5699 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
4793 | 5700 g_object_unref(G_OBJECT(scale)); |
4359 | 5701 |
8821 | 5702 |
9885 | 5703 gtkconv->u.im->icon_container = gtk_vbox_new(FALSE, 0); |
8821 | 5704 |
4359 | 5705 frame = gtk_frame_new(NULL); |
5706 gtk_frame_set_shadow_type(GTK_FRAME(frame), | |
5707 (bm ? GTK_SHADOW_NONE : GTK_SHADOW_IN)); | |
9885 | 5708 gtk_box_pack_start(GTK_BOX(gtkconv->u.im->icon_container), frame, |
5709 FALSE, FALSE, 0); | |
8821 | 5710 |
4359 | 5711 event = gtk_event_box_new(); |
5712 gtk_container_add(GTK_CONTAINER(frame), event); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
5713 g_signal_connect(G_OBJECT(event), "button-press-event", |
4359 | 5714 G_CALLBACK(icon_menu), conv); |
5715 gtk_widget_show(event); | |
5716 | |
4635 | 5717 gtkconv->u.im->icon = gtk_image_new_from_pixmap(pm, bm); |
9318 | 5718 gtk_widget_set_size_request(gtkconv->u.im->icon, scale_width, scale_height); |
4359 | 5719 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); |
5720 gtk_widget_show(gtkconv->u.im->icon); | |
5721 | |
4793 | 5722 g_object_unref(G_OBJECT(pm)); |
4359 | 5723 |
5724 if (bm) | |
4793 | 5725 g_object_unref(G_OBJECT(bm)); |
7143 | 5726 |
9332 | 5727 button_type = gaim_prefs_get_int("/gaim/gtk/conversations/button_type"); |
9876 | 5728 /* the button seems to get its size before the box, so... */ |
5729 gtk_widget_size_request(gtkconv->send, &requisition); | |
9683 | 5730 if (button_type == GAIM_BUTTON_NONE || requisition.height * 1.5 < scale_height) { |
9885 | 5731 gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), |
5732 gtkconv->u.im->icon_container, FALSE, FALSE, 0); | |
9332 | 5733 /* gtk_box_reorder_child(GTK_BOX(gtkconv->lower_hbox), vbox, 0); */ |
5734 } else { | |
9885 | 5735 gtk_box_pack_start(GTK_BOX(gtkconv->bbox), |
5736 gtkconv->u.im->icon_container, FALSE, FALSE, 0); | |
5737 gtk_box_reorder_child(GTK_BOX(gtkconv->bbox), | |
5738 gtkconv->u.im->icon_container, 0); | |
9332 | 5739 } |
5740 | |
9885 | 5741 gtk_widget_show(gtkconv->u.im->icon_container); |
9332 | 5742 gtk_widget_show(frame); |
5743 | |
7143 | 5744 /* The buddy icon code needs badly to be fixed. */ |
5745 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
8068 | 5746 if(conv == gaim_conv_window_get_active_conversation(gaim_conversation_get_window(conv))) |
5747 gtk_window_set_icon(GTK_WINDOW(gtkwin->window), buf); | |
4359 | 5748 } |
5749 | |
5750 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5751 gaim_gtkconv_update_buttons_by_protocol(GaimConversation *conv) |
4359 | 5752 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5753 GaimConvWindow *win; |
4359 | 5754 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5755 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 5756 return; |
5757 | |
7887 | 5758 win = gaim_conversation_get_window(conv); |
5759 | |
5760 if (win != NULL && gaim_conv_window_get_active_conversation(win) == conv) | |
5761 gray_stuff_out(conv); | |
4359 | 5762 } |
5763 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5764 GaimConvWindow * |
4359 | 5765 gaim_gtkwin_get_at_xy(int x, int y) |
5766 { | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5767 GaimConvWindow *win = NULL; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5768 GaimGtkWindow *gtkwin; |
4359 | 5769 GdkWindow *gdkwin; |
5770 GList *l; | |
5771 | |
5772 gdkwin = gdk_window_at_pointer(&x, &y); | |
5773 | |
5774 if (gdkwin) | |
5775 gdkwin = gdk_window_get_toplevel(gdkwin); | |
5776 | |
5777 for (l = gaim_get_windows(); l != NULL; l = l->next) { | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5778 win = (GaimConvWindow *)l->data; |
4359 | 5779 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5780 if (!GAIM_IS_GTK_WINDOW(win)) |
4359 | 5781 continue; |
5782 | |
5783 gtkwin = GAIM_GTK_WINDOW(win); | |
5784 | |
5785 if (gdkwin == gtkwin->window->window) | |
5786 return win; | |
5787 } | |
5788 | |
5789 return NULL; | |
5790 } | |
5791 | |
5792 int | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5793 gaim_gtkconv_get_tab_at_xy(GaimConvWindow *win, int x, int y) |
4359 | 5794 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5795 GaimGtkWindow *gtkwin; |
4359 | 5796 GList *l; |
5797 gint nb_x, nb_y, x_rel, y_rel; | |
5798 GtkNotebook *notebook; | |
5799 GtkWidget *tab; | |
5800 gint i, page_num = 0; | |
5801 gboolean first_visible = TRUE; | |
5802 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5803 if (!GAIM_IS_GTK_WINDOW(win)) |
4359 | 5804 return -1; |
5805 | |
5806 gtkwin = GAIM_GTK_WINDOW(win); | |
5807 notebook = GTK_NOTEBOOK(gtkwin->notebook); | |
5808 | |
5809 gdk_window_get_origin(gtkwin->notebook->window, &nb_x, &nb_y); | |
5810 x_rel = x - nb_x; | |
5811 y_rel = y - nb_y; | |
5812 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5813 for (l = gaim_conv_window_get_conversations(win), i = 0; |
4359 | 5814 l != NULL; |
5815 l = l->next, i++) { | |
5816 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5817 GaimConversation *conv = l->data; |
4359 | 5818 tab = GAIM_GTK_CONVERSATION(conv)->tab_label; |
5819 | |
5820 if (!GTK_WIDGET_MAPPED(tab)) | |
5821 continue; | |
5822 | |
5823 if (first_visible) { | |
5824 first_visible = FALSE; | |
5825 | |
5826 if (x_rel < tab->allocation.x) x_rel = tab->allocation.x; | |
5827 if (y_rel < tab->allocation.y) y_rel = tab->allocation.y; | |
5828 } | |
5829 | |
5830 if (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || | |
5831 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM) { | |
5832 | |
5833 if (tab->allocation.x <= x_rel) { | |
5834 if (tab->allocation.x + tab->allocation.width <= x_rel) | |
5835 page_num = i + 1; | |
5836 else | |
5837 page_num = i; | |
5838 } | |
5839 else | |
5840 break; | |
5841 } | |
5842 else { | |
5843 if (tab->allocation.y <= y_rel) { | |
5844 if (tab->allocation.y + tab->allocation.height <= y_rel) | |
5845 page_num = i + 1; | |
5846 else | |
5847 page_num = i; | |
5848 } | |
5849 else | |
5850 break; | |
5851 } | |
5852 } | |
5853 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5854 if (i == gaim_conv_window_get_conversation_count(win) + 1) |
4359 | 5855 return -1; |
5856 | |
5857 return page_num; | |
5858 } | |
5859 | |
5860 int | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5861 gaim_gtkconv_get_dest_tab_at_xy(GaimConvWindow *win, int x, int y) |
4359 | 5862 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5863 GaimGtkWindow *gtkwin; |
4359 | 5864 GList *l; |
5865 gint nb_x, nb_y, x_rel, y_rel; | |
5866 GtkNotebook *notebook; | |
5867 GtkWidget *tab; | |
5868 gint i, page_num = 0; | |
5869 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5870 if (!GAIM_IS_GTK_WINDOW(win)) |
4359 | 5871 return -1; |
5872 | |
5873 gtkwin = GAIM_GTK_WINDOW(win); | |
5874 notebook = GTK_NOTEBOOK(gtkwin->notebook); | |
5875 | |
5876 gdk_window_get_origin(gtkwin->notebook->window, &nb_x, &nb_y); | |
5877 x_rel = x - nb_x; | |
5878 y_rel = y - nb_y; | |
5879 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5880 for (l = gaim_conv_window_get_conversations(win), i = 0; |
4359 | 5881 l != NULL; |
5882 l = l->next, i++) { | |
5883 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5884 GaimConversation *conv = l->data; |
4359 | 5885 tab = GAIM_GTK_CONVERSATION(conv)->tab_label; |
5886 | |
5887 if (!GTK_WIDGET_MAPPED(tab)) | |
5888 continue; | |
5889 | |
5890 if (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || | |
5891 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM) { | |
5892 | |
5893 if (tab->allocation.x <= x_rel) { | |
5894 if (tab->allocation.x + (tab->allocation.width / 2) <= x_rel) | |
5895 page_num = i + 1; | |
5896 else | |
5897 page_num = i; | |
5898 } | |
5899 else | |
5900 break; | |
5901 } | |
5902 else { | |
5903 if (tab->allocation.y <= y_rel) { | |
5904 if (tab->allocation.y + (tab->allocation.height / 2) <= y_rel) | |
5905 page_num = i + 1; | |
5906 else | |
5907 page_num = i; | |
5908 } | |
5909 else | |
5910 break; | |
5911 } | |
5912 } | |
5913 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5914 if (i == gaim_conv_window_get_conversation_count(win) + 1) |
4359 | 5915 return -1; |
5916 | |
5917 return page_num; | |
5918 } | |
4940
3708545afe42
[gaim-migrate @ 5274]
Christian Hammond <chipx86@chipx86.com>
parents:
4939
diff
changeset
|
5919 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5920 static void |
6398
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
5921 escape_closes_pref_cb(const char *name, GaimPrefType type, gpointer value, |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
5922 gpointer data) |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
5923 { |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
5924 if (value) |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
5925 gtk_accel_map_change_entry(N_("<main>/Conversation/Close"), |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
5926 GDK_Escape, 0, TRUE); |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
5927 else |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
5928 gtk_accel_map_change_entry(N_("<main>/Conversation/Close"), |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
5929 GDK_W, GDK_CONTROL_MASK, TRUE); |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
5930 } |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
5931 |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
5932 static void |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5933 close_on_tabs_pref_cb(const char *name, GaimPrefType type, gpointer value, |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
5934 gpointer data) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5935 { |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5936 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5937 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5938 GaimGtkConversation *gtkconv; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5939 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5940 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5941 conv = (GaimConversation *)l->data; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5942 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5943 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5944 continue; |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5945 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5946 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5947 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5948 if (value) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5949 gtk_widget_show(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5950 else |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5951 gtk_widget_hide(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5952 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5953 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5954 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5955 static void |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5956 show_timestamps_pref_cb(const char *name, GaimPrefType type, gpointer value, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5957 gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5958 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5959 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5960 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5961 GaimGtkConversation *gtkconv; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5962 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5963 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5964 conv = (GaimConversation *)l->data; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5965 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5966 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5967 continue; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5968 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5969 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5970 |
7386 | 5971 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), (gboolean)GPOINTER_TO_INT(value)); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5972 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5973 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5974 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5975 static void |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5976 spellcheck_pref_cb(const char *name, GaimPrefType type, gpointer value, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5977 gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5978 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5979 #ifdef USE_GTKSPELL |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5980 GList *cl; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5981 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5982 GaimGtkConversation *gtkconv; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5983 GtkSpell *spell; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5984 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5985 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
5986 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5987 conv = (GaimConversation *)cl->data; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5988 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5989 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5990 continue; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5991 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5992 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5993 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5994 if (value) |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
5995 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(gtkconv->entry)); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5996 else { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5997 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry)); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5998 gtkspell_detach(spell); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5999 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6000 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6001 #endif |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6002 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6003 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6004 static void |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6005 tab_side_pref_cb(const char *name, GaimPrefType type, gpointer value, |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6006 gpointer data) |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6007 { |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6008 GList *l; |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6009 GtkPositionType pos; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
6010 GaimConvWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6011 GaimGtkWindow *gtkwin; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6012 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6013 pos = GPOINTER_TO_INT(value); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6014 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6015 for (l = gaim_get_windows(); l != NULL; l = l->next) { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
6016 win = (GaimConvWindow *)l->data; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6017 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6018 if (!GAIM_IS_GTK_WINDOW(win)) |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6019 continue; |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6020 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6021 gtkwin = GAIM_GTK_WINDOW(win); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6022 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6023 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(gtkwin->notebook), pos); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6024 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6025 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6026 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6027 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6028 show_formatting_toolbar_pref_cb(const char *name, GaimPrefType type, |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6029 gpointer value, gpointer data) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6030 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6031 GList *l; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6032 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6033 GaimGtkConversation *gtkconv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6034 GaimConvWindow *win; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6035 GaimGtkWindow *gtkwin; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6036 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6037 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6038 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6039 conv = (GaimConversation *)l->data; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6040 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6041 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6042 continue; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6043 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6044 gtkconv = GAIM_GTK_CONVERSATION(conv); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6045 win = gaim_conversation_get_window(conv); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6046 gtkwin = GAIM_GTK_WINDOW(win); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6047 |
7386 | 6048 gtkconv->show_formatting_toolbar = (gboolean)GPOINTER_TO_INT(value); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6049 gtk_check_menu_item_set_active( |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6050 GTK_CHECK_MENU_ITEM(gtkwin->menu.show_formatting_toolbar), |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6051 gtkconv->show_formatting_toolbar); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6052 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6053 if (gtkconv->show_formatting_toolbar) |
8317 | 6054 gtk_widget_show(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6055 else |
8317 | 6056 gtk_widget_hide(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6057 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6058 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6059 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6060 static void |
9150 | 6061 button_type_pref_cb(const char *name, GaimPrefType type, |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6062 gpointer value, gpointer data) |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6063 { |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6064 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6065 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6066 GaimGtkConversation *gtkconv; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6067 |
9150 | 6068 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6069 conv = (GaimConversation *)l->data; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6070 gtkconv = GAIM_GTK_CONVERSATION(conv); |
9150 | 6071 switch (conv->type) { |
6072 case GAIM_CONV_IM: | |
9749 | 6073 setup_im_buttons(conv, gtkconv->bbox); |
9150 | 6074 gaim_gtkconv_update_buddy_icon(conv); |
6075 break; | |
6076 case GAIM_CONV_CHAT: | |
9749 | 6077 setup_chat_buttons(conv, gtkconv->bbox); |
9150 | 6078 break; |
6079 default: | |
6080 break; | |
6081 } | |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6082 } |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6083 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6084 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6085 static void |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6086 animate_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6087 gpointer value, gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6088 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6089 GList *l; |
8189 | 6090 GaimConversation *conv; |
6091 GaimGtkConversation *gtkconv; | |
6092 GaimConvWindow *win; | |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6093 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6094 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6095 return; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6096 |
8189 | 6097 /* Set the "animate" flag for each icon based on the new preference */ |
6098 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
6099 conv = (GaimConversation *)l->data; | |
6100 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10112 | 6101 gtkconv->u.im->animate = GPOINTER_TO_INT(value); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6102 } |
8189 | 6103 |
6104 /* Now either stop or start animation for the active conversation in each window */ | |
6105 for (l = gaim_get_windows(); l != NULL; l = l->next) { | |
6106 win = (GaimConvWindow *)l->data; | |
6107 conv = gaim_conv_window_get_active_conversation(win); | |
6108 gaim_gtkconv_update_buddy_icon(conv); | |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6109 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6110 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6111 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6112 static void |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6113 show_buddy_icons_pref_cb(const char *name, GaimPrefType type, gpointer value, |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6114 gpointer data) |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6115 { |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6116 GList *l; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6117 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6118 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6119 GaimConversation *conv = l->data; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6120 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6121 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6122 gaim_conversation_foreach(gaim_gtkconv_update_buddy_icon); |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6123 } |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6124 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6125 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5680
diff
changeset
|
6126 static void |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6127 conv_placement_pref_cb(const char *name, GaimPrefType type, |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6128 gpointer value, gpointer data) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6129 { |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6130 GaimConvPlacementFunc func; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6131 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6132 if (strcmp(name, "/gaim/gtk/conversations/placement")) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6133 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6134 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6135 func = gaim_conv_placement_get_fnc(value); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6136 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6137 if (func == NULL) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6138 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6139 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6140 gaim_conv_placement_set_current_func(func); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6141 } |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6142 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6143 void * |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6144 gaim_gtk_conversations_get_handle(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6145 { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6146 static int handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6147 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6148 return &handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6149 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6150 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6151 void |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
6152 gaim_gtk_conversations_init(void) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6153 { |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6154 void *handle = gaim_gtk_conversations_get_handle(); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6155 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6156 /* Conversations */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6157 gaim_prefs_add_none("/gaim/gtk/conversations"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6158 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6159 gaim_prefs_add_bool("/gaim/gtk/conversations/escape_closes", FALSE); |
9025 | 6160 gaim_prefs_add_bool("/gaim/gtk/conversations/send_formatting", FALSE); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6161 gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6162 gaim_prefs_add_bool("/gaim/gtk/conversations/send_italic", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6163 gaim_prefs_add_bool("/gaim/gtk/conversations/send_underline", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6164 gaim_prefs_add_bool("/gaim/gtk/conversations/show_timestamps", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6165 gaim_prefs_add_bool("/gaim/gtk/conversations/spellcheck", TRUE); |
9049 | 6166 #if 1 |
6167 gaim_prefs_add_bool("/gaim/gtk/conversations/ignore_colors", FALSE); | |
6168 gaim_prefs_add_bool("/gaim/gtk/conversations/ignore_fonts", FALSE); | |
6169 gaim_prefs_add_bool("/gaim/gtk/conversations/ignore_font_sizes", FALSE); | |
6170 #else | |
8944 | 6171 gaim_prefs_add_bool("/gaim/gtk/conversations/ignore_formatting", FALSE); |
9049 | 6172 #endif |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6173 gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); |
9832 | 6174 gaim_prefs_add_bool("/gaim/gtk/conversations/passthrough_unknown_commands", FALSE); |
9130 | 6175 |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6176 gaim_prefs_add_string("/gaim/gtk/conversations/placement", "last"); |
8998 | 6177 gaim_prefs_add_int("/gaim/gtk/conversations/placement_number", 1); |
9025 | 6178 gaim_prefs_add_string("/gaim/gtk/conversations/bgcolor", ""); |
6179 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", ""); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6180 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", ""); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6181 gaim_prefs_add_int("/gaim/gtk/conversations/font_size", 3); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6182 gaim_prefs_add_bool("/gaim/gtk/conversations/tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6183 gaim_prefs_add_int("/gaim/gtk/conversations/tab_side", GTK_POS_TOP); |
9150 | 6184 gaim_prefs_add_int("/gaim/gtk/conversations/button_type", |
6185 GAIM_BUTTON_TEXT_IMAGE); | |
6186 | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6187 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6188 /* Conversations -> Chat */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6189 gaim_prefs_add_none("/gaim/gtk/conversations/chat"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6190 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6191 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6192 gaim_prefs_add_int("/gaim/gtk/conversations/chat/entry_height", 50); |
9319 | 6193 gaim_prefs_add_bool("/gaim/gtk/conversations/chat/raise_on_events", FALSE); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6194 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6195 /* Conversations -> IM */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6196 gaim_prefs_add_none("/gaim/gtk/conversations/im"); |
9150 | 6197 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6198 gaim_prefs_add_bool("/gaim/gtk/conversations/im/animate_buddy_icons", TRUE); |
9150 | 6199 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6200 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6201 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6202 gaim_prefs_add_int("/gaim/gtk/conversations/im/entry_height", 50); |
9319 | 6203 gaim_prefs_add_bool("/gaim/gtk/conversations/im/raise_on_events", FALSE); |
6204 gaim_prefs_add_bool("/gaim/gtk/conversations/im/show_buddy_icons", TRUE); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6205 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6206 /* Connect callbacks. */ |
10087 | 6207 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/escape_closes", |
6398
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
6208 escape_closes_pref_cb, NULL); |
10087 | 6209 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/close_on_tabs", |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6210 close_on_tabs_pref_cb, NULL); |
10087 | 6211 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/show_timestamps", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6212 show_timestamps_pref_cb, NULL); |
10087 | 6213 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/show_formatting_toolbar", |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6214 show_formatting_toolbar_pref_cb, NULL); |
10087 | 6215 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/spellcheck", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6216 spellcheck_pref_cb, NULL); |
10087 | 6217 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tab_side", |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6218 tab_side_pref_cb, NULL); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6219 |
10087 | 6220 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/placement", |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6221 conv_placement_pref_cb, NULL); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6222 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6223 |
10087 | 6224 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/button_type", |
9150 | 6225 button_type_pref_cb, NULL); |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
6226 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6227 /* IM callbacks */ |
10087 | 6228 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/im/animate_buddy_icons", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6229 animate_buddy_icons_pref_cb, NULL); |
10087 | 6230 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/im/show_buddy_icons", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6231 show_buddy_icons_pref_cb, NULL); |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6232 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6233 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6234 /********************************************************************** |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6235 * Register signals |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6236 **********************************************************************/ |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6237 gaim_signal_register(handle, "conversation-drag-ended", |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6238 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6239 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6240 GAIM_SUBTYPE_CONV_WINDOW), |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6241 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6242 GAIM_SUBTYPE_CONV_WINDOW)); |
9167 | 6243 |
6244 /********************************************************************** | |
6245 * Register commands | |
6246 **********************************************************************/ | |
9829 | 6247 gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT, |
6248 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
6249 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); | |
9213 | 6250 gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, |
6251 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 6252 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
9213 | 6253 gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, |
6254 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 6255 debug_command_cb, _("debug <option>: Send various debug information to the current conversation."), NULL); |
9213 | 6256 |
6257 gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, | |
9597 | 6258 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, |
6259 help_command_cb, _("help <command>: Help on a specific command."), NULL); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6260 } |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6261 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6262 void |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6263 gaim_gtk_conversations_uninit(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6264 { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6265 gaim_signals_unregister_by_instance(gaim_gtk_conversations_get_handle()); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6266 } |