panel: merge statusBox into rightBox

Simplify the layout in rightBox by getting rid of statusBox, and just
putting everything into rightBox directly.

Simplify the handling of the user menu by adding it like it was a
status icon rather than special-casing it. Rename the "tray_icon"
variables to "status_area" to reflect this better.

https://bugzilla.gnome.org/show_bug.cgi?id=651299
This commit is contained in:
Dan Winship 2011-08-25 11:46:25 -04:00
parent 6d89d0b02a
commit 9fbd79316a
3 changed files with 28 additions and 38 deletions

View File

@ -276,12 +276,12 @@ StTooltip StLabel {
background-color: black; background-color: black;
border-image: url("panel-border.svg") 1; border-image: url("panel-border.svg") 1;
font-size: 10.5pt; font-size: 10.5pt;
font-weight: bold;
height: 1.86em; height: 1.86em;
} }
#panelLeft, #panelCenter, #panelRight { #panelLeft, #panelCenter {
spacing: 4px; spacing: 4px;
font-weight: bold;
} }
#panelLeft:ltr { #panelLeft:ltr {
@ -355,9 +355,9 @@ StTooltip StLabel {
text-shadow: black 0px 2px 2px; text-shadow: black 0px 2px 2px;
} }
#statusTray > .panel-button:active, .panel-status-button:active,
#statusTray > .panel-button:checked, .panel-status-button:checked,
#statusTray > .panel-button:focus { .panel-status-button:focus {
background-image: url("panel-button-highlight-narrow.svg"); background-image: url("panel-button-highlight-narrow.svg");
} }

View File

@ -16,7 +16,6 @@ const Layout = imports.ui.layout;
const Overview = imports.ui.overview; const Overview = imports.ui.overview;
const PopupMenu = imports.ui.popupMenu; const PopupMenu = imports.ui.popupMenu;
const PanelMenu = imports.ui.panelMenu; const PanelMenu = imports.ui.panelMenu;
const UserMenu = imports.ui.userMenu;
const DateMenu = imports.ui.dateMenu; const DateMenu = imports.ui.dateMenu;
const Main = imports.ui.main; const Main = imports.ui.main;
const Tweener = imports.ui.tweener; const Tweener = imports.ui.tweener;
@ -28,25 +27,26 @@ const BUTTON_DND_ACTIVATION_TIMEOUT = 250;
const ANIMATED_ICON_UPDATE_TIMEOUT = 100; const ANIMATED_ICON_UPDATE_TIMEOUT = 100;
const SPINNER_ANIMATION_TIME = 0.2; const SPINNER_ANIMATION_TIME = 0.2;
const STANDARD_TRAY_ICON_ORDER = ['a11y', 'keyboard', 'volume', 'bluetooth', 'network', 'battery']; const STANDARD_STATUS_AREA_ORDER = ['a11y', 'keyboard', 'volume', 'bluetooth', 'network', 'battery', 'userMenu'];
const STANDARD_TRAY_ICON_SHELL_IMPLEMENTATION = { const STANDARD_STATUS_AREA_SHELL_IMPLEMENTATION = {
'a11y': imports.ui.status.accessibility.ATIndicator, 'a11y': imports.ui.status.accessibility.ATIndicator,
'volume': imports.ui.status.volume.Indicator, 'volume': imports.ui.status.volume.Indicator,
'battery': imports.ui.status.power.Indicator, 'battery': imports.ui.status.power.Indicator,
'keyboard': imports.ui.status.keyboard.XKBIndicator 'keyboard': imports.ui.status.keyboard.XKBIndicator,
'userMenu': imports.ui.userMenu.UserMenuButton
}; };
if (Config.HAVE_BLUETOOTH) if (Config.HAVE_BLUETOOTH)
STANDARD_TRAY_ICON_SHELL_IMPLEMENTATION['bluetooth'] = imports.ui.status.bluetooth.Indicator; STANDARD_STATUS_AREA_SHELL_IMPLEMENTATION['bluetooth'] = imports.ui.status.bluetooth.Indicator;
try { try {
STANDARD_TRAY_ICON_SHELL_IMPLEMENTATION['network'] = imports.ui.status.network.NMApplet; STANDARD_STATUS_AREA_SHELL_IMPLEMENTATION['network'] = imports.ui.status.network.NMApplet;
} catch(e) { } catch(e) {
log('NMApplet is not supported. It is possible that your NetworkManager version is too old'); log('NMApplet is not supported. It is possible that your NetworkManager version is too old');
} }
const GDM_TRAY_ICON_ORDER = ['a11y', 'display', 'keyboard', 'volume', 'battery']; const GDM_STATUS_AREA_ORDER = ['a11y', 'display', 'keyboard', 'volume', 'battery'];
const GDM_TRAY_ICON_SHELL_IMPLEMENTATION = { const GDM_STATUS_AREA_SHELL_IMPLEMENTATION = {
'a11y': imports.ui.status.accessibility.ATIndicator, 'a11y': imports.ui.status.accessibility.ATIndicator,
'volume': imports.ui.status.volume.Indicator, 'volume': imports.ui.status.volume.Indicator,
'battery': imports.ui.status.power.Indicator, 'battery': imports.ui.status.power.Indicator,
@ -901,14 +901,6 @@ Panel.prototype = {
this.actor.remove_style_class_name('in-overview'); this.actor.remove_style_class_name('in-overview');
})); }));
if (global.session_type == Shell.SessionType.GDM) {
this._tray_icon_order = GDM_TRAY_ICON_ORDER;
this._tray_icon_shell_implementation = GDM_TRAY_ICON_SHELL_IMPLEMENTATION;
} else {
this._tray_icon_order = STANDARD_TRAY_ICON_ORDER;
this._tray_icon_shell_implementation = STANDARD_TRAY_ICON_SHELL_IMPLEMENTATION;
}
this._menus = new PopupMenu.PopupMenuManager(this); this._menus = new PopupMenu.PopupMenuManager(this);
this._leftBox = new St.BoxLayout({ name: 'panelLeft' }); this._leftBox = new St.BoxLayout({ name: 'panelLeft' });
@ -959,14 +951,12 @@ Panel.prototype = {
this._menus.addMenu(this._dateMenu.menu); this._menus.addMenu(this._dateMenu.menu);
/* right */ /* right */
if (global.session_type == Shell.SessionType.GDM) {
this._statusBox = new St.BoxLayout({ name: 'statusTray' }); this._status_area_order = GDM_STATUS_AREA_ORDER;
this._rightBox.add(this._statusBox); this._status_area_shell_implementation = GDM_STATUS_AREA_SHELL_IMPLEMENTATION;
} else {
if (global.session_type == Shell.SessionType.USER) { this._status_area_order = STANDARD_STATUS_AREA_ORDER;
this._userMenu = new UserMenu.UserMenuButton(); this._status_area_shell_implementation = STANDARD_STATUS_AREA_SHELL_IMPLEMENTATION;
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-added', Lang.bind(this, this._onTrayIconAdded));
@ -1052,9 +1042,9 @@ Panel.prototype = {
}, },
startStatusArea: function() { startStatusArea: function() {
for (let i = 0; i < this._tray_icon_order.length; i++) { for (let i = 0; i < this._status_area_order.length; i++) {
let role = this._tray_icon_order[i]; let role = this._status_area_order[i];
let constructor = this._tray_icon_shell_implementation[role]; let constructor = this._status_area_shell_implementation[role];
if (!constructor) { if (!constructor) {
// This icon is not implemented (this is a bug) // This icon is not implemented (this is a bug)
continue; continue;
@ -1071,20 +1061,19 @@ Panel.prototype = {
}, },
_insertStatusItem: function(actor, position) { _insertStatusItem: function(actor, position) {
let children = this._statusBox.get_children(); let children = this._rightBox.get_children();
let i; let i;
for (i = children.length - 1; i >= 0; i--) { for (i = children.length - 1; i >= 0; i--) {
let rolePosition = children[i]._rolePosition; let rolePosition = children[i]._rolePosition;
if (position > rolePosition) { if (position > rolePosition) {
this._statusBox.insert_actor(actor, i + 1); this._rightBox.insert_actor(actor, i + 1);
break; break;
} }
} }
if (i == -1) { if (i == -1) {
// If we didn't find a position, we must be first // If we didn't find a position, we must be first
this._statusBox.insert_actor(actor, 0); this._rightBox.insert_actor(actor, 0);
} }
actor._rolePosition = position; actor._rolePosition = position;
}, },
@ -1110,7 +1099,7 @@ Panel.prototype = {
}, },
_onTrayIconAdded: function(o, icon, role) { _onTrayIconAdded: function(o, icon, role) {
if (this._tray_icon_shell_implementation[role]) { if (this._status_area_shell_implementation[role]) {
// This icon is legacy, and replaced by a Shell version // This icon is legacy, and replaced by a Shell version
// Hide it // Hide it
return; return;
@ -1120,7 +1109,7 @@ Panel.prototype = {
let bin = new St.Bin({ style_class: 'panel-button' }); let bin = new St.Bin({ style_class: 'panel-button' });
bin.child = icon; bin.child = icon;
this._insertStatusItem(bin, this._tray_icon_order.indexOf(role)); this._insertStatusItem(bin, this._status_area_order.indexOf(role));
}, },
_onTrayIconRemoved: function(o, icon) { _onTrayIconRemoved: function(o, icon) {

View File

@ -113,6 +113,7 @@ SystemStatusButton.prototype = {
icon_type: St.IconType.SYMBOLIC, icon_type: St.IconType.SYMBOLIC,
style_class: 'system-status-icon' }); style_class: 'system-status-icon' });
this.actor.set_child(this._iconActor); this.actor.set_child(this._iconActor);
this.actor.add_style_class_name('panel-status-button');
this.setTooltip(tooltipText); this.setTooltip(tooltipText);
}, },