[gnome-shell] global: Add session-mode property



commit 940ddb104c1bb6c79ab6b830735366f3d5650ba2
Author: Florian MÃllner <fmuellner gnome org>
Date:   Wed May 16 23:11:57 2012 +0200

    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

 src/main.c         |   13 ++++---------
 src/shell-global.c |   31 ++++++++++++++++++++++++++-----
 src/shell-global.h |    1 +
 3 files changed, 31 insertions(+), 14 deletions(-)
---
diff --git a/src/main.c b/src/main.c
index b19ff29..bd3b128 100644
--- a/src/main.c
+++ b/src/main.c
@@ -277,7 +277,6 @@ main (int argc, char **argv)
 {
   GOptionContext *ctx;
   GError *error = NULL;
-  ShellSessionType session_type;
   int ecode;
   TpDebugSender *sender;
 
@@ -331,14 +330,10 @@ main (int argc, char **argv)
   g_log_set_default_handler (default_log_handler, sender);
 
   /* Initialize the global object */
-  if (g_strcmp0 (session_mode, "gdm") == 0)
-      session_type = SHELL_SESSION_GDM;
-  else if (is_gdm_mode)
-      session_type = SHELL_SESSION_GDM;
-  else
-      session_type = SHELL_SESSION_USER;
-
-  _shell_global_init ("session-type", session_type, NULL);
+  if (session_mode == NULL)
+    session_mode = is_gdm_mode ? "gdm" : "user";
+
+  _shell_global_init ("session-mode", session_mode, NULL);
 
   ecode = meta_run ();
 
diff --git a/src/shell-global.c b/src/shell-global.c
index be14fa3..0195019 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -59,7 +59,7 @@ struct _ShellGlobal {
   MetaScreen *meta_screen;
   GdkScreen *gdk_screen;
 
-  ShellSessionType session_type;
+  char *session_mode;
 
   /* We use this window to get a notification from GTK+ when
    * a widget in our process does a GTK+ grab.  See
@@ -98,6 +98,7 @@ enum {
   PROP_0,
 
   PROP_SESSION_TYPE,
+  PROP_SESSION_MODE,
   PROP_OVERLAY_GROUP,
   PROP_SCREEN,
   PROP_GDK_SCREEN,
@@ -143,8 +144,9 @@ shell_global_set_property(GObject         *object,
     case PROP_STAGE_INPUT_MODE:
       shell_global_set_stage_input_mode (global, g_value_get_enum (value));
       break;
-    case PROP_SESSION_TYPE:
-      global->session_type = g_value_get_enum (value);
+    case PROP_SESSION_MODE:
+      g_clear_pointer (&global->session_mode, g_free);
+      global->session_mode = g_ascii_strdown (g_value_get_string (value), -1);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -165,6 +167,9 @@ shell_global_get_property(GObject         *object,
     case PROP_SESSION_TYPE:
       g_value_set_enum (value, shell_global_get_session_type (global));
       break;
+    case PROP_SESSION_MODE:
+      g_value_set_string (value, shell_global_get_session_mode (global));
+      break;
     case PROP_OVERLAY_GROUP:
       g_value_set_object (value, meta_get_overlay_group_for_screen (global->meta_screen));
       break;
@@ -349,7 +354,14 @@ shell_global_class_init (ShellGlobalClass *klass)
                                                       "The type of session",
                                                       SHELL_TYPE_SESSION_TYPE,
                                                       SHELL_SESSION_USER,
-                                                      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+                                                      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_object_class_install_property (gobject_class,
                                    PROP_OVERLAY_GROUP,
                                    g_param_spec_object ("overlay-group",
@@ -1802,5 +1814,14 @@ shell_global_get_session_type (ShellGlobal  *global)
   g_return_val_if_fail (SHELL_IS_GLOBAL (global),
                         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;
 }
diff --git a/src/shell-global.h b/src/shell-global.h
index 5a39e79..908ec9e 100644
--- a/src/shell-global.h
+++ b/src/shell-global.h
@@ -147,6 +147,7 @@ typedef enum {
 } ShellSessionType;
 
 ShellSessionType shell_global_get_session_type  (ShellGlobal  *global);
+const char *     shell_global_get_session_mode  (ShellGlobal  *global);
 
 G_END_DECLS
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]