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