From cfdc9a83b9d5441c94f811451146023cd41a4661 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Orsini Date: Tue, 24 Apr 2012 08:03:08 +0000 Subject: [PATCH] implemented the psensor uniquess, non-primary psensor instances show the window of the primary psensor instance and exits. --- NEWS | 3 +++ po/Makefile.in | 8 ++++---- src/main.c | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 00751ae..ad60b4b 100644 --- a/NEWS +++ b/NEWS @@ -26,6 +26,9 @@ ** psensor: fixed many memory leaks in cfg.c (gconf2 keys). ** psensor: fixed memory leak (sensor name when specified by the configuration). +** psensor: implemented the psensor uniquess, non-primary psensor + instances show the window of the primary psensor instance and + exits. * v0.6.2.17 diff --git a/po/Makefile.in b/po/Makefile.in index 136065a..59dadd7 100644 --- a/po/Makefile.in +++ b/po/Makefile.in @@ -21,7 +21,7 @@ srcdir = . top_srcdir = .. -prefix = /tmp/p +prefix = /usr exec_prefix = ${prefix} datarootdir = ${prefix}/share datadir = ${datarootdir} @@ -34,12 +34,12 @@ INSTALL_DATA = ${INSTALL} -m 644 # We use $(mkdir_p). # In automake <= 1.9.x, $(mkdir_p) is defined either as "mkdir -p --" or as # "$(mkinstalldirs)" or as "$(install_sh) -d". For these automake versions, -# ${SHELL} /home/jporsini/work/wpitchoune.net/svnpub/psensor/trunk/install-sh does not start with $(SHELL), so we add it. +# ${SHELL} /mnt/nfs4/users/jporsini/work/wpitchoune.net/svnpub/psensor/trunk/install-sh does not start with $(SHELL), so we add it. # In automake >= 1.10, /bin/mkdir -p is derived from ${MKDIR_P}, which is defined # either as "/path/to/mkdir -p" or ".../install-sh -c -d". For these automake # versions, $(mkinstalldirs) and $(install_sh) are unused. -mkinstalldirs = $(SHELL) ${SHELL} /home/jporsini/work/wpitchoune.net/svnpub/psensor/trunk/install-sh -d -install_sh = $(SHELL) ${SHELL} /home/jporsini/work/wpitchoune.net/svnpub/psensor/trunk/install-sh +mkinstalldirs = $(SHELL) ${SHELL} /mnt/nfs4/users/jporsini/work/wpitchoune.net/svnpub/psensor/trunk/install-sh -d +install_sh = $(SHELL) ${SHELL} /mnt/nfs4/users/jporsini/work/wpitchoune.net/svnpub/psensor/trunk/install-sh MKDIR_P = /bin/mkdir -p mkdir_p = /bin/mkdir -p diff --git a/src/main.c b/src/main.c index 89cf2b9..fd1d44b 100644 --- a/src/main.c +++ b/src/main.c @@ -383,6 +383,12 @@ static void log_glib_info() glib_micro_version); } +static void activate(GApplication *application, + gpointer data) +{ + ui_window_show((struct ui_psensor *)data); +} + int main(int argc, char **argv) { struct ui_psensor ui; @@ -390,6 +396,7 @@ int main(int argc, char **argv) GThread *thread; int optc, cmdok, opti, use_libatasmart; char *url = NULL; + GApplication *app; program_name = argv[0]; @@ -438,6 +445,17 @@ int main(int argc, char **argv) log_init(); + app = g_application_new("wpitchoune.psensor", 0); + g_application_register(app, NULL, NULL); + + if (g_application_get_is_remote(app)) { + g_application_activate(app); + log_debug(_("Psensor instance already exists")); + exit(EXIT_SUCCESS); + } + + g_signal_connect(app, "activate", G_CALLBACK(activate), &ui); + log_glib_info(); #if !(GLIB_CHECK_VERSION(2, 31, 0)) /* -- 2.7.4