Mercurial > pidgin
comparison src/gtksavedstatuses.c @ 12195:d040123d2b69
[gaim-migrate @ 14497]
A saved status dropdown.
I don't know if it works, because the only way for me to test it right now
is through remote X, over 3000 miles away.
And I ain't puttin up with that for long. I'm going to check it out when I
get home and fix it up locally.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Wed, 23 Nov 2005 02:04:59 +0000 |
parents | 81c63578aa39 |
children | 0a549a454d8e |
comparison
equal
deleted
inserted
replaced
12194:a1a835fae1dc | 12195:d040123d2b69 |
---|---|
1448 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); | 1448 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); |
1449 | 1449 |
1450 gtk_widget_show(win); | 1450 gtk_widget_show(win); |
1451 } | 1451 } |
1452 | 1452 |
1453 /************************************************************************** | |
1454 * Utilities * | |
1455 **************************************************************************/ | |
1456 | |
1457 void status_menu_cb(GtkComboBox *widget, void(*callback)(GaimSavedStatus*)) | |
1458 { | |
1459 GtkTreeIter iter; | |
1460 char *title; | |
1461 gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget), &iter); | |
1462 gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(widget)), &iter, | |
1463 STATUS_WINDOW_COLUMN_TITLE, &title, | |
1464 -1); | |
1465 callback(gaim_savedstatus_find(title)); | |
1466 } | |
1467 | |
1468 GtkWidget *gaim_gtk_status_menu(GaimSavedStatus *current_status, GCallback callback) | |
1469 { | |
1470 GtkWidget *combobox; | |
1471 const GList *saved_statuses; | |
1472 GtkCellRenderer *rend; | |
1473 int i; | |
1474 int index = -1; | |
1475 GtkListStore *ls = gtk_list_store_new(STATUS_WINDOW_NUM_COLUMNS, | |
1476 G_TYPE_STRING, | |
1477 G_TYPE_STRING, | |
1478 G_TYPE_STRING); | |
1479 | |
1480 | |
1481 for (saved_statuses = gaim_savedstatuses_get_all(), i = 0; | |
1482 saved_statuses != NULL; | |
1483 saved_statuses = g_list_next(saved_statuses), i++) { | |
1484 add_status_to_saved_status_list(ls, saved_statuses->data); | |
1485 if (saved_statuses->data == current_status) | |
1486 index = i; | |
1487 } | |
1488 | |
1489 combobox = gtk_combo_box_new_with_model(GTK_TREE_MODEL(ls)); | |
1490 rend = gtk_cell_renderer_text_new(); | |
1491 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combobox), rend, TRUE); | |
1492 gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(combobox), rend, "text", | |
1493 STATUS_WINDOW_COLUMN_TITLE); | |
1494 #if GTK_CHECK_VERSION(2,6,0) | |
1495 g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
1496 #endif | |
1497 | |
1498 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), index); | |
1499 g_signal_connect(G_OBJECT(combobox), "changed", G_CALLBACK(status_menu_cb), callback); | |
1500 return combobox; | |
1501 } | |
1502 | |
1453 | 1503 |
1454 /************************************************************************** | 1504 /************************************************************************** |
1455 * GTK+ saved status glue | 1505 * GTK+ saved status glue |
1456 **************************************************************************/ | 1506 **************************************************************************/ |
1457 | 1507 |