Skip to content
Snippets Groups Projects
Commit 67421868 authored by Gaël Bonithon's avatar Gaël Bonithon
Browse files

popup-clipman: Properly use GApplication

This ensures that the primary instance has been activated before
exiting, otherwise the menu is sometimes shown and sometimes not. This
also removes the warning to use g_application_run().
parent eab4beac
No related branches found
No related tags found
No related merge requests found
......@@ -63,34 +63,46 @@ G_GNUC_END_IGNORE_DEPRECATIONS
}
}
gint
main (gint argc, gchar *argv[])
static gint
handle_local_options (GApplication *app,
GVariantDict *options,
gpointer user_data)
{
GtkApplication *app;
GError *error = NULL;
gtk_init (&argc, &argv);
app = gtk_application_new ("org.xfce.clipman", 0);
g_application_register (G_APPLICATION (app), NULL, &error);
if (error != NULL)
if (!g_application_register (app, NULL, &error))
{
g_warning ("Unable to register GApplication: %s", error->message);
g_error_free (error);
error = NULL;
return EXIT_FAILURE;
}
if (g_application_get_is_remote (G_APPLICATION (app)))
{
grab_keyboard ();
g_application_activate (G_APPLICATION (app));
g_object_unref (app);
}
else
if (!g_application_get_is_remote (app))
{
g_warning ("Unable to find the primary instance org.xfce.clipman");
clipman_common_show_warning_dialog ();
return EXIT_FAILURE;
}
return FALSE;
/* ensure grab is available when popup command is activated via keyboard shortcut */
grab_keyboard ();
/* activate primary instance */
return -1;
}
gint
main (gint argc, gchar *argv[])
{
GtkApplication *app;
gint ret;
gtk_init (&argc, &argv);
app = gtk_application_new ("org.xfce.clipman", G_APPLICATION_FLAGS_NONE);
g_signal_connect (app, "handle-local-options", G_CALLBACK (handle_local_options), NULL);
ret = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
return ret;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment