aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornirav <nirav@teisuu.com>2018-09-03 21:44:22 +0530
committerDandelion <nirav@teisuu.com>2018-09-03 21:44:22 +0530
commit8d9ca628e2d0543ed89c4c3529bdb56cc27af25d (patch)
treeed03e0889f2b100c7a759058cabf384e13cb96f0
parenta49ccb8c0731aa0bba767199dfee1e7e235aeb29 (diff)
downloadim-8d9ca628e2d0543ed89c4c3529bdb56cc27af25d.tar.gz
im-8d9ca628e2d0543ed89c4c3529bdb56cc27af25d.zip
Added commandline parameter handling
-rw-r--r--main.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/main.c b/main.c
index 57e84bc..d762469 100644
--- a/main.c
+++ b/main.c
@@ -102,7 +102,15 @@ gboolean configure_callback(GtkWindow *window, GdkEvent *event, gpointer data)
static void activate(GtkApplication *app, gpointer user_data)
{
- window = gtk_application_window_new(app);
+}
+
+static void open(GApplication *app, GFile **files, gint n_files,
+ const gchar *hint)
+{
+ if (n_files != 1) {
+ return;
+ }
+ window = gtk_application_window_new(GTK_APPLICATION(app));
gtk_window_set_title(GTK_WINDOW(window), "qwe");
gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);
g_signal_connect(G_OBJECT(window), "configure-event",
@@ -113,8 +121,7 @@ static void activate(GtkApplication *app, gpointer user_data)
g_signal_connect(G_OBJECT(window), "scroll-event",
G_CALLBACK(scroll_callback), NULL);
- char *curr_filename =
- "/home/nirav/Downloads/Saved Pictures/bash help shortcuts.png";
+ char *curr_filename = g_file_get_path(files[0]);
int i = scan(curr_filename);
if (i < 0) {
@@ -136,8 +143,9 @@ int main(int argc, char *argv[])
{
GtkApplication *app;
int status;
- app = gtk_application_new("org.gtk.qwe", G_APPLICATION_FLAGS_NONE);
+ 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;