about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--main.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/main.c b/main.c
index 1c48ecb..8e1a794 100644
--- a/main.c
+++ b/main.c
@@ -140,17 +140,25 @@ static void activate (GtkApplication* app, gpointer user_data) {
 	g_signal_connect (button, "clicked", G_CALLBACK (open_file), NULL);
 	gtk_header_bar_pack_start (GTK_HEADER_BAR (header), button);
 	gtk_window_set_titlebar (GTK_WINDOW (window), header);
-	// Image
-	image = gtk_image_new_from_file ("./when-i-survey-the-wondrous-cross-watts.svg");
-	gtk_window_set_child (GTK_WINDOW (window), image);
+	// Image will be added by "open"
+	GtkWidget* label = gtk_label_new_with_mnemonic("Please open a file.");
+	gtk_window_set_child (GTK_WINDOW (window), label);
+}
+
+void app_open (GtkApplication* app, GFile** files, gint n_files, const gchar* hint) {
+	activate(app,NULL);
+	// TODO: do we actually want to handle opening multiple in one application?
+	set_file(files[0], NULL);
 }
 
 int main (int argc, char **argv) {
 	GtkApplication *app;
 	int status;
 
-	app = gtk_application_new ("com.zachdecook.shemuvi", G_APPLICATION_DEFAULT_FLAGS);
+	app = gtk_application_new ("com.zachdecook.shemuvi",
+		G_APPLICATION_DEFAULT_FLAGS|G_APPLICATION_HANDLES_OPEN);
 	g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
+	g_signal_connect (app, "open", G_CALLBACK(app_open), NULL);
 	status = g_application_run (G_APPLICATION (app), argc, argv);
 	g_object_unref (app);