global: Add session-mode property

Add a session-mode property on ShellGlobal which corresponds to the
new --mode switch. Make the existing ShellGlobal:session-type property
readonly and base it on ShellGlobal:session-mode to avoid conflicts.

https://bugzilla.gnome.org/show_bug.cgi?id=676156
This commit is contained in:
Florian Müllner 2012-05-16 23:11:57 +02:00
parent 5617f91281
commit 940ddb104c
3 changed files with 30 additions and 13 deletions

View File

@ -277,7 +277,6 @@ main (int argc, char **argv)
{ {
GOptionContext *ctx; GOptionContext *ctx;
GError *error = NULL; GError *error = NULL;
ShellSessionType session_type;
int ecode; int ecode;
TpDebugSender *sender; TpDebugSender *sender;
@ -331,14 +330,10 @@ 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 */
if (g_strcmp0 (session_mode, "gdm") == 0) if (session_mode == NULL)
session_type = SHELL_SESSION_GDM; session_mode = is_gdm_mode ? "gdm" : "user";
else if (is_gdm_mode)
session_type = SHELL_SESSION_GDM;
else
session_type = SHELL_SESSION_USER;
_shell_global_init ("session-type", session_type, NULL); _shell_global_init ("session-mode", session_mode, NULL);
ecode = meta_run (); ecode = meta_run ();

View File

@ -59,7 +59,7 @@ struct _ShellGlobal {
MetaScreen *meta_screen; MetaScreen *meta_screen;
GdkScreen *gdk_screen; GdkScreen *gdk_screen;
ShellSessionType session_type; char *session_mode;
/* We use this window to get a notification from GTK+ when /* We use this window to get a notification from GTK+ when
* a widget in our process does a GTK+ grab. See * a widget in our process does a GTK+ grab. See
@ -98,6 +98,7 @@ enum {
PROP_0, PROP_0,
PROP_SESSION_TYPE, PROP_SESSION_TYPE,
PROP_SESSION_MODE,
PROP_OVERLAY_GROUP, PROP_OVERLAY_GROUP,
PROP_SCREEN, PROP_SCREEN,
PROP_GDK_SCREEN, PROP_GDK_SCREEN,
@ -143,8 +144,9 @@ shell_global_set_property(GObject *object,
case PROP_STAGE_INPUT_MODE: case PROP_STAGE_INPUT_MODE:
shell_global_set_stage_input_mode (global, g_value_get_enum (value)); shell_global_set_stage_input_mode (global, g_value_get_enum (value));
break; break;
case PROP_SESSION_TYPE: case PROP_SESSION_MODE:
global->session_type = g_value_get_enum (value); g_clear_pointer (&global->session_mode, g_free);
global->session_mode = g_ascii_strdown (g_value_get_string (value), -1);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -165,6 +167,9 @@ shell_global_get_property(GObject *object,
case PROP_SESSION_TYPE: case PROP_SESSION_TYPE:
g_value_set_enum (value, shell_global_get_session_type (global)); g_value_set_enum (value, shell_global_get_session_type (global));
break; break;
case PROP_SESSION_MODE:
g_value_set_string (value, shell_global_get_session_mode (global));
break;
case PROP_OVERLAY_GROUP: case PROP_OVERLAY_GROUP:
g_value_set_object (value, meta_get_overlay_group_for_screen (global->meta_screen)); g_value_set_object (value, meta_get_overlay_group_for_screen (global->meta_screen));
break; break;
@ -349,6 +354,13 @@ shell_global_class_init (ShellGlobalClass *klass)
"The type of session", "The type of session",
SHELL_TYPE_SESSION_TYPE, SHELL_TYPE_SESSION_TYPE,
SHELL_SESSION_USER, SHELL_SESSION_USER,
G_PARAM_READABLE));
g_object_class_install_property (gobject_class,
PROP_SESSION_MODE,
g_param_spec_string ("session-mode",
"Session Mode",
"The session mode to use",
"user",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_OVERLAY_GROUP, PROP_OVERLAY_GROUP,
@ -1802,5 +1814,14 @@ shell_global_get_session_type (ShellGlobal *global)
g_return_val_if_fail (SHELL_IS_GLOBAL (global), g_return_val_if_fail (SHELL_IS_GLOBAL (global),
SHELL_SESSION_USER); SHELL_SESSION_USER);
return global->session_type; return strcmp (global->session_mode, "gdm") == 0 ? SHELL_SESSION_GDM
: SHELL_SESSION_USER;
}
const char *
shell_global_get_session_mode (ShellGlobal *global)
{
g_return_val_if_fail (SHELL_IS_GLOBAL (global), "user");
return global->session_mode;
} }

View File

@ -147,6 +147,7 @@ typedef enum {
} ShellSessionType; } ShellSessionType;
ShellSessionType shell_global_get_session_type (ShellGlobal *global); ShellSessionType shell_global_get_session_type (ShellGlobal *global);
const char * shell_global_get_session_mode (ShellGlobal *global);
G_END_DECLS G_END_DECLS