]> Pileus Git - grits/blob - src/gis_test.c
Update copyright and email address
[grits] / src / gis_test.c
1 /*
2  * Copyright (C) 2009-2010 Andy Spencer <andy753421@gmail.com>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 #include <config.h>
19 #include <gtk/gtk.h>
20 #include <gdk/gdkkeysyms.h>
21
22 #include "gis.h"
23
24 /*************
25  * Callbacks *
26  *************/
27 static gboolean on_key_press(GtkWidget *widget, GdkEventKey *event,
28                 gpointer _window)
29 {
30         g_debug("GisTest: on_key_press - key=%x, state=%x",
31                         event->keyval, event->state);
32         GtkWidget *window = _window;
33         switch (event->keyval) {
34         case GDK_q:
35                 gtk_widget_destroy(window);
36                 return TRUE;
37         }
38         return FALSE;
39 }
40
41 /***********
42  * Methods *
43  ***********/
44 int main(int argc, char **argv)
45 {
46         g_thread_init(NULL);
47         gdk_threads_init();
48         gtk_init(&argc, &argv);
49
50         GisPrefs   *prefs   = gis_prefs_new(NULL, NULL);
51         GisPlugins *plugins = gis_plugins_new(NULL);
52         GisViewer  *viewer  = gis_opengl_new(plugins);
53
54         gdk_threads_enter();
55         GtkWidget  *window  = gtk_window_new(GTK_WINDOW_TOPLEVEL);
56         g_signal_connect(window,  "destroy",         G_CALLBACK(gtk_main_quit), NULL);
57         g_signal_connect(window,  "key-press-event", G_CALLBACK(on_key_press),  window);
58         gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(viewer));
59         gtk_widget_show_all(window);
60         gdk_threads_leave();
61
62         while (*argv)
63                 gis_plugins_load(plugins, *argv++, viewer, prefs);
64
65         gdk_threads_enter();
66         gtk_main();
67
68         gis_plugins_free(plugins);
69         g_object_unref(prefs);
70         gdk_threads_leave();
71         return 0;
72 }