2 * Copyright (C) 2009-2010 Andy Spencer <andy753421@gmail.com>
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.
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.
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/>.
20 #include <gtk/gtkgl.h>
21 #include <gdk/gdkkeysyms.h>
25 GisPrefs *prefs = NULL;
26 GisPlugins *plugins = NULL;
27 GisViewer *viewer = NULL;
32 static gboolean gis_shutdown(GtkWidget *window)
34 gis_plugins_free(plugins);
35 g_object_unref(prefs);
36 gtk_widget_destroy(window);
38 while (gtk_events_pending())
44 static gboolean on_delete(GtkWidget *widget, GdkEvent *event, gpointer data)
46 return gis_shutdown(widget);
48 static gboolean on_key_press(GtkWidget *widget, GdkEventKey *event,
51 if (event->keyval == GDK_q)
52 return gis_shutdown(widget);
55 static void load_plugin(GisPlugins *plugins, gchar *name,
56 GisViewer *viewer, GisPrefs *prefs, GtkNotebook *notebook)
58 GisPlugin *plugin = gis_plugins_load(plugins, name, viewer, prefs);
59 GtkWidget *config = gis_plugin_get_config(plugin);
60 gtk_notebook_append_page(notebook, config, gtk_label_new(name));
66 int main(int argc, char **argv)
70 gtk_init(&argc, &argv);
71 gtk_gl_init(&argc, &argv);
73 prefs = gis_prefs_new(NULL, NULL);
74 plugins = gis_plugins_new(g_getenv("GIS_PLUGIN_PATH"), prefs);
75 viewer = gis_opengl_new(plugins, prefs);
78 GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
79 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
80 GtkWidget *config = gtk_notebook_new();
81 g_signal_connect(window, "delete-event", G_CALLBACK(on_delete), NULL);
82 g_signal_connect(window, "key-press-event", G_CALLBACK(on_key_press), NULL);
83 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(config), GTK_POS_BOTTOM);
84 gtk_container_add(GTK_CONTAINER(window), vbox);
85 gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(viewer), TRUE, TRUE, 0);
86 gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(config), FALSE, FALSE, 0);
87 gtk_widget_show_all(window);
89 /* Configurable stuff */
90 gis_viewer_set_offline(viewer, TRUE);
91 //load_plugin(plugins, "elev", viewer, prefs, GTK_NOTEBOOK(config));
92 //load_plugin(plugins, "env", viewer, prefs, GTK_NOTEBOOK(config));
93 //load_plugin(plugins, "map", viewer, prefs, GTK_NOTEBOOK(config));
94 load_plugin(plugins, "sat", viewer, prefs, GTK_NOTEBOOK(config));
95 load_plugin(plugins, "test", viewer, prefs, GTK_NOTEBOOK(config));
96 //load_plugin(plugins, "radar", viewer, prefs, GTK_NOTEBOOK(config));
98 gtk_widget_show_all(config);
102 gdk_display_close(gdk_display_get_default());