[gnome-shell] main: Factor out remaining user session specific bits
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] main: Factor out remaining user session specific bits
- Date: Mon, 29 Aug 2011 18:14:55 +0000 (UTC)
commit d4239d570d3e2ca67c6f58ccd72d6b7ecd540f44
Author: Ray Strode <rstrode redhat com>
Date: Tue Aug 23 21:53:02 2011 -0400
main: Factor out remaining user session specific bits
The shell has a number of things that are only relevant for
logged in users (e.g. calendar events, telepathy integration, a
user menu, etc).
This commit moves those user session specific bits into their
own functions in preparation for making the shell code ready
for use at login time.
https://bugzilla.gnome.org/show_bug.cgi?id=657082
js/ui/main.js | 139 +++++++++++++++++++++++++++++++++-----------------------
js/ui/panel.js | 41 ++++++++++-------
2 files changed, 106 insertions(+), 74 deletions(-)
---
diff --git a/js/ui/main.js b/js/ui/main.js
index bd64499..3fd21c8 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -74,6 +74,70 @@ let _cssStylesheet = null;
let background = null;
+function _createUserSession() {
+ // Load the calendar server. Note that we are careful about
+ // not loading any events until the user presses the clock
+ global.launch_calendar_server();
+
+ placesManager = new PlaceDisplay.PlacesManager();
+ telepathyClient = new TelepathyClient.Client();
+ automountManager = new AutomountManager.AutomountManager();
+ autorunManager = new AutorunManager.AutorunManager();
+ networkAgent = new NetworkAgent.NetworkAgent();
+}
+
+function _initRecorder() {
+ let recorderSettings = new Gio.Settings({ schema: 'org.gnome.shell.recorder' });
+
+ global.screen.connect('toggle-recording', function() {
+ if (recorder == null) {
+ recorder = new Shell.Recorder({ stage: global.stage });
+ }
+
+ if (recorder.is_recording()) {
+ recorder.pause();
+ } else {
+ // read the parameters from GSettings always in case they have changed
+ recorder.set_framerate(recorderSettings.get_int('framerate'));
+ recorder.set_filename('shell-%d%u-%c.' + recorderSettings.get_string('file-extension'));
+ let pipeline = recorderSettings.get_string('pipeline');
+
+ if (!pipeline.match(/^\s*$/))
+ recorder.set_pipeline(pipeline);
+ else
+ recorder.set_pipeline(null);
+
+ recorder.record();
+ }
+ });
+}
+
+function _initUserSession() {
+ _initRecorder();
+
+ keyboard.init();
+
+ global.screen.override_workspace_layout(Meta.ScreenCorner.TOPLEFT, false, -1, 1);
+
+ ExtensionSystem.init();
+ ExtensionSystem.loadExtensions();
+
+ let shellwm = global.window_manager;
+
+ shellwm.takeover_keybinding('panel_run_dialog');
+ shellwm.connect('keybinding::panel_run_dialog', function () {
+ getRunDialog().open();
+ });
+
+ shellwm.takeover_keybinding('panel_main_menu');
+ shellwm.connect('keybinding::panel_main_menu', function () {
+ overview.toggle();
+ });
+
+ global.display.connect('overlay-key', Lang.bind(overview, overview.toggle));
+
+}
+
function start() {
// Monkey patch utility functions into the global proxy;
// This is easier and faster than indirecting down into global
@@ -93,10 +157,6 @@ function start() {
// back into sync ones.
DBus.session.flush();
- // Load the calendar server. Note that we are careful about
- // not loading any events until the user presses the clock
- global.launch_calendar_server();
-
// Ensure ShellWindowTracker and ShellAppUsage are initialized; this will
// also initialize ShellAppSystem first. ShellAppSystem
// needs to load all the .desktop files, and ShellWindowTracker
@@ -117,16 +177,6 @@ function start() {
_defaultCssStylesheet = global.datadir + '/theme/gnome-shell.css';
loadTheme();
- let shellwm = global.window_manager;
- shellwm.takeover_keybinding('panel_main_menu');
- shellwm.connect('keybinding::panel_main_menu', function () {
- overview.toggle();
- });
- shellwm.takeover_keybinding('panel_run_dialog');
- shellwm.connect('keybinding::panel_run_dialog', function () {
- getRunDialog().open();
- });
-
// Set up stage hierarchy to group all UI actors under one container.
uiGroup = new Clutter.Group();
St.set_ui_root(global.stage, uiGroup);
@@ -135,10 +185,10 @@ function start() {
global.stage.add_actor(uiGroup);
layoutManager = new Layout.LayoutManager();
- placesManager = new PlaceDisplay.PlacesManager();
xdndHandler = new XdndHandler.XdndHandler();
ctrlAltTabManager = new CtrlAltTab.CtrlAltTabManager();
- overview = new Overview.Overview();
+ // This overview object is just a stub for non-user sessions
+ overview = new Overview.Overview({ isDummy: global.session_type != Shell.SessionType.USER });
magnifier = new Magnifier.Magnifier();
statusIconDispatcher = new StatusIconDispatcher.StatusIconDispatcher();
panel = new Panel.Panel();
@@ -147,44 +197,16 @@ function start() {
keyboard = new Keyboard.Keyboard();
notificationDaemon = new NotificationDaemon.NotificationDaemon();
windowAttentionHandler = new WindowAttentionHandler.WindowAttentionHandler();
- telepathyClient = new TelepathyClient.Client();
- automountManager = new AutomountManager.AutomountManager();
- autorunManager = new AutorunManager.AutorunManager();
- networkAgent = new NetworkAgent.NetworkAgent();
+ _createUserSession();
- layoutManager.init();
- keyboard.init();
- overview.init();
- statusIconDispatcher.start(messageTray.actor);
panel.startStatusArea();
- _startDate = new Date();
-
- let recorderSettings = new Gio.Settings({ schema: 'org.gnome.shell.recorder' });
-
- global.screen.connect('toggle-recording', function() {
- if (recorder == null) {
- recorder = new Shell.Recorder({ stage: global.stage });
- }
-
- if (recorder.is_recording()) {
- recorder.pause();
- } else {
- // read the parameters from GSettings always in case they have changed
- recorder.set_framerate(recorderSettings.get_int('framerate'));
- recorder.set_filename('shell-%d%u-%c.' + recorderSettings.get_string('file-extension'));
- let pipeline = recorderSettings.get_string('pipeline');
-
- if (!pipeline.match(/^\s*$/))
- recorder.set_pipeline(pipeline);
- else
- recorder.set_pipeline(null);
-
- recorder.record();
- }
- });
+ keyboard.init();
+ overview.init();
- global.screen.override_workspace_layout(Meta.ScreenCorner.TOPLEFT, false, -1, 1);
+ if (global.session_type == Shell.SessionType.USER)
+ _initUserSession();
+ statusIconDispatcher.start(messageTray.actor);
// Provide the bus object for gnome-session to
// initiate logouts.
@@ -193,10 +215,7 @@ function start() {
// Attempt to become a PolicyKit authentication agent
PolkitAuthenticationAgent.init()
- ExtensionSystem.init();
- ExtensionSystem.loadExtensions();
-
- global.display.connect('overlay-key', Lang.bind(overview, overview.toggle));
+ _startDate = new Date();
global.stage.connect('captured-event', _globalKeyPressHandler);
@@ -558,6 +577,15 @@ function _globalKeyPressHandler(actor, event) {
return true;
}
+ if (action == Meta.KeyBindingAction.SWITCH_PANELS) {
+ ctrlAltTabManager.popup(modifierState & Clutter.ModifierType.SHIFT_MASK);
+ return true;
+ }
+
+ // None of the other bindings are relevant outside of the user's session
+ if (global.session_type != Shell.SessionType.USER)
+ return false;
+
switch (action) {
// left/right would effectively act as synonyms for up/down if we enabled them;
// but that could be considered confusing; we also disable them in the main view.
@@ -581,9 +609,6 @@ function _globalKeyPressHandler(actor, event) {
case Meta.KeyBindingAction.PANEL_MAIN_MENU:
overview.hide();
return true;
- case Meta.KeyBindingAction.SWITCH_PANELS:
- ctrlAltTabManager.popup(modifierState & Clutter.ModifierType.SHIFT_MASK);
- return true;
}
return false;
diff --git a/js/ui/panel.js b/js/ui/panel.js
index 8004464..e3803d8 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -903,21 +903,25 @@ Panel.prototype = {
this.actor.connect('allocate', Lang.bind(this, this._allocate));
/* Button on the left side of the panel. */
- this._activitiesButton = new ActivitiesButton();
- this._activities = this._activitiesButton.actor;
- this._leftBox.add(this._activities);
-
- // The activities button has a pretend menu, so as to integrate
- // more cleanly with the rest of the panel
- this._menus.addMenu(this._activitiesButton.menu);
-
- this._appMenu = new AppMenuButton();
- this._leftBox.add(this._appMenu.actor);
-
- this._menus.addMenu(this._appMenu.menu);
+ if (global.session_type == Shell.SessionType.USER) {
+ this._activitiesButton = new ActivitiesButton();
+ this._activities = this._activitiesButton.actor;
+ this._leftBox.add(this._activities);
+
+ // The activities button has a pretend menu, so as to integrate
+ // more cleanly with the rest of the panel
+ this._menus.addMenu(this._activitiesButton.menu);
+
+ this._appMenu = new AppMenuButton();
+ this._leftBox.add(this._appMenu.actor);
+ this._menus.addMenu(this._appMenu.menu);
+ }
/* center */
- this._dateMenu = new DateMenu.DateMenuButton();
+ if (global.session_type == Shell.SessionType.USER)
+ this._dateMenu = new DateMenu.DateMenuButton({ showEvents: true });
+ else
+ this._dateMenu = new DateMenu.DateMenuButton({ showEvents: false });
this._centerBox.add(this._dateMenu.actor, { y_fill: true });
this._menus.addMenu(this._dateMenu.menu);
@@ -933,9 +937,11 @@ Panel.prototype = {
this._rightBox.add(this._trayBox);
this._rightBox.add(this._statusBox);
- this._userMenu = new StatusMenu.StatusMenuButton();
- this._userMenu.actor.name = 'panelStatus';
- this._rightBox.add(this._userMenu.actor);
+ if (global.session_type == Shell.SessionType.USER) {
+ this._userMenu = new StatusMenu.StatusMenuButton();
+ this._userMenu.actor.name = 'panelStatus';
+ this._rightBox.add(this._userMenu.actor);
+ }
Main.statusIconDispatcher.connect('status-icon-added', Lang.bind(this, this._onTrayIconAdded));
Main.statusIconDispatcher.connect('status-icon-removed', Lang.bind(this, this._onTrayIconRemoved));
@@ -1034,7 +1040,8 @@ Panel.prototype = {
// PopupMenuManager depends on menus being added in order for
// keyboard navigation
- this._menus.addMenu(this._userMenu.menu);
+ if (this._userMenu)
+ this._menus.addMenu(this._userMenu.menu);
},
addToStatusArea: function(role, indicator, position) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]