Commit 3ecda06b0697bd809e7824029135a09a943bd45f
1 parent
fee0eaf0
Exists in
master
and in
4 other branches
Implementing action list widget.
Showing
1 changed file
with
18 additions
and
2 deletions
Show diff stats
src/objects/actions/view.c
| ... | ... | @@ -37,6 +37,12 @@ |
| 37 | 37 | #include <pw3270/actions.h> |
| 38 | 38 | #include <lib3270/log.h> |
| 39 | 39 | |
| 40 | + enum { | |
| 41 | + COLUMN_PIXBUF, | |
| 42 | + COLUMN_LABEL, | |
| 43 | + COLUMN_ACTION_NAME | |
| 44 | + }; | |
| 45 | + | |
| 40 | 46 | struct ListElement { |
| 41 | 47 | GAction * action; |
| 42 | 48 | GtkImage * image; |
| ... | ... | @@ -48,7 +54,7 @@ |
| 48 | 54 | |
| 49 | 55 | GtkWidget * pw3270_action_view_new() { |
| 50 | 56 | |
| 51 | - GtkWidget * view = GTK_WIDGET(gtk_tree_view_new_with_model(GTK_TREE_MODEL(gtk_list_store_new(1,G_TYPE_OBJECT)))); | |
| 57 | + GtkWidget * view = GTK_WIDGET(gtk_tree_view_new_with_model(GTK_TREE_MODEL(gtk_list_store_new(3,G_TYPE_OBJECT,G_TYPE_STRING,G_TYPE_STRING)))); | |
| 52 | 58 | |
| 53 | 59 | gtk_widget_set_hexpand(view,TRUE); |
| 54 | 60 | gtk_widget_set_vexpand(view,TRUE); |
| ... | ... | @@ -56,13 +62,23 @@ |
| 56 | 62 | |
| 57 | 63 | // Create Renderers |
| 58 | 64 | GtkCellRenderer * text_renderer = gtk_cell_renderer_text_new(); |
| 65 | + GtkCellRenderer * pixbuf_renderer = gtk_cell_renderer_pixbuf_new(); | |
| 66 | + | |
| 67 | + gtk_tree_view_insert_column_with_attributes( | |
| 68 | + GTK_TREE_VIEW(view), | |
| 69 | + -1, | |
| 70 | + _("Icon"), | |
| 71 | + pixbuf_renderer, | |
| 72 | + "pixbuf",COLUMN_PIXBUF, | |
| 73 | + NULL | |
| 74 | + ); | |
| 59 | 75 | |
| 60 | 76 | gtk_tree_view_insert_column_with_attributes( |
| 61 | 77 | GTK_TREE_VIEW(view), |
| 62 | 78 | -1, |
| 63 | 79 | _("Label"), |
| 64 | 80 | text_renderer, |
| 65 | - "text",0, | |
| 81 | + "text",COLUMN_LABEL, | |
| 66 | 82 | NULL |
| 67 | 83 | ); |
| 68 | 84 | ... | ... |