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