mirror of
https://github.com/morgan9e/dash-to-panel
synced 2026-04-14 00:04:17 +09:00
Add left and right panelbox position
This commit is contained in:
41
panel.js
41
panel.js
@@ -169,7 +169,7 @@ var dtpPanelWrapper = Utils.defineClass({
|
||||
this.dynamicTransparency = new Transparency.DynamicTransparency(this);
|
||||
});
|
||||
|
||||
this.taskbar = new Taskbar.taskbar(this._dtpSettings, this);
|
||||
this.taskbar = new Taskbar.taskbar(this);
|
||||
Main.overview.dashIconSize = this.taskbar.iconSize;
|
||||
|
||||
this.container.insert_child_above(this.taskbar.actor, null);
|
||||
@@ -542,26 +542,15 @@ var dtpPanelWrapper = Utils.defineClass({
|
||||
|
||||
this.panel.actor.set_height(size);
|
||||
|
||||
let position = this._dtpSettings.get_string('panel-position');
|
||||
let isTop = position == "TOP";
|
||||
let position = Taskbar.getPosition();
|
||||
let isTop = position == St.Side.TOP;
|
||||
|
||||
Main.overview._panelGhost.set_height(isTop ? size : 0);
|
||||
this._myPanelGhost.set_height(isTop ? 0 : size);
|
||||
|
||||
if(isTop) {
|
||||
container.set_position(this.monitor.x, this.monitor.y);
|
||||
|
||||
if (isTop) {
|
||||
this._removeTopLimit();
|
||||
|
||||
// styles for theming
|
||||
if(this.panel.actor.has_style_class_name('dashtopanelBottom'))
|
||||
this.panel.actor.remove_style_class_name('dashtopanelBottom');
|
||||
|
||||
if(!this.panel.actor.has_style_class_name('dashtopanelTop'))
|
||||
this.panel.actor.add_style_class_name('dashtopanelTop');
|
||||
} else {
|
||||
container.set_position(this.monitor.x, this.monitor.y + this.monitor.height - this.panelBox.height);
|
||||
|
||||
if (!this._topLimit) {
|
||||
this._topLimit = new St.BoxLayout({ name: 'topLimit', vertical: true });
|
||||
Main.layoutManager.addChrome(this._topLimit, { affectsStruts: true, trackFullscreen: true });
|
||||
@@ -569,15 +558,23 @@ var dtpPanelWrapper = Utils.defineClass({
|
||||
|
||||
this._topLimit.set_position(this.monitor.x, this.monitor.y);
|
||||
this._topLimit.set_size(this.monitor.width, -1);
|
||||
|
||||
// styles for theming
|
||||
if(this.panel.actor.has_style_class_name('dashtopanelTop'))
|
||||
this.panel.actor.remove_style_class_name('dashtopanelTop');
|
||||
|
||||
if(!this.panel.actor.has_style_class_name('dashtopanelBottom'))
|
||||
this.panel.actor.add_style_class_name('dashtopanelBottom');
|
||||
}
|
||||
|
||||
if (isTop || position == St.Side.LEFT) {
|
||||
container.set_position(this.monitor.x, this.monitor.y);
|
||||
} else if (position == St.Side.RIGHT) {
|
||||
container.set_position(this.monitor.x + this.monitor.width - container.width, this.monitor.y);
|
||||
} else { //BOTTOM
|
||||
container.set_position(this.monitor.x, this.monitor.y + this.monitor.height - container.height);
|
||||
}
|
||||
|
||||
// styles for theming
|
||||
Object.keys(St.Side).forEach(p => {
|
||||
let cssName = p.charAt(0) + p.slice(1).toLowerCase();
|
||||
|
||||
this.panel.actor[(p == position ? 'add' : 'remove') + '_style_class_name']('dashtopanel' + cssName);
|
||||
});
|
||||
|
||||
Main.layoutManager._updateHotCorners();
|
||||
Main.layoutManager._updatePanelBarrier(this);
|
||||
},
|
||||
|
||||
@@ -54,6 +54,7 @@ var dtpPanelManager = Utils.defineClass({
|
||||
|
||||
_init: function(settings) {
|
||||
this._dtpSettings = settings;
|
||||
Taskbar.dtpSettings = settings;
|
||||
this.overview = new Overview.dtpOverview(settings);
|
||||
|
||||
Main.overview.viewSelector.appDisplay._views.forEach(v => Utils.wrapActor(v.view._grid));
|
||||
@@ -98,7 +99,13 @@ var dtpPanelManager = Utils.defineClass({
|
||||
|
||||
let panelPosition = Taskbar.getPosition();
|
||||
this.allPanels.forEach(p => {
|
||||
p.panelBox.set_size(p.monitor.width, -1);
|
||||
let leftOrRight = (panelPosition == St.Side.LEFT || panelPosition == St.Side.RIGHT);
|
||||
|
||||
p.panelBox.set_size(
|
||||
leftOrRight ? -1 : p.monitor.width,
|
||||
leftOrRight ? p.monitor.height : -1
|
||||
);
|
||||
|
||||
this._findPanelMenuButtons(p.panelBox).forEach(pmb => this._adjustPanelMenuButton(pmb, p.monitor, panelPosition));
|
||||
});
|
||||
|
||||
|
||||
79
taskbar.js
79
taskbar.js
@@ -51,16 +51,20 @@ const AppIcons = Me.imports.appIcons;
|
||||
var DASH_ANIMATION_TIME = Dash.DASH_ANIMATION_TIME / (Dash.DASH_ANIMATION_TIME > 1 ? 1000 : 1);
|
||||
var DASH_ITEM_HOVER_TIMEOUT = Dash.DASH_ITEM_HOVER_TIMEOUT;
|
||||
var MIN_ICON_SIZE = 4;
|
||||
var dtpSettings;
|
||||
|
||||
function getPosition() {
|
||||
let position = St.Side.BOTTOM;
|
||||
|
||||
if (Main.layoutManager.primaryMonitor && Main.layoutManager.panelBox &&
|
||||
Main.layoutManager.panelBox.y == Main.layoutManager.primaryMonitor.y) {
|
||||
position = St.Side.TOP;
|
||||
let position = dtpSettings.get_string('panel-position');
|
||||
|
||||
if (position == 'TOP') {
|
||||
return St.Side.TOP;
|
||||
} else if (position == 'RIGHT') {
|
||||
return St.Side.RIGHT;
|
||||
} else if (position == 'BOTTOM') {
|
||||
return St.Side.BOTTOM;
|
||||
}
|
||||
|
||||
return position;
|
||||
|
||||
return St.Side.LEFT;
|
||||
}
|
||||
/**
|
||||
* Extend DashItemContainer
|
||||
@@ -159,8 +163,7 @@ var taskbarActor = Utils.defineClass({
|
||||
var taskbar = Utils.defineClass({
|
||||
Name: 'DashToPanel.Taskbar',
|
||||
|
||||
_init : function(settings, panelWrapper) {
|
||||
this._dtpSettings = settings;
|
||||
_init : function(panelWrapper) {
|
||||
this.panelWrapper = panelWrapper;
|
||||
|
||||
// start at smallest size due to running indicator drawing area expanding but not shrinking
|
||||
@@ -191,7 +194,7 @@ var taskbar = Utils.defineClass({
|
||||
this._scrollView.add_actor(this._box);
|
||||
|
||||
// Create a wrapper around the real showAppsIcon in order to add a popupMenu.
|
||||
this._showAppsIconWrapper = new AppIcons.ShowAppsIconWrapper(this._dtpSettings);
|
||||
this._showAppsIconWrapper = new AppIcons.ShowAppsIconWrapper(dtpSettings);
|
||||
this._showAppsIconWrapper.connect('menu-state-changed', Lang.bind(this, function(showAppsIconWrapper, opened) {
|
||||
this._itemMenuStateChanged(showAppsIconWrapper, opened);
|
||||
}));
|
||||
@@ -221,10 +224,10 @@ var taskbar = Utils.defineClass({
|
||||
coordinate: Clutter.BindCoordinate.HEIGHT
|
||||
}));
|
||||
|
||||
this.previewMenu = new WindowPreview.PreviewMenu(settings, panelWrapper);
|
||||
this.previewMenu = new WindowPreview.PreviewMenu(dtpSettings, panelWrapper);
|
||||
this.previewMenu.enable();
|
||||
|
||||
if (!this._dtpSettings.get_boolean('show-show-apps-button'))
|
||||
if (!dtpSettings.get_boolean('show-show-apps-button'))
|
||||
this.hideShowAppsButton();
|
||||
|
||||
let rtl = Clutter.get_default_text_direction() == Clutter.TextDirection.RTL;
|
||||
@@ -285,7 +288,7 @@ var taskbar = Utils.defineClass({
|
||||
'window-left-monitor'
|
||||
],
|
||||
() => {
|
||||
if (this._dtpSettings.get_boolean('isolate-monitors')) {
|
||||
if (dtpSettings.get_boolean('isolate-monitors')) {
|
||||
this._queueRedisplay();
|
||||
}
|
||||
}
|
||||
@@ -312,17 +315,17 @@ var taskbar = Utils.defineClass({
|
||||
Lang.bind(this, this._syncShowAppsButtonToggled)
|
||||
],
|
||||
[
|
||||
this._dtpSettings,
|
||||
dtpSettings,
|
||||
'changed::show-show-apps-button',
|
||||
Lang.bind(this, function() {
|
||||
if (this._dtpSettings.get_boolean('show-show-apps-button'))
|
||||
if (dtpSettings.get_boolean('show-show-apps-button'))
|
||||
this.showShowAppsButton();
|
||||
else
|
||||
this.hideShowAppsButton();
|
||||
})
|
||||
],
|
||||
[
|
||||
this._dtpSettings,
|
||||
dtpSettings,
|
||||
[
|
||||
'changed::dot-size',
|
||||
'changed::show-favorites',
|
||||
@@ -332,16 +335,16 @@ var taskbar = Utils.defineClass({
|
||||
Lang.bind(this, this._redisplay)
|
||||
],
|
||||
[
|
||||
this._dtpSettings,
|
||||
dtpSettings,
|
||||
'changed::group-apps',
|
||||
Lang.bind(this, function() {
|
||||
this.isGroupApps = this._dtpSettings.get_boolean('group-apps');
|
||||
this.isGroupApps = dtpSettings.get_boolean('group-apps');
|
||||
this._connectWorkspaceSignals();
|
||||
this.resetAppIcons();
|
||||
})
|
||||
],
|
||||
[
|
||||
this._dtpSettings,
|
||||
dtpSettings,
|
||||
[
|
||||
'changed::group-apps-use-launchers',
|
||||
'changed::taskbar-locked'
|
||||
@@ -350,7 +353,7 @@ var taskbar = Utils.defineClass({
|
||||
]
|
||||
);
|
||||
|
||||
this.isGroupApps = this._dtpSettings.get_boolean('group-apps');
|
||||
this.isGroupApps = dtpSettings.get_boolean('group-apps');
|
||||
|
||||
this._connectWorkspaceSignals();
|
||||
},
|
||||
@@ -524,7 +527,7 @@ var taskbar = Utils.defineClass({
|
||||
|
||||
_createAppItem: function(app, window, isLauncher) {
|
||||
let appIcon = new AppIcons.taskbarAppIcon(
|
||||
this._dtpSettings,
|
||||
dtpSettings,
|
||||
{
|
||||
app: app,
|
||||
window: window,
|
||||
@@ -534,7 +537,7 @@ var taskbar = Utils.defineClass({
|
||||
{
|
||||
setSizeManually: true,
|
||||
showLabel: false,
|
||||
isDraggable: !this._dtpSettings.get_boolean('taskbar-locked'),
|
||||
isDraggable: !dtpSettings.get_boolean('taskbar-locked'),
|
||||
},
|
||||
this.previewMenu
|
||||
);
|
||||
@@ -686,8 +689,8 @@ var taskbar = Utils.defineClass({
|
||||
},
|
||||
|
||||
_adjustIconSize: function() {
|
||||
let panelSize = this._dtpSettings.get_int('panel-size');
|
||||
let availSize = panelSize - this._dtpSettings.get_int('appicon-padding') * 2;
|
||||
let panelSize = dtpSettings.get_int('panel-size');
|
||||
let availSize = panelSize - dtpSettings.get_int('appicon-padding') * 2;
|
||||
let minIconSize = MIN_ICON_SIZE + panelSize % 2;
|
||||
|
||||
if (availSize == this.iconSize)
|
||||
@@ -736,8 +739,8 @@ var taskbar = Utils.defineClass({
|
||||
},
|
||||
|
||||
sortAppsCompareFunction: function(appA, appB) {
|
||||
return getAppStableSequence(appA, this._dtpSettings, this.panelWrapper.monitor) -
|
||||
getAppStableSequence(appB, this._dtpSettings, this.panelWrapper.monitor);
|
||||
return getAppStableSequence(appA, dtpSettings, this.panelWrapper.monitor) -
|
||||
getAppStableSequence(appB, dtpSettings, this.panelWrapper.monitor);
|
||||
},
|
||||
|
||||
getAppInfos: function() {
|
||||
@@ -749,7 +752,7 @@ var taskbar = Utils.defineClass({
|
||||
// the current workspace (this check is done in AppIcons.getInterestingWindows)
|
||||
let runningApps = this._checkIfShowingRunningApps() ? this._getRunningApps().sort(this.sortAppsCompareFunction.bind(this)) : [];
|
||||
|
||||
if (!this.isGroupApps && this._dtpSettings.get_boolean('group-apps-use-launchers')) {
|
||||
if (!this.isGroupApps && dtpSettings.get_boolean('group-apps-use-launchers')) {
|
||||
return this._createAppInfos(favoriteApps, [], true)
|
||||
.concat(this._createAppInfos(runningApps)
|
||||
.filter(appInfo => appInfo.windows.length));
|
||||
@@ -833,12 +836,12 @@ var taskbar = Utils.defineClass({
|
||||
},
|
||||
|
||||
_checkIfShowingRunningApps: function() {
|
||||
return this._dtpSettings.get_boolean('show-running-apps');
|
||||
return dtpSettings.get_boolean('show-running-apps');
|
||||
},
|
||||
|
||||
_checkIfShowingFavorites: function() {
|
||||
return this._dtpSettings.get_boolean('show-favorites') &&
|
||||
(!this.panelWrapper.isSecondary || this._dtpSettings.get_boolean('show-favorites-all-monitors'));
|
||||
return dtpSettings.get_boolean('show-favorites') &&
|
||||
(!this.panelWrapper.isSecondary || dtpSettings.get_boolean('show-favorites-all-monitors'));
|
||||
},
|
||||
|
||||
_getRunningApps: function() {
|
||||
@@ -861,7 +864,7 @@ var taskbar = Utils.defineClass({
|
||||
return apps.map(app => ({
|
||||
app: app,
|
||||
isLauncher: defaultIsLauncher || false,
|
||||
windows: defaultWindows || AppIcons.getInterestingWindows(app, this._dtpSettings, this.panelWrapper.monitor)
|
||||
windows: defaultWindows || AppIcons.getInterestingWindows(app, dtpSettings, this.panelWrapper.monitor)
|
||||
.sort(sortWindowsCompareFunction)
|
||||
}));
|
||||
},
|
||||
@@ -901,8 +904,8 @@ var taskbar = Utils.defineClass({
|
||||
icon.updateNumberOverlay();
|
||||
});
|
||||
|
||||
if (this._dtpSettings.get_boolean('hot-keys') &&
|
||||
this._dtpSettings.get_string('hotkeys-overlay-combo') === 'ALWAYS')
|
||||
if (dtpSettings.get_boolean('hot-keys') &&
|
||||
dtpSettings.get_string('hotkeys-overlay-combo') === 'ALWAYS')
|
||||
this.toggleNumberOverlay(true);
|
||||
},
|
||||
|
||||
@@ -983,7 +986,7 @@ var taskbar = Utils.defineClass({
|
||||
|
||||
let appIcons = this._getAppIcons();
|
||||
let sourceIndex = appIcons.indexOf(source);
|
||||
let usingLaunchers = !this.isGroupApps && this._dtpSettings.get_boolean('group-apps-use-launchers');
|
||||
let usingLaunchers = !this.isGroupApps && dtpSettings.get_boolean('group-apps-use-launchers');
|
||||
|
||||
// dragging the icon to its original position
|
||||
if (this._dragInfo[0] === sourceIndex) {
|
||||
@@ -1002,7 +1005,7 @@ var taskbar = Utils.defineClass({
|
||||
let interestingWindows = {};
|
||||
let getAppWindows = app => {
|
||||
if (!interestingWindows[app]) {
|
||||
interestingWindows[app] = AppIcons.getInterestingWindows(app, this._dtpSettings, this.panelWrapper.monitor);
|
||||
interestingWindows[app] = AppIcons.getInterestingWindows(app, dtpSettings, this.panelWrapper.monitor);
|
||||
}
|
||||
|
||||
let appWindows = interestingWindows[app]; //prevents "reference to undefined property Symbol.toPrimitive" warning
|
||||
@@ -1054,7 +1057,7 @@ var taskbar = Utils.defineClass({
|
||||
// status (due to the _syncShowAppsButtonToggled function below) and it
|
||||
// has already performed the desired action.
|
||||
|
||||
let animate = this._dtpSettings.get_boolean('animate-show-apps');
|
||||
let animate = dtpSettings.get_boolean('animate-show-apps');
|
||||
let selector = Main.overview.viewSelector;
|
||||
|
||||
if (selector._showAppsButton.checked !== this.showAppsButton.checked) {
|
||||
@@ -1208,8 +1211,8 @@ var DragPlaceholderItem = Utils.defineClass({
|
||||
},
|
||||
});
|
||||
|
||||
function getAppStableSequence(app, settings, monitor) {
|
||||
let windows = AppIcons.getInterestingWindows(app, settings, monitor);
|
||||
function getAppStableSequence(app, dtpSettings, monitor) {
|
||||
let windows = AppIcons.getInterestingWindows(app, dtpSettings, monitor);
|
||||
|
||||
return windows.reduce((prevWindow, window) => {
|
||||
return Math.min(prevWindow, getWindowStableSequence(window));
|
||||
|
||||
Reference in New Issue
Block a user