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