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