1 /****************************************************************************
2 * Familia Lignum - Genealogical program *
3 * Copyright (C) 2011-2012 Rafał Długołęcki <rafal@dlugolecki.net.pl> *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; version 2 of the License. *
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 along *
15 * with this program; if not, write to the Free Software Foundation, Inc., *
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
18 ****************************************************************************/
25 #include <gtk/gtkgl.h>
29 #include "../config.h"
32 #include "commandline.h"
33 #include "storage/storage.h"
34 #include "gedcom/familia_gedcom.h"
36 const char * get_guidatafile()
38 if (g_file_test (DATADIR "/gui.glade", G_FILE_TEST_EXISTS)) {
39 return DATADIR "/gui.glade";
41 return "data/gui.glade";
44 int main(int argc, char** argv) {
45 GtkBuilder *builder = NULL;
46 GtkWidget *window = NULL;
47 GtkWidget *area = NULL;
48 GdkGLConfig *glconfig = NULL;
49 struct familia_storage * storage = NULL;
51 storage = familia_storage_new();
52 familia_storage_set_current(storage);
55 familia_gedcom_init();
57 gtk_init(&argc, &argv);
59 if(!commandline_parse(&argc, &argv)) {
63 /* Initialize OpenGL */
64 gtk_gl_init(&argc, &argv);
66 setlocale(LC_ALL, "");
67 bindtextdomain(PACKAGE_TARNAME, LOCALEDIR);
68 textdomain(PACKAGE_TARNAME);
70 g_set_prgname(PACKAGE_NAME);
72 GdkGLConfigMode gl_mode = GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH |
75 /* Try double-buffered visual */
76 glconfig = gdk_gl_config_new_by_mode (gl_mode);
77 if (glconfig == NULL) {
78 debug("OpenGL mode is not supported. Exiting...");
82 builder = gtk_builder_new();
84 gtk_builder_add_from_file(builder, get_guidatafile(), NULL);
85 gtk_builder_connect_signals(builder, NULL);
87 window = GTK_WIDGET(gtk_builder_get_object(builder, "main-window"));
88 area = GTK_WIDGET(gtk_builder_get_object(builder, "drawing-area"));
90 gtk_window_set_title(GTK_WINDOW(window), g_get_application_name());
92 /* Set OpenGL-capability to the widget. */
93 gtk_widget_set_gl_capability (area, glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE);
95 gtk_widget_show(window);
99 if (familia_storage_get_current()) {
100 storage = familia_storage_get_current();
101 familia_storage_free(storage);