[gnome-user-share] Make the preferences single-instance
- From: Bastien Nocera <hadess src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-user-share] Make the preferences single-instance
- Date: Thu, 26 Nov 2009 14:39:23 +0000 (UTC)
commit a3f6cbcd22360bfb12b2ecb8b0f6481f4d115eee
Author: Bastien Nocera <hadess hadess net>
Date: Thu Nov 26 14:36:33 2009 +0000
Make the preferences single-instance
configure.in | 2 +-
src/file-share-properties.c | 23 +++++++++++++++++++++++
2 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/configure.in b/configure.in
index a4a0799..4110e59 100644
--- a/configure.in
+++ b/configure.in
@@ -60,7 +60,7 @@ PKG_CHECK_MODULES(USER_SHARE, glib-2.0 >= 2.15.2 gio-2.0 gdk-x11-2.0 gtk+-2.0 gc
AC_SUBST(USER_SHARE_CFLAGS)
AC_SUBST(USER_SHARE_LIBS)
-PKG_CHECK_MODULES(USER_SHARE_CONFIG, glib-2.0 >= 2.15.2 gtk+-2.0 >= 2.12.0 gconf-2.0)
+PKG_CHECK_MODULES(USER_SHARE_CONFIG, glib-2.0 >= 2.15.2 gtk+-2.0 >= 2.12.0 gconf-2.0 unique-1.0)
AC_SUBST(USER_SHARE_CONFIG_CFLAGS)
AC_SUBST(USER_SHARE_CONFIG_LIBS)
diff --git a/src/file-share-properties.c b/src/file-share-properties.c
index b858e78..17dc9bb 100644
--- a/src/file-share-properties.c
+++ b/src/file-share-properties.c
@@ -29,6 +29,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <gconf/gconf-client.h>
+#include <unique/uniqueapp.h>
#include "user_share-private.h"
@@ -469,6 +470,18 @@ help_button_clicked (GtkButton *button, GtkWidget *window)
}
}
+static UniqueResponse
+message_received_cb (UniqueApp *app,
+ int command,
+ UniqueMessageData *message_data,
+ guint time_,
+ gpointer user_data)
+{
+ gtk_window_present (GTK_WINDOW (user_data));
+
+ return UNIQUE_RESPONSE_OK;
+}
+
int
main (int argc, char *argv[])
{
@@ -487,6 +500,7 @@ main (int argc, char *argv[])
GtkListStore *store;
GtkCellRenderer *cell;
GtkTreeIter iter;
+ UniqueApp *app;
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
@@ -494,6 +508,13 @@ main (int argc, char *argv[])
gtk_init (&argc, &argv);
+ app = unique_app_new ("org.gnome.user-share.properties", NULL);
+ if (unique_app_is_running (app)) {
+ gdk_notify_startup_complete ();
+ unique_app_send_message (app, UNIQUE_ACTIVATE, NULL);
+ return 0;
+ }
+
builder = gtk_builder_new ();
gtk_builder_add_from_file (builder, DATADIR"file-share-properties.ui", &error);
@@ -511,6 +532,8 @@ main (int argc, char *argv[])
window = GTK_WIDGET (gtk_builder_get_object (builder, "user_share_dialog"));
g_signal_connect (G_OBJECT (window), "delete_event",
G_CALLBACK (gtk_main_quit), NULL);
+ g_signal_connect (app, "message-received",
+ G_CALLBACK (message_received_cb), window);
client = gconf_client_get_default ();
gconf_client_add_dir (client,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]