[Xfce4-commits] [panel-plugins/xfce4-clipman-plugin] 18/37: Only start if the clipman daemon is running

noreply at xfce.org noreply at xfce.org
Mon Mar 23 23:30:13 CET 2020


This is an automated email from the git hooks/post-receive script.

o   c   h   o   s   i       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository panel-plugins/xfce4-clipman-plugin.

commit cc7a0e3cb746a8593b97fa05ec69fe5020044c26
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Fri Mar 20 18:00:27 2020 +0100

    Only start if the clipman daemon is running
---
 panel-plugin/xfce4-clipman-history.c | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/panel-plugin/xfce4-clipman-history.c b/panel-plugin/xfce4-clipman-history.c
index 84d7c6d..9169887 100644
--- a/panel-plugin/xfce4-clipman-history.c
+++ b/panel-plugin/xfce4-clipman-history.c
@@ -329,10 +329,30 @@ clipman_history_dialog_delete_event (GtkWidget *widget,
 
 /* dummy function as we don't want to activate */
 static void
-activate (GApplication *app, gpointer      user_data)
+clipman_history_activate (GApplication *app,
+                          MyPlugin     *plugin)
 {
 }
 
+static gboolean
+clipman_history_clipman_daemon_running (void)
+{
+  GtkApplication *app;
+  GError *error = NULL;
+
+  app = gtk_application_new ("org.xfce.clipman", 0);
+
+  g_application_register (G_APPLICATION (app), NULL, &error);
+  if (error != NULL)
+    {
+      g_warning ("Unable to register GApplication: %s", error->message);
+      g_error_free (error);
+      error = NULL;
+    }
+
+  return g_application_get_is_remote (G_APPLICATION (app));
+}
+
 gint
 main (gint argc, gchar *argv[])
 {
@@ -341,11 +361,17 @@ main (gint argc, gchar *argv[])
   GtkWidget *dialog;
   MyPlugin *plugin = g_slice_new0 (MyPlugin);
 
+  if (!clipman_history_clipman_daemon_running ())
+    {
+      g_warning ("The clipboard daemon is not running, exiting. You can launch it with 'xfce4-clipman'.");
+      return FALSE;
+    }
+
   /* Setup translation domain */
   xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
 
   app = gtk_application_new ("org.xfce.clipman.history", G_APPLICATION_FLAGS_NONE);
-  g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
+  g_signal_connect (app, "activate", G_CALLBACK (clipman_history_activate), plugin);
   g_application_run (G_APPLICATION (app), argc, argv);
 
   g_application_register (G_APPLICATION (app), NULL, &error);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list