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