[gnome-video-arcade] Add libunique dependency.



commit e7e2760c248595a7a43e7fbad6ea29f14a1d63f6
Author: Matthew Barnes <mbarnes redhat com>
Date:   Mon May 31 21:03:31 2010 -0400

    Add libunique dependency.
    
    GNOME Video Arcade is now a "single-instance" application.  That means
    if you launch it while it's already running, it will simply present the
    existing window instead of creating a second window.

 NEWS                       |    4 ++++
 configure.ac               |    5 +++++
 docs/reference/Makefile.am |    2 ++
 maint/Makefile.am          |    6 ++++--
 src/Makefile.am            |    5 +++--
 src/gva-common.h           |    1 +
 src/main.c                 |   41 ++++++++++++++++++++++++++++++++++++++---
 7 files changed, 57 insertions(+), 7 deletions(-)
---
diff --git a/NEWS b/NEWS
index 3e2dedc..be8a3b8 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,10 @@ GNOME Video Arcade 0.7.1
           such as adding or removing games, while its running and offers
           to rescan your ROM files in order to present an updated game
           list without having to restart the application.
+        * GNOME Video Arcade is now a "single-instance" application.
+          That means if you launch it while it's already running, it
+          will simply present the existing window instead of creating
+          a second window.  This adds a new dependency on libunique.
 
 GNOME Video Arcade 0.7.0
 ========================
diff --git a/configure.ac b/configure.ac
index e17631b..957744f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -48,6 +48,11 @@ PKG_CHECK_MODULES(SQLITE, $SQLITE_MODULES)
 AC_SUBST(SQLITE_CFLAGS)
 AC_SUBST(SQLITE_LIBS)
 
+UNIQUE_MODULES="unique-1.0 >= 1.0"
+PKG_CHECK_MODULES(UNIQUE, $UNIQUE_MODULES)
+AC_SUBST(UNIQUE_CFLAGS)
+AC_SUBST(UNIQUE_LIBS)
+
 # --with-dbus=[yes|no]
 DBUS_CFLAGS=
 DBUS_LIBS=
diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am
index 38f1532..f732a7e 100644
--- a/docs/reference/Makefile.am
+++ b/docs/reference/Makefile.am
@@ -81,6 +81,7 @@ INCLUDES=							\
 	$(GCONF_CFLAGS)						\
 	$(GSTREAMER_CFLAGS)					\
 	$(SQLITE_CFLAGS)					\
+	$(UNIQUE_CFLAGS)					\
 	$(WNCK_CFLAGS)
 
 if HAVE_DBUS
@@ -124,6 +125,7 @@ GTKDOC_LIBS=							\
 	$(GCONF_LIBS)						\
 	$(GSTREAMER_LIBS)					\
 	$(SQLITE_LIBS)						\
+	$(UNIQUE_LIBS)						\
 	$(WNCK_LIBS)
 
 # This includes the standard gtk-doc make rules, copied by gtkdocize.
diff --git a/maint/Makefile.am b/maint/Makefile.am
index caaf2f3..103c8be 100644
--- a/maint/Makefile.am
+++ b/maint/Makefile.am
@@ -13,7 +13,8 @@ gladegvadir = `$(PKG_CONFIG) --variable=moduledir gladeui-1.0`
 
 libgladegva_la_CFLAGS = \
 	@GLIB_CFLAGS@ @GTK_CFLAGS@ \
-	@GCONF_CFLAGS@ @GSTREAMER_CFLAGS@
+	@GCONF_CFLAGS@ @GSTREAMER_CFLAGS@ \
+	@UNIQUE_CFLAGS@
 
 libgladegva_la_SOURCES = \
 	$(top_srcdir)/src/gva-column-manager.c \
@@ -25,7 +26,8 @@ libgladegva_la_LDFLAGS = \
 
 libgladegva_la_LIBADD = \
 	@GLIB_LIBS@ @GTK_LIBS@ \
-	@GCONF_LIBS@ @GSTREAMER_LIBS@
+	@GCONF_LIBS@ @GSTREAMER_LIBS@ \
+	@UNIQUE_LIBS@
 
 EXTRA_DIST = \
 	$(gladecatalog_DATA) \
diff --git a/src/Makefile.am b/src/Makefile.am
index f39f0b5..d15fffe 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,7 +6,7 @@ AM_CFLAGS = \
 	-Wall \
 	@DBUS_CFLAGS@ @GLIB_CFLAGS@ @GTK_CFLAGS@ \
 	@GIT_CFLAGS@ @GCONF_CFLAGS@ @GSTREAMER_CFLAGS@ \
-	@SQLITE_CFLAGS@ @WNCK_CFLAGS@
+	@SQLITE_CFLAGS@ @UNIQUE_CFLAGS@ @WNCK_CFLAGS@
 
 AM_CPPFLAGS = \
 	-DG_LOG_DOMAIN=\"Gva\" \
@@ -89,7 +89,8 @@ EXTRA_gnome_video_arcade_SOURCES = \
 gnome_video_arcade_LDADD = \
 	@DBUS_LIBS@ @GLIB_LIBS@ @GTK_LIBS@ \
 	@GIT_LIBS@ @GCONF_LIBS@ @GSTREAMER_LIBS@ \
-	@MAME_BACKEND@ @SQLITE_LIBS@ @WNCK_LIBS@
+	@MAME_BACKEND@ @SQLITE_LIBS@ @UNIQUE_LIBS@ \
+	@WNCK_LIBS@
 
 gnome_video_arcade_DEPENDENCIES = \
 	@MAME_BACKEND@
diff --git a/src/gva-common.h b/src/gva-common.h
index 9dc401b..635a77b 100644
--- a/src/gva-common.h
+++ b/src/gva-common.h
@@ -39,6 +39,7 @@
 #endif
 
 #include <sqlite3.h>
+#include <unique/unique.h>
 #include <gconf/gconf-client.h>
 #include "gconf-bridge.h"               /* Embedded in GVA */
 
diff --git a/src/main.c b/src/main.c
index a09ed1c..7eb84e4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -282,6 +282,7 @@ setup_file_monitors (void)
 gint
 main (gint argc, gchar **argv)
 {
+        UniqueApp *app;
         gchar *path;
         GError *error = NULL;
 
@@ -329,19 +330,51 @@ main (gint argc, gchar **argv)
                         g_printerr ("%s\n", error->message);
                         g_clear_error (&error);
                 }
-                exit (0);
+                exit (EXIT_SUCCESS);
         }
 
         if (opt_version)
         {
                 g_print ("%s\n", PACKAGE_STRING);
-                exit (0);
+                exit (EXIT_SUCCESS);
         }
 
         if (opt_which_emulator)
         {
                 g_print ("%s\n", MAME_PROGRAM);
-                exit (0);
+                exit (EXIT_SUCCESS);
+        }
+
+        /* If another instance is running, exit now. */
+        app = unique_app_new ("org.gnome.GnomeVideoArcade", NULL);
+        if (unique_app_is_running (app))
+        {
+                gint exit_status;
+
+                if (opt_build_database)
+                {
+                        g_printerr (
+                                "Cannot build database: "
+                                PACKAGE_NAME " is already running\n");
+                        exit_status = EXIT_FAILURE;
+                }
+                else
+                {
+                        /* XXX Not handling response, but no real need to. */
+                        unique_app_send_message (app, UNIQUE_ACTIVATE, NULL);
+                        exit_status = EXIT_SUCCESS;
+                }
+
+                g_object_unref (app);
+
+                exit (exit_status);
+        }
+        else
+        {
+                GtkWindow *window;
+
+                window = GTK_WINDOW (GVA_WIDGET_MAIN_WINDOW);
+                unique_app_watch_window (app, window);
         }
 
         gtk_window_set_default_icon_name (PACKAGE);
@@ -374,5 +407,7 @@ main (gint argc, gchar **argv)
 
         gtk_main ();
 
+        g_object_unref (app);
+
         return EXIT_SUCCESS;
 }



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