Mercurial > pidgin
annotate src/gtkutils.c @ 10539:5a50946954dd
[gaim-migrate @ 11900]
Merge some changes from oldstatus
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 23 Jan 2005 20:32:07 +0000 |
parents | 1a97d5e88d12 |
children | 62fc579810f4 |
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 */ | |
9791 | 25 #include "internal.h" |
26 #include "gtkgaim.h" | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
27 |
4359 | 28 #ifndef _WIN32 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
29 # include <X11/Xlib.h> |
4359 | 30 #else |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
31 # ifdef small |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
32 # undef small |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
33 # endif |
4359 | 34 #endif /*_WIN32*/ |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
35 |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
36 #ifdef USE_GTKSPELL |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
37 # include <gtkspell/gtkspell.h> |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
38 # ifdef _WIN32 |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
39 # include "wspell.h" |
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 #endif |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
42 |
4359 | 43 #include <gdk/gdkkeysyms.h> |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
44 |
10229 | 45 #include "conversation.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
46 #include "debug.h" |
10229 | 47 #include "desktopitem.h" |
7078 | 48 #include "imgstore.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
49 #include "notify.h" |
5548 | 50 #include "prefs.h" |
4359 | 51 #include "prpl.h" |
10229 | 52 #include "request.h" |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
53 #include "signals.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
54 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
55 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
56 #include "gtkconv.h" |
9709 | 57 #include "gtkdialogs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
58 #include "gtkimhtml.h" |
10175 | 59 #include "gtkimhtmltoolbar.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
60 #include "gtkutils.h" |
4359 | 61 |
7420 | 62 guint accels_save_timer = 0; |
63 | |
8913 | 64 static gboolean |
65 url_clicked_idle_cb(gpointer data) | |
66 { | |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10229
diff
changeset
|
67 gaim_notify_uri(NULL, data); |
8913 | 68 g_free(data); |
69 return FALSE; | |
70 } | |
71 | |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
72 static void |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
73 url_clicked_cb(GtkWidget *w, const char *uri) |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
74 { |
8913 | 75 g_idle_add(url_clicked_idle_cb, g_strdup(uri)); |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
76 } |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
77 |
8962 | 78 GtkIMHtmlFuncs gtkimhtml_cbs = { |
79 (GtkIMHtmlGetImageFunc)gaim_imgstore_get, | |
80 (GtkIMHtmlGetImageDataFunc)gaim_imgstore_get_data, | |
81 (GtkIMHtmlGetImageSizeFunc)gaim_imgstore_get_size, | |
82 (GtkIMHtmlGetImageFilenameFunc)gaim_imgstore_get_filename, | |
83 gaim_imgstore_ref, | |
84 gaim_imgstore_unref, | |
85 }; | |
86 | |
4359 | 87 void |
88 gaim_setup_imhtml(GtkWidget *imhtml) | |
89 { | |
90 g_return_if_fail(imhtml != NULL); | |
91 g_return_if_fail(GTK_IS_IMHTML(imhtml)); | |
92 | |
93 g_signal_connect(G_OBJECT(imhtml), "url_clicked", | |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
94 G_CALLBACK(url_clicked_cb), NULL); |
4359 | 95 |
96 smiley_themeize(imhtml); | |
8962 | 97 |
98 gtk_imhtml_set_funcs(GTK_IMHTML(imhtml), >kimhtml_cbs); | |
4359 | 99 } |
100 | |
10175 | 101 GtkWidget * |
102 gaim_gtk_create_imhtml(gboolean editable, GtkWidget **imhtml_ret, GtkWidget **toolbar_ret) | |
103 { | |
104 GtkWidget *frame; | |
105 GtkWidget *imhtml; | |
106 GtkWidget *sep; | |
107 GtkWidget *sw; | |
10177
82c1322c4b56
[gaim-migrate @ 11292]
Christian Hammond <chipx86@chipx86.com>
parents:
10175
diff
changeset
|
108 GtkWidget *toolbar = NULL; |
10175 | 109 GtkWidget *vbox; |
110 | |
111 frame = gtk_frame_new(NULL); | |
112 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); | |
113 | |
114 vbox = gtk_vbox_new(FALSE, 0); | |
115 gtk_container_add(GTK_CONTAINER(frame), vbox); | |
116 gtk_widget_show(vbox); | |
117 | |
118 if (editable) { | |
119 toolbar = gtk_imhtmltoolbar_new(); | |
120 gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0); | |
121 gtk_widget_show(toolbar); | |
122 | |
123 sep = gtk_hseparator_new(); | |
124 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); | |
125 gtk_widget_show(sep); | |
126 } | |
127 | |
128 /* | |
129 * We never show the horizontal scrollbar in editable imhtmls becuase | |
130 * it was causing weird lockups when typing text just as you type the | |
131 * character that would cause both scrollbars to appear. Definitely | |
132 * seems like a gtk bug to me. | |
133 */ | |
134 sw = gtk_scrolled_window_new(NULL, NULL); | |
135 if (editable) | |
136 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
137 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); | |
138 else | |
139 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
140 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
141 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); | |
142 gtk_widget_show(sw); | |
143 | |
144 imhtml = gtk_imhtml_new(NULL, NULL); | |
145 gtk_imhtml_set_editable(GTK_IMHTML(imhtml), editable); | |
146 gtk_imhtml_set_format_functions(GTK_IMHTML(imhtml), GTK_IMHTML_ALL ^ GTK_IMHTML_IMAGE); | |
147 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(imhtml), GTK_WRAP_WORD_CHAR); | |
148 if (editable && gaim_prefs_get_bool("/gaim/gtk/conversations/spellcheck")) | |
149 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(imhtml)); | |
150 gtk_widget_show(imhtml); | |
151 | |
152 if (editable) { | |
153 gtk_imhtmltoolbar_attach(GTK_IMHTMLTOOLBAR(toolbar), imhtml); | |
154 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(toolbar), "default"); | |
155 } | |
156 gaim_setup_imhtml(imhtml); | |
157 | |
158 gtk_container_add(GTK_CONTAINER(sw), imhtml); | |
159 | |
160 if (imhtml_ret != NULL) | |
161 *imhtml_ret = imhtml; | |
162 | |
10181 | 163 if (editable && (toolbar_ret != NULL)) |
10175 | 164 *toolbar_ret = toolbar; |
165 | |
166 return frame; | |
167 } | |
168 | |
4359 | 169 void |
170 toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle) | |
171 { | |
172 gboolean sensitivity = GTK_WIDGET_IS_SENSITIVE(to_toggle); | |
173 | |
174 gtk_widget_set_sensitive(to_toggle, !sensitivity); | |
175 } | |
176 | |
7751 | 177 void |
178 gaim_gtk_set_sensitive_if_input(GtkWidget *entry, GtkWidget *dialog) | |
179 { | |
180 const char *text = gtk_entry_get_text(GTK_ENTRY(entry)); | |
181 gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK, | |
182 (*text != '\0')); | |
183 } | |
184 | |
4359 | 185 void |
186 gaim_gtk_toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle) | |
187 { | |
188 gboolean sensitivity; | |
189 | |
190 if (to_toggle == NULL) | |
191 return; | |
192 | |
193 sensitivity = GTK_WIDGET_IS_SENSITIVE(to_toggle); | |
194 | |
195 gtk_widget_set_sensitive(to_toggle, !sensitivity); | |
196 } | |
197 | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
198 void |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
199 gtk_toggle_sensitive_array(GtkWidget *w, GPtrArray *data) |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
200 { |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
201 gboolean sensitivity; |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
202 gpointer element; |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
203 int i; |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
204 |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
205 for (i=0; i < data->len; i++) { |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
206 element = g_ptr_array_index(data,i); |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
207 if (element == NULL) |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
208 continue; |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
209 |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
210 sensitivity = GTK_WIDGET_IS_SENSITIVE(element); |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
211 |
10175 | 212 gtk_widget_set_sensitive(element, !sensitivity); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
213 } |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
214 } |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
215 |
8901 | 216 void |
217 gaim_gtk_toggle_showhide(GtkWidget *widget, GtkWidget *to_toggle) | |
218 { | |
219 if (to_toggle == NULL) | |
220 return; | |
221 | |
222 if (GTK_WIDGET_VISIBLE(to_toggle)) | |
223 gtk_widget_hide(to_toggle); | |
224 else | |
225 gtk_widget_show(to_toggle); | |
226 } | |
227 | |
4687 | 228 void gaim_separator(GtkWidget *menu) |
229 { | |
230 GtkWidget *menuitem; | |
231 | |
232 menuitem = gtk_separator_menu_item_new(); | |
233 gtk_widget_show(menuitem); | |
234 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
235 } | |
5160 | 236 |
5162 | 237 GtkWidget *gaim_new_item(GtkWidget *menu, const char *str) |
238 { | |
239 GtkWidget *menuitem; | |
240 GtkWidget *label; | |
241 | |
242 menuitem = gtk_menu_item_new(); | |
243 if (menu) | |
244 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
245 gtk_widget_show(menuitem); | |
246 | |
247 label = gtk_label_new(str); | |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6236
diff
changeset
|
248 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
5162 | 249 gtk_label_set_pattern(GTK_LABEL(label), "_"); |
250 gtk_container_add(GTK_CONTAINER(menuitem), label); | |
251 gtk_widget_show(label); | |
252 /* FIXME: Go back and fix this | |
253 gtk_widget_add_accelerator(menuitem, "activate", accel, str[0], | |
254 GDK_MOD1_MASK, GTK_ACCEL_LOCKED); | |
255 */ | |
8137 | 256 gaim_set_accessible_label (menuitem, label); |
5162 | 257 return menuitem; |
258 } | |
259 | |
5906 | 260 GtkWidget *gaim_new_check_item(GtkWidget *menu, const char *str, |
261 GtkSignalFunc sf, gpointer data, gboolean checked) | |
262 { | |
263 GtkWidget *menuitem; | |
264 menuitem = gtk_check_menu_item_new_with_mnemonic(str); | |
265 | |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
266 if (menu) |
5906 | 267 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); |
268 | |
7299
2737c287f84d
[gaim-migrate @ 7883]
Christian Hammond <chipx86@chipx86.com>
parents:
7118
diff
changeset
|
269 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
|
270 |
5906 | 271 if (sf) |
272 g_signal_connect(G_OBJECT(menuitem), "activate", sf, data); | |
273 | |
274 gtk_widget_show_all(menuitem); | |
275 | |
276 return menuitem; | |
277 } | |
278 | |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
279 GtkWidget * |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
280 gaim_pixbuf_toolbar_button_from_stock(const char *icon) |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
281 { |
9706 | 282 GtkWidget *button, *image, *bbox; |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
283 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
284 button = gtk_toggle_button_new(); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
285 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
286 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
287 bbox = gtk_vbox_new(FALSE, 0); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
288 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
289 gtk_container_add (GTK_CONTAINER(button), bbox); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
290 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
291 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_MENU); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
292 gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
293 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
294 gtk_widget_show_all(bbox); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
295 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
296 return button; |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
297 } |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
298 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
299 GtkWidget * |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
300 gaim_pixbuf_button_from_stock(const char *text, const char *icon, |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
301 GaimButtonOrientation style) |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
302 { |
10504 | 303 GtkWidget *button, *image, *label, *bbox, *ibox, *lbox = NULL; |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
304 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
305 button = gtk_button_new(); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
306 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
307 if (style == GAIM_BUTTON_HORIZONTAL) { |
9750 | 308 bbox = gtk_hbox_new(FALSE, 0); |
309 ibox = gtk_hbox_new(FALSE, 0); | |
10504 | 310 if (text) |
311 lbox = gtk_hbox_new(FALSE, 0); | |
9750 | 312 } else { |
313 bbox = gtk_vbox_new(FALSE, 0); | |
314 ibox = gtk_vbox_new(FALSE, 0); | |
10504 | 315 if (text) |
316 lbox = gtk_vbox_new(FALSE, 0); | |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
317 } |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
318 |
9750 | 319 gtk_container_add(GTK_CONTAINER(button), bbox); |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
320 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
321 if (icon) { |
9750 | 322 gtk_box_pack_start_defaults(GTK_BOX(bbox), ibox); |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
323 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_BUTTON); |
9767 | 324 gtk_box_pack_end(GTK_BOX(ibox), image, FALSE, TRUE, 0); |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
325 } |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
326 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
327 if (text) { |
9750 | 328 gtk_box_pack_start_defaults(GTK_BOX(bbox), lbox); |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
329 label = gtk_label_new(NULL); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
330 gtk_label_set_text_with_mnemonic(GTK_LABEL(label), text); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
331 gtk_label_set_mnemonic_widget(GTK_LABEL(label), button); |
9767 | 332 gtk_box_pack_start(GTK_BOX(lbox), label, FALSE, TRUE, 0); |
8137 | 333 gaim_set_accessible_label (button, label); |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
334 } |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
335 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
336 gtk_widget_show_all(bbox); |
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 return button; |
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 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
341 |
5160 | 342 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) |
343 { | |
344 GtkWidget *menuitem; | |
345 /* | |
346 GtkWidget *hbox; | |
347 GtkWidget *label; | |
348 */ | |
349 GtkWidget *image; | |
350 | |
351 if (icon == NULL) | |
352 menuitem = gtk_menu_item_new_with_mnemonic(str); | |
353 else | |
354 menuitem = gtk_image_menu_item_new_with_mnemonic(str); | |
355 | |
356 if (menu) | |
357 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
358 | |
359 if (sf) | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
360 g_signal_connect(G_OBJECT(menuitem), "activate", sf, data); |
5160 | 361 |
362 if (icon != NULL) { | |
363 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_MENU); | |
364 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); | |
365 } | |
366 /* FIXME: this isn't right | |
367 if (mod) { | |
368 label = gtk_label_new(mod); | |
369 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 2); | |
370 gtk_widget_show(label); | |
371 } | |
372 */ | |
373 /* | |
374 if (accel_key) { | |
375 gtk_widget_add_accelerator(menuitem, "activate", accel, accel_key, | |
376 accel_mods, GTK_ACCEL_LOCKED); | |
377 } | |
378 */ | |
379 | |
380 gtk_widget_show_all(menuitem); | |
381 | |
382 return menuitem; | |
383 } | |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
384 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
385 GtkWidget * |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
386 gaim_gtk_make_frame(GtkWidget *parent, const char *title) |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
387 { |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
388 GtkWidget *vbox, *label, *hbox; |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
389 char labeltitle[256]; |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
390 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
391 vbox = gtk_vbox_new(FALSE, 6); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
392 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
|
393 gtk_widget_show(vbox); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
394 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
395 label = gtk_label_new(NULL); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
396 g_snprintf(labeltitle, sizeof(labeltitle), |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
397 "<span weight=\"bold\">%s</span>", title); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
398 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
399 gtk_label_set_markup(GTK_LABEL(label), labeltitle); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
400 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
401 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
|
402 gtk_widget_show(label); |
8137 | 403 gaim_set_accessible_label (vbox, label); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
404 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
405 hbox = gtk_hbox_new(FALSE, 6); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
406 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
|
407 gtk_widget_show(hbox); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
408 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
409 label = gtk_label_new(" "); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
410 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
|
411 gtk_widget_show(label); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
412 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
413 vbox = gtk_vbox_new(FALSE, 6); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
414 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
|
415 gtk_widget_show(vbox); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
416 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
417 return vbox; |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
418 } |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
419 |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
420 static void |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
421 protocol_menu_cb(GtkWidget *optmenu, GCallback cb) |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
422 { |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
423 GtkWidget *menu; |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
424 GtkWidget *item; |
7956 | 425 const char *protocol; |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
426 gpointer user_data; |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
427 |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
428 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
429 item = gtk_menu_get_active(GTK_MENU(menu)); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
430 |
7956 | 431 protocol = g_object_get_data(G_OBJECT(item), "protocol"); |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
432 user_data = (g_object_get_data(G_OBJECT(optmenu), "user_data")); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
433 |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
434 if (cb != NULL) |
7956 | 435 ((void (*)(GtkWidget *, const char *, gpointer))cb)(item, protocol, |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
436 user_data); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
437 } |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
438 |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
439 GtkWidget * |
7956 | 440 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
|
441 gpointer user_data) |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
442 { |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
443 GaimPluginProtocolInfo *prpl_info; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
444 GaimPlugin *plugin; |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
445 GtkWidget *hbox; |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
446 GtkWidget *label; |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
447 GtkWidget *optmenu; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
448 GtkWidget *menu; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
449 GtkWidget *item; |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
450 GtkWidget *image; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
451 GdkPixbuf *pixbuf; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
452 GdkPixbuf *scale; |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
453 GList *p; |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
454 GtkSizeGroup *sg; |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
455 char *filename; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
456 const char *proto_name; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
457 char buf[256]; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
458 int i, selected_index = -1; |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
459 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
460 optmenu = gtk_option_menu_new(); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
461 gtk_widget_show(optmenu); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
462 |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
463 g_object_set_data(G_OBJECT(optmenu), "user_data", user_data); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
464 |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
465 menu = gtk_menu_new(); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
466 gtk_widget_show(menu); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
467 |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
468 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
469 |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
470 for (p = gaim_plugins_get_protocols(), i = 0; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
471 p != NULL; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
472 p = p->next, i++) { |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
473 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
474 plugin = (GaimPlugin *)p->data; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
475 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
476 |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
477 /* Create the item. */ |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
478 item = gtk_menu_item_new(); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
479 |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
480 /* Create the hbox. */ |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
481 hbox = gtk_hbox_new(FALSE, 4); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
482 gtk_container_add(GTK_CONTAINER(item), hbox); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
483 gtk_widget_show(hbox); |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
484 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
485 /* Load the image. */ |
6430 | 486 proto_name = prpl_info->list_icon(NULL, NULL); |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
487 g_snprintf(buf, sizeof(buf), "%s.png", proto_name); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
488 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
489 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
490 "default", buf, NULL); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
491 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
492 g_free(filename); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
493 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
494 if (pixbuf != NULL) { |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
495 /* Scale and insert the image */ |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
496 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
497 GDK_INTERP_BILINEAR); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
498 image = gtk_image_new_from_pixbuf(scale); |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
499 |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
500 g_object_unref(G_OBJECT(pixbuf)); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
501 g_object_unref(G_OBJECT(scale)); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
502 } |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
503 else |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
504 image = gtk_image_new(); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
505 |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
506 gtk_size_group_add_widget(sg, image); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
507 |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
508 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
509 gtk_widget_show(image); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
510 |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
511 /* Create the label. */ |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
512 label = gtk_label_new(plugin->info->name); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
513 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
514 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
515 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
516 gtk_widget_show(label); |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
517 |
7956 | 518 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
|
519 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
520 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
521 gtk_widget_show(item); |
8137 | 522 gaim_set_accessible_label (item, label); |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
523 |
8218
4beaf6b35483
[gaim-migrate @ 8941]
Christian Hammond <chipx86@chipx86.com>
parents:
8215
diff
changeset
|
524 if (id != NULL && !strcmp(plugin->info->id, id)) |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
525 selected_index = i; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
526 } |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
527 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
528 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu); |
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 if (selected_index != -1) |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
531 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), selected_index); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
532 |
5688
e43e1b8dca8b
[gaim-migrate @ 6109]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
533 g_signal_connect(G_OBJECT(optmenu), "changed", |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
534 G_CALLBACK(protocol_menu_cb), cb); |
5688
e43e1b8dca8b
[gaim-migrate @ 6109]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
535 |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
536 g_object_unref(sg); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
537 |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
538 return optmenu; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
539 } |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
540 |
8940 | 541 GaimAccount * |
542 gaim_gtk_account_option_menu_get_selected(GtkWidget *optmenu) | |
543 { | |
544 GtkWidget *menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); | |
545 GtkWidget *item = gtk_menu_get_active(GTK_MENU(menu)); | |
546 return g_object_get_data(G_OBJECT(item), "account"); | |
547 } | |
548 | |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
549 static void |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
550 account_menu_cb(GtkWidget *optmenu, GCallback cb) |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
551 { |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
552 GtkWidget *menu; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
553 GtkWidget *item; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
554 GaimAccount *account; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
555 gpointer user_data; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
556 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
557 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
558 item = gtk_menu_get_active(GTK_MENU(menu)); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
559 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
560 account = g_object_get_data(G_OBJECT(item), "account"); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
561 user_data = g_object_get_data(G_OBJECT(optmenu), "user_data"); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
562 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
563 if (cb != NULL) |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
564 ((void (*)(GtkWidget *, GaimAccount *, gpointer))cb)(item, account, |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
565 user_data); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
566 } |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
567 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
568 static void |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
569 create_account_menu(GtkWidget *optmenu, GaimAccount *default_account, |
8289
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
570 GaimFilterAccountFunc filter_func, gboolean show_all) |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
571 { |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
572 GaimAccount *account; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
573 GtkWidget *menu; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
574 GtkWidget *item; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
575 GtkWidget *image; |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
576 GtkWidget *hbox; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
577 GtkWidget *label; |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
578 GdkPixbuf *pixbuf; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
579 GdkPixbuf *scale; |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
580 GList *list; |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
581 GList *p; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
582 GtkSizeGroup *sg; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
583 char *filename; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
584 const char *proto_name; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
585 char buf[256]; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
586 int i, selected_index = -1; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
587 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
588 if (show_all) |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
589 list = gaim_accounts_get_all(); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
590 else |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
591 list = gaim_connections_get_all(); |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
592 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
593 menu = gtk_menu_new(); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
594 gtk_widget_show(menu); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
595 |
5880
1b85ff65be57
[gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
596 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
597 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
598 for (p = list, i = 0; p != NULL; p = p->next, i++) { |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
599 GaimPluginProtocolInfo *prpl_info = NULL; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
600 GaimPlugin *plugin; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
601 |
5879
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
602 if (show_all) |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
603 account = (GaimAccount *)p->data; |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
604 else { |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
605 GaimConnection *gc = (GaimConnection *)p->data; |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
606 |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
607 account = gaim_connection_get_account(gc); |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
608 } |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
609 |
8289
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
610 if (filter_func && !filter_func(account)) { |
8215 | 611 i--; |
6646
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
612 continue; |
8215 | 613 } |
6646
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
614 |
7956 | 615 plugin = gaim_find_prpl(gaim_account_get_protocol_id(account)); |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
616 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
617 if (plugin != NULL) |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
618 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
619 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
620 /* Create the item. */ |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
621 item = gtk_menu_item_new(); |
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 /* Create the hbox. */ |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
624 hbox = gtk_hbox_new(FALSE, 4); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
625 gtk_container_add(GTK_CONTAINER(item), hbox); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
626 gtk_widget_show(hbox); |
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 /* Load the image. */ |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
629 if (prpl_info != NULL) { |
6430 | 630 proto_name = prpl_info->list_icon(account, NULL); |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
631 g_snprintf(buf, sizeof(buf), "%s.png", proto_name); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
632 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
633 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
634 "default", buf, NULL); |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
635 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
636 g_free(filename); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
637 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
638 if (pixbuf != NULL) { |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
639 /* Scale and insert the image */ |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
640 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
641 GDK_INTERP_BILINEAR); |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
642 |
8215 | 643 if (!gaim_account_is_connected(account) && show_all && |
644 gaim_connections_get_all()) | |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
645 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE); |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
646 |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
647 image = gtk_image_new_from_pixbuf(scale); |
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 g_object_unref(G_OBJECT(pixbuf)); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
650 g_object_unref(G_OBJECT(scale)); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
651 } |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
652 else |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
653 image = gtk_image_new(); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
654 } |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
655 else |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
656 image = gtk_image_new(); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
657 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
658 gtk_size_group_add_widget(sg, image); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
659 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
660 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
661 gtk_widget_show(image); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
662 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
663 g_snprintf(buf, sizeof(buf), "%s (%s)", |
9899 | 664 gaim_account_get_username(account), |
665 gaim_account_get_protocol_name(account)); | |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
666 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
667 /* Create the label. */ |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
668 label = gtk_label_new(buf); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
669 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
670 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
671 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
672 gtk_widget_show(label); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
673 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
674 g_object_set_data(G_OBJECT(item), "account", account); |
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 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
677 gtk_widget_show(item); |
8137 | 678 gaim_set_accessible_label (item, label); |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
679 |
5880
1b85ff65be57
[gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
680 if (default_account != NULL && account == default_account) |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
681 selected_index = i; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
682 } |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
683 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
684 g_object_unref(sg); |
5880
1b85ff65be57
[gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
685 |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
686 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
687 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
688 /* Set the place we should be at. */ |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
689 if (selected_index != -1) |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
690 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
|
691 } |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
692 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
693 static void |
8134 | 694 regenerate_account_menu(GtkWidget *optmenu) |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
695 { |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
696 GtkWidget *menu; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
697 GtkWidget *item; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
698 gboolean show_all; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
699 GaimAccount *account; |
8289
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
700 GaimFilterAccountFunc filter_func; |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
701 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
702 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
703 item = gtk_menu_get_active(GTK_MENU(menu)); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
704 account = g_object_get_data(G_OBJECT(item), "account"); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
705 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
706 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
|
707 "show_all")); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
708 |
8289
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
709 filter_func = g_object_get_data(G_OBJECT(optmenu), |
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
710 "filter_func"); |
6646
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
711 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
712 gtk_option_menu_remove_menu(GTK_OPTION_MENU(optmenu)); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
713 |
8289
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
714 create_account_menu(optmenu, account, filter_func, show_all); |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
715 } |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
716 |
8134 | 717 static void |
718 account_menu_sign_on_off_cb(GaimConnection *gc, GtkWidget *optmenu) | |
719 { | |
720 regenerate_account_menu(optmenu); | |
721 } | |
722 | |
723 static void | |
724 account_menu_added_removed_cb(GaimAccount *account, GtkWidget *optmenu) | |
725 { | |
726 regenerate_account_menu(optmenu); | |
727 } | |
728 | |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
729 static gboolean |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
730 account_menu_destroyed_cb(GtkWidget *optmenu, GdkEvent *event, |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
731 void *user_data) |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
732 { |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
733 gaim_signals_disconnect_by_handle(optmenu); |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
734 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
735 return FALSE; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
736 } |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
737 |
9910 | 738 void |
739 gaim_gtk_account_option_menu_set_selected(GtkWidget *optmenu, GaimAccount *account) | |
740 { | |
741 GtkWidget *menu; | |
742 GtkWidget *item; | |
743 gboolean show_all; | |
744 GaimAccount *curaccount; | |
745 GaimFilterAccountFunc filter_func; | |
746 | |
747 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); | |
748 item = gtk_menu_get_active(GTK_MENU(menu)); | |
749 curaccount = g_object_get_data(G_OBJECT(item), "account"); | |
750 | |
751 if (account == curaccount) | |
752 return; | |
753 | |
754 show_all = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(optmenu), | |
755 "show_all")); | |
756 | |
757 filter_func = g_object_get_data(G_OBJECT(optmenu), | |
758 "filter_func"); | |
759 | |
760 gtk_option_menu_remove_menu(GTK_OPTION_MENU(optmenu)); | |
761 | |
762 create_account_menu(optmenu, account, filter_func, show_all); | |
763 } | |
764 | |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
765 GtkWidget * |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
766 gaim_gtk_account_option_menu_new(GaimAccount *default_account, |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
767 gboolean show_all, GCallback cb, |
8289
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
768 GaimFilterAccountFunc filter_func, |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
769 gpointer user_data) |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
770 { |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
771 GtkWidget *optmenu; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
772 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
773 /* Create the option menu */ |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
774 optmenu = gtk_option_menu_new(); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
775 gtk_widget_show(optmenu); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
776 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
777 g_signal_connect(G_OBJECT(optmenu), "destroy", |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
778 G_CALLBACK(account_menu_destroyed_cb), NULL); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
779 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
780 /* Register the gaim sign on/off event callbacks. */ |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
781 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
782 optmenu, GAIM_CALLBACK(account_menu_sign_on_off_cb), |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
783 optmenu); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
784 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
785 optmenu, GAIM_CALLBACK(account_menu_sign_on_off_cb), |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
786 optmenu); |
8134 | 787 gaim_signal_connect(gaim_accounts_get_handle(), "account-added", |
788 optmenu, GAIM_CALLBACK(account_menu_added_removed_cb), | |
789 optmenu); | |
790 gaim_signal_connect(gaim_accounts_get_handle(), "account-removed", | |
791 optmenu, GAIM_CALLBACK(account_menu_added_removed_cb), | |
792 optmenu); | |
6391
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 /* Set some data. */ |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
795 g_object_set_data(G_OBJECT(optmenu), "user_data", user_data); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
796 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
|
797 g_object_set_data(G_OBJECT(optmenu), "filter_func", |
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
798 filter_func); |
6391
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 /* Create and set the actual menu. */ |
8289
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
801 create_account_menu(optmenu, default_account, filter_func, show_all); |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
802 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
803 /* And now the last callback. */ |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
804 g_signal_connect(G_OBJECT(optmenu), "changed", |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
805 G_CALLBACK(account_menu_cb), cb); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
806 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
807 return optmenu; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
808 } |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
809 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
810 gboolean |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
811 gaim_gtk_check_if_dir(const char *path, GtkFileSelection *filesel) |
5966 | 812 { |
5967 | 813 char *dirname; |
5966 | 814 |
5967 | 815 if (g_file_test(path, G_FILE_TEST_IS_DIR)) { |
5966 | 816 /* append a / if needed */ |
9534 | 817 if (path[strlen(path) - 1] != G_DIR_SEPARATOR) { |
818 dirname = g_strconcat(path, G_DIR_SEPARATOR_S, NULL); | |
5966 | 819 } else { |
5967 | 820 dirname = g_strdup(path); |
5966 | 821 } |
5967 | 822 gtk_file_selection_set_filename(filesel, dirname); |
823 g_free(dirname); | |
5966 | 824 return TRUE; |
825 } | |
826 | |
827 return FALSE; | |
828 } | |
829 | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
830 char *stylize(const gchar *text, int length) |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
831 { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
832 gchar *buf; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
833 char *tmp = g_malloc(length); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
834 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
835 buf = g_malloc(length); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
836 g_snprintf(buf, length, "%s", text); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
837 |
9025 | 838 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_formatting")) { |
839 const char *font; | |
840 GdkColor fg_color, bg_color; | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
841 |
9025 | 842 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold")) { |
843 g_snprintf(tmp, length, "<B>%s</B>", buf); | |
844 strcpy(buf, tmp); | |
845 } | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
846 |
9025 | 847 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_italic")) { |
848 g_snprintf(tmp, length, "<I>%s</I>", buf); | |
849 strcpy(buf, tmp); | |
850 } | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
851 |
9025 | 852 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_underline")) { |
853 g_snprintf(tmp, length, "<U>%s</U>", buf); | |
854 strcpy(buf, tmp); | |
855 } | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
856 |
9025 | 857 font = gaim_prefs_get_string("/gaim/gtk/conversations/font_face"); |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
858 |
9025 | 859 if (strcmp(font, "") != 0) { |
860 g_snprintf(tmp, length, "<FONT FACE=\"%s\">%s</FONT>", font, buf); | |
861 strcpy(buf, tmp); | |
862 } | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
863 |
9025 | 864 g_snprintf(tmp, length, "<FONT SIZE=\"%d\">%s</FONT>", |
865 gaim_prefs_get_int("/gaim/gtk/conversations/font_size"), buf); | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
866 strcpy(buf, tmp); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
867 |
9025 | 868 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), "") != 0) |
869 { | |
870 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), | |
871 &fg_color); | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
872 |
9025 | 873 g_snprintf(tmp, length, "<FONT COLOR=\"#%02X%02X%02X\">%s</FONT>", |
874 fg_color.red/256, fg_color.green/256, | |
875 fg_color.blue/256, buf); | |
876 strcpy(buf, tmp); | |
877 } | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
878 |
9025 | 879 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) |
880 { | |
881 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), | |
882 &bg_color); | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
883 |
9025 | 884 g_snprintf(tmp, length, "<BODY BGCOLOR=\"#%02X%02X%02X\">%s</BODY>", |
885 bg_color.red/256, bg_color.green/256, | |
886 bg_color.blue/256, buf); | |
887 strcpy(buf, tmp); | |
888 } | |
889 | |
5943
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 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
892 g_free(tmp); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
893 return buf; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
894 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
895 |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
896 void |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
897 gaim_gtk_setup_gtkspell(GtkTextView *textview) |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
898 { |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
899 #ifdef USE_GTKSPELL |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
900 GError *error = NULL; |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
901 char *locale = NULL; |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
902 |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
903 g_return_if_fail(textview != NULL); |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
904 g_return_if_fail(GTK_IS_TEXT_VIEW(textview)); |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
905 |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
906 if (gtkspell_new_attach(textview, locale, &error) == NULL && error) |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
907 { |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
908 gaim_debug_warning("gtkspell", "Failed to setup GtkSpell: %s\n", |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
909 error->message); |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
910 g_error_free(error); |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
911 } |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
912 #endif /* USE_GTKSPELL */ |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
913 } |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
914 |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
915 void |
7420 | 916 gaim_gtk_save_accels_cb(GtkAccelGroup *accel_group, guint arg1, |
917 GdkModifierType arg2, GClosure *arg3, | |
918 gpointer data) | |
919 { | |
920 gaim_debug(GAIM_DEBUG_MISC, "accels", "accel changed, scheduling save.\n"); | |
921 | |
922 if (!accels_save_timer) | |
923 accels_save_timer = g_timeout_add(5000, gaim_gtk_save_accels, NULL); | |
924 } | |
925 | |
926 gboolean | |
927 gaim_gtk_save_accels(gpointer data) | |
928 { | |
929 char *filename = NULL; | |
930 | |
931 filename = g_build_filename(gaim_user_dir(), G_DIR_SEPARATOR_S, | |
932 "accels", NULL); | |
933 gaim_debug(GAIM_DEBUG_MISC, "accels", "saving accels to %s\n", filename); | |
934 gtk_accel_map_save(filename); | |
935 g_free(filename); | |
936 | |
937 accels_save_timer = 0; | |
938 return FALSE; | |
939 } | |
940 | |
941 void | |
942 gaim_gtk_load_accels(gpointer data) | |
943 { | |
944 char *filename = NULL; | |
945 | |
946 filename = g_build_filename(gaim_user_dir(), G_DIR_SEPARATOR_S, | |
947 "accels", NULL); | |
948 gtk_accel_map_load(filename); | |
949 g_free(filename); | |
950 } | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
951 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
952 gboolean |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
953 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
|
954 GaimAccount **ret_account, char **ret_protocol, |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
955 char **ret_username, char **ret_alias) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
956 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
957 char *protocol = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
958 char *username = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
959 char *alias = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
960 char *str; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
961 char *c, *s; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
962 gboolean valid; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
963 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
964 g_return_val_if_fail(msg != NULL, FALSE); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
965 g_return_val_if_fail(ret_protocol != NULL, FALSE); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
966 g_return_val_if_fail(ret_username != NULL, FALSE); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
967 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
968 s = str = g_strdup(msg); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
969 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
970 while (*s != '\r' && *s != '\n' && *s != '\0') |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
971 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
972 char *key, *value; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
973 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
974 key = s; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
975 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
976 /* Grab the key */ |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
977 while (*s != '\r' && *s != '\n' && *s != '\0' && *s != ' ') |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
978 s++; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
979 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
980 if (*s == '\r') s++; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
981 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
982 if (*s == '\n') |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
983 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
984 s++; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
985 continue; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
986 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
987 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
988 if (*s != '\0') *s++ = '\0'; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
989 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
990 /* Clear past any whitespace */ |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
991 while (*s != '\0' && *s == ' ') |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
992 s++; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
993 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
994 /* Now let's grab until the end of the line. */ |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
995 value = s; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
996 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
997 while (*s != '\r' && *s != '\n' && *s != '\0') |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
998 s++; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
999 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1000 if (*s == '\r') *s++ = '\0'; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1001 if (*s == '\n') *s++ = '\0'; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1002 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1003 if ((c = strchr(key, ':')) != NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1004 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1005 if (!g_ascii_strcasecmp(key, "X-IM-Username:")) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1006 username = g_strdup(value); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1007 else if (!g_ascii_strcasecmp(key, "X-IM-Protocol:")) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1008 protocol = g_strdup(value); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1009 else if (!g_ascii_strcasecmp(key, "X-IM-Alias:")) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1010 alias = g_strdup(value); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1011 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1012 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1013 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1014 if (username != NULL && protocol != NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1015 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1016 valid = TRUE; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1017 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1018 *ret_username = username; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1019 *ret_protocol = protocol; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1020 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1021 if (ret_alias != NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1022 *ret_alias = alias; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1023 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1024 /* Check for a compatible account. */ |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1025 if (ret_account != NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1026 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1027 GList *list; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1028 GaimAccount *account = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1029 GList *l; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1030 const char *protoname; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1031 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1032 if (all_accounts) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1033 list = gaim_accounts_get_all(); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1034 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1035 list = gaim_connections_get_all(); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1036 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1037 for (l = list; l != NULL; l = l->next) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1038 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1039 GaimConnection *gc; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1040 GaimPluginProtocolInfo *prpl_info = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1041 GaimPlugin *plugin; |
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 if (all_accounts) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1044 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1045 account = (GaimAccount *)l->data; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1046 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1047 plugin = gaim_plugins_find_with_id( |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1048 gaim_account_get_protocol_id(account)); |
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 if (plugin == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1051 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1052 account = NULL; |
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 continue; |
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 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1057 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1058 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1059 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1060 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1061 gc = (GaimConnection *)l->data; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1062 account = gaim_connection_get_account(gc); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1063 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1064 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
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 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1067 protoname = prpl_info->list_icon(account, NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1068 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1069 if (!strcmp(protoname, protocol)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1070 break; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1071 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1072 account = NULL; |
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 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1075 /* Special case for AIM and ICQ */ |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1076 if (account == NULL && (!strcmp(protocol, "aim") || |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1077 !strcmp(protocol, "icq"))) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1078 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1079 for (l = list; l != NULL; l = l->next) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1080 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1081 GaimConnection *gc; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1082 GaimPluginProtocolInfo *prpl_info = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1083 GaimPlugin *plugin; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1084 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1085 if (all_accounts) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1086 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1087 account = (GaimAccount *)l->data; |
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 plugin = gaim_plugins_find_with_id( |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1090 gaim_account_get_protocol_id(account)); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1091 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1092 if (plugin == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1093 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1094 account = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1095 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1096 continue; |
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 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1100 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1101 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1102 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1103 gc = (GaimConnection *)l->data; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1104 account = gaim_connection_get_account(gc); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1105 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1106 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1107 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1108 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1109 protoname = prpl_info->list_icon(account, NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1110 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1111 if (!strcmp(protoname, "aim") || !strcmp(protoname, "icq")) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1112 break; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1113 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1114 account = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1115 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1116 } |
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 *ret_account = account; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1119 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1120 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1121 else |
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 valid = FALSE; |
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 if (username != NULL) g_free(username); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1126 if (protocol != NULL) g_free(protocol); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1127 if (alias != NULL) g_free(alias); |
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 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1130 g_free(str); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1131 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1132 return valid; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1133 } |
8137 | 1134 |
1135 void | |
1136 gaim_set_accessible_label (GtkWidget *w, GtkWidget *l) | |
1137 { | |
1138 AtkObject *acc, *label; | |
1139 AtkObject *rel_obj[1]; | |
1140 AtkRelationSet *set; | |
1141 AtkRelation *relation; | |
1142 const gchar *label_text; | |
1143 const gchar *existing_name; | |
1144 | |
1145 acc = gtk_widget_get_accessible (w); | |
1146 label = gtk_widget_get_accessible (l); | |
1147 | |
1148 /* If this object has no name, set it's name with the label text */ | |
1149 existing_name = atk_object_get_name (acc); | |
1150 if (!existing_name) { | |
1151 label_text = gtk_label_get_text (GTK_LABEL(l)); | |
1152 if (label_text) | |
1153 atk_object_set_name (acc, label_text); | |
1154 } | |
1155 | |
1156 /* Create the labeled-by relation */ | |
1157 set = atk_object_ref_relation_set (acc); | |
1158 rel_obj[0] = label; | |
1159 relation = atk_relation_new (rel_obj, 1, ATK_RELATION_LABELLED_BY); | |
1160 atk_relation_set_add (set, relation); | |
1161 g_object_unref (relation); | |
1162 | |
1163 /* Create the label-for relation */ | |
1164 set = atk_object_ref_relation_set (label); | |
1165 rel_obj[0] = acc; | |
1166 relation = atk_relation_new (rel_obj, 1, ATK_RELATION_LABEL_FOR); | |
1167 atk_relation_set_add (set, relation); | |
1168 g_object_unref (relation); | |
1169 } | |
8143 | 1170 |
8247 | 1171 #if GTK_CHECK_VERSION(2,2,0) |
8143 | 1172 static void |
1173 gaim_gtk_menu_position_func(GtkMenu *menu, | |
1174 gint *x, | |
1175 gint *y, | |
1176 gboolean *push_in, | |
1177 gpointer data) | |
1178 { | |
1179 GtkWidget *widget; | |
1180 GtkRequisition requisition; | |
1181 GdkScreen *screen; | |
1182 GdkRectangle monitor; | |
1183 gint monitor_num; | |
1184 gint space_left, space_right, space_above, space_below; | |
1185 gint needed_width; | |
1186 gint needed_height; | |
1187 gint xthickness; | |
1188 gint ythickness; | |
1189 gboolean rtl; | |
1190 | |
1191 g_return_if_fail(GTK_IS_MENU(menu)); | |
1192 | |
1193 widget = GTK_WIDGET(menu); | |
1194 screen = gtk_widget_get_screen(widget); | |
1195 xthickness = widget->style->xthickness; | |
1196 ythickness = widget->style->ythickness; | |
1197 rtl = (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL); | |
1198 | |
1199 /* | |
1200 * We need the requisition to figure out the right place to | |
1201 * popup the menu. In fact, we always need to ask here, since | |
1202 * if a size_request was queued while we weren't popped up, | |
1203 * the requisition won't have been recomputed yet. | |
1204 */ | |
1205 gtk_widget_size_request (widget, &requisition); | |
1206 | |
1207 monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y); | |
1208 | |
1209 push_in = FALSE; | |
1210 | |
1211 /* | |
1212 * The placement of popup menus horizontally works like this (with | |
1213 * RTL in parentheses) | |
1214 * | |
1215 * - If there is enough room to the right (left) of the mouse cursor, | |
1216 * position the menu there. | |
1217 * | |
1218 * - Otherwise, if if there is enough room to the left (right) of the | |
1219 * mouse cursor, position the menu there. | |
1220 * | |
1221 * - Otherwise if the menu is smaller than the monitor, position it | |
1222 * on the side of the mouse cursor that has the most space available | |
1223 * | |
1224 * - Otherwise (if there is simply not enough room for the menu on the | |
1225 * monitor), position it as far left (right) as possible. | |
1226 * | |
1227 * Positioning in the vertical direction is similar: first try below | |
1228 * mouse cursor, then above. | |
1229 */ | |
1230 gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); | |
1231 | |
1232 space_left = *x - monitor.x; | |
1233 space_right = monitor.x + monitor.width - *x - 1; | |
1234 space_above = *y - monitor.y; | |
1235 space_below = monitor.y + monitor.height - *y - 1; | |
1236 | |
1237 /* position horizontally */ | |
1238 | |
1239 /* the amount of space we need to position the menu. Note the | |
1240 * menu is offset "xthickness" pixels | |
1241 */ | |
1242 needed_width = requisition.width - xthickness; | |
1243 | |
1244 if (needed_width <= space_left || | |
1245 needed_width <= space_right) | |
1246 { | |
1247 if ((rtl && needed_width <= space_left) || | |
1248 (!rtl && needed_width > space_right)) | |
1249 { | |
1250 /* position left */ | |
1251 *x = *x + xthickness - requisition.width + 1; | |
1252 } | |
1253 else | |
1254 { | |
1255 /* position right */ | |
1256 *x = *x - xthickness; | |
1257 } | |
1258 | |
1259 /* x is clamped on-screen further down */ | |
1260 } | |
1261 else if (requisition.width <= monitor.width) | |
1262 { | |
1263 /* the menu is too big to fit on either side of the mouse | |
1264 * cursor, but smaller than the monitor. Position it on | |
1265 * the side that has the most space | |
1266 */ | |
1267 if (space_left > space_right) | |
1268 { | |
1269 /* left justify */ | |
1270 *x = monitor.x; | |
1271 } | |
1272 else | |
1273 { | |
1274 /* right justify */ | |
1275 *x = monitor.x + monitor.width - requisition.width; | |
1276 } | |
1277 } | |
1278 else /* menu is simply too big for the monitor */ | |
1279 { | |
1280 if (rtl) | |
1281 { | |
1282 /* right justify */ | |
1283 *x = monitor.x + monitor.width - requisition.width; | |
1284 } | |
1285 else | |
1286 { | |
1287 /* left justify */ | |
1288 *x = monitor.x; | |
1289 } | |
1290 } | |
1291 | |
1292 /* Position vertically. The algorithm is the same as above, but | |
1293 * simpler because we don't have to take RTL into account. | |
1294 */ | |
1295 needed_height = requisition.height - ythickness; | |
1296 | |
1297 if (needed_height <= space_above || | |
1298 needed_height <= space_below) | |
1299 { | |
1300 if (needed_height <= space_below) | |
1301 *y = *y - ythickness; | |
1302 else | |
1303 *y = *y + ythickness - requisition.height + 1; | |
10061 | 1304 |
8143 | 1305 *y = CLAMP (*y, monitor.y, |
1306 monitor.y + monitor.height - requisition.height); | |
1307 } | |
1308 else if (needed_height > space_below && needed_height > space_above) | |
1309 { | |
1310 if (space_below >= space_above) | |
1311 *y = monitor.y + monitor.height - requisition.height; | |
1312 else | |
1313 *y = monitor.y; | |
1314 } | |
1315 else | |
1316 { | |
1317 *y = monitor.y; | |
1318 } | |
1319 } | |
1320 | |
8247 | 1321 #endif |
1322 | |
8143 | 1323 void |
1324 gaim_gtk_treeview_popup_menu_position_func(GtkMenu *menu, | |
1325 gint *x, | |
1326 gint *y, | |
1327 gboolean *push_in, | |
1328 gpointer data) | |
1329 { | |
1330 GtkWidget *widget = GTK_WIDGET(data); | |
1331 GtkTreeView *tv = GTK_TREE_VIEW(data); | |
1332 GtkTreePath *path; | |
1333 GtkTreeViewColumn *col; | |
1334 GdkRectangle rect; | |
1335 gint ythickness = GTK_WIDGET(menu)->style->ythickness; | |
1336 | |
1337 gdk_window_get_origin (widget->window, x, y); | |
1338 gtk_tree_view_get_cursor (tv, &path, &col); | |
1339 gtk_tree_view_get_cell_area (tv, path, col, &rect); | |
8218
4beaf6b35483
[gaim-migrate @ 8941]
Christian Hammond <chipx86@chipx86.com>
parents:
8215
diff
changeset
|
1340 |
8143 | 1341 *x += rect.x+rect.width; |
1342 *y += rect.y+rect.height+ythickness; | |
8247 | 1343 #if GTK_CHECK_VERSION(2,2,0) |
8143 | 1344 gaim_gtk_menu_position_func (menu, x, y, push_in, data); |
8247 | 1345 #endif |
8143 | 1346 } |
10061 | 1347 |
1348 gboolean | |
1349 gaim_running_gnome(void) | |
1350 { | |
1351 if ((g_getenv("GNOME_DESKTOP_SESSION_ID") != NULL) && | |
1352 (g_find_program_in_path("gnome-open") != NULL)) | |
1353 { | |
1354 return TRUE; | |
1355 } | |
1356 | |
1357 return FALSE; | |
1358 } | |
10229 | 1359 |
1360 enum { | |
1361 DND_FILE_TRANSFER, | |
1362 DND_IM_IMAGE, | |
1363 DND_BUDDY_ICON | |
1364 }; | |
1365 | |
1366 typedef struct { | |
1367 char *filename; | |
1368 GaimAccount *account; | |
1369 char *who; | |
1370 } _DndData; | |
1371 | |
1372 void dnd_set_icon_ok_cb(_DndData *data) | |
1373 { | |
1374 free(data->filename); | |
1375 free(data->who); | |
1376 free(data); | |
1377 } | |
1378 | |
1379 void dnd_set_icon_cancel_cb(_DndData *data) | |
1380 { | |
1381 free(data->filename); | |
1382 free(data->who); | |
1383 free (data); | |
1384 } | |
1385 | |
1386 void dnd_image_ok_callback(_DndData *data, int choice) | |
1387 { | |
1388 char *filedata; | |
1389 size_t size; | |
1390 GError *err = NULL; | |
1391 GaimConversation *conv; | |
1392 GaimGtkConversation *gtkconv; | |
1393 GtkTextIter iter; | |
1394 int id; | |
1395 switch (choice) { | |
1396 case DND_BUDDY_ICON: | |
1397 if (!g_file_get_contents(data->filename, &filedata, &size, | |
1398 &err)) { | |
1399 char *str; | |
1400 | |
1401 str = g_strdup_printf(_("The following error has occurred loading %s: %s"), data->filename, err->message); | |
1402 gaim_notify_error(NULL, NULL, | |
1403 _("Failed to load image"), | |
1404 str); | |
10335 | 1405 |
10229 | 1406 g_error_free(err); |
1407 g_free(str); | |
1408 | |
1409 return; | |
1410 } | |
10335 | 1411 |
10229 | 1412 gaim_buddy_icons_set_for_user(data->account, data->who, filedata, size); |
1413 g_free(filedata); | |
1414 break; | |
1415 case DND_FILE_TRANSFER: | |
1416 serv_send_file(gaim_account_get_connection(data->account), data->who, data->filename); | |
1417 break; | |
1418 case DND_IM_IMAGE: | |
1419 conv = gaim_conversation_new(GAIM_CONV_IM, data->account, data->who); | |
1420 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1421 | |
1422 if (!g_file_get_contents(data->filename, &filedata, &size, | |
1423 &err)) { | |
1424 char *str; | |
10335 | 1425 |
10229 | 1426 str = g_strdup_printf(_("The following error has occurred loading %s: %s"), data->filename, err->message); |
1427 gaim_notify_error(NULL, NULL, | |
1428 _("Failed to load image"), | |
1429 str); | |
10335 | 1430 |
10229 | 1431 g_error_free(err); |
1432 g_free(str); | |
10335 | 1433 |
10229 | 1434 return; |
1435 } | |
1436 id = gaim_imgstore_add(filedata, size, data->filename); | |
1437 g_free(filedata); | |
10335 | 1438 |
10229 | 1439 gtk_text_buffer_get_iter_at_mark(GTK_IMHTML(gtkconv->entry)->text_buffer, &iter, |
1440 gtk_text_buffer_get_insert(GTK_IMHTML(gtkconv->entry)->text_buffer)); | |
1441 gtk_imhtml_insert_image_at_iter(GTK_IMHTML(gtkconv->entry), id, &iter); | |
1442 gaim_imgstore_unref(id); | |
10335 | 1443 |
10229 | 1444 break; |
1445 } | |
1446 free(data->filename); | |
1447 free(data->who); | |
1448 free(data); | |
1449 } | |
1450 | |
1451 void dnd_image_cancel_callback(_DndData *data, int choice) | |
1452 { | |
1453 free(data->filename); | |
1454 free(data->who); | |
1455 free(data); | |
1456 } | |
1457 | |
1458 void | |
1459 gaim_dnd_file_manage(GtkSelectionData *sd, GaimAccount *account, const char *who) | |
1460 { | |
1461 GList *tmp; | |
1462 GdkPixbuf *pb; | |
1463 GList *files = gaim_uri_list_extract_filenames(sd->data); | |
1464 GaimConnection *gc = gaim_account_get_connection(account); | |
1465 GaimPluginProtocolInfo *prpl_info = NULL; | |
10335 | 1466 gboolean file_send_ok = FALSE; |
1467 #ifndef _WIN32 | |
10229 | 1468 GaimDesktopItem *item; |
10335 | 1469 #endif |
10229 | 1470 |
1471 g_return_if_fail(account != NULL); | |
1472 g_return_if_fail(who != NULL); | |
10335 | 1473 |
10229 | 1474 for(tmp = files; tmp != NULL ; tmp = g_list_next(tmp)) { |
1475 gchar *filename = tmp->data; | |
1476 gchar *basename = g_path_get_basename(filename); | |
10335 | 1477 |
10229 | 1478 /* Set the default action: don't send anything */ |
1479 file_send_ok = FALSE; | |
1480 | |
1481 /* XXX - Make ft API support creating a transfer with more than one file */ | |
1482 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { | |
1483 continue; | |
1484 } | |
1485 | |
1486 /* XXX - make ft api suupport sending a directory */ | |
1487 /* Are we dealing with a directory? */ | |
1488 if (g_file_test(filename, G_FILE_TEST_IS_DIR)) { | |
1489 char *str; | |
1490 | |
1491 str = g_strdup_printf(_("Cannot send folder %s."), basename); | |
1492 gaim_notify_error(NULL, NULL, | |
1493 str,_("Gaim cannot transfer a folder. You will need to send the files within individually")); | |
10335 | 1494 |
10229 | 1495 g_free(str); |
10335 | 1496 |
1497 continue; | |
10229 | 1498 } |
1499 | |
1500 /* Are we dealing with an image? */ | |
1501 pb = gdk_pixbuf_new_from_file(filename, NULL); | |
1502 if (pb) { | |
1503 _DndData *data = g_malloc(sizeof(_DndData)); | |
1504 gboolean ft = FALSE, im = FALSE; | |
10335 | 1505 |
10229 | 1506 data->who = g_strdup(who); |
1507 data->filename = g_strdup(filename); | |
1508 data->account = account; | |
1509 | |
1510 if (gc) | |
1511 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
10348 | 1512 |
10229 | 1513 if (prpl_info && prpl_info->options & OPT_PROTO_IM_IMAGE) |
1514 im = TRUE; | |
10335 | 1515 |
10348 | 1516 if (prpl_info && prpl_info->can_receive_file) |
10229 | 1517 ft = prpl_info->can_receive_file(gc, who); |
10335 | 1518 |
10229 | 1519 if (im && ft) |
1520 gaim_request_choice(NULL, NULL, | |
1521 _("You have dragged an image"), | |
1522 _("You can send this image as a file transfer," | |
1523 " embed it into this message, or use it as the buddy icon for this user."), | |
1524 DND_BUDDY_ICON, "OK", (GCallback)dnd_image_ok_callback, | |
10335 | 1525 "Cancel", (GCallback)dnd_image_cancel_callback, data, |
10229 | 1526 _("Set as buddy icon"), DND_BUDDY_ICON, |
10335 | 1527 _("Send image file"), DND_FILE_TRANSFER, |
1528 _("Insert in message"), DND_IM_IMAGE, NULL); | |
10229 | 1529 else if (!(im || ft)) |
10335 | 1530 gaim_request_yes_no(NULL, NULL, _("You have dragged an image"), |
10229 | 1531 _("Would you like to set it as the buddy icon for this user?"), |
1532 0, data, (GCallback)dnd_set_icon_ok_cb, (GCallback)dnd_set_icon_cancel_cb); | |
10335 | 1533 else |
10229 | 1534 gaim_request_choice(NULL, NULL, |
1535 _("You have dragged an image"), | |
1536 ft ? _("You can send this image as a file transfer or" | |
1537 "embed it into this message, or use it as the buddy icon for this user.") : | |
1538 _("You can insert this image into this message, or use it as the buddy icon for this user"), | |
1539 DND_BUDDY_ICON, "OK", (GCallback)dnd_image_ok_callback, | |
10335 | 1540 "Cancel", (GCallback)dnd_image_cancel_callback, data, |
10229 | 1541 _("Set as buddy icon"), DND_BUDDY_ICON, |
10335 | 1542 ft ? _("Send image file") : _("Insert in message"), ft ? DND_FILE_TRANSFER : DND_IM_IMAGE, NULL); |
10229 | 1543 return; |
1544 } | |
1545 | |
1546 #ifndef _WIN32 | |
1547 /* Are we trying to send a .desktop file? */ | |
1548 else if (g_str_has_suffix(basename, ".desktop") && (item = gaim_desktop_item_new_from_file(filename))) { | |
1549 GaimDesktopItemType dtype; | |
1550 char key[64]; | |
1551 char *dot; | |
1552 const char *itemname = NULL; | |
10335 | 1553 |
10229 | 1554 #if GTK_CHECK_VERSION(2,6,0) |
1555 char **langs; | |
1556 int i; | |
1557 langs = g_get_language_names(); | |
1558 for (i = 0; langs[i]; i++) { | |
1559 g_snprintf(key, sizeof(key), "Name[%s]", langs[i]); | |
1560 itemname = gaim_desktop_item_get_string(item, key); | |
1561 break; | |
1562 } | |
1563 #else | |
1564 const char *lang = g_getenv("LANG"); | |
1565 dot = strchr(lang, '.'); | |
10335 | 1566 if (dot) |
10229 | 1567 *dot = '\0'; |
1568 g_snprintf(key, sizeof(key), "Name[%s]", lang); | |
1569 itemname = gaim_desktop_item_get_string(item, key); | |
1570 #endif | |
1571 if (!itemname) | |
1572 itemname = gaim_desktop_item_get_string(item, "Name"); | |
1573 | |
1574 dtype = gaim_desktop_item_get_entry_type(item); | |
1575 switch (dtype) { | |
1576 GaimConversation *conv; | |
1577 GaimGtkConversation *gtkconv; | |
1578 | |
1579 case GAIM_DESKTOP_ITEM_TYPE_LINK: | |
1580 conv = gaim_conversation_new(GAIM_CONV_IM, account, who); | |
1581 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10335 | 1582 gtk_imhtml_insert_link(GTK_IMHTML(gtkconv->entry), |
1583 gtk_text_buffer_get_insert(GTK_IMHTML(gtkconv->entry)->text_buffer), | |
10229 | 1584 gaim_desktop_item_get_string(item, "URL"), itemname); |
1585 break; | |
10335 | 1586 default: |
10229 | 1587 /* I don't know if we really want to do anything here. Most of the desktop item types are crap like |
1588 * "MIME Type" (I have no clue how that would be a desktop item) and "Comment"... nothing we can really | |
1589 * send. The only logical one is "Application," but do we really want to send a binary and nothing else? | |
1590 * Probably not. I'll just give an error and return. */ | |
1591 /* The original patch sent the icon used by the launcher. That's probably wrong */ | |
1592 gaim_notify_error(NULL, NULL, _("Cannot send launcher"), _("You dragged a desktop launcher. " | |
1593 "Most likely you wanted to send whatever this launcher points to instead of this launcher" | |
1594 " itself.")); | |
1595 break; | |
1596 } | |
1597 gaim_desktop_item_unref(item); | |
1598 return; | |
1599 } | |
1600 #endif /* _WIN32 */ | |
1601 | |
1602 /* Everything is fine, let's send */ | |
1603 serv_send_file(gc, who, filename); | |
1604 g_free(filename); | |
1605 } | |
1606 g_list_free(files); | |
1607 } | |
10483 | 1608 |
1609 void gaim_gtk_buddy_icon_get_scale_size(GdkPixbuf *buf, GaimBuddyIconSpec *spec, int *width, int *height) | |
1610 { | |
1611 *width = gdk_pixbuf_get_width(buf); | |
1612 *height = gdk_pixbuf_get_height(buf); | |
1613 | |
1614 gaim_buddy_icon_get_scale_size(spec, width, height); | |
1615 | |
1616 /* and now for some arbitrary sanity checks */ | |
1617 if(*width > 100) | |
1618 *width = 100; | |
1619 if(*height > 100) | |
1620 *height = 100; | |
1621 } |