Add illumos projects
[smatch.git] / ast-view.c
blob22aba115b2b597ca63ea377648a221905e916693
2 #include <stdlib.h>
3 #include "ast-model.h"
4 #include "ast-inspect.h"
5 #include "ast-view.h"
7 static GtkWidget *
8 create_view_and_model (void *ptr)
10 GtkTreeViewColumn *text;
11 GtkCellRenderer *renderer;
12 AstNode *root;
13 GtkWidget *view;
15 root = ast_new(NULL, 0, "", ptr, inspect_symbol_list);
17 view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(root));
19 g_object_unref(root); /* destroy store automatically with view */
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);
27 return view;
30 void
31 treeview_main (struct symbol_list *syms)
33 GtkWidget *window, *view, *scrollwin;
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);
39 scrollwin = gtk_scrolled_window_new(NULL,NULL);
41 view = create_view_and_model(syms);
43 gtk_container_add(GTK_CONTAINER(scrollwin), view);
44 gtk_container_add(GTK_CONTAINER(window), scrollwin);
46 gtk_widget_show_all(window);
48 gtk_main();