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



commit f09bcf1216630508ecf171cff7aa18c9599b14d2
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 0e77187..6ef0345 100644
--- a/src/main.c
+++ b/src/main.c
@@ -22,6 +22,7 @@
 
 #include "shell-a11y.h"
 #include "shell-global.h"
+#include "shell-global-private.h"
 #include "shell-perf-log.h"
 #include "st.h"
 
@@ -30,6 +31,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)
 {
@@ -445,6 +448,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 }
 };
 
@@ -453,6 +462,7 @@ main (int argc, char **argv)
 {
   GOptionContext *ctx;
   GError *error = NULL;
+  ShellGlobal *global;
   int ecode;
 
   g_type_init ();
@@ -506,14 +516,17 @@ main (int argc, char **argv)
                      muted_log_handler, NULL);
 
   /* 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);
     }
 
   return ecode;
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 55875c7..704125c 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,
@@ -1738,3 +1778,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 7c1c7bb..64f5eb9 100644
--- a/src/shell-global.h
+++ b/src/shell-global.h
@@ -145,6 +145,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]