Mercurial > pidgin.yaz
annotate src/gtkstatusselector.c @ 10369:584c792dd15c
[gaim-migrate @ 11588]
this is overdue
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Tue, 14 Dec 2004 22:13:16 +0000 |
parents | 5879593a6a10 |
children | 6a043ae92db6 |
rev | line source |
---|---|
10178 | 1 /** |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10249
diff
changeset
|
2 * @file gtkstatusselector.c GTK+ Status selector widget |
10178 | 3 * @ingroup gtkui |
4 * | |
5 * gaim | |
6 * | |
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. | |
10 * | |
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 */ | |
25 #include "internal.h" | |
26 #include "gtkgaim.h" | |
27 #include "gtkimhtml.h" | |
28 #include "gtkstatusselector.h" | |
29 #include "gtkutils.h" | |
30 | |
31 #include "account.h" | |
32 #include "debug.h" | |
33 #include "prefs.h" | |
34 | |
35 struct _GaimGtkStatusSelectorPrivate | |
36 { | |
37 GtkWidget *combo; | |
38 GtkWidget *entry; | |
10191 | 39 GtkWidget *frame; |
10178 | 40 |
10347 | 41 GtkWidget *optmenu; |
42 GtkWidget *menu; | |
43 GtkSizeGroup *sg; | |
44 | |
10178 | 45 GtkListStore *model; |
10199 | 46 |
47 guint entry_timer; | |
10178 | 48 }; |
49 | |
50 enum | |
51 { | |
52 COLUMN_STATUS_TYPE_ID, | |
53 COLUMN_ICON, | |
54 COLUMN_NAME, | |
55 NUM_COLUMNS | |
56 }; | |
57 | |
10347 | 58 #define GAIM_SELECTOR_TEXT "gaim-text" |
59 #define GAIM_SELECTOR_STATUS_TYPE_ID "gaim-status-type-id" | |
60 | |
10178 | 61 static void gaim_gtk_status_selector_class_init(GaimGtkStatusSelectorClass *klass); |
62 static void gaim_gtk_status_selector_init(GaimGtkStatusSelector *selector); | |
63 static void gaim_gtk_status_selector_finalize(GObject *obj); | |
64 static void gaim_gtk_status_selector_destroy(GtkObject *obj); | |
65 static void status_switched_cb(GtkWidget *combo, GaimGtkStatusSelector *selector); | |
10199 | 66 static gboolean key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer user_data); |
10178 | 67 static void signed_on_off_cb(GaimConnection *gc, GaimGtkStatusSelector *selector); |
68 static void rebuild_list(GaimGtkStatusSelector *selector); | |
69 | |
70 static GtkVBox *parent_class = NULL; | |
71 | |
72 GType | |
73 gaim_gtk_status_selector_get_type(void) | |
74 { | |
75 static GType type = 0; | |
76 | |
77 if (!type) | |
78 { | |
79 static const GTypeInfo info = | |
80 { | |
81 sizeof(GaimGtkStatusSelectorClass), | |
82 NULL, | |
83 NULL, | |
84 (GClassInitFunc)gaim_gtk_status_selector_class_init, | |
85 NULL, | |
86 NULL, | |
87 sizeof(GaimGtkStatusSelector), | |
88 0, | |
89 (GInstanceInitFunc)gaim_gtk_status_selector_init | |
90 }; | |
91 | |
92 type = g_type_register_static(GTK_TYPE_VBOX, | |
93 "GaimGtkStatusSelector", &info, 0); | |
94 } | |
95 | |
96 return type; | |
97 } | |
98 | |
99 static void | |
100 gaim_gtk_status_selector_class_init(GaimGtkStatusSelectorClass *klass) | |
101 { | |
102 GObjectClass *gobject_class; | |
103 GtkObjectClass *object_class; | |
104 | |
105 parent_class = g_type_class_peek_parent(klass); | |
106 | |
107 gobject_class = G_OBJECT_CLASS(klass); | |
108 object_class = GTK_OBJECT_CLASS(klass); | |
109 | |
110 gobject_class->finalize = gaim_gtk_status_selector_finalize; | |
111 | |
112 object_class->destroy = gaim_gtk_status_selector_destroy; | |
113 } | |
114 | |
115 static void | |
116 gaim_gtk_status_selector_init(GaimGtkStatusSelector *selector) | |
117 { | |
10225 | 118 #if GTK_CHECK_VERSION(2,4,0) |
10178 | 119 GtkWidget *combo; |
10347 | 120 GtkCellRenderer *renderer; |
121 #else | |
122 GtkWidget *optmenu; | |
123 #endif | |
10178 | 124 GtkWidget *entry; |
10191 | 125 GtkWidget *toolbar; |
126 GtkWidget *frame; | |
10178 | 127 |
128 selector->priv = g_new0(GaimGtkStatusSelectorPrivate, 1); | |
129 | |
130 #if GTK_CHECK_VERSION(2,4,0) | |
131 selector->priv->model = gtk_list_store_new(NUM_COLUMNS, G_TYPE_POINTER, | |
10347 | 132 GDK_TYPE_PIXBUF, G_TYPE_STRING); |
10178 | 133 |
134 combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(selector->priv->model)); | |
135 selector->priv->combo = combo; | |
136 | |
137 g_object_unref(G_OBJECT(selector->priv->model)); | |
138 | |
139 renderer = gtk_cell_renderer_pixbuf_new(); | |
140 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, FALSE); | |
141 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, | |
142 "pixbuf", COLUMN_ICON, | |
143 NULL); | |
144 | |
145 renderer = gtk_cell_renderer_text_new(); | |
146 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, TRUE); | |
147 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, | |
148 "text", COLUMN_NAME, | |
149 NULL); | |
150 | |
151 g_signal_connect(G_OBJECT(combo), "changed", | |
152 G_CALLBACK(status_switched_cb), selector); | |
153 | |
154 /* TODO */ | |
155 | |
156 | |
157 gtk_widget_show(combo); | |
158 gtk_box_pack_start(GTK_BOX(selector), combo, FALSE, FALSE, 0); | |
159 | |
10347 | 160 |
161 #else /* GTK < 2.4.0 */ | |
162 selector->priv->optmenu = optmenu = gtk_option_menu_new(); | |
163 gtk_widget_show(optmenu); | |
164 | |
165 selector->priv->menu = gtk_menu_new(); | |
166 gtk_widget_show(selector->priv->menu); | |
167 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), selector->priv->menu); | |
168 | |
169 selector->priv->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
170 | |
171 g_signal_connect(G_OBJECT(optmenu), "changed", | |
172 G_CALLBACK(status_switched_cb), selector); | |
173 | |
174 gtk_box_pack_start(GTK_BOX(selector), optmenu, FALSE, FALSE, 0); | |
175 #endif | |
176 | |
10191 | 177 frame = gaim_gtk_create_imhtml(TRUE, &entry, &toolbar); |
178 selector->priv->entry = entry; | |
179 selector->priv->frame = frame; | |
180 gtk_widget_set_name(entry, "gaim_gtkstatusselector_imhtml"); | |
181 gtk_box_pack_start(GTK_BOX(selector), frame, TRUE, TRUE, 0); | |
182 gtk_widget_hide(toolbar); | |
10178 | 183 |
10199 | 184 g_signal_connect(G_OBJECT(entry), "key_press_event", |
10347 | 185 G_CALLBACK(key_press_cb), selector); |
10199 | 186 |
10178 | 187 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", |
10347 | 188 selector, GAIM_CALLBACK(signed_on_off_cb), |
189 selector); | |
10178 | 190 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", |
10347 | 191 selector, GAIM_CALLBACK(signed_on_off_cb), |
192 selector); | |
10178 | 193 |
194 rebuild_list(selector); | |
195 } | |
196 | |
197 static void | |
198 gaim_gtk_status_selector_finalize(GObject *obj) | |
199 { | |
200 GaimGtkStatusSelector *selector; | |
201 | |
202 g_return_if_fail(obj != NULL); | |
203 g_return_if_fail(GAIM_GTK_IS_STATUS_SELECTOR(obj)); | |
204 | |
205 selector = GAIM_GTK_STATUS_SELECTOR(obj); | |
206 | |
10347 | 207 if (selector->priv->sg) { |
208 g_object_unref(selector->priv->sg); | |
209 selector->priv->sg = NULL; | |
210 } | |
211 | |
10178 | 212 g_free(selector->priv); |
213 | |
214 if (G_OBJECT_CLASS(parent_class)->finalize) | |
215 G_OBJECT_CLASS(parent_class)->finalize(obj); | |
216 } | |
217 | |
218 static void | |
219 gaim_gtk_status_selector_destroy(GtkObject *obj) | |
220 { | |
221 GaimGtkStatusSelector *selector; | |
222 | |
223 g_return_if_fail(obj != NULL); | |
224 g_return_if_fail(GAIM_GTK_IS_STATUS_SELECTOR(obj)); | |
225 | |
226 selector = GAIM_GTK_STATUS_SELECTOR(obj); | |
227 | |
10187 | 228 gaim_signals_disconnect_by_handle(selector); |
10249 | 229 if (selector->priv->entry_timer != 0) |
230 gaim_timeout_remove(selector->priv->entry_timer); | |
10187 | 231 |
10178 | 232 if (GTK_OBJECT_CLASS(parent_class)->destroy) |
233 GTK_OBJECT_CLASS(parent_class)->destroy(obj); | |
234 } | |
235 | |
10347 | 236 static gboolean |
237 get_selected_data(GaimGtkStatusSelector *selector, const char **text, const char **status_type_id) | |
238 { | |
10225 | 239 #if GTK_CHECK_VERSION(2,4,0) |
10347 | 240 GtkTreeIter iter; |
241 | |
242 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(selector->priv->combo), | |
243 &iter)) | |
244 return FALSE; | |
245 | |
246 gtk_tree_model_get(GTK_TREE_MODEL(selector->priv->model), &iter, | |
247 COLUMN_NAME, text, | |
248 COLUMN_STATUS_TYPE_ID, status_type_id, | |
249 -1); | |
250 return TRUE; | |
251 #else | |
252 GtkWidget *item; | |
253 int i; | |
254 GList *l; | |
255 | |
256 i = gtk_option_menu_get_history(GTK_OPTION_MENU(selector->priv->optmenu)); | |
257 l = GTK_MENU_SHELL(selector->priv->menu)->children; | |
258 item = g_list_nth_data(l, i); | |
259 *text = g_object_get_data(G_OBJECT(item), GAIM_SELECTOR_TEXT); | |
260 *status_type_id = g_object_get_data(G_OBJECT(item), GAIM_SELECTOR_STATUS_TYPE_ID); | |
261 return TRUE; | |
262 #endif | |
263 return FALSE; | |
264 } | |
265 | |
10178 | 266 static void |
267 status_switched_cb(GtkWidget *combo, GaimGtkStatusSelector *selector) | |
268 { | |
10347 | 269 const char *status_type_id = NULL; |
270 const char *text = NULL; | |
10178 | 271 |
10347 | 272 if (!get_selected_data(selector, &text, &status_type_id)) |
10188 | 273 return; |
10178 | 274 |
10191 | 275 if (status_type_id == NULL) |
276 { | |
277 if (!strcmp(text, _("New Status"))) | |
278 { | |
279 /* TODO */ | |
280 } | |
281 } | |
10197 | 282 else |
10188 | 283 { |
10199 | 284 /* |
285 * If the chosen status does not require a message, then set the | |
286 * status immediately. Otherwise just register a timeout and the | |
287 * status will be set whenever the user stops typing the message. | |
288 */ | |
289 GList *l; | |
10188 | 290 GtkTextBuffer *buffer; |
291 gboolean allow_message = FALSE; | |
10178 | 292 |
10188 | 293 buffer = |
294 gtk_text_view_get_buffer(GTK_TEXT_VIEW(selector->priv->entry)); | |
295 | |
10199 | 296 gtk_text_buffer_set_text(buffer, text, -1); |
297 | |
298 for (l = gaim_connections_get_all(); l != NULL; l = l->next) | |
299 { | |
300 GaimConnection *gc = (GaimConnection *)l->data; | |
301 GaimAccount *account = gaim_connection_get_account(gc); | |
302 GaimStatusType *status_type; | |
303 | |
304 status_type = gaim_account_get_status_type(account, | |
305 status_type_id); | |
306 | |
307 if (status_type == NULL) | |
308 continue; | |
309 | |
310 if (gaim_status_type_get_attr(status_type, "message") != NULL) | |
311 { | |
312 allow_message = TRUE; | |
313 } | |
314 else | |
315 { | |
316 gaim_account_set_status(account, | |
317 status_type_id, TRUE, | |
318 NULL); | |
319 } | |
320 } | |
321 | |
322 if (allow_message) | |
323 { | |
324 gtk_widget_show(selector->priv->frame); | |
325 key_press_cb(NULL, NULL, selector); | |
326 } | |
327 else | |
328 gtk_widget_hide(selector->priv->frame); | |
329 } | |
330 } | |
331 | |
332 static gboolean | |
333 insert_text_timeout_cb(gpointer data) | |
334 { | |
335 GaimGtkStatusSelector *selector = (GaimGtkStatusSelector *)data; | |
336 const char *status_type_id; | |
337 const char *text; | |
338 | |
10347 | 339 if (!get_selected_data(selector, &text, &status_type_id)) |
10199 | 340 return FALSE; |
341 | |
342 if (status_type_id == NULL) | |
343 { | |
344 if (!strcmp(text, _("New Status"))) | |
345 { | |
346 /* TODO */ | |
347 } | |
348 } | |
349 else | |
350 { | |
351 gchar *message; | |
352 GList *l; | |
353 | |
354 message = gtk_imhtml_get_markup(GTK_IMHTML(selector->priv->entry)); | |
10188 | 355 |
356 for (l = gaim_connections_get_all(); l != NULL; l = l->next) | |
10178 | 357 { |
10188 | 358 GaimConnection *gc = (GaimConnection *)l->data; |
359 GaimAccount *account = gaim_connection_get_account(gc); | |
360 GaimStatusType *status_type; | |
10178 | 361 |
10188 | 362 status_type = gaim_account_get_status_type(account, |
10347 | 363 status_type_id); |
10178 | 364 |
10188 | 365 if (status_type == NULL) |
366 continue; | |
10178 | 367 |
10188 | 368 if (gaim_status_type_get_attr(status_type, "message") != NULL) |
10178 | 369 { |
10188 | 370 gaim_account_set_status(account, |
10347 | 371 status_type_id, TRUE, |
372 "message", message, | |
373 NULL); | |
10188 | 374 } |
375 } | |
10199 | 376 } |
10178 | 377 |
10199 | 378 return FALSE; |
379 } | |
380 | |
381 /** | |
382 * The user typed in the IMHTML entry widget. If the user is finished | |
383 * typing then we want to set the appropriate status message. So let's | |
384 * wait 3 seconds, and if they haven't typed anything else then set the | |
385 * status message. | |
386 */ | |
387 static gboolean | |
388 key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer user_data) | |
389 { | |
390 GaimGtkStatusSelector *selector = (GaimGtkStatusSelector *)user_data; | |
391 | |
392 if (selector->priv->entry_timer != 0) { | |
393 gaim_timeout_remove(selector->priv->entry_timer); | |
10178 | 394 } |
10199 | 395 |
396 selector->priv->entry_timer = gaim_timeout_add(3000, insert_text_timeout_cb, | |
397 selector); | |
398 | |
399 return FALSE; | |
10178 | 400 } |
401 | |
402 static void | |
403 signed_on_off_cb(GaimConnection *gc, GaimGtkStatusSelector *selector) | |
404 { | |
405 rebuild_list(selector); | |
406 } | |
407 | |
408 static GdkPixbuf * | |
409 load_icon(const char *basename) | |
410 { | |
411 char *filename; | |
412 GdkPixbuf *pixbuf, *scale = NULL; | |
413 | |
414 if (!strcmp(basename, "available.png")) | |
415 basename = "online.png"; | |
416 else if (!strcmp(basename, "hidden.png")) | |
417 basename = "invisible.png"; | |
418 | |
419 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "icons", | |
420 basename, NULL); | |
421 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
422 g_free(filename); | |
423 | |
424 if (pixbuf != NULL) | |
425 { | |
426 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, | |
427 GDK_INTERP_BILINEAR); | |
428 | |
429 g_object_unref(G_OBJECT(pixbuf)); | |
430 } | |
431 else | |
432 { | |
433 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", | |
434 "default", basename, NULL); | |
435 scale = gdk_pixbuf_new_from_file(filename, NULL); | |
436 g_free(filename); | |
437 } | |
438 | |
439 return scale; | |
440 } | |
441 | |
442 static void | |
443 add_item(GaimGtkStatusSelector *selector, const char *status_type_id, | |
444 const char *text, GdkPixbuf *pixbuf) | |
445 { | |
10347 | 446 #if GTK_CHECK_VERSION(2,4,0) |
10178 | 447 GtkTreeIter iter; |
448 | |
449 gtk_list_store_append(selector->priv->model, &iter); | |
450 gtk_list_store_set(selector->priv->model, &iter, | |
451 COLUMN_STATUS_TYPE_ID, status_type_id, | |
452 COLUMN_ICON, pixbuf, | |
453 COLUMN_NAME, text, | |
454 -1); | |
10347 | 455 #else |
456 GtkWidget *image = gtk_image_new_from_pixbuf(pixbuf); | |
457 GtkWidget *item, *hbox, *label; | |
458 | |
459 /* Create the item. */ | |
460 item = gtk_menu_item_new(); | |
461 | |
462 /* Create the hbox. */ | |
463 hbox = gtk_hbox_new(FALSE, 4); | |
464 gtk_container_add(GTK_CONTAINER(item), hbox); | |
465 gtk_widget_show(hbox); | |
466 | |
467 gtk_size_group_add_widget(selector->priv->sg, image); | |
468 | |
469 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); | |
470 gtk_widget_show(image); | |
471 | |
472 /* Create the label. */ | |
473 label = gtk_label_new(text); | |
474 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | |
475 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
476 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); | |
477 gtk_widget_show(label); | |
478 | |
479 g_object_set_data_full(G_OBJECT(item), GAIM_SELECTOR_TEXT, g_strdup(text), g_free); | |
480 g_object_set_data_full(G_OBJECT(item), GAIM_SELECTOR_STATUS_TYPE_ID, g_strdup(status_type_id), g_free); | |
481 | |
482 gtk_menu_shell_append(GTK_MENU_SHELL(selector->priv->menu), item); | |
483 gtk_widget_show(item); | |
484 gaim_set_accessible_label(item, label); | |
485 #endif | |
10178 | 486 |
487 if (pixbuf != NULL) | |
488 g_object_unref(G_OBJECT(pixbuf)); | |
489 } | |
490 | |
10347 | 491 |
10178 | 492 static void |
493 rebuild_list(GaimGtkStatusSelector *selector) | |
494 { | |
495 gboolean single_prpl = TRUE; | |
496 GaimAccount *first_account = NULL; | |
497 const char *first_prpl_type = NULL; | |
498 GList *l; | |
499 | |
500 g_return_if_fail(selector != NULL); | |
501 g_return_if_fail(GAIM_GTK_IS_STATUS_SELECTOR(selector)); | |
502 | |
10347 | 503 #if GTK_CHECK_VERSION(2,4,0) |
10178 | 504 gtk_list_store_clear(selector->priv->model); |
10347 | 505 #else |
506 gtk_option_menu_remove_menu(GTK_OPTION_MENU(selector->priv->optmenu)); | |
507 /* XXX this automaticly destroys the menu, right? */ | |
508 selector->priv->menu = gtk_menu_new(); | |
509 gtk_widget_show(selector->priv->menu); | |
510 #endif | |
10178 | 511 |
512 /* | |
10352 | 513 * If no accounts are connected then gray ourself out and get |
514 * outta hee. | |
515 */ | |
516 if (gaim_connections_get_all() == NULL) | |
517 { | |
518 gtk_widget_set_sensitive(GTK_WIDGET(selector), FALSE); | |
519 return; | |
520 } | |
521 gtk_widget_set_sensitive(GTK_WIDGET(selector), TRUE); | |
522 | |
523 /* | |
10178 | 524 * If the user only has one IM account or one type of IM account |
525 * connected, they'll see all their statuses. This is ideal for those | |
526 * who use only one account, or one single protocol. Everyone else | |
527 * gets Available and Away and a list of saved statuses. | |
528 */ | |
529 for (l = gaim_connections_get_all(); l != NULL && single_prpl; l = l->next) | |
530 { | |
531 GaimConnection *gc = (GaimConnection *)l->data; | |
532 GaimAccount *account = gaim_connection_get_account(gc); | |
533 GaimPluginProtocolInfo *prpl_info; | |
534 const char *basename; | |
535 | |
536 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
537 basename = prpl_info->list_icon(account, NULL); | |
538 | |
539 if (first_prpl_type == NULL) | |
540 { | |
541 first_prpl_type = basename; | |
542 first_account = account; | |
543 } | |
10179
97ee3bf7bcf7
[gaim-migrate @ 11294]
Christian Hammond <chipx86@chipx86.com>
parents:
10178
diff
changeset
|
544 else if (strcmp(first_prpl_type, basename)) |
10178 | 545 single_prpl = FALSE; |
546 } | |
547 | |
548 if (single_prpl) | |
549 { | |
550 const GList *l; | |
551 | |
552 for (l = gaim_account_get_status_types(first_account); | |
553 l != NULL; | |
554 l = l->next) | |
555 { | |
556 GaimStatusType *status_type = (GaimStatusType *)l->data; | |
557 char filename[BUFSIZ]; | |
558 | |
559 if (!gaim_status_type_is_user_settable(status_type)) | |
560 continue; | |
561 | |
10207 | 562 /* |
563 * TODO Find a way to fallback to the GaimStatusPrimitive | |
564 * if an icon for this id does not exist. | |
565 */ | |
10178 | 566 g_snprintf(filename, sizeof(filename), "%s.png", |
567 gaim_status_type_get_id(status_type)); | |
568 | |
569 add_item(selector, | |
570 gaim_status_type_get_id(status_type), | |
571 gaim_status_type_get_name(status_type), | |
572 load_icon(filename)); | |
573 } | |
574 } | |
575 else | |
576 { | |
577 add_item(selector, "available", _("Available"), | |
578 load_icon("online.png")); | |
579 add_item(selector, "away", _("Away"), load_icon("away.png")); | |
580 } | |
581 | |
10191 | 582 /* TODO: Add saved statuses here? */ |
583 | |
10178 | 584 add_item(selector, NULL, _("New Status"), |
10347 | 585 gtk_widget_render_icon(GTK_WIDGET(selector), GTK_STOCK_NEW, |
586 GTK_ICON_SIZE_MENU, NULL)); | |
587 #if !GTK_CHECK_VERSION(2,4,0) | |
588 gtk_option_menu_set_menu(GTK_OPTION_MENU(selector->priv->optmenu), selector->priv->menu); | |
589 #endif | |
10178 | 590 } |
591 | |
592 GtkWidget * | |
593 gaim_gtk_status_selector_new(void) | |
594 { | |
595 GaimGtkStatusSelector *selector; | |
596 | |
597 selector = g_object_new(GAIM_GTK_TYPE_STATUS_SELECTOR, NULL); | |
598 | |
599 return GTK_WIDGET(selector); | |
600 } |