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