summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2010-06-20 22:07:05 +0100
committerThomas Wood <thomas.wood@intel.com>2010-06-21 16:30:44 +0100
commitae7944a0c8e3e6b516073dd8484b774a5ad191a6 (patch)
tree602b54a33f2e99559186a34266a7b9a26edc5e96
parentf4ef1914628de1c9853834cffdaee61ad3cff4cb (diff)
downloadgnome-control-center-ae7944a0c8e3e6b516073dd8484b774a5ad191a6.tar.gz
Convert from libunique to GtkApplication to remove the final gtk-2.0 library
-rw-r--r--configure.ac2
-rw-r--r--shell/control-center.c75
2 files changed, 18 insertions, 59 deletions
diff --git a/configure.ac b/configure.ac
index 8cc80d4bc..226e4d9f5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -115,7 +115,7 @@ COMMON_MODULES="gtk+-3.0 >= 2.90.0 dnl
gnome-desktop-3.0 >= 2.29.4"
PKG_CHECK_MODULES(CAPPLET, $COMMON_MODULES)
PKG_CHECK_MODULES(GNOMECC, $COMMON_MODULES libgnome-menu >= 2.10.1)
-PKG_CHECK_MODULES(GNOMECC_SHELL, $COMMON_MODULES libgnome-menu unique-1.0 gio-unix-2.0)
+PKG_CHECK_MODULES(GNOMECC_SHELL, $COMMON_MODULES libgnome-menu gio-unix-2.0)
PKG_CHECK_MODULES(DBUS, dbus-1 dbus-glib-1)
PKG_CHECK_MODULES(GNOME_DESKTOP, gnome-desktop-2.0)
PKG_CHECK_MODULES(DEFAULT_APPLICATIONS_CAPPLET, libxml-2.0)
diff --git a/shell/control-center.c b/shell/control-center.c
index 1451e0a9e..6f5fe189e 100644
--- a/shell/control-center.c
+++ b/shell/control-center.c
@@ -28,34 +28,22 @@
#include <gtk/gtk.h>
#include <string.h>
-
-#include <unique/unique.h>
-
-
-enum
-{
- CC_SHELL_RAISE_COMMAND = 1
-};
-
-
-static UniqueResponse
-message_received (UniqueApp *app,
- gint command,
- UniqueMessageData *message_data,
- guint time_,
- GnomeControlCenter *shell)
+static void
+application_prepare_action_cb (GApplication *application, GVariant *arguments,
+ GVariant *platform_data, GnomeControlCenter *shell)
{
- const gchar *id;
- gsize len;
+ GVariantIter iter;
+ GVariant *temp = NULL;
gnome_control_center_present (shell);
- id = (gchar*) unique_message_data_get (message_data, &len);
-
- if (id)
+ /* we only care about the first argv */
+ g_variant_iter_init (&iter, arguments);
+ temp = g_variant_iter_next_value (&iter);
+ if (temp != NULL)
{
GError *err = NULL;
-
+ const gchar *id = g_variant_get_byte_array (temp, NULL);
if (!cc_shell_set_active_panel_from_id (CC_SHELL (shell), id, &err))
{
if (err)
@@ -63,19 +51,16 @@ message_received (UniqueApp *app,
g_warning ("Could not load setting panel \"%s\": %s", id,
err->message);
g_error_free (err);
- err = NULL;
}
}
}
-
- return GTK_RESPONSE_OK;
}
int
main (int argc, char **argv)
{
GnomeControlCenter *shell;
- UniqueApp *unique;
+ GtkApplication *application;
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
@@ -85,39 +70,12 @@ main (int argc, char **argv)
g_thread_init (NULL);
gtk_init (&argc, &argv);
-
- /* use Unique to enforce single instance of this application */
- unique = unique_app_new_with_commands ("org.gnome.ControlCenter",
- NULL,
- "raise",
- CC_SHELL_RAISE_COMMAND,
- NULL);
-
- /* check if the application is already running */
- if (unique_app_is_running (unique))
- {
- UniqueMessageData *data;
-
- if (argc == 2)
- {
- data = unique_message_data_new ();
- unique_message_data_set (data, (guchar*) argv[1],
- strlen(argv[1]) + 1);
- }
- else
- data = NULL;
-
- unique_app_send_message (unique, 1, data);
-
- gdk_notify_startup_complete ();
- return 0;
- }
-
-
shell = gnome_control_center_new ();
- g_signal_connect (unique, "message-received", G_CALLBACK (message_received),
- shell);
+ /* enforce single instance of this application */
+ application = gtk_application_new ("org.gnome.ControlCenter", &argc, &argv);
+ g_signal_connect (application, "prepare-activation",
+ G_CALLBACK (application_prepare_action_cb), shell);
if (argc == 2)
{
@@ -138,9 +96,10 @@ main (int argc, char **argv)
}
}
- gtk_main ();
+ gtk_application_run (application);
g_object_unref (shell);
+ g_object_unref (application);
return 0;
}