iso-profiles-settings/tromjaro/gnome/desktop-overlay/etc/skel/.local/share/gnome-shell/extensions/unite@hardpixel.eu/overrides/panel.js

92 lines
2.6 KiB
JavaScript

const Gi = imports._gi
const Clutter = imports.gi.Clutter
const Main = imports.ui.main
const Me = imports.misc.extensionUtils.getCurrentExtension()
const Override = Me.imports.overrides.helper
const VERSION = Me.imports.overrides.helper.VERSION
const CLASSIC = global.session_mode == 'classic'
var ExtendLeftBox = class ExtendLeftBox extends Override.Injection {
get active() {
return VERSION < 38
}
_init() {
this._replace('_injectAllocate')
this._replace('_allocate')
}
_injectAllocate() {
Main.panel.__proto__[Gi.hook_up_vfunc_symbol]('allocate', (box, flags) => {
Main.panel.vfunc_allocate.call(Main.panel, box, flags)
this._allocate(Main.panel, box, flags)
})
}
_allocate(actor, box, flags) {
let leftBox = Main.panel._leftBox
let centerBox = Main.panel._centerBox
let rightBox = Main.panel._rightBox
let allocWidth = box.x2 - box.x1
let allocHeight = box.y2 - box.y1
let [leftMinWidth, leftNaturalWidth] = leftBox.get_preferred_width(-1)
let [centerMinWidth, centerNaturalWidth] = centerBox.get_preferred_width(-1)
let [rightMinWidth, rightNaturalWidth] = rightBox.get_preferred_width(-1)
let sideWidth = allocWidth - rightNaturalWidth - centerNaturalWidth
let childBox = new Clutter.ActorBox()
childBox.y1 = 0
childBox.y2 = allocHeight
if (actor.get_text_direction() == Clutter.TextDirection.RTL) {
childBox.x1 = allocWidth - Math.min(Math.floor(sideWidth), leftNaturalWidth)
childBox.x2 = allocWidth
} else {
childBox.x1 = 0
childBox.x2 = Math.min(Math.floor(sideWidth), leftNaturalWidth)
}
leftBox.allocate(childBox, flags)
childBox.y1 = 0
childBox.y2 = allocHeight
if (actor.get_text_direction() == Clutter.TextDirection.RTL) {
childBox.x1 = rightNaturalWidth
childBox.x2 = childBox.x1 + centerNaturalWidth
} else {
childBox.x1 = allocWidth - centerNaturalWidth - rightNaturalWidth
childBox.x2 = childBox.x1 + centerNaturalWidth
}
centerBox.allocate(childBox, flags)
childBox.y1 = 0
childBox.y2 = allocHeight
if (actor.get_text_direction() == Clutter.TextDirection.RTL) {
childBox.x1 = 0
childBox.x2 = rightNaturalWidth
} else {
childBox.x1 = allocWidth - rightNaturalWidth
childBox.x2 = allocWidth
}
rightBox.allocate(childBox, flags)
}
}
var ActivitiesButtonClassic = class ActivitiesButtonClassic extends Override.Injection {
get active() {
return CLASSIC == true
}
_init() {
this._replace('activate', () => {})
this._replace('destroy', () => {})
}
}