Project

General

Profile

Statistics
| Revision:

root / branches / simulator / projects / simulator / simulator / gui / gtk_gui.c @ 1065

History | View | Annotate | Download (1020 Bytes)

1
#include <stdlib.h>
2
#include <gtk/gtk.h>
3
#include <glib.h>
4

    
5
#include "gtk_gui.h"
6
#include "gtk_environment_view.h"
7

    
8
GtkWidget* window;
9
GtkWidget* view = NULL;
10

    
11
void destroy_callback(int arg)
12
{
13
        gtk_main_quit();
14
}
15

    
16
int gtk_gui_run(int argc, char** argv)
17
{
18
        //g_thread_init(NULL);
19
        gdk_threads_init();
20
        gdk_threads_enter();
21
        gtk_init(&argc, &argv);
22

    
23
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
24
        gtk_window_set_title(GTK_WINDOW(window), "Colony Simulator");
25
        gtk_window_maximize(GTK_WINDOW(window));
26
        //g_signal_connect(G_OBJECT(window), "delete_event",
27
        //                G_CALLBACK(delete_event), NULL);
28
        
29
        g_signal_connect(G_OBJECT(window), "destroy",
30
                        G_CALLBACK(destroy_callback), NULL);
31
        
32
        gtk_container_set_border_width(GTK_CONTAINER(window), 0);
33

    
34
        view = gtk_environment_view_new();
35
        gtk_container_add(GTK_CONTAINER(window), view);
36
        gtk_widget_show(view);
37

    
38
        gtk_widget_show(window);
39

    
40
        gtk_main();
41
        gdk_threads_leave();
42

    
43
        return 0;
44
}
45

    
46
void gui_refresh()
47
{
48
        if (view == NULL)
49
                return;
50
        gtk_environment_view_refresh(view);
51
}
52