Mercurial > pidgin.yaz
annotate src/gtkutils.c @ 10197:7369bf2bf593
[gaim-migrate @ 11314]
More status fixes. Oscar kind of works... you can set yourself away,
invisible and available, but you can't choose the message for away,
can't choose an available message, and invisible only seems to work
the first time.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 17 Nov 2004 01:32:06 +0000 |
parents | 025e119f95f9 |
children | 9e0b98c458b1 |
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 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
45 #include "debug.h" |
7078 | 46 #include "imgstore.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
47 #include "notify.h" |
5548 | 48 #include "prefs.h" |
4359 | 49 #include "prpl.h" |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
50 #include "signals.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
51 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
52 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
53 #include "gtkconv.h" |
9709 | 54 #include "gtkdialogs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
55 #include "gtkimhtml.h" |
10175 | 56 #include "gtkimhtmltoolbar.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
57 #include "gtkutils.h" |
4359 | 58 |
7420 | 59 guint accels_save_timer = 0; |
60 | |
8913 | 61 static gboolean |
62 url_clicked_idle_cb(gpointer data) | |
63 { | |
64 gaim_notify_uri(NULL, data); | |
65 g_free(data); | |
66 return FALSE; | |
67 } | |
68 | |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
69 static void |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
70 url_clicked_cb(GtkWidget *w, const char *uri) |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
71 { |
8913 | 72 g_idle_add(url_clicked_idle_cb, g_strdup(uri)); |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
73 } |
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
74 |
8962 | 75 GtkIMHtmlFuncs gtkimhtml_cbs = { |
76 (GtkIMHtmlGetImageFunc)gaim_imgstore_get, | |
77 (GtkIMHtmlGetImageDataFunc)gaim_imgstore_get_data, | |
78 (GtkIMHtmlGetImageSizeFunc)gaim_imgstore_get_size, | |
79 (GtkIMHtmlGetImageFilenameFunc)gaim_imgstore_get_filename, | |
80 gaim_imgstore_ref, | |
81 gaim_imgstore_unref, | |
82 }; | |
83 | |
4359 | 84 void |
85 gaim_setup_imhtml(GtkWidget *imhtml) | |
86 { | |
87 g_return_if_fail(imhtml != NULL); | |
88 g_return_if_fail(GTK_IS_IMHTML(imhtml)); | |
89 | |
90 g_signal_connect(G_OBJECT(imhtml), "url_clicked", | |
6465
fb64cc87bc96
[gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents:
6430
diff
changeset
|
91 G_CALLBACK(url_clicked_cb), NULL); |
4359 | 92 |
93 smiley_themeize(imhtml); | |
8962 | 94 |
95 gtk_imhtml_set_funcs(GTK_IMHTML(imhtml), >kimhtml_cbs); | |
4359 | 96 } |
97 | |
10175 | 98 GtkWidget * |
99 gaim_gtk_create_imhtml(gboolean editable, GtkWidget **imhtml_ret, GtkWidget **toolbar_ret) | |
100 { | |
101 GtkWidget *frame; | |
102 GtkWidget *imhtml; | |
103 GtkWidget *sep; | |
104 GtkWidget *sw; | |
10177
82c1322c4b56
[gaim-migrate @ 11292]
Christian Hammond <chipx86@chipx86.com>
parents:
10175
diff
changeset
|
105 GtkWidget *toolbar = NULL; |
10175 | 106 GtkWidget *vbox; |
107 | |
108 frame = gtk_frame_new(NULL); | |
109 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); | |
110 | |
111 vbox = gtk_vbox_new(FALSE, 0); | |
112 gtk_container_add(GTK_CONTAINER(frame), vbox); | |
113 gtk_widget_show(vbox); | |
114 | |
115 if (editable) { | |
116 toolbar = gtk_imhtmltoolbar_new(); | |
117 gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0); | |
118 gtk_widget_show(toolbar); | |
119 | |
120 sep = gtk_hseparator_new(); | |
121 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); | |
122 gtk_widget_show(sep); | |
123 } | |
124 | |
125 /* | |
126 * We never show the horizontal scrollbar in editable imhtmls becuase | |
127 * it was causing weird lockups when typing text just as you type the | |
128 * character that would cause both scrollbars to appear. Definitely | |
129 * seems like a gtk bug to me. | |
130 */ | |
131 sw = gtk_scrolled_window_new(NULL, NULL); | |
132 if (editable) | |
133 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
134 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); | |
135 else | |
136 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
137 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); | |
138 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); | |
139 gtk_widget_show(sw); | |
140 | |
141 imhtml = gtk_imhtml_new(NULL, NULL); | |
142 gtk_imhtml_set_editable(GTK_IMHTML(imhtml), editable); | |
143 gtk_imhtml_set_format_functions(GTK_IMHTML(imhtml), GTK_IMHTML_ALL ^ GTK_IMHTML_IMAGE); | |
144 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(imhtml), GTK_WRAP_WORD_CHAR); | |
145 if (editable && gaim_prefs_get_bool("/gaim/gtk/conversations/spellcheck")) | |
146 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(imhtml)); | |
147 gtk_widget_show(imhtml); | |
148 | |
149 if (editable) { | |
150 gtk_imhtmltoolbar_attach(GTK_IMHTMLTOOLBAR(toolbar), imhtml); | |
151 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(toolbar), "default"); | |
152 } | |
153 gaim_setup_imhtml(imhtml); | |
154 | |
155 gtk_container_add(GTK_CONTAINER(sw), imhtml); | |
156 | |
157 if (imhtml_ret != NULL) | |
158 *imhtml_ret = imhtml; | |
159 | |
10181 | 160 if (editable && (toolbar_ret != NULL)) |
10175 | 161 *toolbar_ret = toolbar; |
162 | |
163 return frame; | |
164 } | |
165 | |
4359 | 166 void |
167 toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle) | |
168 { | |
169 gboolean sensitivity = GTK_WIDGET_IS_SENSITIVE(to_toggle); | |
170 | |
171 gtk_widget_set_sensitive(to_toggle, !sensitivity); | |
172 } | |
173 | |
7751 | 174 void |
175 gaim_gtk_set_sensitive_if_input(GtkWidget *entry, GtkWidget *dialog) | |
176 { | |
177 const char *text = gtk_entry_get_text(GTK_ENTRY(entry)); | |
178 gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK, | |
179 (*text != '\0')); | |
180 } | |
181 | |
4359 | 182 void |
183 gaim_gtk_toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle) | |
184 { | |
185 gboolean sensitivity; | |
186 | |
187 if (to_toggle == NULL) | |
188 return; | |
189 | |
190 sensitivity = GTK_WIDGET_IS_SENSITIVE(to_toggle); | |
191 | |
192 gtk_widget_set_sensitive(to_toggle, !sensitivity); | |
193 } | |
194 | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
195 void |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
196 gtk_toggle_sensitive_array(GtkWidget *w, GPtrArray *data) |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
197 { |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
198 gboolean sensitivity; |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
199 gpointer element; |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
200 int i; |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
201 |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
202 for (i=0; i < data->len; i++) { |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
203 element = g_ptr_array_index(data,i); |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
204 if (element == NULL) |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
205 continue; |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
206 |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
207 sensitivity = GTK_WIDGET_IS_SENSITIVE(element); |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
208 |
10175 | 209 gtk_widget_set_sensitive(element, !sensitivity); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
210 } |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
211 } |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
212 |
8901 | 213 void |
214 gaim_gtk_toggle_showhide(GtkWidget *widget, GtkWidget *to_toggle) | |
215 { | |
216 if (to_toggle == NULL) | |
217 return; | |
218 | |
219 if (GTK_WIDGET_VISIBLE(to_toggle)) | |
220 gtk_widget_hide(to_toggle); | |
221 else | |
222 gtk_widget_show(to_toggle); | |
223 } | |
224 | |
4687 | 225 void gaim_separator(GtkWidget *menu) |
226 { | |
227 GtkWidget *menuitem; | |
228 | |
229 menuitem = gtk_separator_menu_item_new(); | |
230 gtk_widget_show(menuitem); | |
231 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
232 } | |
5160 | 233 |
5162 | 234 GtkWidget *gaim_new_item(GtkWidget *menu, const char *str) |
235 { | |
236 GtkWidget *menuitem; | |
237 GtkWidget *label; | |
238 | |
239 menuitem = gtk_menu_item_new(); | |
240 if (menu) | |
241 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
242 gtk_widget_show(menuitem); | |
243 | |
244 label = gtk_label_new(str); | |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6236
diff
changeset
|
245 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
5162 | 246 gtk_label_set_pattern(GTK_LABEL(label), "_"); |
247 gtk_container_add(GTK_CONTAINER(menuitem), label); | |
248 gtk_widget_show(label); | |
249 /* FIXME: Go back and fix this | |
250 gtk_widget_add_accelerator(menuitem, "activate", accel, str[0], | |
251 GDK_MOD1_MASK, GTK_ACCEL_LOCKED); | |
252 */ | |
8137 | 253 gaim_set_accessible_label (menuitem, label); |
5162 | 254 return menuitem; |
255 } | |
256 | |
5906 | 257 GtkWidget *gaim_new_check_item(GtkWidget *menu, const char *str, |
258 GtkSignalFunc sf, gpointer data, gboolean checked) | |
259 { | |
260 GtkWidget *menuitem; | |
261 menuitem = gtk_check_menu_item_new_with_mnemonic(str); | |
262 | |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
263 if (menu) |
5906 | 264 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); |
265 | |
7299
2737c287f84d
[gaim-migrate @ 7883]
Christian Hammond <chipx86@chipx86.com>
parents:
7118
diff
changeset
|
266 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
|
267 |
5906 | 268 if (sf) |
269 g_signal_connect(G_OBJECT(menuitem), "activate", sf, data); | |
270 | |
271 gtk_widget_show_all(menuitem); | |
272 | |
273 return menuitem; | |
274 } | |
275 | |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
276 GtkWidget * |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
277 gaim_pixbuf_toolbar_button_from_stock(const char *icon) |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
278 { |
9706 | 279 GtkWidget *button, *image, *bbox; |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
280 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
281 button = gtk_toggle_button_new(); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
282 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
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 bbox = gtk_vbox_new(FALSE, 0); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
285 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
286 gtk_container_add (GTK_CONTAINER(button), bbox); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
287 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
288 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_MENU); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
289 gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0); |
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 gtk_widget_show_all(bbox); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
292 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
293 return button; |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
294 } |
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 GtkWidget * |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
297 gaim_pixbuf_button_from_stock(const char *text, const char *icon, |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
298 GaimButtonOrientation style) |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
299 { |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
300 GtkWidget *button, *image, *label, *bbox, *ibox, *lbox; |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
301 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
302 button = gtk_button_new(); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
303 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
304 if (style == GAIM_BUTTON_HORIZONTAL) { |
9750 | 305 bbox = gtk_hbox_new(FALSE, 0); |
306 ibox = gtk_hbox_new(FALSE, 0); | |
307 lbox = gtk_hbox_new(FALSE, 0); | |
308 } else { | |
309 bbox = gtk_vbox_new(FALSE, 0); | |
310 ibox = gtk_vbox_new(FALSE, 0); | |
311 lbox = gtk_vbox_new(FALSE, 0); | |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
312 } |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
313 |
9750 | 314 gtk_container_add(GTK_CONTAINER(button), bbox); |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
315 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
316 if (icon) { |
9750 | 317 gtk_box_pack_start_defaults(GTK_BOX(bbox), ibox); |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
318 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_BUTTON); |
9767 | 319 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
|
320 } |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
321 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
322 if (text) { |
9750 | 323 gtk_box_pack_start_defaults(GTK_BOX(bbox), lbox); |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
324 label = gtk_label_new(NULL); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
325 gtk_label_set_text_with_mnemonic(GTK_LABEL(label), text); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
326 gtk_label_set_mnemonic_widget(GTK_LABEL(label), button); |
9767 | 327 gtk_box_pack_start(GTK_BOX(lbox), label, FALSE, TRUE, 0); |
8137 | 328 gaim_set_accessible_label (button, label); |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
329 } |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
330 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
331 gtk_widget_show_all(bbox); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
332 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
333 return button; |
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 |
5160 | 337 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) |
338 { | |
339 GtkWidget *menuitem; | |
340 /* | |
341 GtkWidget *hbox; | |
342 GtkWidget *label; | |
343 */ | |
344 GtkWidget *image; | |
345 | |
346 if (icon == NULL) | |
347 menuitem = gtk_menu_item_new_with_mnemonic(str); | |
348 else | |
349 menuitem = gtk_image_menu_item_new_with_mnemonic(str); | |
350 | |
351 if (menu) | |
352 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
353 | |
354 if (sf) | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
355 g_signal_connect(G_OBJECT(menuitem), "activate", sf, data); |
5160 | 356 |
357 if (icon != NULL) { | |
358 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_MENU); | |
359 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); | |
360 } | |
361 /* FIXME: this isn't right | |
362 if (mod) { | |
363 label = gtk_label_new(mod); | |
364 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 2); | |
365 gtk_widget_show(label); | |
366 } | |
367 */ | |
368 /* | |
369 if (accel_key) { | |
370 gtk_widget_add_accelerator(menuitem, "activate", accel, accel_key, | |
371 accel_mods, GTK_ACCEL_LOCKED); | |
372 } | |
373 */ | |
374 | |
375 gtk_widget_show_all(menuitem); | |
376 | |
377 return menuitem; | |
378 } | |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
379 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
380 GtkWidget * |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
381 gaim_gtk_make_frame(GtkWidget *parent, const char *title) |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
382 { |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
383 GtkWidget *vbox, *label, *hbox; |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
384 char labeltitle[256]; |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
385 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
386 vbox = gtk_vbox_new(FALSE, 6); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
387 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
|
388 gtk_widget_show(vbox); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
389 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
390 label = gtk_label_new(NULL); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
391 g_snprintf(labeltitle, sizeof(labeltitle), |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
392 "<span weight=\"bold\">%s</span>", title); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
393 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
394 gtk_label_set_markup(GTK_LABEL(label), labeltitle); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
395 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
396 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
|
397 gtk_widget_show(label); |
8137 | 398 gaim_set_accessible_label (vbox, label); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
399 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
400 hbox = gtk_hbox_new(FALSE, 6); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
401 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
|
402 gtk_widget_show(hbox); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
403 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
404 label = gtk_label_new(" "); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
405 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
|
406 gtk_widget_show(label); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
407 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
408 vbox = gtk_vbox_new(FALSE, 6); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
409 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
|
410 gtk_widget_show(vbox); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
411 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
412 return vbox; |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
413 } |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
414 |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
415 static void |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
416 protocol_menu_cb(GtkWidget *optmenu, GCallback cb) |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
417 { |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
418 GtkWidget *menu; |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
419 GtkWidget *item; |
7956 | 420 const char *protocol; |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
421 gpointer user_data; |
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 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
424 item = gtk_menu_get_active(GTK_MENU(menu)); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
425 |
7956 | 426 protocol = g_object_get_data(G_OBJECT(item), "protocol"); |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
427 user_data = (g_object_get_data(G_OBJECT(optmenu), "user_data")); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
428 |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
429 if (cb != NULL) |
7956 | 430 ((void (*)(GtkWidget *, const char *, gpointer))cb)(item, protocol, |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
431 user_data); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
432 } |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
433 |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
434 GtkWidget * |
7956 | 435 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
|
436 gpointer user_data) |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
437 { |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
438 GaimPluginProtocolInfo *prpl_info; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
439 GaimPlugin *plugin; |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
440 GtkWidget *hbox; |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
441 GtkWidget *label; |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
442 GtkWidget *optmenu; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
443 GtkWidget *menu; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
444 GtkWidget *item; |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
445 GtkWidget *image; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
446 GdkPixbuf *pixbuf; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
447 GdkPixbuf *scale; |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
448 GList *p; |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
449 GtkSizeGroup *sg; |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
450 char *filename; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
451 const char *proto_name; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
452 char buf[256]; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
453 int i, selected_index = -1; |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
454 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
455 optmenu = gtk_option_menu_new(); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
456 gtk_widget_show(optmenu); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
457 |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
458 g_object_set_data(G_OBJECT(optmenu), "user_data", user_data); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
459 |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
460 menu = gtk_menu_new(); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
461 gtk_widget_show(menu); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
462 |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
463 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
464 |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
465 for (p = gaim_plugins_get_protocols(), i = 0; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
466 p != NULL; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
467 p = p->next, i++) { |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
468 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
469 plugin = (GaimPlugin *)p->data; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
470 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
471 |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
472 /* Create the item. */ |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
473 item = gtk_menu_item_new(); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
474 |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
475 /* Create the hbox. */ |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
476 hbox = gtk_hbox_new(FALSE, 4); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
477 gtk_container_add(GTK_CONTAINER(item), hbox); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
478 gtk_widget_show(hbox); |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
479 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
480 /* Load the image. */ |
6430 | 481 proto_name = prpl_info->list_icon(NULL, NULL); |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
482 g_snprintf(buf, sizeof(buf), "%s.png", proto_name); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
483 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
484 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
485 "default", buf, NULL); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
486 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
487 g_free(filename); |
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 if (pixbuf != NULL) { |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
490 /* Scale and insert the image */ |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
491 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
492 GDK_INTERP_BILINEAR); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
493 image = gtk_image_new_from_pixbuf(scale); |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
494 |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
495 g_object_unref(G_OBJECT(pixbuf)); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
496 g_object_unref(G_OBJECT(scale)); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
497 } |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
498 else |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
499 image = gtk_image_new(); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
500 |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
501 gtk_size_group_add_widget(sg, image); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
502 |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
503 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
504 gtk_widget_show(image); |
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 /* Create the label. */ |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
507 label = gtk_label_new(plugin->info->name); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
508 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
509 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
510 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
511 gtk_widget_show(label); |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
512 |
7956 | 513 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
|
514 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
515 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
516 gtk_widget_show(item); |
8137 | 517 gaim_set_accessible_label (item, label); |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
518 |
8218
4beaf6b35483
[gaim-migrate @ 8941]
Christian Hammond <chipx86@chipx86.com>
parents:
8215
diff
changeset
|
519 if (id != NULL && !strcmp(plugin->info->id, id)) |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
520 selected_index = i; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
521 } |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
522 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
523 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
524 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
525 if (selected_index != -1) |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
526 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), selected_index); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
527 |
5688
e43e1b8dca8b
[gaim-migrate @ 6109]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
528 g_signal_connect(G_OBJECT(optmenu), "changed", |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
529 G_CALLBACK(protocol_menu_cb), cb); |
5688
e43e1b8dca8b
[gaim-migrate @ 6109]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
530 |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
531 g_object_unref(sg); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
532 |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
533 return optmenu; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
534 } |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
535 |
8940 | 536 GaimAccount * |
537 gaim_gtk_account_option_menu_get_selected(GtkWidget *optmenu) | |
538 { | |
539 GtkWidget *menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); | |
540 GtkWidget *item = gtk_menu_get_active(GTK_MENU(menu)); | |
541 return g_object_get_data(G_OBJECT(item), "account"); | |
542 } | |
543 | |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
544 static void |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
545 account_menu_cb(GtkWidget *optmenu, GCallback cb) |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
546 { |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
547 GtkWidget *menu; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
548 GtkWidget *item; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
549 GaimAccount *account; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
550 gpointer user_data; |
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 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
553 item = gtk_menu_get_active(GTK_MENU(menu)); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
554 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
555 account = g_object_get_data(G_OBJECT(item), "account"); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
556 user_data = g_object_get_data(G_OBJECT(optmenu), "user_data"); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
557 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
558 if (cb != NULL) |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
559 ((void (*)(GtkWidget *, GaimAccount *, gpointer))cb)(item, account, |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
560 user_data); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
561 } |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
562 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
563 static void |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
564 create_account_menu(GtkWidget *optmenu, GaimAccount *default_account, |
8289
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
565 GaimFilterAccountFunc filter_func, gboolean show_all) |
5877
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 GaimAccount *account; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
568 GtkWidget *menu; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
569 GtkWidget *item; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
570 GtkWidget *image; |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
571 GtkWidget *hbox; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
572 GtkWidget *label; |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
573 GdkPixbuf *pixbuf; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
574 GdkPixbuf *scale; |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
575 GList *list; |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
576 GList *p; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
577 GtkSizeGroup *sg; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
578 char *filename; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
579 const char *proto_name; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
580 char buf[256]; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
581 int i, selected_index = -1; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
582 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
583 if (show_all) |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
584 list = gaim_accounts_get_all(); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
585 else |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
586 list = gaim_connections_get_all(); |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
587 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
588 menu = gtk_menu_new(); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
589 gtk_widget_show(menu); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
590 |
5880
1b85ff65be57
[gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
591 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
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 for (p = list, i = 0; p != NULL; p = p->next, i++) { |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
594 GaimPluginProtocolInfo *prpl_info = NULL; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
595 GaimPlugin *plugin; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
596 |
5879
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
597 if (show_all) |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
598 account = (GaimAccount *)p->data; |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
599 else { |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
600 GaimConnection *gc = (GaimConnection *)p->data; |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
601 |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
602 account = gaim_connection_get_account(gc); |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
603 } |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
604 |
8289
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
605 if (filter_func && !filter_func(account)) { |
8215 | 606 i--; |
6646
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
607 continue; |
8215 | 608 } |
6646
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
609 |
7956 | 610 plugin = gaim_find_prpl(gaim_account_get_protocol_id(account)); |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
611 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
612 if (plugin != NULL) |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
613 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
614 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
615 /* Create the item. */ |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
616 item = gtk_menu_item_new(); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
617 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
618 /* Create the hbox. */ |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
619 hbox = gtk_hbox_new(FALSE, 4); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
620 gtk_container_add(GTK_CONTAINER(item), hbox); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
621 gtk_widget_show(hbox); |
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 /* Load the image. */ |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
624 if (prpl_info != NULL) { |
6430 | 625 proto_name = prpl_info->list_icon(account, NULL); |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
626 g_snprintf(buf, sizeof(buf), "%s.png", proto_name); |
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 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
629 "default", buf, NULL); |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
630 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
631 g_free(filename); |
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 if (pixbuf != NULL) { |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
634 /* Scale and insert the image */ |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
635 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
636 GDK_INTERP_BILINEAR); |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
637 |
8215 | 638 if (!gaim_account_is_connected(account) && show_all && |
639 gaim_connections_get_all()) | |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
640 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE); |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
641 |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
642 image = gtk_image_new_from_pixbuf(scale); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
643 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
644 g_object_unref(G_OBJECT(pixbuf)); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
645 g_object_unref(G_OBJECT(scale)); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
646 } |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
647 else |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
648 image = gtk_image_new(); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
649 } |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
650 else |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
651 image = gtk_image_new(); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
652 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
653 gtk_size_group_add_widget(sg, image); |
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 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
656 gtk_widget_show(image); |
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 g_snprintf(buf, sizeof(buf), "%s (%s)", |
9899 | 659 gaim_account_get_username(account), |
660 gaim_account_get_protocol_name(account)); | |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
661 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
662 /* Create the label. */ |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
663 label = gtk_label_new(buf); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
664 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
665 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
666 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
667 gtk_widget_show(label); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
668 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
669 g_object_set_data(G_OBJECT(item), "account", account); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
670 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
671 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
672 gtk_widget_show(item); |
8137 | 673 gaim_set_accessible_label (item, label); |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
674 |
5880
1b85ff65be57
[gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
675 if (default_account != NULL && account == default_account) |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
676 selected_index = i; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
677 } |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
678 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
679 g_object_unref(sg); |
5880
1b85ff65be57
[gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
680 |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
681 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
682 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
683 /* Set the place we should be at. */ |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
684 if (selected_index != -1) |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
685 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
|
686 } |
5877
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 static void |
8134 | 689 regenerate_account_menu(GtkWidget *optmenu) |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
690 { |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
691 GtkWidget *menu; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
692 GtkWidget *item; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
693 gboolean show_all; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
694 GaimAccount *account; |
8289
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
695 GaimFilterAccountFunc filter_func; |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
696 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
697 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
698 item = gtk_menu_get_active(GTK_MENU(menu)); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
699 account = g_object_get_data(G_OBJECT(item), "account"); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
700 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
701 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
|
702 "show_all")); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
703 |
8289
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
704 filter_func = g_object_get_data(G_OBJECT(optmenu), |
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
705 "filter_func"); |
6646
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
706 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
707 gtk_option_menu_remove_menu(GTK_OPTION_MENU(optmenu)); |
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 create_account_menu(optmenu, account, filter_func, show_all); |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
710 } |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
711 |
8134 | 712 static void |
713 account_menu_sign_on_off_cb(GaimConnection *gc, GtkWidget *optmenu) | |
714 { | |
715 regenerate_account_menu(optmenu); | |
716 } | |
717 | |
718 static void | |
719 account_menu_added_removed_cb(GaimAccount *account, GtkWidget *optmenu) | |
720 { | |
721 regenerate_account_menu(optmenu); | |
722 } | |
723 | |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
724 static gboolean |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
725 account_menu_destroyed_cb(GtkWidget *optmenu, GdkEvent *event, |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
726 void *user_data) |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
727 { |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
728 gaim_signals_disconnect_by_handle(optmenu); |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
729 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
730 return FALSE; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
731 } |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
732 |
9910 | 733 void |
734 gaim_gtk_account_option_menu_set_selected(GtkWidget *optmenu, GaimAccount *account) | |
735 { | |
736 GtkWidget *menu; | |
737 GtkWidget *item; | |
738 gboolean show_all; | |
739 GaimAccount *curaccount; | |
740 GaimFilterAccountFunc filter_func; | |
741 | |
742 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); | |
743 item = gtk_menu_get_active(GTK_MENU(menu)); | |
744 curaccount = g_object_get_data(G_OBJECT(item), "account"); | |
745 | |
746 if (account == curaccount) | |
747 return; | |
748 | |
749 show_all = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(optmenu), | |
750 "show_all")); | |
751 | |
752 filter_func = g_object_get_data(G_OBJECT(optmenu), | |
753 "filter_func"); | |
754 | |
755 gtk_option_menu_remove_menu(GTK_OPTION_MENU(optmenu)); | |
756 | |
757 create_account_menu(optmenu, account, filter_func, show_all); | |
758 } | |
759 | |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
760 GtkWidget * |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
761 gaim_gtk_account_option_menu_new(GaimAccount *default_account, |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
762 gboolean show_all, GCallback cb, |
8289
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
763 GaimFilterAccountFunc filter_func, |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
764 gpointer user_data) |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
765 { |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
766 GtkWidget *optmenu; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
767 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
768 /* Create the option menu */ |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
769 optmenu = gtk_option_menu_new(); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
770 gtk_widget_show(optmenu); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
771 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
772 g_signal_connect(G_OBJECT(optmenu), "destroy", |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
773 G_CALLBACK(account_menu_destroyed_cb), NULL); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
774 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
775 /* Register the gaim sign on/off event callbacks. */ |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
776 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
777 optmenu, GAIM_CALLBACK(account_menu_sign_on_off_cb), |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
778 optmenu); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
779 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
780 optmenu, GAIM_CALLBACK(account_menu_sign_on_off_cb), |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
781 optmenu); |
8134 | 782 gaim_signal_connect(gaim_accounts_get_handle(), "account-added", |
783 optmenu, GAIM_CALLBACK(account_menu_added_removed_cb), | |
784 optmenu); | |
785 gaim_signal_connect(gaim_accounts_get_handle(), "account-removed", | |
786 optmenu, GAIM_CALLBACK(account_menu_added_removed_cb), | |
787 optmenu); | |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
788 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
789 /* Set some data. */ |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
790 g_object_set_data(G_OBJECT(optmenu), "user_data", user_data); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
791 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
|
792 g_object_set_data(G_OBJECT(optmenu), "filter_func", |
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
793 filter_func); |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
794 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
795 /* Create and set the actual menu. */ |
8289
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
796 create_account_menu(optmenu, default_account, filter_func, show_all); |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
797 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
798 /* And now the last callback. */ |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
799 g_signal_connect(G_OBJECT(optmenu), "changed", |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
800 G_CALLBACK(account_menu_cb), cb); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
801 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
802 return optmenu; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
803 } |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
804 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
805 gboolean |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
806 gaim_gtk_check_if_dir(const char *path, GtkFileSelection *filesel) |
5966 | 807 { |
5967 | 808 char *dirname; |
5966 | 809 |
5967 | 810 if (g_file_test(path, G_FILE_TEST_IS_DIR)) { |
5966 | 811 /* append a / if needed */ |
9534 | 812 if (path[strlen(path) - 1] != G_DIR_SEPARATOR) { |
813 dirname = g_strconcat(path, G_DIR_SEPARATOR_S, NULL); | |
5966 | 814 } else { |
5967 | 815 dirname = g_strdup(path); |
5966 | 816 } |
5967 | 817 gtk_file_selection_set_filename(filesel, dirname); |
818 g_free(dirname); | |
5966 | 819 return TRUE; |
820 } | |
821 | |
822 return FALSE; | |
823 } | |
824 | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
825 char *stylize(const gchar *text, int length) |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
826 { |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
827 gchar *buf; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
828 char *tmp = g_malloc(length); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
829 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
830 buf = g_malloc(length); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
831 g_snprintf(buf, length, "%s", text); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
832 |
9025 | 833 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_formatting")) { |
834 const char *font; | |
835 GdkColor fg_color, bg_color; | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
836 |
9025 | 837 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold")) { |
838 g_snprintf(tmp, length, "<B>%s</B>", buf); | |
839 strcpy(buf, tmp); | |
840 } | |
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_italic")) { |
843 g_snprintf(tmp, length, "<I>%s</I>", 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_underline")) { |
848 g_snprintf(tmp, length, "<U>%s</U>", buf); | |
849 strcpy(buf, tmp); | |
850 } | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
851 |
9025 | 852 font = gaim_prefs_get_string("/gaim/gtk/conversations/font_face"); |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
853 |
9025 | 854 if (strcmp(font, "") != 0) { |
855 g_snprintf(tmp, length, "<FONT FACE=\"%s\">%s</FONT>", font, buf); | |
856 strcpy(buf, tmp); | |
857 } | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
858 |
9025 | 859 g_snprintf(tmp, length, "<FONT SIZE=\"%d\">%s</FONT>", |
860 gaim_prefs_get_int("/gaim/gtk/conversations/font_size"), buf); | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
861 strcpy(buf, tmp); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
862 |
9025 | 863 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), "") != 0) |
864 { | |
865 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), | |
866 &fg_color); | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
867 |
9025 | 868 g_snprintf(tmp, length, "<FONT COLOR=\"#%02X%02X%02X\">%s</FONT>", |
869 fg_color.red/256, fg_color.green/256, | |
870 fg_color.blue/256, buf); | |
871 strcpy(buf, tmp); | |
872 } | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
873 |
9025 | 874 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) |
875 { | |
876 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), | |
877 &bg_color); | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
878 |
9025 | 879 g_snprintf(tmp, length, "<BODY BGCOLOR=\"#%02X%02X%02X\">%s</BODY>", |
880 bg_color.red/256, bg_color.green/256, | |
881 bg_color.blue/256, buf); | |
882 strcpy(buf, tmp); | |
883 } | |
884 | |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
885 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
886 |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
887 g_free(tmp); |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
888 return buf; |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
889 } |
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
890 |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
891 void |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
892 gaim_gtk_setup_gtkspell(GtkTextView *textview) |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
893 { |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
894 #ifdef USE_GTKSPELL |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
895 GError *error = NULL; |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
896 char *locale = NULL; |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
897 |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
898 g_return_if_fail(textview != NULL); |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
899 g_return_if_fail(GTK_IS_TEXT_VIEW(textview)); |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
900 |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
901 if (gtkspell_new_attach(textview, locale, &error) == NULL && error) |
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 gaim_debug_warning("gtkspell", "Failed to setup GtkSpell: %s\n", |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
904 error->message); |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
905 g_error_free(error); |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
906 } |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
907 #endif /* USE_GTKSPELL */ |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
908 } |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
909 |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
910 void |
7420 | 911 gaim_gtk_save_accels_cb(GtkAccelGroup *accel_group, guint arg1, |
912 GdkModifierType arg2, GClosure *arg3, | |
913 gpointer data) | |
914 { | |
915 gaim_debug(GAIM_DEBUG_MISC, "accels", "accel changed, scheduling save.\n"); | |
916 | |
917 if (!accels_save_timer) | |
918 accels_save_timer = g_timeout_add(5000, gaim_gtk_save_accels, NULL); | |
919 } | |
920 | |
921 gboolean | |
922 gaim_gtk_save_accels(gpointer data) | |
923 { | |
924 char *filename = NULL; | |
925 | |
926 filename = g_build_filename(gaim_user_dir(), G_DIR_SEPARATOR_S, | |
927 "accels", NULL); | |
928 gaim_debug(GAIM_DEBUG_MISC, "accels", "saving accels to %s\n", filename); | |
929 gtk_accel_map_save(filename); | |
930 g_free(filename); | |
931 | |
932 accels_save_timer = 0; | |
933 return FALSE; | |
934 } | |
935 | |
936 void | |
937 gaim_gtk_load_accels(gpointer data) | |
938 { | |
939 char *filename = NULL; | |
940 | |
941 filename = g_build_filename(gaim_user_dir(), G_DIR_SEPARATOR_S, | |
942 "accels", NULL); | |
943 gtk_accel_map_load(filename); | |
944 g_free(filename); | |
945 } | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
946 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
947 gboolean |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
948 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
|
949 GaimAccount **ret_account, char **ret_protocol, |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
950 char **ret_username, char **ret_alias) |
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 char *protocol = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
953 char *username = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
954 char *alias = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
955 char *str; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
956 char *c, *s; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
957 gboolean valid; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
958 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
959 g_return_val_if_fail(msg != NULL, FALSE); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
960 g_return_val_if_fail(ret_protocol != NULL, FALSE); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
961 g_return_val_if_fail(ret_username != NULL, FALSE); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
962 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
963 s = str = g_strdup(msg); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
964 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
965 while (*s != '\r' && *s != '\n' && *s != '\0') |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
966 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
967 char *key, *value; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
968 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
969 key = s; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
970 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
971 /* Grab the key */ |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
972 while (*s != '\r' && *s != '\n' && *s != '\0' && *s != ' ') |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
973 s++; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
974 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
975 if (*s == '\r') s++; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
976 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
977 if (*s == '\n') |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
978 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
979 s++; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
980 continue; |
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 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
983 if (*s != '\0') *s++ = '\0'; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
984 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
985 /* Clear past any whitespace */ |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
986 while (*s != '\0' && *s == ' ') |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
987 s++; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
988 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
989 /* Now let's grab until the end of the line. */ |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
990 value = s; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
991 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
992 while (*s != '\r' && *s != '\n' && *s != '\0') |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
993 s++; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
994 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
995 if (*s == '\r') *s++ = '\0'; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
996 if (*s == '\n') *s++ = '\0'; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
997 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
998 if ((c = strchr(key, ':')) != NULL) |
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 (!g_ascii_strcasecmp(key, "X-IM-Username:")) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1001 username = g_strdup(value); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1002 else if (!g_ascii_strcasecmp(key, "X-IM-Protocol:")) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1003 protocol = g_strdup(value); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1004 else if (!g_ascii_strcasecmp(key, "X-IM-Alias:")) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1005 alias = g_strdup(value); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1006 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1007 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1008 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1009 if (username != NULL && protocol != NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1010 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1011 valid = TRUE; |
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 *ret_username = username; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1014 *ret_protocol = protocol; |
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 if (ret_alias != NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1017 *ret_alias = alias; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1018 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1019 /* Check for a compatible account. */ |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1020 if (ret_account != NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1021 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1022 GList *list; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1023 GaimAccount *account = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1024 GList *l; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1025 const char *protoname; |
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 if (all_accounts) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1028 list = gaim_accounts_get_all(); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1029 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1030 list = gaim_connections_get_all(); |
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 for (l = list; l != NULL; l = l->next) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1033 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1034 GaimConnection *gc; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1035 GaimPluginProtocolInfo *prpl_info = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1036 GaimPlugin *plugin; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1037 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1038 if (all_accounts) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1039 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1040 account = (GaimAccount *)l->data; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1041 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1042 plugin = gaim_plugins_find_with_id( |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1043 gaim_account_get_protocol_id(account)); |
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 if (plugin == NULL) |
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 account = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1048 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1049 continue; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1050 } |
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 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); |
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 else |
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 gc = (GaimConnection *)l->data; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1057 account = gaim_connection_get_account(gc); |
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 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
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 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1062 protoname = prpl_info->list_icon(account, NULL); |
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 if (!strcmp(protoname, protocol)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1065 break; |
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 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 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1070 /* Special case for AIM and ICQ */ |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1071 if (account == NULL && (!strcmp(protocol, "aim") || |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1072 !strcmp(protocol, "icq"))) |
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 for (l = list; l != NULL; l = l->next) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1075 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1076 GaimConnection *gc; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1077 GaimPluginProtocolInfo *prpl_info = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1078 GaimPlugin *plugin; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1079 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1080 if (all_accounts) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1081 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1082 account = (GaimAccount *)l->data; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1083 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1084 plugin = gaim_plugins_find_with_id( |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1085 gaim_account_get_protocol_id(account)); |
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 if (plugin == NULL) |
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 account = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1090 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1091 continue; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1092 } |
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 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); |
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 else |
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 gc = (GaimConnection *)l->data; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1099 account = gaim_connection_get_account(gc); |
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 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
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 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1104 protoname = prpl_info->list_icon(account, NULL); |
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 if (!strcmp(protoname, "aim") || !strcmp(protoname, "icq")) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1107 break; |
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 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 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1112 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1113 *ret_account = account; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1114 } |
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 else |
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 valid = FALSE; |
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 if (username != NULL) g_free(username); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1121 if (protocol != NULL) g_free(protocol); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1122 if (alias != NULL) g_free(alias); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1123 } |
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 g_free(str); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1126 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1127 return valid; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1128 } |
8137 | 1129 |
1130 void | |
1131 gaim_set_accessible_label (GtkWidget *w, GtkWidget *l) | |
1132 { | |
1133 AtkObject *acc, *label; | |
1134 AtkObject *rel_obj[1]; | |
1135 AtkRelationSet *set; | |
1136 AtkRelation *relation; | |
1137 const gchar *label_text; | |
1138 const gchar *existing_name; | |
1139 | |
1140 acc = gtk_widget_get_accessible (w); | |
1141 label = gtk_widget_get_accessible (l); | |
1142 | |
1143 /* If this object has no name, set it's name with the label text */ | |
1144 existing_name = atk_object_get_name (acc); | |
1145 if (!existing_name) { | |
1146 label_text = gtk_label_get_text (GTK_LABEL(l)); | |
1147 if (label_text) | |
1148 atk_object_set_name (acc, label_text); | |
1149 } | |
1150 | |
1151 /* Create the labeled-by relation */ | |
1152 set = atk_object_ref_relation_set (acc); | |
1153 rel_obj[0] = label; | |
1154 relation = atk_relation_new (rel_obj, 1, ATK_RELATION_LABELLED_BY); | |
1155 atk_relation_set_add (set, relation); | |
1156 g_object_unref (relation); | |
1157 | |
1158 /* Create the label-for relation */ | |
1159 set = atk_object_ref_relation_set (label); | |
1160 rel_obj[0] = acc; | |
1161 relation = atk_relation_new (rel_obj, 1, ATK_RELATION_LABEL_FOR); | |
1162 atk_relation_set_add (set, relation); | |
1163 g_object_unref (relation); | |
1164 } | |
8143 | 1165 |
8247 | 1166 #if GTK_CHECK_VERSION(2,2,0) |
8143 | 1167 static void |
1168 gaim_gtk_menu_position_func(GtkMenu *menu, | |
1169 gint *x, | |
1170 gint *y, | |
1171 gboolean *push_in, | |
1172 gpointer data) | |
1173 { | |
1174 GtkWidget *widget; | |
1175 GtkRequisition requisition; | |
1176 GdkScreen *screen; | |
1177 GdkRectangle monitor; | |
1178 gint monitor_num; | |
1179 gint space_left, space_right, space_above, space_below; | |
1180 gint needed_width; | |
1181 gint needed_height; | |
1182 gint xthickness; | |
1183 gint ythickness; | |
1184 gboolean rtl; | |
1185 | |
1186 g_return_if_fail(GTK_IS_MENU(menu)); | |
1187 | |
1188 widget = GTK_WIDGET(menu); | |
1189 screen = gtk_widget_get_screen(widget); | |
1190 xthickness = widget->style->xthickness; | |
1191 ythickness = widget->style->ythickness; | |
1192 rtl = (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL); | |
1193 | |
1194 /* | |
1195 * We need the requisition to figure out the right place to | |
1196 * popup the menu. In fact, we always need to ask here, since | |
1197 * if a size_request was queued while we weren't popped up, | |
1198 * the requisition won't have been recomputed yet. | |
1199 */ | |
1200 gtk_widget_size_request (widget, &requisition); | |
1201 | |
1202 monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y); | |
1203 | |
1204 push_in = FALSE; | |
1205 | |
1206 /* | |
1207 * The placement of popup menus horizontally works like this (with | |
1208 * RTL in parentheses) | |
1209 * | |
1210 * - If there is enough room to the right (left) of the mouse cursor, | |
1211 * position the menu there. | |
1212 * | |
1213 * - Otherwise, if if there is enough room to the left (right) of the | |
1214 * mouse cursor, position the menu there. | |
1215 * | |
1216 * - Otherwise if the menu is smaller than the monitor, position it | |
1217 * on the side of the mouse cursor that has the most space available | |
1218 * | |
1219 * - Otherwise (if there is simply not enough room for the menu on the | |
1220 * monitor), position it as far left (right) as possible. | |
1221 * | |
1222 * Positioning in the vertical direction is similar: first try below | |
1223 * mouse cursor, then above. | |
1224 */ | |
1225 gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); | |
1226 | |
1227 space_left = *x - monitor.x; | |
1228 space_right = monitor.x + monitor.width - *x - 1; | |
1229 space_above = *y - monitor.y; | |
1230 space_below = monitor.y + monitor.height - *y - 1; | |
1231 | |
1232 /* position horizontally */ | |
1233 | |
1234 /* the amount of space we need to position the menu. Note the | |
1235 * menu is offset "xthickness" pixels | |
1236 */ | |
1237 needed_width = requisition.width - xthickness; | |
1238 | |
1239 if (needed_width <= space_left || | |
1240 needed_width <= space_right) | |
1241 { | |
1242 if ((rtl && needed_width <= space_left) || | |
1243 (!rtl && needed_width > space_right)) | |
1244 { | |
1245 /* position left */ | |
1246 *x = *x + xthickness - requisition.width + 1; | |
1247 } | |
1248 else | |
1249 { | |
1250 /* position right */ | |
1251 *x = *x - xthickness; | |
1252 } | |
1253 | |
1254 /* x is clamped on-screen further down */ | |
1255 } | |
1256 else if (requisition.width <= monitor.width) | |
1257 { | |
1258 /* the menu is too big to fit on either side of the mouse | |
1259 * cursor, but smaller than the monitor. Position it on | |
1260 * the side that has the most space | |
1261 */ | |
1262 if (space_left > space_right) | |
1263 { | |
1264 /* left justify */ | |
1265 *x = monitor.x; | |
1266 } | |
1267 else | |
1268 { | |
1269 /* right justify */ | |
1270 *x = monitor.x + monitor.width - requisition.width; | |
1271 } | |
1272 } | |
1273 else /* menu is simply too big for the monitor */ | |
1274 { | |
1275 if (rtl) | |
1276 { | |
1277 /* right justify */ | |
1278 *x = monitor.x + monitor.width - requisition.width; | |
1279 } | |
1280 else | |
1281 { | |
1282 /* left justify */ | |
1283 *x = monitor.x; | |
1284 } | |
1285 } | |
1286 | |
1287 /* Position vertically. The algorithm is the same as above, but | |
1288 * simpler because we don't have to take RTL into account. | |
1289 */ | |
1290 needed_height = requisition.height - ythickness; | |
1291 | |
1292 if (needed_height <= space_above || | |
1293 needed_height <= space_below) | |
1294 { | |
1295 if (needed_height <= space_below) | |
1296 *y = *y - ythickness; | |
1297 else | |
1298 *y = *y + ythickness - requisition.height + 1; | |
10061 | 1299 |
8143 | 1300 *y = CLAMP (*y, monitor.y, |
1301 monitor.y + monitor.height - requisition.height); | |
1302 } | |
1303 else if (needed_height > space_below && needed_height > space_above) | |
1304 { | |
1305 if (space_below >= space_above) | |
1306 *y = monitor.y + monitor.height - requisition.height; | |
1307 else | |
1308 *y = monitor.y; | |
1309 } | |
1310 else | |
1311 { | |
1312 *y = monitor.y; | |
1313 } | |
1314 } | |
1315 | |
8247 | 1316 #endif |
1317 | |
8143 | 1318 void |
1319 gaim_gtk_treeview_popup_menu_position_func(GtkMenu *menu, | |
1320 gint *x, | |
1321 gint *y, | |
1322 gboolean *push_in, | |
1323 gpointer data) | |
1324 { | |
1325 GtkWidget *widget = GTK_WIDGET(data); | |
1326 GtkTreeView *tv = GTK_TREE_VIEW(data); | |
1327 GtkTreePath *path; | |
1328 GtkTreeViewColumn *col; | |
1329 GdkRectangle rect; | |
1330 gint ythickness = GTK_WIDGET(menu)->style->ythickness; | |
1331 | |
1332 gdk_window_get_origin (widget->window, x, y); | |
1333 gtk_tree_view_get_cursor (tv, &path, &col); | |
1334 gtk_tree_view_get_cell_area (tv, path, col, &rect); | |
8218
4beaf6b35483
[gaim-migrate @ 8941]
Christian Hammond <chipx86@chipx86.com>
parents:
8215
diff
changeset
|
1335 |
8143 | 1336 *x += rect.x+rect.width; |
1337 *y += rect.y+rect.height+ythickness; | |
8247 | 1338 #if GTK_CHECK_VERSION(2,2,0) |
8143 | 1339 gaim_gtk_menu_position_func (menu, x, y, push_in, data); |
8247 | 1340 #endif |
8143 | 1341 } |
10061 | 1342 |
1343 gboolean | |
1344 gaim_running_gnome(void) | |
1345 { | |
1346 if ((g_getenv("GNOME_DESKTOP_SESSION_ID") != NULL) && | |
1347 (g_find_program_in_path("gnome-open") != NULL)) | |
1348 { | |
1349 return TRUE; | |
1350 } | |
1351 | |
1352 return FALSE; | |
1353 } |