Mercurial > pidgin
annotate src/gtkutils.c @ 14189:789d80a6b9d9
[gaim-migrate @ 16853]
Have substatuses for custom statuses.
This is probably the last dialog/feature before the end of SoC. I plan to add stuff for roomlists later (next week), and possibly start on replacing pluginpref with request.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 19 Aug 2006 00:07:40 +0000 |
parents | 92f5e6f3acfb |
children |
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 * |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13202
diff
changeset
|
104 gaim_gtk_create_imhtml(gboolean editable, GtkWidget **imhtml_ret, GtkWidget **toolbar_ret, GtkWidget **sw_ret) |
10175 | 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 | |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13202
diff
changeset
|
160 if (sw_ret != NULL) |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13202
diff
changeset
|
161 *sw_ret = sw; |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13202
diff
changeset
|
162 |
10175 | 163 return frame; |
164 } | |
165 | |
4359 | 166 void |
7751 | 167 gaim_gtk_set_sensitive_if_input(GtkWidget *entry, GtkWidget *dialog) |
168 { | |
169 const char *text = gtk_entry_get_text(GTK_ENTRY(entry)); | |
170 gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK, | |
171 (*text != '\0')); | |
172 } | |
173 | |
4359 | 174 void |
175 gaim_gtk_toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle) | |
176 { | |
177 gboolean sensitivity; | |
178 | |
179 if (to_toggle == NULL) | |
180 return; | |
181 | |
182 sensitivity = GTK_WIDGET_IS_SENSITIVE(to_toggle); | |
183 | |
184 gtk_widget_set_sensitive(to_toggle, !sensitivity); | |
185 } | |
186 | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
187 void |
10590
896efbdc74e2
[gaim-migrate @ 11995]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10566
diff
changeset
|
188 gaim_gtk_toggle_sensitive_array(GtkWidget *w, GPtrArray *data) |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
189 { |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
190 gboolean sensitivity; |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
191 gpointer element; |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
192 int i; |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
193 |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
194 for (i=0; i < data->len; i++) { |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
195 element = g_ptr_array_index(data,i); |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
196 if (element == NULL) |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
197 continue; |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
198 |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
199 sensitivity = GTK_WIDGET_IS_SENSITIVE(element); |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
200 |
10175 | 201 gtk_widget_set_sensitive(element, !sensitivity); |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
202 } |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
203 } |
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
204 |
8901 | 205 void |
206 gaim_gtk_toggle_showhide(GtkWidget *widget, GtkWidget *to_toggle) | |
207 { | |
208 if (to_toggle == NULL) | |
209 return; | |
210 | |
211 if (GTK_WIDGET_VISIBLE(to_toggle)) | |
212 gtk_widget_hide(to_toggle); | |
213 else | |
214 gtk_widget_show(to_toggle); | |
215 } | |
216 | |
4687 | 217 void gaim_separator(GtkWidget *menu) |
218 { | |
219 GtkWidget *menuitem; | |
220 | |
221 menuitem = gtk_separator_menu_item_new(); | |
222 gtk_widget_show(menuitem); | |
223 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
224 } | |
5160 | 225 |
5162 | 226 GtkWidget *gaim_new_item(GtkWidget *menu, const char *str) |
227 { | |
228 GtkWidget *menuitem; | |
229 GtkWidget *label; | |
230 | |
231 menuitem = gtk_menu_item_new(); | |
232 if (menu) | |
233 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
234 gtk_widget_show(menuitem); | |
235 | |
236 label = gtk_label_new(str); | |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6236
diff
changeset
|
237 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
5162 | 238 gtk_label_set_pattern(GTK_LABEL(label), "_"); |
239 gtk_container_add(GTK_CONTAINER(menuitem), label); | |
240 gtk_widget_show(label); | |
11525 | 241 /* FIXME: Go back and fix this |
5162 | 242 gtk_widget_add_accelerator(menuitem, "activate", accel, str[0], |
243 GDK_MOD1_MASK, GTK_ACCEL_LOCKED); | |
244 */ | |
8137 | 245 gaim_set_accessible_label (menuitem, label); |
5162 | 246 return menuitem; |
247 } | |
248 | |
5906 | 249 GtkWidget *gaim_new_check_item(GtkWidget *menu, const char *str, |
250 GtkSignalFunc sf, gpointer data, gboolean checked) | |
251 { | |
252 GtkWidget *menuitem; | |
253 menuitem = gtk_check_menu_item_new_with_mnemonic(str); | |
254 | |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
255 if (menu) |
5906 | 256 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); |
257 | |
7299
2737c287f84d
[gaim-migrate @ 7883]
Christian Hammond <chipx86@chipx86.com>
parents:
7118
diff
changeset
|
258 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
|
259 |
5906 | 260 if (sf) |
261 g_signal_connect(G_OBJECT(menuitem), "activate", sf, data); | |
262 | |
263 gtk_widget_show_all(menuitem); | |
264 | |
265 return menuitem; | |
266 } | |
267 | |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
268 GtkWidget * |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
269 gaim_pixbuf_toolbar_button_from_stock(const char *icon) |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
270 { |
9706 | 271 GtkWidget *button, *image, *bbox; |
6372
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 button = gtk_toggle_button_new(); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
274 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
275 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
276 bbox = gtk_vbox_new(FALSE, 0); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
277 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
278 gtk_container_add (GTK_CONTAINER(button), bbox); |
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 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_MENU); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
281 gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
282 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
283 gtk_widget_show_all(bbox); |
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 return button; |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
286 } |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
287 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
288 GtkWidget * |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
289 gaim_pixbuf_button_from_stock(const char *text, const char *icon, |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
290 GaimButtonOrientation style) |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
291 { |
10504 | 292 GtkWidget *button, *image, *label, *bbox, *ibox, *lbox = NULL; |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
293 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
294 button = gtk_button_new(); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
295 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
296 if (style == GAIM_BUTTON_HORIZONTAL) { |
9750 | 297 bbox = gtk_hbox_new(FALSE, 0); |
298 ibox = gtk_hbox_new(FALSE, 0); | |
10504 | 299 if (text) |
300 lbox = gtk_hbox_new(FALSE, 0); | |
9750 | 301 } else { |
302 bbox = gtk_vbox_new(FALSE, 0); | |
303 ibox = gtk_vbox_new(FALSE, 0); | |
10504 | 304 if (text) |
305 lbox = gtk_vbox_new(FALSE, 0); | |
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 |
9750 | 308 gtk_container_add(GTK_CONTAINER(button), bbox); |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
309 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
310 if (icon) { |
9750 | 311 gtk_box_pack_start_defaults(GTK_BOX(bbox), ibox); |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
312 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_BUTTON); |
9767 | 313 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
|
314 } |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
315 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
316 if (text) { |
9750 | 317 gtk_box_pack_start_defaults(GTK_BOX(bbox), lbox); |
6372
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
318 label = gtk_label_new(NULL); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
319 gtk_label_set_text_with_mnemonic(GTK_LABEL(label), text); |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
320 gtk_label_set_mnemonic_widget(GTK_LABEL(label), button); |
9767 | 321 gtk_box_pack_start(GTK_BOX(lbox), label, FALSE, TRUE, 0); |
8137 | 322 gaim_set_accessible_label (button, label); |
6372
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 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
325 gtk_widget_show_all(bbox); |
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 return button; |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
328 } |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
329 |
9dd4bb3cf1df
[gaim-migrate @ 6877]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
330 |
5160 | 331 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) |
332 { | |
333 GtkWidget *menuitem; | |
334 /* | |
335 GtkWidget *hbox; | |
336 GtkWidget *label; | |
337 */ | |
338 GtkWidget *image; | |
339 | |
340 if (icon == NULL) | |
341 menuitem = gtk_menu_item_new_with_mnemonic(str); | |
342 else | |
343 menuitem = gtk_image_menu_item_new_with_mnemonic(str); | |
344 | |
345 if (menu) | |
346 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
347 | |
348 if (sf) | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5162
diff
changeset
|
349 g_signal_connect(G_OBJECT(menuitem), "activate", sf, data); |
5160 | 350 |
351 if (icon != NULL) { | |
352 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_MENU); | |
353 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); | |
354 } | |
355 /* FIXME: this isn't right | |
356 if (mod) { | |
357 label = gtk_label_new(mod); | |
358 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 2); | |
359 gtk_widget_show(label); | |
360 } | |
361 */ | |
362 /* | |
363 if (accel_key) { | |
364 gtk_widget_add_accelerator(menuitem, "activate", accel, accel_key, | |
365 accel_mods, GTK_ACCEL_LOCKED); | |
366 } | |
367 */ | |
368 | |
369 gtk_widget_show_all(menuitem); | |
370 | |
371 return menuitem; | |
372 } | |
5530
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 * |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
375 gaim_gtk_make_frame(GtkWidget *parent, const char *title) |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
376 { |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
377 GtkWidget *vbox, *label, *hbox; |
13099
913e06e4155c
[gaim-migrate @ 15461]
Richard Laager <rlaager@wiktel.com>
parents:
13091
diff
changeset
|
378 char *labeltitle; |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
379 |
11243 | 380 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
381 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
|
382 gtk_widget_show(vbox); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
383 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
384 label = gtk_label_new(NULL); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
385 |
13099
913e06e4155c
[gaim-migrate @ 15461]
Richard Laager <rlaager@wiktel.com>
parents:
13091
diff
changeset
|
386 labeltitle = g_strdup_printf("<span weight=\"bold\">%s</span>", title); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
387 gtk_label_set_markup(GTK_LABEL(label), labeltitle); |
13099
913e06e4155c
[gaim-migrate @ 15461]
Richard Laager <rlaager@wiktel.com>
parents:
13091
diff
changeset
|
388 g_free(labeltitle); |
913e06e4155c
[gaim-migrate @ 15461]
Richard Laager <rlaager@wiktel.com>
parents:
13091
diff
changeset
|
389 |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
390 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
391 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
|
392 gtk_widget_show(label); |
8137 | 393 gaim_set_accessible_label (vbox, label); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
394 |
11243 | 395 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
396 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
|
397 gtk_widget_show(hbox); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
398 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
399 label = gtk_label_new(" "); |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
400 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
|
401 gtk_widget_show(label); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
402 |
11243 | 403 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
404 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
|
405 gtk_widget_show(vbox); |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
406 |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
407 return vbox; |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
408 } |
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
409 |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
410 static void |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
411 protocol_menu_cb(GtkWidget *optmenu, GCallback cb) |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
412 { |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
413 GtkWidget *menu; |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
414 GtkWidget *item; |
7956 | 415 const char *protocol; |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
416 gpointer user_data; |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
417 |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
418 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
419 item = gtk_menu_get_active(GTK_MENU(menu)); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
420 |
7956 | 421 protocol = g_object_get_data(G_OBJECT(item), "protocol"); |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
422 user_data = (g_object_get_data(G_OBJECT(optmenu), "user_data")); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
423 |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
424 if (cb != NULL) |
7956 | 425 ((void (*)(GtkWidget *, const char *, gpointer))cb)(item, protocol, |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
426 user_data); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
427 } |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
428 |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
429 GtkWidget * |
7956 | 430 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
|
431 gpointer user_data) |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
432 { |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
433 GaimPluginProtocolInfo *prpl_info; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
434 GaimPlugin *plugin; |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
435 GtkWidget *hbox; |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
436 GtkWidget *label; |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
437 GtkWidget *optmenu; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
438 GtkWidget *menu; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
439 GtkWidget *item; |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
440 GtkWidget *image; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
441 GdkPixbuf *pixbuf; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
442 GdkPixbuf *scale; |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
443 GList *p; |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
444 GtkSizeGroup *sg; |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
445 char *filename; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
446 const char *proto_name; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
447 char buf[256]; |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
448 int i, selected_index = -1; |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
449 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
450 optmenu = gtk_option_menu_new(); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
451 gtk_widget_show(optmenu); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
452 |
5647
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
453 g_object_set_data(G_OBJECT(optmenu), "user_data", user_data); |
6e551616d051
[gaim-migrate @ 6061]
Christian Hammond <chipx86@chipx86.com>
parents:
5646
diff
changeset
|
454 |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
455 menu = gtk_menu_new(); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
456 gtk_widget_show(menu); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
457 |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
458 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
459 |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
460 for (p = gaim_plugins_get_protocols(), i = 0; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
461 p != NULL; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
462 p = p->next, i++) { |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
463 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
464 plugin = (GaimPlugin *)p->data; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
465 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
466 |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
467 /* Create the item. */ |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
468 item = gtk_menu_item_new(); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
469 |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
470 /* Create the hbox. */ |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
471 hbox = gtk_hbox_new(FALSE, 4); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
472 gtk_container_add(GTK_CONTAINER(item), hbox); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
473 gtk_widget_show(hbox); |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
474 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
475 /* Load the image. */ |
6430 | 476 proto_name = prpl_info->list_icon(NULL, NULL); |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
477 g_snprintf(buf, sizeof(buf), "%s.png", proto_name); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
478 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
479 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
480 "default", buf, NULL); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
481 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
482 g_free(filename); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
483 |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
484 if (pixbuf != NULL) { |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
485 /* Scale and insert the image */ |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
486 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
487 GDK_INTERP_BILINEAR); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
488 image = gtk_image_new_from_pixbuf(scale); |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
489 |
5646
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
490 g_object_unref(G_OBJECT(pixbuf)); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
491 g_object_unref(G_OBJECT(scale)); |
48c63ee49961
[gaim-migrate @ 6060]
Christian Hammond <chipx86@chipx86.com>
parents:
5644
diff
changeset
|
492 } |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
493 else |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
494 image = gtk_image_new(); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
495 |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
496 gtk_size_group_add_widget(sg, 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 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
499 gtk_widget_show(image); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
500 |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
501 /* Create the label. */ |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
502 label = gtk_label_new(plugin->info->name); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
503 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
504 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
505 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
506 gtk_widget_show(label); |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
507 |
7956 | 508 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
|
509 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
510 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
511 gtk_widget_show(item); |
8137 | 512 gaim_set_accessible_label (item, label); |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
513 |
8218
4beaf6b35483
[gaim-migrate @ 8941]
Christian Hammond <chipx86@chipx86.com>
parents:
8215
diff
changeset
|
514 if (id != NULL && !strcmp(plugin->info->id, id)) |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
515 selected_index = i; |
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 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
518 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
519 |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
520 if (selected_index != -1) |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
521 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), selected_index); |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
522 |
5688
e43e1b8dca8b
[gaim-migrate @ 6109]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
523 g_signal_connect(G_OBJECT(optmenu), "changed", |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5746
diff
changeset
|
524 G_CALLBACK(protocol_menu_cb), cb); |
5688
e43e1b8dca8b
[gaim-migrate @ 6109]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
525 |
5649
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
526 g_object_unref(sg); |
84221116b28e
[gaim-migrate @ 6063]
Christian Hammond <chipx86@chipx86.com>
parents:
5647
diff
changeset
|
527 |
5644
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
528 return optmenu; |
213e999fa5cc
[gaim-migrate @ 6058]
Christian Hammond <chipx86@chipx86.com>
parents:
5641
diff
changeset
|
529 } |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
530 |
8940 | 531 GaimAccount * |
532 gaim_gtk_account_option_menu_get_selected(GtkWidget *optmenu) | |
533 { | |
534 GtkWidget *menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); | |
535 GtkWidget *item = gtk_menu_get_active(GTK_MENU(menu)); | |
536 return g_object_get_data(G_OBJECT(item), "account"); | |
537 } | |
538 | |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
539 static void |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
540 account_menu_cb(GtkWidget *optmenu, GCallback cb) |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
541 { |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
542 GtkWidget *menu; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
543 GtkWidget *item; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
544 GaimAccount *account; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
545 gpointer user_data; |
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 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
548 item = gtk_menu_get_active(GTK_MENU(menu)); |
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 account = g_object_get_data(G_OBJECT(item), "account"); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
551 user_data = g_object_get_data(G_OBJECT(optmenu), "user_data"); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
552 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
553 if (cb != NULL) |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
554 ((void (*)(GtkWidget *, GaimAccount *, gpointer))cb)(item, account, |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
555 user_data); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
556 } |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
557 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
558 static void |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
559 create_account_menu(GtkWidget *optmenu, GaimAccount *default_account, |
8289
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
560 GaimFilterAccountFunc filter_func, gboolean show_all) |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
561 { |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
562 GaimAccount *account; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
563 GtkWidget *menu; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
564 GtkWidget *item; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
565 GtkWidget *image; |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
566 GtkWidget *hbox; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
567 GtkWidget *label; |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
568 GdkPixbuf *pixbuf; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
569 GdkPixbuf *scale; |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
570 GList *list; |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
571 GList *p; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
572 GtkSizeGroup *sg; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
573 char *filename; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
574 const char *proto_name; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
575 char buf[256]; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
576 int i, selected_index = -1; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
577 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
578 if (show_all) |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
579 list = gaim_accounts_get_all(); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
580 else |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
581 list = gaim_connections_get_all(); |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
582 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
583 menu = gtk_menu_new(); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
584 gtk_widget_show(menu); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
585 |
5880
1b85ff65be57
[gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
586 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
587 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
588 for (p = list, i = 0; p != NULL; p = p->next, i++) { |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
589 GaimPluginProtocolInfo *prpl_info = NULL; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
590 GaimPlugin *plugin; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
591 |
5879
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
592 if (show_all) |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
593 account = (GaimAccount *)p->data; |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
594 else { |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
595 GaimConnection *gc = (GaimConnection *)p->data; |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
596 |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
597 account = gaim_connection_get_account(gc); |
d58406d31a1a
[gaim-migrate @ 6311]
Christian Hammond <chipx86@chipx86.com>
parents:
5877
diff
changeset
|
598 } |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
599 |
8289
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
600 if (filter_func && !filter_func(account)) { |
8215 | 601 i--; |
6646
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
602 continue; |
8215 | 603 } |
6646
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
604 |
7956 | 605 plugin = gaim_find_prpl(gaim_account_get_protocol_id(account)); |
5877
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 if (plugin != NULL) |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
608 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); |
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 item. */ |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
611 item = gtk_menu_item_new(); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
612 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
613 /* Create the hbox. */ |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
614 hbox = gtk_hbox_new(FALSE, 4); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
615 gtk_container_add(GTK_CONTAINER(item), hbox); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
616 gtk_widget_show(hbox); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
617 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
618 /* Load the image. */ |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
619 if (prpl_info != NULL) { |
6430 | 620 proto_name = prpl_info->list_icon(account, NULL); |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
621 g_snprintf(buf, sizeof(buf), "%s.png", proto_name); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
622 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
623 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
624 "default", buf, NULL); |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
625 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
626 g_free(filename); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
627 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
628 if (pixbuf != NULL) { |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
629 /* Scale and insert the image */ |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
630 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
631 GDK_INTERP_BILINEAR); |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
632 |
11251 | 633 if (gaim_account_is_disconnected(account) && show_all && |
8215 | 634 gaim_connections_get_all()) |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
635 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE); |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
636 |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
637 image = gtk_image_new_from_pixbuf(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 g_object_unref(G_OBJECT(pixbuf)); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
640 g_object_unref(G_OBJECT(scale)); |
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 else |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
646 image = gtk_image_new(); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
647 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
648 gtk_size_group_add_widget(sg, image); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
649 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
650 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
651 gtk_widget_show(image); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
652 |
11017
829ab6b71ffe
[gaim-migrate @ 12886]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10951
diff
changeset
|
653 if (gaim_account_get_alias(account)) { |
829ab6b71ffe
[gaim-migrate @ 12886]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10951
diff
changeset
|
654 g_snprintf(buf, sizeof(buf), "%s (%s) (%s)", |
829ab6b71ffe
[gaim-migrate @ 12886]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10951
diff
changeset
|
655 gaim_account_get_username(account), |
829ab6b71ffe
[gaim-migrate @ 12886]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10951
diff
changeset
|
656 gaim_account_get_alias(account), |
829ab6b71ffe
[gaim-migrate @ 12886]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10951
diff
changeset
|
657 gaim_account_get_protocol_name(account)); |
829ab6b71ffe
[gaim-migrate @ 12886]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10951
diff
changeset
|
658 } else { |
829ab6b71ffe
[gaim-migrate @ 12886]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10951
diff
changeset
|
659 g_snprintf(buf, sizeof(buf), "%s (%s)", |
829ab6b71ffe
[gaim-migrate @ 12886]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10951
diff
changeset
|
660 gaim_account_get_username(account), |
829ab6b71ffe
[gaim-migrate @ 12886]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10951
diff
changeset
|
661 gaim_account_get_protocol_name(account)); |
829ab6b71ffe
[gaim-migrate @ 12886]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10951
diff
changeset
|
662 } |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
663 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
664 /* Create the label. */ |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
665 label = gtk_label_new(buf); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
666 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
667 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
668 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
669 gtk_widget_show(label); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
670 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
671 g_object_set_data(G_OBJECT(item), "account", account); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
672 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
673 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
674 gtk_widget_show(item); |
8137 | 675 gaim_set_accessible_label (item, label); |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
676 |
5880
1b85ff65be57
[gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
677 if (default_account != NULL && account == default_account) |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
678 selected_index = i; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
679 } |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
680 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
681 g_object_unref(sg); |
5880
1b85ff65be57
[gaim-migrate @ 6312]
Christian Hammond <chipx86@chipx86.com>
parents:
5879
diff
changeset
|
682 |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
683 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
684 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
685 /* Set the place we should be at. */ |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
686 if (selected_index != -1) |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
687 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
|
688 } |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
689 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
690 static void |
8134 | 691 regenerate_account_menu(GtkWidget *optmenu) |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
692 { |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
693 GtkWidget *menu; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
694 GtkWidget *item; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
695 gboolean show_all; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
696 GaimAccount *account; |
8289
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
697 GaimFilterAccountFunc filter_func; |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
698 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
699 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
700 item = gtk_menu_get_active(GTK_MENU(menu)); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
701 account = g_object_get_data(G_OBJECT(item), "account"); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
702 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
703 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
|
704 "show_all")); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
705 |
8289
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
706 filter_func = g_object_get_data(G_OBJECT(optmenu), |
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
707 "filter_func"); |
6646
b89d98f0bf79
[gaim-migrate @ 7171]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
708 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
709 gtk_option_menu_remove_menu(GTK_OPTION_MENU(optmenu)); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
710 |
8289
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
711 create_account_menu(optmenu, account, filter_func, show_all); |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
712 } |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
713 |
8134 | 714 static void |
715 account_menu_sign_on_off_cb(GaimConnection *gc, GtkWidget *optmenu) | |
716 { | |
717 regenerate_account_menu(optmenu); | |
718 } | |
719 | |
720 static void | |
721 account_menu_added_removed_cb(GaimAccount *account, GtkWidget *optmenu) | |
722 { | |
723 regenerate_account_menu(optmenu); | |
724 } | |
725 | |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
726 static gboolean |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
727 account_menu_destroyed_cb(GtkWidget *optmenu, GdkEvent *event, |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
728 void *user_data) |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
729 { |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
730 gaim_signals_disconnect_by_handle(optmenu); |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
731 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
732 return FALSE; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
733 } |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
734 |
9910 | 735 void |
736 gaim_gtk_account_option_menu_set_selected(GtkWidget *optmenu, GaimAccount *account) | |
737 { | |
738 GtkWidget *menu; | |
739 GtkWidget *item; | |
740 gboolean show_all; | |
741 GaimAccount *curaccount; | |
742 GaimFilterAccountFunc filter_func; | |
743 | |
744 menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); | |
745 item = gtk_menu_get_active(GTK_MENU(menu)); | |
746 curaccount = g_object_get_data(G_OBJECT(item), "account"); | |
747 | |
748 if (account == curaccount) | |
749 return; | |
750 | |
751 show_all = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(optmenu), | |
752 "show_all")); | |
753 | |
754 filter_func = g_object_get_data(G_OBJECT(optmenu), | |
755 "filter_func"); | |
756 | |
757 gtk_option_menu_remove_menu(GTK_OPTION_MENU(optmenu)); | |
758 | |
759 create_account_menu(optmenu, account, filter_func, show_all); | |
760 } | |
761 | |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
762 GtkWidget * |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
763 gaim_gtk_account_option_menu_new(GaimAccount *default_account, |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
764 gboolean show_all, GCallback cb, |
8289
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
765 GaimFilterAccountFunc filter_func, |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
766 gpointer user_data) |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
767 { |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
768 GtkWidget *optmenu; |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
769 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
770 /* Create the option menu */ |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
771 optmenu = gtk_option_menu_new(); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
772 gtk_widget_show(optmenu); |
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 g_signal_connect(G_OBJECT(optmenu), "destroy", |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
775 G_CALLBACK(account_menu_destroyed_cb), NULL); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
776 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
777 /* Register the gaim sign on/off event callbacks. */ |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
778 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", |
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); |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
781 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
782 optmenu, GAIM_CALLBACK(account_menu_sign_on_off_cb), |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6465
diff
changeset
|
783 optmenu); |
8134 | 784 gaim_signal_connect(gaim_accounts_get_handle(), "account-added", |
785 optmenu, GAIM_CALLBACK(account_menu_added_removed_cb), | |
786 optmenu); | |
787 gaim_signal_connect(gaim_accounts_get_handle(), "account-removed", | |
788 optmenu, GAIM_CALLBACK(account_menu_added_removed_cb), | |
789 optmenu); | |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
790 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
791 /* Set some data. */ |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
792 g_object_set_data(G_OBJECT(optmenu), "user_data", user_data); |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
793 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
|
794 g_object_set_data(G_OBJECT(optmenu), "filter_func", |
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
795 filter_func); |
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 /* Create and set the actual menu. */ |
8289
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8247
diff
changeset
|
798 create_account_menu(optmenu, default_account, filter_func, show_all); |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
799 |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
800 /* And now the last callback. */ |
5877
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
801 g_signal_connect(G_OBJECT(optmenu), "changed", |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
802 G_CALLBACK(account_menu_cb), cb); |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
803 |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
804 return optmenu; |
f336fc0a7b8b
[gaim-migrate @ 6309]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
805 } |
5943
a4f2aba0848d
[gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
806 |
6391
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
807 gboolean |
4b2d8d7d0118
[gaim-migrate @ 6896]
Christian Hammond <chipx86@chipx86.com>
parents:
6372
diff
changeset
|
808 gaim_gtk_check_if_dir(const char *path, GtkFileSelection *filesel) |
5966 | 809 { |
5967 | 810 char *dirname; |
5966 | 811 |
5967 | 812 if (g_file_test(path, G_FILE_TEST_IS_DIR)) { |
5966 | 813 /* append a / if needed */ |
9534 | 814 if (path[strlen(path) - 1] != G_DIR_SEPARATOR) { |
815 dirname = g_strconcat(path, G_DIR_SEPARATOR_S, NULL); | |
5966 | 816 } else { |
5967 | 817 dirname = g_strdup(path); |
5966 | 818 } |
5967 | 819 gtk_file_selection_set_filename(filesel, dirname); |
820 g_free(dirname); | |
5966 | 821 return TRUE; |
822 } | |
823 | |
824 return FALSE; | |
825 } | |
826 | |
12067
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12063
diff
changeset
|
827 void |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12063
diff
changeset
|
828 gaim_gtk_setup_gtkspell(GtkTextView *textview) |
12061
29dc8fc0dd6c
[gaim-migrate @ 14356]
Richard Laager <rlaager@wiktel.com>
parents:
11878
diff
changeset
|
829 { |
12067
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12063
diff
changeset
|
830 #ifdef USE_GTKSPELL |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
831 GError *error = NULL; |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
832 char *locale = NULL; |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
833 |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
834 g_return_if_fail(textview != NULL); |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
835 g_return_if_fail(GTK_IS_TEXT_VIEW(textview)); |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
836 |
12067
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12063
diff
changeset
|
837 if (gtkspell_new_attach(textview, locale, &error) == NULL && error) |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
838 { |
12067
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12063
diff
changeset
|
839 gaim_debug_warning("gtkspell", "Failed to setup GtkSpell: %s\n", |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12063
diff
changeset
|
840 error->message); |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
841 g_error_free(error); |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
842 } |
12067
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12063
diff
changeset
|
843 #endif /* USE_GTKSPELL */ |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
844 } |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
845 |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7420
diff
changeset
|
846 void |
7420 | 847 gaim_gtk_save_accels_cb(GtkAccelGroup *accel_group, guint arg1, |
848 GdkModifierType arg2, GClosure *arg3, | |
849 gpointer data) | |
850 { | |
851 gaim_debug(GAIM_DEBUG_MISC, "accels", "accel changed, scheduling save.\n"); | |
852 | |
853 if (!accels_save_timer) | |
854 accels_save_timer = g_timeout_add(5000, gaim_gtk_save_accels, NULL); | |
855 } | |
856 | |
857 gboolean | |
858 gaim_gtk_save_accels(gpointer data) | |
859 { | |
860 char *filename = NULL; | |
861 | |
862 filename = g_build_filename(gaim_user_dir(), G_DIR_SEPARATOR_S, | |
863 "accels", NULL); | |
864 gaim_debug(GAIM_DEBUG_MISC, "accels", "saving accels to %s\n", filename); | |
865 gtk_accel_map_save(filename); | |
866 g_free(filename); | |
867 | |
868 accels_save_timer = 0; | |
869 return FALSE; | |
870 } | |
871 | |
872 void | |
12322
c7ae1fd0827d
[gaim-migrate @ 14626]
Richard Laager <rlaager@wiktel.com>
parents:
12114
diff
changeset
|
873 gaim_gtk_load_accels() |
7420 | 874 { |
875 char *filename = NULL; | |
876 | |
877 filename = g_build_filename(gaim_user_dir(), G_DIR_SEPARATOR_S, | |
878 "accels", NULL); | |
879 gtk_accel_map_load(filename); | |
880 g_free(filename); | |
881 } | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
882 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
883 gboolean |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
884 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
|
885 GaimAccount **ret_account, char **ret_protocol, |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
886 char **ret_username, char **ret_alias) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
887 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
888 char *protocol = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
889 char *username = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
890 char *alias = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
891 char *str; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
892 char *c, *s; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
893 gboolean valid; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
894 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
895 g_return_val_if_fail(msg != NULL, FALSE); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
896 g_return_val_if_fail(ret_protocol != NULL, FALSE); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
897 g_return_val_if_fail(ret_username != NULL, FALSE); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
898 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
899 s = str = g_strdup(msg); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
900 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
901 while (*s != '\r' && *s != '\n' && *s != '\0') |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
902 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
903 char *key, *value; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
904 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
905 key = s; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
906 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
907 /* Grab the key */ |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
908 while (*s != '\r' && *s != '\n' && *s != '\0' && *s != ' ') |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
909 s++; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
910 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
911 if (*s == '\r') s++; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
912 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
913 if (*s == '\n') |
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 s++; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
916 continue; |
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 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
919 if (*s != '\0') *s++ = '\0'; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
920 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
921 /* Clear past any whitespace */ |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
922 while (*s != '\0' && *s == ' ') |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
923 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 /* Now let's grab until the end of the line. */ |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
926 value = 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 while (*s != '\r' && *s != '\n' && *s != '\0') |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
929 s++; |
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 (*s == '\r') *s++ = '\0'; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
932 if (*s == '\n') *s++ = '\0'; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
933 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
934 if ((c = strchr(key, ':')) != NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
935 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
936 if (!g_ascii_strcasecmp(key, "X-IM-Username:")) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
937 username = g_strdup(value); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
938 else if (!g_ascii_strcasecmp(key, "X-IM-Protocol:")) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
939 protocol = g_strdup(value); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
940 else if (!g_ascii_strcasecmp(key, "X-IM-Alias:")) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
941 alias = g_strdup(value); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
942 } |
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 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
945 if (username != NULL && protocol != NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
946 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
947 valid = TRUE; |
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 *ret_username = username; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
950 *ret_protocol = protocol; |
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 if (ret_alias != NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
953 *ret_alias = alias; |
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 /* Check for a compatible account. */ |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
956 if (ret_account != NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
957 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
958 GList *list; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
959 GaimAccount *account = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
960 GList *l; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
961 const char *protoname; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
962 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
963 if (all_accounts) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
964 list = gaim_accounts_get_all(); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
965 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
966 list = gaim_connections_get_all(); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
967 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
968 for (l = list; l != NULL; l = l->next) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
969 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
970 GaimConnection *gc; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
971 GaimPluginProtocolInfo *prpl_info = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
972 GaimPlugin *plugin; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
973 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
974 if (all_accounts) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
975 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
976 account = (GaimAccount *)l->data; |
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 plugin = gaim_plugins_find_with_id( |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
979 gaim_account_get_protocol_id(account)); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
980 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
981 if (plugin == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
982 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
983 account = NULL; |
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 continue; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
986 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
987 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
988 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
989 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
990 else |
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 gc = (GaimConnection *)l->data; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
993 account = gaim_connection_get_account(gc); |
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 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
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 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
998 protoname = prpl_info->list_icon(account, NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
999 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1000 if (!strcmp(protoname, protocol)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1001 break; |
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 account = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1004 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1005 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1006 /* Special case for AIM and ICQ */ |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1007 if (account == NULL && (!strcmp(protocol, "aim") || |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1008 !strcmp(protocol, "icq"))) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1009 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1010 for (l = list; l != NULL; l = l->next) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1011 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1012 GaimConnection *gc; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1013 GaimPluginProtocolInfo *prpl_info = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1014 GaimPlugin *plugin; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1015 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1016 if (all_accounts) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1017 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1018 account = (GaimAccount *)l->data; |
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 plugin = gaim_plugins_find_with_id( |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1021 gaim_account_get_protocol_id(account)); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1022 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1023 if (plugin == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1024 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1025 account = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1026 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1027 continue; |
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 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1030 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1031 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1032 else |
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 gc = (GaimConnection *)l->data; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1035 account = gaim_connection_get_account(gc); |
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 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
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 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1040 protoname = prpl_info->list_icon(account, NULL); |
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 if (!strcmp(protoname, "aim") || !strcmp(protoname, "icq")) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1043 break; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1044 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1045 account = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1046 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1047 } |
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 *ret_account = account; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1050 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1051 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1052 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1053 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1054 valid = FALSE; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1055 |
14035 | 1056 g_free(username); |
1057 g_free(protocol); | |
1058 g_free(alias); | |
7712
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 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1061 g_free(str); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1062 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1063 return valid; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
1064 } |
8137 | 1065 |
1066 void | |
1067 gaim_set_accessible_label (GtkWidget *w, GtkWidget *l) | |
1068 { | |
1069 AtkObject *acc, *label; | |
1070 AtkObject *rel_obj[1]; | |
1071 AtkRelationSet *set; | |
1072 AtkRelation *relation; | |
1073 const gchar *label_text; | |
1074 const gchar *existing_name; | |
1075 | |
1076 acc = gtk_widget_get_accessible (w); | |
1077 label = gtk_widget_get_accessible (l); | |
1078 | |
1079 /* If this object has no name, set it's name with the label text */ | |
1080 existing_name = atk_object_get_name (acc); | |
1081 if (!existing_name) { | |
1082 label_text = gtk_label_get_text (GTK_LABEL(l)); | |
1083 if (label_text) | |
1084 atk_object_set_name (acc, label_text); | |
1085 } | |
1086 | |
1087 /* Create the labeled-by relation */ | |
1088 set = atk_object_ref_relation_set (acc); | |
1089 rel_obj[0] = label; | |
1090 relation = atk_relation_new (rel_obj, 1, ATK_RELATION_LABELLED_BY); | |
1091 atk_relation_set_add (set, relation); | |
1092 g_object_unref (relation); | |
1093 | |
1094 /* Create the label-for relation */ | |
1095 set = atk_object_ref_relation_set (label); | |
1096 rel_obj[0] = acc; | |
1097 relation = atk_relation_new (rel_obj, 1, ATK_RELATION_LABEL_FOR); | |
1098 atk_relation_set_add (set, relation); | |
1099 g_object_unref (relation); | |
1100 } | |
8143 | 1101 |
8247 | 1102 #if GTK_CHECK_VERSION(2,2,0) |
8143 | 1103 static void |
1104 gaim_gtk_menu_position_func(GtkMenu *menu, | |
1105 gint *x, | |
1106 gint *y, | |
1107 gboolean *push_in, | |
1108 gpointer data) | |
1109 { | |
1110 GtkWidget *widget; | |
1111 GtkRequisition requisition; | |
1112 GdkScreen *screen; | |
1113 GdkRectangle monitor; | |
1114 gint monitor_num; | |
1115 gint space_left, space_right, space_above, space_below; | |
1116 gint needed_width; | |
1117 gint needed_height; | |
1118 gint xthickness; | |
1119 gint ythickness; | |
1120 gboolean rtl; | |
1121 | |
1122 g_return_if_fail(GTK_IS_MENU(menu)); | |
1123 | |
1124 widget = GTK_WIDGET(menu); | |
1125 screen = gtk_widget_get_screen(widget); | |
1126 xthickness = widget->style->xthickness; | |
1127 ythickness = widget->style->ythickness; | |
1128 rtl = (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL); | |
1129 | |
1130 /* | |
1131 * We need the requisition to figure out the right place to | |
1132 * popup the menu. In fact, we always need to ask here, since | |
1133 * if a size_request was queued while we weren't popped up, | |
1134 * the requisition won't have been recomputed yet. | |
1135 */ | |
1136 gtk_widget_size_request (widget, &requisition); | |
1137 | |
1138 monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y); | |
1139 | |
1140 push_in = FALSE; | |
11525 | 1141 |
8143 | 1142 /* |
1143 * The placement of popup menus horizontally works like this (with | |
1144 * RTL in parentheses) | |
1145 * | |
1146 * - If there is enough room to the right (left) of the mouse cursor, | |
1147 * position the menu there. | |
11525 | 1148 * |
1149 * - Otherwise, if if there is enough room to the left (right) of the | |
8143 | 1150 * mouse cursor, position the menu there. |
11525 | 1151 * |
8143 | 1152 * - Otherwise if the menu is smaller than the monitor, position it |
1153 * on the side of the mouse cursor that has the most space available | |
1154 * | |
1155 * - Otherwise (if there is simply not enough room for the menu on the | |
1156 * monitor), position it as far left (right) as possible. | |
1157 * | |
1158 * Positioning in the vertical direction is similar: first try below | |
1159 * mouse cursor, then above. | |
1160 */ | |
1161 gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); | |
1162 | |
1163 space_left = *x - monitor.x; | |
1164 space_right = monitor.x + monitor.width - *x - 1; | |
1165 space_above = *y - monitor.y; | |
1166 space_below = monitor.y + monitor.height - *y - 1; | |
1167 | |
1168 /* position horizontally */ | |
1169 | |
1170 /* the amount of space we need to position the menu. Note the | |
11525 | 1171 * menu is offset "xthickness" pixels |
8143 | 1172 */ |
1173 needed_width = requisition.width - xthickness; | |
1174 | |
1175 if (needed_width <= space_left || | |
1176 needed_width <= space_right) | |
1177 { | |
1178 if ((rtl && needed_width <= space_left) || | |
1179 (!rtl && needed_width > space_right)) | |
1180 { | |
1181 /* position left */ | |
1182 *x = *x + xthickness - requisition.width + 1; | |
1183 } | |
1184 else | |
1185 { | |
1186 /* position right */ | |
1187 *x = *x - xthickness; | |
1188 } | |
1189 | |
1190 /* x is clamped on-screen further down */ | |
1191 } | |
1192 else if (requisition.width <= monitor.width) | |
1193 { | |
1194 /* the menu is too big to fit on either side of the mouse | |
1195 * cursor, but smaller than the monitor. Position it on | |
1196 * the side that has the most space | |
1197 */ | |
1198 if (space_left > space_right) | |
1199 { | |
1200 /* left justify */ | |
1201 *x = monitor.x; | |
1202 } | |
1203 else | |
1204 { | |
1205 /* right justify */ | |
1206 *x = monitor.x + monitor.width - requisition.width; | |
1207 } | |
1208 } | |
1209 else /* menu is simply too big for the monitor */ | |
1210 { | |
1211 if (rtl) | |
1212 { | |
1213 /* right justify */ | |
1214 *x = monitor.x + monitor.width - requisition.width; | |
1215 } | |
1216 else | |
1217 { | |
1218 /* left justify */ | |
1219 *x = monitor.x; | |
1220 } | |
1221 } | |
1222 | |
1223 /* Position vertically. The algorithm is the same as above, but | |
1224 * simpler because we don't have to take RTL into account. | |
1225 */ | |
1226 needed_height = requisition.height - ythickness; | |
1227 | |
1228 if (needed_height <= space_above || | |
1229 needed_height <= space_below) | |
1230 { | |
1231 if (needed_height <= space_below) | |
1232 *y = *y - ythickness; | |
1233 else | |
1234 *y = *y + ythickness - requisition.height + 1; | |
11525 | 1235 |
8143 | 1236 *y = CLAMP (*y, monitor.y, |
1237 monitor.y + monitor.height - requisition.height); | |
1238 } | |
1239 else if (needed_height > space_below && needed_height > space_above) | |
1240 { | |
1241 if (space_below >= space_above) | |
1242 *y = monitor.y + monitor.height - requisition.height; | |
1243 else | |
1244 *y = monitor.y; | |
1245 } | |
1246 else | |
1247 { | |
1248 *y = monitor.y; | |
1249 } | |
1250 } | |
1251 | |
8247 | 1252 #endif |
1253 | |
8143 | 1254 void |
1255 gaim_gtk_treeview_popup_menu_position_func(GtkMenu *menu, | |
1256 gint *x, | |
1257 gint *y, | |
1258 gboolean *push_in, | |
1259 gpointer data) | |
1260 { | |
1261 GtkWidget *widget = GTK_WIDGET(data); | |
1262 GtkTreeView *tv = GTK_TREE_VIEW(data); | |
1263 GtkTreePath *path; | |
1264 GtkTreeViewColumn *col; | |
1265 GdkRectangle rect; | |
1266 gint ythickness = GTK_WIDGET(menu)->style->ythickness; | |
1267 | |
1268 gdk_window_get_origin (widget->window, x, y); | |
1269 gtk_tree_view_get_cursor (tv, &path, &col); | |
1270 gtk_tree_view_get_cell_area (tv, path, col, &rect); | |
8218
4beaf6b35483
[gaim-migrate @ 8941]
Christian Hammond <chipx86@chipx86.com>
parents:
8215
diff
changeset
|
1271 |
8143 | 1272 *x += rect.x+rect.width; |
1273 *y += rect.y+rect.height+ythickness; | |
8247 | 1274 #if GTK_CHECK_VERSION(2,2,0) |
8143 | 1275 gaim_gtk_menu_position_func (menu, x, y, push_in, data); |
8247 | 1276 #endif |
8143 | 1277 } |
10061 | 1278 |
10229 | 1279 enum { |
1280 DND_FILE_TRANSFER, | |
1281 DND_IM_IMAGE, | |
1282 DND_BUDDY_ICON | |
1283 }; | |
1284 | |
1285 typedef struct { | |
1286 char *filename; | |
1287 GaimAccount *account; | |
1288 char *who; | |
1289 } _DndData; | |
1290 | |
10850 | 1291 static void dnd_image_ok_callback(_DndData *data, int choice) |
10229 | 1292 { |
1293 char *filedata; | |
1294 size_t size; | |
1295 GError *err = NULL; | |
1296 GaimConversation *conv; | |
1297 GaimGtkConversation *gtkconv; | |
1298 GtkTextIter iter; | |
1299 int id; | |
1300 switch (choice) { | |
1301 case DND_BUDDY_ICON: | |
1302 if (!g_file_get_contents(data->filename, &filedata, &size, | |
1303 &err)) { | |
1304 char *str; | |
1305 | |
1306 str = g_strdup_printf(_("The following error has occurred loading %s: %s"), data->filename, err->message); | |
1307 gaim_notify_error(NULL, NULL, | |
1308 _("Failed to load image"), | |
1309 str); | |
10335 | 1310 |
10229 | 1311 g_error_free(err); |
1312 g_free(str); | |
1313 | |
1314 return; | |
1315 } | |
10335 | 1316 |
10229 | 1317 gaim_buddy_icons_set_for_user(data->account, data->who, filedata, size); |
1318 g_free(filedata); | |
1319 break; | |
1320 case DND_FILE_TRANSFER: | |
1321 serv_send_file(gaim_account_get_connection(data->account), data->who, data->filename); | |
1322 break; | |
1323 case DND_IM_IMAGE: | |
11338 | 1324 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, data->account, data->who); |
10229 | 1325 gtkconv = GAIM_GTK_CONVERSATION(conv); |
1326 | |
1327 if (!g_file_get_contents(data->filename, &filedata, &size, | |
1328 &err)) { | |
1329 char *str; | |
10335 | 1330 |
10229 | 1331 str = g_strdup_printf(_("The following error has occurred loading %s: %s"), data->filename, err->message); |
1332 gaim_notify_error(NULL, NULL, | |
1333 _("Failed to load image"), | |
1334 str); | |
10335 | 1335 |
10229 | 1336 g_error_free(err); |
1337 g_free(str); | |
10335 | 1338 |
10229 | 1339 return; |
1340 } | |
1341 id = gaim_imgstore_add(filedata, size, data->filename); | |
1342 g_free(filedata); | |
10335 | 1343 |
10229 | 1344 gtk_text_buffer_get_iter_at_mark(GTK_IMHTML(gtkconv->entry)->text_buffer, &iter, |
1345 gtk_text_buffer_get_insert(GTK_IMHTML(gtkconv->entry)->text_buffer)); | |
1346 gtk_imhtml_insert_image_at_iter(GTK_IMHTML(gtkconv->entry), id, &iter); | |
1347 gaim_imgstore_unref(id); | |
10335 | 1348 |
10229 | 1349 break; |
1350 } | |
1351 free(data->filename); | |
1352 free(data->who); | |
1353 free(data); | |
1354 } | |
1355 | |
10850 | 1356 static void dnd_image_cancel_callback(_DndData *data, int choice) |
10229 | 1357 { |
1358 free(data->filename); | |
1359 free(data->who); | |
1360 free(data); | |
1361 } | |
1362 | |
11110
f7ce10cad83d
[gaim-migrate @ 13162]
Richard Laager <rlaager@wiktel.com>
parents:
11017
diff
changeset
|
1363 static void dnd_set_icon_ok_cb(_DndData *data) |
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 dnd_image_ok_callback(data, DND_BUDDY_ICON); |
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 |
f7ce10cad83d
[gaim-migrate @ 13162]
Richard Laager <rlaager@wiktel.com>
parents:
11017
diff
changeset
|
1368 static void dnd_set_icon_cancel_cb(_DndData *data) |
f7ce10cad83d
[gaim-migrate @ 13162]
Richard Laager <rlaager@wiktel.com>
parents:
11017
diff
changeset
|
1369 { |
f7ce10cad83d
[gaim-migrate @ 13162]
Richard Laager <rlaager@wiktel.com>
parents:
11017
diff
changeset
|
1370 free(data->filename); |
f7ce10cad83d
[gaim-migrate @ 13162]
Richard Laager <rlaager@wiktel.com>
parents:
11017
diff
changeset
|
1371 free(data->who); |
f7ce10cad83d
[gaim-migrate @ 13162]
Richard Laager <rlaager@wiktel.com>
parents:
11017
diff
changeset
|
1372 free(data); |
f7ce10cad83d
[gaim-migrate @ 13162]
Richard Laager <rlaager@wiktel.com>
parents:
11017
diff
changeset
|
1373 } |
f7ce10cad83d
[gaim-migrate @ 13162]
Richard Laager <rlaager@wiktel.com>
parents:
11017
diff
changeset
|
1374 |
10229 | 1375 void |
1376 gaim_dnd_file_manage(GtkSelectionData *sd, GaimAccount *account, const char *who) | |
1377 { | |
1378 GList *tmp; | |
1379 GdkPixbuf *pb; | |
11135 | 1380 GList *files = gaim_uri_list_extract_filenames((const gchar *)sd->data); |
10229 | 1381 GaimConnection *gc = gaim_account_get_connection(account); |
1382 GaimPluginProtocolInfo *prpl_info = NULL; | |
10335 | 1383 gboolean file_send_ok = FALSE; |
1384 #ifndef _WIN32 | |
10229 | 1385 GaimDesktopItem *item; |
10335 | 1386 #endif |
10229 | 1387 |
1388 g_return_if_fail(account != NULL); | |
1389 g_return_if_fail(who != NULL); | |
10335 | 1390 |
10229 | 1391 for(tmp = files; tmp != NULL ; tmp = g_list_next(tmp)) { |
1392 gchar *filename = tmp->data; | |
1393 gchar *basename = g_path_get_basename(filename); | |
10335 | 1394 |
10229 | 1395 /* Set the default action: don't send anything */ |
1396 file_send_ok = FALSE; | |
1397 | |
1398 /* XXX - Make ft API support creating a transfer with more than one file */ | |
1399 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { | |
1400 continue; | |
1401 } | |
1402 | |
1403 /* XXX - make ft api suupport sending a directory */ | |
1404 /* Are we dealing with a directory? */ | |
1405 if (g_file_test(filename, G_FILE_TEST_IS_DIR)) { | |
1406 char *str; | |
1407 | |
1408 str = g_strdup_printf(_("Cannot send folder %s."), basename); | |
1409 gaim_notify_error(NULL, NULL, | |
1410 str,_("Gaim cannot transfer a folder. You will need to send the files within individually")); | |
10335 | 1411 |
10229 | 1412 g_free(str); |
10335 | 1413 |
1414 continue; | |
10229 | 1415 } |
1416 | |
1417 /* Are we dealing with an image? */ | |
1418 pb = gdk_pixbuf_new_from_file(filename, NULL); | |
1419 if (pb) { | |
1420 _DndData *data = g_malloc(sizeof(_DndData)); | |
1421 gboolean ft = FALSE, im = FALSE; | |
10335 | 1422 |
10229 | 1423 data->who = g_strdup(who); |
1424 data->filename = g_strdup(filename); | |
1425 data->account = account; | |
1426 | |
1427 if (gc) | |
1428 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
10348 | 1429 |
10229 | 1430 if (prpl_info && prpl_info->options & OPT_PROTO_IM_IMAGE) |
1431 im = TRUE; | |
10335 | 1432 |
10348 | 1433 if (prpl_info && prpl_info->can_receive_file) |
10229 | 1434 ft = prpl_info->can_receive_file(gc, who); |
10335 | 1435 |
10229 | 1436 if (im && ft) |
1437 gaim_request_choice(NULL, NULL, | |
1438 _("You have dragged an image"), | |
10951 | 1439 _("You can send this image as a file transfer, " |
1440 "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
|
1441 DND_FILE_TRANSFER, "OK", (GCallback)dnd_image_ok_callback, |
10335 | 1442 "Cancel", (GCallback)dnd_image_cancel_callback, data, |
10229 | 1443 _("Set as buddy icon"), DND_BUDDY_ICON, |
10335 | 1444 _("Send image file"), DND_FILE_TRANSFER, |
1445 _("Insert in message"), DND_IM_IMAGE, NULL); | |
10229 | 1446 else if (!(im || ft)) |
10335 | 1447 gaim_request_yes_no(NULL, NULL, _("You have dragged an image"), |
10229 | 1448 _("Would you like to set it as the buddy icon for this user?"), |
1449 0, data, (GCallback)dnd_set_icon_ok_cb, (GCallback)dnd_set_icon_cancel_cb); | |
10335 | 1450 else |
10229 | 1451 gaim_request_choice(NULL, NULL, |
1452 _("You have dragged an image"), | |
10951 | 1453 ft ? _("You can send this image as a file transfer or " |
10229 | 1454 "embed it into this message, or use it as the buddy icon for this user.") : |
1455 _("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
|
1456 ft ? DND_FILE_TRANSFER : DND_IM_IMAGE, "OK", (GCallback)dnd_image_ok_callback, |
10335 | 1457 "Cancel", (GCallback)dnd_image_cancel_callback, data, |
10229 | 1458 _("Set as buddy icon"), DND_BUDDY_ICON, |
10335 | 1459 ft ? _("Send image file") : _("Insert in message"), ft ? DND_FILE_TRANSFER : DND_IM_IMAGE, NULL); |
10229 | 1460 return; |
1461 } | |
1462 | |
1463 #ifndef _WIN32 | |
1464 /* Are we trying to send a .desktop file? */ | |
11780 | 1465 else if (gaim_str_has_suffix(basename, ".desktop") && (item = gaim_desktop_item_new_from_file(filename))) { |
10229 | 1466 GaimDesktopItemType dtype; |
1467 char key[64]; | |
1468 const char *itemname = NULL; | |
10335 | 1469 |
10229 | 1470 #if GTK_CHECK_VERSION(2,6,0) |
10679 | 1471 const char * const *langs; |
10229 | 1472 int i; |
1473 langs = g_get_language_names(); | |
1474 for (i = 0; langs[i]; i++) { | |
1475 g_snprintf(key, sizeof(key), "Name[%s]", langs[i]); | |
1476 itemname = gaim_desktop_item_get_string(item, key); | |
1477 break; | |
1478 } | |
1479 #else | |
1480 const char *lang = g_getenv("LANG"); | |
10681 | 1481 char *dot; |
10229 | 1482 dot = strchr(lang, '.'); |
10335 | 1483 if (dot) |
10229 | 1484 *dot = '\0'; |
1485 g_snprintf(key, sizeof(key), "Name[%s]", lang); | |
1486 itemname = gaim_desktop_item_get_string(item, key); | |
1487 #endif | |
1488 if (!itemname) | |
1489 itemname = gaim_desktop_item_get_string(item, "Name"); | |
1490 | |
1491 dtype = gaim_desktop_item_get_entry_type(item); | |
1492 switch (dtype) { | |
1493 GaimConversation *conv; | |
1494 GaimGtkConversation *gtkconv; | |
1495 | |
1496 case GAIM_DESKTOP_ITEM_TYPE_LINK: | |
11338 | 1497 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, who); |
10229 | 1498 gtkconv = GAIM_GTK_CONVERSATION(conv); |
10335 | 1499 gtk_imhtml_insert_link(GTK_IMHTML(gtkconv->entry), |
1500 gtk_text_buffer_get_insert(GTK_IMHTML(gtkconv->entry)->text_buffer), | |
10229 | 1501 gaim_desktop_item_get_string(item, "URL"), itemname); |
1502 break; | |
10335 | 1503 default: |
10229 | 1504 /* I don't know if we really want to do anything here. Most of the desktop item types are crap like |
1505 * "MIME Type" (I have no clue how that would be a desktop item) and "Comment"... nothing we can really | |
1506 * send. The only logical one is "Application," but do we really want to send a binary and nothing else? | |
1507 * Probably not. I'll just give an error and return. */ | |
1508 /* The original patch sent the icon used by the launcher. That's probably wrong */ | |
1509 gaim_notify_error(NULL, NULL, _("Cannot send launcher"), _("You dragged a desktop launcher. " | |
1510 "Most likely you wanted to send whatever this launcher points to instead of this launcher" | |
1511 " itself.")); | |
1512 break; | |
1513 } | |
1514 gaim_desktop_item_unref(item); | |
1515 return; | |
1516 } | |
1517 #endif /* _WIN32 */ | |
1518 | |
1519 /* Everything is fine, let's send */ | |
1520 serv_send_file(gc, who, filename); | |
1521 g_free(filename); | |
1522 } | |
1523 g_list_free(files); | |
1524 } | |
10483 | 1525 |
1526 void gaim_gtk_buddy_icon_get_scale_size(GdkPixbuf *buf, GaimBuddyIconSpec *spec, int *width, int *height) | |
1527 { | |
1528 *width = gdk_pixbuf_get_width(buf); | |
1529 *height = gdk_pixbuf_get_height(buf); | |
1530 | |
1531 gaim_buddy_icon_get_scale_size(spec, width, height); | |
1532 | |
1533 /* and now for some arbitrary sanity checks */ | |
1534 if(*width > 100) | |
1535 *width = 100; | |
1536 if(*height > 100) | |
1537 *height = 100; | |
1538 } | |
12080 | 1539 |
1540 GdkPixbuf * | |
13090 | 1541 gaim_gtk_create_prpl_icon(GaimAccount *account, double scale_factor) |
12080 | 1542 { |
1543 GaimPlugin *prpl; | |
13090 | 1544 GaimPluginProtocolInfo *prpl_info; |
12080 | 1545 const char *protoname = NULL; |
1546 char buf[256]; /* TODO: We should use a define for max file length */ | |
13090 | 1547 char *filename = NULL; |
1548 GdkPixbuf *pixbuf, *scaled; | |
12080 | 1549 |
1550 g_return_val_if_fail(account != NULL, NULL); | |
1551 | |
1552 prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); | |
13090 | 1553 if (prpl == NULL) |
1554 return NULL; | |
12080 | 1555 |
13090 | 1556 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); |
1557 if (prpl_info->list_icon == NULL) | |
1558 return NULL; | |
12080 | 1559 |
13090 | 1560 protoname = prpl_info->list_icon(account, NULL); |
12080 | 1561 if (protoname == NULL) |
1562 return NULL; | |
1563 | |
1564 /* | |
1565 * Status icons will be themeable too, and then it will look up | |
1566 * protoname from the theme | |
1567 */ | |
1568 g_snprintf(buf, sizeof(buf), "%s.png", protoname); | |
1569 | |
1570 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", | |
1571 "default", buf, NULL); | |
13090 | 1572 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
12080 | 1573 g_free(filename); |
1574 | |
13109 | 1575 scaled = gdk_pixbuf_scale_simple(pixbuf, 32*scale_factor, |
1576 32*scale_factor, GDK_INTERP_BILINEAR); | |
13090 | 1577 g_object_unref(pixbuf); |
1578 | |
1579 return scaled; | |
1580 } | |
1581 | |
1582 static GdkPixbuf * | |
1583 overlay_status_onto_icon(GdkPixbuf *pixbuf, GaimStatusPrimitive primitive) | |
1584 { | |
1585 const char *type_name; | |
13113
7a05525e4197
[gaim-migrate @ 15475]
Richard Laager <rlaager@wiktel.com>
parents:
13109
diff
changeset
|
1586 char basename[256]; |
13090 | 1587 char *filename; |
1588 GdkPixbuf *emblem; | |
1589 | |
1590 type_name = gaim_primitive_get_id_from_type(primitive); | |
1591 | |
13113
7a05525e4197
[gaim-migrate @ 15475]
Richard Laager <rlaager@wiktel.com>
parents:
13109
diff
changeset
|
1592 g_snprintf(basename, sizeof(basename), "%s.png", type_name); |
13090 | 1593 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", |
1594 "default", basename, NULL); | |
1595 emblem = gdk_pixbuf_new_from_file(filename, NULL); | |
1596 g_free(filename); | |
1597 | |
1598 if (emblem != NULL) { | |
13091 | 1599 int width, height, emblem_width, emblem_height; |
1600 int new_emblem_width, new_emblem_height; | |
1601 | |
13090 | 1602 width = gdk_pixbuf_get_width(pixbuf); |
1603 height = gdk_pixbuf_get_height(pixbuf); | |
1604 emblem_width = gdk_pixbuf_get_width(emblem); | |
1605 emblem_height = gdk_pixbuf_get_height(emblem); | |
13091 | 1606 |
1607 /* | |
1608 * Figure out how big to make the emblem. Normally the emblem | |
1609 * will have half the width of the pixbuf. But we don't make | |
1610 * an emblem any smaller than 10 pixels because it becomes | |
1611 * unrecognizable, unless the width of the pixbuf is less than | |
1612 * 10 pixels, in which case we make the emblem width the same | |
1613 * as the pixbuf width. | |
1614 */ | |
1615 new_emblem_width = MAX(width / 2, MIN(width, 10)); | |
1616 new_emblem_height = MAX(height / 2, MIN(height, 10)); | |
1617 | |
13090 | 1618 /* Overlay emblem onto the bottom right corner of pixbuf */ |
1619 gdk_pixbuf_composite(emblem, pixbuf, | |
1620 width - new_emblem_width, height - new_emblem_height, | |
1621 new_emblem_width, new_emblem_height, | |
1622 width - new_emblem_width, height - new_emblem_height, | |
1623 (double)new_emblem_width / (double)emblem_width, | |
1624 (double)new_emblem_height / (double)emblem_height, | |
1625 GDK_INTERP_BILINEAR, | |
1626 255); | |
1627 g_object_unref(emblem); | |
1628 } | |
1629 | |
1630 return pixbuf; | |
12080 | 1631 } |
1632 | |
1633 GdkPixbuf * | |
13090 | 1634 gaim_gtk_create_prpl_icon_with_status(GaimAccount *account, GaimStatusType *status_type, double scale_factor) |
12080 | 1635 { |
13090 | 1636 GdkPixbuf *pixbuf; |
1637 | |
1638 pixbuf = gaim_gtk_create_prpl_icon(account, scale_factor); | |
1639 if (pixbuf == NULL) | |
1640 return NULL; | |
12080 | 1641 |
13090 | 1642 /* |
1643 * TODO: Let the prpl pick the emblem on a per status basis, | |
1644 * and only use the primitive as a fallback? | |
1645 */ | |
12080 | 1646 |
13090 | 1647 return overlay_status_onto_icon(pixbuf, |
1648 gaim_status_type_get_primitive(status_type)); | |
1649 } | |
12080 | 1650 |
13090 | 1651 GdkPixbuf * |
1652 gaim_gtk_create_gaim_icon_with_status(GaimStatusPrimitive primitive, double scale_factor) | |
1653 { | |
1654 gchar *filename; | |
1655 GdkPixbuf *orig, *pixbuf; | |
12080 | 1656 |
13090 | 1657 filename = g_build_filename(DATADIR, "pixmaps", "gaim.png", NULL); |
1658 orig = gdk_pixbuf_new_from_file(filename, NULL); | |
1659 g_free(filename); | |
1660 if (orig == NULL) | |
1661 return NULL; | |
12080 | 1662 |
13109 | 1663 pixbuf = gdk_pixbuf_scale_simple(orig, 32*scale_factor, |
1664 32*scale_factor, GDK_INTERP_BILINEAR); | |
13090 | 1665 g_object_unref(G_OBJECT(orig)); |
1666 | |
1667 return overlay_status_onto_icon(pixbuf, primitive); | |
12080 | 1668 } |
1669 | |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1670 static void |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1671 menu_action_cb(GtkMenuItem *item, gpointer object) |
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 gpointer data; |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1674 void (*callback)(gpointer, gpointer); |
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 callback = g_object_get_data(G_OBJECT(item), "gaimcallback"); |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1677 data = g_object_get_data(G_OBJECT(item), "gaimcallbackdata"); |
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 if (callback) |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1680 callback(object, data); |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1681 } |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1682 |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1683 void |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1684 gaim_gtk_append_menu_action(GtkWidget *menu, GaimMenuAction *act, |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1685 gpointer object) |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1686 { |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1687 if (act == NULL) { |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1688 gaim_separator(menu); |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1689 } else { |
13781
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13469
diff
changeset
|
1690 GtkWidget *menuitem; |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1691 |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1692 if (act->children == NULL) { |
13781
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13469
diff
changeset
|
1693 menuitem = gtk_menu_item_new_with_mnemonic(act->label); |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1694 |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1695 if (act->callback != NULL) { |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1696 g_object_set_data(G_OBJECT(menuitem), |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1697 "gaimcallback", |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1698 act->callback); |
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 "gaimcallbackdata", |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1701 act->data); |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1702 g_signal_connect(G_OBJECT(menuitem), "activate", |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1703 G_CALLBACK(menu_action_cb), |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1704 object); |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1705 } else { |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1706 gtk_widget_set_sensitive(menuitem, FALSE); |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1707 } |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1708 |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1709 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1710 } else { |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1711 GList *l = NULL; |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1712 GtkWidget *submenu = NULL; |
13781
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13469
diff
changeset
|
1713 GtkAccelGroup *group; |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1714 |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1715 menuitem = gtk_menu_item_new_with_mnemonic(act->label); |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1716 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1717 |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1718 submenu = gtk_menu_new(); |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1719 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1720 |
13781
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13469
diff
changeset
|
1721 group = gtk_menu_get_accel_group(GTK_MENU(menu)); |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13469
diff
changeset
|
1722 if (group) { |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13469
diff
changeset
|
1723 char *path = g_strdup_printf("%s/%s", GTK_MENU_ITEM(menuitem)->accel_path, act->label); |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13469
diff
changeset
|
1724 gtk_menu_set_accel_path(GTK_MENU(submenu), path); |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13469
diff
changeset
|
1725 g_free(path); |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13469
diff
changeset
|
1726 gtk_menu_set_accel_group(GTK_MENU(submenu), group); |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13469
diff
changeset
|
1727 } |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13469
diff
changeset
|
1728 |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1729 for (l = act->children; l; l = l->next) { |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1730 GaimMenuAction *act = (GaimMenuAction *)l->data; |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1731 |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1732 gaim_gtk_append_menu_action(submenu, act, object); |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1733 } |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1734 g_list_free(act->children); |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1735 act->children = NULL; |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1736 } |
13102
5828d42e8684
[gaim-migrate @ 15464]
Richard Laager <rlaager@wiktel.com>
parents:
13101
diff
changeset
|
1737 gaim_menu_action_free(act); |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1738 } |
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12905
diff
changeset
|
1739 } |
13360
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1740 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1741 #if GTK_CHECK_VERSION(2,3,0) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1742 # define NEW_STYLE_COMPLETION |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1743 #endif |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1744 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1745 #ifndef NEW_STYLE_COMPLETION |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1746 typedef struct |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1747 { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1748 GCompletion *completion; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1749 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1750 gboolean completion_started; |
13364
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
1751 gboolean all; |
13360
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1752 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1753 } GaimGtkCompletionData; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1754 #endif |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1755 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1756 #ifndef NEW_STYLE_COMPLETION |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1757 static gboolean |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1758 completion_entry_event(GtkEditable *entry, GdkEventKey *event, |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1759 GaimGtkCompletionData *data) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1760 { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1761 int pos, end_pos; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1762 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1763 if (event->type == GDK_KEY_PRESS && event->keyval == GDK_Tab) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1764 { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1765 gtk_editable_get_selection_bounds(entry, &pos, &end_pos); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1766 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1767 if (data->completion_started && |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1768 pos != end_pos && pos > 1 && |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1769 end_pos == strlen(gtk_entry_get_text(GTK_ENTRY(entry)))) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1770 { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1771 gtk_editable_select_region(entry, 0, 0); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1772 gtk_editable_set_position(entry, -1); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1773 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1774 return TRUE; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1775 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1776 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1777 else if (event->type == GDK_KEY_PRESS && event->length > 0) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1778 { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1779 char *prefix, *nprefix; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1780 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1781 gtk_editable_get_selection_bounds(entry, &pos, &end_pos); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1782 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1783 if (data->completion_started && |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1784 pos != end_pos && pos > 1 && |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1785 end_pos == strlen(gtk_entry_get_text(GTK_ENTRY(entry)))) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1786 { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1787 char *temp; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1788 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1789 temp = gtk_editable_get_chars(entry, 0, pos); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1790 prefix = g_strconcat(temp, event->string, NULL); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1791 g_free(temp); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1792 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1793 else if (pos == end_pos && pos > 1 && |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1794 end_pos == strlen(gtk_entry_get_text(GTK_ENTRY(entry)))) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1795 { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1796 prefix = g_strconcat(gtk_entry_get_text(GTK_ENTRY(entry)), |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1797 event->string, NULL); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1798 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1799 else |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1800 return FALSE; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1801 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1802 pos = strlen(prefix); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1803 nprefix = NULL; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1804 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1805 g_completion_complete(data->completion, prefix, &nprefix); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1806 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1807 if (nprefix != NULL) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1808 { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1809 gtk_entry_set_text(GTK_ENTRY(entry), nprefix); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1810 gtk_editable_set_position(entry, pos); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1811 gtk_editable_select_region(entry, pos, -1); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1812 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1813 data->completion_started = TRUE; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1814 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1815 g_free(nprefix); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1816 g_free(prefix); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1817 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1818 return TRUE; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1819 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1820 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1821 g_free(prefix); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1822 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1823 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1824 return FALSE; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1825 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1826 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1827 static void |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1828 destroy_completion_data(GtkWidget *w, GaimGtkCompletionData *data) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1829 { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1830 g_list_foreach(data->completion->items, (GFunc)g_free, NULL); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1831 g_completion_free(data->completion); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1832 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1833 g_free(data); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1834 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1835 #endif /* !NEW_STYLE_COMPLETION */ |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1836 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1837 #ifdef NEW_STYLE_COMPLETION |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1838 static gboolean screenname_completion_match_func(GtkEntryCompletion *completion, |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1839 const gchar *key, GtkTreeIter *iter, gpointer user_data) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1840 { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1841 GtkTreeModel *model; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1842 GValue val1; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1843 GValue val2; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1844 const char *tmp; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1845 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1846 model = gtk_entry_completion_get_model (completion); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1847 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1848 val1.g_type = 0; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1849 gtk_tree_model_get_value(model, iter, 2, &val1); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1850 tmp = g_value_get_string(&val1); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1851 if (tmp != NULL && gaim_str_has_prefix(tmp, key)) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1852 { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1853 g_value_unset(&val1); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1854 return TRUE; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1855 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1856 g_value_unset(&val1); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1857 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1858 val2.g_type = 0; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1859 gtk_tree_model_get_value(model, iter, 3, &val2); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1860 tmp = g_value_get_string(&val2); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1861 if (tmp != NULL && gaim_str_has_prefix(tmp, key)) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1862 { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1863 g_value_unset(&val2); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1864 return TRUE; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1865 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1866 g_value_unset(&val2); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1867 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1868 return FALSE; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1869 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1870 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1871 static gboolean screenname_completion_match_selected_cb(GtkEntryCompletion *completion, |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1872 GtkTreeModel *model, GtkTreeIter *iter, gpointer *user_data) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1873 { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1874 GValue val; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1875 GtkWidget *optmenu = user_data[1]; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1876 GaimAccount *account; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1877 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1878 val.g_type = 0; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1879 gtk_tree_model_get_value(model, iter, 1, &val); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1880 gtk_entry_set_text(GTK_ENTRY(user_data[0]), g_value_get_string(&val)); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1881 g_value_unset(&val); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1882 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1883 gtk_tree_model_get_value(model, iter, 4, &val); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1884 account = g_value_get_pointer(&val); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1885 g_value_unset(&val); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1886 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1887 if (account == NULL) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1888 return TRUE; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1889 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1890 if (optmenu != NULL) { |
13371
1299f8f51b07
[gaim-migrate @ 15744]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13366
diff
changeset
|
1891 GList *items; |
1299f8f51b07
[gaim-migrate @ 15744]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13366
diff
changeset
|
1892 guint index = 0; |
13360
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1893 gaim_gtk_account_option_menu_set_selected(optmenu, account); |
13371
1299f8f51b07
[gaim-migrate @ 15744]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13366
diff
changeset
|
1894 items = GTK_MENU_SHELL(gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)))->children; |
13360
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1895 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1896 do { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1897 if (account == g_object_get_data(G_OBJECT(items->data), "account")) { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1898 /* Set the account in the GUI. */ |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1899 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), index); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1900 return TRUE; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1901 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1902 index++; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1903 } while ((items = items->next) != NULL); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1904 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1905 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1906 return TRUE; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1907 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1908 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1909 static void |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1910 add_screenname_autocomplete_entry(GtkListStore *store, const char *buddy_alias, const char *contact_alias, |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1911 const GaimAccount *account, const char *screenname) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1912 { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1913 GtkTreeIter iter; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1914 gboolean completion_added = FALSE; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1915 gchar *normalized_screenname; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1916 gchar *tmp; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1917 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1918 tmp = g_utf8_normalize(screenname, -1, G_NORMALIZE_DEFAULT); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1919 normalized_screenname = g_utf8_casefold(tmp, -1); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1920 g_free(tmp); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1921 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1922 /* There's no sense listing things like: 'xxx "xxx"' |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1923 when the screenname and buddy alias match. */ |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1924 if (buddy_alias && strcmp(buddy_alias, screenname)) { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1925 char *completion_entry = g_strdup_printf("%s \"%s\"", screenname, buddy_alias); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1926 char *tmp2 = g_utf8_normalize(buddy_alias, -1, G_NORMALIZE_DEFAULT); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1927 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1928 tmp = g_utf8_casefold(tmp2, -1); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1929 g_free(tmp2); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1930 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1931 gtk_list_store_append(store, &iter); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1932 gtk_list_store_set(store, &iter, |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1933 0, completion_entry, |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1934 1, screenname, |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1935 2, normalized_screenname, |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1936 3, tmp, |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1937 4, account, |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1938 -1); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1939 g_free(completion_entry); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1940 g_free(tmp); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1941 completion_added = TRUE; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1942 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1943 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1944 /* There's no sense listing things like: 'xxx "xxx"' |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1945 when the screenname and contact alias match. */ |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1946 if (contact_alias && strcmp(contact_alias, screenname)) { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1947 /* We don't want duplicates when the contact and buddy alias match. */ |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1948 if (!buddy_alias || strcmp(contact_alias, buddy_alias)) { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1949 char *completion_entry = g_strdup_printf("%s \"%s\"", |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1950 screenname, contact_alias); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1951 char *tmp2 = g_utf8_normalize(contact_alias, -1, G_NORMALIZE_DEFAULT); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1952 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1953 tmp = g_utf8_casefold(tmp2, -1); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1954 g_free(tmp2); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1955 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1956 gtk_list_store_append(store, &iter); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1957 gtk_list_store_set(store, &iter, |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1958 0, completion_entry, |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1959 1, screenname, |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1960 2, normalized_screenname, |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1961 3, tmp, |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1962 4, account, |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1963 -1); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1964 g_free(completion_entry); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1965 g_free(tmp); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1966 completion_added = TRUE; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1967 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1968 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1969 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1970 if (completion_added == FALSE) { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1971 /* Add the buddy's screenname. */ |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1972 gtk_list_store_append(store, &iter); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1973 gtk_list_store_set(store, &iter, |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1974 0, screenname, |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1975 1, screenname, |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1976 2, normalized_screenname, |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1977 3, NULL, |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1978 4, account, |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1979 -1); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1980 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1981 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1982 g_free(normalized_screenname); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1983 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1984 #endif /* NEW_STYLE_COMPLETION */ |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1985 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1986 static void get_log_set_name(GaimLogSet *set, gpointer value, gpointer **set_hash_data) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1987 { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1988 /* 1. Don't show buddies because we will have gotten them already. |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1989 * 2. Only show those with non-NULL accounts that are currently connected. |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1990 * 3. The boxes that use this autocomplete code handle only IMs. */ |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1991 if (!set->buddy && |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1992 (GPOINTER_TO_INT(set_hash_data[1]) || |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1993 (set->account != NULL && gaim_account_is_connected(set->account))) && |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1994 set->type == GAIM_LOG_IM) { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1995 #ifdef NEW_STYLE_COMPLETION |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1996 add_screenname_autocomplete_entry((GtkListStore *)set_hash_data[0], |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1997 NULL, NULL, set->account, set->name); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1998 #else |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1999 GList **items = ((GList **)set_hash_data[0]); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2000 /* Steal the name for the GCompletion. */ |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2001 *items = g_list_append(*items, set->name); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2002 set->name = set->normalized_name = NULL; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2003 #endif /* NEW_STYLE_COMPLETION */ |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2004 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2005 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2006 |
13364
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2007 #ifdef NEW_STYLE_COMPLETION |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2008 static void |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2009 add_completion_list(GtkListStore *store) |
13360
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2010 { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2011 GaimBlistNode *gnode, *cnode, *bnode; |
13364
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2012 gboolean all = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(store), "screenname-all")); |
13360
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2013 GHashTable *sets; |
13364
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2014 gpointer set_hash_data[] = {store, GINT_TO_POINTER(all)}; |
13360
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2015 |
13364
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2016 gtk_list_store_clear(store); |
13360
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2017 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2018 for (gnode = gaim_get_blist()->root; gnode != NULL; gnode = gnode->next) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2019 { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2020 if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2021 continue; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2022 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2023 for (cnode = gnode->child; cnode != NULL; cnode = cnode->next) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2024 { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2025 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode)) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2026 continue; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2027 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2028 for (bnode = cnode->child; bnode != NULL; bnode = bnode->next) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2029 { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2030 GaimBuddy *buddy = (GaimBuddy *)bnode; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2031 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2032 if (!all && !gaim_account_is_connected(buddy->account)) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2033 continue; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2034 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2035 add_screenname_autocomplete_entry(store, |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2036 ((GaimContact *)cnode)->alias, |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2037 gaim_buddy_get_contact_alias(buddy), |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2038 buddy->account, |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2039 buddy->name |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2040 ); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2041 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2042 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2043 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2044 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2045 sets = gaim_log_get_log_sets(); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2046 g_hash_table_foreach(sets, (GHFunc)get_log_set_name, &set_hash_data); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2047 g_hash_table_destroy(sets); |
13364
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2048 } |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2049 #else |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2050 static void |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2051 add_completion_list(GaimGtkCompletionData *data) |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2052 { |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2053 GaimBlistNode *gnode, *cnode, *bnode; |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2054 GCompletion *completion; |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2055 GList *item = g_list_append(NULL, NULL); |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2056 GHashTable *sets; |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2057 gpointer set_hash_data[2]; |
13360
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2058 |
13364
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2059 completion = data->completion; |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2060 |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2061 g_list_foreach(completion->items, (GFunc)g_free, NULL); |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2062 g_completion_clear_items(completion); |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2063 |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2064 for (gnode = gaim_get_blist()->root; gnode != NULL; gnode = gnode->next) |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2065 { |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2066 if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2067 continue; |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2068 |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2069 for (cnode = gnode->child; cnode != NULL; cnode = cnode->next) |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2070 { |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2071 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode)) |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2072 continue; |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2073 |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2074 for (bnode = cnode->child; bnode != NULL; bnode = bnode->next) |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2075 { |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2076 GaimBuddy *buddy = (GaimBuddy *)bnode; |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2077 |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2078 if (!data->all && !gaim_account_is_connected(buddy->account)) |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2079 continue; |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2080 |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2081 item->data = g_strdup(buddy->name); |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2082 g_completion_add_items(data->completion, item); |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2083 } |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2084 } |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2085 } |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2086 g_list_free(item); |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2087 |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2088 sets = gaim_log_get_log_sets(); |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2089 item = NULL; |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2090 set_hash_data[0] = &item; |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2091 set_hash_data[1] = GINT_TO_POINTER(data->all); |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2092 g_hash_table_foreach(sets, (GHFunc)get_log_set_name, &set_hash_data); |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2093 g_hash_table_destroy(sets); |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2094 g_completion_add_items(data->completion, item); |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2095 g_list_free(item); |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2096 } |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2097 #endif |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2098 |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2099 static void |
13366
0758db6d46ac
[gaim-migrate @ 15739]
Richard Laager <rlaager@wiktel.com>
parents:
13365
diff
changeset
|
2100 screenname_autocomplete_destroyed_cb(GtkWidget *widget, gpointer data) |
13364
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2101 { |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2102 gaim_signals_disconnect_by_handle(widget); |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2103 } |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2104 |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2105 static void |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2106 repopulate_autocomplete(gpointer something, gpointer data) |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2107 { |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2108 add_completion_list(data); |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2109 } |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2110 |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2111 void |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2112 gaim_gtk_setup_screenname_autocomplete(GtkWidget *entry, GtkWidget *accountopt, gboolean all) |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2113 { |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2114 gpointer cb_data = NULL; |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2115 |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2116 #ifdef NEW_STYLE_COMPLETION |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2117 /* Store the displayed completion value, the screenname, the UTF-8 normalized & casefolded screenname, |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2118 * the UTF-8 normalized & casefolded value for comparison, and the account. */ |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2119 GtkListStore *store = gtk_list_store_new(5, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2120 |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2121 GtkEntryCompletion *completion; |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2122 gpointer *data; |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2123 |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2124 g_object_set_data(G_OBJECT(store), "screenname-all", GINT_TO_POINTER(all)); |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2125 add_completion_list(store); |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2126 |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2127 cb_data = store; |
13360
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2128 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2129 /* Sort the completion list by screenname. */ |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2130 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store), |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2131 1, GTK_SORT_ASCENDING); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2132 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2133 completion = gtk_entry_completion_new(); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2134 gtk_entry_completion_set_match_func(completion, screenname_completion_match_func, NULL, NULL); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2135 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2136 data = g_new0(gpointer, 2); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2137 data[0] = entry; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2138 data[1] = accountopt; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2139 g_signal_connect(G_OBJECT(completion), "match-selected", |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2140 G_CALLBACK(screenname_completion_match_selected_cb), data); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2141 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2142 gtk_entry_set_completion(GTK_ENTRY(entry), completion); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2143 g_object_unref(completion); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2144 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2145 gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(store)); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2146 g_object_unref(store); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2147 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2148 gtk_entry_completion_set_text_column(completion, 0); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2149 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2150 #else /* !NEW_STYLE_COMPLETION */ |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2151 GaimGtkCompletionData *data; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2152 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2153 data = g_new0(GaimGtkCompletionData, 1); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2154 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2155 data->completion = g_completion_new(NULL); |
13364
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2156 data->all = all; |
13360
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2157 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2158 g_completion_set_compare(data->completion, g_ascii_strncasecmp); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2159 |
13364
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2160 add_completion_list(data); |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2161 cb_data = data; |
13360
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2162 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2163 g_signal_connect(G_OBJECT(entry), "event", |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2164 G_CALLBACK(completion_entry_event), data); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2165 g_signal_connect(G_OBJECT(entry), "destroy", |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2166 G_CALLBACK(destroy_completion_data), data); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2167 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2168 #endif /* !NEW_STYLE_COMPLETION */ |
13364
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2169 |
13365
143233089386
[gaim-migrate @ 15738]
Richard Laager <rlaager@wiktel.com>
parents:
13364
diff
changeset
|
2170 if (!all) |
143233089386
[gaim-migrate @ 15738]
Richard Laager <rlaager@wiktel.com>
parents:
13364
diff
changeset
|
2171 { |
143233089386
[gaim-migrate @ 15738]
Richard Laager <rlaager@wiktel.com>
parents:
13364
diff
changeset
|
2172 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", entry, |
143233089386
[gaim-migrate @ 15738]
Richard Laager <rlaager@wiktel.com>
parents:
13364
diff
changeset
|
2173 GAIM_CALLBACK(repopulate_autocomplete), cb_data); |
143233089386
[gaim-migrate @ 15738]
Richard Laager <rlaager@wiktel.com>
parents:
13364
diff
changeset
|
2174 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", entry, |
143233089386
[gaim-migrate @ 15738]
Richard Laager <rlaager@wiktel.com>
parents:
13364
diff
changeset
|
2175 GAIM_CALLBACK(repopulate_autocomplete), cb_data); |
143233089386
[gaim-migrate @ 15738]
Richard Laager <rlaager@wiktel.com>
parents:
13364
diff
changeset
|
2176 } |
143233089386
[gaim-migrate @ 15738]
Richard Laager <rlaager@wiktel.com>
parents:
13364
diff
changeset
|
2177 |
13364
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2178 gaim_signal_connect(gaim_accounts_get_handle(), "account-added", entry, |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2179 GAIM_CALLBACK(repopulate_autocomplete), cb_data); |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2180 gaim_signal_connect(gaim_accounts_get_handle(), "account-removed", entry, |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2181 GAIM_CALLBACK(repopulate_autocomplete), cb_data); |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2182 |
3b7abce487f5
[gaim-migrate @ 15737]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
2183 g_signal_connect(G_OBJECT(entry), "destroy", G_CALLBACK(screenname_autocomplete_destroyed_cb), NULL); |
13360
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2184 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
2185 |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13371
diff
changeset
|
2186 void gaim_gtk_set_cursor(GtkWidget *widget, GdkCursorType cursor_type) |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13371
diff
changeset
|
2187 { |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13371
diff
changeset
|
2188 GdkCursor *cursor; |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13371
diff
changeset
|
2189 |
13469
689f652480f7
[gaim-migrate @ 15845]
Richard Laager <rlaager@wiktel.com>
parents:
13434
diff
changeset
|
2190 g_return_if_fail(widget != NULL); |
689f652480f7
[gaim-migrate @ 15845]
Richard Laager <rlaager@wiktel.com>
parents:
13434
diff
changeset
|
2191 if (widget->window == NULL) |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13371
diff
changeset
|
2192 return; |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13371
diff
changeset
|
2193 |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13371
diff
changeset
|
2194 cursor = gdk_cursor_new(GDK_WATCH); |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13371
diff
changeset
|
2195 gdk_window_set_cursor(widget->window, cursor); |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13371
diff
changeset
|
2196 gdk_cursor_unref(cursor); |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13371
diff
changeset
|
2197 |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13371
diff
changeset
|
2198 #if GTK_CHECK_VERSION(2,4,0) |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13371
diff
changeset
|
2199 gdk_display_flush(gdk_drawable_get_display(GDK_DRAWABLE(widget->window))); |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13371
diff
changeset
|
2200 #else |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13371
diff
changeset
|
2201 gdk_flush(); |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13371
diff
changeset
|
2202 #endif |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13371
diff
changeset
|
2203 } |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13371
diff
changeset
|
2204 |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13371
diff
changeset
|
2205 void gaim_gtk_clear_cursor(GtkWidget *widget) |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13371
diff
changeset
|
2206 { |
13469
689f652480f7
[gaim-migrate @ 15845]
Richard Laager <rlaager@wiktel.com>
parents:
13434
diff
changeset
|
2207 g_return_if_fail(widget != NULL); |
689f652480f7
[gaim-migrate @ 15845]
Richard Laager <rlaager@wiktel.com>
parents:
13434
diff
changeset
|
2208 if (widget->window == NULL) |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13371
diff
changeset
|
2209 return; |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13371
diff
changeset
|
2210 |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13371
diff
changeset
|
2211 gdk_window_set_cursor(widget->window, NULL); |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13371
diff
changeset
|
2212 } |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13371
diff
changeset
|
2213 |
14133 | 2214 struct _icon_chooser { |
2215 GtkWidget *icon_filesel; | |
2216 GtkWidget *icon_preview; | |
2217 GtkWidget *icon_text; | |
2218 | |
2219 void (*callback)(const char*,gpointer); | |
2220 gpointer data; | |
2221 }; | |
2222 | |
2223 #if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ | |
2224 static void | |
2225 icon_filesel_delete_cb(GtkWidget *w, struct _icon_chooser *dialog) | |
2226 { | |
2227 if (dialog->icon_filesel != NULL) | |
2228 gtk_widget_destroy(dialog->icon_filesel); | |
2229 | |
2230 if (dialog->callback) | |
2231 dialog->callback(NULL, data); | |
2232 | |
2233 g_free(dialog); | |
2234 } | |
2235 #endif /* FILECHOOSER */ | |
2236 | |
2237 | |
2238 | |
2239 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ | |
2240 static void | |
2241 icon_filesel_choose_cb(GtkWidget *widget, gint response, struct _icon_chooser *dialog) | |
2242 { | |
2243 char *filename, *current_folder; | |
2244 | |
2245 if (response != GTK_RESPONSE_ACCEPT) { | |
2246 if (response == GTK_RESPONSE_CANCEL) { | |
2247 gtk_widget_destroy(dialog->icon_filesel); | |
2248 } | |
2249 dialog->icon_filesel = NULL; | |
2250 if (dialog->callback) | |
2251 dialog->callback(NULL, dialog->data); | |
2252 g_free(dialog); | |
2253 return; | |
2254 } | |
2255 | |
2256 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog->icon_filesel)); | |
2257 current_folder = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(dialog->icon_filesel)); | |
2258 if (current_folder != NULL) { | |
2259 gaim_prefs_set_string("/gaim/gtk/filelocations/last_icon_folder", current_folder); | |
2260 g_free(current_folder); | |
2261 } | |
2262 | |
2263 #else /* FILECHOOSER */ | |
2264 static void | |
2265 icon_filesel_choose_cb(GtkWidget *w, AccountPrefsDialog *dialog) | |
2266 { | |
2267 char *filename, *current_folder; | |
2268 | |
2269 filename = g_strdup(gtk_file_selection_get_filename( | |
2270 GTK_FILE_SELECTION(dialog->icon_filesel))); | |
2271 | |
2272 /* If they typed in a directory, change there */ | |
2273 if (gaim_gtk_check_if_dir(filename, | |
2274 GTK_FILE_SELECTION(dialog->icon_filesel))) | |
2275 { | |
2276 g_free(filename); | |
2277 return; | |
2278 } | |
2279 | |
2280 current_folder = g_path_get_dirname(filename); | |
2281 if (current_folder != NULL) { | |
2282 gaim_prefs_set_string("/gaim/gtk/filelocations/last_icon_folder", current_folder); | |
2283 g_free(current_folder); | |
2284 } | |
2285 | |
2286 #endif /* FILECHOOSER */ | |
2287 if (dialog->callback) | |
2288 dialog->callback(filename, dialog->data); | |
2289 gtk_widget_destroy(dialog->icon_filesel); | |
2290 g_free(filename); | |
2291 g_free(dialog); | |
2292 } | |
2293 | |
2294 | |
2295 static void | |
2296 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ | |
2297 icon_preview_change_cb(GtkFileChooser *widget, struct _icon_chooser *dialog) | |
2298 #else /* FILECHOOSER */ | |
2299 icon_preview_change_cb(GtkTreeSelection *sel, struct _icon_chooser *dialog) | |
2300 #endif /* FILECHOOSER */ | |
2301 { | |
2302 GdkPixbuf *pixbuf, *scale; | |
2303 int height, width; | |
2304 char *basename, *markup, *size; | |
2305 struct stat st; | |
2306 char *filename; | |
2307 | |
2308 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ | |
2309 filename = gtk_file_chooser_get_preview_filename( | |
2310 GTK_FILE_CHOOSER(dialog->icon_filesel)); | |
2311 #else /* FILECHOOSER */ | |
2312 filename = g_strdup(gtk_file_selection_get_filename( | |
2313 GTK_FILE_SELECTION(dialog->icon_filesel))); | |
2314 #endif /* FILECHOOSER */ | |
2315 | |
2316 if (!filename || g_stat(filename, &st)) | |
2317 { | |
2318 g_free(filename); | |
2319 return; | |
2320 } | |
2321 | |
2322 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
2323 if (!pixbuf) { | |
2324 gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->icon_preview), NULL); | |
2325 gtk_label_set_markup(GTK_LABEL(dialog->icon_text), ""); | |
2326 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ | |
2327 gtk_file_chooser_set_preview_widget_active( | |
2328 GTK_FILE_CHOOSER(dialog->icon_filesel), FALSE); | |
2329 #endif /* FILECHOOSER */ | |
2330 g_free(filename); | |
2331 return; | |
2332 } | |
2333 | |
2334 width = gdk_pixbuf_get_width(pixbuf); | |
2335 height = gdk_pixbuf_get_height(pixbuf); | |
2336 basename = g_path_get_basename(filename); | |
2337 size = gaim_str_size_to_units(st.st_size); | |
2338 markup = g_strdup_printf(_("<b>File:</b> %s\n" | |
2339 "<b>File size:</b> %s\n" | |
2340 "<b>Image size:</b> %dx%d"), | |
2341 basename, size, width, height); | |
2342 | |
2343 scale = gdk_pixbuf_scale_simple(pixbuf, width * 50 / height, | |
2344 50, GDK_INTERP_BILINEAR); | |
2345 gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->icon_preview), scale); | |
2346 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ | |
2347 gtk_file_chooser_set_preview_widget_active( | |
2348 GTK_FILE_CHOOSER(dialog->icon_filesel), TRUE); | |
2349 #endif /* FILECHOOSER */ | |
2350 gtk_label_set_markup(GTK_LABEL(dialog->icon_text), markup); | |
2351 | |
2352 g_object_unref(G_OBJECT(pixbuf)); | |
2353 g_object_unref(G_OBJECT(scale)); | |
2354 g_free(filename); | |
2355 g_free(basename); | |
2356 g_free(size); | |
2357 g_free(markup); | |
2358 } | |
2359 | |
2360 | |
14141 | 2361 GtkWidget *gaim_gtk_buddy_icon_chooser_new(GtkWindow *parent, void(*callback)(const char *, gpointer), gpointer data) { |
14133 | 2362 struct _icon_chooser *dialog = g_new0(struct _icon_chooser, 1); |
2363 | |
2364 #if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ | |
2365 GtkWidget *hbox; | |
2366 GtkWidget *tv; | |
2367 GtkTreeSelection *sel; | |
2368 #endif /* FILECHOOSER */ | |
2369 const char *current_folder; | |
2370 | |
2371 dialog->callback = callback; | |
2372 dialog->data = data; | |
2373 | |
2374 if (dialog->icon_filesel != NULL) { | |
2375 gtk_window_present(GTK_WINDOW(dialog->icon_filesel)); | |
2376 return NULL; | |
2377 } | |
2378 | |
2379 current_folder = gaim_prefs_get_string("/gaim/gtk/filelocations/last_icon_folder"); | |
2380 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ | |
2381 | |
2382 dialog->icon_filesel = gtk_file_chooser_dialog_new(_("Buddy Icon"), | |
2383 parent, | |
2384 GTK_FILE_CHOOSER_ACTION_OPEN, | |
2385 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
2386 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, | |
2387 NULL); | |
2388 gtk_dialog_set_default_response(GTK_DIALOG(dialog->icon_filesel), GTK_RESPONSE_ACCEPT); | |
2389 if ((current_folder != NULL) && (*current_folder != '\0')) | |
2390 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog->icon_filesel), | |
2391 current_folder); | |
2392 | |
2393 dialog->icon_preview = gtk_image_new(); | |
2394 dialog->icon_text = gtk_label_new(NULL); | |
2395 gtk_widget_set_size_request(GTK_WIDGET(dialog->icon_preview), -1, 50); | |
2396 gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog->icon_filesel), | |
2397 GTK_WIDGET(dialog->icon_preview)); | |
2398 g_signal_connect(G_OBJECT(dialog->icon_filesel), "update-preview", | |
2399 G_CALLBACK(icon_preview_change_cb), dialog); | |
2400 g_signal_connect(G_OBJECT(dialog->icon_filesel), "response", | |
2401 G_CALLBACK(icon_filesel_choose_cb), dialog); | |
2402 icon_preview_change_cb(NULL, dialog); | |
2403 #else /* FILECHOOSER */ | |
2404 dialog->icon_filesel = gtk_file_selection_new(_("Buddy Icon")); | |
2405 dialog->icon_preview = gtk_image_new(); | |
2406 dialog->icon_text = gtk_label_new(NULL); | |
2407 if ((current_folder != NULL) && (*current_folder != '\0')) | |
2408 gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog->icon_filesel), | |
2409 current_folder); | |
2410 | |
2411 gtk_widget_set_size_request(GTK_WIDGET(dialog->icon_preview), -1, 50); | |
2412 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
2413 gtk_box_pack_start( | |
2414 GTK_BOX(GTK_FILE_SELECTION(dialog->icon_filesel)->main_vbox), | |
2415 hbox, FALSE, FALSE, 0); | |
2416 gtk_box_pack_end(GTK_BOX(hbox), dialog->icon_preview, | |
2417 FALSE, FALSE, 0); | |
2418 gtk_box_pack_end(GTK_BOX(hbox), dialog->icon_text, FALSE, FALSE, 0); | |
2419 | |
2420 tv = GTK_FILE_SELECTION(dialog->icon_filesel)->file_list; | |
2421 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv)); | |
2422 | |
2423 g_signal_connect(G_OBJECT(sel), "changed", | |
2424 G_CALLBACK(icon_preview_change_cb), dialog); | |
2425 g_signal_connect( | |
2426 G_OBJECT(GTK_FILE_SELECTION(dialog->icon_filesel)->ok_button), | |
2427 "clicked", | |
2428 G_CALLBACK(icon_filesel_choose_cb), dialog); | |
2429 g_signal_connect( | |
2430 G_OBJECT(GTK_FILE_SELECTION(dialog->icon_filesel)->cancel_button), | |
2431 "clicked", | |
2432 G_CALLBACK(icon_filesel_delete_cb), dialog); | |
2433 g_signal_connect(G_OBJECT(dialog->icon_filesel), "destroy", | |
2434 G_CALLBACK(icon_filesel_delete_cb), dialog); | |
2435 #endif /* FILECHOOSER */ | |
2436 return dialog->icon_filesel; | |
2437 } | |
2438 | |
2439 | |
2440 #if GTK_CHECK_VERSION(2,2,0) | |
2441 static gboolean | |
2442 str_array_match(char **a, char **b) | |
2443 { | |
2444 int i, j; | |
2445 | |
2446 if (!a || !b) | |
2447 return FALSE; | |
2448 for (i = 0; a[i] != NULL; i++) | |
2449 for (j = 0; b[j] != NULL; j++) | |
2450 if (!g_ascii_strcasecmp(a[i], b[j])) | |
2451 return TRUE; | |
2452 return FALSE; | |
2453 } | |
2454 #endif | |
2455 | |
14144 | 2456 char * |
14133 | 2457 gaim_gtk_convert_buddy_icon(GaimPlugin *plugin, const char *path) |
2458 { | |
2459 #if GTK_CHECK_VERSION(2,2,0) | |
2460 int width, height; | |
2461 char **pixbuf_formats = NULL; | |
2462 GdkPixbufFormat *format; | |
2463 GdkPixbuf *pixbuf; | |
14141 | 2464 GaimPluginProtocolInfo *prpl_info; |
2465 char **prpl_formats; | |
14133 | 2466 #if !GTK_CHECK_VERSION(2,4,0) |
2467 GdkPixbufLoader *loader; | |
2468 FILE *file; | |
2469 struct stat st; | |
2470 void *data = NULL; | |
2471 #endif | |
2472 #endif | |
14141 | 2473 const char *dirname; |
2474 char *random; | |
2475 char *filename; | |
2476 | |
2477 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); | |
2478 | |
2479 g_return_val_if_fail(prpl_info->icon_spec.format != NULL, NULL); | |
2480 | |
2481 prpl_formats = g_strsplit(prpl_info->icon_spec.format,",",0); | |
2482 dirname = gaim_buddy_icons_get_cache_dir(); | |
2483 random = g_strdup_printf("%x", g_random_int()); | |
2484 filename = g_build_filename(dirname, random, NULL); | |
14133 | 2485 |
2486 if (!g_file_test(dirname, G_FILE_TEST_IS_DIR)) { | |
2487 gaim_debug_info("buddyicon", "Creating icon cache directory.\n"); | |
2488 | |
2489 if (g_mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0) { | |
2490 gaim_debug_error("buddyicon", | |
2491 "Unable to create directory %s: %s\n", | |
2492 dirname, strerror(errno)); | |
2493 #if GTK_CHECK_VERSION(2,2,0) | |
2494 g_strfreev(prpl_formats); | |
2495 #endif | |
2496 g_free(random); | |
2497 g_free(filename); | |
2498 return NULL; | |
2499 } | |
2500 } | |
2501 | |
2502 #if GTK_CHECK_VERSION(2,2,0) | |
2503 #if GTK_CHECK_VERSION(2,4,0) | |
2504 format = gdk_pixbuf_get_file_info (path, &width, &height); | |
2505 #else | |
2506 loader = gdk_pixbuf_loader_new(); | |
2507 if (!g_stat(path, &st) && (file = g_fopen(path, "rb")) != NULL) { | |
2508 data = g_malloc(st.st_size); | |
2509 fread(data, 1, st.st_size, file); | |
2510 fclose(file); | |
2511 gdk_pixbuf_loader_write(loader, data, st.st_size, NULL); | |
2512 g_free(data); | |
2513 } | |
2514 gdk_pixbuf_loader_close(loader, NULL); | |
2515 pixbuf = gdk_pixbuf_loader_get_pixbuf(loader); | |
2516 width = gdk_pixbuf_get_width(pixbuf); | |
2517 height = gdk_pixbuf_get_height(pixbuf); | |
2518 format = gdk_pixbuf_loader_get_format(loader); | |
2519 g_object_unref(G_OBJECT(loader)); | |
2520 #endif | |
14144 | 2521 if (format == NULL) |
2522 return NULL; | |
14133 | 2523 pixbuf_formats = gdk_pixbuf_format_get_extensions(format); |
2524 | |
2525 if (str_array_match(pixbuf_formats, prpl_formats) && /* This is an acceptable format AND */ | |
2526 (!(prpl_info->icon_spec.scale_rules & GAIM_ICON_SCALE_SEND) || /* The prpl doesn't scale before it sends OR */ | |
2527 (prpl_info->icon_spec.min_width <= width && | |
2528 prpl_info->icon_spec.max_width >= width && | |
2529 prpl_info->icon_spec.min_height <= height && | |
2530 prpl_info->icon_spec.max_height >= height))) /* The icon is the correct size */ | |
2531 #endif | |
2532 { | |
2533 gchar *contents; | |
2534 gsize length; | |
2535 FILE *image; | |
2536 | |
2537 #if GTK_CHECK_VERSION(2,2,0) | |
2538 g_strfreev(prpl_formats); | |
2539 g_strfreev(pixbuf_formats); | |
2540 #endif | |
2541 | |
2542 /* Copy the image to the cache folder as "filename". */ | |
2543 | |
2544 if (!g_file_get_contents(path, &contents, &length, NULL) || | |
2545 (image = g_fopen(filename, "wb")) == NULL) | |
2546 { | |
2547 g_free(random); | |
2548 g_free(filename); | |
2549 #if GTK_CHECK_VERSION(2,2,0) && !GTK_CHECK_VERSION(2,4,0) | |
2550 g_object_unref(G_OBJECT(pixbuf)); | |
2551 #endif | |
2552 return NULL; | |
2553 } | |
2554 | |
2555 if (fwrite(contents, 1, length, image) != length) | |
2556 { | |
2557 fclose(image); | |
2558 g_unlink(filename); | |
2559 | |
2560 g_free(random); | |
2561 g_free(filename); | |
2562 #if GTK_CHECK_VERSION(2,2,0) && !GTK_CHECK_VERSION(2,4,0) | |
2563 g_object_unref(G_OBJECT(pixbuf)); | |
2564 #endif | |
2565 return NULL; | |
2566 } | |
2567 fclose(image); | |
2568 | |
2569 #if GTK_CHECK_VERSION(2,2,0) && !GTK_CHECK_VERSION(2,4,0) | |
2570 g_object_unref(G_OBJECT(pixbuf)); | |
2571 #endif | |
2572 | |
2573 g_free(filename); | |
2574 return random; | |
2575 } | |
2576 #if GTK_CHECK_VERSION(2,2,0) | |
2577 else | |
2578 { | |
2579 int i; | |
2580 GError *error = NULL; | |
2581 GdkPixbuf *scale; | |
2582 pixbuf = gdk_pixbuf_new_from_file(path, &error); | |
2583 g_strfreev(pixbuf_formats); | |
2584 if (!error && (prpl_info->icon_spec.scale_rules & GAIM_ICON_SCALE_SEND) && | |
2585 (width < prpl_info->icon_spec.min_width || | |
2586 width > prpl_info->icon_spec.max_width || | |
2587 height < prpl_info->icon_spec.min_height || | |
2588 height > prpl_info->icon_spec.max_height)) | |
2589 { | |
2590 int new_width = width; | |
2591 int new_height = height; | |
2592 | |
2593 if(new_width > prpl_info->icon_spec.max_width) | |
2594 new_width = prpl_info->icon_spec.max_width; | |
2595 else if(new_width < prpl_info->icon_spec.min_width) | |
2596 new_width = prpl_info->icon_spec.min_width; | |
2597 if(new_height > prpl_info->icon_spec.max_height) | |
2598 new_height = prpl_info->icon_spec.max_height; | |
2599 else if(new_height < prpl_info->icon_spec.min_height) | |
2600 new_height = prpl_info->icon_spec.min_height; | |
2601 | |
2602 /* preserve aspect ratio */ | |
2603 if ((double)height * (double)new_width > | |
2604 (double)width * (double)new_height) { | |
2605 new_width = 0.5 + (double)width * (double)new_height / (double)height; | |
2606 } else { | |
2607 new_height = 0.5 + (double)height * (double)new_width / (double)width; | |
2608 } | |
2609 | |
2610 scale = gdk_pixbuf_scale_simple (pixbuf, new_width, new_height, | |
2611 GDK_INTERP_HYPER); | |
2612 g_object_unref(G_OBJECT(pixbuf)); | |
2613 pixbuf = scale; | |
2614 } | |
2615 if (error) { | |
2616 g_free(random); | |
2617 g_free(filename); | |
2618 gaim_debug_error("buddyicon", "Could not open icon for conversion: %s\n", error->message); | |
2619 g_error_free(error); | |
2620 g_strfreev(prpl_formats); | |
2621 return NULL; | |
2622 } | |
2623 | |
2624 for (i = 0; prpl_formats[i]; i++) { | |
2625 gaim_debug_info("buddyicon", "Converting buddy icon to %s as %s\n", prpl_formats[i], filename); | |
2626 /* The gdk-pixbuf documentation is wrong. gdk_pixbuf_save returns TRUE if it was successful, | |
2627 * FALSE if an error was set. */ | |
2628 if (gdk_pixbuf_save (pixbuf, filename, prpl_formats[i], &error, NULL) == TRUE) | |
2629 break; | |
2630 gaim_debug_warning("buddyicon", "Could not convert to %s: %s\n", prpl_formats[i], error->message); | |
2631 g_error_free(error); | |
2632 error = NULL; | |
2633 } | |
2634 g_strfreev(prpl_formats); | |
2635 if (!error) { | |
2636 g_object_unref(G_OBJECT(pixbuf)); | |
2637 g_free(filename); | |
2638 return random; | |
2639 } else { | |
2640 gaim_debug_error("buddyicon", "Could not convert icon to usable format: %s\n", error->message); | |
2641 g_error_free(error); | |
2642 } | |
2643 g_free(random); | |
2644 g_free(filename); | |
2645 g_object_unref(G_OBJECT(pixbuf)); | |
2646 } | |
2647 return NULL; | |
2648 #endif | |
2649 } |