summaryrefslogtreecommitdiff
blob: 40bf060b1434cb18fe5e5809b67194629fb1dde8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <stdlib.h>
#include "ast-model.h"
#include "ast-inspect.h"

GtkWidget *
create_view_and_model (void *ptr)
{
	GtkTreeViewColumn   *text;
	GtkCellRenderer *renderer;
	AstNode *root;
	GtkWidget *view;

	root = ast_new(NULL, 0, "", ptr, inspect_symbol_list);

	view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(root));

	g_object_unref(root); /* destroy store automatically with view */

	renderer = gtk_cell_renderer_text_new();
	text = gtk_tree_view_column_new_with_attributes("Node", renderer,
						       "text", AST_COL_NAME,
						       NULL);
	gtk_tree_view_append_column(GTK_TREE_VIEW(view), text);

	return view;
}

void
treeview_main (struct symbol_list *syms)
{
	GtkWidget *window, *view, *scrollwin;

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_default_size (GTK_WINDOW(window), 400, 600);
	g_signal_connect(window, "delete_event", gtk_main_quit, NULL);

	scrollwin = gtk_scrolled_window_new(NULL,NULL);

	view = create_view_and_model(syms);

	gtk_container_add(GTK_CONTAINER(scrollwin), view);
	gtk_container_add(GTK_CONTAINER(window), scrollwin);

	gtk_widget_show_all(window);

	gtk_main();
}