Skip to content

Commit

Permalink
fix: app_links is not configured on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
w568w committed Jul 2, 2024
1 parent a3b8cdb commit d599924
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions linux/my_application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION
// Implements GApplication::activate.
static void my_application_activate(GApplication *application) {
MyApplication * self = MY_APPLICATION(application);

// >>> Required by app_links
GList *windows = gtk_application_get_windows(GTK_APPLICATION(application));
if (windows) {
gtk_window_present(GTK_WINDOW(windows->data));
return;
}
// <<< Required by app_links

GtkWindow *window =
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));

Expand Down Expand Up @@ -85,7 +94,9 @@ my_application_local_command_line(GApplication *application, gchar ***arguments,
g_application_activate(application);
*exit_status = 0;

return TRUE;
// >>> Required by app_links
return FALSE;
// <<< Required by app_links
}

// Implements GObject::dispose.
Expand All @@ -106,6 +117,9 @@ static void my_application_init(MyApplication * self) {}
MyApplication *my_application_new() {
return MY_APPLICATION(g_object_new(my_application_get_type(),
"application-id", APPLICATION_ID,
"flags", G_APPLICATION_NON_UNIQUE,
// >>> Required by app_links
"flags", G_APPLICATION_HANDLES_COMMAND_LINE |
G_APPLICATION_HANDLES_OPEN,
// <<< Required by app_links
nullptr));
}

0 comments on commit d599924

Please sign in to comment.