Mercurial > pidgin.yaz
annotate src/gtkutils.c @ 5836:09f7f23dc83a
[gaim-migrate @ 6267]
I think I've fixed the negative online time for real, now. Or, at least
reduced the frequency of it happening. Also added the ability to see
iChat's "available" messages.
Sean, I ended up changing more than I thought I would have to, but that's
partially because I like to change things a lot.
If it conflicts or whatever feel free to back it out and I can re-patch it
back in when you're done with your stuff.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 12 Jun 2003 03:27:58 +0000 |
parents | 5e93fc46d1af |
children | 059d95c67cda |
rev | line source |
---|---|
4359 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 2002-2003, Christian Hammond <chipx86@gnupdate.org> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
21 #ifdef HAVE_CONFIG_H | |
22 #include <config.h> | |
23 #endif | |
24 #include <string.h> | |
25 #ifndef _WIN32 | |
26 #include <sys/time.h> | |
27 #include <unistd.h> | |
28 #include <gdk/gdkx.h> | |
29 #include <X11/Xlib.h> | |
30 #else | |
31 #ifdef small | |
32 #undef small | |
33 #endif | |
34 #endif /*_WIN32*/ | |
35 #include <sys/types.h> | |
36 #include <sys/stat.h> | |
37 #include <stdio.h> | |
38 #include <stdlib.h> | |
39 #include <errno.h> | |
40 #include <ctype.h> | |
41 #include <gtk/gtk.h> | |
42 #ifdef USE_GTKSPELL | |
43 #include <gtkspell/gtkspell.h> | |
44 #endif | |
45 #include "gtkimhtml.h" | |
46 #include <gdk/gdkkeysyms.h> | |
5548 | 47 #include "prefs.h" |
4359 | 48 #include "prpl.h" |
5717 | 49 #include "gaim.h" |
4359 | 50 #include "ui.h" |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
51 #include "notify.h" |
4359 | 52 |
4859
a9a831508b43
[gaim-migrate @ 5186]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4793
diff
changeset
|
53 #ifdef _WIN32 |
a9a831508b43
[gaim-migrate @ 5186]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4793
diff
changeset
|
54 #include "wspell.h" |
5746
2c04c55222b7
[gaim-migrate @ 6171]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5717
diff
changeset
|
55 #include "win32dep.h" |
4859
a9a831508b43
[gaim-migrate @ 5186]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4793
diff
changeset
|
56 #endif |
4359 | 57 |
58 void | |
59 gaim_setup_imhtml(GtkWidget *imhtml) | |
60 { | |
61 g_return_if_fail(imhtml != NULL); | |
62 g_return_if_fail(GTK_IS_IMHTML(imhtml)); | |
63 | |
5548 | 64 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/show_smileys")) |
4359 | 65 gtk_imhtml_show_smileys(GTK_IMHTML(imhtml), FALSE); |
66 | |
67 g_signal_connect(G_OBJECT(imhtml), "url_clicked", | |
68 G_CALLBACK(open_url), NULL); | |
69 | |
70 smiley_themeize(imhtml); | |
71 } | |
72 | |
73 void | |
74 toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle) | |
75 { | |
76 gboolean sensitivity = GTK_WIDGET_IS_SENSITIVE(to_toggle); | |
77 | |
78 gtk_widget_set_sensitive(to_toggle, !sensitivity); | |
79 } | |
80 | |
81 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
82 gaim_gtk_remove_tags(GaimGtkConversation *gtkconv, const char *tag) |
4359 | 83 { |
84 GtkTextIter start, end, m_start, m_end; | |
85 | |
86 if (gtkconv == NULL || tag == NULL) | |
87 return; | |
88 | |
89 if (!gtk_text_buffer_get_selection_bounds(gtkconv->entry_buffer, | |
90 &start, &end)) | |
91 return; | |
92 | |
93 /* FIXMEif (strstr(tag, "<FONT SIZE=")) { | |
94 while ((t = strstr(t, "<FONT SIZE="))) { | |
95 if (((t - s) < finish) && ((t - s) >= start)) { | |
96 gtk_editable_delete_text(GTK_EDITABLE(entry), (t - s), | |
97 (t - s) + strlen(tag)); | |
98 g_free(s); | |
99 s = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); | |
100 t = s; | |
101 } else | |
102 t++; | |
103 } | |
104 } else*/ { | |
105 while (gtk_text_iter_forward_search(&start, tag, 0, &m_start, | |
106 &m_end, &end)) { | |
107 | |
108 gtk_text_buffer_delete(gtkconv->entry_buffer, &m_start, &m_end); | |
109 gtk_text_buffer_get_selection_bounds(gtkconv->entry_buffer, | |
110 &start, &end); | |
111 } | |
112 } | |
113 } | |
114 | |
115 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
116 gaim_gtk_surround(GaimGtkConversation *gtkconv, |
4359 | 117 const char *pre, const char *post) |
118 { | |
119 GtkTextIter start, end; | |
120 GtkTextMark *mark_start, *mark_end; | |
121 GtkTextBuffer *entry_buffer; | |
122 | |
123 if (gtkconv == NULL || pre == NULL || post == NULL) | |
124 return; | |
125 | |
126 entry_buffer = gtkconv->entry_buffer; | |
127 | |
128 if (gtk_text_buffer_get_selection_bounds(entry_buffer, | |
129 &start, &end)) { | |
130 gaim_gtk_remove_tags(gtkconv, pre); | |
131 gaim_gtk_remove_tags(gtkconv, post); | |
132 | |
133 mark_start = gtk_text_buffer_create_mark(entry_buffer, "m1", | |
134 &start, TRUE); | |
135 mark_end = gtk_text_buffer_create_mark(entry_buffer, "m2", | |
136 &end, FALSE); | |
137 gtk_text_buffer_insert(entry_buffer, &start, pre, -1); | |
138 gtk_text_buffer_get_selection_bounds(entry_buffer, &start, &end); | |
139 gtk_text_buffer_insert(entry_buffer, &end, post, -1); | |
140 gtk_text_buffer_get_iter_at_mark(entry_buffer, &start, mark_start); | |
141 gtk_text_buffer_move_mark_by_name(entry_buffer, "selection_bound", | |
142 &start); | |
143 } else { | |
144 gtk_text_buffer_insert(entry_buffer, &start, pre, -1); | |
145 gtk_text_buffer_insert(entry_buffer, &start, post, -1); | |
146 mark_start = gtk_text_buffer_get_insert(entry_buffer); | |
147 gtk_text_buffer_get_iter_at_mark(entry_buffer, &start, mark_start); | |
148 gtk_text_iter_backward_chars(&start, strlen(post)); | |
149 gtk_text_buffer_place_cursor(entry_buffer, &start); | |
150 } | |
151 | |
152 gtk_widget_grab_focus(gtkconv->entry); | |
153 } | |
154 | |
155 static gboolean | |
156 invert_tags(GtkTextBuffer *buffer, const char *s1, const char *s2, | |
157 gboolean really) | |
158 { | |
159 GtkTextIter start1, start2, end1, end2; | |
160 char *b1, *b2; | |
161 | |
162 if (gtk_text_buffer_get_selection_bounds(buffer, &start1, &end2)) { | |
163 start2 = start1; | |
164 end1 = end2; | |
165 | |
166 if (!gtk_text_iter_forward_chars(&start2, strlen(s1))) | |
167 return FALSE; | |
168 | |
169 if (!gtk_text_iter_backward_chars(&end1, strlen(s2))) | |
170 return FALSE; | |
171 | |
172 b1 = gtk_text_buffer_get_text(buffer, &start1, &start2, FALSE); | |
173 b2 = gtk_text_buffer_get_text(buffer, &end1, &end2, FALSE); | |
174 | |
4793 | 175 if (!g_ascii_strncasecmp(b1, s1, strlen(s1)) && |
176 !g_ascii_strncasecmp(b2, s2, strlen(s2))) { | |
4359 | 177 |
178 if (really) { | |
179 GtkTextMark *m_end1, *m_end2; | |
180 | |
181 m_end1= gtk_text_buffer_create_mark(buffer, "m1", &end1, TRUE); | |
182 m_end2= gtk_text_buffer_create_mark(buffer, "m2", &end2, TRUE); | |
183 | |
184 gtk_text_buffer_delete(buffer, &start1, &start2); | |
185 gtk_text_buffer_get_iter_at_mark(buffer, &end1, m_end1); | |
186 gtk_text_buffer_get_iter_at_mark(buffer, &end2, m_end2); | |
187 gtk_text_buffer_delete(buffer, &end1, &end2); | |
188 gtk_text_buffer_delete_mark(buffer, m_end1); | |
189 gtk_text_buffer_delete_mark(buffer, m_end2); | |
190 } | |
191 | |
192 g_free(b1); | |
193 g_free(b2); | |
194 | |
195 return TRUE; | |
196 } | |
197 | |
198 g_free(b1); | |
199 g_free(b2); | |
200 } | |
201 | |
202 return FALSE; | |
203 } | |
204 | |
205 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
206 gaim_gtk_advance_past(GaimGtkConversation *gtkconv, |
4359 | 207 const char *pre, const char *post) |
208 { | |
209 GtkTextIter current_pos, start, end; | |
210 | |
211 if (invert_tags(gtkconv->entry_buffer, pre, post, TRUE)) | |
212 return; | |
213 | |
214 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, ¤t_pos, | |
215 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
216 | |
217 if (gtk_text_iter_forward_search(¤t_pos, post, 0, | |
218 &start, &end, NULL)) | |
219 gtk_text_buffer_place_cursor(gtkconv->entry_buffer, &end); | |
220 else | |
221 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, post, -1); | |
222 | |
223 gtk_widget_grab_focus(gtkconv->entry); | |
224 } | |
225 | |
226 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
227 gaim_gtk_set_font_face(GaimGtkConversation *gtkconv, |
4359 | 228 const char *font) |
229 { | |
230 char *pre_fontface; | |
231 | |
232 if (gtkconv == NULL || font == NULL) | |
233 return; | |
234 | |
235 strncpy(gtkconv->fontface, | |
236 (font && *font ? font : DEFAULT_FONT_FACE), | |
237 sizeof(gtkconv->fontface)); | |
238 | |
239 gtkconv->has_font = TRUE; | |
240 | |
241 pre_fontface = g_strconcat("<FONT FACE=\"", | |
242 gtkconv->fontface, "\">", NULL); | |
243 gaim_gtk_surround(gtkconv, pre_fontface, "</FONT>"); | |
244 | |
245 gtk_widget_grab_focus(gtkconv->entry); | |
246 | |
247 g_free(pre_fontface); | |
248 } | |
249 | |
250 static int | |
251 des_save_icon(GtkObject *obj, GdkEvent *e, | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
252 GaimGtkConversation *gtkconv) |
4359 | 253 { |
254 gtk_widget_destroy(gtkconv->u.im->save_icon); | |
255 gtkconv->u.im->save_icon = NULL; | |
256 | |
257 return TRUE; | |
258 } | |
259 | |
260 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
261 do_save_icon(GtkObject *obj, GaimConversation *c) |
4359 | 262 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
263 GaimGtkConversation *gtkconv; |
4359 | 264 FILE *file; |
265 const char *f; | |
266 | |
267 gtkconv = GAIM_GTK_CONVERSATION(c); | |
268 | |
269 f = gtk_file_selection_get_filename( | |
270 GTK_FILE_SELECTION(gtkconv->u.im->save_icon)); | |
271 | |
272 if (file_is_dir(f, gtkconv->u.im->save_icon)) | |
273 return; | |
274 | |
275 if ((file = fopen(f, "w")) != NULL) { | |
276 int len; | |
277 void *data = get_icon_data(gaim_conversation_get_gc(c), | |
278 normalize(gaim_conversation_get_name(c)), | |
279 &len); | |
280 | |
281 if (data) | |
282 fwrite(data, 1, len, file); | |
283 | |
284 fclose(file); | |
285 } else { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
286 gaim_notify_error(NULL, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
287 _("Can't save icon file to disk."), NULL); |
4359 | 288 } |
289 | |
290 gtk_widget_destroy(gtkconv->u.im->save_icon); | |
291 gtkconv->u.im->save_icon = NULL; | |
292 } | |
293 | |
294 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
295 cancel_save_icon(GtkObject *obj, GaimGtkConversation *gtkconv) |
4359 | 296 { |
297 gtk_widget_destroy(gtkconv->u.im->save_icon); | |
298 gtkconv->u.im->save_icon = NULL; | |
299 } | |
300 | |
301 | |
302 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
303 gaim_gtk_save_icon_dialog(GtkObject *obj, GaimConversation *conv) |
4359 | 304 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5649
diff
changeset
|
305 GaimGtkConversation *gtkconv; |
4359 | 306 char buf[BUF_LEN]; |
307 | |
308 if (conv == NULL || gaim_conversation_get_type(conv) != GAIM_CONV_IM) | |
309 return; | |
310 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
311 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 312 return; |
313 | |
314 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
315 | |
316 if (gtkconv->u.im->save_icon != NULL) | |
317 { | |
318 gdk_window_raise(gtkconv->u.im->save_icon->window); | |
319 return; | |
320 } | |
321 | |
322 gtkconv->u.im->save_icon = gtk_file_selection_new(_("Gaim - Save Icon")); | |
323 | |
324 gtk_file_selection_hide_fileop_buttons( | |
325 GTK_FILE_SELECTION(gtkconv->u.im->save_icon)); | |
326 | |
327 g_snprintf(buf, BUF_LEN - 1, | |
328 "%s" G_DIR_SEPARATOR_S "%s.icon", | |
329 gaim_home_dir(), gaim_conversation_get_name(conv)); | |
330 | |
331 gtk_file_selection_set_filename( | |
332 GTK_FILE_SELECTION(gtkconv->u.im->save_icon), buf); | |
333 | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
334 g_signal_connect(G_OBJECT(gtkconv->u.im->save_icon), "delete_event", |
4359 | 335 G_CALLBACK(des_save_icon), gtkconv); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
336 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(gtkconv->u.im->save_icon)->ok_button), "clicked", |
4359 | 337 G_CALLBACK(do_save_icon), conv); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
338 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(gtkconv->u.im->save_icon)->cancel_button), "clicked", |
4359 | 339 G_CALLBACK(cancel_save_icon), gtkconv); |
340 | |
341 gtk_widget_show(gtkconv->u.im->save_icon); | |
342 } | |
343 | |
344 int | |
345 gaim_gtk_get_dispstyle(GaimConversationType type) | |
346 { | |
347 int dispstyle = 2; | |
5554
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
348 int value; |
4359 | 349 |
350 if (type == GAIM_CONV_CHAT) { | |
5554
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
351 value = gaim_prefs_get_int("/gaim/gtk/conversations/chat/button_type"); |
4359 | 352 |
5554
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
353 switch (value) { |
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
354 case GAIM_BUTTON_TEXT: dispstyle = 1; break; |
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
355 case GAIM_BUTTON_IMAGE: dispstyle = 0; break; |
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
356 default: dispstyle = 2; break; /* both/neither */ |
4359 | 357 } |
358 } | |
359 else if (type == GAIM_CONV_IM) { | |
5554
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
360 value = gaim_prefs_get_int("/gaim/gtk/conversations/im/button_type"); |
4359 | 361 |
5554
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
362 switch (value) { |
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
363 case GAIM_BUTTON_TEXT: dispstyle = 1; break; |
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
364 case GAIM_BUTTON_IMAGE: dispstyle = 0; break; |
7b36d02031a2
[gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents:
5548
diff
changeset
|
365 default: dispstyle = 2; break; /* both/neither */ |
4359 | 366 } |
367 } | |
368 | |
369 return dispstyle; | |
370 } | |
371 | |
372 GtkWidget * | |
373 gaim_gtk_change_text(const char *text, GtkWidget *button, | |
374 const char *stock, GaimConversationType type) | |
375 { | |
376 int dispstyle = gaim_gtk_get_dispstyle(type); | |
377 | |
378 if (button != NULL) | |
379 gtk_widget_destroy(button); | |
380 | |
381 button = gaim_pixbuf_button_from_stock((dispstyle == 0 ? NULL : text), | |
382 (dispstyle == 1 ? NULL : stock), | |
383 GAIM_BUTTON_VERTICAL); | |
384 | |
385 gtk_widget_show(button); | |
386 | |
387 return button; | |
388 } | |
389 | |
390 void | |
391 gaim_gtk_toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle) | |
392 { | |
393 gboolean sensitivity; | |
394 | |
395 if (to_toggle == NULL) | |
396 return; | |
397 | |
398 sensitivity = GTK_WIDGET_IS_SENSITIVE(to_toggle); | |
399 | |
400 gtk_widget_set_sensitive(to_toggle, !sensitivity); | |
401 } | |
402 | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
403 void |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
404 gtk_toggle_sensitive_array(GtkWidget *w, GPtrArray *data) |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
405 { |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
406 gboolean sensitivity; |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
407 gpointer element; |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
408 int i; |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
409 |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
410 for (i=0; i < data->len; i++) { |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
411 element = g_ptr_array_index(data,i); |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
412 if (element == NULL) |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
413 continue; |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
414 |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
415 sensitivity = GTK_WIDGET_IS_SENSITIVE(element); |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
416 |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
417 gtk_widget_set_sensitive(element, !sensitivity); |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
418 } |
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 |
4687 | 421 void gaim_separator(GtkWidget *menu) |
422 { | |
423 GtkWidget *menuitem; | |
424 | |
425 menuitem = gtk_separator_menu_item_new(); | |
426 gtk_widget_show(menuitem); | |
427 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
428 } | |
5160 | 429 |
5162 | 430 GtkWidget *gaim_new_item(GtkWidget *menu, const char *str) |
431 { | |
432 GtkWidget *menuitem; | |
433 GtkWidget *label; | |
434 | |
435 menuitem = gtk_menu_item_new(); | |
436 if (menu) | |
437 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
438 gtk_widget_show(menuitem); | |
439 | |
440 label = gtk_label_new(str); | |
441 gtk_label_set_pattern(GTK_LABEL(label), "_"); | |
442 gtk_container_add(GTK_CONTAINER(menuitem), label); | |
443 gtk_widget_show(label); | |
444 /* FIXME: Go back and fix this | |
445 gtk_widget_add_accelerator(menuitem, "activate", accel, str[0], | |
446 GDK_MOD1_MASK, GTK_ACCEL_LOCKED); | |
447 */ | |
448 return menuitem; | |
449 } | |
450 | |
5160 | 451 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) |
452 { | |
453 GtkWidget *menuitem; | |
454 /* | |
455 GtkWidget *hbox; | |
456 GtkWidget *label; | |
457 */ | |
458 GtkWidget *image; | |
459 | |
460 if (icon == NULL) | |
461 menuitem = gtk_menu_item_new_with_mnemonic(str); | |
462 else | |
463 menuitem = gtk_image_menu_item_new_with_mnemonic(str); | |
464 | |
465 if (menu) | |
466 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
467 | |
468 if (sf) | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
469 g_signal_connect(G_OBJECT(menuitem), "activate", sf, data); |
5160 | 470 |
471 if (icon != NULL) { | |
472 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_MENU); | |
473 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); | |
474 } | |
475 /* FIXME: this isn't right | |
476 if (mod) { | |
477 label = gtk_label_new(mod); | |
478 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 2); | |
479 gtk_widget_show(label); | |
480 } | |
481 */ | |
482 /* | |
483 if (accel_key) { | |
484 gtk_widget_add_accelerator(menuitem, "activate", accel, accel_key, | |
485 accel_mods, GTK_ACCEL_LOCKED); | |
486 } | |
487 */ | |
488 | |
489 gtk_widget_show_all(menuitem); | |
490 | |
491 return menuitem; | |
492 } | |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
493 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
494 GtkWidget * |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
495 gaim_gtk_make_frame(GtkWidget *parent, const char *title) |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
496 { |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
497 GtkWidget *vbox, *label, *hbox; |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
498 char labeltitle[256]; |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
499 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
500 vbox = gtk_vbox_new(FALSE, 6); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
501 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
|
502 gtk_widget_show(vbox); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
503 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
504 label = gtk_label_new(NULL); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
505 g_snprintf(labeltitle, sizeof(labeltitle), |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
506 "<span weight=\"bold\">%s</span>", title); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
507 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
508 gtk_label_set_markup(GTK_LABEL(label), labeltitle); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
509 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
510 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
|
511 gtk_widget_show(label); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
512 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
513 hbox = gtk_hbox_new(FALSE, 6); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
514 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
|
515 gtk_widget_show(hbox); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
516 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
517 label = gtk_label_new(" "); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
518 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
|
519 gtk_widget_show(label); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
520 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
521 vbox = gtk_vbox_new(FALSE, 6); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
522 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
|
523 gtk_widget_show(vbox); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
524 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
525 return vbox; |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
526 } |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
527 |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
528 static void |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
529 protocol_menu_cb(GtkWidget *optmenu, GCallback cb) |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
530 { |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
531 GtkWidget *menu; |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
532 GtkWidget *item; |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
533 GaimProtocol protocol; |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
534 gpointer user_data; |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
535 |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
536 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
537 item = gtk_menu_get_active(GTK_MENU(menu)); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
538 |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
539 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
|
540 user_data = (g_object_get_data(G_OBJECT(optmenu), "user_data")); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
541 |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
542 if (cb != NULL) |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
543 ((void (*)(GtkWidget *, GaimProtocol, gpointer))cb)(item, protocol, |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
544 user_data); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
545 } |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
546 |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
547 GtkWidget * |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
548 gaim_gtk_protocol_option_menu_new(GaimProtocol protocol, GCallback cb, |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
549 gpointer user_data) |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
550 { |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
551 GaimPluginProtocolInfo *prpl_info; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
552 GaimPlugin *plugin; |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
553 GtkWidget *hbox; |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
554 GtkWidget *label; |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
555 GtkWidget *optmenu; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
556 GtkWidget *menu; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
557 GtkWidget *item; |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
558 GtkWidget *image; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
559 GdkPixbuf *pixbuf; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
560 GdkPixbuf *scale; |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
561 GList *p; |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
562 GtkSizeGroup *sg; |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
563 char *filename; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
564 const char *proto_name; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
565 char buf[256]; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
566 int i, selected_index = -1; |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
567 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
568 optmenu = gtk_option_menu_new(); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
569 gtk_widget_show(optmenu); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
570 |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
571 g_object_set_data(G_OBJECT(optmenu), "user_data", user_data); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
572 |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
573 menu = gtk_menu_new(); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
574 gtk_widget_show(menu); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
575 |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
576 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
577 |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
578 for (p = gaim_plugins_get_protocols(), i = 0; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
579 p != NULL; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
580 p = p->next, i++) { |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
581 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
582 plugin = (GaimPlugin *)p->data; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
583 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
584 |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
585 /* Create the item. */ |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
586 item = gtk_menu_item_new(); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
587 |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
588 /* Create the hbox. */ |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
589 hbox = gtk_hbox_new(FALSE, 4); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
590 gtk_container_add(GTK_CONTAINER(item), hbox); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
591 gtk_widget_show(hbox); |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
592 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
593 /* Load the image. */ |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
594 proto_name = prpl_info->list_icon(NULL, NULL); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
595 g_snprintf(buf, sizeof(buf), "%s.png", proto_name); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
596 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
597 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
598 "default", buf, NULL); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
599 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
600 g_free(filename); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
601 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
602 if (pixbuf != NULL) { |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
603 /* Scale and insert the image */ |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
604 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
605 GDK_INTERP_BILINEAR); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
606 image = gtk_image_new_from_pixbuf(scale); |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
607 |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
608 g_object_unref(G_OBJECT(pixbuf)); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
609 g_object_unref(G_OBJECT(scale)); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
610 } |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
611 else |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
612 image = gtk_image_new(); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
613 |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
614 gtk_size_group_add_widget(sg, image); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
615 |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
616 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
617 gtk_widget_show(image); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
618 |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
619 /* Create the label. */ |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
620 label = gtk_label_new(plugin->info->name); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
621 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
622 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
623 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
624 gtk_widget_show(label); |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
625 |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
626 g_object_set_data(G_OBJECT(item), "protocol", |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
627 GINT_TO_POINTER(prpl_info->protocol)); |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
628 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
629 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
630 gtk_widget_show(item); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
631 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
632 if (prpl_info->protocol == protocol) |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
633 selected_index = i; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
634 } |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
635 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
636 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
637 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
638 if (selected_index != -1) |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
639 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), selected_index); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
640 |
5688
e43e1b8dca8b
[gaim-migrate @ 6109]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
641 g_signal_connect(G_OBJECT(optmenu), "changed", |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
642 G_CALLBACK(protocol_menu_cb), cb); |
5688
e43e1b8dca8b
[gaim-migrate @ 6109]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
643 |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
644 g_object_unref(sg); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
645 |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
646 return optmenu; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
647 } |