diff options
author | Bastien Nocera <hadess@hadess.net> | 2020-08-26 12:55:41 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2020-08-26 13:13:55 +0200 |
commit | eff42ea800eccfce840e2a097fb5a6170a0a51c6 (patch) | |
tree | f2346d8be17a76846dd0b67282cc617f833b4f70 /tools | |
parent | 3d30f160d33ca7dd1f3e2ebf731585297f3f5ea6 (diff) | |
download | grilo-eff42ea800eccfce840e2a097fb5a6170a0a51c6.tar.gz |
grilo-test-ui: Fix tool not working in Flatpak
Since commit adc11e54537aff804c6dcd8d26ade0114632157b, it's
impossible to use grilo-test-ui in the Flatpak for another
application, as it tries to request a D-Bus name that it cannot own.
Instead of using our own app-id/D-Bus name, try to own a variant of the
real app's name.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/grilo-test-ui/main.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/tools/grilo-test-ui/main.c b/tools/grilo-test-ui/main.c index 1fabf76..e2335e6 100644 --- a/tools/grilo-test-ui/main.c +++ b/tools/grilo-test-ui/main.c @@ -2472,16 +2472,41 @@ activate (GApplication *app, load_plugins (); } +static char * +get_app_id (void) +{ + g_autoptr(GKeyFile) keyfile = NULL; + const char *app_id; + + if (!g_file_test ("/.flatpak-info", G_FILE_TEST_EXISTS)) + goto bail; + + keyfile = g_key_file_new (); + if (!g_key_file_load_from_file (keyfile, "/.flatpak-info", G_KEY_FILE_NONE, NULL)) + goto bail; + + app_id = g_key_file_get_string (keyfile, "Application", "name", NULL); + if (!app_id) + goto bail; + + return g_strdup_printf ("%s.grilotestui", app_id); + +bail: + return g_strdup ("org.gnome.grilotestui"); +} + int main (int argc, char **argv) { GtkApplication *app; int status; + g_autofree char *app_id = NULL; grl_init (&argc, &argv); GRL_LOG_DOMAIN_INIT (test_ui_log_domain, "test-ui"); - app = gtk_application_new ("org.gnome.grilotestui", G_APPLICATION_FLAGS_NONE); + app_id = get_app_id (); + app = gtk_application_new (app_id, G_APPLICATION_FLAGS_NONE); g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); status = g_application_run (G_APPLICATION (app), argc, argv); g_object_unref (app); |