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
|
#include "file.h"
#include "image.h"
#include "input.h"
#include "window.h"
#include <gtk-3.0/gtk/gtk.h>
void print_help()
{
printf("usage: qwe [filename]\n");
}
static void activate(GtkApplication *app, gpointer user_data)
{
print_help();
}
static void open(GApplication *app, GFile **files, gint n_files,
const gchar *hint)
{
if (n_files != 1) {
print_help();
return;
}
create_main_window(app);
char *curr_filename = g_file_get_path(files[0]);
int i = scan(curr_filename);
if (i < 0) {
printf("failed to load file");
return;
}
load_image(curr_filename);
}
int main(int argc, char *argv[])
{
GtkApplication *app;
int status;
app = gtk_application_new("org.gtk.qwe", G_APPLICATION_HANDLES_OPEN);
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
g_signal_connect(app, "open", G_CALLBACK(open), NULL);
status = g_application_run(G_APPLICATION(app), argc, argv);
g_object_unref(app);
return status;
}
|