1
2 #include <stdlib.h>
3 #include "ast-model.h"
4 #include "ast-inspect.h"
5 #include "ast-view.h"
6
7 static GtkWidget *
create_view_and_model(void * ptr)8 create_view_and_model (void *ptr)
9 {
10 GtkTreeViewColumn *text;
11 GtkCellRenderer *renderer;
12 AstNode *root;
13 GtkWidget *view;
14
15 root = ast_new(NULL, 0, "", ptr, inspect_symbol_list);
16
17 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(root));
18
19 g_object_unref(root); /* destroy store automatically with view */
20
21 renderer = gtk_cell_renderer_text_new();
22 text = gtk_tree_view_column_new_with_attributes("Node", renderer,
23 "text", AST_COL_NAME,
24 NULL);
25 gtk_tree_view_append_column(GTK_TREE_VIEW(view), text);
26
27 return view;
28 }
29
30 void
treeview_main(struct symbol_list * syms)31 treeview_main (struct symbol_list *syms)
32 {
33 GtkWidget *window, *view, *scrollwin;
34
35 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
36 gtk_window_set_default_size (GTK_WINDOW(window), 600, 800);
37 g_signal_connect(window, "delete_event", gtk_main_quit, NULL);
38
39 scrollwin = gtk_scrolled_window_new(NULL,NULL);
40
41 view = create_view_and_model(syms);
42
43 gtk_container_add(GTK_CONTAINER(scrollwin), view);
44 gtk_container_add(GTK_CONTAINER(window), scrollwin);
45
46 gtk_widget_show_all(window);
47
48 gtk_main();
49 }
50