[gnome-disk-utility] unique application support



commit e4c0df4af35c793c353dc5118af831566031c83d
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Mar 30 22:50:09 2009 -0400

    unique application support
    
    Make palimpsest a unique application, using libunique.
    
    Signed-off-by: David Zeuthen <davidz redhat com>
---
 configure.ac               |    2 ++
 doc/TODO                   |    1 +
 src/palimpsest/Makefile.am |    2 ++
 src/palimpsest/gdu-main.c  |   35 +++++++++++++++++++++++++++++++++++
 4 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index 2b5c27a..50fd8ae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -126,6 +126,7 @@ POLKIT_GNOME_REQUIRED=0.7
 GNOME_KEYRING_REQUIRED=2.22
 GTK2_REQUIRED=2.6.0
 LIBSEXY_REQUIRED=0.1.11
+UNIQUE_REQUIRED=1.0
 
 SCROLLKEEPER_REQUIRED=0.3.14
 INTLTOOL_REQUIRED=0.35.0
@@ -140,6 +141,7 @@ PKG_CHECK_MODULES(POLKIT_GNOME, polkit-gnome >= $POLKIT_GNOME_REQUIRED)
 PKG_CHECK_MODULES(GNOME_KEYRING, gnome-keyring-1 >= $GNOME_KEYRING_REQUIRED)
 PKG_CHECK_MODULES(GTK2, gtk+-2.0 >= $GTK2_REQUIRED)
 PKG_CHECK_MODULES(LIBSEXY, libsexy >= $LIBSEXY_REQUIRED)
+PKG_CHECK_MODULES(UNIQUE, unique-1.0 >= $UNIQUE_REQUIRED)
 
 # *************
 # Documentation
diff --git a/doc/TODO b/doc/TODO
index a4db0bf..0ebbbeb 100644
--- a/doc/TODO
+++ b/doc/TODO
@@ -9,6 +9,7 @@
  - PolicyKit-gnome 0.9
  - dbus-glib
  - gio
+ - libunique
 
 ------------------------------------------------------------------------
 - TODO List
diff --git a/src/palimpsest/Makefile.am b/src/palimpsest/Makefile.am
index 21322c8..0dca7ad 100644
--- a/src/palimpsest/Makefile.am
+++ b/src/palimpsest/Makefile.am
@@ -39,6 +39,7 @@ palimpsest_CFLAGS = 					\
 	$(GNOME_KEYRING_CFLAGS)				\
 	$(GTK2_CFLAGS)					\
 	$(LIBSEXY_CFLAGS)				\
+	$(UNIQUE_CFLAGS)				\
 	$(WARN_CFLAGS)					\
 	$(AM_CFLAGS)
 
@@ -55,6 +56,7 @@ palimpsest_LDADD = 					\
 	$(GNOME_KEYRING_LIBS)				\
 	$(GTK2_LIBS)					\
 	$(LIBSEXY_LIBS)					\
+	$(UNIQUE_LIBS)					\
 	$(INTLLIBS)					\
 	$(top_builddir)/src/gdu/libgdu.la		\
 	$(top_builddir)/src/gdu-gtk/libgdu-gtk.la
diff --git a/src/palimpsest/gdu-main.c b/src/palimpsest/gdu-main.c
index a1dfe15..ba31d7c 100644
--- a/src/palimpsest/gdu-main.c
+++ b/src/palimpsest/gdu-main.c
@@ -24,6 +24,7 @@
 #include <string.h>
 #include <glib/gi18n.h>
 #include <polkit-gnome/polkit-gnome.h>
+#include <unique/unique.h>
 
 #include "gdu-shell.h"
 
@@ -56,16 +57,50 @@ show_nag_dialog (GtkWidget *toplevel)
         return ret;
 }
 
+enum {
+        CMD_PRESENT_WINDOW = 1
+};
+
+static UniqueResponse
+message_received (UniqueApp         *app,
+                  gint               command,
+                  UniqueMessageData *message_data,
+                  guint              timestamp,
+                  GduShell          *shell)
+{
+        switch (command) {
+        case CMD_PRESENT_WINDOW:
+                gtk_window_present (GTK_WINDOW (gdu_shell_get_toplevel (shell)));
+                return UNIQUE_RESPONSE_OK;
+        default:
+                return UNIQUE_RESPONSE_PASSTHROUGH;
+        }
+}
+
 int
 main (int argc, char **argv)
 {
         GduShell *shell;
+        UniqueApp *unique_app;
 
         gtk_init (&argc, &argv);
 
         gtk_window_set_default_icon_name ("palimpsest");
 
+        unique_app = unique_app_new_with_commands ("org.gnome.Palimpsest",
+                                                   NULL,
+                                                   "present_window", CMD_PRESENT_WINDOW,
+                                                   NULL);
+        if (unique_app_is_running (unique_app)) {
+                unique_app_send_message (unique_app, CMD_PRESENT_WINDOW, NULL);
+                return 0;
+        }
+
         shell = gdu_shell_new ();
+
+        g_signal_connect (unique_app, "message-received",
+                          G_CALLBACK (message_received), shell);
+
         gtk_widget_show_all (gdu_shell_get_toplevel (shell));
         gdu_shell_update (shell);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]