]> git.datanom.net - lensdb.git/blobdiff - src/main.c
Import and overwrite
[lensdb.git] / src / main.c
index b8cfdd932a8e0e75aeb6652d4f6adb73657179dd..468ed1726145e0de2c52a2f14b81523508ca70ed 100644 (file)
@@ -5,7 +5,7 @@
  * 
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  * 
  * This program is distributed in the hope that it will be useful,
 #ifdef HAVE_CONFIG_H
 #       include <config.h>
 #endif
+#include <gtk/gtk.h>
 #include <glib.h>
+#include <glib/gstdio.h>
 #include <glib-object.h>
 #include <stdio.h>
 #include "sqlite-storage.h"
+#include "gui.h"
+#include "csv.h"
+#include "lib/scanner.h"
 
 gint main(gint argc, gchar** argv) {
-       printf("test\n");
-       return 0;
+       gint status = 0;
+       gchar* path = g_build_filename(g_get_user_config_dir(), PACKAGE, NULL);
+       if (!g_file_test(path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
+               if (g_mkdir(path, 0766)) {
+                       fprintf(stderr, "%s: Failed to create dir for database\n", path);
+                       g_free(path);
+                       return EXIT_FAILURE;
+               }
+       }
+       fprintf(stdout, "workdir: %s\n", path);
+       if ((status = init_storage(path)) > 0) {
+               fprintf(stderr, "%s: Failed to open DB\n", path);
+       } else {
+               gtk_init(&argc, &argv);
+               if (init_gui()) {
+                       g_free(path);
+                       close_storage();
+                       gchar* err = g_strdup_printf("Failed initializing GUI\n");
+                       fprintf(stderr, err);
+                       show_message(GTK_MESSAGE_ERROR, err);
+                       g_free(err);
+                       return EXIT_FAILURE;
+               }
+       }
+       g_free(path);
+       close_storage();
+       
+       return status;
 }
This page took 0.384835 seconds and 5 git commands to generate.