aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authornirav <nirav@teisuu.com>2018-09-09 12:13:13 +0530
committerDandelion <nirav@teisuu.com>2018-09-09 12:46:57 +0530
commite54d8327819e310b7b148e45c15fca197be845c7 (patch)
tree04e513d52ed2191364e6b9472cd0f3882a60da4a /src/main.c
parent661756c9237a26562cae102f53b12aa0b403fde1 (diff)
downloadim-e54d8327819e310b7b148e45c15fca197be845c7.tar.gz
im-e54d8327819e310b7b148e45c15fca197be845c7.zip
Moved source files to src dir, updated makefile
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..b5eb616
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,51 @@
+#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\n");
+ return;
+ }
+
+ i = load_image(curr_filename);
+ if (i < 0) {
+ printf("failed to load file\n");
+ quit();
+ }
+}
+
+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;
+}