Add option to keep gnome-shell top panel

This commit is contained in:
Charles Gagnon
2020-05-02 12:57:21 -04:00
parent f8560cd190
commit 0013f5154f
7 changed files with 164 additions and 96 deletions

View File

@@ -7392,31 +7392,6 @@
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="stockgs_panelbtn_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Activate panel menu buttons (e.g. date menu) on click only</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="stockgs_panelbtn_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="stockgs_hotcorner_label">
<property name="visible">True</property>
@@ -7427,7 +7402,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
@@ -7439,9 +7414,59 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="stockgs_panelbtn_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Activate panel menu buttons (e.g. date menu) on click only</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="stockgs_panelbtn_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="stockgs_top_panel_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Keep original gnome-shell top panel</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="stockgs_top_panel_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
</child>
</object>

View File

@@ -157,7 +157,7 @@ var Intellihide = Utils.defineClass({
_changeEnabledStatus: function() {
let intellihide = Me.settings.get_boolean('intellihide');
let onlySecondary = Me.settings.get_boolean('intellihide-only-secondary');
let enabled = intellihide && (this._dtpPanel.isSecondary || !onlySecondary);
let enabled = intellihide && !(this._dtpPanel.isPrimary && onlySecondary);
if (this.enabled !== enabled) {
this[enabled ? 'enable' : 'disable']();

View File

@@ -117,7 +117,7 @@ var dtpPanel = Utils.defineClass({
Name: 'DashToPanel-Panel',
Extends: St.Widget,
_init: function(panelManager, monitor, panelBox, isSecondary) {
_init: function(panelManager, monitor, panelBox, isStandalone) {
let position = getPosition();
this.callParent('_init', { layout_manager: new Clutter.BinLayout() });
@@ -130,11 +130,18 @@ var dtpPanel = Utils.defineClass({
this.monitor = monitor;
this.panelBox = panelBox;
this.isSecondary = isSecondary;
// when the original gnome-shell top panel is kept, all panels are "standalone",
// so in this case use isPrimary to get the panel on the primary dtp monitor, which
// might be different from the system's primary monitor.
this.isStandalone = isStandalone;
this.isPrimary = !isStandalone || (Me.settings.get_boolean('stockgs-keep-top-panel') &&
monitor == panelManager.dtpPrimaryMonitor);
this._sessionStyle = null;
this._unmappedButtons = [];
if (isSecondary) {
if (isStandalone) {
this.panel = new St.Widget({ name: 'panel', reactive: true });
this.statusArea = this.panel.statusArea = {};
@@ -185,7 +192,7 @@ var dtpPanel = Utils.defineClass({
Utils.wrapActor(this.panel._leftCorner);
Utils.wrapActor(this.panel._rightCorner);
if (isSecondary) {
if (isStandalone) {
this.panel.add_child(this.panel._leftCorner.actor);
this.panel.add_child(this.panel._rightCorner.actor);
}
@@ -254,7 +261,7 @@ var dtpPanel = Utils.defineClass({
this._setPanelPosition();
if (!this.isSecondary) {
if (!this.isStandalone) {
if (this.panel.vfunc_allocate) {
this._panelConnectId = 0;
Utils.hookVfunc(this.panel.__proto__, 'allocate', (box, flags) => this._mainPanelAllocate(0, box, flags));
@@ -438,14 +445,13 @@ var dtpPanel = Utils.defineClass({
this._dateMenuIndicatorPadContraints.forEach(c => indicatorPad.add_constraint(c));
}
if (!this.isSecondary) {
this._setVertical(this.panel.actor, false);
if (!this.isStandalone) {
this.statusArea.dateMenu._clockDisplay.text = this.statusArea.dateMenu._clock.clock;
this._setVertical(this.panel.actor, false);
['vertical', 'horizontal', 'dashtopanelMainPanel'].forEach(c => this.panel.actor.remove_style_class_name(c));
if(!Main.sessionMode.isLocked) {
this._setActivitiesButtonVisible(true);
this._setClockLocation("BUTTONSLEFT");
@@ -658,11 +664,16 @@ var dtpPanel = Utils.defineClass({
let lrPadding = panelBoxTheme.get_padding(St.Side.RIGHT) + panelBoxTheme.get_padding(St.Side.LEFT);
let tbPadding = panelBoxTheme.get_padding(St.Side.TOP) + panelBoxTheme.get_padding(St.Side.BOTTOM);
let position = getPosition();
let gsTopPanelOffset = 0;
let x = 0, y = 0;
let w = 0, h = 0;
size = Me.settings.get_int('panel-size') * scaleFactor;
if (Me.settings.get_boolean('stockgs-keep-top-panel') && Main.layoutManager.primaryMonitor == this.monitor) {
gsTopPanelOffset = Main.layoutManager.panelBox.height;
}
if (checkIfVertical()) {
if (!Me.settings.get_boolean('group-apps')) {
// add window title width and side padding of _dtpIconContainer when vertical
@@ -674,7 +685,7 @@ var dtpPanel = Utils.defineClass({
varCoord = { c1: 'y1', c2: 'y2' };
w = size;
h = this.monitor.height - tbPadding;
h = this.monitor.height - tbPadding - gsTopPanelOffset;
} else {
sizeFunc = 'get_preferred_width';
fixedCoord = { c1: 'y1', c2: 'y2' };
@@ -686,10 +697,10 @@ var dtpPanel = Utils.defineClass({
if (position == St.Side.TOP || position == St.Side.LEFT) {
x = this.monitor.x;
y = this.monitor.y;
y = this.monitor.y + gsTopPanelOffset;
} else if (position == St.Side.RIGHT) {
x = this.monitor.x + this.monitor.width - size - lrPadding;
y = this.monitor.y;
y = this.monitor.y + gsTopPanelOffset;
} else { //BOTTOM
x = this.monitor.x;
y = this.monitor.y + this.monitor.height - size - tbPadding;
@@ -970,41 +981,43 @@ var dtpPanel = Utils.defineClass({
_formatVerticalClock: function() {
// https://github.com/GNOME/gnome-desktop/blob/master/libgnome-desktop/gnome-wall-clock.c#L310
let datetime = this.statusArea.dateMenu._clock.clock;
let datetimeParts = datetime.split('');
let time = datetimeParts[1];
let clockText = this.statusArea.dateMenu._clockDisplay.clutter_text;
let setClockText = text => {
let stacks = text instanceof Array;
let separator = '\n<span size="xx-small">‧‧</span>\n';
clockText.set_text((stacks ? text.join(separator) : text).trim());
clockText.set_use_markup(stacks);
clockText.get_allocation_box();
return !clockText.get_layout().is_ellipsized();
};
if (this.statusArea.dateMenu) {
let datetime = this.statusArea.dateMenu._clock.clock;
let datetimeParts = datetime.split('');
let time = datetimeParts[1];
let clockText = this.statusArea.dateMenu._clockDisplay.clutter_text;
let setClockText = text => {
let stacks = text instanceof Array;
let separator = '\n<span size="xx-small">‧‧</span>\n';
clockText.set_text((stacks ? text.join(separator) : text).trim());
clockText.set_use_markup(stacks);
clockText.get_allocation_box();
return !clockText.get_layout().is_ellipsized();
};
if (!time) {
datetimeParts = datetime.split(' ');
time = datetimeParts.pop();
datetimeParts = [datetimeParts.join(' '), time];
}
if (!setClockText(datetime) &&
!setClockText(datetimeParts) &&
!setClockText(time)) {
let timeParts = time.split('');
if (!this._clockFormat) {
this._clockFormat = Me.desktopSettings.get_string('clock-format');
if (!time) {
datetimeParts = datetime.split(' ');
time = datetimeParts.pop();
datetimeParts = [datetimeParts.join(' '), time];
}
if (this._clockFormat == '12h') {
timeParts.push.apply(timeParts, timeParts.pop().split(' '));
}
if (!setClockText(datetime) &&
!setClockText(datetimeParts) &&
!setClockText(time)) {
let timeParts = time.split('');
setClockText(timeParts);
if (!this._clockFormat) {
this._clockFormat = Me.desktopSettings.get_string('clock-format');
}
if (this._clockFormat == '12h') {
timeParts.push.apply(timeParts, timeParts.pop().split(' '));
}
setClockText(timeParts);
}
}
},

View File

@@ -70,20 +70,19 @@ var dtpPanelManager = Utils.defineClass({
if(dtpPrimaryIndex < 0 || dtpPrimaryIndex >= Main.layoutManager.monitors.length)
dtpPrimaryIndex = Main.layoutManager.primaryIndex;
let dtpPrimaryMonitor = Main.layoutManager.monitors[dtpPrimaryIndex];
this.dtpPrimaryMonitor = Main.layoutManager.monitors[dtpPrimaryIndex];
this.proximityManager = new Proximity.ProximityManager();
Utils.wrapActor(Main.panel);
Utils.wrapActor(Main.overview.dash || 0);
this.primaryPanel = this._createPanel(dtpPrimaryMonitor);
this.primaryPanel = this._createPanel(this.dtpPrimaryMonitor, Me.settings.get_boolean('stockgs-keep-top-panel'));
this.allPanels = [ this.primaryPanel ];
this.overview.enable(this.primaryPanel);
if (Me.settings.get_boolean('multi-monitors')) {
Main.layoutManager.monitors.filter(m => m != dtpPrimaryMonitor).forEach(m => {
Main.layoutManager.monitors.filter(m => m != this.dtpPrimaryMonitor).forEach(m => {
this.allPanels.push(this._createPanel(m, true));
});
}
@@ -96,8 +95,8 @@ var dtpPanelManager = Utils.defineClass({
let leftOrRight = (panelPosition == St.Side.LEFT || panelPosition == St.Side.RIGHT);
p.panelBox.set_size(
leftOrRight ? -1 : p.monitor.width,
leftOrRight ? p.monitor.height : -1
leftOrRight ? -1 : p.geom.w,
leftOrRight ? p.geom.h : -1
);
this._findPanelMenuButtons(p.panelBox).forEach(pmb => this._adjustPanelMenuButton(pmb, p.monitor, panelPosition));
@@ -116,7 +115,7 @@ var dtpPanelManager = Utils.defineClass({
});
}
this.setFocusedMonitor(dtpPrimaryMonitor);
this.setFocusedMonitor(this.dtpPrimaryMonitor);
if (Panel.checkIfVertical()) {
Main.wm._getPositionForDirection = newGetPositionForDirection;
@@ -231,7 +230,8 @@ var dtpPanelManager = Utils.defineClass({
'changed::multi-monitors',
'changed::isolate-monitors',
'changed::taskbar-position',
'changed::panel-position'
'changed::panel-position',
'changed::stockgs-keep-top-panel'
],
() => this._reset()
],
@@ -282,7 +282,7 @@ var dtpPanelManager = Utils.defineClass({
Main.layoutManager._untrackActor(p.panelBox);
Main.layoutManager.removeChrome(clipContainer);
if (p.isSecondary) {
if (p.isStandalone) {
p.panelBox.destroy();
} else {
p.panelBox.remove_child(p);
@@ -302,17 +302,17 @@ var dtpPanelManager = Utils.defineClass({
delete Main.wm._getPositionForDirection;
if (Main.layoutManager.primaryMonitor) {
Main.layoutManager.panelBox.set_position(Main.layoutManager.primaryMonitor.x, Main.layoutManager.primaryMonitor.y);
Main.layoutManager.panelBox.set_size(Main.layoutManager.primaryMonitor.width, -1);
}
if (reset) return;
this._setKeyBindings(false);
this._signalsHandler.destroy();
if (Main.layoutManager.primaryMonitor) {
Main.layoutManager.panelBox.set_position(Main.layoutManager.primaryMonitor.x, Main.layoutManager.primaryMonitor.y);
Main.layoutManager.panelBox.set_size(Main.layoutManager.primaryMonitor.width, -1);
}
Main.layoutManager._updateHotCorners = this._oldUpdateHotCorners;
Main.layoutManager._updateHotCorners();
@@ -373,12 +373,12 @@ var dtpPanelManager = Utils.defineClass({
return Main.overview.viewSelector._workspacesDisplay._primaryIndex == monitor.index;
},
_createPanel: function(monitor, isSecondary) {
_createPanel: function(monitor, isStandalone) {
let panelBox;
let panel;
let clipContainer = new Clutter.Actor();
if (isSecondary) {
if (isStandalone) {
panelBox = new St.BoxLayout({ name: 'panelBox' });
} else {
panelBox = Main.layoutManager.panelBox;
@@ -391,7 +391,7 @@ var dtpPanelManager = Utils.defineClass({
clipContainer.add_child(panelBox);
Main.layoutManager.trackChrome(panelBox, { trackFullscreen: true, affectsStruts: true, affectsInputRegion: true });
panel = new Panel.dtpPanel(this, monitor, panelBox, isSecondary);
panel = new Panel.dtpPanel(this, monitor, panelBox, isStandalone);
panelBox.add(panel);
panel.enable();
@@ -454,7 +454,7 @@ var dtpPanelManager = Utils.defineClass({
},
_removePanelBarriers: function(panel) {
if (panel.isSecondary && panel._rightPanelBarrier) {
if (panel.isStandalone && panel._rightPanelBarrier) {
panel._rightPanelBarrier.destroy();
}
@@ -705,7 +705,7 @@ function newUpdateHotCorners() {
function newUpdatePanelBarrier(panel) {
let barriers = {
_rightPanelBarrier: [(panel.isSecondary ? panel : this)],
_rightPanelBarrier: [(panel.isStandalone ? panel : this)],
_leftPanelBarrier: [panel]
};
@@ -776,7 +776,7 @@ function newUpdatePanelBarrier(panel) {
}
function _newLookingGlassResize() {
let topOffset = Panel.getPosition() == St.Side.TOP ? Panel.size : 0;
let topOffset = Panel.getPosition() == St.Side.TOP ? Panel.size : 32;
this._oldResize();
Utils.wrapActor(this);

View File

@@ -230,10 +230,7 @@ const Settings = new Lang.Class({
showDesktopWidthLabel.set_text(isVertical ? _('Show Desktop button height (px)') : _('Show Desktop button width (px)'));
},
_bindSettings: function() {
// Position and style panel
// Position option
_setPositionRadios: function() {
let position = this._settings.get_string('panel-position');
switch (position) {
@@ -251,6 +248,13 @@ const Settings = new Lang.Class({
break;
}
},
_bindSettings: function() {
// Position and style panel
// Position option
this._setPositionRadios();
this._settings.connect('changed::panel-position', () => this._updateVerticalRelatedOptions());
this._updateVerticalRelatedOptions();
@@ -1760,6 +1764,27 @@ const Settings = new Lang.Class({
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('stockgs-keep-top-panel',
this._builder.get_object('stockgs_top_panel_switch'),
'active',
Gio.SettingsBindFlags.DEFAULT);
var maybeDisableTopPosition = () => {
let keepTopPanel = this._settings.get_boolean('stockgs-keep-top-panel');
let topRadio = this._builder.get_object('position_top_button');
topRadio.set_sensitive(!keepTopPanel);
topRadio.set_tooltip_text(keepTopPanel ? _('Unavailable when gnome-shell top panel is present') : '');
if (keepTopPanel && this._settings.get_string('panel-position') == 'TOP') {
this._settings.set_string('panel-position', "BOTTOM");
this._setPositionRadios();
}
};
this._settings.connect('changed::stockgs-keep-top-panel', () => maybeDisableTopPosition());
maybeDisableTopPosition();
this._settings.bind('stockgs-panelbtn-click-only',
this._builder.get_object('stockgs_panelbtn_switch'),
'active',

View File

@@ -192,6 +192,11 @@
<summary>Keep dash</summary>
<description>Whether to keep the stock gnome-shell dash while in overview</description>
</key>
<key type="b" name="stockgs-keep-top-panel">
<default>false</default>
<summary>Keep top panel</summary>
<description>Whether to keep the stock gnome-shell top panel</description>
</key>
<key type="b" name="stockgs-panelbtn-click-only">
<default>false</default>
<summary>Panel menu buttons require click</summary>

View File

@@ -854,7 +854,7 @@ var taskbar = Utils.defineClass({
this._updateAppIcons();
// This will update the size, and the corresponding number for each icon on the primary panel
if (!this.dtpPanel.isSecondary) {
if (this.dtpPanel.isPrimary) {
this._updateNumberOverlay();
}
@@ -867,7 +867,7 @@ var taskbar = Utils.defineClass({
_checkIfShowingFavorites: function() {
return Me.settings.get_boolean('show-favorites') &&
(!this.dtpPanel.isSecondary || Me.settings.get_boolean('show-favorites-all-monitors'));
(this.dtpPanel.isPrimary || Me.settings.get_boolean('show-favorites-all-monitors'));
},
_getRunningApps: function() {