aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
blob: 21dd14ea47ccba48e1435ef85ae3b731b9541e27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <gtk-3.0/gtk/gtk.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include "file.h"
#include "image.h"
#include "window.h"

void print_usage()
{
    printf("qwe [filename]\n");
}

void print_version()
{
    printf("0.01\n");
}

int main(int argc, char **argv)
{
    gtk_init(&argc, &argv);

    int opt;
    while ((opt = getopt(argc, argv, "hv")) != -1) {
        switch (opt) {
        case '?':
            print_usage();
            exit(EXIT_FAILURE);
        case 'h':
            print_usage();
            exit(EXIT_SUCCESS);
        case 'v':
            print_version();
            exit(EXIT_SUCCESS);
        }
    }

    if (optind >= argc) {
        print_usage();
        exit(EXIT_FAILURE);
    }

    // load the specified image
    if (load_image(argv[optind])) {
        exit(EXIT_FAILURE);
    }

    // scan other supported image file in the same dir
    scan(argv[optind]);

    create_main_window();
    gtk_main();

    return EXIT_SUCCESS;
}