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