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 subsequent commits.

https://bugzilla.gnome.org/show_bug.cgi?id=657082
This commit is contained in:
Ray Strode 2011-06-21 10:09:09 -04:00
parent 4156a4c2d0
commit 5088f22388
4 changed files with 71 additions and 3 deletions

View File

@ -23,6 +23,7 @@
#include <telepathy-glib/debug-sender.h> #include <telepathy-glib/debug-sender.h>
#include "shell-a11y.h" #include "shell-a11y.h"
#include "shell-global.h"
#include "shell-global-private.h" #include "shell-global-private.h"
#include "shell-perf-log.h" #include "shell-perf-log.h"
#include "st.h" #include "st.h"
@ -32,6 +33,8 @@ extern GType gnome_shell_plugin_get_type (void);
#define SHELL_DBUS_SERVICE "org.gnome.Shell" #define SHELL_DBUS_SERVICE "org.gnome.Shell"
#define MAGNIFIER_DBUS_SERVICE "org.gnome.Magnifier" #define MAGNIFIER_DBUS_SERVICE "org.gnome.Magnifier"
static gboolean is_gdm_mode = FALSE;
static void static void
shell_dbus_init (gboolean replace) shell_dbus_init (gboolean replace)
{ {
@ -466,6 +469,12 @@ GOptionEntry gnome_shell_options[] = {
N_("Print version"), N_("Print version"),
NULL NULL
}, },
{
"gdm-mode", 0, 0, G_OPTION_ARG_NONE,
&is_gdm_mode,
N_("Mode used by GDM for login screen"),
NULL
},
{ NULL } { NULL }
}; };
@ -474,6 +483,7 @@ 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;
@ -540,7 +550,12 @@ 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 */
_shell_global_init (NULL); if (is_gdm_mode)
session_type = SHELL_SESSION_GDM;
else
session_type = SHELL_SESSION_USER;
_shell_global_init ("session-type", session_type, NULL);
ecode = meta_run (); ecode = meta_run ();

View File

@ -16,6 +16,9 @@ GjsContext *_shell_global_get_gjs_context (ShellGlobal *global);
gboolean _shell_global_check_xdnd_event (ShellGlobal *global, gboolean _shell_global_check_xdnd_event (ShellGlobal *global,
XEvent *xev); XEvent *xev);
void _shell_global_set_session_type (ShellGlobal *global,
ShellSessionType session_type);
/* Used for async screenshot grabbing */ /* Used for async screenshot grabbing */
typedef struct _screenshot_data { typedef struct _screenshot_data {
ShellGlobal *global; ShellGlobal *global;

View File

@ -56,6 +56,8 @@ struct _ShellGlobal {
MetaScreen *meta_screen; MetaScreen *meta_screen;
GdkScreen *gdk_screen; GdkScreen *gdk_screen;
ShellSessionType session_type;
/* 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
* http://bugzilla.gnome.org/show_bug.cgi?id=570641 * http://bugzilla.gnome.org/show_bug.cgi?id=570641
@ -90,6 +92,7 @@ struct _ShellGlobal {
enum { enum {
PROP_0, PROP_0,
PROP_SESSION_TYPE,
PROP_OVERLAY_GROUP, PROP_OVERLAY_GROUP,
PROP_SCREEN, PROP_SCREEN,
PROP_GDK_SCREEN, PROP_GDK_SCREEN,
@ -135,7 +138,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:
global->session_type = g_value_get_enum (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -152,6 +157,9 @@ shell_global_get_property(GObject *object,
switch (prop_id) switch (prop_id)
{ {
case PROP_SESSION_TYPE:
g_value_set_enum (value, shell_global_get_session_type (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;
@ -330,6 +338,14 @@ shell_global_class_init (ShellGlobalClass *klass)
G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING); 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_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,
g_param_spec_object ("overlay-group", g_param_spec_object ("overlay-group",
@ -1886,3 +1902,32 @@ shell_global_screenshot_window (ShellGlobal *global,
return status == CAIRO_STATUS_SUCCESS; return status == CAIRO_STATUS_SUCCESS;
} }
/**
* 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_GDM 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;
}

View File

@ -142,7 +142,6 @@ void shell_global_reexec_self (ShellGlobal *global);
void shell_global_launch_calendar_server (ShellGlobal *global); void shell_global_launch_calendar_server (ShellGlobal *global);
typedef void (*ShellGlobalScreenshotCallback) (ShellGlobal *global, gboolean success); typedef void (*ShellGlobalScreenshotCallback) (ShellGlobal *global, gboolean success);
void shell_global_screenshot_area (ShellGlobal *global, void shell_global_screenshot_area (ShellGlobal *global,
@ -160,6 +159,12 @@ gboolean shell_global_screenshot_window (ShellGlobal *global,
void shell_global_screenshot (ShellGlobal *global, void shell_global_screenshot (ShellGlobal *global,
const char *filename, const char *filename,
ShellGlobalScreenshotCallback callback); ShellGlobalScreenshotCallback callback);
typedef enum {
SHELL_SESSION_USER,
SHELL_SESSION_GDM
} ShellSessionType;
ShellSessionType shell_global_get_session_type (ShellGlobal *global);
G_END_DECLS G_END_DECLS