[gnome-shell] shell-global: require init call before shell_global_get()
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] shell-global: require init call before shell_global_get()
- Date: Mon, 29 Aug 2011 16:20:48 +0000 (UTC)
commit 4156a4c2d015af81dae1c3d5b404a293075023fb
Author: Ray Strode <rstrode redhat com>
Date: Sun Aug 28 01:32:12 2011 -0400
shell-global: require init call before shell_global_get()
shell_global_get() currently implicitly instantiates the shell
global singleton the first time it's called. This means there's
no opportunity to set construction-time properties on the singleton.
This isn't an issue yet, because there aren't any. We will need it
in the future, though, when we grow a --gdm-mode that gets exposed as
a property through the global singleton.
This commit adds a new _shell_global_init() function that must be
invoked before shell_global_get() can be called.
https://bugzilla.gnome.org/show_bug.cgi?id=657082
src/main.c | 4 ++--
src/shell-global-private.h | 2 ++
src/shell-global.c | 35 ++++++++++++++++++++++++++++++++---
3 files changed, 36 insertions(+), 5 deletions(-)
---
diff --git a/src/main.c b/src/main.c
index d970887..1b96a25 100644
--- a/src/main.c
+++ b/src/main.c
@@ -23,7 +23,7 @@
#include <telepathy-glib/debug-sender.h>
#include "shell-a11y.h"
-#include "shell-global.h"
+#include "shell-global-private.h"
#include "shell-perf-log.h"
#include "st.h"
@@ -540,7 +540,7 @@ main (int argc, char **argv)
g_log_set_default_handler (default_log_handler, sender);
/* Initialize the global object */
- shell_global_get ();
+ _shell_global_init (NULL);
ecode = meta_run ();
diff --git a/src/shell-global-private.h b/src/shell-global-private.h
index 2dd698f..f10dfb8 100644
--- a/src/shell-global-private.h
+++ b/src/shell-global-private.h
@@ -6,6 +6,8 @@
#include <gjs/gjs.h>
+void _shell_global_init (const char *first_property_name,
+ ...);
void _shell_global_set_plugin (ShellGlobal *global,
MetaPlugin *plugin);
diff --git a/src/shell-global.c b/src/shell-global.c
index 07a51a2..7160c2d 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -6,6 +6,7 @@
#include <errno.h>
#include <fcntl.h>
#include <math.h>
+#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -448,6 +449,37 @@ shell_global_class_init (ShellGlobalClass *klass)
G_PARAM_READABLE));
}
+/**â
+ * _shell_global_init: (skip)â
+ * @first_property_name: the name of the first property
+ * @...: the value of the first property, followed optionally by more
+ * name/value pairs, followed by %NULL
+ *â
+ * Initializes the shell global singleton with the construction-time
+ * properties.
+ *
+ * There are currently no such properties, so @first_property_name should
+ * always be %NULL.
+ *
+ * This call must be called before shell_global_get() and shouldn't be called
+ * more than once.
+ */
+void
+_shell_global_init (const char *first_property_name,
+ ...)
+{
+ va_list argument_list;
+
+ g_return_if_fail (the_object == NULL);
+
+ va_start (argument_list, first_property_name);
+ the_object = SHELL_GLOBAL (g_object_new_valist (SHELL_TYPE_GLOBAL,
+ first_property_name,
+ argument_list));
+ va_end (argument_list);
+
+}
+
/**
* shell_global_get:
*
@@ -458,9 +490,6 @@ shell_global_class_init (ShellGlobalClass *klass)
ShellGlobal *
shell_global_get (void)
{
- if (!the_object)
- the_object = g_object_new (SHELL_TYPE_GLOBAL, 0);
-
return the_object;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]