[Xfce4-commits] <xfce4-notes-plugin:master> Add Unique support for xfce4-notes and the settings dialog

Mike Massonnet noreply at xfce.org
Wed Dec 2 17:04:01 CET 2009


Updating branch refs/heads/master
         to 71a8070168881256735aac5cd5fc5683341d6a28 (commit)
       from 9d4d549cd0421cee1326f296b1adefd36f203fc5 (commit)

commit 71a8070168881256735aac5cd5fc5683341d6a28
Author: Mike Massonnet <mmassonnet at xfce.org>
Date:   Wed Dec 2 17:01:11 2009 +0100

    Add Unique support for xfce4-notes and the settings dialog

 ChangeLog                           |    4 ++++
 configure.ac.in                     |    1 +
 panel-plugin/Makefile.am            |   14 +++++++++-----
 panel-plugin/main-status-icon.vala  |   13 +++++++++++++
 panel-plugin/xfce4-notes-settings.c |   27 +++++++++++++++++++++++++++
 5 files changed, 54 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2f4ae51..99589b3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2009-12-02  Mike Massonnet <mmassonnet at xfce.org>
 
+Add Unique support for xfce4-notes and the settings dialog
+
+2009-12-02  Mike Massonnet <mmassonnet at xfce.org>
+
 Hide notebook border
 
 2009-12-01  Mike Massonnet <mmassonnet at xfce.org>
diff --git a/configure.ac.in b/configure.ac.in
index 061fda6..63790a6 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -49,6 +49,7 @@ XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.4.0])
 XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.4.0])
 XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.4.0])
 XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.6.0])
+XDT_CHECK_PACKAGE([UNIQUE], [unique-1.0], [1.0.0])
 
 dnl Check for libxfce4panel >= 4.7
 XDT_CHECK_OPTIONAL_PACKAGE([LIBXFCE4PANEL47], [libxfce4panel-1.0], [4.7.0], [], [])
diff --git a/panel-plugin/Makefile.am b/panel-plugin/Makefile.am
index 44fb002..3d15277 100644
--- a/panel-plugin/Makefile.am
+++ b/panel-plugin/Makefile.am
@@ -37,13 +37,15 @@ xfce4_notes_settings_CFLAGS =						\
 	@LIBX11_CFLAGS@							\
 	@GTK_CFLAGS@							\
 	@LIBXFCEGUI4_CFLAGS@						\
-	@XFCONF_CFLAGS@
+	@XFCONF_CFLAGS@							\
+	@UNIQUE_CFLAGS@
 
 xfce4_notes_settings_LDADD =						\
 	@LIBX11_LIBS@							\
 	@GTK_LIBS@							\
 	@LIBXFCEGUI4_LIBS@						\
-	@XFCONF_LIBS@
+	@XFCONF_LIBS@							\
+	@UNIQUE_LIBS@
 
 #
 # Vala sources
@@ -83,7 +85,7 @@ vala.stamp: $(notes_VALASOURCES) $(notes_panel_plugin_VALASOURCES) $(notes_statu
 	$(VALAC) $(DEFINES) --vapidir=$(srcdir) $(PACKAGES)				\
 		 --pkg=libxfconf-0 --pkg=libxfce4panel-1.0				\
 		 $(notes_VALASOURCES) $(notes_panel_plugin_VALASOURCES) -C
-	$(VALAC) $(DEFINES) --vapidir=$(srcdir) $(PACKAGES)				\
+	$(VALAC) $(DEFINES) --vapidir=$(srcdir) $(PACKAGES) --pkg=unique-1.0		\
 		 --pkg=xfce-autostart --pkg=libxfconf-0 --pkg=libxfce4util-1.0		\
 		 $(notes_VALASOURCES) $(notes_status_icon_VALASOURCES) -C
 	touch $@
@@ -170,14 +172,16 @@ xfce4_notes_CFLAGS =							\
 	@GTK_CFLAGS@							\
 	@LIBXFCE4UTIL_CFLAGS@						\
 	@LIBXFCEGUI4_CFLAGS@						\
-	@XFCONF_CFLAGS@
+	@XFCONF_CFLAGS@							\
+	@UNIQUE_CFLAGS@
 
 xfce4_notes_LDADD =							\
 	@LIBX11_LIBS@							\
 	@GTK_LIBS@							\
 	@LIBXFCE4UTIL_LIBS@						\
 	@LIBXFCEGUI4_LIBS@						\
-	@XFCONF_LIBS@
+	@XFCONF_LIBS@							\
+	@UNIQUE_LIBS@
 
 #
 # Plugin desktop file
diff --git a/panel-plugin/main-status-icon.vala b/panel-plugin/main-status-icon.vala
index fd84021..0d975f7 100644
--- a/panel-plugin/main-status-icon.vala
+++ b/panel-plugin/main-status-icon.vala
@@ -128,6 +128,19 @@ public class Notes : GLib.Object {
 
 	public static int main (string[] args) {
 		Gtk.init (ref args);
+		Unique.App app = new Unique.App ("org.xfce.Notes", null);
+		if (app.is_running) {
+			if (app.send_message (Unique.Command.ACTIVATE, null) == Unique.Response.OK) {
+				app = null;
+				return 0;
+			}
+		}
+		app.message_received += (command, message_data, time_) => {
+			if (command != Unique.Command.ACTIVATE) {
+				return Unique.Response.PASSTHROUGH;
+			}
+			return Unique.Response.OK;
+		};
 		GLib.Environment.set_application_name (_("Notes"));
 		var notes = new Notes ();
 		Xfce.Autostart. at set ("xfce4-notes-autostart", "xfce4-notes", false);
diff --git a/panel-plugin/xfce4-notes-settings.c b/panel-plugin/xfce4-notes-settings.c
index 767182c..60bc965 100644
--- a/panel-plugin/xfce4-notes-settings.c
+++ b/panel-plugin/xfce4-notes-settings.c
@@ -21,6 +21,7 @@
 #include <config.h>
 #endif
 
+#include <unique/unique.h>
 #include <xfconf/xfconf.h>
 #include <gtk/gtk.h>
 #include <libxfce4util/libxfce4util.h>
@@ -474,6 +475,22 @@ cb_color_button_pressed (GtkButton *button,
 
 
 
+static UniqueResponse
+cb_unique_app (UniqueApp *app,
+               gint command,
+               UniqueMessageData *message_data,
+               guint time_,
+               gpointer user_data)
+{
+  GtkWidget *dialog = user_data;
+  if (command != UNIQUE_ACTIVATE)
+    {
+      return UNIQUE_RESPONSE_PASSTHROUGH;
+    }
+  gtk_window_present (GTK_WINDOW (dialog));
+  return UNIQUE_RESPONSE_OK;
+}
+
 gint main (gint argc,
           gchar *argv[])
 {
@@ -481,7 +498,17 @@ gint main (gint argc,
   xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, NULL);
   xfconf_init (NULL);
   gtk_init (&argc, &argv);
+  UniqueApp *app = unique_app_new ("org.xfce.NotesSettings", NULL);
+  if (unique_app_is_running (app))
+    {
+      if (unique_app_send_message (app, UNIQUE_ACTIVATE, NULL) == UNIQUE_RESPONSE_OK)
+        {
+          g_object_unref (app);
+          return;
+        }
+    }
   dialog = prop_dialog_new ();
+  g_signal_connect (app, "message-received", G_CALLBACK (cb_unique_app), dialog);
   gtk_dialog_run (GTK_DIALOG (dialog));
   gtk_widget_destroy (dialog);
   xfconf_shutdown ();



More information about the Xfce4-commits mailing list