[Xfce4-commits] [panel-plugins/xfce4-clipman-plugin] 10/15: Migrate from libunique to GtkApplication

noreply at xfce.org noreply at xfce.org
Wed Jun 1 22:40:03 CEST 2016


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

schuellerf pushed a commit to branch master
in repository panel-plugins/xfce4-clipman-plugin.

commit 75071c2c4c6090dc8b7a06ceca958dcca4d2283b
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Tue May 31 20:35:20 2016 +0300

    Migrate from libunique to GtkApplication
---
 configure.ac.in                       | 10 ------
 panel-plugin/Makefile.am              |  2 --
 panel-plugin/xfce4-clipman-settings.c | 68 ++++++++++++++---------------------
 3 files changed, 27 insertions(+), 53 deletions(-)

diff --git a/configure.ac.in b/configure.ac.in
index 26071ee..07558ff 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -70,16 +70,6 @@ XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.10.0])
 XDT_CHECK_PACKAGE([LIBXPROTO], [xproto], [7.0.0])
 XDT_CHECK_PACKAGE([LIBXTST], [xtst], [1.0.0])
 
-dnl ***************************
-dnl *** Check for libunique ***
-dnl ***************************
-XDT_CHECK_OPTIONAL_PACKAGE([UNIQUE], [unique-3.0], [3.0.0], unique, [Unique support])
-if test x"$UNIQUE_FOUND" = x"yes"; then
-	enable_unique=yes
-else
-	enable_unique=no
-fi
-
 dnl *****************************
 dnl *** Check for libqrencode ***
 dnl *****************************
diff --git a/panel-plugin/Makefile.am b/panel-plugin/Makefile.am
index b4fd1e9..05c2689 100644
--- a/panel-plugin/Makefile.am
+++ b/panel-plugin/Makefile.am
@@ -62,7 +62,6 @@ xfce4_clipman_settings_CFLAGS =						\
 	@GTK_CFLAGS@							\
 	@LIBXFCE4UI_CFLAGS@						\
 	@XFCONF_CFLAGS@							\
-	@UNIQUE_CFLAGS@							\
 	$(NULL)
 
 xfce4_clipman_settings_LDADD =						\
@@ -71,7 +70,6 @@ xfce4_clipman_settings_LDADD =						\
 	@GTK_LIBS@							\
 	@LIBXFCE4UI_LIBS@						\
 	@XFCONF_LIBS@							\
-	@UNIQUE_LIBS@							\
 	$(NULL)
 
 #
diff --git a/panel-plugin/xfce4-clipman-settings.c b/panel-plugin/xfce4-clipman-settings.c
index 044dc03..4e65673 100644
--- a/panel-plugin/xfce4-clipman-settings.c
+++ b/panel-plugin/xfce4-clipman-settings.c
@@ -24,10 +24,6 @@
 #include <locale.h>
 #endif
 
-#ifdef HAVE_UNIQUE
-#include <unique/unique.h>
-#endif
-
 #include <glib/gstdio.h>
 #include <gtk/gtk.h>
 #include <libxfce4ui/libxfce4ui.h>
@@ -81,11 +77,7 @@ prop_dialog_run (void)
   GtkWidget *combobox;
   GtkWidget *enable_actions;
 
-  builder = gtk_builder_new ();
-  gtk_builder_add_from_string (builder, settings_dialog_ui, settings_dialog_ui_length, NULL);
-
   /* Dialogs */
-  settings_dialog = GTK_WIDGET (gtk_builder_get_object (builder, "settings-dialog"));
   action_dialog = GTK_WIDGET (gtk_builder_get_object (builder, "action-dialog"));
 
   /* General settings */
@@ -880,47 +872,41 @@ cb_set_action_dialog_button_ok (GtkWidget *widget)
 
 
 
-/* Main */
-#ifdef HAVE_UNIQUE
-static UniqueResponse
-cb_unique_app (UniqueApp *app,
-               gint command,
-               UniqueMessageData *message_data,
-               guint time_,
-               gpointer user_data)
-{
-  if (command != UNIQUE_ACTIVATE)
-    {
-      return UNIQUE_RESPONSE_PASSTHROUGH;
-    }
-
-  gtk_window_present (GTK_WINDOW (settings_dialog));
-  return UNIQUE_RESPONSE_OK;
-}
-#endif
-
 gint
 main (gint argc,
       gchar *argv[])
 {
+  GtkApplication *app;
+  GError *error = NULL;
+
   xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, NULL);
   xfconf_init (NULL);
   gtk_init (&argc, &argv);
 
-#ifdef HAVE_UNIQUE
-    {
-      UniqueApp *app = unique_app_new ("org.xfce.Clipman", NULL);
-      if (unique_app_is_running (app))
-        {
-          if (unique_app_send_message (app, UNIQUE_ACTIVATE, NULL) == UNIQUE_RESPONSE_OK)
-            {
-              g_object_unref (app);
-              return 0;
-            }
-        }
-      g_signal_connect (app, "message-received", G_CALLBACK (cb_unique_app), NULL);
-    }
-#endif
+  app = gtk_application_new ("org.xfce.Clipman", G_APPLICATION_FLAGS_NONE);
+
+  g_application_register (G_APPLICATION (app), NULL, &error);
+  if (error != NULL)
+  {
+    g_warning ("Unable to register GApplication: %s", error->message);
+    g_clear_error (&error);
+    return 1;
+  }
+
+  if (g_application_get_is_remote (G_APPLICATION (app)))
+  {
+    g_application_activate (G_APPLICATION (app));
+    g_object_unref (app);
+    return 0;
+  }
+
+  builder = gtk_builder_new ();
+  gtk_builder_add_from_string (builder, settings_dialog_ui, settings_dialog_ui_length, NULL);
+
+  /* Main Dialog */
+  settings_dialog = GTK_WIDGET (gtk_builder_get_object (builder, "settings-dialog"));
+
+  g_signal_connect_swapped (app, "activate", G_CALLBACK (gtk_window_present), settings_dialog);
 
   xfconf_channel = xfconf_channel_new_with_property_base ("xfce4-panel", "/plugins/clipman");
   actions = clipman_actions_get ();

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


More information about the Xfce4-commits mailing list