[Xfce4-commits] [panel-plugins/xfce4-clipman-plugin] 01/01: Implement GtkApplication for the panel plugin

noreply at xfce.org noreply at xfce.org
Wed Jul 19 23:55:56 CEST 2017


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 68bc4fff61b3bb6bf0af56a052efc0e8d83b9a0d
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Wed Jul 19 23:55:11 2017 +0200

    Implement GtkApplication for the panel plugin
---
 panel-plugin/plugin.c | 21 +++++++++++++++++++++
 panel-plugin/plugin.h |  2 +-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/panel-plugin/plugin.c b/panel-plugin/plugin.c
index bf70319..04694b3 100644
--- a/panel-plugin/plugin.c
+++ b/panel-plugin/plugin.c
@@ -63,6 +63,7 @@ MyPlugin *
 plugin_register (void)
 {
   MyPlugin *plugin = g_slice_new0 (MyPlugin);
+  GError *error = NULL;
 
   /* Locale */
   xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, NULL);
@@ -74,6 +75,25 @@ plugin_register (void)
       gsd_clipboard_manager_start (plugin->daemon, NULL);
     }
 
+  plugin->app = gtk_application_new ("org.xfce.clipman", 0);
+  g_application_register (G_APPLICATION (plugin->app), NULL, &error);
+  if (error != NULL)
+    {
+      g_warning ("Unable to register GApplication: %s", error->message);
+      g_error_free (error);
+      error = NULL;
+    }
+
+  if (g_application_get_is_remote (G_APPLICATION (plugin->app)))
+    {
+      g_message ("Primary instance org.xfce.clipman already running");
+      g_object_unref (plugin->app);
+      return FALSE;
+    }
+
+  g_set_application_name (_("Clipman"));
+  g_signal_connect_swapped (plugin->app, "activate", G_CALLBACK (plugin_popup_menu), plugin);
+
   /* Xfconf */
   xfconf_init (NULL);
   plugin->channel = xfconf_channel_new_with_property_base ("xfce4-panel", "/plugins/clipman");
@@ -283,6 +303,7 @@ plugin_free (MyPlugin *plugin)
   gtk_widget_destroy (plugin->popup_menu);
 #endif
 
+  g_object_unref (plugin->app);
   g_slice_free (MyPlugin, plugin);
   xfconf_shutdown ();
 }
diff --git a/panel-plugin/plugin.h b/panel-plugin/plugin.h
index ee6aa47..3b5603c 100644
--- a/panel-plugin/plugin.h
+++ b/panel-plugin/plugin.h
@@ -58,6 +58,7 @@ struct _MyPlugin
   GtkMenuPositionFunc   menu_position_func;
   GtkWidget            *popup_menu;
   gulong                popup_menu_id;
+  GtkApplication       *app;
 };
 
 /*
@@ -73,4 +74,3 @@ void                    plugin_configure                (MyPlugin *plugin);
 void                    plugin_popup_menu               (MyPlugin *plugin);
 
 #endif /* !__CLIPMAN_PLUGIN_H__ */
-

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


More information about the Xfce4-commits mailing list