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