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
This commit is contained in:
parent
b6c2399a17
commit
4156a4c2d0
@ -23,7 +23,7 @@
|
|||||||
#include <telepathy-glib/debug-sender.h>
|
#include <telepathy-glib/debug-sender.h>
|
||||||
|
|
||||||
#include "shell-a11y.h"
|
#include "shell-a11y.h"
|
||||||
#include "shell-global.h"
|
#include "shell-global-private.h"
|
||||||
#include "shell-perf-log.h"
|
#include "shell-perf-log.h"
|
||||||
#include "st.h"
|
#include "st.h"
|
||||||
|
|
||||||
@ -540,7 +540,7 @@ main (int argc, char **argv)
|
|||||||
g_log_set_default_handler (default_log_handler, sender);
|
g_log_set_default_handler (default_log_handler, sender);
|
||||||
|
|
||||||
/* Initialize the global object */
|
/* Initialize the global object */
|
||||||
shell_global_get ();
|
_shell_global_init (NULL);
|
||||||
|
|
||||||
ecode = meta_run ();
|
ecode = meta_run ();
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#include <gjs/gjs.h>
|
#include <gjs/gjs.h>
|
||||||
|
|
||||||
|
void _shell_global_init (const char *first_property_name,
|
||||||
|
...);
|
||||||
void _shell_global_set_plugin (ShellGlobal *global,
|
void _shell_global_set_plugin (ShellGlobal *global,
|
||||||
MetaPlugin *plugin);
|
MetaPlugin *plugin);
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -448,6 +449,37 @@ shell_global_class_init (ShellGlobalClass *klass)
|
|||||||
G_PARAM_READABLE));
|
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:
|
* shell_global_get:
|
||||||
*
|
*
|
||||||
@ -458,9 +490,6 @@ shell_global_class_init (ShellGlobalClass *klass)
|
|||||||
ShellGlobal *
|
ShellGlobal *
|
||||||
shell_global_get (void)
|
shell_global_get (void)
|
||||||
{
|
{
|
||||||
if (!the_object)
|
|
||||||
the_object = g_object_new (SHELL_TYPE_GLOBAL, 0);
|
|
||||||
|
|
||||||
return the_object;
|
return the_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user