Mercurial > pidgin
diff 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 |
line wrap: on
line diff
--- a/src/gtksavedstatuses.c Wed Nov 23 01:13:02 2005 +0000 +++ b/src/gtksavedstatuses.c Wed Nov 23 02:04:59 2005 +0000 @@ -1450,6 +1450,56 @@ gtk_widget_show(win); } +/************************************************************************** + * Utilities * + **************************************************************************/ + +void status_menu_cb(GtkComboBox *widget, void(*callback)(GaimSavedStatus*)) +{ + GtkTreeIter iter; + char *title; + gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget), &iter); + gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(widget)), &iter, + STATUS_WINDOW_COLUMN_TITLE, &title, + -1); + callback(gaim_savedstatus_find(title)); +} + +GtkWidget *gaim_gtk_status_menu(GaimSavedStatus *current_status, GCallback callback) +{ + GtkWidget *combobox; + const GList *saved_statuses; + GtkCellRenderer *rend; + int i; + int index = -1; + GtkListStore *ls = gtk_list_store_new(STATUS_WINDOW_NUM_COLUMNS, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_STRING); + + + for (saved_statuses = gaim_savedstatuses_get_all(), i = 0; + saved_statuses != NULL; + saved_statuses = g_list_next(saved_statuses), i++) { + add_status_to_saved_status_list(ls, saved_statuses->data); + if (saved_statuses->data == current_status) + index = i; + } + + combobox = gtk_combo_box_new_with_model(GTK_TREE_MODEL(ls)); + rend = gtk_cell_renderer_text_new(); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combobox), rend, TRUE); + gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(combobox), rend, "text", + STATUS_WINDOW_COLUMN_TITLE); +#if GTK_CHECK_VERSION(2,6,0) + g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); +#endif + + gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), index); + g_signal_connect(G_OBJECT(combobox), "changed", G_CALLBACK(status_menu_cb), callback); + return combobox; +} + /************************************************************************** * GTK+ saved status glue