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 630ac15..6351567 100644 --- a/Settings.ui +++ b/Settings.ui @@ -1,18 +1,18 @@ - + - 0.33000000000000002 + 0.33 1 0.01 - 0.10000000000000001 + 0.1 - 0.33000000000000002 + 0.33 1 0.01 - 0.10000000000000001 + 0.1 True @@ -2036,22 +2036,22 @@ 100 - 0.33000000000000002 + 0.33 1 0.01 - 0.10000000000000001 + 0.1 - 0.33000000000000002 + 0.33 1 0.01 - 0.10000000000000001 + 0.1 - 0.33000000000000002 + 0.33 1 0.01 - 0.10000000000000001 + 0.1 255 @@ -3825,6 +3825,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 @@ -4021,10 +4069,10 @@ - 0.33000000000000002 + 0.33 1 0.01 - 0.10000000000000001 + 0.1 2000 @@ -4260,16 +4308,16 @@ - 0.33000000000000002 + 0.33 1 0.01 - 0.10000000000000001 + 0.1 - 0.33000000000000002 + 0.33 1 0.01 - 0.10000000000000001 + 0.1 True @@ -4284,260 +4332,6 @@ 24 vertical 24 - - - True - False - 0 - in - - - True - False - none - - - 100 - True - True - - - True - False - 12 - 12 - 12 - 12 - 32 - - - True - False - True - Panel screen position - 0 - - - False - True - 0 - - - - - True - False - 32 - - - Bottom - True - True - False - center - center - 0 - True - True - - - - False - True - 0 - - - - - Top - True - True - False - center - center - 0 - bottom - True - position_bottom_button - - - - False - True - 1 - - - - - Left - True - True - False - center - center - 0 - bottom - True - position_bottom_button - - - - False - True - 2 - - - - - Right - True - True - False - center - center - 0 - bottom - True - position_bottom_button - - - - False - True - 3 - - - - - False - True - 1 - - - - - - - - - - - - - - False - True - 0 - - - - - True - False - 0 - in - - - True - False - none - - - 100 - True - True - - - True - False - 12 - 12 - 12 - 12 - 32 - 32 - - - True - False - True - Taskbar position - 0 - - - 0 - 0 - - - - - True - False - center - - - 1 - 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 - True - 2 - - True @@ -4631,79 +4425,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 - - - - - @@ -4717,7 +4438,7 @@ False True - 3 + 0 @@ -4840,7 +4561,218 @@ False True - 4 + 1 + + + + + True + False + 0 + in + + + True + False + vertical + + + True + False + 12 + 12 + 12 + 12 + + + True + False + True + Order and positions on monitor + 0 + + + 0 + 0 + + + + + True + False + center + + + 1 + 0 + + + + + Apply changes to all monitors + True + True + False + 12 + True + + + 0 + 1 + + + + + True + False + 18 + 6 + 32 + + + True + False + True + Panel screen position + 0 + + + False + True + 0 + + + + + True + False + 32 + + + Bottom + True + True + False + center + center + 0 + True + True + + + + False + True + 0 + + + + + Top + True + True + False + center + center + 0 + bottom + True + position_bottom_button + + + + False + True + 1 + + + + + Left + True + True + False + center + center + 0 + bottom + True + position_bottom_button + + + + False + True + 2 + + + + + Right + True + True + False + center + center + 0 + bottom + True + position_bottom_button + + + + False + True + 3 + + + + + False + True + 1 + + + + + 0 + 2 + 2 + + + + + + + + False + True + 0 + + + + + True + False + 6 + none + + + False + True + 1 + + + + + + + + + + False + True + 2 @@ -5890,238 +5822,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/appIcons.js b/appIcons.js index 42565d3..99514d8 100644 --- a/appIcons.js +++ b/appIcons.js @@ -150,7 +150,7 @@ var taskbarAppIcon = Utils.defineClass({ this._container = new St.Widget({ style_class: 'dtp-container', layout_manager: new Clutter.BinLayout() }); this._dotsContainer = new St.Widget({ layout_manager: new Clutter.BinLayout() }); - this._dtpIconContainer = new St.Widget({ layout_manager: new Clutter.BinLayout(), style: getIconContainerStyle() }); + this._dtpIconContainer = new St.Widget({ layout_manager: new Clutter.BinLayout(), style: this.getIconContainerStyle() }); this.actor.remove_actor(this._iconContainer); @@ -181,7 +181,7 @@ var taskbarAppIcon = Utils.defineClass({ this._container.add_child(this._dotsContainer); this.actor.set_child(this._container); - if (Panel.checkIfVertical()) { + if (panel.checkIfVertical()) { this.actor.set_width(panel.geom.w); } @@ -482,7 +482,7 @@ var taskbarAppIcon = Utils.defineClass({ _updateWindowTitleStyle: function() { if (this._windowTitle) { let useFixedWidth = Me.settings.get_boolean('group-apps-use-fixed-width'); - let variableWidth = !useFixedWidth || Panel.checkIfVertical() || this.dtpPanel.taskbar.fullScrollView; + let variableWidth = !useFixedWidth || this.dtpPanel.checkIfVertical() || this.dtpPanel.taskbar.fullScrollView; let fontWeight = Me.settings.get_string('group-apps-label-font-weight'); let fontScale = Me.desktopSettings.get_double('text-scaling-factor'); let fontColor = this.window.minimized ? @@ -537,7 +537,7 @@ var taskbarAppIcon = Utils.defineClass({ let bgSvg = '/img/highlight_stacked_bg'; if (pos == DOT_POSITION.LEFT || pos == DOT_POSITION.RIGHT) { - bgSvg += (Panel.checkIfVertical() ? '_2' : '_3'); + bgSvg += (this.dtpPanel.checkIfVertical() ? '_2' : '_3'); } inlineStyle += "background-image: url('" + Me.path + bgSvg + ".svg');" + @@ -576,7 +576,7 @@ var taskbarAppIcon = Utils.defineClass({ let padding = getIconPadding(); let margin = Me.settings.get_int('appicon-margin'); - this.actor.set_style('padding:' + (Panel.checkIfVertical() ? margin + 'px 0' : '0 ' + margin + 'px;')); + this.actor.set_style('padding:' + (this.dtpPanel.checkIfVertical() ? margin + 'px 0' : '0 ' + margin + 'px;')); this._iconContainer.set_style('padding: ' + padding + 'px;'); }, @@ -589,7 +589,7 @@ var taskbarAppIcon = Utils.defineClass({ } if (!this._menu) { - this._menu = new taskbarSecondaryMenu(this); + this._menu = new taskbarSecondaryMenu(this, this.dtpPanel); this._menu.connect('activate-window', Lang.bind(this, function (menu, window) { this.activateWindow(window, Me.settings); })); @@ -1224,24 +1224,23 @@ var taskbarAppIcon = Utils.defineClass({ getAppIconInterestingWindows: function(isolateMonitors) { return getInterestingWindows(this.app, this.dtpPanel.monitor, isolateMonitors); - } + }, + getIconContainerStyle: function() { + let style = 'padding: '; + let isVertical = this.dtpPanel.checkIfVertical(); + + if (Me.settings.get_boolean('group-apps')) { + style += (isVertical ? '0;' : '0 ' + DEFAULT_PADDING_SIZE + 'px;'); + } else { + style += (isVertical ? '' : '0 ') + DEFAULT_PADDING_SIZE + 'px;'; + } + + return style; + } }); taskbarAppIcon.prototype.scaleAndFade = taskbarAppIcon.prototype.undoScaleAndFade = () => {}; -function getIconContainerStyle() { - let style = 'padding: '; - let isVertical = Panel.checkIfVertical(); - - if (Me.settings.get_boolean('group-apps')) { - style += (isVertical ? '0;' : '0 ' + DEFAULT_PADDING_SIZE + 'px;'); - } else { - style += (isVertical ? '' : '0 ') + DEFAULT_PADDING_SIZE + 'px;'; - } - - return style; -} - function minimizeWindow(app, param, monitor){ // Param true make all app windows minimize let windows = getInterestingWindows(app, monitor); @@ -1404,13 +1403,13 @@ var taskbarSecondaryMenu = Utils.defineClass({ Extends: AppDisplay.AppIconMenu, ParentConstrParams: [[0]], - _init: function(source) { + _init: function(source, panel) { // Damm it, there has to be a proper way of doing this... // As I can't call the parent parent constructor (?) passing the side // parameter, I overwite what I need later this.callParent('_init', source); - let side = Panel.getPosition(); + let side = panel.getPosition(); // Change the initialized side where required. this._arrowSide = side; this._boxPointer._arrowSide = side; @@ -1545,7 +1544,7 @@ function ItemShowLabel() { let labelWidth = this.label.get_width(); let labelHeight = this.label.get_height(); - let position = Panel.getPosition(); + let position = this._dtpPanel.getPosition(); let labelOffset = node.get_length('-x-offset'); let xOffset = Math.floor((itemWidth - labelWidth) / 2); @@ -1608,7 +1607,7 @@ function ItemShowLabel() { var ShowAppsIconWrapper = Utils.defineClass({ Name: 'DashToPanel.ShowAppsIconWrapper', - _init: function() { + _init: function(dtpPanel) { this.realShowAppsIcon = new Dash.ShowAppsIcon(); Utils.wrapActor(this.realShowAppsIcon); @@ -1639,6 +1638,7 @@ var ShowAppsIconWrapper = Utils.defineClass({ this._menuManager = new PopupMenu.PopupMenuManager(this.actor); this._menuTimeoutId = 0; + this.realShowAppsIcon._dtpPanel = dtpPanel; Taskbar.extendDashItemContainer(this.realShowAppsIcon); let customIconPath = Me.settings.get_string('show-apps-icon-file'); @@ -1699,14 +1699,14 @@ var ShowAppsIconWrapper = Utils.defineClass({ setShowAppsPadding: function() { let padding = getIconPadding(); let sidePadding = Me.settings.get_int('show-apps-icon-side-padding'); - let isVertical = Panel.checkIfVertical(); + let isVertical = this.realShowAppsIcon._dtpPanel.checkIfVertical(); this.actor.set_style('padding:' + (padding + (isVertical ? sidePadding : 0)) + 'px ' + (padding + (isVertical ? 0 : sidePadding)) + 'px;'); }, createMenu: function() { if (!this._menu) { - this._menu = new MyShowAppsIconMenu(this.actor); + this._menu = new MyShowAppsIconMenu(this.actor, this.realShowAppsIcon._dtpPanel); this._menu.connect('open-state-changed', Lang.bind(this, function(menu, isPoppedUp) { if (!isPoppedUp) this._onMenuPoppedDown(); @@ -1755,7 +1755,7 @@ Signals.addSignalMethods(ShowAppsIconWrapper.prototype); var MyShowAppsIconMenu = Utils.defineClass({ Name: 'DashToPanel.ShowAppsIconMenu', Extends: taskbarSecondaryMenu, - ParentConstrParams: [[0]], + ParentConstrParams: [[0], [1]], _dtpRedisplay: function() { this.removeAll(); diff --git a/intellihide.js b/intellihide.js index c4c9c97..7673b43 100644 --- a/intellihide.js +++ b/intellihide.js @@ -21,7 +21,7 @@ const Meta = imports.gi.Meta; const Shell = imports.gi.Shell; const St = imports.gi.St; -const GrabHelper = imports.ui.grabHelper; +var GrabHelper = imports.ui.grabHelper; const Layout = imports.ui.layout; const Main = imports.ui.main; const OverviewControls = imports.ui.overviewControls; @@ -79,7 +79,7 @@ var Intellihide = Utils.defineClass({ this._pendingUpdate = false; this._hoveredOut = false; this._windowOverlap = false; - this._translationProp = 'translation_' + (Panel.checkIfVertical() ? 'x' : 'y'); + this._translationProp = 'translation_' + (this._dtpPanel.checkIfVertical() ? 'x' : 'y'); this._panelBox.translation_y = 0; this._panelBox.translation_x = 0; @@ -251,7 +251,7 @@ var Intellihide = Utils.defineClass({ let position = this._dtpPanel.geom.position; let opts = { display: global.display }; - if (Panel.checkIfVertical()) { + if (this._dtpPanel.checkIfVertical()) { opts.y1 = this._monitor.y; opts.y2 = this._monitor.y + this._monitor.height; opts.x1 = opts.x2 = this._monitor.x; diff --git a/media/sources/D2P_import settings/Artist_design b/media/sources/D2P_import settings/Artist_design index 55638e2..edd39b7 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 @@ -72,7 +71,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 fc923a7..da54ec9 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 @@ -72,7 +71,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 06fb023..b4576a5 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 @@ -72,7 +71,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 6b7e3fe..edc1809 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 @@ -72,7 +71,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 6d00a91..7af0543 100644 --- a/media/sources/D2P_import settings/Mountain_intellihide +++ b/media/sources/D2P_import settings/Mountain_intellihide @@ -46,7 +46,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'] @@ -104,7 +103,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'] @@ -165,7 +163,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 b396b33..dc85636 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 @@ -72,7 +71,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 351d5b3..9b06201 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 @@ -72,7 +71,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 482d2d2..e040070 100644 --- a/media/sources/D2P_import settings/Wolf_programmer +++ b/media/sources/D2P_import settings/Wolf_programmer @@ -46,7 +46,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'] @@ -104,7 +103,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/panel.js b/panel.js index 5ded78e..37c4b9a 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; @@ -61,10 +62,6 @@ const _ = imports.gettext.domain(Me.imports.utils.TRANSLATION_DOMAIN).gettext; let tracker = Shell.WindowTracker.get_default(); var panelBoxes = ['_leftBox', '_centerBox', '_rightBox']; -var sizeFunc; -var fixedCoord; -var varCoord; -var size; //timeout names const T1 = 'startDynamicTransparencyTimeout'; @@ -75,30 +72,6 @@ const T5 = 'trackerFocusAppTimeout'; const T6 = 'scrollPanelDelayTimeout'; const T7 = 'waitPanelBoxAllocation'; -function getPosition() { - let position = Me.settings.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 St.Side.LEFT; -} - -function checkIfVertical() { - let position = getPosition(); - - return (position == St.Side.LEFT || position == St.Side.RIGHT); -} - -function getOrientation() { - return (checkIfVertical() ? 'vertical' : 'horizontal'); -} - function setMenuArrow(arrowIcon, side) { let parent = arrowIcon.get_parent(); let iconNames = { @@ -118,8 +91,6 @@ var dtpPanel = Utils.defineClass({ Extends: St.Widget, _init: function(panelManager, monitor, panelBox, isStandalone) { - let position = getPosition(); - this.callParent('_init', { layout_manager: new Clutter.BinLayout() }); this._timeoutsHandler = new Utils.TimeoutsHandler(); @@ -140,10 +111,13 @@ var dtpPanel = Utils.defineClass({ this._sessionStyle = null; this._unmappedButtons = []; + this._elementGroups = []; this.cornerSize = 0; + let position = this.getPosition(); + if (isStandalone) { - this.panel = new St.Widget({ name: 'panel', reactive: true }); + this.panel = new dtpSecondaryPanel({ name: 'panel', reactive: true }); this.statusArea = this.panel.statusArea = {}; Utils.wrapActor(this.panel); @@ -167,9 +141,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 +160,38 @@ 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); + 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); + Utils.wrapActor(this.statusArea.activities); + 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.add_child(this.panel.actor); if (Main.panel._onButtonPress || Main.panel._tryDragWindow) { @@ -226,14 +214,7 @@ 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; - } + let position = this.getPosition(); if (this.statusArea.aggregateMenu) { Utils.getIndicators(this.statusArea.aggregateMenu._volume)._dtpIgnoreScroll = 1; @@ -322,16 +303,14 @@ 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._setRightCornerStyle(); - - this.panel.actor.add_style_class_name('dashtopanelMainPanel ' + getOrientation()); + this._setAllocationMap(); + + this.panel.actor.add_style_class_name('dashtopanelMainPanel ' + this.getOrientation()); // Since Gnome 3.8 dragging an app without having opened the overview before cause the attemp to //animate a null target since some variables are not initialized when the viewSelector is created @@ -340,9 +319,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 +332,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, @@ -366,6 +342,26 @@ var dtpPanel = Utils.defineClass({ ], () => this._adjustForOverview() ], + [ + Main.overview, + 'hidden', + () => { + if (this.isPrimary) { + //reset the primary monitor when exiting the overview + this.panelManager.setFocusedMonitor(this.monitor, true); + } + } + ], + [ + this.statusArea.activities.actor, + 'captured-event', + (actor, e) => { + if (e.type() == Clutter.EventType.BUTTON_PRESS || e.type() == Clutter.EventType.TOUCH_BEGIN) { + //temporarily use as primary the monitor on which the activities btn was clicked + this.panelManager.setFocusedMonitor(this.monitor, true); + } + } + ], [ this._centerBox, 'actor-added', @@ -392,7 +388,7 @@ var dtpPanel = Utils.defineClass({ this.panelStyle.enable(this); - if (checkIfVertical()) { + if (this.checkIfVertical()) { this._signalsHandler.add([ this.panelBox, 'notify::visible', @@ -429,7 +425,9 @@ var dtpPanel = Utils.defineClass({ this._timeoutsHandler.destroy(); this._signalsHandler.destroy(); - this.container.remove_child(this.taskbar.actor); + this._disablePanelCornerSignals(); + + this.panel.actor.remove_child(this.taskbar.actor); this._setAppmenuVisible(false); if (this.intellihide) { @@ -441,6 +439,7 @@ var dtpPanel = Utils.defineClass({ this.progressManager.destroy(); this.taskbar.destroy(); + this.showAppsIconWrapper.destroy(); this.menuManager._changeMenu = this.menuManager._oldChangeMenu; @@ -463,10 +462,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.actor.remove_child(this.statusArea.activities.container); + this._leftBox.insert_child_at_index(this.statusArea.activities.container, 0); + this.panel.actor.remove_child(this.statusArea.dateMenu.container); + this._centerBox.insert_child_at_index(this.statusArea.dateMenu.container, 0); + + this.panel.actor.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,10 +482,7 @@ var dtpPanel = Utils.defineClass({ } } - this._displayShowDesktopButton(false); - - this._toggleCornerStyle(this.panel._leftCorner, true); - this._toggleCornerStyle(this.panel._rightCorner, true); + this._setShowDesktopButton(false); delete Utils.getIndicators(this.statusArea.aggregateMenu._volume)._dtpIgnoreScroll; setMenuArrow(this.statusArea.aggregateMenu._indicators.get_last_child(), St.Side.TOP); @@ -500,10 +502,7 @@ var dtpPanel = Utils.defineClass({ } else { this._removePanelMenu('dateMenu'); this._removePanelMenu('aggregateMenu'); - - if (this.panel._rightCorner && this.panel._rightCorner._buttonStyleChangedSignalId) { - this.panel._rightCorner._button.disconnect(this.panel._rightCorner._buttonStyleChangedSignalId); - } + this._removePanelMenu('activities'); } Main.ctrlAltTabManager.removeGroup(this); @@ -521,8 +520,124 @@ var dtpPanel = Utils.defineClass({ return DND.DragMotionResult.CONTINUE; }, + getPosition: function() { + //for now, use the previous "global" position setting as default. The 'panel-position' should be deleted in the future + let position = this.panelManager.panelPositions[this.monitor.index] || Me.settings.get_string('panel-position'); + + if (position == Pos.TOP) { + return St.Side.TOP; + } else if (position == Pos.RIGHT) { + return St.Side.RIGHT; + } else if (position == Pos.BOTTOM) { + return St.Side.BOTTOM; + } + + return St.Side.LEFT; + }, + + checkIfVertical: function() { + let position = this.getPosition(); + + return (position == St.Side.LEFT || position == St.Side.RIGHT); + }, + + getOrientation: function() { + return (this.checkIfVertical() ? 'vertical' : 'horizontal'); + }, + + updateElementPositions: function() { + let panelPositions = this.panelManager.panelsElementPositions[this.monitor.index] || Pos.defaults; + + this._updateGroupedElements(panelPositions); + + this._disablePanelCornerSignals(); + + if (this.getPosition() == St.Side.TOP) { + let visibleElements = panelPositions.filter(pp => pp.visible); + let connectCorner = (corner, button) => { + corner._button = button; + corner._buttonStyleChangedSignalId = button.connect('style-changed', () => { + corner.set_style_pseudo_class(button.get_style_pseudo_class()); + }); + } + + if (visibleElements[0].element == Pos.ACTIVITIES_BTN) { + connectCorner(this.panel._leftCorner, this.statusArea.activities); + } + + if (visibleElements[visibleElements.length - 1].element == Pos.SYSTEM_MENU) { + connectCorner(this.panel._rightCorner, this.statusArea.aggregateMenu); + } + } + + this.panel.actor.hide(); + this.panel.actor.show(); + }, + + _updateGroupedElements: function(panelPositions) { + let previousPosition = 0; + let previousCenteredPosition = 0; + let currentGroup = -1; + + this._elementGroups = []; + + panelPositions.forEach(pos => { + let allocationMap = this.allocationMap[pos.element]; + + if (allocationMap.actor) { + allocationMap.actor.visible = pos.visible; + + if (!pos.visible) { + return; + } + + let currentPosition = pos.position; + let isCentered = Pos.checkIfCentered(currentPosition); + + if (currentPosition == Pos.STACKED_TL && previousPosition == Pos.STACKED_BR) { + currentPosition = Pos.STACKED_BR; + } + + if (!previousPosition || + (previousPosition == Pos.STACKED_TL && currentPosition != Pos.STACKED_TL) || + (previousPosition != Pos.STACKED_BR && currentPosition == Pos.STACKED_BR) || + (isCentered && previousPosition != currentPosition && previousPosition != Pos.STACKED_BR)) { + this._elementGroups[++currentGroup] = { elements: [], index: this._elementGroups.length, expandableIndex: -1 }; + previousCenteredPosition = 0; + } + + if (pos.element == Pos.TASKBAR) { + this._elementGroups[currentGroup].expandableIndex = this._elementGroups[currentGroup].elements.length; + } + + if (isCentered && !this._elementGroups[currentGroup].isCentered) { + this._elementGroups[currentGroup].isCentered = 1; + previousCenteredPosition = currentPosition; + } + + this._elementGroups[currentGroup].position = previousCenteredPosition || currentPosition; + this._elementGroups[currentGroup].elements.push(allocationMap); + + allocationMap.position = currentPosition; + previousPosition = currentPosition; + } + }); + }, + + _disablePanelCornerSignals: function() { + if (this.panel._rightCorner && this.panel._rightCorner._buttonStyleChangedSignalId) { + this.panel._rightCorner._button.disconnect(this.panel._rightCorner._buttonStyleChangedSignalId); + delete this.panel._rightCorner._buttonStyleChangedSignalId; + } + + if (this.panel._leftCorner && this.panel._leftCorner._buttonStyleChangedSignalId) { + this.panel._leftCorner._button.disconnect(this.panel._leftCorner._buttonStyleChangedSignalId); + delete this.panel._leftCorner._buttonStyleChangedSignalId; + } + }, + _bindSettingsChanges: function() { - let isVertical = checkIfVertical(); + let isVertical = this.checkIfVertical(); this._signalsHandler.add( [ @@ -541,26 +656,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 +694,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); @@ -640,7 +734,7 @@ var dtpPanel = Utils.defineClass({ }, _setPanelGhostSize: function() { - this._myPanelGhost.set_size(this.width, checkIfVertical() ? 1 : this.height); + this._myPanelGhost.set_size(this.width, this.checkIfVertical() ? 1 : this.height); }, _setSearchEntryOffset: function(offset) { @@ -649,7 +743,7 @@ var dtpPanel = Utils.defineClass({ //that doesn't natively take into account the size of a side dock, as it is always //centered relatively to the monitor. This looks misaligned, adjust it here so it //is centered like the rest of the overview elements. - let paddingSide = getPosition() == St.Side.LEFT ? 'left' : 'right'; + let paddingSide = this.getPosition() == St.Side.LEFT ? 'left' : 'right'; let scaleFactor = Utils.getScaleFactor(); let style = offset ? 'padding-' + paddingSide + ':' + (offset / scaleFactor) + 'px;' : null; let searchEntry = Main.overview._searchEntry || Main.overview._overview._searchEntry; @@ -679,14 +773,15 @@ 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) { this.intellihide.reset(); } - if (checkIfVertical()) { + if (this.checkIfVertical()) { + this.showAppsIconWrapper.realShowAppsIcon.toggleButton.set_width(this.geom.w); this._refreshVerticalAlloc(); this._setSearchEntryOffset(this.geom.w); } @@ -698,47 +793,47 @@ var dtpPanel = Utils.defineClass({ let lrPadding = panelBoxTheme.get_padding(St.Side.RIGHT) + panelBoxTheme.get_padding(St.Side.LEFT); let topPadding = panelBoxTheme.get_padding(St.Side.TOP); let tbPadding = topPadding + panelBoxTheme.get_padding(St.Side.BOTTOM); - let position = getPosition(); + let position = this.getPosition(); let gsTopPanelOffset = 0; let x = 0, y = 0; let w = 0, h = 0; - size = Me.settings.get_int('panel-size') * scaleFactor; + this.dtpSize = 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 - topPadding; } - if (checkIfVertical()) { + if (this.checkIfVertical()) { if (!Me.settings.get_boolean('group-apps')) { // add window title width and side padding of _dtpIconContainer when vertical - size += Me.settings.get_int('group-apps-label-max-width') + AppIcons.DEFAULT_PADDING_SIZE * 2 / scaleFactor; + this.dtpSize += Me.settings.get_int('group-apps-label-max-width') + AppIcons.DEFAULT_PADDING_SIZE * 2 / scaleFactor; } - sizeFunc = 'get_preferred_height', - fixedCoord = { c1: 'x1', c2: 'x2' }, - varCoord = { c1: 'y1', c2: 'y2' }; + this.sizeFunc = 'get_preferred_height', + this.fixedCoord = { c1: 'x1', c2: 'x2' }, + this.varCoord = { c1: 'y1', c2: 'y2' }; - w = size; + w = this.dtpSize; h = this.monitor.height - tbPadding - gsTopPanelOffset; } else { - sizeFunc = 'get_preferred_width'; - fixedCoord = { c1: 'y1', c2: 'y2' }; - varCoord = { c1: 'x1', c2: 'x2' }; + this.sizeFunc = 'get_preferred_width'; + this.fixedCoord = { c1: 'y1', c2: 'y2' }; + this.varCoord = { c1: 'x1', c2: 'x2' }; w = this.monitor.width - lrPadding; - h = size; + h = this.dtpSize; } if (position == St.Side.TOP || position == St.Side.LEFT) { x = this.monitor.x; y = this.monitor.y + gsTopPanelOffset; } else if (position == St.Side.RIGHT) { - x = this.monitor.x + this.monitor.width - size - lrPadding; + x = this.monitor.x + this.monitor.width - this.dtpSize - lrPadding; y = this.monitor.y + gsTopPanelOffset; } else { //BOTTOM x = this.monitor.x; - y = this.monitor.y + this.monitor.height - size - tbPadding; + y = this.monitor.y + this.monitor.height - this.dtpSize - tbPadding; } return { @@ -750,102 +845,186 @@ 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(); + let fixed = 0; + let centeredMonitorGroup; + let panelAlloc = new Clutter.ActorBox({ x1: 0, y1: 0, x2: this.geom.w, y2: this.geom.h }); + let assignGroupSize = (group, update) => { + group.size = 0; + group.tlOffset = 0; + group.brOffset = 0; - if (taskbarPosition == 'CENTEREDMONITOR') { - leftAllocSize = leftNaturalSize; + group.elements.forEach(element => { + if (!update) { + element.box[this.fixedCoord.c1] = panelAlloc[this.fixedCoord.c1]; + element.box[this.fixedCoord.c2] = panelAlloc[this.fixedCoord.c2]; + element.natSize = element.actor[this.sizeFunc](-1)[1]; + } - 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; + if (!group.isCentered || Pos.checkIfCentered(element.position)) { + group.size += element.natSize; + } else if (element.position == Pos.STACKED_TL) {  + group.tlOffset += element.natSize; + } else { // Pos.STACKED_BR + group.brOffset += element.natSize; + } + }); - 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); + if (group.isCentered) { + group.size += Math.max(group.tlOffset, group.brOffset) * 2; + group.tlOffset = Math.max(group.tlOffset - group.brOffset, 0); + } + }; + let allocateGroup = (group, tlLimit, brLimit) => { + let startPosition = tlLimit; + let currentPosition = 0; - let freeSpace = panelAllocVarSize - leftAllocSize - rightAllocSize - centerNaturalSize; + if (group.expandableIndex >= 0) { + let availableSize = brLimit - tlLimit; + let expandable = group.elements[group.expandableIndex]; + let i = 0; + let l = this._elementGroups.length; + let tlSize = 0; + let brSize = 0; - centerStartPosition = leftAllocSize + Math.floor(freeSpace / 2); - centerEndPosition = centerStartPosition + centerNaturalSize; - } else { // LEFTPANEL - leftAllocSize = panelAllocVarSize - rightNaturalSize - centerNaturalSize; - centerStartPosition = leftAllocSize; - centerEndPosition = centerStartPosition + centerNaturalSize; + if (centeredMonitorGroup && (centeredMonitorGroup != group || expandable.position != Pos.CENTERED_MONITOR)) { + if (centeredMonitorGroup.index < group.index || (centeredMonitorGroup == group && expandable.position == Pos.STACKED_TL)) { + i = centeredMonitorGroup.index; + } else { + l = centeredMonitorGroup.index; + } + } + + for (; i < l; ++i) { + let refGroup = this._elementGroups[i]; + + if (i < group.index && (!refGroup.fixed || refGroup[this.varCoord.c2] > tlLimit)) { + tlSize += refGroup.size; + } else if (i > group.index && (!refGroup.fixed || refGroup[this.varCoord.c1] < brLimit)) { + brSize += refGroup.size; + } + } + + if (group.isCentered) { + availableSize -= Math.max(tlSize, brSize) * 2; + } else { + availableSize -= tlSize + brSize; + } + + if (availableSize < group.size) { + expandable.natSize -= (group.size - availableSize) * (group.isCentered && !Pos.checkIfCentered(expandable.position) ? .5 : 1); + assignGroupSize(group, true); + } + } + + if (group.isCentered) { + startPosition = tlLimit + (brLimit - tlLimit - group.size) * .5; + } else if (group.position == Pos.STACKED_BR) { + startPosition = brLimit - group.size; + } + + currentPosition = group.tlOffset + startPosition; + + group.elements.forEach(element => { + let params = [element.box, flags]; + + element.box[this.varCoord.c1] = Math.round(currentPosition); + element.box[this.varCoord.c2] = Math.round((currentPosition += element.natSize)); + + if (element.isBox) { + params.push(1); + } + + element.actor.allocate.apply(element.actor, params); + }); + + group[this.varCoord.c1] = startPosition; + group[this.varCoord.c2] = currentPosition; + group.fixed = 1; + ++fixed; + }; + + this.panel.actor.allocate(panelAlloc, flags); + + this._elementGroups.forEach(group => { + group.fixed = 0; + + assignGroupSize(group); + + if (group.position == Pos.CENTERED_MONITOR) { + centeredMonitorGroup = group; + } + }); + + if (centeredMonitorGroup) { + allocateGroup(centeredMonitorGroup, panelAlloc[this.varCoord.c1], panelAlloc[this.varCoord.c2]); } - childBoxLeft[fixedCoord.c1] = childBoxCenter[fixedCoord.c1] = childBoxRight[fixedCoord.c1] = 0; - childBoxLeft[fixedCoord.c2] = childBoxCenter[fixedCoord.c2] = childBoxRight[fixedCoord.c2] = panelAllocFixedSize; + let iterations = 0; //failsafe + while (fixed < this._elementGroups.length && ++iterations < 10) { + for (let i = 0, l = this._elementGroups.length; i < l; ++i) { + let group = this._elementGroups[i]; - // 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; + if (group.fixed) { + continue; + } - childBoxCenter[varCoord.c1] = panelAllocVarSize - centerEndPosition; - childBoxCenter[varCoord.c2] = panelAllocVarSize - centerStartPosition; + let prevGroup = this._elementGroups[i - 1]; + let nextGroup = this._elementGroups[i + 1]; + let prevLimit = prevGroup && prevGroup.fixed ? prevGroup[this.varCoord.c2] : panelAlloc[this.varCoord.c1]; + let nextLimit = nextGroup && nextGroup.fixed ? nextGroup[this.varCoord.c1] : panelAlloc[this.varCoord.c2]; - 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; + if (group.position == Pos.STACKED_TL) { + allocateGroup(group, panelAlloc[this.varCoord.c1], nextLimit); + } else if (group.position == Pos.STACKED_BR) { + allocateGroup(group, prevLimit, panelAlloc[this.varCoord.c2]); + } else if ((!prevGroup || prevGroup.fixed) && (!nextGroup || nextGroup.fixed)) { // CENTERED + allocateGroup(group, prevLimit, nextLimit); + } + } } - 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); - if (this.geom.position == St.Side.TOP) { let childBoxLeftCorner = new Clutter.ActorBox(); let childBoxRightCorner = new Clutter.ActorBox(); let currentCornerSize = this.cornerSize; + let panelAllocFixedSize = box[this.fixedCoord.c2] - box[this.fixedCoord.c1]; - [ , this.cornerSize] = this.panel._leftCorner.actor[sizeFunc](-1); - childBoxLeftCorner[varCoord.c1] = 0; - childBoxLeftCorner[varCoord.c2] = this.cornerSize; - childBoxLeftCorner[fixedCoord.c1] = panelAllocFixedSize; - childBoxLeftCorner[fixedCoord.c2] = panelAllocFixedSize + this.cornerSize; + [ , this.cornerSize] = this.panel._leftCorner.actor[this.sizeFunc](-1); + childBoxLeftCorner[this.varCoord.c1] = 0; + childBoxLeftCorner[this.varCoord.c2] = this.cornerSize; + childBoxLeftCorner[this.fixedCoord.c1] = panelAllocFixedSize; + childBoxLeftCorner[this.fixedCoord.c2] = panelAllocFixedSize + this.cornerSize; - childBoxRightCorner[varCoord.c1] = panelAllocVarSize - this.cornerSize; - childBoxRightCorner[varCoord.c2] = panelAllocVarSize; - childBoxRightCorner[fixedCoord.c1] = panelAllocFixedSize; - childBoxRightCorner[fixedCoord.c2] = panelAllocFixedSize + this.cornerSize; + childBoxRightCorner[this.varCoord.c1] = box[this.varCoord.c2] - this.cornerSize; + childBoxRightCorner[this.varCoord.c2] = box[this.varCoord.c2]; + childBoxRightCorner[this.fixedCoord.c1] = panelAllocFixedSize; + childBoxRightCorner[this.fixedCoord.c2] = panelAllocFixedSize + this.cornerSize; this.panel._leftCorner.actor.allocate(childBoxLeftCorner, flags); this.panel._rightCorner.actor.allocate(childBoxRightCorner, flags); @@ -862,7 +1041,7 @@ var dtpPanel = Utils.defineClass({ this.set_size(this.geom.w, this.geom.h); clipContainer.set_position(this.geom.x, this.geom.y); - this._setVertical(this.panel.actor, checkIfVertical()); + this._setVertical(this.panel.actor, this.checkIfVertical()); // styles for theming Object.keys(St.Side).forEach(p => { @@ -892,9 +1071,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 || @@ -903,8 +1082,8 @@ var dtpPanel = Utils.defineClass({ return Clutter.EVENT_PROPAGATE; } - let params = checkIfVertical() ? [stageY, 'y', 'height'] : [stageX, 'x', 'width']; - let dragWindow = this._getDraggableWindowForPosition.apply(this, params.concat(['maximized_' + getOrientation() + 'ly'])); + let params = this.checkIfVertical() ? [stageY, 'y', 'height'] : [stageX, 'x', 'width']; + let dragWindow = this._getDraggableWindowForPosition.apply(this, params.concat(['maximized_' + this.getOrientation() + 'ly'])); if (!dragWindow) return Clutter.EVENT_PROPAGATE; @@ -927,7 +1106,7 @@ var dtpPanel = Utils.defineClass({ workspace.list_windows() ).reverse(); - return allWindowsByStacking.find(metaWindow => { + return Utils.find(allWindowsByStacking, metaWindow => { let rect = metaWindow.get_frame_rect(); return metaWindow.get_monitor() == this.monitor.index && @@ -939,11 +1118,7 @@ var dtpPanel = Utils.defineClass({ }, _onBoxActorAdded: function(box) { - if (!this._setClockLocation(Me.settings.get_string('location-clock'))) { - this._setRightCornerStyle(); - } - - if (checkIfVertical()) { + if (this.checkIfVertical()) { this._setVertical(box, true); } }, @@ -978,8 +1153,8 @@ var dtpPanel = Utils.defineClass({ let [, natWidth] = actor.get_preferred_width(-1); child.x_align = Clutter.ActorAlign[isVertical ? 'CENTER' : 'START']; - actor.set_width(isVertical ? size : -1); - isVertical = isVertical && (natWidth > size); + actor.set_width(isVertical ? this.dtpSize : -1); + isVertical = isVertical && (natWidth > this.dtpSize); actor[(isVertical ? 'add' : 'remove') + '_style_class_name']('vertical'); } } @@ -1001,12 +1176,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 +1188,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,59 +1234,8 @@ 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) - ); - } - }, - - _toggleCornerStyle: function(corner, visible) { - if (corner) { - corner.actor[(visible ? 'remove' : 'add') + '_style_class_name']('hidden'); - } - }, - - _displayShowDesktopButton: function (isVisible) { - if(isVisible) { + _setShowDesktopButton: function (add) { + if (add) { if(this._showDesktopButton) return; @@ -1159,22 +1272,21 @@ 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(); } }, _setShowDesktopButtonSize: function() { if (this._showDesktopButton) { let buttonSize = Me.settings.get_int('showdesktop-button-width') + 'px;'; - let isVertical = checkIfVertical(); + let isVertical = this.checkIfVertical(); let sytle = isVertical ? 'border-top-width:1px;height:' + buttonSize : 'border-left-width:1px;width:' + buttonSize; this._showDesktopButton.set_style(sytle); @@ -1283,8 +1395,21 @@ var dtpPanel = Utils.defineClass({ }, }); +var dtpSecondaryPanel = Utils.defineClass({ + Name: 'DashToPanel-SecondaryPanel', + Extends: St.Widget, + + _init: function(params) { + this.callParent('_init', params); + }, + + vfunc_allocate: function(box, flags) { + this.set_allocation(box, flags); + } +}); + var dtpSecondaryAggregateMenu = Utils.defineClass({ - Name: 'dtpSecondaryAggregateMenu', + Name: 'DashToPanel-SecondaryAggregateMenu', Extends: PanelMenu.Button, _init: function() { diff --git a/panelManager.js b/panelManager.js index 06553c3..046ce2f 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,9 @@ var dtpPanelManager = Utils.defineClass({ _init: function() { this.overview = new Overview.dtpOverview(); + this.panelsElementPositions = {}; + + this._saveMonitors(); Main.overview.viewSelector.appDisplay._views.forEach(v => { Utils.wrapActor(v.view); @@ -67,10 +72,9 @@ 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.panelPositions = Pos.getSettingsPositions(Me.settings, 'panel-positions'); + this.dtpPrimaryMonitor = Main.layoutManager.monitors[dtpPrimaryIndex] || Main.layoutManager.primaryMonitor; this.proximityManager = new Proximity.ProximityManager(); Utils.wrapActor(Main.panel); @@ -90,8 +94,8 @@ var dtpPanelManager = Utils.defineClass({ global.dashToPanel.panels = this.allPanels; global.dashToPanel.emit('panels-created'); - let panelPosition = Panel.getPosition(); this.allPanels.forEach(p => { + let panelPosition = p.getPosition(); let leftOrRight = (panelPosition == St.Side.LEFT || panelPosition == St.Side.RIGHT); p.panelBox.set_size( @@ -115,9 +119,10 @@ var dtpPanelManager = Utils.defineClass({ }); } + this._updatePanelElementPositions(); this.setFocusedMonitor(this.dtpPrimaryMonitor); - if (Panel.checkIfVertical()) { + if (this.primaryPanel.checkIfVertical()) { Main.wm._getPositionForDirection = newGetPositionForDirection; } @@ -229,12 +234,16 @@ var dtpPanelManager = Utils.defineClass({ 'changed::primary-monitor', 'changed::multi-monitors', 'changed::isolate-monitors', - 'changed::taskbar-position', - 'changed::panel-position', + 'changed::panel-positions', 'changed::stockgs-keep-top-panel' ], () => this._reset() ], + [ + Me.settings, + 'changed::panel-element-positions', + () => this._updatePanelElementPositions() + ], [ Me.settings, 'changed::intellihide-key-toggle-text', @@ -245,6 +254,7 @@ var dtpPanelManager = Utils.defineClass({ 'monitors-changed', () => { if (Main.layoutManager.primaryMonitor) { + this._saveMonitors(); this._reset(); } } @@ -252,7 +262,7 @@ var dtpPanelManager = Utils.defineClass({ ); Panel.panelBoxes.forEach(c => this._signalsHandler.add( - [Main.panel[c], 'actor-added', (parent, child) => this._adjustPanelMenuButton(this._getPanelMenuButton(child), this.primaryPanel.monitor, Panel.getPosition())] + [Main.panel[c], 'actor-added', (parent, child) => this._adjustPanelMenuButton(this._getPanelMenuButton(child), this.primaryPanel.monitor, this.primaryPanel.getPosition())] )); this._setKeyBindings(true); @@ -369,6 +379,18 @@ var dtpPanelManager = Utils.defineClass({ } }, + _saveMonitors: function() { + //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)); + }, + checkIfFocusedMonitor: function(monitor) { return Main.overview.viewSelector._workspacesDisplay._primaryIndex == monitor.index; }, @@ -407,6 +429,11 @@ var dtpPanelManager = Utils.defineClass({ this.enable(true); }, + _updatePanelElementPositions: function() { + this.panelsElementPositions = Pos.getSettingsPositions(Me.settings, 'panel-element-positions'); + this.allPanels.forEach(p => p.updateElementPositions()); + }, + _adjustPanelMenuButton: function(button, monitor, arrowSide) { if (button) { Utils.wrapActor(button); @@ -426,7 +453,8 @@ var dtpPanelManager = Utils.defineClass({ _getBoxPointerPreferredHeight: function(boxPointer, alloc, monitor) { if (boxPointer._dtpInPanel && boxPointer.sourceActor && Me.settings.get_boolean('intellihide')) { monitor = monitor || Main.layoutManager.findMonitorForActor(boxPointer.sourceActor); - let excess = alloc.natural_size + Panel.size + 10 - monitor.height; // 10 is arbitrary + let panel = Utils.find(global.dashToPanel.panels, p => p.monitor == monitor); + let excess = alloc.natural_size + panel.dtpSize + 10 - monitor.height; // 10 is arbitrary if (excess > 0) { alloc.natural_size -= excess; @@ -505,12 +533,16 @@ var dtpPanelManager = Utils.defineClass({ let monitors = Main.layoutManager.monitors; for (let i = 0; i < monitors.length; i++) { + let workspaces; let view; if (this._workspacesOnlyOnPrimary && i != Main.layoutManager.primaryIndex) { view = new WorkspacesView.ExtraWorkspaceView(i); view.getActiveWorkspace = view.getActiveWorkspace || function() { return this._workspace; }; - } else + workspaces = [view._workspace]; + } else { view = new WorkspacesView.WorkspacesView(i, this._scrollAdjustment || 0); + workspaces = view._workspaces; + } Utils.wrapActor(view); view.actor.connect('scroll-event', this._onScrollEvent.bind(this)); @@ -520,6 +552,7 @@ var dtpPanelManager = Utils.defineClass({ this._scrollValueChanged.bind(this)); } + workspaces.forEach(w => w.setFullGeometry = geom => w._fullGeometry = geom); this._workspacesViews.push(view); } @@ -645,11 +678,11 @@ function newUpdateHotCorners() { return; } - let panelPosition = Panel.getPosition(); - let panelTopLeft = panelPosition == St.Side.TOP || panelPosition == St.Side.LEFT; - // build new hot corners for (let i = 0; i < this.monitors.length; i++) { + let panel = Utils.find(global.dashToPanel.panels, p => p.monitor.index == i); + let panelPosition = panel.getPosition(); + let panelTopLeft = panelPosition == St.Side.TOP || panelPosition == St.Side.LEFT; let monitor = this.monitors[i]; let cornerX = this._rtl ? monitor.x + monitor.width : monitor.x; let cornerY = monitor.y; @@ -693,7 +726,7 @@ function newUpdateHotCorners() { let corner = new Layout.HotCorner(this, monitor, cornerX, cornerY); corner.setBarrierSize = size => corner.__proto__.setBarrierSize.call(corner, Math.min(size, 32)); - corner.setBarrierSize(Panel.size); + corner.setBarrierSize(panel.dtpSize); this.hotCorners.push(corner); } else { this.hotCorners.push(null); @@ -726,7 +759,7 @@ function newUpdatePanelBarrier(panel) { let fixed1 = panel.monitor.y; let fixed2 = panel.monitor.y + barrierSize; - if (Panel.checkIfVertical()) { + if (panel.checkIfVertical()) { barriers._rightPanelBarrier.push(panel.monitor.y + panel.monitor.height, Meta.BarrierDirection.POSITIVE_Y); barriers._leftPanelBarrier.push(panel.monitor.y, Meta.BarrierDirection.NEGATIVE_Y); } else { @@ -734,7 +767,7 @@ function newUpdatePanelBarrier(panel) { barriers._leftPanelBarrier.push(panel.monitor.x, Meta.BarrierDirection.POSITIVE_X); } - switch (Panel.getPosition()) { + switch (panel.getPosition()) { //values are initialized as St.Side.TOP case St.Side.BOTTOM: fixed1 = panel.monitor.y + panel.monitor.height - barrierSize; @@ -767,16 +800,17 @@ function newUpdatePanelBarrier(panel) { directions: barriers[k][2] }; - barrierOptions[Panel.varCoord.c1] = barrierOptions[Panel.varCoord.c2] = barriers[k][1]; - barrierOptions[Panel.fixedCoord.c1] = fixed1; - barrierOptions[Panel.fixedCoord.c2] = fixed2; + barrierOptions[panel.varCoord.c1] = barrierOptions[panel.varCoord.c2] = barriers[k][1]; + barrierOptions[panel.fixedCoord.c1] = fixed1; + barrierOptions[panel.fixedCoord.c2] = fixed2; barriers[k][0][k] = new Meta.Barrier(barrierOptions); }); } function _newLookingGlassResize() { - let topOffset = Panel.getPosition() == St.Side.TOP ? Panel.size : 32; + let primaryMonitorPanel = Utils.find(global.dashToPanel.panels, p => p.monitor == Main.layoutManager.primaryMonitor); + let topOffset = primaryMonitorPanel.getPosition() == St.Side.TOP ? primaryMonitorPanel.size : 32; this._oldResize(); Utils.wrapActor(this); diff --git a/panelPositions.js b/panelPositions.js new file mode 100644 index 0000000..3c2d1af --- /dev/null +++ b/panelPositions.js @@ -0,0 +1,69 @@ +/* + * 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 TOP = 'TOP'; +var BOTTOM = 'BOTTOM'; +var LEFT = 'LEFT'; +var RIGHT = 'RIGHT'; + +var defaults = [ + { element: SHOW_APPS_BTN, visible: true, position: STACKED_TL }, + { element: ACTIVITIES_BTN, visible: false, position: STACKED_TL }, + { element: LEFT_BOX, visible: true, 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, setting) { + var positions = null; + + try { + positions = JSON.parse(settings.get_string(setting)); + } catch(e) { + log('Error parsing positions: ' + e.message); + } + + return positions; +} + +function checkIfCentered(position) { + return position == CENTERED || position == CENTERED_MONITOR; +} \ No newline at end of file diff --git a/panelStyle.js b/panelStyle.js index 120040c..2697ace 100644 --- a/panelStyle.js +++ b/panelStyle.js @@ -79,7 +79,7 @@ var dtpPanelStyle = Utils.defineClass({ this._rightBoxOperations = []; let trayPadding = Me.settings.get_int('tray-padding'); - let isVertical = Panel.checkIfVertical(); + let isVertical = this.panel.checkIfVertical(); let paddingStyle = 'padding: ' + (isVertical ? '%dpx 0' : '0 %dpx'); if(trayPadding >= 0) { @@ -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 2be9623..37e2551 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 ]; @@ -198,82 +199,282 @@ 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 position = this._getPanelPosition(this._currentMonitorIndex); + let isVertical = position == Pos.LEFT || position == Pos.RIGHT; 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._displayPanelPositionsForMonitor(this._currentMonitorIndex); }, - _setPositionRadios: function() { - let position = this._settings.get_string('panel-position'); + _maybeDisableTopPosition: function() { + let keepTopPanel = this._settings.get_boolean('stockgs-keep-top-panel'); + let monitorSync = this._settings.get_boolean('panel-element-positions-monitors-sync'); + let topAvailable = !keepTopPanel || (!monitorSync && this._currentMonitorIndex != this.monitors[0]); + let topRadio = this._builder.get_object('position_top_button'); + topRadio.set_sensitive(topAvailable); + topRadio.set_tooltip_text(!topAvailable ? _('Unavailable when gnome-shell top panel is present') : ''); + }, + + _getPanelPositions: function() { + return Pos.getSettingsPositions(this._settings, 'panel-positions'); + }, + + _getPanelPosition: function(monitorIndex) { + let panelPositionsSettings = this._getPanelPositions(); + + return panelPositionsSettings[monitorIndex] || this._settings.get_string('panel-position'); + }, + + _setPanelPosition: function(position) { + let panelPositionsSettings = this._getPanelPositions(); + let preventTop = this._settings.get_boolean('stockgs-keep-top-panel') && position == Pos.TOP; + let monitorSync = this._settings.get_boolean('panel-element-positions-monitors-sync'); + let monitors = monitorSync ? this.monitors : [this._currentMonitorIndex]; + + monitors.forEach(m => panelPositionsSettings[m] = preventTop && this.monitors[0] == m ? Pos.BOTTOM : position); + + this._settings.set_string('panel-positions', JSON.stringify(panelPositionsSettings)); + }, + + _setPositionRadios: function(position) { + this._ignorePositionRadios = true; + switch (position) { - case 'BOTTOM': + case Pos.BOTTOM: this._builder.get_object('position_bottom_button').set_active(true); break; - case 'TOP': + case Pos.TOP: this._builder.get_object('position_top_button').set_active(true); break; - case 'LEFT': + case Pos.LEFT: this._builder.get_object('position_left_button').set_active(true); break; - case 'RIGHT': + case Pos.RIGHT: this._builder.get_object('position_right_button').set_active(true); break; - } + + this._ignorePositionRadios = false; + }, + + _displayPanelPositionsForMonitor: function(monitorIndex) { + let taskbarListBox = this._builder.get_object('taskbar_display_listbox'); + + taskbarListBox.get_children().forEach(c => c.destroy()); + + let labels = {}; + let panelPosition = this._getPanelPosition(monitorIndex); + let isVertical = panelPosition == Pos.LEFT || panelPosition == Pos.RIGHT; + let panelElementPositionsSettings = Pos.getSettingsPositions(this._settings, 'panel-element-positions'); + let panelElementPositions = panelElementPositionsSettings[monitorIndex] || Pos.defaults; + let updateElementsSettings = () => { + let newPanelElementPositions = []; + let monitorSync = this._settings.get_boolean('panel-element-positions-monitors-sync'); + let monitors = monitorSync ? this.monitors : [monitorIndex]; + + taskbarListBox.get_children().forEach(c => { + newPanelElementPositions.push({ + element: c.id, + visible: c.visibleToggleBtn.get_active(), + position: c.positionCombo.get_active_id() + }); + }); + + monitors.forEach(m => panelElementPositionsSettings[m] = newPanelElementPositions); + this._settings.set_string('panel-element-positions', JSON.stringify(panelElementPositionsSettings)); + }; + + this._maybeDisableTopPosition(); + this._setPositionRadios(panelPosition); + + 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'); + + panelElementPositions.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)); + updateElementsSettings(); + } + }; + + positionCombo.append(Pos.STACKED_TL, isVertical ? _('Stacked to top') : _('Stacked to left')); + positionCombo.append(Pos.STACKED_BR, isVertical ? _('Stacked to bottom') :_('Stacked to 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(panelElementPositions.length - 1)); + visibleToggleBtn.connect('toggled', () => updateElementsSettings()); + positionCombo.connect('changed', () => updateElementsSettings()); + + 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(); }, _bindSettings: function() { - // Position and style panel - - // Position option - this._setPositionRadios(); - - 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,37 +714,61 @@ const Settings = new Lang.Class({ })); //multi-monitor - let monitors = [-1]; + this.monitors = this._settings.get_value('available-monitors').deep_unpack(); - this._builder.get_object('multimon_primary_combo').append_text(_('Default (Primary monitor)')); + let dtpPrimaryMonitorIndex = this.monitors.indexOf(this._settings.get_int('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); + if (dtpPrimaryMonitorIndex < 0) { + dtpPrimaryMonitorIndex = 0; } - this._builder.get_object('multimon_primary_combo').set_active(monitors.indexOf(this._settings.get_int('primary-monitor'))); + this._currentMonitorIndex = this.monitors[dtpPrimaryMonitorIndex]; + + this._settings.connect('changed::panel-positions', () => this._updateVerticalRelatedOptions()); + this._updateVerticalRelatedOptions(); + + 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(label); + this._builder.get_object('taskbar_position_monitor_combo').append_text(label); + } + + this._builder.get_object('multimon_primary_combo').set_active(dtpPrimaryMonitorIndex); + this._builder.get_object('taskbar_position_monitor_combo').set_active(dtpPrimaryMonitorIndex); + + this._settings.bind('panel-element-positions-monitors-sync', + this._builder.get_object('taskbar_position_sync_button'), + 'active', + Gio.SettingsBindFlags.DEFAULT); + + this._settings.bind('panel-element-positions-monitors-sync', + this._builder.get_object('taskbar_position_monitor_combo'), + 'sensitive', + Gio.SettingsBindFlags.INVERT_BOOLEAN); + + this._settings.connect('changed::panel-element-positions-monitors-sync', () => this._maybeDisableTopPosition()); + 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._currentMonitorIndex = this.monitors[widget.get_active()]; + this._displayPanelPositionsForMonitor(this._currentMonitorIndex); + })); + + //panel positions + this._displayPanelPositionsForMonitor(this._currentMonitorIndex); + 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) { - this._builder.get_object('multimon_multi_switch').set_active(false); + if (this.monitors.length === 1) { + this._builder.get_object('multimon_multi_switch').set_sensitive(false); } //dynamic opacity @@ -835,102 +1060,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 +1085,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', @@ -1755,34 +1845,11 @@ const Settings = new Lang.Class({ '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(); - } - }; + - var setGsStockPanelOptions = () => { - let keepTopPanel = this._settings.get_boolean('stockgs-keep-top-panel'); + this._settings.connect('changed::stockgs-keep-top-panel', () => this._maybeDisableTopPosition()); - 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._maybeDisableTopPosition(); this._settings.bind('stockgs-panelbtn-click-only', this._builder.get_object('stockgs_panelbtn_switch'), @@ -1896,24 +1963,20 @@ const Settings = new Lang.Class({ */ _SignalHandler: { - position_bottom_button_toggled_cb: function(button) { - if (button.get_active()) - this._settings.set_string('panel-position', "BOTTOM"); + position_bottom_button_clicked_cb: function(button) { + if (!this._ignorePositionRadios && button.get_active()) this._setPanelPosition(Pos.BOTTOM); }, - position_top_button_toggled_cb: function(button) { - if (button.get_active()) - this._settings.set_string('panel-position', "TOP"); + position_top_button_clicked_cb: function(button) { + if (!this._ignorePositionRadios && button.get_active()) this._setPanelPosition(Pos.TOP); }, - position_left_button_toggled_cb: function(button) { - if (button.get_active()) - this._settings.set_string('panel-position', "LEFT"); + position_left_button_clicked_cb: function(button) { + if (!this._ignorePositionRadios && button.get_active()) this._setPanelPosition(Pos.LEFT); }, - position_right_button_toggled_cb: function(button) { - if (button.get_active()) - this._settings.set_string('panel-position', "RIGHT"); + position_right_button_clicked_cb: function(button) { + if (!this._ignorePositionRadios && button.get_active()) this._setPanelPosition(Pos.RIGHT); }, dots_bottom_button_toggled_cb: function(button) { 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 59551a4..74c0671 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,21 @@ Panel position Panel is shown on the Bottom or Top of the screen. + + true + Sync element positions + Sync panel element positions on all monitors. + + + '{}' + Panel positions + Panel positions (JSON). + + + '{}' + Panel element positions + Panel element positions (JSON). + 48 Panel size @@ -207,16 +207,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 @@ -588,30 +578,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 3ebcb9a..1319aa3 100644 --- a/stylesheet.css +++ b/stylesheet.css @@ -27,7 +27,8 @@ } #dashtopanelScrollview .app-well-app .overview-icon, -#dashtopanelTaskbar .show-apps .overview-icon { +.dashtopanelMainPanel .show-apps .overview-icon { + background: none; border: none; margin: 0; padding: 0; @@ -44,6 +45,7 @@ background: none; } +.dashtopanelMainPanel .show-apps:hover .overview-icon, #dashtopanelScrollview .app-well-app:hover .dtp-container, #dashtopanelScrollview .app-well-app:focus .dtp-container { background-color: rgba(238, 238, 236, 0.1); diff --git a/taskbar.js b/taskbar.js index 1f829c3..2133198 100644 --- a/taskbar.js +++ b/taskbar.js @@ -80,38 +80,34 @@ var taskbarActor = Utils.defineClass({ this._delegate = delegate; this._currentBackgroundColor = 0; this.callParent('_init', { name: 'dashtopanelTaskbar', - layout_manager: new Clutter.BoxLayout({ orientation: Clutter.Orientation[Panel.getOrientation().toUpperCase()] }), + layout_manager: new Clutter.BoxLayout({ orientation: Clutter.Orientation[delegate.dtpPanel.getOrientation().toUpperCase()] }), clip_to_allocation: true }); }, vfunc_allocate: function(box, flags)  { this.set_allocation(box, flags); - 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 [, natSize] = this[Panel.sizeFunc](availFixedSize); + let panel = this._delegate.dtpPanel; + let availFixedSize = box[panel.fixedCoord.c2] - box[panel.fixedCoord.c1]; + let availVarSize = box[panel.varCoord.c2] - box[panel.varCoord.c1]; + let [, scrollview, leftFade, rightFade] = this.get_children(); + let [, natSize] = this[panel.sizeFunc](availFixedSize); let childBox = new Clutter.ActorBox(); - let orientation = Panel.getOrientation(); + let orientation = panel.getOrientation(); - childBox[Panel.varCoord.c1] = box[Panel.varCoord.c1]; - childBox[Panel.fixedCoord.c1] = box[Panel.fixedCoord.c1]; + childBox[panel.varCoord.c1] = box[panel.varCoord.c1]; + childBox[panel.varCoord.c2] = Math.min(availVarSize, natSize); + childBox[panel.fixedCoord.c1] = box[panel.fixedCoord.c1]; + childBox[panel.fixedCoord.c2] = box[panel.fixedCoord.c2]; - 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); scrollview.allocate(childBox, flags); let [value, , upper, , , pageSize] = scrollview[orientation[0] + 'scroll'].adjustment.get_values(); upper = Math.floor(upper); scrollview._dtpFadeSize = upper > pageSize ? this._delegate.iconSize : 0; - if (this._currentBackgroundColor !== this._delegate.dtpPanel.dynamicTransparency.currentBackgroundColor) { - this._currentBackgroundColor = this._delegate.dtpPanel.dynamicTransparency.currentBackgroundColor; + if (this._currentBackgroundColor !== panel.dynamicTransparency.currentBackgroundColor) { + this._currentBackgroundColor = panel.dynamicTransparency.currentBackgroundColor; let gradientStyle = 'background-gradient-start: ' + this._currentBackgroundColor + 'background-gradient-direction: ' + orientation; @@ -119,12 +115,11 @@ 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); + childBox[panel.varCoord.c2] = childBox[panel.varCoord.c1] + (value > 0 ? scrollview._dtpFadeSize : 0); leftFade.allocate(childBox, flags); - childBox[Panel.varCoord.c1] = box[Panel.varCoord.c2] - (value + pageSize < upper ? scrollview._dtpFadeSize : 0); - childBox[Panel.varCoord.c2] = box[Panel.varCoord.c2]; + childBox[panel.varCoord.c1] = box[panel.varCoord.c2] - (value + pageSize < upper ? scrollview._dtpFadeSize : 0); + childBox[panel.varCoord.c2] = box[panel.varCoord.c2]; rightFade.allocate(childBox, flags); }, @@ -177,7 +172,7 @@ var taskbar = Utils.defineClass({ this._labelShowing = false; this.fullScrollView = 0; - let isVertical = Panel.checkIfVertical(); + let isVertical = panel.checkIfVertical(); this._box = new St.BoxLayout({ vertical: isVertical, clip_to_allocation: false, @@ -193,8 +188,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,10 +209,9 @@ 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(); + let orientation = panel.getOrientation(); let fadeStyle = 'background-gradient-direction:' + orientation; let fade1 = new St.Widget({ style_class: 'scrollview-fade', reactive: false }); let fade2 = new St.Widget({ style_class: 'scrollview-fade', @@ -358,41 +351,23 @@ var taskbar = Utils.defineClass({ ], [ adjustment, - 'notify::upper', - () => { - // Update minimization animation target position on scrollview change. - this._updateAppIcons(); - - // When applications are ungrouped and there is some empty space on the horizontal taskbar, - // force a fixed label width to prevent the icons from "wiggling" when an animation runs - // (adding or removing an icon). When the taskbar is full, revert to a dynamic label width - // to allow them to resize and make room for new icons. - if (!isVertical && !this.isGroupApps) { - let initial = this.fullScrollView; - - if (!this.fullScrollView && Math.floor(adjustment.upper) > adjustment.page_size) { - this.fullScrollView = adjustment.page_size; - } else if (adjustment.page_size < this.fullScrollView) { - this.fullScrollView = 0; - } - - if (initial != this.fullScrollView) { - this._getAppIcons().forEach(a => a.updateTitleStyle()); - } - } - } + [ + 'notify::upper', + 'notify::pageSize' + ], + () => this._onScrollSizeChange(adjustment) ] ); this.isGroupApps = Me.settings.get_boolean('group-apps'); + this._onScrollSizeChange(adjustment); this._connectWorkspaceSignals(); }, destroy: function() { this._signalsHandler.destroy(); this._signalsHandler = 0; - this._showAppsIconWrapper.destroy(); this._container.destroy(); @@ -404,7 +379,7 @@ var taskbar = Utils.defineClass({ _onScrollEvent: function(actor, event) { - let orientation = Panel.getOrientation(); + let orientation = this.dtpPanel.getOrientation(); // reset timeout to avid conflicts with the mousehover event if (this._ensureAppIconVisibilityTimeoutId>0) { @@ -445,6 +420,29 @@ var taskbar = Utils.defineClass({ }, + _onScrollSizeChange: function(adjustment) { + // Update minimization animation target position on scrollview change. + this._updateAppIcons(); + + // When applications are ungrouped and there is some empty space on the horizontal taskbar, + // force a fixed label width to prevent the icons from "wiggling" when an animation runs + // (adding or removing an icon). When the taskbar is full, revert to a dynamic label width + // to allow them to resize and make room for new icons. + if (!this.dtpPanel.checkIfVertical() && !this.isGroupApps) { + let initial = this.fullScrollView; + + if (!this.fullScrollView && Math.floor(adjustment.upper) > adjustment.page_size) { + this.fullScrollView = adjustment.page_size; + } else if (adjustment.page_size < this.fullScrollView) { + this.fullScrollView = 0; + } + + if (initial != this.fullScrollView) { + this._getAppIcons().forEach(a => a.updateTitleStyle()); + } + } + }, + _onDragBegin: function() { this._dragCancelled = false; this._dragMonitor = { @@ -587,6 +585,7 @@ var taskbar = Utils.defineClass({ let item = new Dash.DashItemContainer(); + item._dtpPanel = this.dtpPanel extendDashItemContainer(item); item.setChild(appIcon.actor); @@ -896,7 +895,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 +907,7 @@ var taskbar = Utils.defineClass({ this._shownInitially = false; this._redisplay(); - if (Panel.checkIfVertical()) { - this.showAppsButton.set_width(this.dtpPanel.geom.w); + if (geometryChange && this.dtpPanel.checkIfVertical()) { this.previewMenu._updateClip(); } }, @@ -972,7 +970,7 @@ var taskbar = Utils.defineClass({ this._box.insert_child_above(source._dashItemContainer, null); } - let isVertical = Panel.checkIfVertical(); + let isVertical = this.dtpPanel.checkIfVertical(); let sizeProp = isVertical ? 'height' : 'width'; let posProp = isVertical ? 'y' : 'x'; let pos = isVertical ? y : x; @@ -1160,13 +1158,12 @@ var taskbar = Utils.defineClass({ } } - //temporarily use as primary the monitor on which the showapps btn was clicked + //temporarily use as primary the monitor on which the showapps btn was clicked, this is + //restored by the panel when exiting the overview this.dtpPanel.panelManager.setFocusedMonitor(this.dtpPanel.monitor); - //reset the primary monitor when exiting the overview let overviewHiddenId = Main.overview.connect('hidden', () => { Main.overview.disconnect(overviewHiddenId); - this.dtpPanel.panelManager.setFocusedMonitor(this.dtpPanel.panelManager.primaryPanel.monitor, true); delete Main.overview.viewSelector._onStageKeyPress; }); @@ -1247,7 +1244,7 @@ var DragPlaceholderItem = Utils.defineClass({ Extends: St.Widget, _init: function(appIcon, iconSize) { - this.callParent('_init', { style: AppIcons.getIconContainerStyle(), layout_manager: new Clutter.BinLayout() }); + this.callParent('_init', { style: appIcon.getIconContainerStyle(), layout_manager: new Clutter.BinLayout() }); this.child = { _delegate: appIcon }; diff --git a/transparency.js b/transparency.js index 835f88a..aa86d7a 100644 --- a/transparency.js +++ b/transparency.js @@ -134,7 +134,7 @@ var DynamicTransparency = Utils.defineClass({ this._proximityManager.removeWatch(this._proximityWatchId); if (Me.settings.get_boolean('trans-use-dynamic-opacity')) { - let isVertical = Panel.checkIfVertical(); + let isVertical = this._dtpPanel.checkIfVertical(); let threshold = Me.settings.get_int('trans-dynamic-distance'); this._proximityWatchId = this._proximityManager.createWatch( @@ -206,7 +206,7 @@ var DynamicTransparency = Utils.defineClass({ this._gradientStyle = ''; if (Me.settings.get_boolean('trans-use-custom-gradient')) { - this._gradientStyle += 'background-gradient-direction: ' + (Panel.checkIfVertical() ? 'horizontal;' : 'vertical;') + + this._gradientStyle += 'background-gradient-direction: ' + (this._dtpPanel.checkIfVertical() ? 'horizontal;' : 'vertical;') + 'background-gradient-start: ' + Utils.getrgbaColor(Me.settings.get_string('trans-gradient-top-color'), Me.settings.get_double('trans-gradient-top-opacity')) + 'background-gradient-end: ' + Utils.getrgbaColor(Me.settings.get_string('trans-gradient-bottom-color'), diff --git a/utils.js b/utils.js index 8fbb280..73486cf 100644 --- a/utils.js +++ b/utils.js @@ -316,6 +316,14 @@ var findIndex = function(array, predicate) { return -1; }; +var find = function(array, predicate) { + let index = findIndex(array, predicate); + + if (index > -1) { + return array[index]; + } +}; + var mergeObjects = function(main, bck) { for (var prop in bck) { if (!main.hasOwnProperty(prop) && bck.hasOwnProperty(prop)) { diff --git a/windowPreview.js b/windowPreview.js index e6954cd..6dd0f96 100644 --- a/windowPreview.js +++ b/windowPreview.js @@ -53,7 +53,6 @@ const FADE_SIZE = 36; const PEEK_INDEX_PROP = '_dtpPeekInitialIndex'; let headerHeight = 0; -let clipHeight = 0; let alphaBg = 0; let isLeftButtons = false; let isTopHeader = true; @@ -80,7 +79,7 @@ var PreviewMenu = Utils.defineClass({ this.isVertical = geom.position == St.Side.LEFT || geom.position == St.Side.RIGHT; this._translationProp = 'translation_' + (this.isVertical ? 'x' : 'y'); this._translationDirection = (geom.position == St.Side.TOP || geom.position == St.Side.LEFT ? -1 : 1); - this._translationOffset = Math.min(Panel.size, MAX_TRANSLATION) * this._translationDirection; + this._translationOffset = Math.min(panel.dtpSize, MAX_TRANSLATION) * this._translationDirection; this.menu = new St.Widget({ name: 'preview-menu', @@ -192,7 +191,7 @@ var PreviewMenu = Utils.defineClass({ if (!this.opened) { this._refreshGlobals(); - this.set_height(clipHeight); + this.set_height(this.clipHeight); this.menu.show(); setStyle(this.menu, 'background: ' + Utils.getrgbaColor(this.panel.dynamicTransparency.backgroundColorRgb, alphaBg)); @@ -442,25 +441,25 @@ var PreviewMenu = Utils.defineClass({ if (this.isVertical) { w = previewSize; - clipHeight = this.panel.monitor.height; + this.clipHeight = this.panel.monitor.height; y = this.panel.monitor.y; } else { w = this.panel.monitor.width; - clipHeight = (previewSize + headerHeight); + this.clipHeight = (previewSize + headerHeight); x = this.panel.monitor.x; } if (geom.position == St.Side.LEFT) { - x = this.panel.monitor.x + Panel.size + panelBoxTheme.get_padding(St.Side.LEFT); + x = this.panel.monitor.x + this.panel.dtpSize + panelBoxTheme.get_padding(St.Side.LEFT); } else if (geom.position == St.Side.RIGHT) { - x = this.panel.monitor.x + this.panel.monitor.width - (Panel.size + previewSize) - panelBoxTheme.get_padding(St.Side.RIGHT); + x = this.panel.monitor.x + this.panel.monitor.width - (this.panel.dtpSize + previewSize) - panelBoxTheme.get_padding(St.Side.RIGHT); } else if (geom.position == St.Side.TOP) { - y = this.panel.monitor.y + Panel.size + panelBoxTheme.get_padding(St.Side.TOP); + y = this.panel.monitor.y + this.panel.dtpSize + panelBoxTheme.get_padding(St.Side.TOP); } else { //St.Side.BOTTOM - y = this.panel.monitor.y + this.panel.monitor.height - (Panel.size + panelBoxTheme.get_padding(St.Side.BOTTOM) + previewSize + headerHeight); + y = this.panel.monitor.y + this.panel.monitor.height - (this.panel.dtpSize + panelBoxTheme.get_padding(St.Side.BOTTOM) + previewSize + headerHeight); } - Utils.setClip(this, x, y, w, clipHeight); + Utils.setClip(this, x, y, w, this.clipHeight); }, _updatePosition: function() { @@ -526,7 +525,7 @@ var PreviewMenu = Utils.defineClass({ let endBg = Utils.getrgbaColor(this.panel.dynamicTransparency.backgroundColorRgb, 0) let fadeStyle = 'background-gradient-start:' + startBg + 'background-gradient-end:' + endBg + - 'background-gradient-direction:' + Panel.getOrientation(); + 'background-gradient-direction:' + this.panel.getOrientation(); if (this.isVertical) { y = end ? this.panel.monitor.height - FADE_SIZE : 0;