diff options
author | Alan Fitton <ajf@eth0.org.uk> | 2011-10-26 18:55:21 +0000 |
---|---|---|
committer | Alan Fitton <ajf@eth0.org.uk> | 2011-10-26 18:55:21 +0000 |
commit | aff982298fb16ef8bbf32697df59965def50eb5d (patch) | |
tree | 185f87e687e7c312dd5e2835234ebaf32a326cfc /src/util.c | |
parent | ecf7d01164029d5b5cd139e7db8a5e8705c6fac5 (diff) |
closer to gtk3 support, I think just the graph needs doing now.
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -420,3 +420,34 @@ gchar *trg_base64encode(const gchar *filename) return b64out; } + +GtkWidget *gtr_combo_box_new_enum(const char *text_1, ...) +{ + GtkWidget *w; + GtkCellRenderer *r; + GtkListStore *store; + va_list vl; + const char *text; + va_start(vl, text_1); + + store = gtk_list_store_new(2, G_TYPE_INT, G_TYPE_STRING); + + text = text_1; + if (text != NULL) + do { + const int val = va_arg(vl, int); + gtk_list_store_insert_with_values(store, NULL, INT_MAX, 0, val, + 1, text, -1); + text = va_arg(vl, const char *); + } + while (text != NULL); + + w = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store)); + r = gtk_cell_renderer_text_new(); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(w), r, TRUE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(w), r, "text", 1, NULL); + + /* cleanup */ + g_object_unref(store); + return w; +} |