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