[gnome-control-center] shell: Make it build and work against new GApplication
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] shell: Make it build and work against new GApplication
- Date: Fri, 22 Oct 2010 13:08:35 +0000 (UTC)
commit 93ee44fe43cd132110fb0a066f1bac3c7f2ecd88
Author: Bastien Nocera <hadess hadess net>
Date: Fri Oct 22 14:08:11 2010 +0100
shell: Make it build and work against new GApplication
shell/control-center.c | 72 ++++++++++++++++++-----------------------
shell/gnome-control-center.c | 15 +++++---
shell/gnome-control-center.h | 2 +
3 files changed, 43 insertions(+), 46 deletions(-)
---
diff --git a/shell/control-center.c b/shell/control-center.c
index be23207..ece261b 100644
--- a/shell/control-center.c
+++ b/shell/control-center.c
@@ -28,34 +28,43 @@
#include <gtk/gtk.h>
#include <string.h>
+
static void
-application_prepare_action_cb (GApplication *application,
- GVariant *arguments,
- GVariant *platform_data,
- GnomeControlCenter *shell)
+application_command_line_cb (GApplication *application,
+ GApplicationCommandLine *command_line,
+ GnomeControlCenter *shell)
{
- const gchar **argv;
- gsize length;
-
- gnome_control_center_present (shell);
+ int argc;
+ char **argv;
- argv = g_variant_get_bytestring_array (arguments, &length);
-
- if (length == 2)
+ g_application_command_line_get_argc_argv (command_line, &argc, &argv);
+ if (argc == 2)
{
+ gchar *start_id;
GError *err = NULL;
- const gchar *id = argv[1];
- if (!cc_shell_set_active_panel_from_id (CC_SHELL (shell), id, &err))
+ start_id = argv[1];
+
+ if (!cc_shell_set_active_panel_from_id (CC_SHELL (shell), start_id, &err))
{
+ g_warning ("Could not load setting panel \"%s\": %s", start_id,
+ (err) ? err->message : "Unknown error");
if (err)
{
- g_warning ("Could not load setting panel \"%s\": %s", id,
- err->message);
g_error_free (err);
+ err = NULL;
}
}
}
+ g_strfreev (argv);
+}
+
+static void
+application_startup_cb (GApplication *application,
+ GnomeControlCenter *shell)
+{
+ gnome_control_center_show (shell, GTK_APPLICATION (application));
+ gnome_control_center_present (shell);
}
int
@@ -63,6 +72,7 @@ main (int argc, char **argv)
{
GnomeControlCenter *shell;
GtkApplication *application;
+ int status;
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
@@ -75,33 +85,15 @@ main (int argc, char **argv)
shell = gnome_control_center_new ();
/* 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)
- {
- gchar *start_id;
- GError *err = NULL;
-
- start_id = argv[1];
-
- if (!cc_shell_set_active_panel_from_id (CC_SHELL (shell), start_id, &err))
- {
- g_warning ("Could not load setting panel \"%s\": %s", start_id,
- (err) ? err->message : "Unknown error");
- if (err)
- {
- g_error_free (err);
- err = NULL;
- }
- }
- }
+ application = gtk_application_new ("org.gnome.ControlCenter", G_APPLICATION_HANDLES_COMMAND_LINE);
+ g_signal_connect (application, "startup",
+ G_CALLBACK (application_startup_cb), shell);
+ g_signal_connect (application, "command-line",
+ G_CALLBACK (application_command_line_cb), shell);
- gtk_application_run (application);
+ status = g_application_run (G_APPLICATION (application), argc, argv);
- g_object_unref (shell);
g_object_unref (application);
- return 0;
+ return status;
}
diff --git a/shell/gnome-control-center.c b/shell/gnome-control-center.c
index 5f4d3e3..0ce0844 100644
--- a/shell/gnome-control-center.c
+++ b/shell/gnome-control-center.c
@@ -874,7 +874,6 @@ gnome_control_center_finalize (GObject *object)
{
GnomeControlCenterPrivate *priv = GNOME_CONTROL_CENTER (object)->priv;
-
if (priv->filter_string)
{
g_free (priv->filter_string);
@@ -950,8 +949,7 @@ gnome_control_center_init (GnomeControlCenter *self)
/* connect various signals */
priv->window = W (priv->builder, "main-window");
- g_signal_connect (priv->window, "delete-event", G_CALLBACK (gtk_main_quit),
- NULL);
+ g_signal_connect_swapped (priv->window, "delete-event", G_CALLBACK (g_object_unref), self);
priv->notebook = W (priv->builder, "notebook");
@@ -981,9 +979,6 @@ gnome_control_center_init (GnomeControlCenter *self)
/* setup search functionality */
setup_search (self);
-
- gtk_widget_show_all (priv->window);
-
/* store default window title and name */
priv->default_window_title = g_strdup (gtk_window_get_title (GTK_WINDOW (priv->window)));
priv->default_window_icon = g_strdup (gtk_window_get_icon_name (GTK_WINDOW (priv->window)));
@@ -1000,3 +995,11 @@ gnome_control_center_present (GnomeControlCenter *center)
{
gtk_window_present (GTK_WINDOW (center->priv->window));
}
+
+void
+gnome_control_center_show (GnomeControlCenter *center,
+ GtkApplication *app)
+{
+ gtk_window_set_application (GTK_WINDOW (center->priv->window), app);
+ gtk_widget_show_all (center->priv->window);
+}
diff --git a/shell/gnome-control-center.h b/shell/gnome-control-center.h
index 09ba5de..10a4c35 100644
--- a/shell/gnome-control-center.h
+++ b/shell/gnome-control-center.h
@@ -70,6 +70,8 @@ GnomeControlCenter *gnome_control_center_new (void);
void gnome_control_center_present (GnomeControlCenter *center);
+void gnome_control_center_show (GnomeControlCenter *center, GtkApplication *app);
+
G_END_DECLS
#endif /* _GNOME_CONTROL_CENTER_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]