From e79d0da8c9856764e32e9cab7cd6a1802677650e Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Tue, 12 May 2020 19:00:51 -0400 Subject: [PATCH] Add new panel positioning options --- Makefile | 2 +- Settings.ui | 468 ++++-------------- .../sources/D2P_import settings/Artist_design | 2 - .../D2P_import settings/Fortnite_Brite gunner | 2 - .../D2P_import settings/Galaxy_bizouneur | 2 - .../D2P_import settings/Ghibli_student | 2 - .../D2P_import settings/Mountain_intellihide | 3 - .../D2P_import settings/Plants_Solitaire | 2 - .../D2P_import settings/Star Wars_gamer | 2 - .../D2P_import settings/Wolf_programmer | 3 - panel.js | 429 +++++++++------- panelManager.js | 27 +- panelPositions.js | 60 +++ panelStyle.js | 50 +- prefs.js | 440 ++++++++-------- ...shell.extensions.dash-to-panel.gschema.xml | 49 +- stylesheet.css | 2 +- taskbar.js | 29 +- 18 files changed, 696 insertions(+), 878 deletions(-) create mode 100644 panelPositions.js diff --git a/Makefile b/Makefile index 23278d0..334f60f 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ UUID = dash-to-panel@jderose9.github.com BASE_MODULES = extension.js stylesheet.css metadata.json COPYING README.md -EXTRA_MODULES = appIcons.js convenience.js panel.js panelManager.js proximity.js intellihide.js progress.js panelStyle.js overview.js taskbar.js transparency.js windowPreview.js prefs.js update.js utils.js Settings.ui +EXTRA_MODULES = appIcons.js convenience.js panel.js panelManager.js proximity.js intellihide.js progress.js panelPositions.js panelStyle.js overview.js taskbar.js transparency.js windowPreview.js prefs.js update.js utils.js Settings.ui EXTRA_IMAGES = highlight_stacked_bg.svg highlight_stacked_bg_2.svg highlight_stacked_bg_3.svg TOLOCALIZE = prefs.js appIcons.js update.js diff --git a/Settings.ui b/Settings.ui index 8949c9f..118d7f4 100644 --- a/Settings.ui +++ b/Settings.ui @@ -3782,6 +3782,54 @@ 2 + + + True + True + + + True + False + 12 + 12 + 12 + 12 + 32 + + + True + False + True + Animate <i>Show Applications</i>. + True + 0 + + + 0 + 0 + + + + + True + True + end + center + + + 1 + 0 + + + + + + + False + True + 3 + + 5000 @@ -4394,94 +4442,61 @@ 0 in - + True False - none + vertical - - 100 + True - True + False + 12 + 12 + 12 + 12 - + True False - 12 - 12 - 12 - 12 - 32 - 32 - - - True - False - True - Taskbar position - 0 - - - 0 - 0 - - - - - True - False - center - - - 1 - 0 - - + True + Order and position of panel elements on monitor + 0 + + 0 + 0 + + + + + True + False + center + + + 1 + 0 + + + False + True + 0 + - + True - True - - - True - False - 12 - 12 - 12 - 12 - 32 - 32 - - - True - False - True - Clock location - 0 - - - 0 - 0 - - - - - True - False - center - - - 1 - 0 - - - - + False + 6 + none + + False + True + 1 + @@ -4588,79 +4603,6 @@ 0 - - - True - False - True - True - 0 - - - 0 - 3 - - - - - True - False - True - True - 0 - - - 0 - 2 - - - - - True - True - end - center - - - 1 - 3 - - - - - True - True - end - center - - - 1 - 2 - - - - - True - False - True - 6 - True - For the following 2 options, "additional" refers to panels that are displayed in addition to the gnome-shell top panel. - True - 40 - 0 - - - - 0 - 1 - - - - - @@ -5847,238 +5789,6 @@ - - - True - True - - - True - False - 12 - 12 - 12 - 12 - 32 - - - True - False - True - Show <i>Applications</i> icon - True - 0 - - - 0 - 0 - - - - - True - True - False - 12 - 3 - 0 - 0.5 - True - - - 4 - True - False - 4 - Animate <i>Show Applications</i>. - True - - - - - 0 - 1 - 2 - - - - - True - False - 6 - - - True - True - True - center - center - 0.46000000834465027 - - - True - False - emblem-system-symbolic - - - - - - False - True - 0 - - - - - True - True - end - center - - - False - True - 1 - - - - - 1 - 0 - - - - - - - - - 100 - True - True - - - True - False - 12 - 12 - 12 - 12 - 32 - - - True - True - end - center - - - 1 - 0 - - - - - True - False - True - Show <i>Activities</i> button - True - 0 - - - 0 - 0 - - - - - - - - - 100 - True - True - - - True - False - 12 - 12 - 12 - 12 - 32 - - - True - False - True - Show <i>Desktop</i> button - True - 0 - - - 0 - 0 - - - - - True - False - 6 - - - True - True - True - center - center - 0.46000000834465027 - - - True - False - emblem-system-symbolic - - - - - - False - True - 0 - - - - - True - True - end - center - - - False - True - 1 - - - - - 1 - 0 - - - - - - 100 diff --git a/media/sources/D2P_import settings/Artist_design b/media/sources/D2P_import settings/Artist_design index a744408..3390515 100644 --- a/media/sources/D2P_import settings/Artist_design +++ b/media/sources/D2P_import settings/Artist_design @@ -11,7 +11,6 @@ show-activities-button=false intellihide-use-pressure=false group-apps-use-launchers=false focus-highlight=true -location-clock='BUTTONSRIGHT' panel-position='BOTTOM' hot-keys=true window-preview-height=50 @@ -71,7 +70,6 @@ show-show-apps-button=true dot-style-unfocused='DOTS' shift-click-action='MINIMIZE' trans-gradient-bottom-color='#2195c5' -taskbar-position='LEFTPANEL_FIXEDCENTER' click-action='MINIMIZE' animate-show-apps=true group-apps-label-font-size=14 diff --git a/media/sources/D2P_import settings/Fortnite_Brite gunner b/media/sources/D2P_import settings/Fortnite_Brite gunner index 75f5744..74a20b7 100644 --- a/media/sources/D2P_import settings/Fortnite_Brite gunner +++ b/media/sources/D2P_import settings/Fortnite_Brite gunner @@ -11,7 +11,6 @@ show-activities-button=false intellihide-use-pressure=false group-apps-use-launchers=false focus-highlight=true -location-clock='STATUSLEFT' panel-position='BOTTOM' hot-keys=true window-preview-height=50 @@ -71,7 +70,6 @@ show-show-apps-button=true dot-style-unfocused='CILIORA' shift-click-action='MINIMIZE' trans-gradient-bottom-color='#765550' -taskbar-position='CENTEREDMONITOR' click-action='RAISE' animate-show-apps=true group-apps-label-font-size=14 diff --git a/media/sources/D2P_import settings/Galaxy_bizouneur b/media/sources/D2P_import settings/Galaxy_bizouneur index 17d52d8..61385c2 100644 --- a/media/sources/D2P_import settings/Galaxy_bizouneur +++ b/media/sources/D2P_import settings/Galaxy_bizouneur @@ -11,7 +11,6 @@ show-activities-button=false intellihide-use-pressure=false group-apps-use-launchers=false focus-highlight=true -location-clock='STATUSLEFT' panel-position='TOP' hot-keys=true window-preview-height=100 @@ -71,7 +70,6 @@ show-show-apps-button=true dot-style-unfocused='CILIORA' shift-click-action='MINIMIZE' trans-gradient-bottom-color='#4a5b8f' -taskbar-position='LEFTPANEL' click-action='RAISE' animate-show-apps=true group-apps-label-font-size=14 diff --git a/media/sources/D2P_import settings/Ghibli_student b/media/sources/D2P_import settings/Ghibli_student index 1bcefa0..6f38506 100644 --- a/media/sources/D2P_import settings/Ghibli_student +++ b/media/sources/D2P_import settings/Ghibli_student @@ -11,7 +11,6 @@ show-activities-button=false intellihide-use-pressure=false group-apps-use-launchers=false focus-highlight=true -location-clock='STATUSRIGHT' panel-position='TOP' hot-keys=true window-preview-height=80 @@ -71,7 +70,6 @@ show-show-apps-button=true dot-style-unfocused='DOTS' shift-click-action='MINIMIZE' trans-gradient-bottom-color='#2195c5' -taskbar-position='CENTEREDMONITOR' click-action='RAISE' animate-show-apps=true group-apps-label-font-size=14 diff --git a/media/sources/D2P_import settings/Mountain_intellihide b/media/sources/D2P_import settings/Mountain_intellihide index 8b46192..de05575 100644 --- a/media/sources/D2P_import settings/Mountain_intellihide +++ b/media/sources/D2P_import settings/Mountain_intellihide @@ -45,7 +45,6 @@ app-hotkey-6=['6'] app-hotkey-7=['7'] app-hotkey-8=['8'] app-hotkey-9=['9'] -location-clock='STATUSLEFT' intellihide-use-pressure=false intellihide-pressure-time=1000 app-ctrl-hotkey-10=['0'] @@ -103,7 +102,6 @@ show-apps-icon-file='' primary-monitor=0 window-preview-width=240 trans-gradient-top-opacity=0.0 -show-clock-all-monitors=true intellihide-close-delay=400 focus-highlight=true app-hotkey-10=['0'] @@ -164,7 +162,6 @@ leftbox-size=0 group-apps-label-font-weight='inherit' appicon-padding=2 trans-dynamic-opacity=true -taskbar-position='LEFTPANEL' intellihide-animation-time=200 hot-keys=false app-hotkey-kp-10=['KP_0'] diff --git a/media/sources/D2P_import settings/Plants_Solitaire b/media/sources/D2P_import settings/Plants_Solitaire index a4c0ae7..7b6aae4 100644 --- a/media/sources/D2P_import settings/Plants_Solitaire +++ b/media/sources/D2P_import settings/Plants_Solitaire @@ -11,7 +11,6 @@ show-activities-button=false intellihide-use-pressure=false group-apps-use-launchers=false focus-highlight=true -location-clock='BUTTONSRIGHT' panel-position='TOP' hot-keys=true window-preview-height=50 @@ -71,7 +70,6 @@ show-show-apps-button=true dot-style-unfocused='SEGMENTED' shift-click-action='MINIMIZE' trans-gradient-bottom-color='#e5e3e4' -taskbar-position='LEFTPANEL_FIXEDCENTER' click-action='MINIMIZE' animate-show-apps=true group-apps-label-font-size=14 diff --git a/media/sources/D2P_import settings/Star Wars_gamer b/media/sources/D2P_import settings/Star Wars_gamer index 325622f..74d2577 100644 --- a/media/sources/D2P_import settings/Star Wars_gamer +++ b/media/sources/D2P_import settings/Star Wars_gamer @@ -11,7 +11,6 @@ show-activities-button=false intellihide-use-pressure=false group-apps-use-launchers=false focus-highlight=true -location-clock='STATUSLEFT' panel-position='BOTTOM' hot-keys=true window-preview-height=100 @@ -71,7 +70,6 @@ show-show-apps-button=true dot-style-unfocused='DASHES' shift-click-action='MINIMIZE' trans-gradient-bottom-color='#3b5346' -taskbar-position='LEFTPANEL_FLOATCENTER' click-action='RAISE' animate-show-apps=true group-apps-label-font-size=14 diff --git a/media/sources/D2P_import settings/Wolf_programmer b/media/sources/D2P_import settings/Wolf_programmer index 3bfa1f8..167b75a 100644 --- a/media/sources/D2P_import settings/Wolf_programmer +++ b/media/sources/D2P_import settings/Wolf_programmer @@ -45,7 +45,6 @@ app-hotkey-6=['6'] app-hotkey-7=['7'] app-hotkey-8=['8'] app-hotkey-9=['9'] -location-clock='STATUSLEFT' intellihide-use-pressure=false intellihide-pressure-time=1000 app-ctrl-hotkey-10=['0'] @@ -103,7 +102,6 @@ show-apps-icon-file='' primary-monitor=0 window-preview-width=240 trans-gradient-top-opacity=0.0 -show-clock-all-monitors=true intellihide-close-delay=400 focus-highlight=true app-hotkey-10=['0'] @@ -163,7 +161,6 @@ leftbox-size=0 group-apps-label-font-weight='inherit' appicon-padding=2 trans-dynamic-opacity=true -taskbar-position='LEFTPANEL' intellihide-animation-time=200 hot-keys=false app-hotkey-kp-10=['KP_0'] diff --git a/panel.js b/panel.js index 5ded78e..70307c3 100644 --- a/panel.js +++ b/panel.js @@ -35,6 +35,7 @@ const Gi = imports._gi; const AppIcons = Me.imports.appIcons; const Utils = Me.imports.utils; const Taskbar = Me.imports.taskbar; +const Pos = Me.imports.panelPositions; const PanelStyle = Me.imports.panelStyle; const Lang = imports.lang; const Main = imports.ui.main; @@ -167,9 +168,9 @@ var dtpPanel = Utils.defineClass({ this.menuManager = this.panel.menuManager = new PopupMenu.PopupMenuManager(this.panel); - //adding the clock to the centerbox will correctly position it according to dtp settings (event actor-added) - this._setPanelMenu('show-status-menu-all-monitors', 'aggregateMenu', dtpSecondaryAggregateMenu, this._rightBox, true); - this._setPanelMenu('show-clock-all-monitors', 'dateMenu', DateMenu.DateMenuButton, this._centerBox, true); + this._setPanelMenu('aggregateMenu', dtpSecondaryAggregateMenu, this.panel.actor); + this._setPanelMenu('dateMenu', DateMenu.DateMenuButton, this.panel.actor); + this._setPanelMenu('activities', Panel.ActivitiesButton, this.panel.actor); if (this.statusArea.aggregateMenu) { setMenuArrow(this.statusArea.aggregateMenu._indicators.get_last_child(), position); @@ -186,24 +187,39 @@ var dtpPanel = Utils.defineClass({ setMenuArrow(this.statusArea.aggregateMenu._indicators.get_last_child(), position); panelBoxes.forEach(p => this[p] = Main.panel[p]); + + this._leftBox.remove_child(this.statusArea.activities.container); + this.panel.actor.add_child(this.statusArea.activities.container); + + this._rightBox.remove_child(this.statusArea.aggregateMenu.container); + this.panel.actor.add_child(this.statusArea.aggregateMenu.container); + + this._centerBox.remove_child(this.statusArea.dateMenu.container); + this.panel.actor.add_child(this.statusArea.dateMenu.container); } + // Create a wrapper around the real showAppsIcon in order to add a popupMenu. Most of + // its behavior is handled by the taskbar, but its positioning is done at the panel level + this.showAppsIconWrapper = new AppIcons.ShowAppsIconWrapper(); + this.showAppsIconWrapper._dtpPanel = this; + this.panel.actor.add_child(this.showAppsIconWrapper.realShowAppsIcon); + this.panel.actor._delegate = this; if (position == St.Side.TOP) { this.panel._leftCorner = this.panel._leftCorner || new Panel.PanelCorner(St.Side.LEFT); this.panel._rightCorner = this.panel._rightCorner || new Panel.PanelCorner(St.Side.RIGHT); - - if (isStandalone) { - this.panel.add_child(this.panel._leftCorner.actor); - this.panel.add_child(this.panel._rightCorner.actor); - this.panel._rightCorner.setStyleParent(this._rightBox); - } } Utils.wrapActor(this.panel._leftCorner || 0); Utils.wrapActor(this.panel._rightCorner || 0); + if (isStandalone && position == St.Side.TOP) { + this.panel.actor.add_child(this.panel._leftCorner.actor); + this.panel.actor.add_child(this.panel._rightCorner.actor); + this.panel._rightCorner.setStyleParent(this.panel.actor); + } + this.add_child(this.panel.actor); if (Main.panel._onButtonPress || Main.panel._tryDragWindow) { @@ -226,15 +242,8 @@ var dtpPanel = Utils.defineClass({ }, enable : function() { - let taskbarPosition = Me.settings.get_string('taskbar-position'); let position = getPosition(); - if (taskbarPosition == 'CENTEREDCONTENT' || taskbarPosition == 'CENTEREDMONITOR') { - this.container = this._centerBox; - } else { - this.container = this._leftBox; - } - if (this.statusArea.aggregateMenu) { Utils.getIndicators(this.statusArea.aggregateMenu._volume)._dtpIgnoreScroll = 1; } @@ -322,13 +331,13 @@ var dtpPanel = Utils.defineClass({ this.taskbar = new Taskbar.taskbar(this); - this.container.insert_child_above(this.taskbar.actor, null); - - this._setActivitiesButtonVisible(Me.settings.get_boolean('show-activities-button')); + this.panel.actor.add_child(this.taskbar.actor); + this._setAppmenuVisible(Me.settings.get_boolean('show-appmenu')); - this._setClockLocation(Me.settings.get_string('location-clock')); - this._displayShowDesktopButton(Me.settings.get_boolean('show-showdesktop-button')); + this._setShowDesktopButton(true); + this._setAllocationMap(); + this._setRightCornerStyle(); this.panel.actor.add_style_class_name('dashtopanelMainPanel ' + getOrientation()); @@ -340,9 +349,6 @@ var dtpPanel = Utils.defineClass({ this._setPanelGhostSize(); - if(this.taskbar._showAppsIconWrapper) - this.taskbar._showAppsIconWrapper._dtpPanel = this; - this._timeoutsHandler.add([T2, Me.settings.get_int('intellihide-enable-start-delay'), () => this.intellihide = new Intellihide.Intellihide(this)]); this._signalsHandler.add( @@ -356,7 +362,7 @@ var dtpPanel = Utils.defineClass({ // sync hover after a popupmenu is closed this.taskbar, 'menu-closed', - Lang.bind(this, function(){this.container.sync_hover();}) + Lang.bind(this, function(){this.panel.actor.sync_hover();}) ], [ Main.overview, @@ -429,7 +435,7 @@ var dtpPanel = Utils.defineClass({ this._timeoutsHandler.destroy(); this._signalsHandler.destroy(); - this.container.remove_child(this.taskbar.actor); + this.panel.remove_child(this.taskbar.actor); this._setAppmenuVisible(false); if (this.intellihide) { @@ -441,6 +447,7 @@ var dtpPanel = Utils.defineClass({ this.progressManager.destroy(); this.taskbar.destroy(); + this.showAppsIconWrapper.destroy(); this.menuManager._changeMenu = this.menuManager._oldChangeMenu; @@ -463,10 +470,16 @@ var dtpPanel = Utils.defineClass({ ['vertical', 'horizontal', 'dashtopanelMainPanel'].forEach(c => this.panel.actor.remove_style_class_name(c)); - if(!Main.sessionMode.isLocked) { - this._setActivitiesButtonVisible(true); - this._setClockLocation("BUTTONSLEFT"); + if (!Main.sessionMode.isLocked) { + this.panel.remove_child(this.statusArea.activities.container); + this._leftBox.insert_child_at_index(this.statusArea.activities.container, 0); + this.panel.remove_child(this.statusArea.dateMenu.container); + this._centerBox.insert_child_at_index(this.statusArea.dateMenu.container, 0); + + this.panel.remove_child(this.statusArea.aggregateMenu.container); + this._rightBox.add_child(this.statusArea.aggregateMenu.container); + if (this.statusArea.appMenu) { setMenuArrow(this.statusArea.appMenu._arrow, St.Side.TOP); this._leftBox.add_child(this.statusArea.appMenu.container); @@ -477,7 +490,7 @@ var dtpPanel = Utils.defineClass({ } } - this._displayShowDesktopButton(false); + this._setShowDesktopButton(false); this._toggleCornerStyle(this.panel._leftCorner, true); this._toggleCornerStyle(this.panel._rightCorner, true); @@ -500,6 +513,7 @@ var dtpPanel = Utils.defineClass({ } else { this._removePanelMenu('dateMenu'); this._removePanelMenu('aggregateMenu'); + this._removePanelMenu('activities'); if (this.panel._rightCorner && this.panel._rightCorner._buttonStyleChangedSignalId) { this.panel._rightCorner._button.disconnect(this.panel._rightCorner._buttonStyleChangedSignalId); @@ -521,6 +535,23 @@ var dtpPanel = Utils.defineClass({ return DND.DragMotionResult.CONTINUE; }, + updateElementPositions: function() { + this._getElementPositions().forEach(pos => { + let actor = this.allocationMap[pos.element].actor; + + if (actor) { + actor.visible = pos.visible; + } + }); + + this.panel.actor.hide(); + this.panel.actor.show(); + }, + + _getElementPositions: function() { + return this.panelManager.panelsElementPositions[this.monitor.index] || Pos.defaults; + }, + _bindSettingsChanges: function() { let isVertical = checkIfVertical(); @@ -541,26 +572,11 @@ var dtpPanel = Utils.defineClass({ ], () => this.taskbar.resetAppIcons() ], - [ - Me.settings, - 'changed::show-activities-button', - () => this._setActivitiesButtonVisible(Me.settings.get_boolean('show-activities-button')) - ], [ Me.settings, 'changed::show-appmenu', () => this._setAppmenuVisible(Me.settings.get_boolean('show-appmenu')) ], - [ - Me.settings, - 'changed::location-clock', - () => this._setClockLocation(Me.settings.get_string('location-clock')) - ], - [ - Me.settings, - 'changed::show-showdesktop-button', - () => this._displayShowDesktopButton(Me.settings.get_boolean('show-showdesktop-button')) - ], [ Me.settings, 'changed::showdesktop-button-width', @@ -594,14 +610,8 @@ var dtpPanel = Utils.defineClass({ } }, - _setPanelMenu: function(settingName, propName, constr, container, isInit) { - if (isInit) { - this._signalsHandler.add([Me.settings, 'changed::' + settingName, () => this._setPanelMenu(settingName, propName, constr, container)]); - } - - if (!Me.settings.get_boolean(settingName)) { - this._removePanelMenu(propName); - } else if (!this.statusArea[propName]) { + _setPanelMenu: function(propName, constr, container) { + if (!this.statusArea[propName]) { this.statusArea[propName] = this._getPanelMenu(propName, constr); this.menuManager.addMenu(this.statusArea[propName].menu); container.insert_child_at_index(this.statusArea[propName].container, 0); @@ -679,7 +689,7 @@ var dtpPanel = Utils.defineClass({ this.geom = this.getGeometry(); this._setPanelGhostSize(); this._setPanelPosition(); - this.taskbar.resetAppIcons(); + this.taskbar.resetAppIcons(true); this.dynamicTransparency.updateExternalStyle(); if (this.intellihide && this.intellihide.enabled) { @@ -687,6 +697,7 @@ var dtpPanel = Utils.defineClass({ } if (checkIfVertical()) { + this.showAppsButton.set_width(this.geom.w); this._refreshVerticalAlloc(); this._setSearchEntryOffset(this.geom.w); } @@ -750,91 +761,188 @@ var dtpPanel = Utils.defineClass({ }; }, + _setAllocationMap: function() { + this.allocationMap = {}; + let setMap = (name, actor, isBox) => this.allocationMap[name] = { + actor: actor, + isBox: isBox || 0, + box: new Clutter.ActorBox() + }; + + setMap(Pos.SHOW_APPS_BTN, this.showAppsIconWrapper.realShowAppsIcon); + setMap(Pos.ACTIVITIES_BTN, this.statusArea.activities ? this.statusArea.activities.container : 0); + setMap(Pos.LEFT_BOX, this._leftBox, 1); + setMap(Pos.TASKBAR, this.taskbar.actor); + setMap(Pos.CENTER_BOX, this._centerBox, 1); + setMap(Pos.DATE_MENU, this.statusArea.dateMenu.container); + setMap(Pos.SYSTEM_MENU, this.statusArea.aggregateMenu.container); + setMap(Pos.RIGHT_BOX, this._rightBox, 1); + setMap(Pos.DESKTOP_BTN, this._showDesktopButton); + }, + _mainPanelAllocate: function(actor, box, flags) { this.panel.actor.set_allocation(box, flags); }, vfunc_allocate: function(box, flags) { this.set_allocation(box, flags); - - let panelAllocVarSize = box[varCoord.c2] - box[varCoord.c1]; - let panelAllocFixedSize = box[fixedCoord.c2] - box[fixedCoord.c1]; - let [, leftNaturalSize] = this._leftBox[sizeFunc](-1); - let [, centerNaturalSize] = this._centerBox[sizeFunc](-1); - let [, rightNaturalSize] = this._rightBox[sizeFunc](-1); - let taskbarPosition = Me.settings.get_string('taskbar-position'); - - // The _rightBox is always allocated the same, regardless of taskbar position setting - let rightAllocSize = rightNaturalSize; - - // Now figure out how large the _leftBox and _centerBox should be. - // The box with the taskbar is always the one that is forced to be smaller as the other boxes grow - let leftAllocSize, centerStartPosition, centerEndPosition; - let childBoxLeft = new Clutter.ActorBox(); - let childBoxCenter = new Clutter.ActorBox(); - let childBoxRight = new Clutter.ActorBox(); - - if (taskbarPosition == 'CENTEREDMONITOR') { - leftAllocSize = leftNaturalSize; - - centerStartPosition = Math.max(leftNaturalSize, Math.floor((panelAllocVarSize - centerNaturalSize)/2)); - centerEndPosition = Math.min(panelAllocVarSize-rightNaturalSize, Math.ceil((panelAllocVarSize+centerNaturalSize))/2); - } else if (taskbarPosition == 'CENTEREDCONTENT') { - leftAllocSize = leftNaturalSize; - - centerStartPosition = Math.max(leftNaturalSize, Math.floor((panelAllocVarSize - centerNaturalSize + leftNaturalSize - rightNaturalSize) / 2)); - centerEndPosition = Math.min(panelAllocVarSize-rightNaturalSize, Math.ceil((panelAllocVarSize + centerNaturalSize + leftNaturalSize - rightNaturalSize) / 2)); - } else if (taskbarPosition == 'LEFTPANEL_FIXEDCENTER') { - leftAllocSize = Math.floor((panelAllocVarSize - centerNaturalSize) / 2); - centerStartPosition = leftAllocSize; - centerEndPosition = centerStartPosition + centerNaturalSize; - } else if (taskbarPosition == 'LEFTPANEL_FLOATCENTER') { - let leftAllocSizeMax = panelAllocVarSize - rightNaturalSize - centerNaturalSize; - leftAllocSize = Math.min(leftAllocSizeMax, leftNaturalSize); - - let freeSpace = panelAllocVarSize - leftAllocSize - rightAllocSize - centerNaturalSize; - - centerStartPosition = leftAllocSize + Math.floor(freeSpace / 2); - centerEndPosition = centerStartPosition + centerNaturalSize; - } else { // LEFTPANEL - leftAllocSize = panelAllocVarSize - rightNaturalSize - centerNaturalSize; - centerStartPosition = leftAllocSize; - centerEndPosition = centerStartPosition + centerNaturalSize; - } - - childBoxLeft[fixedCoord.c1] = childBoxCenter[fixedCoord.c1] = childBoxRight[fixedCoord.c1] = 0; - childBoxLeft[fixedCoord.c2] = childBoxCenter[fixedCoord.c2] = childBoxRight[fixedCoord.c2] = panelAllocFixedSize; - - // if it is a RTL language, the boxes are switched around, and we need to invert the coordinates - if (this.get_text_direction() == Clutter.TextDirection.RTL) { - childBoxLeft[varCoord.c1] = panelAllocVarSize - leftAllocSize; - childBoxLeft[varCoord.c2] = panelAllocVarSize; - - childBoxCenter[varCoord.c1] = panelAllocVarSize - centerEndPosition; - childBoxCenter[varCoord.c2] = panelAllocVarSize - centerStartPosition; - - childBoxRight[varCoord.c1] = 0; - childBoxRight[varCoord.c2] = rightAllocSize; - } else { - childBoxLeft[varCoord.c1] = 0; - childBoxLeft[varCoord.c2] = leftAllocSize; - - childBoxCenter[varCoord.c1] = centerStartPosition; - childBoxCenter[varCoord.c2] = centerEndPosition; - - childBoxRight[varCoord.c1] = panelAllocVarSize - rightAllocSize; - childBoxRight[varCoord.c2] = panelAllocVarSize; - } this.panel.actor.allocate(new Clutter.ActorBox({ x1: 0, y1: 0, x2: this.geom.w, y2: this.geom.h }), flags); - this._leftBox.allocate(childBoxLeft, flags, 1); - this._centerBox.allocate(childBoxCenter, flags, 1); - this._rightBox.allocate(childBoxRight, flags, 1); + + let panelAllocVarSize = box[varCoord.c2] - box[varCoord.c1]; + let elements = []; + let centerMonitorElements = []; + let fixed = 0; + let checkIfCentered = element => element.position == Pos.CENTERED || element.position == Pos.CENTERED_MONITOR; + let allocateCenter = (centeredElements, trLimit, brLimit) => { + if (centeredElements.length) { + centeredElements.filter(c => c.hasDynamicSize).forEach(c => adjustDynamicSize(c)); + + let centeredWidth = centeredElements.reduce((size, c) => size + c.natSize, 0); + let tlOffset = Math.max(0, Math.round((brLimit - trLimit - centeredWidth) * .5)); + + centeredElements.forEach(c => { + allocate(c, trLimit + tlOffset); + trLimit += c.natSize; + }); + } + }; + let allocate = (element, c1) => { + element.box[varCoord.c1] = Math.max(0, Math.min(panelAllocVarSize, c1)); + element.box[varCoord.c2] = Math.max(element.natSize, Math.min(panelAllocVarSize, element.box[varCoord.c1] + element.natSize)); + + if (element.hasDynamicSize) { + adjustDynamicSize(element, true); + } + + element.fixed = 1; + ++fixed; + + let params = [element.box, flags]; + + if (element.isBox) { + params.push(1); + } + + element.actor.allocate.apply(element.actor, params); + }; + let adjustDynamicSize = (element, adjustPos) => { + let isCentered = checkIfCentered(element); + let getSiblingsInfo = (direction, defaultLimit = 0, unfixedSize = 0, centeredSize = 0, limit = 0) => { + let j = element.index + direction; + let refElement = elements[j]; + + while (refElement && (!refElement.fixed || (isCentered && refElement.position == element.position))) { + if (isCentered && refElement.position == element.position) { + centeredSize += refElement.natSize; + } + + unfixedSize += refElement.natSize; + refElement = elements[(j += direction)]; + } + + limit = refElement ? refElement.box[varCoord[direction > 0 ? 'c1' : 'c2']] : defaultLimit; + + return [unfixedSize, centeredSize, limit]; + }; + let [unfixedSizeTl, centeredSizeTl, prevLimit] = getSiblingsInfo(-1); + let [unfixedSizeBr, centeredSizeBr, nextLimit] = getSiblingsInfo(1, panelAllocVarSize); + let availableSize = nextLimit - prevLimit - unfixedSizeTl - unfixedSizeBr - + (isCentered ? Math.abs((unfixedSizeTl - centeredSizeTl) - (unfixedSizeBr - centeredSizeBr)) : 0); + + if (availableSize < element.natSize) { + element.natSize = availableSize; + + if (adjustPos) { + element.box[varCoord.c1] = Math.max(prevLimit + unfixedSizeTl, element.box[varCoord.c1]); + element.box[varCoord.c2] = Math.min(nextLimit - unfixedSizeBr, element.box[varCoord.c2]); + } + } + + element.hasDynamicSize = 0; + }; + + this._getElementPositions().forEach(pos => { + let element = this.allocationMap[pos.element]; + + if (element.actor && pos.visible) { + element.natSize = element.actor[sizeFunc](-1)[1]; + + if (element.natSize <= 0) return; + + element.box[fixedCoord.c1] = box[fixedCoord.c1]; + element.box[fixedCoord.c2] = box[fixedCoord.c2]; + element.hasDynamicSize = pos.element == Pos.TASKBAR; + element.index = elements.length; + element.position = pos.position; + element.fixed = 0; + + if (pos.position == Pos.CENTERED_MONITOR && + (!centerMonitorElements.length || elements[element.index - 1].position == Pos.CENTERED_MONITOR)) { + centerMonitorElements.push(element); + } + + elements.push(element); + } + }); + + allocateCenter(centerMonitorElements, 0, box[varCoord.c2]); + + let iterations = 0; //failsafe + while (fixed < elements.length && ++iterations < 10) { + for (let i = 0, l = elements.length; i < l; ++i) { + if (elements[i].fixed) continue; + + let element = elements[i]; + let prevElement = elements[i - 1]; + let nextElement = elements[i + 1]; + + if (element.position == Pos.STACKED_TL && prevElement && prevElement.position == Pos.STACKED_BR) { + element.position = Pos.STACKED_BR; + } + + if (element.position == Pos.STACKED_TL && (!prevElement || prevElement.fixed)) { + allocate(element, prevElement ? prevElement.box[varCoord.c2] : 0); + } else if (element.position == Pos.STACKED_BR && (!nextElement || nextElement.fixed)) { + let nextLimit = nextElement ? nextElement.box[varCoord.c1] : panelAllocVarSize; + + allocate(element, nextLimit - element.natSize); + } else if (checkIfCentered(element)) { //fallback for non contiguous CENTERED_MONITOR + let centeredElements = [element]; + let j = i; + + while (prevElement && prevElement.position == Pos.STACKED_BR) { + prevElement = elements[--j]; + } + + if (prevElement && !prevElement.fixed) continue; + + while (nextElement && checkIfCentered(nextElement)) { + centeredElements.push(nextElement); + nextElement = elements[++i + 1]; + } + + j = i; + while (nextElement && nextElement.position == Pos.STACKED_TL) { + nextElement = elements[++j]; + } + + if (!nextElement || (nextElement.fixed)) { + allocateCenter( + centeredElements, + prevElement ? prevElement.box[varCoord.c2] : 0, + nextElement ? nextElement.box[varCoord.c1] : panelAllocVarSize + ); + } + } + } + } if (this.geom.position == St.Side.TOP) { let childBoxLeftCorner = new Clutter.ActorBox(); let childBoxRightCorner = new Clutter.ActorBox(); let currentCornerSize = this.cornerSize; + let panelAllocFixedSize = box[fixedCoord.c2] - box[fixedCoord.c1]; [ , this.cornerSize] = this.panel._leftCorner.actor[sizeFunc](-1); childBoxLeftCorner[varCoord.c1] = 0; @@ -892,9 +1000,9 @@ var dtpPanel = Utils.defineClass({ //right click on an empty part of the panel, temporarily borrow and display the showapps context menu Main.layoutManager.setDummyCursorGeometry(stageX, stageY, 0, 0); - this.taskbar._showAppsIconWrapper.createMenu(); - this.taskbar._showAppsIconWrapper._menu.sourceActor = Main.layoutManager.dummyCursor; - this.taskbar._showAppsIconWrapper.popupMenu(); + this.showAppsIconWrapper.createMenu(); + this.showAppsIconWrapper._menu.sourceActor = Main.layoutManager.dummyCursor; + this.showAppsIconWrapper.popupMenu(); return Clutter.EVENT_STOP; } else if (Main.modalCount > 0 || event.get_source() != actor || @@ -939,9 +1047,7 @@ var dtpPanel = Utils.defineClass({ }, _onBoxActorAdded: function(box) { - if (!this._setClockLocation(Me.settings.get_string('location-clock'))) { - this._setRightCornerStyle(); - } + this._setRightCornerStyle(); if (checkIfVertical()) { this._setVertical(box, true); @@ -1001,12 +1107,6 @@ var dtpPanel = Utils.defineClass({ this._unmappedButtons.splice(this._unmappedButtons.indexOf(actor), 1); }, - _setActivitiesButtonVisible: function(isVisible) { - if(this.statusArea.activities) - isVisible ? this.statusArea.activities.container.show() : - this.statusArea.activities.container.hide(); - }, - _setAppmenuVisible: function(isVisible) { let parent; let appMenu = this.statusArea.appMenu; @@ -1019,12 +1119,7 @@ var dtpPanel = Utils.defineClass({ } if (isVisible && appMenu) { - let taskbarPosition = Me.settings.get_string('taskbar-position'); - if (taskbarPosition == 'CENTEREDCONTENT' || taskbarPosition == 'CENTEREDMONITOR') { - this._leftBox.insert_child_above(appMenu.container, null); - } else { - this._centerBox.insert_child_at_index(appMenu.container, 0); - } + this._leftBox.insert_child_above(appMenu.container, null); } }, @@ -1070,47 +1165,12 @@ var dtpPanel = Utils.defineClass({ } }, - _setClockLocation: function(loc) { - if(!this.statusArea.dateMenu) - return; - - let dateMenuContainer = this.statusArea.dateMenu.container; - let parent = dateMenuContainer.get_parent(); - let destination; - let refSibling = null; - - if (!parent) { - return; - } - - if (loc.indexOf('BUTTONS') == 0) { - destination = this._centerBox; - } else if (loc.indexOf('STATUS') == 0) { - refSibling = this.statusArea.aggregateMenu ? this.statusArea.aggregateMenu.container : null; - destination = this._rightBox; - } else { //TASKBAR - refSibling = this.taskbar.actor; - destination = refSibling.get_parent(); - } - - if (parent != destination) { - parent.remove_actor(dateMenuContainer); - destination.add_actor(dateMenuContainer); - } - - destination['set_child_' + (loc.indexOf('RIGHT') > 0 ? 'above' : 'below') + '_sibling'](dateMenuContainer, refSibling); - destination.queue_relayout(); - this._setRightCornerStyle(); - - return 1; - }, - _setRightCornerStyle: function() { if (this.panel._rightCorner) { this._toggleCornerStyle( this.panel._rightCorner, (this.statusArea.aggregateMenu && - this._rightBox.get_last_child() == this.statusArea.aggregateMenu.container) + this.panel.actor.get_last_child() == this.statusArea.aggregateMenu.container) ); } }, @@ -1121,8 +1181,8 @@ var dtpPanel = Utils.defineClass({ } }, - _displayShowDesktopButton: function (isVisible) { - if(isVisible) { + _setShowDesktopButton: function (add) { + if (add) { if(this._showDesktopButton) return; @@ -1159,15 +1219,14 @@ var dtpPanel = Utils.defineClass({  } }); - this._rightBox.insert_child_at_index(this._showDesktopButton, this._rightBox.get_children().length); + this.panel.actor.add_child(this._showDesktopButton); } else { if(!this._showDesktopButton) return; - this._rightBox.remove_child(this._showDesktopButton); + this.panel.actor.remove_child(this._showDesktopButton); this._showDesktopButton.destroy(); this._showDesktopButton = null; - this._setRightCornerStyle(); } }, diff --git a/panelManager.js b/panelManager.js index 06553c3..09b497c 100755 --- a/panelManager.js +++ b/panelManager.js @@ -30,6 +30,7 @@ const Me = imports.misc.extensionUtils.getCurrentExtension(); const Overview = Me.imports.overview; const Panel = Me.imports.panel; +const Pos = Me.imports.panelPositions; const Proximity = Me.imports.proximity; const Taskbar = Me.imports.taskbar; const Utils = Me.imports.utils; @@ -37,6 +38,7 @@ const Utils = Me.imports.utils; const Config = imports.misc.config; const Lang = imports.lang; const Gi = imports._gi; +const GLib = imports.gi.GLib; const Clutter = imports.gi.Clutter; const Meta = imports.gi.Meta; const Shell = imports.gi.Shell; @@ -58,6 +60,17 @@ var dtpPanelManager = Utils.defineClass({ _init: function() { this.overview = new Overview.dtpOverview(); + this.panelsElementPositions = {}; + + //Mutter meta_monitor_manager_get_primary_monitor (global.display.get_primary_monitor()) doesn't return the same + //monitor as GDK gdk_screen_get_primary_monitor (imports.gi.Gdk.Screen.get_default().get_primary_monitor()). + //Since the Mutter function is what's used in gnome-shell and we can't access it from the settings dialog, store + //the monitors information in a setting so we can use the same monitor indexes as the ones in gnome-shell + let primaryIndex = Main.layoutManager.primaryIndex; + let monitors = [primaryIndex]; + + Main.layoutManager.monitors.filter(m => m.index != primaryIndex).forEach(m => monitors.push(m.index)); + Me.settings.set_value('available-monitors', new GLib.Variant('ai', monitors)); Main.overview.viewSelector.appDisplay._views.forEach(v => { Utils.wrapActor(v.view); @@ -67,8 +80,6 @@ var dtpPanelManager = Utils.defineClass({ enable: function(reset) { let dtpPrimaryIndex = Me.settings.get_int('primary-monitor'); - if(dtpPrimaryIndex < 0 || dtpPrimaryIndex >= Main.layoutManager.monitors.length) - dtpPrimaryIndex = Main.layoutManager.primaryIndex; this.dtpPrimaryMonitor = Main.layoutManager.monitors[dtpPrimaryIndex]; this.proximityManager = new Proximity.ProximityManager(); @@ -115,6 +126,7 @@ var dtpPanelManager = Utils.defineClass({ }); } + this._updatePanelElementPositions(); this.setFocusedMonitor(this.dtpPrimaryMonitor); if (Panel.checkIfVertical()) { @@ -229,12 +241,16 @@ var dtpPanelManager = Utils.defineClass({ 'changed::primary-monitor', 'changed::multi-monitors', 'changed::isolate-monitors', - 'changed::taskbar-position', 'changed::panel-position', 'changed::stockgs-keep-top-panel' ], () => this._reset() ], + [ + Me.settings, + 'changed::panel-element-positions', + () => this._updatePanelElementPositions() + ], [ Me.settings, 'changed::intellihide-key-toggle-text', @@ -407,6 +423,11 @@ var dtpPanelManager = Utils.defineClass({ this.enable(true); }, + _updatePanelElementPositions: function() { + this.panelsElementPositions = Pos.getSettingsPositions(Me.settings); + this.allPanels.forEach(p => p.updateElementPositions()); + }, + _adjustPanelMenuButton: function(button, monitor, arrowSide) { if (button) { Utils.wrapActor(button); diff --git a/panelPositions.js b/panelPositions.js new file mode 100644 index 0000000..80eab48 --- /dev/null +++ b/panelPositions.js @@ -0,0 +1,60 @@ +/* + * This file is part of the Dash-To-Panel extension for Gnome 3 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +var SHOW_APPS_BTN = 'showAppsButton'; +var ACTIVITIES_BTN = 'activitiesButton'; +var TASKBAR = 'taskbar'; +var DATE_MENU = 'dateMenu'; +var SYSTEM_MENU = 'systemMenu'; +var LEFT_BOX = 'leftBox'; +var CENTER_BOX = 'centerBox'; +var RIGHT_BOX = 'rightBox'; +var DESKTOP_BTN = 'desktopButton'; + +var STACKED_TL = 'stackedTL'; +var STACKED_BR = 'stackedBR'; +var CENTERED = 'centered'; +var CENTERED_MONITOR = 'centerMonitor'; + +var defaults = [ + { element: SHOW_APPS_BTN, visible: true, position: STACKED_TL }, + { element: ACTIVITIES_BTN, visible: false, position: STACKED_TL }, + { element: LEFT_BOX, visible: false, position: STACKED_TL }, + { element: TASKBAR, visible: true, position: STACKED_TL }, + { element: CENTER_BOX, visible: true, position: STACKED_BR }, + { element: RIGHT_BOX, visible: true, position: STACKED_BR }, + { element: DATE_MENU, visible: true, position: STACKED_BR }, + { element: SYSTEM_MENU, visible: true, position: STACKED_BR }, + { element: DESKTOP_BTN, visible: true, position: STACKED_BR }, +]; + +var optionDialogFunctions = {}; + +optionDialogFunctions[SHOW_APPS_BTN] = '_showShowAppsButtonOptions'; +optionDialogFunctions[DESKTOP_BTN] = '_showDesktopButtonOptions'; + +function getSettingsPositions(settings) { + var positions = null; + + try { + positions = JSON.parse(settings.get_string('panel-element-positions')); + } catch(e) { + log('Error parsing positions: ' + e.message); + } + + return positions; +} \ No newline at end of file diff --git a/panelStyle.js b/panelStyle.js index 120040c..73e5072 100644 --- a/panelStyle.js +++ b/panelStyle.js @@ -193,25 +193,7 @@ var dtpPanelStyle = Utils.defineClass({ this._overrideStyle(this.panel._leftBox, leftboxContentSizeStyleLine, 0); } - - /*recurse actors */ - if(this._rightBoxOperations.length) { - let children = this.panel._rightBox.get_children(); - for(let i in children) - this._recursiveApply(children[i], this._rightBoxOperations); - } - - if(this._centerBoxOperations.length) { - let children = this.panel._centerBox.get_children(); - for(let i in children) - this._recursiveApply(children[i], this._centerBoxOperations); - } - - if(this._leftBoxOperations.length) { - let children = this.panel._leftBox.get_children(); - for(let i in children) - this._recursiveApply(children[i], this._leftBoxOperations); - } + this._applyStylesRecursively(); /* connect signal */ this._rightBoxActorAddedID = this.panel._rightBox.connect('actor-added', @@ -248,24 +230,32 @@ var dtpPanelStyle = Utils.defineClass({ this.panel._leftBox.disconnect(this._leftBoxActorAddedID); this._restoreOriginalStyle(this.panel._rightBox); - if(this._rightBoxOperations.length) { - let children = this.panel._rightBox.get_children(); - for(let i in children) - this._recursiveApply(children[i], this._rightBoxOperations, true); - } - this._restoreOriginalStyle(this.panel._centerBox); - if(this._centerBoxOperations.length) { - let children = this.panel._centerBox.get_children(); + this._restoreOriginalStyle(this.panel._leftBox); + + this._applyStylesRecursively(true); + }, + + _applyStylesRecursively: function(restore) { + /*recurse actors */ + if(this._rightBoxOperations.length) { + // add the system menu as we move it from the rightbox to the panel to position it independently + let children = this.panel._rightBox.get_children().concat([this.panel.statusArea.aggregateMenu.container]); for(let i in children) - this._recursiveApply(children[i], this._centerBoxOperations, true); + this._recursiveApply(children[i], this._rightBoxOperations, restore); + } + + if(this._centerBoxOperations.length) { + // add the date menu as we move it from the centerbox to the panel to position it independently + let children = this.panel._centerBox.get_children().concat([this.panel.statusArea.dateMenu.container]); + for(let i in children) + this._recursiveApply(children[i], this._centerBoxOperations, restore); } - this._restoreOriginalStyle(this.panel._leftBox); if(this._leftBoxOperations.length) { let children = this.panel._leftBox.get_children(); for(let i in children) - this._recursiveApply(children[i], this._leftBoxOperations, true); + this._recursiveApply(children[i], this._leftBoxOperations, restore); } }, diff --git a/prefs.js b/prefs.js index 9ae567c..d5118c9 100644 --- a/prefs.js +++ b/prefs.js @@ -35,6 +35,7 @@ const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']); const _ = Gettext.gettext; const N_ = function(e) { return e }; const Update = Me.imports.update; +const Pos = Me.imports.panelPositions; const SCALE_UPDATE_TIMEOUT = 500; const DEFAULT_PANEL_SIZES = [ 128, 96, 64, 48, 32, 24, 16 ]; @@ -200,34 +201,220 @@ const Settings = new Lang.Class({ _updateVerticalRelatedOptions: function() { let position = this._settings.get_string('panel-position'); let isVertical = position == 'LEFT' || position == 'RIGHT'; - let taskbarLocationCombo = this._builder.get_object('taskbar_position_combo'); - let clockLocationCombo = this._builder.get_object('location_clock_combo'); let showDesktopWidthLabel = this._builder.get_object('show_showdesktop_width_label'); - - taskbarLocationCombo.remove_all(); - clockLocationCombo.remove_all(); - - [ - ['LEFTPANEL', isVertical ? _('Top, with plugin icons collapsed to bottom') : _('Left, with plugin icons collapsed to right')], - ['LEFTPANEL_FIXEDCENTER', isVertical ? _('Top, with fixed center plugin icons') : _('Left, with fixed center plugin icons')], - ['LEFTPANEL_FLOATCENTER', isVertical ? _('Top, with floating center plugin icons') : _('Left, with floating center plugin icons')], - ['CENTEREDMONITOR', _('Center, fixed in middle of monitor')], - ['CENTEREDCONTENT', isVertical ? _('Center, floating between top and bottom elements') : _('Center, floating between left and right elements')] - ].forEach(tl => taskbarLocationCombo.append.apply(taskbarLocationCombo, tl)); - - [ - ['BUTTONSLEFT', isVertical ? _('Top of plugin icons') : _('Left of plugin icons')], - ['BUTTONSRIGHT', isVertical ? _('Bottom of plugin icons') : _('Right of plugin icons')], - ['STATUSLEFT', isVertical ? _('Top of system indicators') : _('Left of system indicators')], - ['STATUSRIGHT', isVertical ? _('Bottom of system indicators') : _('Right of system indicators')], - ['TASKBARLEFT', isVertical ? _('Top of taskbar') : _('Left of taskbar')], - ['TASKBARRIGHT', isVertical ? _('Bottom of taskbar') : _('Right of taskbar')] - ].forEach(cl => clockLocationCombo.append.apply(clockLocationCombo, cl)); - - taskbarLocationCombo.set_active_id(this._settings.get_string('taskbar-position')); - clockLocationCombo.set_active_id(this._settings.get_string('location-clock')); showDesktopWidthLabel.set_text(isVertical ? _('Show Desktop button height (px)') : _('Show Desktop button width (px)')); + + this._displayTaskbarElementPositionsForMonitor(this.monitors[this._builder.get_object('taskbar_position_monitor_combo').get_active()]); + }, + + _displayTaskbarElementPositionsForMonitor: function(monitorIndex) { + let taskbarListBox = this._builder.get_object('taskbar_display_listbox'); + + taskbarListBox.get_children().forEach(c => c.destroy()); + + let labels = {}; + let position = this._settings.get_string('panel-position'); + let isVertical = position == 'LEFT' || position == 'RIGHT'; + let positionSettings = Pos.getSettingsPositions(this._settings); + let panelInfo = positionSettings[monitorIndex] || Pos.defaults; + let updateSettings = () => { + let newPanelInfo = []; + + taskbarListBox.get_children().forEach(c => { + newPanelInfo.push({ + element: c.id, + visible: c.visibleToggleBtn.get_active(), + position: c.positionCombo.get_active_id() + }); + }); + + positionSettings[monitorIndex] = newPanelInfo; + this._settings.set_string('panel-element-positions', JSON.stringify(positionSettings)); + }; + + labels[Pos.SHOW_APPS_BTN] = _('Show Applications button'); + labels[Pos.ACTIVITIES_BTN] = _('Activities button'); + labels[Pos.TASKBAR] = _('Taskbar'); + labels[Pos.DATE_MENU] = _('Date menu'); + labels[Pos.SYSTEM_MENU] = _('System menu'); + labels[Pos.LEFT_BOX] = _('Left box'); + labels[Pos.CENTER_BOX] = _('Center box'); + labels[Pos.RIGHT_BOX] = _('Right box'); + labels[Pos.DESKTOP_BTN] = _('Desktop button'); + + panelInfo.forEach(el => { + let row = new Gtk.ListBoxRow(); + let grid = new Gtk.Grid({ margin: 2, margin_left: 12, margin_right: 12, column_spacing: 8 }); + let upDownGrid = new Gtk.Grid({ column_spacing: 2 }); + let upBtn = new Gtk.Button({ tooltip_text: _('Move up') }); + let upImg = new Gtk.Image({ icon_name: 'go-up-symbolic', pixel_size: 12 }); + let downBtn = new Gtk.Button({ tooltip_text: _('Move down') }); + let downImg = new Gtk.Image({ icon_name: 'go-down-symbolic', pixel_size: 12 }); + let visibleToggleBtn = new Gtk.ToggleButton({ label: _('Visible'), active: el.visible }); + let positionCombo = new Gtk.ComboBoxText({ tooltip_text: _('Select element position') }); + let upDownClickHandler = limit => { + let index = row.get_index(); + + if (index != limit) { + taskbarListBox.remove(row); + taskbarListBox.insert(row, index + (!limit ? -1 : 1)); + updateSettings(); + } + }; + + positionCombo.append(Pos.STACKED_TL, isVertical ? _('Stacked top') : _('Stacked left')); + positionCombo.append(Pos.STACKED_BR, isVertical ? _('Stacked bottom') :_('Stacked right')); + positionCombo.append(Pos.CENTERED, _('Centered')); + positionCombo.append(Pos.CENTERED_MONITOR, _('Monitor Center')); + positionCombo.set_active_id(el.position); + + upBtn.connect('clicked', () => upDownClickHandler(0)); + downBtn.connect('clicked', () => upDownClickHandler(panelInfo.length - 1)); + visibleToggleBtn.connect('toggled', () => updateSettings()); + positionCombo.connect('changed', () => updateSettings()); + + upBtn.add(upImg); + downBtn.add(downImg); + + upDownGrid.add(upBtn); + upDownGrid.add(downBtn); + + grid.add(upDownGrid); + grid.add(new Gtk.Label({ label: labels[el.element], xalign: 0, hexpand: true })); + + if (Pos.optionDialogFunctions[el.element]) { + let cogImg = new Gtk.Image({ icon_name: 'emblem-system-symbolic' }); + let optionsBtn = new Gtk.Button({ tooltip_text: _('More options') }); + + optionsBtn.get_style_context().add_class('circular'); + optionsBtn.add(cogImg); + grid.add(optionsBtn); + + optionsBtn.connect('clicked', () => this[Pos.optionDialogFunctions[el.element]]()); + } + + grid.add(visibleToggleBtn); + grid.add(positionCombo); + + row.id = el.element; + row.visibleToggleBtn = visibleToggleBtn; + row.positionCombo = positionCombo; + + row.add(grid); + taskbarListBox.add(row); + }); + + taskbarListBox.show_all(); + }, + + _showShowAppsButtonOptions: function() { + let dialog = new Gtk.Dialog({ title: _('Show Applications options'), + transient_for: this.widget.get_toplevel(), + use_header_bar: true, + modal: true }); + + // GTK+ leaves positive values for application-defined response ids. + // Use +1 for the reset action + dialog.add_button(_('Reset to defaults'), 1); + + let box = this._builder.get_object('show_applications_options'); + dialog.get_content_area().add(box); + + let fileChooser = this._builder.get_object('show_applications_icon_file_filebutton'); + let fileImage = this._builder.get_object('show_applications_current_icon_image'); + let fileFilter = new Gtk.FileFilter(); + let handleIconChange = function(newIconPath) { + if (newIconPath && GLib.file_test(newIconPath, GLib.FileTest.EXISTS)) { + let file = Gio.File.new_for_path(newIconPath) + let pixbuf = GdkPixbuf.Pixbuf.new_from_stream_at_scale(file.read(null), 32, 32, true, null); + + fileImage.set_from_pixbuf(pixbuf); + fileChooser.set_filename(newIconPath); + } else { + newIconPath = ''; + fileImage.set_from_icon_name('view-app-grid-symbolic', 32); + fileChooser.unselect_all(); + fileChooser.set_current_folder(GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES)); + } + + this._settings.set_string('show-apps-icon-file', newIconPath || ''); + }; + + fileFilter.add_pixbuf_formats(); + fileChooser.filter = fileFilter; + + fileChooser.connect('file-set', widget => handleIconChange.call(this, widget.get_filename())); + handleIconChange.call(this, this._settings.get_string('show-apps-icon-file')); + + dialog.connect('response', Lang.bind(this, function(dialog, id) { + if (id == 1) { + // restore default settings + this._settings.set_value('show-apps-icon-side-padding', this._settings.get_default_value('show-apps-icon-side-padding')); + this._builder.get_object('show_applications_side_padding_spinbutton').set_value(this._settings.get_int('show-apps-icon-side-padding')); + this._settings.set_value('show-apps-override-escape', this._settings.get_default_value('show-apps-override-escape')); + handleIconChange.call(this, null); + } else { + // remove the settings box so it doesn't get destroyed; + dialog.get_content_area().remove(box); + dialog.destroy(); + } + return; + })); + + dialog.show_all(); + }, + + _showDesktopButtonOptions: function() { + let dialog = new Gtk.Dialog({ title: _('Show Desktop options'), + transient_for: this.widget.get_toplevel(), + use_header_bar: true, + modal: true }); + + // GTK+ leaves positive values for application-defined response ids. + // Use +1 for the reset action + dialog.add_button(_('Reset to defaults'), 1); + + let box = this._builder.get_object('box_show_showdesktop_options'); + dialog.get_content_area().add(box); + + this._builder.get_object('show_showdesktop_width_spinbutton').set_value(this._settings.get_int('showdesktop-button-width')); + this._builder.get_object('show_showdesktop_width_spinbutton').connect('value-changed', Lang.bind (this, function(widget) { + this._settings.set_int('showdesktop-button-width', widget.get_value()); + })); + + this._builder.get_object('show_showdesktop_delay_spinbutton').set_value(this._settings.get_int('show-showdesktop-delay')); + this._builder.get_object('show_showdesktop_delay_spinbutton').connect('value-changed', Lang.bind (this, function(widget) { + this._settings.set_int('show-showdesktop-delay', widget.get_value()); + })); + + this._builder.get_object('show_showdesktop_time_spinbutton').set_value(this._settings.get_int('show-showdesktop-time')); + this._builder.get_object('show_showdesktop_time_spinbutton').connect('value-changed', Lang.bind (this, function(widget) { + this._settings.set_int('show-showdesktop-time', widget.get_value()); + })); + + dialog.connect('response', Lang.bind(this, function(dialog, id) { + if (id == 1) { + // restore default settings + this._settings.set_value('showdesktop-button-width', this._settings.get_default_value('showdesktop-button-width')); + this._builder.get_object('show_showdesktop_width_spinbutton').set_value(this._settings.get_int('showdesktop-button-width')); + + this._settings.set_value('show-showdesktop-hover', this._settings.get_default_value('show-showdesktop-hover')); + + this._settings.set_value('show-showdesktop-delay', this._settings.get_default_value('show-showdesktop-delay')); + this._builder.get_object('show_showdesktop_delay_spinbutton').set_value(this._settings.get_int('show-showdesktop-delay')); + + this._settings.set_value('show-showdesktop-time', this._settings.get_default_value('show-showdesktop-time')); + this._builder.get_object('show_showdesktop_time_spinbutton').set_value(this._settings.get_int('show-showdesktop-time')); + } else { + // remove the settings box so it doesn't get destroyed; + dialog.get_content_area().remove(box); + dialog.destroy(); + } + return; + })); + + dialog.show_all(); }, _setPositionRadios: function() { @@ -256,24 +443,11 @@ const Settings = new Lang.Class({ // Position option this._setPositionRadios(); + this.monitors = this._settings.get_value('available-monitors').deep_unpack(); + this._settings.connect('changed::panel-position', () => this._updateVerticalRelatedOptions()); this._updateVerticalRelatedOptions(); - this._builder.get_object('location_clock_combo').connect('changed', Lang.bind (this, function(widget) { - let activeId = widget.get_active_id(); - - if (activeId) { - this._settings.set_string('location-clock', activeId); - } - })); - this._builder.get_object('taskbar_position_combo').connect('changed', Lang.bind (this, function(widget) { - let activeId = widget.get_active_id(); - - if (activeId) { - this._settings.set_string('taskbar-position', activeId); - } - })); - // size options let panel_size_scale = this._builder.get_object('panel_size_scale'); panel_size_scale.set_range(DEFAULT_PANEL_SIZES[DEFAULT_PANEL_SIZES.length-1], DEFAULT_PANEL_SIZES[0]); @@ -513,36 +687,35 @@ const Settings = new Lang.Class({ })); //multi-monitor - let monitors = [-1]; + + for (let i = 0; i < this.monitors.length; ++i) { + //the primary index is the first one in the "available-monitors" setting + let label = !i ? _('Primary monitor') : _('Monitor ') + (i + 1); - this._builder.get_object('multimon_primary_combo').append_text(_('Default (Primary monitor)')); - - for (let i = 0, monitorNum = Gdk.Screen.get_default().get_n_monitors(); i < monitorNum; ++i) { - this._builder.get_object('multimon_primary_combo').append_text(_('Monitor ') + (i+1)); - monitors.push(i); + this._builder.get_object('multimon_primary_combo').append_text(label); + this._builder.get_object('taskbar_position_monitor_combo').append_text(label); } - this._builder.get_object('multimon_primary_combo').set_active(monitors.indexOf(this._settings.get_int('primary-monitor'))); + this._builder.get_object('multimon_primary_combo').set_active(this.monitors.indexOf(this._settings.get_int('primary-monitor'))); + this._builder.get_object('taskbar_position_monitor_combo').set_active(this.monitors.indexOf(this._settings.get_int('primary-monitor'))); + this._builder.get_object('multimon_primary_combo').connect('changed', Lang.bind (this, function(widget) { - this._settings.set_int('primary-monitor', monitors[widget.get_active()]); + this._settings.set_int('primary-monitor', this.monitors[widget.get_active()]); })); + this._builder.get_object('taskbar_position_monitor_combo').connect('changed', Lang.bind (this, function(widget) { + this._displayTaskbarElementPositionsForMonitor(this.monitors[widget.get_active()]); + })); + + //taskbar element positions + this._displayTaskbarElementPositionsForMonitor(this.monitors[this._builder.get_object('multimon_primary_combo').get_active()]); + this._settings.bind('multi-monitors', this._builder.get_object('multimon_multi_switch'), 'active', Gio.SettingsBindFlags.DEFAULT); - this._settings.bind('show-clock-all-monitors', - this._builder.get_object('multimon_multi_show_clock_switch'), - 'active', - Gio.SettingsBindFlags.DEFAULT); - - this._settings.bind('show-status-menu-all-monitors', - this._builder.get_object('multimon_multi_show_status_menu_switch'), - 'active', - Gio.SettingsBindFlags.DEFAULT); - - if (monitors.length === 1) { + if (this.monitors.length === 1) { this._builder.get_object('multimon_multi_switch').set_active(false); } @@ -835,102 +1008,20 @@ const Settings = new Lang.Class({ // Behavior panel - this._settings.bind('show-show-apps-button', - this._builder.get_object('show_applications_button_switch'), - 'active', - Gio.SettingsBindFlags.DEFAULT); - - this._settings.bind('show-show-apps-button', - this._builder.get_object('show_application_options_button'), - 'sensitive', - Gio.SettingsBindFlags.DEFAULT); - this._builder.get_object('show_applications_side_padding_spinbutton').set_value(this._settings.get_int('show-apps-icon-side-padding')); this._builder.get_object('show_applications_side_padding_spinbutton').connect('value-changed', Lang.bind (this, function(widget) { this._settings.set_int('show-apps-icon-side-padding', widget.get_value()); })); - this._builder.get_object('show_application_options_button').connect('clicked', Lang.bind(this, function() { - let dialog = new Gtk.Dialog({ title: _('Show Applications options'), - transient_for: this.widget.get_toplevel(), - use_header_bar: true, - modal: true }); - - // GTK+ leaves positive values for application-defined response ids. - // Use +1 for the reset action - dialog.add_button(_('Reset to defaults'), 1); - - let box = this._builder.get_object('show_applications_options'); - dialog.get_content_area().add(box); - - let fileChooser = this._builder.get_object('show_applications_icon_file_filebutton'); - let fileImage = this._builder.get_object('show_applications_current_icon_image'); - let fileFilter = new Gtk.FileFilter(); - let handleIconChange = function(newIconPath) { - if (newIconPath && GLib.file_test(newIconPath, GLib.FileTest.EXISTS)) { - let file = Gio.File.new_for_path(newIconPath) - let pixbuf = GdkPixbuf.Pixbuf.new_from_stream_at_scale(file.read(null), 32, 32, true, null); - - fileImage.set_from_pixbuf(pixbuf); - fileChooser.set_filename(newIconPath); - } else { - newIconPath = ''; - fileImage.set_from_icon_name('view-app-grid-symbolic', 32); - fileChooser.unselect_all(); - fileChooser.set_current_folder(GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES)); - } - - this._settings.set_string('show-apps-icon-file', newIconPath || ''); - }; - - fileFilter.add_pixbuf_formats(); - fileChooser.filter = fileFilter; - - fileChooser.connect('file-set', widget => handleIconChange.call(this, widget.get_filename())); - handleIconChange.call(this, this._settings.get_string('show-apps-icon-file')); - - dialog.connect('response', Lang.bind(this, function(dialog, id) { - if (id == 1) { - // restore default settings - this._settings.set_value('show-apps-icon-side-padding', this._settings.get_default_value('show-apps-icon-side-padding')); - this._builder.get_object('show_applications_side_padding_spinbutton').set_value(this._settings.get_int('show-apps-icon-side-padding')); - this._settings.set_value('show-apps-override-escape', this._settings.get_default_value('show-apps-override-escape')); - handleIconChange.call(this, null); - } else { - // remove the settings box so it doesn't get destroyed; - dialog.get_content_area().remove(box); - dialog.destroy(); - } - return; - })); - - dialog.show_all(); - })); - this._settings.bind('animate-show-apps', - this._builder.get_object('application_button_animation_button'), + this._builder.get_object('application_button_animation_switch'), 'active', Gio.SettingsBindFlags.DEFAULT); - this._settings.bind('show-show-apps-button', - this._builder.get_object('application_button_animation_button'), - 'sensitive', - Gio.SettingsBindFlags.DEFAULT); + this._settings.bind('show-apps-override-escape', this._builder.get_object('show_applications_esc_key_switch'), 'active', Gio.SettingsBindFlags.DEFAULT); - this._settings.bind('show-activities-button', - this._builder.get_object('show_activities_button_switch'), - 'active', - Gio.SettingsBindFlags.DEFAULT); - this._settings.bind('show-showdesktop-button', - this._builder.get_object('show_showdesktop_button_switch'), - 'active', - Gio.SettingsBindFlags.DEFAULT); - this._settings.bind('show-showdesktop-button', - this._builder.get_object('show_showdesktop_options_button'), - 'sensitive', - Gio.SettingsBindFlags.DEFAULT); this._settings.bind('show-showdesktop-hover', this._builder.get_object('show_showdesktop_hide_switch'), @@ -942,59 +1033,6 @@ const Settings = new Lang.Class({ 'sensitive', Gio.SettingsBindFlags.DEFAULT); - this._builder.get_object('show_showdesktop_options_button').connect('clicked', Lang.bind(this, function() { - - let dialog = new Gtk.Dialog({ title: _('Show Desktop options'), - transient_for: this.widget.get_toplevel(), - use_header_bar: true, - modal: true }); - - // GTK+ leaves positive values for application-defined response ids. - // Use +1 for the reset action - dialog.add_button(_('Reset to defaults'), 1); - - let box = this._builder.get_object('box_show_showdesktop_options'); - dialog.get_content_area().add(box); - - this._builder.get_object('show_showdesktop_width_spinbutton').set_value(this._settings.get_int('showdesktop-button-width')); - this._builder.get_object('show_showdesktop_width_spinbutton').connect('value-changed', Lang.bind (this, function(widget) { - this._settings.set_int('showdesktop-button-width', widget.get_value()); - })); - - this._builder.get_object('show_showdesktop_delay_spinbutton').set_value(this._settings.get_int('show-showdesktop-delay')); - this._builder.get_object('show_showdesktop_delay_spinbutton').connect('value-changed', Lang.bind (this, function(widget) { - this._settings.set_int('show-showdesktop-delay', widget.get_value()); - })); - - this._builder.get_object('show_showdesktop_time_spinbutton').set_value(this._settings.get_int('show-showdesktop-time')); - this._builder.get_object('show_showdesktop_time_spinbutton').connect('value-changed', Lang.bind (this, function(widget) { - this._settings.set_int('show-showdesktop-time', widget.get_value()); - })); - - dialog.connect('response', Lang.bind(this, function(dialog, id) { - if (id == 1) { - // restore default settings - this._settings.set_value('showdesktop-button-width', this._settings.get_default_value('showdesktop-button-width')); - this._builder.get_object('show_showdesktop_width_spinbutton').set_value(this._settings.get_int('showdesktop-button-width')); - - this._settings.set_value('show-showdesktop-hover', this._settings.get_default_value('show-showdesktop-hover')); - - this._settings.set_value('show-showdesktop-delay', this._settings.get_default_value('show-showdesktop-delay')); - this._builder.get_object('show_showdesktop_delay_spinbutton').set_value(this._settings.get_int('show-showdesktop-delay')); - - this._settings.set_value('show-showdesktop-time', this._settings.get_default_value('show-showdesktop-time')); - this._builder.get_object('show_showdesktop_time_spinbutton').set_value(this._settings.get_int('show-showdesktop-time')); - } else { - // remove the settings box so it doesn't get destroyed; - dialog.get_content_area().remove(box); - dialog.destroy(); - } - return; - })); - - dialog.show_all(); - })); - this._settings.bind('show-appmenu', this._builder.get_object('show_appmenu_switch'), 'active', @@ -1750,20 +1788,10 @@ const Settings = new Lang.Class({ } }; - var setGsStockPanelOptions = () => { - let keepTopPanel = this._settings.get_boolean('stockgs-keep-top-panel'); - - this._builder.get_object('stockgs_top_panel_description')[keepTopPanel ? 'show' : 'hide'](); - this._builder.get_object('multimon_multi_show_clock_label').set_text(keepTopPanel ? _('Display the clock on additional panels') : _('Display the clock on secondary panels')); - this._builder.get_object('multimon_multi_show_status_menu_label').set_text(keepTopPanel ? _('Display the status menu on additional panels') : _('Display the status menu on secondary panels')); - }; - this._settings.connect('changed::stockgs-keep-top-panel', () => { - setGsStockPanelOptions(); maybeDisableTopPosition(); }); - setGsStockPanelOptions(); maybeDisableTopPosition(); this._settings.bind('stockgs-panelbtn-click-only', diff --git a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml index 1b80e40..64abeeb 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml @@ -25,21 +25,6 @@ - - - - - - - - - - - - - - - @@ -87,6 +72,11 @@ Panel position Panel is shown on the Bottom or Top of the screen. + + '{}' + Panel element positions + Panel element positions (JSON). + 48 Panel size @@ -207,16 +197,6 @@ Force hot corner Wheter to force having an Activities hot corner on the primary monitor - - 'STATUSLEFT' - Location of the clock - Set the location of the clock on the taskbar - - - 'LEFTPANEL' - Position of the taskbar - Set the position of the taskbar on the panel - false Lock the taskbar @@ -583,30 +563,25 @@ When the applications are ungrouped, this defines if running applications stay separate from the favorite icons. - -1 + 0 Primary monitor index - Specifies the index of the primary monitor (-1 = GNOME Primary Monitor). + Specifies the index of the primary monitor. true Display panels on all monitors Specifies if a panel is shown on every monitors + + [] + Available monitors + Available gnome-shell (Mutter) monitors, internal use + false Provide monitor isolation Dash shows only windows from the current monitor - - true - Display the clock on all monitors - Specifies if every panel should display the clock. If false, the clock is only displayed on the primary monitor. - - - true - Display the status menu on all monitors - Specifies if every panel should display the status menu. If false, the status menu is only displayed on the primary monitor. - true Display the favorites on all monitors diff --git a/stylesheet.css b/stylesheet.css index 66b2384..1f23906 100644 --- a/stylesheet.css +++ b/stylesheet.css @@ -27,7 +27,7 @@ } #dashtopanelScrollview .app-well-app .overview-icon, -#dashtopanelTaskbar .show-apps .overview-icon { +.dashtopanelMainPanel .show-apps .overview-icon { border: none; margin: 0; padding: 0; diff --git a/taskbar.js b/taskbar.js index 1f829c3..f54b89d 100644 --- a/taskbar.js +++ b/taskbar.js @@ -89,21 +89,16 @@ var taskbarActor = Utils.defineClass({ let availFixedSize = box[Panel.fixedCoord.c2] - box[Panel.fixedCoord.c1]; let availVarSize = box[Panel.varCoord.c2] - box[Panel.varCoord.c1]; - let [, showAppsButton, scrollview, leftFade, rightFade] = this.get_children(); - let [, showAppsNatSize] = showAppsButton[Panel.sizeFunc](availFixedSize); + let [, scrollview, leftFade, rightFade] = this.get_children(); let [, natSize] = this[Panel.sizeFunc](availFixedSize); let childBox = new Clutter.ActorBox(); let orientation = Panel.getOrientation(); childBox[Panel.varCoord.c1] = box[Panel.varCoord.c1]; - childBox[Panel.fixedCoord.c1] = box[Panel.fixedCoord.c1]; - - childBox[Panel.varCoord.c2] = box[Panel.varCoord.c1] + showAppsNatSize; - childBox[Panel.fixedCoord.c2] = box[Panel.fixedCoord.c2]; - showAppsButton.allocate(childBox, flags); - - childBox[Panel.varCoord.c1] = box[Panel.varCoord.c1] + showAppsNatSize; childBox[Panel.varCoord.c2] = Math.min(availVarSize, natSize); + childBox[Panel.fixedCoord.c1] = box[Panel.fixedCoord.c1]; + childBox[Panel.fixedCoord.c2] = box[Panel.fixedCoord.c2]; + scrollview.allocate(childBox, flags); let [value, , upper, , , pageSize] = scrollview[orientation[0] + 'scroll'].adjustment.get_values(); @@ -119,7 +114,6 @@ var taskbarActor = Utils.defineClass({ rightFade.set_style(gradientStyle); } - childBox[Panel.varCoord.c1] = box[Panel.varCoord.c1] + showAppsNatSize; childBox[Panel.varCoord.c2] = childBox[Panel.varCoord.c1] + (value > 0 ? scrollview._dtpFadeSize : 0); leftFade.allocate(childBox, flags); @@ -193,8 +187,7 @@ var taskbar = Utils.defineClass({ this._scrollView.connect('scroll-event', Lang.bind(this, this._onScrollEvent )); 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._showAppsIconWrapper = panel.showAppsIconWrapper; this._showAppsIconWrapper.connect('menu-state-changed', Lang.bind(this, function(showAppsIconWrapper, opened) { this._itemMenuStateChanged(showAppsIconWrapper, opened); })); @@ -215,7 +208,6 @@ var taskbar = Utils.defineClass({ this._hookUpLabel(this._showAppsIcon, this._showAppsIconWrapper); this._container.add_child(new St.Widget({ width: 0, reactive: false })); - this._container.add_actor(this._showAppsIcon); this._container.add_actor(this._scrollView); let orientation = Panel.getOrientation(); @@ -358,7 +350,10 @@ var taskbar = Utils.defineClass({ ], [ adjustment, - 'notify::upper', + [ + 'notify::upper', + 'notify::pageSize' + ], () => { // Update minimization animation target position on scrollview change. this._updateAppIcons(); @@ -392,7 +387,6 @@ var taskbar = Utils.defineClass({ destroy: function() { this._signalsHandler.destroy(); this._signalsHandler = 0; - this._showAppsIconWrapper.destroy(); this._container.destroy(); @@ -896,7 +890,7 @@ var taskbar = Utils.defineClass({ }, // Reset the displayed apps icon to mantain the correct order - resetAppIcons : function() { + resetAppIcons : function(geometryChange) { let children = this._getTaskbarIcons(true); for (let i = 0; i < children.length; i++) { @@ -908,8 +902,7 @@ var taskbar = Utils.defineClass({ this._shownInitially = false; this._redisplay(); - if (Panel.checkIfVertical()) { - this.showAppsButton.set_width(this.dtpPanel.geom.w); + if (geometryChange && Panel.checkIfVertical()) { this.previewMenu._updateClip(); } },