[gnome-shell/wip/gdm-shell: 14/16] global: Add concept of "session type"



commit 7efe068e1f83c2d0a14ec53ec0c95db47dbd8931
Author: Ray Strode <rstrode redhat com>
Date:   Tue Jun 21 10:09:09 2011 -0400

    global: Add concept of "session type"
    
    This commit introduces a "session type" for
    gnome-shell.  It essentially defines what
    mode of operation the shell runs in
    (normal-in-a-users-session mode, or at-the-login-screen mode).
    
    Note this commit only lays the groundwork.  Actually
    looking at the key and appropriately differentiating
    the UI will happen in a subsequent commit.

 src/main.c                 |   17 +++++++++-
 src/shell-global-private.h |    2 +
 src/shell-global.c         |   69 ++++++++++++++++++++++++++++++++++++++++++++
 src/shell-global.h         |    6 ++++
 4 files changed, 92 insertions(+), 2 deletions(-)
---
diff --git a/src/main.c b/src/main.c
index d970887..fe5d175 100644
--- a/src/main.c
+++ b/src/main.c
@@ -24,6 +24,7 @@
 
 #include "shell-a11y.h"
 #include "shell-global.h"
+#include "shell-global-private.h"
 #include "shell-perf-log.h"
 #include "st.h"
 
@@ -32,6 +33,8 @@ extern GType gnome_shell_plugin_get_type (void);
 #define SHELL_DBUS_SERVICE "org.gnome.Shell"
 #define MAGNIFIER_DBUS_SERVICE "org.gnome.Magnifier"
 
+static gboolean is_login_mode = FALSE;
+
 static void
 shell_dbus_init (gboolean replace)
 {
@@ -466,6 +469,12 @@ GOptionEntry gnome_shell_options[] = {
     N_("Print version"),
     NULL
   },
+  {
+    "login-mode", 0, 0, G_OPTION_ARG_NONE,
+    &is_login_mode,
+    N_("Login mode"),
+    NULL
+  },
   { NULL }
 };
 
@@ -474,6 +483,7 @@ main (int argc, char **argv)
 {
   GOptionContext *ctx;
   GError *error = NULL;
+  ShellGlobal *global;
   int ecode;
   TpDebugSender *sender;
 
@@ -540,14 +550,17 @@ main (int argc, char **argv)
   g_log_set_default_handler (default_log_handler, sender);
 
   /* Initialize the global object */
-  shell_global_get ();
+  global = shell_global_get ();
+
+  if (is_login_mode)
+    _shell_global_set_session_type (global, SHELL_SESSION_LOGIN);
 
   ecode = meta_run ();
 
   if (g_getenv ("GNOME_SHELL_ENABLE_CLEANUP"))
     {
       g_printerr ("Doing final cleanup...\n");
-      g_object_unref (shell_global_get ());
+      g_object_unref (global);
     }
 
   g_object_unref (sender);
diff --git a/src/shell-global-private.h b/src/shell-global-private.h
index 5512645..83fd420 100644
--- a/src/shell-global-private.h
+++ b/src/shell-global-private.h
@@ -13,4 +13,6 @@ GjsContext *_shell_global_get_gjs_context (ShellGlobal  *global);
 
 gboolean _shell_global_check_xdnd_event (ShellGlobal  *global,
                                          XEvent       *xev);
+void     _shell_global_set_session_type (ShellGlobal      *global,
+                                         ShellSessionType  session_type);
 #endif /* __SHELL_GLOBAL_PRIVATE_H__ */
diff --git a/src/shell-global.c b/src/shell-global.c
index c18d474..6f9ba62 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -55,6 +55,8 @@ struct _ShellGlobal {
   MetaScreen *meta_screen;
   GdkScreen *gdk_screen;
 
+  ShellSessionType session_type;
+
   /* We use this window to get a notification from GTK+ when
    * a widget in our process does a GTK+ grab.  See
    * http://bugzilla.gnome.org/show_bug.cgi?id=570641
@@ -89,6 +91,7 @@ struct _ShellGlobal {
 enum {
   PROP_0,
 
+  PROP_SESSION_TYPE,
   PROP_OVERLAY_GROUP,
   PROP_SCREEN,
   PROP_GDK_SCREEN,
@@ -151,6 +154,9 @@ shell_global_get_property(GObject         *object,
 
   switch (prop_id)
     {
+    case PROP_SESSION_TYPE:
+      g_value_set_enum (value, shell_global_get_session_type (global));
+      break;
     case PROP_OVERLAY_GROUP:
       g_value_set_object (value, meta_get_overlay_group_for_screen (global->meta_screen));
       break;
@@ -330,6 +336,14 @@ shell_global_class_init (ShellGlobalClass *klass)
                     G_TYPE_STRING);
 
   g_object_class_install_property (gobject_class,
+                                   PROP_SESSION_TYPE,
+                                   g_param_spec_enum ("session-type",
+                                                      "Session Type",
+                                                      "The type of session",
+                                                      SHELL_TYPE_SESSION_TYPE,
+                                                      SHELL_SESSION_USER,
+                                                      G_PARAM_READABLE));
+  g_object_class_install_property (gobject_class,
                                    PROP_OVERLAY_GROUP,
                                    g_param_spec_object ("overlay-group",
                                                         "Overlay Group",
@@ -464,6 +478,32 @@ shell_global_get (void)
   return the_object;
 }
 
+/**
+ * _shell_global_set_session_type:
+ * @global: The #ShellGlobal.
+ * @session_type: the type of session
+ *
+ * Sets the type of session gnome-shell should provide.
+ *
+ * See shell_global_get_session_type() for more information
+ * about session types.
+ *
+ * This function should only be called one time, during
+ * program initialization.
+ */
+void
+_shell_global_set_session_type (ShellGlobal      *global,
+                                ShellSessionType  session_type)
+{
+  g_return_if_fail (SHELL_IS_GLOBAL (global));
+
+  if (session_type != global->session_type)
+    {
+      global->session_type = session_type;
+      g_object_notify (G_OBJECT (global), "session-type");
+    }
+}
+
 static void
 focus_window_changed (MetaDisplay *display,
                       GParamSpec  *param,
@@ -1628,3 +1668,32 @@ shell_global_launch_calendar_server (ShellGlobal *global)
 
   g_free (calendar_server_exe);
 }
+
+/**
+ * shell_global_get_session_type:
+ * @global: The #ShellGlobal.
+ *
+ * Gets the type of session gnome-shell provides.
+ *
+ * The type determines what UI elements are displayed,
+ * what keybindings work, and generally how the shell
+ * behaves.
+ *
+ * A session type of #SHELL_SESSION_USER means gnome-shell
+ * will enable the activities overview, status menu, run dialog,
+ * etc. This is the default.
+ *
+ * A session type of #SHELL_SESSION_LOGIN means gnome-shell
+ * will enable a login dialog and run in a more confined
+ * way.  This type is suitable for the display manager.
+ *
+ * Returns the type of session gnome-shell is providing.
+ */
+ShellSessionType
+shell_global_get_session_type (ShellGlobal  *global)
+{
+  g_return_val_if_fail (SHELL_IS_GLOBAL (global),
+                        SHELL_SESSION_USER);
+
+  return global->session_type;
+}
diff --git a/src/shell-global.h b/src/shell-global.h
index d5bca83..2fdf4ae 100644
--- a/src/shell-global.h
+++ b/src/shell-global.h
@@ -142,6 +142,12 @@ void     shell_global_reexec_self               (ShellGlobal  *global);
 
 void     shell_global_launch_calendar_server    (ShellGlobal  *global);
 
+typedef enum {
+  SHELL_SESSION_USER,
+  SHELL_SESSION_LOGIN
+} ShellSessionType;
+ShellSessionType shell_global_get_session_type  (ShellGlobal  *global);
+
 G_END_DECLS
 
 #endif /* __SHELL_GLOBAL_H__ */



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