#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) {
gint status = 0;
-
-// Scanner_t* sc = scanner_create("/home/mir/Pictures/Pictures/20211019_0012.jpg");
-// Scanner_t* sc = scanner_create("/home/mir/Pictures/Pictures/2024/09/14/Lndskrona Foto Festival/Lndskrona Foto Festival-8.ORF");
- Scanner_t* sc = scanner_create("/home/mir/Pictures/Pictures/2024/08/21/Fototur til Hejresøen/Fototur til Hejresøen-6.NEF");
- scanner_do_work(sc);
- scanner_destroy(sc);
-
- gchar* path = g_path_get_dirname(argv[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_err_msg(GTK_MESSAGE_ERROR, err);
+ show_message(GTK_MESSAGE_ERROR, err);
g_free(err);
return EXIT_FAILURE;
}