#include "file.h" #include "image.h" #include "input.h" #include "window.h" #include 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; }