diff options
| author | Zach DeCook <zachdecook@librem.one> | 2023-08-26 14:38:20 -0400 |
|---|---|---|
| committer | Zach DeCook <zachdecook@librem.one> | 2023-08-26 14:38:20 -0400 |
| commit | e95b166f03143f488b218c385c1fcbd3be0f216c (patch) | |
| tree | a49c282d6ac4bb28fd58ad272a7b9ad0604c0362 | |
| parent | a8896b3bddd8a78ef5332b0bdbf644e5259b6063 (diff) | |
| download | shemuvi-e95b166f03143f488b218c385c1fcbd3be0f216c.tar.gz | |
Application: Allow opening a file from the command line
| -rw-r--r-- | main.c | 16 |
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); |
