2021-05-10 22:03:41 +00:00
|
|
|
const Gi = imports._gi
|
2021-06-09 15:51:27 +00:00
|
|
|
const Clutter = imports.gi.Clutter
|
2021-05-10 22:03:41 +00:00
|
|
|
const Main = imports.ui.main
|
|
|
|
const Me = imports.misc.extensionUtils.getCurrentExtension()
|
|
|
|
const Override = Me.imports.overrides.helper
|
|
|
|
const VERSION = Me.imports.overrides.helper.VERSION
|
2021-06-09 15:51:27 +00:00
|
|
|
const CLASSIC = global.session_mode == 'classic'
|
2021-05-10 22:03:41 +00:00
|
|
|
|
|
|
|
var ExtendLeftBox = class ExtendLeftBox extends Override.Injection {
|
|
|
|
get active() {
|
|
|
|
return VERSION < 38
|
|
|
|
}
|
|
|
|
|
|
|
|
_init() {
|
|
|
|
this._replace('_injectAllocate')
|
2021-06-09 15:51:27 +00:00
|
|
|
this._replace('_allocate')
|
2021-05-10 22:03:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_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)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-06-09 15:51:27 +00:00
|
|
|
_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', () => {})
|
2021-05-10 22:03:41 +00:00
|
|
|
}
|
|
|
|
}
|