Mercurial > pidgin
annotate src/gtkutils.c @ 7518:3177568fc346
[gaim-migrate @ 8131]
better
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Sat, 15 Nov 2003 17:50:31 +0000 |
parents | 53c86d59f20b |
children | 357eb1c39b72 |
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 |
4359 | 33 #include <gdk/gdkkeysyms.h> |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
34 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
35 #include "debug.h" |
7078 | 36 #include "imgstore.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
37 #include "notify.h" |
5548 | 38 #include "prefs.h" |
4359 | 39 #include "prpl.h" |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
40 #include "signals.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
41 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
42 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
43 #include "gtkconv.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
44 #include "gtkimhtml.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
45 #include "gtkutils.h" |
4359 | 46 #include "ui.h" |
47 | |
4859
a9a831508b43
[gaim-migrate @ 5186]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4793
diff
changeset
|
48 #ifdef _WIN32 |
a9a831508b43
[gaim-migrate @ 5186]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4793
diff
changeset
|
49 #include "wspell.h" |
a9a831508b43
[gaim-migrate @ 5186]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4793
diff
changeset
|
50 #endif |
4359 | 51 |
7420 | 52 guint accels_save_timer = 0; |
53 | |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
54 static void |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
55 url_clicked_cb(GtkWidget *w, const char *uri) |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
56 { |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
57 gaim_notify_uri(NULL, uri); |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
58 } |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
59 |
4359 | 60 void |
61 gaim_setup_imhtml(GtkWidget *imhtml) | |
62 { | |
63 g_return_if_fail(imhtml != NULL); | |
64 g_return_if_fail(GTK_IS_IMHTML(imhtml)); | |
65 | |
5548 | 66 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/show_smileys")) |
4359 | 67 gtk_imhtml_show_smileys(GTK_IMHTML(imhtml), FALSE); |
68 | |
69 g_signal_connect(G_OBJECT(imhtml), "url_clicked", | |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
70 G_CALLBACK(url_clicked_cb), NULL); |
4359 | 71 |
72 smiley_themeize(imhtml); | |
73 } | |
74 | |
75 void | |
76 toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle) | |
77 { | |
78 gboolean sensitivity = GTK_WIDGET_IS_SENSITIVE(to_toggle); | |
79 | |
80 gtk_widget_set_sensitive(to_toggle, !sensitivity); | |
81 } | |
82 | |
83 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
84 gaim_gtk_remove_tags(GaimGtkConversation *gtkconv, const char *tag) |
4359 | 85 { |
86 GtkTextIter start, end, m_start, m_end; | |
87 | |
88 if (gtkconv == NULL || tag == NULL) | |
89 return; | |
90 | |
91 if (!gtk_text_buffer_get_selection_bounds(gtkconv->entry_buffer, | |
92 &start, &end)) | |
93 return; | |
94 | |
95 /* FIXMEif (strstr(tag, "<FONT SIZE=")) { | |
96 while ((t = strstr(t, "<FONT SIZE="))) { | |
97 if (((t - s) < finish) && ((t - s) >= start)) { | |
98 gtk_editable_delete_text(GTK_EDITABLE(entry), (t - s), | |
99 (t - s) + strlen(tag)); | |
100 g_free(s); | |
101 s = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); | |
102 t = s; | |
103 } else | |
104 t++; | |
105 } | |
106 } else*/ { | |
107 while (gtk_text_iter_forward_search(&start, tag, 0, &m_start, | |
108 &m_end, &end)) { | |
109 | |
110 gtk_text_buffer_delete(gtkconv->entry_buffer, &m_start, &m_end); | |
111 gtk_text_buffer_get_selection_bounds(gtkconv->entry_buffer, | |
112 &start, &end); | |
113 } | |
114 } | |
115 } | |
116 | |
117 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
118 gaim_gtk_surround(GaimGtkConversation *gtkconv, |
4359 | 119 const char *pre, const char *post) |
120 { | |
121 GtkTextIter start, end; | |
122 GtkTextMark *mark_start, *mark_end; | |
123 GtkTextBuffer *entry_buffer; | |
124 | |
125 if (gtkconv == NULL || pre == NULL || post == NULL) | |
126 return; | |
127 | |
128 entry_buffer = gtkconv->entry_buffer; | |
129 | |
130 if (gtk_text_buffer_get_selection_bounds(entry_buffer, | |
131 &start, &end)) { | |
132 gaim_gtk_remove_tags(gtkconv, pre); | |
133 gaim_gtk_remove_tags(gtkconv, post); | |
134 | |
135 mark_start = gtk_text_buffer_create_mark(entry_buffer, "m1", | |
136 &start, TRUE); | |
137 mark_end = gtk_text_buffer_create_mark(entry_buffer, "m2", | |
138 &end, FALSE); | |
139 gtk_text_buffer_insert(entry_buffer, &start, pre, -1); | |
140 gtk_text_buffer_get_selection_bounds(entry_buffer, &start, &end); | |
141 gtk_text_buffer_insert(entry_buffer, &end, post, -1); | |
142 gtk_text_buffer_get_iter_at_mark(entry_buffer, &start, mark_start); | |
143 gtk_text_buffer_move_mark_by_name(entry_buffer, "selection_bound", | |
144 &start); | |
145 } else { | |
146 gtk_text_buffer_insert(entry_buffer, &start, pre, -1); | |
147 gtk_text_buffer_insert(entry_buffer, &start, post, -1); | |
148 mark_start = gtk_text_buffer_get_insert(entry_buffer); | |
149 gtk_text_buffer_get_iter_at_mark(entry_buffer, &start, mark_start); | |
150 gtk_text_iter_backward_chars(&start, strlen(post)); | |
151 gtk_text_buffer_place_cursor(entry_buffer, &start); | |
152 } | |
153 | |
154 gtk_widget_grab_focus(gtkconv->entry); | |
155 } | |
156 | |
157 static gboolean | |
158 invert_tags(GtkTextBuffer *buffer, const char *s1, const char *s2, | |
159 gboolean really) | |
160 { | |
161 GtkTextIter start1, start2, end1, end2; | |
162 char *b1, *b2; | |
163 | |
164 if (gtk_text_buffer_get_selection_bounds(buffer, &start1, &end2)) { | |
165 start2 = start1; | |
166 end1 = end2; | |
167 | |
168 if (!gtk_text_iter_forward_chars(&start2, strlen(s1))) | |
169 return FALSE; | |
170 | |
171 if (!gtk_text_iter_backward_chars(&end1, strlen(s2))) | |
172 return FALSE; | |
173 | |
174 b1 = gtk_text_buffer_get_text(buffer, &start1, &start2, FALSE); | |
175 b2 = gtk_text_buffer_get_text(buffer, &end1, &end2, FALSE); | |
176 | |
4793 | 177 if (!g_ascii_strncasecmp(b1, s1, strlen(s1)) && |
178 !g_ascii_strncasecmp(b2, s2, strlen(s2))) { | |
4359 | 179 |
180 if (really) { | |
181 GtkTextMark *m_end1, *m_end2; | |
182 | |
183 m_end1= gtk_text_buffer_create_mark(buffer, "m1", &end1, TRUE); | |
184 m_end2= gtk_text_buffer_create_mark(buffer, "m2", &end2, TRUE); | |
185 | |
186 gtk_text_buffer_delete(buffer, &start1, &start2); | |
187 gtk_text_buffer_get_iter_at_mark(buffer, &end1, m_end1); | |
188 gtk_text_buffer_get_iter_at_mark(buffer, &end2, m_end2); | |
189 gtk_text_buffer_delete(buffer, &end1, &end2); | |
190 gtk_text_buffer_delete_mark(buffer, m_end1); | |
191 gtk_text_buffer_delete_mark(buffer, m_end2); | |
192 } | |
193 | |
194 g_free(b1); | |
195 g_free(b2); | |
196 | |
197 return TRUE; | |
198 } | |
199 | |
200 g_free(b1); | |
201 g_free(b2); | |
202 } | |
203 | |
204 return FALSE; | |
205 } | |
206 | |
207 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
208 gaim_gtk_advance_past(GaimGtkConversation *gtkconv, |
4359 | 209 const char *pre, const char *post) |
210 { | |
211 GtkTextIter current_pos, start, end; | |
212 | |
213 if (invert_tags(gtkconv->entry_buffer, pre, post, TRUE)) | |
214 return; | |
215 | |
216 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, ¤t_pos, | |
217 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
218 | |
219 if (gtk_text_iter_forward_search(¤t_pos, post, 0, | |
220 &start, &end, NULL)) | |
221 gtk_text_buffer_place_cursor(gtkconv->entry_buffer, &end); | |
222 else | |
223 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, post, -1); | |
224 | |
225 gtk_widget_grab_focus(gtkconv->entry); | |
226 } | |
227 | |
228 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
229 gaim_gtk_set_font_face(GaimGtkConversation *gtkconv, |
4359 | 230 const char *font) |
231 { | |
232 char *pre_fontface; | |
233 | |
234 if (gtkconv == NULL || font == NULL) | |
235 return; | |
236 | |
237 strncpy(gtkconv->fontface, | |
238 (font && *font ? font : DEFAULT_FONT_FACE), | |
239 sizeof(gtkconv->fontface)); | |
240 | |
241 gtkconv->has_font = TRUE; | |
242 | |
243 pre_fontface = g_strconcat("<FONT FACE=\"", | |
244 gtkconv->fontface, "\">", NULL); | |
245 gaim_gtk_surround(gtkconv, pre_fontface, "</FONT>"); | |
246 | |
247 gtk_widget_grab_focus(gtkconv->entry); | |
248 | |
249 g_free(pre_fontface); | |
250 } | |
251 | |
252 static int | |
253 des_save_icon(GtkObject *obj, GdkEvent *e, | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
254 GaimGtkConversation *gtkconv) |
4359 | 255 { |
256 gtk_widget_destroy(gtkconv->u.im->save_icon); | |
257 gtkconv->u.im->save_icon = NULL; | |
258 | |
259 return TRUE; | |
260 } | |
261 | |
262 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
263 do_save_icon(GtkObject *obj, GaimConversation *c) |
4359 | 264 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
265 GaimGtkConversation *gtkconv; |
4359 | 266 FILE *file; |
267 const char *f; | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6652
diff
changeset
|
268 |
4359 | 269 gtkconv = GAIM_GTK_CONVERSATION(c); |
270 | |
271 f = gtk_file_selection_get_filename( | |
272 GTK_FILE_SELECTION(gtkconv->u.im->save_icon)); | |
273 | |
5966 | 274 if (gaim_gtk_check_if_dir(f, GTK_FILE_SELECTION(gtkconv->u.im->save_icon))) |
4359 | 275 return; |
276 | |
277 if ((file = fopen(f, "w")) != NULL) { | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7102
diff
changeset
|
278 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
|
279 size_t len; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6652
diff
changeset
|
280 const void *data = gaim_buddy_icon_get_data(icon, &len); |
4359 | 281 |
282 if (data) | |
283 fwrite(data, 1, len, file); | |
284 | |
285 fclose(file); | |
286 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
287 gaim_notify_error(NULL, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
288 _("Can't save icon file to disk."), NULL); |
4359 | 289 } |
290 | |
291 gtk_widget_destroy(gtkconv->u.im->save_icon); | |
292 gtkconv->u.im->save_icon = NULL; | |
293 } | |
294 | |
295 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
296 cancel_save_icon(GtkObject *obj, GaimGtkConversation *gtkconv) |
4359 | 297 { |
298 gtk_widget_destroy(gtkconv->u.im->save_icon); | |
299 gtkconv->u.im->save_icon = NULL; | |
300 } | |
301 | |
302 | |
303 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
304 gaim_gtk_save_icon_dialog(GtkObject *obj, GaimConversation *conv) |
4359 | 305 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
306 GaimGtkConversation *gtkconv; |
4359 | 307 char buf[BUF_LEN]; |
308 | |
309 if (conv == NULL || gaim_conversation_get_type(conv) != GAIM_CONV_IM) | |
310 return; | |
311 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
312 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 313 return; |
314 | |
315 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
316 | |
317 if (gtkconv->u.im->save_icon != NULL) | |
318 { | |
319 gdk_window_raise(gtkconv->u.im->save_icon->window); | |
320 return; | |
321 } | |
322 | |
323 gtkconv->u.im->save_icon = gtk_file_selection_new(_("Gaim - Save Icon")); | |
324 | |
325 gtk_file_selection_hide_fileop_buttons( | |
326 GTK_FILE_SELECTION(gtkconv->u.im->save_icon)); | |
327 | |
328 g_snprintf(buf, BUF_LEN - 1, | |
329 "%s" G_DIR_SEPARATOR_S "%s.icon", | |
330 gaim_home_dir(), gaim_conversation_get_name(conv)); | |
331 | |
332 gtk_file_selection_set_filename( | |
333 GTK_FILE_SELECTION(gtkconv->u.im->save_icon), buf); | |
334 | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
335 g_signal_connect(G_OBJECT(gtkconv->u.im->save_icon), "delete_event", |
4359 | 336 G_CALLBACK(des_save_icon), gtkconv); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
337 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(gtkconv->u.im->save_icon)->ok_button), "clicked", |
4359 | 338 G_CALLBACK(do_save_icon), conv); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
339 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(gtkconv->u.im->save_icon)->cancel_button), "clicked", |
4359 | 340 G_CALLBACK(cancel_save_icon), gtkconv); |
341 | |
342 gtk_widget_show(gtkconv->u.im->save_icon); | |
343 } | |
344 | |
345 int | |
346 gaim_gtk_get_dispstyle(GaimConversationType type) | |
347 { | |
348 int dispstyle = 2; | |
5554
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
349 int value; |
4359 | 350 |
351 if (type == GAIM_CONV_CHAT) { | |
5554
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
352 value = gaim_prefs_get_int("/gaim/gtk/conversations/chat/button_type"); |
4359 | 353 |
5554
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
354 switch (value) { |
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
355 case GAIM_BUTTON_TEXT: dispstyle = 1; break; |
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
356 case GAIM_BUTTON_IMAGE: dispstyle = 0; break; |
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
357 default: dispstyle = 2; break; /* both/neither */ |
4359 | 358 } |
359 } | |
360 else if (type == GAIM_CONV_IM) { | |
5554
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
361 value = gaim_prefs_get_int("/gaim/gtk/conversations/im/button_type"); |
4359 | 362 |
5554
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
363 switch (value) { |
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
364 case GAIM_BUTTON_TEXT: dispstyle = 1; break; |
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
365 case GAIM_BUTTON_IMAGE: dispstyle = 0; break; |
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
366 default: dispstyle = 2; break; /* both/neither */ |
4359 | 367 } |
368 } | |
369 | |
370 return dispstyle; | |
371 } | |
372 | |
373 GtkWidget * | |
374 gaim_gtk_change_text(const char *text, GtkWidget *button, | |
375 const char *stock, GaimConversationType type) | |
376 { | |
377 int dispstyle = gaim_gtk_get_dispstyle(type); | |
378 | |
379 if (button != NULL) | |
380 gtk_widget_destroy(button); | |
381 | |
382 button = gaim_pixbuf_button_from_stock((dispstyle == 0 ? NULL : text), | |
383 (dispstyle == 1 ? NULL : stock), | |
384 GAIM_BUTTON_VERTICAL); | |
385 | |
386 gtk_widget_show(button); | |
387 | |
388 return button; | |
389 } | |
390 | |
391 void | |
392 gaim_gtk_toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle) | |
393 { | |
394 gboolean sensitivity; | |
395 | |
396 if (to_toggle == NULL) | |
397 return; | |
398 | |
399 sensitivity = GTK_WIDGET_IS_SENSITIVE(to_toggle); | |
400 | |
401 gtk_widget_set_sensitive(to_toggle, !sensitivity); | |
402 } | |
403 | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
404 void |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
405 gtk_toggle_sensitive_array(GtkWidget *w, GPtrArray *data) |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
406 { |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
407 gboolean sensitivity; |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
408 gpointer element; |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
409 int i; |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
410 |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
411 for (i=0; i < data->len; i++) { |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
412 element = g_ptr_array_index(data,i); |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
413 if (element == NULL) |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
414 continue; |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
415 |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
416 sensitivity = GTK_WIDGET_IS_SENSITIVE(element); |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
417 |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
418 gtk_widget_set_sensitive(element, !sensitivity); |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
419 } |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
420 } |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
421 |
4687 | 422 void gaim_separator(GtkWidget *menu) |
423 { | |
424 GtkWidget *menuitem; | |
425 | |
426 menuitem = gtk_separator_menu_item_new(); | |
427 gtk_widget_show(menuitem); | |
428 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
429 } | |
5160 | 430 |
5162 | 431 GtkWidget *gaim_new_item(GtkWidget *menu, const char *str) |
432 { | |
433 GtkWidget *menuitem; | |
434 GtkWidget *label; | |
435 | |
436 menuitem = gtk_menu_item_new(); | |
437 if (menu) | |
438 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
439 gtk_widget_show(menuitem); | |
440 | |
441 label = gtk_label_new(str); | |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6236
diff
changeset
|
442 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
5162 | 443 gtk_label_set_pattern(GTK_LABEL(label), "_"); |
444 gtk_container_add(GTK_CONTAINER(menuitem), label); | |
445 gtk_widget_show(label); | |
446 /* FIXME: Go back and fix this | |
447 gtk_widget_add_accelerator(menuitem, "activate", accel, str[0], | |
448 GDK_MOD1_MASK, GTK_ACCEL_LOCKED); | |
449 */ | |
450 return menuitem; | |
451 } | |
452 | |
5906 | 453 GtkWidget *gaim_new_check_item(GtkWidget *menu, const char *str, |
454 GtkSignalFunc sf, gpointer data, gboolean checked) | |
455 { | |
456 GtkWidget *menuitem; | |
457 menuitem = gtk_check_menu_item_new_with_mnemonic(str); | |
458 | |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
459 if (menu) |
5906 | 460 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); |
461 | |
7299
2737c287f84d
[gaim-migrate @ 7883]
Christian Hammond <chipx86@chipx86.com>
parents:
7118
diff
changeset
|
462 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
|
463 |
5906 | 464 if (sf) |
465 g_signal_connect(G_OBJECT(menuitem), "activate", sf, data); | |
466 | |
467 gtk_widget_show_all(menuitem); | |
468 | |
469 return menuitem; | |
470 } | |
471 | |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
472 GtkWidget * |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
473 gaim_pixbuf_toolbar_button_from_stock(const char *icon) |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
474 { |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
475 GtkWidget *button, *image, *bbox; |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
476 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
477 button = gtk_toggle_button_new(); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
478 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
479 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
480 bbox = gtk_vbox_new(FALSE, 0); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
481 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
482 gtk_container_add (GTK_CONTAINER(button), bbox); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
483 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
484 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_MENU); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
485 gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
486 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
487 gtk_widget_show_all(bbox); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
488 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
489 return button; |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
490 } |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
491 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
492 GtkWidget * |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
493 gaim_pixbuf_button_from_stock(const char *text, const char *icon, |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
494 GaimButtonOrientation style) |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
495 { |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
496 GtkWidget *button, *image, *label, *bbox, *ibox, *lbox; |
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 button = gtk_button_new(); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
499 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
500 if (style == GAIM_BUTTON_HORIZONTAL) { |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
501 bbox = gtk_hbox_new(FALSE, 5); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
502 ibox = gtk_hbox_new(FALSE, 0); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
503 lbox = gtk_hbox_new(FALSE, 0); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
504 } |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
505 else { |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
506 bbox = gtk_vbox_new(FALSE, 5); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
507 ibox = gtk_vbox_new(FALSE, 0); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
508 lbox = gtk_vbox_new(FALSE, 0); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
509 } |
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 gtk_container_add (GTK_CONTAINER(button), bbox); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
512 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
513 gtk_box_pack_start_defaults(GTK_BOX(bbox), ibox); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
514 gtk_box_pack_start_defaults(GTK_BOX(bbox), lbox); |
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 if (icon) { |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
517 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_BUTTON); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
518 gtk_box_pack_end(GTK_BOX(ibox), image, FALSE, FALSE, 0); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
519 } |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
520 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
521 if (text) { |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
522 label = gtk_label_new(NULL); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
523 gtk_label_set_text_with_mnemonic(GTK_LABEL(label), text); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
524 gtk_label_set_mnemonic_widget(GTK_LABEL(label), button); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
525 gtk_box_pack_start(GTK_BOX(lbox), label, FALSE, FALSE, 0); |
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 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
528 gtk_widget_show_all(bbox); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
529 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
530 return button; |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
531 } |
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 |
5160 | 534 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) |
535 { | |
536 GtkWidget *menuitem; | |
537 /* | |
538 GtkWidget *hbox; | |
539 GtkWidget *label; | |
540 */ | |
541 GtkWidget *image; | |
542 | |
543 if (icon == NULL) | |
544 menuitem = gtk_menu_item_new_with_mnemonic(str); | |
545 else | |
546 menuitem = gtk_image_menu_item_new_with_mnemonic(str); | |
547 | |
548 if (menu) | |
549 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
550 | |
551 if (sf) | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
552 g_signal_connect(G_OBJECT(menuitem), "activate", sf, data); |
5160 | 553 |
554 if (icon != NULL) { | |
555 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_MENU); | |
556 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); | |
557 } | |
558 /* FIXME: this isn't right | |
559 if (mod) { | |
560 label = gtk_label_new(mod); | |
561 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 2); | |
562 gtk_widget_show(label); | |
563 } | |
564 */ | |
565 /* | |
566 if (accel_key) { | |
567 gtk_widget_add_accelerator(menuitem, "activate", accel, accel_key, | |
568 accel_mods, GTK_ACCEL_LOCKED); | |
569 } | |
570 */ | |
571 | |
572 gtk_widget_show_all(menuitem); | |
573 | |
574 return menuitem; | |
575 } | |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
576 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
577 GtkWidget * |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
578 gaim_gtk_make_frame(GtkWidget *parent, const char *title) |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
579 { |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
580 GtkWidget *vbox, *label, *hbox; |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
581 char labeltitle[256]; |
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 vbox = gtk_vbox_new(FALSE, 6); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
584 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
|
585 gtk_widget_show(vbox); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
586 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
587 label = gtk_label_new(NULL); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
588 g_snprintf(labeltitle, sizeof(labeltitle), |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
589 "<span weight=\"bold\">%s</span>", title); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
590 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
591 gtk_label_set_markup(GTK_LABEL(label), labeltitle); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
592 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
593 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
|
594 gtk_widget_show(label); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
595 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
596 hbox = gtk_hbox_new(FALSE, 6); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
597 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
|
598 gtk_widget_show(hbox); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
599 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
600 label = gtk_label_new(" "); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
601 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
|
602 gtk_widget_show(label); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
603 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
604 vbox = gtk_vbox_new(FALSE, 6); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
605 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
|
606 gtk_widget_show(vbox); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
607 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
608 return vbox; |
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 |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
611 static void |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
612 protocol_menu_cb(GtkWidget *optmenu, GCallback cb) |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
613 { |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
614 GtkWidget *menu; |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
615 GtkWidget *item; |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
616 GaimProtocol protocol; |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
617 gpointer user_data; |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
618 |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
619 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
620 item = gtk_menu_get_active(GTK_MENU(menu)); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
621 |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
622 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
|
623 user_data = (g_object_get_data(G_OBJECT(optmenu), "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 if (cb != NULL) |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
626 ((void (*)(GtkWidget *, GaimProtocol, gpointer))cb)(item, protocol, |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
627 user_data); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
628 } |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
629 |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
630 GtkWidget * |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
631 gaim_gtk_protocol_option_menu_new(GaimProtocol protocol, GCallback cb, |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
632 gpointer user_data) |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
633 { |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
634 GaimPluginProtocolInfo *prpl_info; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
635 GaimPlugin *plugin; |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
636 GtkWidget *hbox; |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
637 GtkWidget *label; |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
638 GtkWidget *optmenu; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
639 GtkWidget *menu; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
640 GtkWidget *item; |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
641 GtkWidget *image; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
642 GdkPixbuf *pixbuf; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
643 GdkPixbuf *scale; |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
644 GList *p; |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
645 GtkSizeGroup *sg; |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
646 char *filename; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
647 const char *proto_name; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
648 char buf[256]; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
649 int i, selected_index = -1; |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
650 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
651 optmenu = gtk_option_menu_new(); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
652 gtk_widget_show(optmenu); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
653 |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
654 g_object_set_data(G_OBJECT(optmenu), "user_data", user_data); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
655 |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
656 menu = gtk_menu_new(); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
657 gtk_widget_show(menu); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
658 |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
659 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
660 |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
661 for (p = gaim_plugins_get_protocols(), i = 0; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
662 p != NULL; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
663 p = p->next, i++) { |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
664 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
665 plugin = (GaimPlugin *)p->data; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
666 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
667 |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
668 /* Create the item. */ |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
669 item = gtk_menu_item_new(); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
670 |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
671 /* Create the hbox. */ |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
672 hbox = gtk_hbox_new(FALSE, 4); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
673 gtk_container_add(GTK_CONTAINER(item), hbox); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
674 gtk_widget_show(hbox); |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
675 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
676 /* Load the image. */ |
6430 | 677 proto_name = prpl_info->list_icon(NULL, NULL); |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
678 g_snprintf(buf, sizeof(buf), "%s.png", proto_name); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
679 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
680 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
681 "default", buf, NULL); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
682 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
683 g_free(filename); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
684 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
685 if (pixbuf != NULL) { |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
686 /* Scale and insert the image */ |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
687 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
688 GDK_INTERP_BILINEAR); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
689 image = gtk_image_new_from_pixbuf(scale); |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
690 |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
691 g_object_unref(G_OBJECT(pixbuf)); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
692 g_object_unref(G_OBJECT(scale)); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
693 } |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
694 else |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
695 image = gtk_image_new(); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
696 |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
697 gtk_size_group_add_widget(sg, image); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
698 |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
699 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
700 gtk_widget_show(image); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
701 |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
702 /* Create the label. */ |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
703 label = gtk_label_new(plugin->info->name); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
704 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
705 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
706 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
707 gtk_widget_show(label); |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
708 |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
709 g_object_set_data(G_OBJECT(item), "protocol", |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
710 GINT_TO_POINTER(prpl_info->protocol)); |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
711 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
712 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
713 gtk_widget_show(item); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
714 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
715 if (prpl_info->protocol == protocol) |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
716 selected_index = i; |
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 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
719 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu); |
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 (selected_index != -1) |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
722 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), selected_index); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
723 |
5688
e43e1b8dca8b
[gaim-migrate @ 6109]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
724 g_signal_connect(G_OBJECT(optmenu), "changed", |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
725 G_CALLBACK(protocol_menu_cb), cb); |
5688
e43e1b8dca8b
[gaim-migrate @ 6109]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
726 |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
727 g_object_unref(sg); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
728 |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
729 return optmenu; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
730 } |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
731 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
732 static void |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
733 account_menu_cb(GtkWidget *optmenu, GCallback cb) |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
734 { |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
735 GtkWidget *menu; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
736 GtkWidget *item; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
737 GaimAccount *account; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
738 gpointer user_data; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
739 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
740 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
741 item = gtk_menu_get_active(GTK_MENU(menu)); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
742 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
743 account = g_object_get_data(G_OBJECT(item), "account"); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
744 user_data = g_object_get_data(G_OBJECT(optmenu), "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 if (cb != NULL) |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
747 ((void (*)(GtkWidget *, GaimAccount *, gpointer))cb)(item, account, |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
748 user_data); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
749 } |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
750 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
751 static void |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
752 create_account_menu(GtkWidget *optmenu, GaimAccount *default_account, |
6646
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
753 GaimCheckAccountFunc check_account_func, gboolean show_all) |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
754 { |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
755 GaimAccount *account; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
756 GtkWidget *menu; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
757 GtkWidget *item; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
758 GtkWidget *image; |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
759 GtkWidget *hbox; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
760 GtkWidget *label; |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
761 GdkPixbuf *pixbuf; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
762 GdkPixbuf *scale; |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
763 GList *list; |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
764 GList *p; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
765 GtkSizeGroup *sg; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
766 char *filename; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
767 const char *proto_name; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
768 char buf[256]; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
769 int i, selected_index = -1; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
770 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
771 if (show_all) |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
772 list = gaim_accounts_get_all(); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
773 else |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
774 list = gaim_connections_get_all(); |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
775 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
776 menu = gtk_menu_new(); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
777 gtk_widget_show(menu); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
778 |
5880
1b85ff65be57
[gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
779 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
780 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
781 for (p = list, i = 0; p != NULL; p = p->next, i++) { |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
782 GaimPluginProtocolInfo *prpl_info = NULL; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
783 GaimPlugin *plugin; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
784 |
5879
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
785 if (show_all) |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
786 account = (GaimAccount *)p->data; |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
787 else { |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
788 GaimConnection *gc = (GaimConnection *)p->data; |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
789 |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
790 account = gaim_connection_get_account(gc); |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
791 } |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
792 |
6652 | 793 if (check_account_func && !check_account_func(account)) |
6646
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
794 continue; |
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
795 |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
796 plugin = gaim_find_prpl(gaim_account_get_protocol(account)); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
797 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
798 if (plugin != NULL) |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
799 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
800 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
801 /* Create the item. */ |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
802 item = gtk_menu_item_new(); |
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 /* Create the hbox. */ |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
805 hbox = gtk_hbox_new(FALSE, 4); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
806 gtk_container_add(GTK_CONTAINER(item), hbox); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
807 gtk_widget_show(hbox); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
808 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
809 /* Load the image. */ |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
810 if (prpl_info != NULL) { |
6430 | 811 proto_name = prpl_info->list_icon(account, NULL); |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
812 g_snprintf(buf, sizeof(buf), "%s.png", proto_name); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
813 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
814 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
815 "default", buf, NULL); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
816 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
817 g_free(filename); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
818 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
819 if (pixbuf != NULL) { |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
820 /* Scale and insert the image */ |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
821 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
822 GDK_INTERP_BILINEAR); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
823 image = gtk_image_new_from_pixbuf(scale); |
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 g_object_unref(G_OBJECT(pixbuf)); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
826 g_object_unref(G_OBJECT(scale)); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
827 } |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
828 else |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
829 image = gtk_image_new(); |
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 else |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
832 image = gtk_image_new(); |
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 gtk_size_group_add_widget(sg, image); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
835 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
836 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
837 gtk_widget_show(image); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
838 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
839 g_snprintf(buf, sizeof(buf), "%s (%s)", |
6236 | 840 gaim_account_get_username(account), |
841 (plugin != NULL) ? plugin->info->name : _("Unknown")); | |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
842 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
843 /* Create the label. */ |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
844 label = gtk_label_new(buf); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
845 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
846 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
847 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
848 gtk_widget_show(label); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
849 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
850 g_object_set_data(G_OBJECT(item), "account", account); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
851 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
852 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
853 gtk_widget_show(item); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
854 |
5880
1b85ff65be57
[gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
855 if (default_account != NULL && account == default_account) |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
856 selected_index = i; |
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 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
859 g_object_unref(sg); |
5880
1b85ff65be57
[gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
860 |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
861 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
862 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
863 /* Set the place we should be at. */ |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
864 if (selected_index != -1) |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
865 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
|
866 } |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
867 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
868 static void |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
869 account_menu_sign_on_off_cb(GaimConnection *gc, GtkWidget *optmenu) |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
870 { |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
871 GtkWidget *menu; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
872 GtkWidget *item; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
873 gboolean show_all; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
874 GaimAccount *account; |
6646
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
875 GaimCheckAccountFunc check_account_func; |
6391
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 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
878 item = gtk_menu_get_active(GTK_MENU(menu)); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
879 account = g_object_get_data(G_OBJECT(item), "account"); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
880 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
881 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
|
882 "show_all")); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
883 |
6646
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
884 check_account_func = g_object_get_data(G_OBJECT(item), |
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
885 "check_account_func"); |
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
886 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
887 gtk_option_menu_remove_menu(GTK_OPTION_MENU(optmenu)); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
888 |
6646
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
889 create_account_menu(optmenu, account, check_account_func, show_all); |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
890 } |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
891 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
892 static gboolean |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
893 account_menu_destroyed_cb(GtkWidget *optmenu, GdkEvent *event, |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
894 void *user_data) |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
895 { |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
896 gaim_signals_disconnect_by_handle(optmenu); |
6391
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 return FALSE; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
899 } |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
900 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
901 GtkWidget * |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
902 gaim_gtk_account_option_menu_new(GaimAccount *default_account, |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
903 gboolean show_all, GCallback cb, |
6646
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
904 GaimCheckAccountFunc check_account_func, |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
905 gpointer user_data) |
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 *optmenu; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
908 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
909 /* Create the option menu */ |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
910 optmenu = gtk_option_menu_new(); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
911 gtk_widget_show(optmenu); |
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 g_signal_connect(G_OBJECT(optmenu), "destroy", |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
914 G_CALLBACK(account_menu_destroyed_cb), NULL); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
915 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
916 /* Register the gaim sign on/off event callbacks. */ |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
917 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
918 optmenu, GAIM_CALLBACK(account_menu_sign_on_off_cb), |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
919 optmenu); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
920 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
921 optmenu, GAIM_CALLBACK(account_menu_sign_on_off_cb), |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
922 optmenu); |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
923 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
924 /* Set some data. */ |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
925 g_object_set_data(G_OBJECT(optmenu), "user_data", user_data); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
926 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
|
927 g_object_set_data(G_OBJECT(optmenu), "chck_account_func", |
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
928 check_account_func); |
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 /* Create and set the actual menu. */ |
6646
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
931 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
|
932 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
933 /* And now the last callback. */ |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
934 g_signal_connect(G_OBJECT(optmenu), "changed", |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
935 G_CALLBACK(account_menu_cb), cb); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
936 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
937 return optmenu; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
938 } |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
939 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
940 gboolean |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
941 gaim_gtk_check_if_dir(const char *path, GtkFileSelection *filesel) |
5966 | 942 { |
5967 | 943 char *dirname; |
5966 | 944 |
5967 | 945 if (g_file_test(path, G_FILE_TEST_IS_DIR)) { |
5966 | 946 /* append a / if needed */ |
947 if (path[strlen(path) - 1] != '/') { | |
5967 | 948 dirname = g_strconcat(path, "/", NULL); |
5966 | 949 } else { |
5967 | 950 dirname = g_strdup(path); |
5966 | 951 } |
5967 | 952 gtk_file_selection_set_filename(filesel, dirname); |
953 g_free(dirname); | |
5966 | 954 return TRUE; |
955 } | |
956 | |
957 return FALSE; | |
958 } | |
959 | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
960 char *stylize(const gchar *text, int length) |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
961 { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
962 gchar *buf; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
963 char *tmp = g_malloc(length); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
964 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
965 buf = g_malloc(length); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
966 g_snprintf(buf, length, "%s", text); |
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 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold")) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
969 g_snprintf(tmp, length, "<B>%s</B>", buf); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
970 strcpy(buf, tmp); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
971 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
972 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
973 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_italic")) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
974 g_snprintf(tmp, length, "<I>%s</I>", buf); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
975 strcpy(buf, tmp); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
976 } |
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 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_underline")) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
979 g_snprintf(tmp, length, "<U>%s</U>", buf); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
980 strcpy(buf, tmp); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
981 } |
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 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_strikethrough")) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
984 g_snprintf(tmp, length, "<S>%s</S>", buf); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
985 strcpy(buf, tmp); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
986 } |
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 if (gaim_prefs_get_bool("/gaim/gtk/conversations/use_custom_font")) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
989 const char *fontface; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
990 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
991 fontface = gaim_prefs_get_string("/gaim/gtk/conversations/font_face"); |
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 g_snprintf(tmp, length, "<FONT FACE=\"%s\">%s</FONT>", fontface, buf); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
994 strcpy(buf, tmp); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
995 } |
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 if (gaim_prefs_get_bool("/gaim/gtk/conversations/use_custom_size")) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
998 int fontsize = gaim_prefs_get_int("/gaim/gtk/conversations/font_size"); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
999 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1000 g_snprintf(tmp, length, "<FONT SIZE=\"%d\">%s</FONT>", fontsize, buf); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1001 strcpy(buf, tmp); |
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 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1004 if (gaim_prefs_get_bool("/gaim/gtk/conversations/use_custom_fgcolor")) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1005 GdkColor fgcolor; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1006 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1007 gdk_color_parse( |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1008 gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1009 &fgcolor); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1010 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1011 g_snprintf(tmp, length, "<FONT COLOR=\"#%02X%02X%02X\">%s</FONT>", |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1012 fgcolor.red/256, fgcolor.green/256, fgcolor.blue/256, buf); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1013 strcpy(buf, tmp); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1014 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1015 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1016 if (gaim_prefs_get_bool("/gaim/gtk/conversations/use_custom_bgcolor")) { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1017 GdkColor bgcolor; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1018 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1019 gdk_color_parse( |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1020 gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1021 &bgcolor); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1022 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1023 g_snprintf(tmp, length, "<BODY BGCOLOR=\"#%02X%02X%02X\">%s</BODY>", |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1024 bgcolor.red/256, bgcolor.green/256, bgcolor.blue/256, buf); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1025 strcpy(buf, tmp); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1026 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1027 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1028 g_free(tmp); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1029 return buf; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1030 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
1031 |
7078 | 1032 void gaim_gtk_find_images(const char *message, GSList **list) { |
1033 GData *attribs; | |
1034 const char *tmp, *start, *end; | |
1035 | |
1036 tmp = message; | |
1037 while (gaim_markup_find_tag("img", tmp, &start, &end, &attribs)) { | |
1038 GaimStoredImage *image = NULL; | |
1039 GdkPixbufLoader *loader = NULL; | |
1040 GdkPixbuf *pixbuf = NULL; | |
1041 GError *error = NULL; | |
1042 char *id = g_datalist_get_data(&attribs, "id"); | |
1043 | |
1044 tmp = end + 1; | |
1045 | |
1046 if (id) | |
1047 image = gaim_imgstore_get(atoi(id)); | |
1048 | |
1049 g_datalist_clear(&attribs); | |
1050 | |
1051 if (!image) { | |
1052 *list = g_slist_append(*list, NULL); | |
1053 continue; | |
1054 } | |
1055 | |
1056 loader = gdk_pixbuf_loader_new(); | |
1057 | |
1058 if (gdk_pixbuf_loader_write(loader, image->data, image->size, &error) | |
1059 && (pixbuf = gdk_pixbuf_loader_get_pixbuf(loader))) { | |
1060 | |
1061 if (image->filename) | |
1062 g_object_set_data_full(G_OBJECT(pixbuf), "filename", | |
1063 g_strdup(image->filename), g_free); | |
1064 g_object_ref(G_OBJECT(pixbuf)); | |
1065 *list = g_slist_append(*list, pixbuf); | |
1066 } else { | |
1067 if (error) { | |
1068 gaim_debug(GAIM_DEBUG_ERROR, "gtkutils", | |
1069 "Failed to make pixbuf from image store: %s\n", | |
1070 error->message); | |
1071 g_error_free(error); | |
1072 } else { | |
1073 gaim_debug(GAIM_DEBUG_ERROR, "gtkutils", | |
1074 "Failed to make pixbuf from image store: unknown reason\n"); | |
1075 } | |
1076 *list = g_slist_append(*list, NULL); | |
1077 } | |
1078 | |
1079 gdk_pixbuf_loader_close(loader, NULL); | |
1080 } | |
1081 } | |
7420 | 1082 |
1083 void | |
1084 gaim_gtk_save_accels_cb(GtkAccelGroup *accel_group, guint arg1, | |
1085 GdkModifierType arg2, GClosure *arg3, | |
1086 gpointer data) | |
1087 { | |
1088 gaim_debug(GAIM_DEBUG_MISC, "accels", "accel changed, scheduling save.\n"); | |
1089 | |
1090 if (!accels_save_timer) | |
1091 accels_save_timer = g_timeout_add(5000, gaim_gtk_save_accels, NULL); | |
1092 } | |
1093 | |
1094 gboolean | |
1095 gaim_gtk_save_accels(gpointer data) | |
1096 { | |
1097 char *filename = NULL; | |
1098 | |
1099 filename = g_build_filename(gaim_user_dir(), G_DIR_SEPARATOR_S, | |
1100 "accels", NULL); | |
1101 gaim_debug(GAIM_DEBUG_MISC, "accels", "saving accels to %s\n", filename); | |
1102 gtk_accel_map_save(filename); | |
1103 g_free(filename); | |
1104 | |
1105 accels_save_timer = 0; | |
1106 return FALSE; | |
1107 } | |
1108 | |
1109 void | |
1110 gaim_gtk_load_accels(gpointer data) | |
1111 { | |
1112 char *filename = NULL; | |
1113 | |
1114 filename = g_build_filename(gaim_user_dir(), G_DIR_SEPARATOR_S, | |
1115 "accels", NULL); | |
1116 gtk_accel_map_load(filename); | |
1117 g_free(filename); | |
1118 } |