Mercurial > pidgin
annotate src/gtkutils.c @ 7935:11cef36ba006
[gaim-migrate @ 8606]
Fix unblocking of users.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Sat, 27 Dec 2003 01:02:44 +0000 |
parents | f691e3eb4ff3 |
children | e8fc79fb648b |
rev | line source |
---|---|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1 /** |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
2 * @file gtkutils.h GTK+ utility functions |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
3 * @ingroup gtkui |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
4 * |
4359 | 5 * gaim |
6 * | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
7 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
8 * |
4359 | 9 * This program is free software; you can redistribute it and/or modify |
10 * it under the terms of the GNU General Public License as published by | |
11 * the Free Software Foundation; either version 2 of the License, or | |
12 * (at your option) any later version. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program; if not, write to the Free Software | |
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
22 */ | |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6236
diff
changeset
|
23 #include "gtkinternal.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
24 |
4359 | 25 #ifndef _WIN32 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
26 # include <X11/Xlib.h> |
4359 | 27 #else |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
28 # ifdef small |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
29 # undef small |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
30 # endif |
4359 | 31 #endif /*_WIN32*/ |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
32 |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
33 #ifdef USE_GTKSPELL |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
34 # include <gtkspell/gtkspell.h> |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
35 # ifdef _WIN32 |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
36 # include "wspell.h" |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
37 # endif |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
38 #endif |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
39 |
4359 | 40 #include <gdk/gdkkeysyms.h> |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
41 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
42 #include "debug.h" |
7078 | 43 #include "imgstore.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
44 #include "notify.h" |
5548 | 45 #include "prefs.h" |
4359 | 46 #include "prpl.h" |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
47 #include "signals.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
48 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
49 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
50 #include "gtkconv.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
51 #include "gtkimhtml.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
52 #include "gtkutils.h" |
4359 | 53 #include "ui.h" |
54 | |
7420 | 55 guint accels_save_timer = 0; |
56 | |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
57 static void |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
58 url_clicked_cb(GtkWidget *w, const char *uri) |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
59 { |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
60 gaim_notify_uri(NULL, uri); |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
61 } |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
62 |
4359 | 63 void |
64 gaim_setup_imhtml(GtkWidget *imhtml) | |
65 { | |
66 g_return_if_fail(imhtml != NULL); | |
67 g_return_if_fail(GTK_IS_IMHTML(imhtml)); | |
68 | |
5548 | 69 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/show_smileys")) |
4359 | 70 gtk_imhtml_show_smileys(GTK_IMHTML(imhtml), FALSE); |
71 | |
72 g_signal_connect(G_OBJECT(imhtml), "url_clicked", | |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
73 G_CALLBACK(url_clicked_cb), NULL); |
4359 | 74 |
75 smiley_themeize(imhtml); | |
76 } | |
77 | |
78 void | |
79 toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle) | |
80 { | |
81 gboolean sensitivity = GTK_WIDGET_IS_SENSITIVE(to_toggle); | |
82 | |
83 gtk_widget_set_sensitive(to_toggle, !sensitivity); | |
84 } | |
85 | |
7751 | 86 void |
87 gaim_gtk_set_sensitive_if_input(GtkWidget *entry, GtkWidget *dialog) | |
88 { | |
89 const char *text = gtk_entry_get_text(GTK_ENTRY(entry)); | |
90 gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK, | |
91 (*text != '\0')); | |
92 } | |
93 | |
4359 | 94 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
95 gaim_gtk_remove_tags(GaimGtkConversation *gtkconv, const char *tag) |
4359 | 96 { |
97 GtkTextIter start, end, m_start, m_end; | |
98 | |
99 if (gtkconv == NULL || tag == NULL) | |
100 return; | |
101 | |
102 if (!gtk_text_buffer_get_selection_bounds(gtkconv->entry_buffer, | |
103 &start, &end)) | |
104 return; | |
105 | |
106 /* FIXMEif (strstr(tag, "<FONT SIZE=")) { | |
107 while ((t = strstr(t, "<FONT SIZE="))) { | |
108 if (((t - s) < finish) && ((t - s) >= start)) { | |
109 gtk_editable_delete_text(GTK_EDITABLE(entry), (t - s), | |
110 (t - s) + strlen(tag)); | |
111 g_free(s); | |
112 s = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); | |
113 t = s; | |
114 } else | |
115 t++; | |
116 } | |
117 } else*/ { | |
118 while (gtk_text_iter_forward_search(&start, tag, 0, &m_start, | |
119 &m_end, &end)) { | |
120 | |
121 gtk_text_buffer_delete(gtkconv->entry_buffer, &m_start, &m_end); | |
122 gtk_text_buffer_get_selection_bounds(gtkconv->entry_buffer, | |
123 &start, &end); | |
124 } | |
125 } | |
126 } | |
127 | |
128 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
129 gaim_gtk_surround(GaimGtkConversation *gtkconv, |
4359 | 130 const char *pre, const char *post) |
131 { | |
132 GtkTextIter start, end; | |
133 GtkTextMark *mark_start, *mark_end; | |
134 GtkTextBuffer *entry_buffer; | |
135 | |
136 if (gtkconv == NULL || pre == NULL || post == NULL) | |
137 return; | |
138 | |
139 entry_buffer = gtkconv->entry_buffer; | |
140 | |
141 if (gtk_text_buffer_get_selection_bounds(entry_buffer, | |
142 &start, &end)) { | |
143 gaim_gtk_remove_tags(gtkconv, pre); | |
144 gaim_gtk_remove_tags(gtkconv, post); | |
145 | |
146 mark_start = gtk_text_buffer_create_mark(entry_buffer, "m1", | |
147 &start, TRUE); | |
148 mark_end = gtk_text_buffer_create_mark(entry_buffer, "m2", | |
149 &end, FALSE); | |
150 gtk_text_buffer_insert(entry_buffer, &start, pre, -1); | |
151 gtk_text_buffer_get_selection_bounds(entry_buffer, &start, &end); | |
152 gtk_text_buffer_insert(entry_buffer, &end, post, -1); | |
153 gtk_text_buffer_get_iter_at_mark(entry_buffer, &start, mark_start); | |
154 gtk_text_buffer_move_mark_by_name(entry_buffer, "selection_bound", | |
155 &start); | |
156 } else { | |
157 gtk_text_buffer_insert(entry_buffer, &start, pre, -1); | |
158 gtk_text_buffer_insert(entry_buffer, &start, post, -1); | |
159 mark_start = gtk_text_buffer_get_insert(entry_buffer); | |
160 gtk_text_buffer_get_iter_at_mark(entry_buffer, &start, mark_start); | |
161 gtk_text_iter_backward_chars(&start, strlen(post)); | |
162 gtk_text_buffer_place_cursor(entry_buffer, &start); | |
163 } | |
164 | |
165 gtk_widget_grab_focus(gtkconv->entry); | |
166 } | |
167 | |
168 static gboolean | |
169 invert_tags(GtkTextBuffer *buffer, const char *s1, const char *s2, | |
170 gboolean really) | |
171 { | |
172 GtkTextIter start1, start2, end1, end2; | |
173 char *b1, *b2; | |
174 | |
175 if (gtk_text_buffer_get_selection_bounds(buffer, &start1, &end2)) { | |
176 start2 = start1; | |
177 end1 = end2; | |
178 | |
179 if (!gtk_text_iter_forward_chars(&start2, strlen(s1))) | |
180 return FALSE; | |
181 | |
182 if (!gtk_text_iter_backward_chars(&end1, strlen(s2))) | |
183 return FALSE; | |
184 | |
185 b1 = gtk_text_buffer_get_text(buffer, &start1, &start2, FALSE); | |
186 b2 = gtk_text_buffer_get_text(buffer, &end1, &end2, FALSE); | |
187 | |
4793 | 188 if (!g_ascii_strncasecmp(b1, s1, strlen(s1)) && |
189 !g_ascii_strncasecmp(b2, s2, strlen(s2))) { | |
4359 | 190 |
191 if (really) { | |
192 GtkTextMark *m_end1, *m_end2; | |
193 | |
194 m_end1= gtk_text_buffer_create_mark(buffer, "m1", &end1, TRUE); | |
195 m_end2= gtk_text_buffer_create_mark(buffer, "m2", &end2, TRUE); | |
196 | |
197 gtk_text_buffer_delete(buffer, &start1, &start2); | |
198 gtk_text_buffer_get_iter_at_mark(buffer, &end1, m_end1); | |
199 gtk_text_buffer_get_iter_at_mark(buffer, &end2, m_end2); | |
200 gtk_text_buffer_delete(buffer, &end1, &end2); | |
201 gtk_text_buffer_delete_mark(buffer, m_end1); | |
202 gtk_text_buffer_delete_mark(buffer, m_end2); | |
203 } | |
204 | |
205 g_free(b1); | |
206 g_free(b2); | |
207 | |
208 return TRUE; | |
209 } | |
210 | |
211 g_free(b1); | |
212 g_free(b2); | |
213 } | |
214 | |
215 return FALSE; | |
216 } | |
217 | |
218 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
219 gaim_gtk_advance_past(GaimGtkConversation *gtkconv, |
4359 | 220 const char *pre, const char *post) |
221 { | |
222 GtkTextIter current_pos, start, end; | |
223 | |
224 if (invert_tags(gtkconv->entry_buffer, pre, post, TRUE)) | |
225 return; | |
226 | |
227 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, ¤t_pos, | |
228 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
229 | |
230 if (gtk_text_iter_forward_search(¤t_pos, post, 0, | |
231 &start, &end, NULL)) | |
232 gtk_text_buffer_place_cursor(gtkconv->entry_buffer, &end); | |
233 else | |
234 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, post, -1); | |
235 | |
236 gtk_widget_grab_focus(gtkconv->entry); | |
237 } | |
238 | |
239 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
240 gaim_gtk_set_font_face(GaimGtkConversation *gtkconv, |
4359 | 241 const char *font) |
242 { | |
243 if (gtkconv == NULL || font == NULL) | |
244 return; | |
245 | |
246 strncpy(gtkconv->fontface, | |
247 (font && *font ? font : DEFAULT_FONT_FACE), | |
248 sizeof(gtkconv->fontface)); | |
249 | |
250 gtkconv->has_font = TRUE; | |
251 | |
7717 | 252 gtk_imhtml_toggle_fontface(GTK_IMHTML(gtkconv->entry), gtkconv->fontface); |
4359 | 253 |
254 gtk_widget_grab_focus(gtkconv->entry); | |
255 | |
256 } | |
257 | |
258 static int | |
259 des_save_icon(GtkObject *obj, GdkEvent *e, | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
260 GaimGtkConversation *gtkconv) |
4359 | 261 { |
262 gtk_widget_destroy(gtkconv->u.im->save_icon); | |
263 gtkconv->u.im->save_icon = NULL; | |
264 | |
265 return TRUE; | |
266 } | |
267 | |
268 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
269 do_save_icon(GtkObject *obj, GaimConversation *c) |
4359 | 270 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
271 GaimGtkConversation *gtkconv; |
4359 | 272 FILE *file; |
273 const char *f; | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6652
diff
changeset
|
274 |
4359 | 275 gtkconv = GAIM_GTK_CONVERSATION(c); |
276 | |
277 f = gtk_file_selection_get_filename( | |
278 GTK_FILE_SELECTION(gtkconv->u.im->save_icon)); | |
279 | |
5966 | 280 if (gaim_gtk_check_if_dir(f, GTK_FILE_SELECTION(gtkconv->u.im->save_icon))) |
4359 | 281 return; |
282 | |
283 if ((file = fopen(f, "w")) != NULL) { | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7102
diff
changeset
|
284 GaimBuddyIcon *icon = gaim_conv_im_get_icon(GAIM_CONV_IM(c)); |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6652
diff
changeset
|
285 size_t len; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6652
diff
changeset
|
286 const void *data = gaim_buddy_icon_get_data(icon, &len); |
4359 | 287 |
288 if (data) | |
289 fwrite(data, 1, len, file); | |
290 | |
291 fclose(file); | |
292 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
293 gaim_notify_error(NULL, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
294 _("Can't save icon file to disk."), NULL); |
4359 | 295 } |
296 | |
297 gtk_widget_destroy(gtkconv->u.im->save_icon); | |
298 gtkconv->u.im->save_icon = NULL; | |
299 } | |
300 | |
301 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
302 cancel_save_icon(GtkObject *obj, GaimGtkConversation *gtkconv) |
4359 | 303 { |
304 gtk_widget_destroy(gtkconv->u.im->save_icon); | |
305 gtkconv->u.im->save_icon = NULL; | |
306 } | |
307 | |
308 | |
309 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
310 gaim_gtk_save_icon_dialog(GtkObject *obj, GaimConversation *conv) |
4359 | 311 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
312 GaimGtkConversation *gtkconv; |
4359 | 313 char buf[BUF_LEN]; |
314 | |
315 if (conv == NULL || gaim_conversation_get_type(conv) != GAIM_CONV_IM) | |
316 return; | |
317 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
318 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 319 return; |
320 | |
321 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
322 | |
323 if (gtkconv->u.im->save_icon != NULL) | |
324 { | |
325 gdk_window_raise(gtkconv->u.im->save_icon->window); | |
326 return; | |
327 } | |
328 | |
7859 | 329 gtkconv->u.im->save_icon = gtk_file_selection_new(_("Save Icon")); |
4359 | 330 |
331 gtk_file_selection_hide_fileop_buttons( | |
332 GTK_FILE_SELECTION(gtkconv->u.im->save_icon)); | |
333 | |
334 g_snprintf(buf, BUF_LEN - 1, | |
335 "%s" G_DIR_SEPARATOR_S "%s.icon", | |
336 gaim_home_dir(), gaim_conversation_get_name(conv)); | |
337 | |
338 gtk_file_selection_set_filename( | |
339 GTK_FILE_SELECTION(gtkconv->u.im->save_icon), buf); | |
340 | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
341 g_signal_connect(G_OBJECT(gtkconv->u.im->save_icon), "delete_event", |
4359 | 342 G_CALLBACK(des_save_icon), gtkconv); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
343 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(gtkconv->u.im->save_icon)->ok_button), "clicked", |
4359 | 344 G_CALLBACK(do_save_icon), conv); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
345 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(gtkconv->u.im->save_icon)->cancel_button), "clicked", |
4359 | 346 G_CALLBACK(cancel_save_icon), gtkconv); |
347 | |
348 gtk_widget_show(gtkconv->u.im->save_icon); | |
349 } | |
350 | |
351 int | |
352 gaim_gtk_get_dispstyle(GaimConversationType type) | |
353 { | |
354 int dispstyle = 2; | |
5554
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
355 int value; |
4359 | 356 |
357 if (type == GAIM_CONV_CHAT) { | |
5554
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
358 value = gaim_prefs_get_int("/gaim/gtk/conversations/chat/button_type"); |
4359 | 359 |
5554
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
360 switch (value) { |
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
361 case GAIM_BUTTON_TEXT: dispstyle = 1; break; |
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
362 case GAIM_BUTTON_IMAGE: dispstyle = 0; break; |
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
363 default: dispstyle = 2; break; /* both/neither */ |
4359 | 364 } |
365 } | |
366 else if (type == GAIM_CONV_IM) { | |
5554
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
367 value = gaim_prefs_get_int("/gaim/gtk/conversations/im/button_type"); |
4359 | 368 |
5554
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
369 switch (value) { |
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
370 case GAIM_BUTTON_TEXT: dispstyle = 1; break; |
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
371 case GAIM_BUTTON_IMAGE: dispstyle = 0; break; |
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
372 default: dispstyle = 2; break; /* both/neither */ |
4359 | 373 } |
374 } | |
375 | |
376 return dispstyle; | |
377 } | |
378 | |
379 GtkWidget * | |
380 gaim_gtk_change_text(const char *text, GtkWidget *button, | |
381 const char *stock, GaimConversationType type) | |
382 { | |
383 int dispstyle = gaim_gtk_get_dispstyle(type); | |
384 | |
385 if (button != NULL) | |
386 gtk_widget_destroy(button); | |
387 | |
388 button = gaim_pixbuf_button_from_stock((dispstyle == 0 ? NULL : text), | |
389 (dispstyle == 1 ? NULL : stock), | |
390 GAIM_BUTTON_VERTICAL); | |
391 | |
392 gtk_widget_show(button); | |
393 | |
394 return button; | |
395 } | |
396 | |
397 void | |
398 gaim_gtk_toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle) | |
399 { | |
400 gboolean sensitivity; | |
401 | |
402 if (to_toggle == NULL) | |
403 return; | |
404 | |
405 sensitivity = GTK_WIDGET_IS_SENSITIVE(to_toggle); | |
406 | |
407 gtk_widget_set_sensitive(to_toggle, !sensitivity); | |
408 } | |
409 | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
410 void |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
411 gtk_toggle_sensitive_array(GtkWidget *w, GPtrArray *data) |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
412 { |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
413 gboolean sensitivity; |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
414 gpointer element; |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
415 int i; |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
416 |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
417 for (i=0; i < data->len; i++) { |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
418 element = g_ptr_array_index(data,i); |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
419 if (element == NULL) |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
420 continue; |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
421 |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
422 sensitivity = GTK_WIDGET_IS_SENSITIVE(element); |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
423 |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
424 gtk_widget_set_sensitive(element, !sensitivity); |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
425 } |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
426 } |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
427 |
4687 | 428 void gaim_separator(GtkWidget *menu) |
429 { | |
430 GtkWidget *menuitem; | |
431 | |
432 menuitem = gtk_separator_menu_item_new(); | |
433 gtk_widget_show(menuitem); | |
434 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
435 } | |
5160 | 436 |
5162 | 437 GtkWidget *gaim_new_item(GtkWidget *menu, const char *str) |
438 { | |
439 GtkWidget *menuitem; | |
440 GtkWidget *label; | |
441 | |
442 menuitem = gtk_menu_item_new(); | |
443 if (menu) | |
444 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
445 gtk_widget_show(menuitem); | |
446 | |
447 label = gtk_label_new(str); | |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6236
diff
changeset
|
448 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
5162 | 449 gtk_label_set_pattern(GTK_LABEL(label), "_"); |
450 gtk_container_add(GTK_CONTAINER(menuitem), label); | |
451 gtk_widget_show(label); | |
452 /* FIXME: Go back and fix this | |
453 gtk_widget_add_accelerator(menuitem, "activate", accel, str[0], | |
454 GDK_MOD1_MASK, GTK_ACCEL_LOCKED); | |
455 */ | |
456 return menuitem; | |
457 } | |
458 | |
5906 | 459 GtkWidget *gaim_new_check_item(GtkWidget *menu, const char *str, |
460 GtkSignalFunc sf, gpointer data, gboolean checked) | |
461 { | |
462 GtkWidget *menuitem; | |
463 menuitem = gtk_check_menu_item_new_with_mnemonic(str); | |
464 | |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
465 if (menu) |
5906 | 466 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); |
467 | |
7299
2737c287f84d
[gaim-migrate @ 7883]
Christian Hammond <chipx86@chipx86.com>
parents:
7118
diff
changeset
|
468 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), checked); |
2737c287f84d
[gaim-migrate @ 7883]
Christian Hammond <chipx86@chipx86.com>
parents:
7118
diff
changeset
|
469 |
5906 | 470 if (sf) |
471 g_signal_connect(G_OBJECT(menuitem), "activate", sf, data); | |
472 | |
473 gtk_widget_show_all(menuitem); | |
474 | |
475 return menuitem; | |
476 } | |
477 | |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
478 GtkWidget * |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
479 gaim_pixbuf_toolbar_button_from_stock(const char *icon) |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
480 { |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
481 GtkWidget *button, *image, *bbox; |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
482 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
483 button = gtk_toggle_button_new(); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
484 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
485 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
486 bbox = gtk_vbox_new(FALSE, 0); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
487 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
488 gtk_container_add (GTK_CONTAINER(button), bbox); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
489 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
490 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_MENU); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
491 gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
492 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
493 gtk_widget_show_all(bbox); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
494 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
495 return button; |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
496 } |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
497 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
498 GtkWidget * |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
499 gaim_pixbuf_button_from_stock(const char *text, const char *icon, |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
500 GaimButtonOrientation style) |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
501 { |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
502 GtkWidget *button, *image, *label, *bbox, *ibox, *lbox; |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
503 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
504 button = gtk_button_new(); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
505 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
506 if (style == GAIM_BUTTON_HORIZONTAL) { |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
507 bbox = gtk_hbox_new(FALSE, 5); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
508 ibox = gtk_hbox_new(FALSE, 0); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
509 lbox = gtk_hbox_new(FALSE, 0); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
510 } |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
511 else { |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
512 bbox = gtk_vbox_new(FALSE, 5); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
513 ibox = gtk_vbox_new(FALSE, 0); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
514 lbox = gtk_vbox_new(FALSE, 0); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
515 } |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
516 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
517 gtk_container_add (GTK_CONTAINER(button), bbox); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
518 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
519 gtk_box_pack_start_defaults(GTK_BOX(bbox), ibox); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
520 gtk_box_pack_start_defaults(GTK_BOX(bbox), lbox); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
521 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
522 if (icon) { |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
523 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_BUTTON); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
524 gtk_box_pack_end(GTK_BOX(ibox), image, FALSE, FALSE, 0); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
525 } |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
526 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
527 if (text) { |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
528 label = gtk_label_new(NULL); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
529 gtk_label_set_text_with_mnemonic(GTK_LABEL(label), text); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
530 gtk_label_set_mnemonic_widget(GTK_LABEL(label), button); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
531 gtk_box_pack_start(GTK_BOX(lbox), label, FALSE, FALSE, 0); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
532 } |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
533 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
534 gtk_widget_show_all(bbox); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
535 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
536 return button; |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
537 } |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
538 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
539 |
5160 | 540 GtkWidget *gaim_new_item_from_stock(GtkWidget *menu, const char *str, const char *icon, GtkSignalFunc sf, gpointer data, guint accel_key, guint accel_mods, char *mod) |
541 { | |
542 GtkWidget *menuitem; | |
543 /* | |
544 GtkWidget *hbox; | |
545 GtkWidget *label; | |
546 */ | |
547 GtkWidget *image; | |
548 | |
549 if (icon == NULL) | |
550 menuitem = gtk_menu_item_new_with_mnemonic(str); | |
551 else | |
552 menuitem = gtk_image_menu_item_new_with_mnemonic(str); | |
553 | |
554 if (menu) | |
555 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
556 | |
557 if (sf) | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
558 g_signal_connect(G_OBJECT(menuitem), "activate", sf, data); |
5160 | 559 |
560 if (icon != NULL) { | |
561 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_MENU); | |
562 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); | |
563 } | |
564 /* FIXME: this isn't right | |
565 if (mod) { | |
566 label = gtk_label_new(mod); | |
567 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 2); | |
568 gtk_widget_show(label); | |
569 } | |
570 */ | |
571 /* | |
572 if (accel_key) { | |
573 gtk_widget_add_accelerator(menuitem, "activate", accel, accel_key, | |
574 accel_mods, GTK_ACCEL_LOCKED); | |
575 } | |
576 */ | |
577 | |
578 gtk_widget_show_all(menuitem); | |
579 | |
580 return menuitem; | |
581 } | |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
582 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
583 GtkWidget * |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
584 gaim_gtk_make_frame(GtkWidget *parent, const char *title) |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
585 { |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
586 GtkWidget *vbox, *label, *hbox; |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
587 char labeltitle[256]; |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
588 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
589 vbox = gtk_vbox_new(FALSE, 6); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
590 gtk_box_pack_start(GTK_BOX(parent), vbox, FALSE, FALSE, 0); |
5641
5e9babc828c4
[gaim-migrate @ 6054]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
591 gtk_widget_show(vbox); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
592 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
593 label = gtk_label_new(NULL); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
594 g_snprintf(labeltitle, sizeof(labeltitle), |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
595 "<span weight=\"bold\">%s</span>", title); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
596 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
597 gtk_label_set_markup(GTK_LABEL(label), labeltitle); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
598 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
599 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); |
5641
5e9babc828c4
[gaim-migrate @ 6054]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
600 gtk_widget_show(label); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
601 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
602 hbox = gtk_hbox_new(FALSE, 6); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
603 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); |
5641
5e9babc828c4
[gaim-migrate @ 6054]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
604 gtk_widget_show(hbox); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
605 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
606 label = gtk_label_new(" "); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
607 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
5641
5e9babc828c4
[gaim-migrate @ 6054]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
608 gtk_widget_show(label); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
609 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
610 vbox = gtk_vbox_new(FALSE, 6); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
611 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); |
5641
5e9babc828c4
[gaim-migrate @ 6054]
Christian Hammond <chipx86@chipx86.com>
parents:
5554
diff
changeset
|
612 gtk_widget_show(vbox); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
613 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
614 return vbox; |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
615 } |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
616 |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
617 static void |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
618 protocol_menu_cb(GtkWidget *optmenu, GCallback cb) |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
619 { |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
620 GtkWidget *menu; |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
621 GtkWidget *item; |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
622 GaimProtocol protocol; |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
623 gpointer user_data; |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
624 |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
625 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
626 item = gtk_menu_get_active(GTK_MENU(menu)); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
627 |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
628 protocol = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(item), "protocol")); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
629 user_data = (g_object_get_data(G_OBJECT(optmenu), "user_data")); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
630 |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
631 if (cb != NULL) |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
632 ((void (*)(GtkWidget *, GaimProtocol, gpointer))cb)(item, protocol, |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
633 user_data); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
634 } |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
635 |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
636 GtkWidget * |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
637 gaim_gtk_protocol_option_menu_new(GaimProtocol protocol, GCallback cb, |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
638 gpointer user_data) |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
639 { |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
640 GaimPluginProtocolInfo *prpl_info; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
641 GaimPlugin *plugin; |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
642 GtkWidget *hbox; |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
643 GtkWidget *label; |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
644 GtkWidget *optmenu; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
645 GtkWidget *menu; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
646 GtkWidget *item; |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
647 GtkWidget *image; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
648 GdkPixbuf *pixbuf; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
649 GdkPixbuf *scale; |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
650 GList *p; |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
651 GtkSizeGroup *sg; |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
652 char *filename; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
653 const char *proto_name; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
654 char buf[256]; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
655 int i, selected_index = -1; |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
656 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
657 optmenu = gtk_option_menu_new(); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
658 gtk_widget_show(optmenu); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
659 |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
660 g_object_set_data(G_OBJECT(optmenu), "user_data", user_data); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
661 |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
662 menu = gtk_menu_new(); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
663 gtk_widget_show(menu); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
664 |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
665 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
666 |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
667 for (p = gaim_plugins_get_protocols(), i = 0; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
668 p != NULL; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
669 p = p->next, i++) { |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
670 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
671 plugin = (GaimPlugin *)p->data; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
672 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
673 |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
674 /* Create the item. */ |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
675 item = gtk_menu_item_new(); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
676 |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
677 /* Create the hbox. */ |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
678 hbox = gtk_hbox_new(FALSE, 4); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
679 gtk_container_add(GTK_CONTAINER(item), hbox); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
680 gtk_widget_show(hbox); |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
681 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
682 /* Load the image. */ |
6430 | 683 proto_name = prpl_info->list_icon(NULL, NULL); |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
684 g_snprintf(buf, sizeof(buf), "%s.png", proto_name); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
685 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
686 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
687 "default", buf, NULL); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
688 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
689 g_free(filename); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
690 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
691 if (pixbuf != NULL) { |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
692 /* Scale and insert the image */ |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
693 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
694 GDK_INTERP_BILINEAR); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
695 image = gtk_image_new_from_pixbuf(scale); |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
696 |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
697 g_object_unref(G_OBJECT(pixbuf)); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
698 g_object_unref(G_OBJECT(scale)); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
699 } |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
700 else |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
701 image = gtk_image_new(); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
702 |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
703 gtk_size_group_add_widget(sg, image); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
704 |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
705 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
706 gtk_widget_show(image); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
707 |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
708 /* Create the label. */ |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
709 label = gtk_label_new(plugin->info->name); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
710 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
711 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
712 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
713 gtk_widget_show(label); |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
714 |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
715 g_object_set_data(G_OBJECT(item), "protocol", |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
716 GINT_TO_POINTER(prpl_info->protocol)); |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
717 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
718 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
719 gtk_widget_show(item); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
720 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
721 if (prpl_info->protocol == protocol) |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
722 selected_index = i; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
723 } |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
724 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
725 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
726 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
727 if (selected_index != -1) |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
728 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), selected_index); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
729 |
5688
e43e1b8dca8b
[gaim-migrate @ 6109]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
730 g_signal_connect(G_OBJECT(optmenu), "changed", |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
731 G_CALLBACK(protocol_menu_cb), cb); |
5688
e43e1b8dca8b
[gaim-migrate @ 6109]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
732 |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
733 g_object_unref(sg); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
734 |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
735 return optmenu; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
736 } |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
737 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
738 static void |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
739 account_menu_cb(GtkWidget *optmenu, GCallback cb) |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
740 { |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
741 GtkWidget *menu; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
742 GtkWidget *item; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
743 GaimAccount *account; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
744 gpointer user_data; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
745 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
746 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
747 item = gtk_menu_get_active(GTK_MENU(menu)); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
748 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
749 account = g_object_get_data(G_OBJECT(item), "account"); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
750 user_data = g_object_get_data(G_OBJECT(optmenu), "user_data"); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
751 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
752 if (cb != NULL) |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
753 ((void (*)(GtkWidget *, GaimAccount *, gpointer))cb)(item, account, |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
754 user_data); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
755 } |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
756 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
757 static void |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
758 create_account_menu(GtkWidget *optmenu, GaimAccount *default_account, |
6646
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
759 GaimCheckAccountFunc check_account_func, gboolean show_all) |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
760 { |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
761 GaimAccount *account; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
762 GtkWidget *menu; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
763 GtkWidget *item; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
764 GtkWidget *image; |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
765 GtkWidget *hbox; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
766 GtkWidget *label; |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
767 GdkPixbuf *pixbuf; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
768 GdkPixbuf *scale; |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
769 GList *list; |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
770 GList *p; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
771 GtkSizeGroup *sg; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
772 char *filename; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
773 const char *proto_name; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
774 char buf[256]; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
775 int i, selected_index = -1; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
776 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
777 if (show_all) |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
778 list = gaim_accounts_get_all(); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
779 else |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
780 list = gaim_connections_get_all(); |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
781 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
782 menu = gtk_menu_new(); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
783 gtk_widget_show(menu); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
784 |
5880
1b85ff65be57
[gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
785 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
786 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
787 for (p = list, i = 0; p != NULL; p = p->next, i++) { |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
788 GaimPluginProtocolInfo *prpl_info = NULL; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
789 GaimPlugin *plugin; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
790 |
5879
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
791 if (show_all) |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
792 account = (GaimAccount *)p->data; |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
793 else { |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
794 GaimConnection *gc = (GaimConnection *)p->data; |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
795 |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
796 account = gaim_connection_get_account(gc); |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
797 } |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
798 |
6652 | 799 if (check_account_func && !check_account_func(account)) |
6646
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
800 continue; |
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
801 |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
802 plugin = gaim_find_prpl(gaim_account_get_protocol(account)); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
803 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
804 if (plugin != NULL) |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
805 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
806 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
807 /* Create the item. */ |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
808 item = gtk_menu_item_new(); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
809 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
810 /* Create the hbox. */ |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
811 hbox = gtk_hbox_new(FALSE, 4); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
812 gtk_container_add(GTK_CONTAINER(item), hbox); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
813 gtk_widget_show(hbox); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
814 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
815 /* Load the image. */ |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
816 if (prpl_info != NULL) { |
6430 | 817 proto_name = prpl_info->list_icon(account, NULL); |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
818 g_snprintf(buf, sizeof(buf), "%s.png", proto_name); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
819 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
820 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
821 "default", buf, NULL); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
822 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
823 g_free(filename); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
824 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
825 if (pixbuf != NULL) { |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
826 /* Scale and insert the image */ |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
827 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
828 GDK_INTERP_BILINEAR); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
829 image = gtk_image_new_from_pixbuf(scale); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
830 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
831 g_object_unref(G_OBJECT(pixbuf)); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
832 g_object_unref(G_OBJECT(scale)); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
833 } |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
834 else |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
835 image = gtk_image_new(); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
836 } |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
837 else |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
838 image = gtk_image_new(); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
839 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
840 gtk_size_group_add_widget(sg, image); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
841 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
842 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
843 gtk_widget_show(image); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
844 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
845 g_snprintf(buf, sizeof(buf), "%s (%s)", |
6236 | 846 gaim_account_get_username(account), |
847 (plugin != NULL) ? plugin->info->name : _("Unknown")); | |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
848 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
849 /* Create the label. */ |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
850 label = gtk_label_new(buf); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
851 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
852 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
853 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
854 gtk_widget_show(label); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
855 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
856 g_object_set_data(G_OBJECT(item), "account", account); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
857 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
858 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
859 gtk_widget_show(item); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
860 |
5880
1b85ff65be57
[gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
861 if (default_account != NULL && account == default_account) |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
862 selected_index = i; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
863 } |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
864 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
865 g_object_unref(sg); |
5880
1b85ff65be57
[gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
866 |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
867 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
868 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
869 /* Set the place we should be at. */ |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
870 if (selected_index != -1) |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
871 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), selected_index); |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
872 } |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
873 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
874 static void |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
875 account_menu_sign_on_off_cb(GaimConnection *gc, GtkWidget *optmenu) |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
876 { |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
877 GtkWidget *menu; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
878 GtkWidget *item; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
879 gboolean show_all; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
880 GaimAccount *account; |
6646
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
881 GaimCheckAccountFunc check_account_func; |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
882 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
883 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
884 item = gtk_menu_get_active(GTK_MENU(menu)); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
885 account = g_object_get_data(G_OBJECT(item), "account"); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
886 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
887 show_all = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(optmenu), |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
888 "show_all")); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
889 |
6646
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
890 check_account_func = g_object_get_data(G_OBJECT(item), |
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
891 "check_account_func"); |
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
892 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
893 gtk_option_menu_remove_menu(GTK_OPTION_MENU(optmenu)); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
894 |
6646
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
895 create_account_menu(optmenu, account, check_account_func, show_all); |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
896 } |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
897 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
898 static gboolean |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
899 account_menu_destroyed_cb(GtkWidget *optmenu, GdkEvent *event, |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
900 void *user_data) |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
901 { |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
902 gaim_signals_disconnect_by_handle(optmenu); |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
903 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
904 return FALSE; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
905 } |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
906 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
907 GtkWidget * |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
908 gaim_gtk_account_option_menu_new(GaimAccount *default_account, |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
909 gboolean show_all, GCallback cb, |
6646
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
910 GaimCheckAccountFunc check_account_func, |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
911 gpointer user_data) |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
912 { |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
913 GtkWidget *optmenu; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
914 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
915 /* Create the option menu */ |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
916 optmenu = gtk_option_menu_new(); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
917 gtk_widget_show(optmenu); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
918 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
919 g_signal_connect(G_OBJECT(optmenu), "destroy", |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
920 G_CALLBACK(account_menu_destroyed_cb), NULL); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
921 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
922 /* Register the gaim sign on/off event callbacks. */ |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
923 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
924 optmenu, GAIM_CALLBACK(account_menu_sign_on_off_cb), |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
925 optmenu); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
926 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
927 optmenu, GAIM_CALLBACK(account_menu_sign_on_off_cb), |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
928 optmenu); |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
929 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
930 /* Set some data. */ |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
931 g_object_set_data(G_OBJECT(optmenu), "user_data", user_data); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
932 g_object_set_data(G_OBJECT(optmenu), "show_all", GINT_TO_POINTER(show_all)); |
6646
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
933 g_object_set_data(G_OBJECT(optmenu), "chck_account_func", |
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
934 check_account_func); |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
935 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
936 /* Create and set the actual menu. */ |
6646
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
937 create_account_menu(optmenu, default_account, check_account_func, show_all); |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
938 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
939 /* And now the last callback. */ |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
940 g_signal_connect(G_OBJECT(optmenu), "changed", |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
941 G_CALLBACK(account_menu_cb), cb); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
942 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
943 return optmenu; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
944 } |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
945 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
946 gboolean |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
947 gaim_gtk_check_if_dir(const char *path, GtkFileSelection *filesel) |
5966 | 948 { |
5967 | 949 char *dirname; |
5966 | 950 |
5967 | 951 if (g_file_test(path, G_FILE_TEST_IS_DIR)) { |
5966 | 952 /* append a / if needed */ |
953 if (path[strlen(path) - 1] != '/') { | |
5967 | 954 dirname = g_strconcat(path, "/", NULL); |
5966 | 955 } else { |
5967 | 956 dirname = g_strdup(path); |
5966 | 957 } |
5967 | 958 gtk_file_selection_set_filename(filesel, dirname); |
959 g_free(dirname); | |
5966 | 960 return TRUE; |
961 } | |
962 | |
963 return FALSE; | |
964 } | |
965 | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
966 char *stylize(const gchar *text, int length) |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
967 { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
968 gchar *buf; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
969 char *tmp = g_malloc(length); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
970 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
971 buf = g_malloc(length); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
972 g_snprintf(buf, length, "%s", text); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
973 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
974 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold")) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
975 g_snprintf(tmp, length, "<B>%s</B>", buf); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
976 strcpy(buf, tmp); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
977 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
978 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
979 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_italic")) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
980 g_snprintf(tmp, length, "<I>%s</I>", buf); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
981 strcpy(buf, tmp); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
982 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
983 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
984 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_underline")) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
985 g_snprintf(tmp, length, "<U>%s</U>", buf); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
986 strcpy(buf, tmp); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
987 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
988 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
989 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_strikethrough")) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
990 g_snprintf(tmp, length, "<S>%s</S>", buf); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
991 strcpy(buf, tmp); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
992 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
993 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
994 if (gaim_prefs_get_bool("/gaim/gtk/conversations/use_custom_font")) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
995 const char *fontface; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
996 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
997 fontface = gaim_prefs_get_string("/gaim/gtk/conversations/font_face"); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
998 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
999 g_snprintf(tmp, length, "<FONT FACE=\"%s\">%s</FONT>", fontface, buf); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1000 strcpy(buf, tmp); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1001 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1002 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1003 if (gaim_prefs_get_bool("/gaim/gtk/conversations/use_custom_size")) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1004 int fontsize = gaim_prefs_get_int("/gaim/gtk/conversations/font_size"); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1005 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1006 g_snprintf(tmp, length, "<FONT SIZE=\"%d\">%s</FONT>", fontsize, buf); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1007 strcpy(buf, tmp); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1008 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1009 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1010 if (gaim_prefs_get_bool("/gaim/gtk/conversations/use_custom_fgcolor")) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1011 GdkColor fgcolor; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1012 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1013 gdk_color_parse( |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1014 gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1015 &fgcolor); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1016 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1017 g_snprintf(tmp, length, "<FONT COLOR=\"#%02X%02X%02X\">%s</FONT>", |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1018 fgcolor.red/256, fgcolor.green/256, fgcolor.blue/256, buf); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1019 strcpy(buf, tmp); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1020 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1021 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1022 if (gaim_prefs_get_bool("/gaim/gtk/conversations/use_custom_bgcolor")) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1023 GdkColor bgcolor; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1024 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1025 gdk_color_parse( |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1026 gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1027 &bgcolor); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1028 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1029 g_snprintf(tmp, length, "<BODY BGCOLOR=\"#%02X%02X%02X\">%s</BODY>", |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1030 bgcolor.red/256, bgcolor.green/256, bgcolor.blue/256, buf); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1031 strcpy(buf, tmp); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1032 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1033 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1034 g_free(tmp); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1035 return buf; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1036 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1037 |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
1038 void |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
1039 gaim_gtk_find_images(const char *message, GSList **list) |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
1040 { |
7078 | 1041 GData *attribs; |
1042 const char *tmp, *start, *end; | |
1043 | |
7804 | 1044 g_return_if_fail(message != NULL); |
1045 g_return_if_fail( list != NULL); | |
1046 | |
7078 | 1047 tmp = message; |
1048 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
1049 GaimStoredImage *image = NULL; | |
1050 GdkPixbufLoader *loader = NULL; | |
1051 GdkPixbuf *pixbuf = NULL; | |
1052 GError *error = NULL; | |
1053 char *id = g_datalist_get_data(&attribs, "id"); | |
1054 | |
1055 tmp = end + 1; | |
1056 | |
1057 if (id) | |
1058 image = gaim_imgstore_get(atoi(id)); | |
1059 | |
1060 g_datalist_clear(&attribs); | |
1061 | |
1062 if (!image) { | |
1063 *list = g_slist_append(*list, NULL); | |
1064 continue; | |
1065 } | |
1066 | |
1067 loader = gdk_pixbuf_loader_new(); | |
1068 | |
1069 if (gdk_pixbuf_loader_write(loader, image->data, image->size, &error) | |
1070 && (pixbuf = gdk_pixbuf_loader_get_pixbuf(loader))) { | |
1071 | |
1072 if (image->filename) | |
1073 g_object_set_data_full(G_OBJECT(pixbuf), "filename", | |
1074 g_strdup(image->filename), g_free); | |
1075 g_object_ref(G_OBJECT(pixbuf)); | |
1076 *list = g_slist_append(*list, pixbuf); | |
1077 } else { | |
1078 if (error) { | |
1079 gaim_debug(GAIM_DEBUG_ERROR, "gtkutils", | |
1080 "Failed to make pixbuf from image store: %s\n", | |
1081 error->message); | |
1082 g_error_free(error); | |
1083 } else { | |
1084 gaim_debug(GAIM_DEBUG_ERROR, "gtkutils", | |
1085 "Failed to make pixbuf from image store: unknown reason\n"); | |
1086 } | |
1087 *list = g_slist_append(*list, NULL); | |
1088 } | |
1089 | |
1090 gdk_pixbuf_loader_close(loader, NULL); | |
1091 } | |
1092 } | |
7420 | 1093 |
1094 void | |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
1095 gaim_gtk_setup_gtkspell(GtkTextView *textview) |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
1096 { |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
1097 #ifdef USE_GTKSPELL |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
1098 GError *error = NULL; |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
1099 char *locale = NULL; |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
1100 |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
1101 g_return_if_fail(textview != NULL); |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
1102 g_return_if_fail(GTK_IS_TEXT_VIEW(textview)); |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
1103 |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
1104 if (gtkspell_new_attach(textview, locale, &error) == NULL && error) |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
1105 { |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
1106 gaim_debug_warning("gtkspell", "Failed to setup GtkSpell: %s\n", |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
1107 error->message); |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
1108 g_error_free(error); |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
1109 } |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
1110 #endif /* USE_GTKSPELL */ |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
1111 } |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
1112 |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
1113 void |
7420 | 1114 gaim_gtk_save_accels_cb(GtkAccelGroup *accel_group, guint arg1, |
1115 GdkModifierType arg2, GClosure *arg3, | |
1116 gpointer data) | |
1117 { | |
1118 gaim_debug(GAIM_DEBUG_MISC, "accels", "accel changed, scheduling save.\n"); | |
1119 | |
1120 if (!accels_save_timer) | |
1121 accels_save_timer = g_timeout_add(5000, gaim_gtk_save_accels, NULL); | |
1122 } | |
1123 | |
1124 gboolean | |
1125 gaim_gtk_save_accels(gpointer data) | |
1126 { | |
1127 char *filename = NULL; | |
1128 | |
1129 filename = g_build_filename(gaim_user_dir(), G_DIR_SEPARATOR_S, | |
1130 "accels", NULL); | |
1131 gaim_debug(GAIM_DEBUG_MISC, "accels", "saving accels to %s\n", filename); | |
1132 gtk_accel_map_save(filename); | |
1133 g_free(filename); | |
1134 | |
1135 accels_save_timer = 0; | |
1136 return FALSE; | |
1137 } | |
1138 | |
1139 void | |
1140 gaim_gtk_load_accels(gpointer data) | |
1141 { | |
1142 char *filename = NULL; | |
1143 | |
1144 filename = g_build_filename(gaim_user_dir(), G_DIR_SEPARATOR_S, | |
1145 "accels", NULL); | |
1146 gtk_accel_map_load(filename); | |
1147 g_free(filename); | |
1148 } | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1149 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1150 gboolean |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1151 gaim_gtk_parse_x_im_contact(const char *msg, gboolean all_accounts, |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1152 GaimAccount **ret_account, char **ret_protocol, |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1153 char **ret_username, char **ret_alias) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1154 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1155 char *protocol = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1156 char *username = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1157 char *alias = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1158 char *str; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1159 char *c, *s; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1160 gboolean valid; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1161 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1162 g_return_val_if_fail(msg != NULL, FALSE); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1163 g_return_val_if_fail(ret_protocol != NULL, FALSE); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1164 g_return_val_if_fail(ret_username != NULL, FALSE); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1165 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1166 s = str = g_strdup(msg); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1167 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1168 while (*s != '\r' && *s != '\n' && *s != '\0') |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1169 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1170 char *key, *value; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1171 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1172 key = s; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1173 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1174 /* Grab the key */ |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1175 while (*s != '\r' && *s != '\n' && *s != '\0' && *s != ' ') |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1176 s++; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1177 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1178 if (*s == '\r') s++; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1179 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1180 if (*s == '\n') |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1181 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1182 s++; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1183 continue; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1184 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1185 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1186 if (*s != '\0') *s++ = '\0'; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1187 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1188 /* Clear past any whitespace */ |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1189 while (*s != '\0' && *s == ' ') |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1190 s++; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1191 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1192 /* Now let's grab until the end of the line. */ |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1193 value = s; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1194 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1195 while (*s != '\r' && *s != '\n' && *s != '\0') |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1196 s++; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1197 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1198 if (*s == '\r') *s++ = '\0'; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1199 if (*s == '\n') *s++ = '\0'; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1200 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1201 if ((c = strchr(key, ':')) != NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1202 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1203 if (!g_ascii_strcasecmp(key, "X-IM-Username:")) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1204 username = g_strdup(value); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1205 else if (!g_ascii_strcasecmp(key, "X-IM-Protocol:")) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1206 protocol = g_strdup(value); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1207 else if (!g_ascii_strcasecmp(key, "X-IM-Alias:")) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1208 alias = g_strdup(value); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1209 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1210 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1211 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1212 if (username != NULL && protocol != NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1213 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1214 valid = TRUE; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1215 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1216 *ret_username = username; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1217 *ret_protocol = protocol; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1218 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1219 if (ret_alias != NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1220 *ret_alias = alias; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1221 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1222 /* Check for a compatible account. */ |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1223 if (ret_account != NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1224 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1225 GList *list; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1226 GaimAccount *account = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1227 GList *l; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1228 const char *protoname; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1229 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1230 if (all_accounts) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1231 list = gaim_accounts_get_all(); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1232 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1233 list = gaim_connections_get_all(); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1234 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1235 for (l = list; l != NULL; l = l->next) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1236 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1237 GaimConnection *gc; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1238 GaimPluginProtocolInfo *prpl_info = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1239 GaimPlugin *plugin; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1240 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1241 if (all_accounts) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1242 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1243 account = (GaimAccount *)l->data; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1244 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1245 plugin = gaim_plugins_find_with_id( |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1246 gaim_account_get_protocol_id(account)); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1247 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1248 if (plugin == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1249 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1250 account = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1251 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1252 continue; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1253 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1254 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1255 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1256 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1257 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1258 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1259 gc = (GaimConnection *)l->data; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1260 account = gaim_connection_get_account(gc); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1261 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1262 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1263 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1264 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1265 protoname = prpl_info->list_icon(account, NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1266 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1267 if (!strcmp(protoname, protocol)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1268 break; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1269 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1270 account = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1271 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1272 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1273 /* Special case for AIM and ICQ */ |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1274 if (account == NULL && (!strcmp(protocol, "aim") || |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1275 !strcmp(protocol, "icq"))) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1276 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1277 for (l = list; l != NULL; l = l->next) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1278 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1279 GaimConnection *gc; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1280 GaimPluginProtocolInfo *prpl_info = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1281 GaimPlugin *plugin; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1282 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1283 if (all_accounts) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1284 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1285 account = (GaimAccount *)l->data; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1286 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1287 plugin = gaim_plugins_find_with_id( |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1288 gaim_account_get_protocol_id(account)); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1289 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1290 if (plugin == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1291 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1292 account = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1293 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1294 continue; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1295 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1296 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1297 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1298 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1299 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1300 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1301 gc = (GaimConnection *)l->data; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1302 account = gaim_connection_get_account(gc); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1303 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1304 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1305 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1306 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1307 protoname = prpl_info->list_icon(account, NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1308 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1309 if (!strcmp(protoname, "aim") || !strcmp(protoname, "icq")) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1310 break; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1311 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1312 account = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1313 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1314 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1315 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1316 *ret_account = account; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1317 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1318 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1319 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1320 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1321 valid = FALSE; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1322 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1323 if (username != NULL) g_free(username); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1324 if (protocol != NULL) g_free(protocol); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1325 if (alias != NULL) g_free(alias); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1326 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1327 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1328 g_free(str); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1329 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1330 return valid; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1331 } |