[gnome-shell/wip/gdm-shell: 5/8] global: add session-type concept



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

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

 src/main.c                 |   17 +++++++++-
 src/shell-global-private.h |    2 +
 src/shell-global.c         |   71 +++++++++++++++++++++++++++++++++++++++++++-
 src/shell-global.h         |    6 ++++
 4 files changed, 93 insertions(+), 3 deletions(-)
---
diff --git a/src/main.c b/src/main.c
index fe72e24..7cb120a 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;
 
@@ -538,14 +548,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 8c00514..66e8653 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -45,7 +45,9 @@ static void grab_notify (GtkWidget *widget, gboolean is_grab, gpointer user_data
 
 struct _ShellGlobal {
   GObject parent;
-  
+
+  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
@@ -82,6 +84,7 @@ struct _ShellGlobal {
 enum {
   PROP_0,
 
+  PROP_SESSION_TYPE,
   PROP_OVERLAY_GROUP,
   PROP_SCREEN,
   PROP_GDK_SCREEN,
@@ -143,6 +146,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_plugin_get_overlay_group (global->plugin));
       break;
@@ -321,6 +327,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",
@@ -447,6 +461,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,
@@ -1635,3 +1675,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 1f79cf5..d49741a 100644
--- a/src/shell-global.h
+++ b/src/shell-global.h
@@ -141,6 +141,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]