[gnome-control-center/extensible-shell] shell: Add single instance support
- From: Thomas Wood <thos src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/extensible-shell] shell: Add single instance support
- Date: Wed, 24 Mar 2010 16:08:21 +0000 (UTC)
commit fbb26e2477ede705b87f9da9d6faab4fcf74af00
Author: Thomas Wood <thomas wood intel com>
Date: Wed Mar 24 16:08:04 2010 +0000
shell: Add single instance support
Use libunique to add single instance support to the shell to prevent
multiple instances of the shell being started. If a second instance is
started it will raise the existing instance and quit.
shell/control-center.c | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/shell/control-center.c b/shell/control-center.c
index 0c405b9..84dde76 100644
--- a/shell/control-center.c
+++ b/shell/control-center.c
@@ -33,8 +33,15 @@
#include "cc-shell.h"
#include "shell-search-renderer.h"
+#include <unique/unique.h>
+
#define W(b,x) GTK_WIDGET (gtk_builder_get_object (b, x))
+enum
+{
+ CC_SHELL_RAISE_COMMAND = 1
+};
+
typedef struct
{
GtkBuilder *builder;
@@ -479,16 +486,40 @@ search_entry_clear_cb (GtkEntry *entry)
gtk_entry_set_text (entry, "");
}
+static UniqueResponse
+message_received (UniqueApp *app,
+ gint command,
+ UniqueMessageData *message_data,
+ guint time_,
+ GtkWindow *window)
+{
+ gtk_window_present (window);
+
+ return GTK_RESPONSE_OK;
+}
int
main (int argc, char **argv)
{
ShellData *data;
GtkWidget *widget;
+ UniqueApp *unique;
g_thread_init (NULL);
gtk_init (&argc, &argv);
+ unique = unique_app_new_with_commands ("org.gnome.ControlCenter",
+ NULL,
+ "raise",
+ CC_SHELL_RAISE_COMMAND,
+ NULL);
+
+ if (unique_app_is_running (unique))
+ {
+ unique_app_send_message (unique, 1, NULL);
+ return 0;
+ }
+
data = g_new0 (ShellData, 1);
data->builder = (GtkBuilder*) cc_shell_new ();
@@ -527,6 +558,10 @@ main (int argc, char **argv)
gtk_widget_show_all (data->window);
+ g_signal_connect (unique, "message-received", G_CALLBACK (message_received),
+ data->window);
+
+
if (argc == 2)
{
GtkTreeIter iter;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]