js: Use gjs-defined GObject accessors where possible
Nowadays gjs allows to omit get/set accessors for read-write properties, and will define reasonable defaults in that case. In many cases we don't need anything more than the default handling, let gjs handle those props. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1611>
This commit is contained in:
parent
a41e294e21
commit
0f1b566918
@ -323,40 +323,15 @@ var IconGridLayout = GObject.registerClass({
|
|||||||
},
|
},
|
||||||
}, class IconGridLayout extends Clutter.LayoutManager {
|
}, class IconGridLayout extends Clutter.LayoutManager {
|
||||||
_init(params = {}) {
|
_init(params = {}) {
|
||||||
params = Params.parse(params, {
|
this._orientation = params.orientation ?? Clutter.Orientation.VERTICAL;
|
||||||
allow_incomplete_pages: true,
|
|
||||||
column_spacing: 0,
|
|
||||||
columns_per_page: 6,
|
|
||||||
fixed_icon_size: -1,
|
|
||||||
last_row_align: Clutter.ActorAlign.FILL,
|
|
||||||
max_column_spacing: -1,
|
|
||||||
max_row_spacing: -1,
|
|
||||||
orientation: Clutter.Orientation.VERTICAL,
|
|
||||||
page_halign: Clutter.ActorAlign.FILL,
|
|
||||||
page_padding: new Clutter.Margin(),
|
|
||||||
page_valign: Clutter.ActorAlign.FILL,
|
|
||||||
row_spacing: 0,
|
|
||||||
rows_per_page: 4,
|
|
||||||
});
|
|
||||||
|
|
||||||
this._allowIncompletePages = params.allow_incomplete_pages;
|
|
||||||
this._columnSpacing = params.column_spacing;
|
|
||||||
this._columnsPerPage = params.columns_per_page;
|
|
||||||
this._fixedIconSize = params.fixed_icon_size;
|
|
||||||
this._lastRowAlign = params.last_row_align;
|
|
||||||
this._maxColumnSpacing = params.max_column_spacing;
|
|
||||||
this._maxRowSpacing = params.max_row_spacing;
|
|
||||||
this._orientation = params.orientation;
|
|
||||||
this._pageHAlign = params.page_halign;
|
|
||||||
this._pagePadding = params.page_padding;
|
|
||||||
this._pageVAlign = params.page_valign;
|
|
||||||
this._rowSpacing = params.row_spacing;
|
|
||||||
this._rowsPerPage = params.rows_per_page;
|
|
||||||
|
|
||||||
super._init(params);
|
super._init(params);
|
||||||
|
|
||||||
this._iconSize = this._fixedIconSize !== -1
|
if (!this.pagePadding)
|
||||||
? this._fixedIconSize
|
this.pagePadding = new Clutter.Margin();
|
||||||
|
|
||||||
|
this._iconSize = this.fixedIconSize !== -1
|
||||||
|
? this.fixedIconSize
|
||||||
: IconSize.LARGE;
|
: IconSize.LARGE;
|
||||||
|
|
||||||
this._pageSizeChanged = false;
|
this._pageSizeChanged = false;
|
||||||
@ -397,14 +372,14 @@ var IconGridLayout = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
_findBestIconSize() {
|
_findBestIconSize() {
|
||||||
const nColumns = this._columnsPerPage;
|
const nColumns = this.columnsPerPage;
|
||||||
const nRows = this._rowsPerPage;
|
const nRows = this.rowsPerPage;
|
||||||
const columnSpacingPerPage = this._columnSpacing * (nColumns - 1);
|
const columnSpacingPerPage = this.columnSpacing * (nColumns - 1);
|
||||||
const rowSpacingPerPage = this._rowSpacing * (nRows - 1);
|
const rowSpacingPerPage = this.rowSpacing * (nRows - 1);
|
||||||
const [firstItem] = this._container;
|
const [firstItem] = this._container;
|
||||||
|
|
||||||
if (this._fixedIconSize !== -1)
|
if (this.fixedIconSize !== -1)
|
||||||
return this._fixedIconSize;
|
return this.fixedIconSize;
|
||||||
|
|
||||||
const iconSizes = Object.values(IconSize).sort((a, b) => b - a);
|
const iconSizes = Object.values(IconSize).sort((a, b) => b - a);
|
||||||
for (const size of iconSizes) {
|
for (const size of iconSizes) {
|
||||||
@ -426,10 +401,10 @@ var IconGridLayout = GObject.registerClass({
|
|||||||
|
|
||||||
const emptyHSpace =
|
const emptyHSpace =
|
||||||
this._pageWidth - usedWidth - columnSpacingPerPage -
|
this._pageWidth - usedWidth - columnSpacingPerPage -
|
||||||
this._pagePadding.left - this._pagePadding.right;
|
this.pagePadding.left - this.pagePadding.right;
|
||||||
const emptyVSpace =
|
const emptyVSpace =
|
||||||
this._pageHeight - usedHeight - rowSpacingPerPage -
|
this._pageHeight - usedHeight - rowSpacingPerPage -
|
||||||
this._pagePadding.top - this._pagePadding.bottom;
|
this.pagePadding.top - this.pagePadding.bottom;
|
||||||
|
|
||||||
if (emptyHSpace >= 0 && emptyVSpace > 0)
|
if (emptyHSpace >= 0 && emptyVSpace > 0)
|
||||||
return size;
|
return size;
|
||||||
@ -495,7 +470,7 @@ var IconGridLayout = GObject.registerClass({
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
const visiblePageItems = this._getVisibleChildrenForPage(pageIndex);
|
const visiblePageItems = this._getVisibleChildrenForPage(pageIndex);
|
||||||
const itemsPerPage = this._columnsPerPage * this._rowsPerPage;
|
const itemsPerPage = this.columnsPerPage * this.rowsPerPage;
|
||||||
|
|
||||||
// No reduce needed
|
// No reduce needed
|
||||||
if (visiblePageItems.length === itemsPerPage)
|
if (visiblePageItems.length === itemsPerPage)
|
||||||
@ -528,13 +503,13 @@ var IconGridLayout = GObject.registerClass({
|
|||||||
if (visibleItems.length === 0)
|
if (visibleItems.length === 0)
|
||||||
this._removePage(pageIndex);
|
this._removePage(pageIndex);
|
||||||
|
|
||||||
if (!this._allowIncompletePages)
|
if (!this.allowIncompletePages)
|
||||||
this._fillItemVacancies(pageIndex);
|
this._fillItemVacancies(pageIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
_relocateSurplusItems(pageIndex) {
|
_relocateSurplusItems(pageIndex) {
|
||||||
const visiblePageItems = this._getVisibleChildrenForPage(pageIndex);
|
const visiblePageItems = this._getVisibleChildrenForPage(pageIndex);
|
||||||
const itemsPerPage = this._columnsPerPage * this._rowsPerPage;
|
const itemsPerPage = this.columnsPerPage * this.rowsPerPage;
|
||||||
|
|
||||||
// No overflow needed
|
// No overflow needed
|
||||||
if (visiblePageItems.length <= itemsPerPage)
|
if (visiblePageItems.length <= itemsPerPage)
|
||||||
@ -579,7 +554,7 @@ var IconGridLayout = GObject.registerClass({
|
|||||||
|
|
||||||
if (item.visible)
|
if (item.visible)
|
||||||
this._relocateSurplusItems(itemData.pageIndex);
|
this._relocateSurplusItems(itemData.pageIndex);
|
||||||
else if (!this._allowIncompletePages)
|
else if (!this.allowIncompletePages)
|
||||||
this._fillItemVacancies(itemData.pageIndex);
|
this._fillItemVacancies(itemData.pageIndex);
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
@ -591,72 +566,72 @@ var IconGridLayout = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
_calculateSpacing(childSize) {
|
_calculateSpacing(childSize) {
|
||||||
const nColumns = this._columnsPerPage;
|
const nColumns = this.columnsPerPage;
|
||||||
const nRows = this._rowsPerPage;
|
const nRows = this.rowsPerPage;
|
||||||
const usedWidth = childSize * nColumns;
|
const usedWidth = childSize * nColumns;
|
||||||
const usedHeight = childSize * nRows;
|
const usedHeight = childSize * nRows;
|
||||||
const columnSpacingPerPage = this._columnSpacing * (nColumns - 1);
|
const columnSpacingPerPage = this.columnSpacing * (nColumns - 1);
|
||||||
const rowSpacingPerPage = this._rowSpacing * (nRows - 1);
|
const rowSpacingPerPage = this.rowSpacing * (nRows - 1);
|
||||||
|
|
||||||
const emptyHSpace =
|
const emptyHSpace =
|
||||||
this._pageWidth - usedWidth - columnSpacingPerPage -
|
this._pageWidth - usedWidth - columnSpacingPerPage -
|
||||||
this._pagePadding.left - this._pagePadding.right;
|
this.pagePadding.left - this.pagePadding.right;
|
||||||
const emptyVSpace =
|
const emptyVSpace =
|
||||||
this._pageHeight - usedHeight - rowSpacingPerPage -
|
this._pageHeight - usedHeight - rowSpacingPerPage -
|
||||||
this._pagePadding.top - this._pagePadding.bottom;
|
this.pagePadding.top - this.pagePadding.bottom;
|
||||||
let leftEmptySpace = this._pagePadding.left;
|
let leftEmptySpace = this.pagePadding.left;
|
||||||
let topEmptySpace = this._pagePadding.top;
|
let topEmptySpace = this.pagePadding.top;
|
||||||
let hSpacing;
|
let hSpacing;
|
||||||
let vSpacing;
|
let vSpacing;
|
||||||
|
|
||||||
switch (this._pageHAlign) {
|
switch (this.pageHalign) {
|
||||||
case Clutter.ActorAlign.START:
|
case Clutter.ActorAlign.START:
|
||||||
hSpacing = this._columnSpacing;
|
hSpacing = this.columnSpacing;
|
||||||
break;
|
break;
|
||||||
case Clutter.ActorAlign.CENTER:
|
case Clutter.ActorAlign.CENTER:
|
||||||
leftEmptySpace += Math.floor(emptyHSpace / 2);
|
leftEmptySpace += Math.floor(emptyHSpace / 2);
|
||||||
hSpacing = this._columnSpacing;
|
hSpacing = this.columnSpacing;
|
||||||
break;
|
break;
|
||||||
case Clutter.ActorAlign.END:
|
case Clutter.ActorAlign.END:
|
||||||
leftEmptySpace += emptyHSpace;
|
leftEmptySpace += emptyHSpace;
|
||||||
hSpacing = this._columnSpacing;
|
hSpacing = this.columnSpacing;
|
||||||
break;
|
break;
|
||||||
case Clutter.ActorAlign.FILL:
|
case Clutter.ActorAlign.FILL:
|
||||||
hSpacing = this._columnSpacing + emptyHSpace / (nColumns - 1);
|
hSpacing = this.columnSpacing + emptyHSpace / (nColumns - 1);
|
||||||
|
|
||||||
// Maybe constraint horizontal spacing
|
// Maybe constraint horizontal spacing
|
||||||
if (this._maxColumnSpacing !== -1 && hSpacing > this._maxColumnSpacing) {
|
if (this.maxColumnSpacing !== -1 && hSpacing > this.maxColumnSpacing) {
|
||||||
const extraHSpacing =
|
const extraHSpacing =
|
||||||
(this._maxColumnSpacing - this._columnSpacing) * (nColumns - 1);
|
(this.maxColumnSpacing - this.columnSpacing) * (nColumns - 1);
|
||||||
|
|
||||||
hSpacing = this._maxColumnSpacing;
|
hSpacing = this.maxColumnSpacing;
|
||||||
leftEmptySpace +=
|
leftEmptySpace +=
|
||||||
Math.max((emptyHSpace - extraHSpacing) / 2, 0);
|
Math.max((emptyHSpace - extraHSpacing) / 2, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (this._pageVAlign) {
|
switch (this.pageValign) {
|
||||||
case Clutter.ActorAlign.START:
|
case Clutter.ActorAlign.START:
|
||||||
vSpacing = this._rowSpacing;
|
vSpacing = this.rowSpacing;
|
||||||
break;
|
break;
|
||||||
case Clutter.ActorAlign.CENTER:
|
case Clutter.ActorAlign.CENTER:
|
||||||
topEmptySpace += Math.floor(emptyVSpace / 2);
|
topEmptySpace += Math.floor(emptyVSpace / 2);
|
||||||
vSpacing = this._rowSpacing;
|
vSpacing = this.rowSpacing;
|
||||||
break;
|
break;
|
||||||
case Clutter.ActorAlign.END:
|
case Clutter.ActorAlign.END:
|
||||||
topEmptySpace += emptyVSpace;
|
topEmptySpace += emptyVSpace;
|
||||||
vSpacing = this._rowSpacing;
|
vSpacing = this.rowSpacing;
|
||||||
break;
|
break;
|
||||||
case Clutter.ActorAlign.FILL:
|
case Clutter.ActorAlign.FILL:
|
||||||
vSpacing = this._rowSpacing + emptyVSpace / (nRows - 1);
|
vSpacing = this.rowSpacing + emptyVSpace / (nRows - 1);
|
||||||
|
|
||||||
// Maybe constraint vertical spacing
|
// Maybe constraint vertical spacing
|
||||||
if (this._maxRowSpacing !== -1 && vSpacing > this._maxRowSpacing) {
|
if (this.maxRowSpacing !== -1 && vSpacing > this.maxRowSpacing) {
|
||||||
const extraVSpacing =
|
const extraVSpacing =
|
||||||
(this._maxRowSpacing - this._rowSpacing) * (nRows - 1);
|
(this.maxRowSpacing - this.rowSpacing) * (nRows - 1);
|
||||||
|
|
||||||
vSpacing = this._maxRowSpacing;
|
vSpacing = this.maxRowSpacing;
|
||||||
topEmptySpace +=
|
topEmptySpace +=
|
||||||
Math.max((emptyVSpace - extraVSpacing) / 2, 0);
|
Math.max((emptyVSpace - extraVSpacing) / 2, 0);
|
||||||
}
|
}
|
||||||
@ -668,25 +643,25 @@ var IconGridLayout = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
_getRowPadding(items, itemIndex, childSize, spacing) {
|
_getRowPadding(items, itemIndex, childSize, spacing) {
|
||||||
const nRows = Math.ceil(items.length / this._columnsPerPage);
|
const nRows = Math.ceil(items.length / this.columnsPerPage);
|
||||||
|
|
||||||
let rowAlign = 0;
|
let rowAlign = 0;
|
||||||
const row = Math.floor(itemIndex / this._columnsPerPage);
|
const row = Math.floor(itemIndex / this.columnsPerPage);
|
||||||
|
|
||||||
// Only apply to the last row
|
// Only apply to the last row
|
||||||
if (row < nRows - 1)
|
if (row < nRows - 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
const rowStart = row * this._columnsPerPage;
|
const rowStart = row * this.columnsPerPage;
|
||||||
const rowEnd = Math.min((row + 1) * this._columnsPerPage - 1, items.length - 1);
|
const rowEnd = Math.min((row + 1) * this.columnsPerPage - 1, items.length - 1);
|
||||||
const itemsInThisRow = rowEnd - rowStart + 1;
|
const itemsInThisRow = rowEnd - rowStart + 1;
|
||||||
const nEmpty = this._columnsPerPage - itemsInThisRow;
|
const nEmpty = this.columnsPerPage - itemsInThisRow;
|
||||||
const availableWidth = nEmpty * (spacing + childSize);
|
const availableWidth = nEmpty * (spacing + childSize);
|
||||||
|
|
||||||
const isRtl =
|
const isRtl =
|
||||||
Clutter.get_default_text_direction() === Clutter.TextDirection.RTL;
|
Clutter.get_default_text_direction() === Clutter.TextDirection.RTL;
|
||||||
|
|
||||||
switch (this._lastRowAlign) {
|
switch (this.lastRowAlign) {
|
||||||
case Clutter.ActorAlign.START:
|
case Clutter.ActorAlign.START:
|
||||||
rowAlign = 0;
|
rowAlign = 0;
|
||||||
break;
|
break;
|
||||||
@ -801,11 +776,11 @@ var IconGridLayout = GObject.registerClass({
|
|||||||
pageIndex = swap(pageIndex, this._pages.length);
|
pageIndex = swap(pageIndex, this._pages.length);
|
||||||
|
|
||||||
visibleItems.forEach((item, itemIndex) => {
|
visibleItems.forEach((item, itemIndex) => {
|
||||||
const row = Math.floor(itemIndex / this._columnsPerPage);
|
const row = Math.floor(itemIndex / this.columnsPerPage);
|
||||||
let column = itemIndex % this._columnsPerPage;
|
let column = itemIndex % this.columnsPerPage;
|
||||||
|
|
||||||
if (isRtl)
|
if (isRtl)
|
||||||
column = swap(column, this._columnsPerPage);
|
column = swap(column, this.columnsPerPage);
|
||||||
|
|
||||||
const rowPadding = this._getRowPadding(visibleItems, itemIndex,
|
const rowPadding = this._getRowPadding(visibleItems, itemIndex,
|
||||||
childSize, hSpacing);
|
childSize, hSpacing);
|
||||||
@ -1060,11 +1035,11 @@ var IconGridLayout = GObject.registerClass({
|
|||||||
return [null, DragLocation.INVALID];
|
return [null, DragLocation.INVALID];
|
||||||
|
|
||||||
const gridWidth =
|
const gridWidth =
|
||||||
childSize * this._columnsPerPage +
|
childSize * this.columnsPerPage +
|
||||||
hSpacing * (this._columnsPerPage - 1);
|
hSpacing * (this.columnsPerPage - 1);
|
||||||
const gridHeight =
|
const gridHeight =
|
||||||
childSize * this._rowsPerPage +
|
childSize * this.rowsPerPage +
|
||||||
vSpacing * (this._rowsPerPage - 1);
|
vSpacing * (this.rowsPerPage - 1);
|
||||||
|
|
||||||
if (x > leftEmptySpace + gridWidth || y > topEmptySpace + gridHeight)
|
if (x > leftEmptySpace + gridWidth || y > topEmptySpace + gridHeight)
|
||||||
return [null, DragLocation.INVALID];
|
return [null, DragLocation.INVALID];
|
||||||
@ -1115,186 +1090,15 @@ var IconGridLayout = GObject.registerClass({
|
|||||||
return [null, DragLocation.EMPTY_SPACE];
|
return [null, DragLocation.EMPTY_SPACE];
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
get allow_incomplete_pages() {
|
|
||||||
return this._allowIncompletePages;
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
set allow_incomplete_pages(v) {
|
|
||||||
if (this._allowIncompletePages === v)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this._allowIncompletePages = v;
|
|
||||||
this.notify('allow-incomplete-pages');
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
get column_spacing() {
|
|
||||||
return this._columnSpacing;
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
set column_spacing(v) {
|
|
||||||
if (this._columnSpacing === v)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this._columnSpacing = v;
|
|
||||||
this.notify('column-spacing');
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
get columns_per_page() {
|
|
||||||
return this._columnsPerPage;
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
set columns_per_page(v) {
|
|
||||||
if (this._columnsPerPage === v)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this._columnsPerPage = v;
|
|
||||||
this.notify('columns-per-page');
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
get fixed_icon_size() {
|
|
||||||
return this._fixedIconSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
set fixed_icon_size(v) {
|
|
||||||
if (this._fixedIconSize === v)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this._fixedIconSize = v;
|
|
||||||
this.notify('fixed-icon-size');
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
get icon_size() {
|
get icon_size() {
|
||||||
return this._iconSize;
|
return this._iconSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
get last_row_align() {
|
|
||||||
return this._lastRowAlign;
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
get max_column_spacing() {
|
|
||||||
return this._maxColumnSpacing;
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
set max_column_spacing(v) {
|
|
||||||
if (this._maxColumnSpacing === v)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this._maxColumnSpacing = v;
|
|
||||||
this.notify('max-column-spacing');
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
get max_row_spacing() {
|
|
||||||
return this._maxRowSpacing;
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
set max_row_spacing(v) {
|
|
||||||
if (this._maxRowSpacing === v)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this._maxRowSpacing = v;
|
|
||||||
this.notify('max-row-spacing');
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
set last_row_align(v) {
|
|
||||||
if (this._lastRowAlign === v)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this._lastRowAlign = v;
|
|
||||||
this.notify('last-row-align');
|
|
||||||
}
|
|
||||||
|
|
||||||
get nPages() {
|
get nPages() {
|
||||||
return this._pages.length;
|
return this._pages.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
get page_halign() {
|
|
||||||
return this._pageHAlign;
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
set page_halign(v) {
|
|
||||||
if (this._pageHAlign === v)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this._pageHAlign = v;
|
|
||||||
this.notify('page-halign');
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
get page_padding() {
|
|
||||||
return this._pagePadding;
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
set page_padding(padding) {
|
|
||||||
if (this._pagePadding.top === padding.top &&
|
|
||||||
this._pagePadding.right === padding.right &&
|
|
||||||
this._pagePadding.bottom === padding.bottom &&
|
|
||||||
this._pagePadding.left === padding.left)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this._pagePadding = padding;
|
|
||||||
this.notify('page-padding');
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
get page_valign() {
|
|
||||||
return this._pageVAlign;
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
set page_valign(v) {
|
|
||||||
if (this._pageVAlign === v)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this._pageVAlign = v;
|
|
||||||
this.notify('page-valign');
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
get row_spacing() {
|
|
||||||
return this._rowSpacing;
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
set row_spacing(v) {
|
|
||||||
if (this._rowSpacing === v)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this._rowSpacing = v;
|
|
||||||
this.notify('row-spacing');
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
get rows_per_page() {
|
|
||||||
return this._rowsPerPage;
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
set rows_per_page(v) {
|
|
||||||
if (this._rowsPerPage === v)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this._rowsPerPage = v;
|
|
||||||
this.notify('rows-per-page');
|
|
||||||
}
|
|
||||||
|
|
||||||
get orientation() {
|
get orientation() {
|
||||||
return this._orientation;
|
return this._orientation;
|
||||||
}
|
}
|
||||||
|
@ -35,16 +35,13 @@ var RadialShaderEffect = GObject.registerClass({
|
|||||||
},
|
},
|
||||||
}, class RadialShaderEffect extends Shell.GLSLEffect {
|
}, class RadialShaderEffect extends Shell.GLSLEffect {
|
||||||
_init(params) {
|
_init(params) {
|
||||||
this._brightness = undefined;
|
|
||||||
this._sharpness = undefined;
|
|
||||||
|
|
||||||
super._init(params);
|
super._init(params);
|
||||||
|
|
||||||
this._brightnessLocation = this.get_uniform_location('brightness');
|
this._brightnessLocation = this.get_uniform_location('brightness');
|
||||||
this._sharpnessLocation = this.get_uniform_location('vignette_sharpness');
|
this._sharpnessLocation = this.get_uniform_location('vignette_sharpness');
|
||||||
|
|
||||||
this.brightness = 1.0;
|
this._setBrightnessUniform();
|
||||||
this.sharpness = 0.0;
|
this._setSharpnessUniform();
|
||||||
}
|
}
|
||||||
|
|
||||||
vfunc_build_pipeline() {
|
vfunc_build_pipeline() {
|
||||||
@ -52,30 +49,14 @@ var RadialShaderEffect = GObject.registerClass({
|
|||||||
VIGNETTE_DECLARATIONS, VIGNETTE_CODE, true);
|
VIGNETTE_DECLARATIONS, VIGNETTE_CODE, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
get brightness() {
|
_setBrightnessUniform() {
|
||||||
return this._brightness;
|
|
||||||
}
|
|
||||||
|
|
||||||
set brightness(v) {
|
|
||||||
if (this._brightness == v)
|
|
||||||
return;
|
|
||||||
this._brightness = v;
|
|
||||||
this.set_uniform_float(this._brightnessLocation,
|
this.set_uniform_float(this._brightnessLocation,
|
||||||
1, [this._brightness]);
|
1, [this.brightness]);
|
||||||
this.notify('brightness');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get sharpness() {
|
_setSharpnessUniform() {
|
||||||
return this._sharpness;
|
|
||||||
}
|
|
||||||
|
|
||||||
set sharpness(v) {
|
|
||||||
if (this._sharpness == v)
|
|
||||||
return;
|
|
||||||
this._sharpness = v;
|
|
||||||
this.set_uniform_float(this._sharpnessLocation,
|
this.set_uniform_float(this._sharpnessLocation,
|
||||||
1, [this._sharpness]);
|
1, [this.sharpness]);
|
||||||
this.notify('sharpness');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -369,7 +369,6 @@ var Notification = GObject.registerClass({
|
|||||||
this.isTransient = false;
|
this.isTransient = false;
|
||||||
this.privacyScope = PrivacyScope.USER;
|
this.privacyScope = PrivacyScope.USER;
|
||||||
this.forFeedback = false;
|
this.forFeedback = false;
|
||||||
this._acknowledged = false;
|
|
||||||
this.bannerBodyText = null;
|
this.bannerBodyText = null;
|
||||||
this.bannerBodyMarkup = false;
|
this.bannerBodyMarkup = false;
|
||||||
this._soundName = null;
|
this._soundName = null;
|
||||||
@ -438,17 +437,6 @@ var Notification = GObject.registerClass({
|
|||||||
this.actions.push({ label, callback });
|
this.actions.push({ label, callback });
|
||||||
}
|
}
|
||||||
|
|
||||||
get acknowledged() {
|
|
||||||
return this._acknowledged;
|
|
||||||
}
|
|
||||||
|
|
||||||
set acknowledged(v) {
|
|
||||||
if (this._acknowledged == v)
|
|
||||||
return;
|
|
||||||
this._acknowledged = v;
|
|
||||||
this.notify('acknowledged');
|
|
||||||
}
|
|
||||||
|
|
||||||
setUrgency(urgency) {
|
setUrgency(urgency) {
|
||||||
this.urgency = urgency;
|
this.urgency = urgency;
|
||||||
}
|
}
|
||||||
|
@ -307,16 +307,6 @@ var PadDiagram = GObject.registerClass({
|
|||||||
super._init(params);
|
super._init(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
get left_handed() {
|
|
||||||
return this._leftHanded;
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
|
||||||
set left_handed(leftHanded) {
|
|
||||||
this._leftHanded = leftHanded;
|
|
||||||
}
|
|
||||||
|
|
||||||
get image() {
|
get image() {
|
||||||
return this._imagePath;
|
return this._imagePath;
|
||||||
}
|
}
|
||||||
@ -404,8 +394,7 @@ var PadDiagram = GObject.registerClass({
|
|||||||
istream.add_bytes(new GLib.Bytes(svgData));
|
istream.add_bytes(new GLib.Bytes(svgData));
|
||||||
|
|
||||||
return Rsvg.Handle.new_from_stream_sync(istream,
|
return Rsvg.Handle.new_from_stream_sync(istream,
|
||||||
Gio.File.new_for_path(this._imagePath),
|
Gio.File.new_for_path(this._imagePath), 0, null);
|
||||||
0, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateDiagramScale() {
|
_updateDiagramScale() {
|
||||||
@ -471,7 +460,7 @@ var PadDiagram = GObject.registerClass({
|
|||||||
cr.save();
|
cr.save();
|
||||||
cr.translate(width / 2, height / 2);
|
cr.translate(width / 2, height / 2);
|
||||||
cr.scale(this._scale, this._scale);
|
cr.scale(this._scale, this._scale);
|
||||||
if (this._leftHanded)
|
if (this.leftHanded)
|
||||||
cr.rotate(Math.PI);
|
cr.rotate(Math.PI);
|
||||||
cr.translate(-dimensions.width / 2, -dimensions.height / 2);
|
cr.translate(-dimensions.width / 2, -dimensions.height / 2);
|
||||||
this._handle.render_cairo(cr);
|
this._handle.render_cairo(cr);
|
||||||
@ -500,7 +489,7 @@ var PadDiagram = GObject.registerClass({
|
|||||||
else
|
else
|
||||||
direction = RTL;
|
direction = RTL;
|
||||||
|
|
||||||
if (this._leftHanded) {
|
if (this.leftHanded) {
|
||||||
direction = 1 - direction;
|
direction = 1 - direction;
|
||||||
pos.x = this._imageWidth - pos.x;
|
pos.x = this._imageWidth - pos.x;
|
||||||
pos.y = this._imageHeight - pos.y;
|
pos.y = this._imageHeight - pos.y;
|
||||||
|
@ -53,37 +53,11 @@ const TouchpadSwipeGesture = GObject.registerClass({
|
|||||||
this._touchpadSettings = new Gio.Settings({
|
this._touchpadSettings = new Gio.Settings({
|
||||||
schema_id: 'org.gnome.desktop.peripherals.touchpad',
|
schema_id: 'org.gnome.desktop.peripherals.touchpad',
|
||||||
});
|
});
|
||||||
this._orientation = Clutter.Orientation.VERTICAL;
|
|
||||||
this._enabled = true;
|
|
||||||
|
|
||||||
this._stageCaptureEvent =
|
this._stageCaptureEvent =
|
||||||
global.stage.connect('captured-event::touchpad', this._handleEvent.bind(this));
|
global.stage.connect('captured-event::touchpad', this._handleEvent.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
get enabled() {
|
|
||||||
return this._enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
set enabled(enabled) {
|
|
||||||
if (this._enabled === enabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this._enabled = enabled;
|
|
||||||
this.notify('enabled');
|
|
||||||
}
|
|
||||||
|
|
||||||
get orientation() {
|
|
||||||
return this._orientation;
|
|
||||||
}
|
|
||||||
|
|
||||||
set orientation(orientation) {
|
|
||||||
if (this._orientation === orientation)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this._orientation = orientation;
|
|
||||||
this.notify('orientation');
|
|
||||||
}
|
|
||||||
|
|
||||||
_handleEvent(actor, event) {
|
_handleEvent(actor, event) {
|
||||||
if (event.type() !== Clutter.EventType.TOUCHPAD_SWIPE)
|
if (event.type() !== Clutter.EventType.TOUCHPAD_SWIPE)
|
||||||
return Clutter.EVENT_PROPAGATE;
|
return Clutter.EVENT_PROPAGATE;
|
||||||
@ -103,7 +77,7 @@ const TouchpadSwipeGesture = GObject.registerClass({
|
|||||||
let [dx, dy] = event.get_gesture_motion_delta();
|
let [dx, dy] = event.get_gesture_motion_delta();
|
||||||
|
|
||||||
let delta;
|
let delta;
|
||||||
if (this._orientation === Clutter.Orientation.VERTICAL)
|
if (this.orientation === Clutter.Orientation.VERTICAL)
|
||||||
delta = dy / TOUCHPAD_BASE_HEIGHT;
|
delta = dy / TOUCHPAD_BASE_HEIGHT;
|
||||||
else
|
else
|
||||||
delta = dx / TOUCHPAD_BASE_WIDTH;
|
delta = dx / TOUCHPAD_BASE_WIDTH;
|
||||||
@ -162,7 +136,6 @@ const TouchSwipeGesture = GObject.registerClass({
|
|||||||
|
|
||||||
this._allowedModes = allowedModes;
|
this._allowedModes = allowedModes;
|
||||||
this._distance = global.screen_height;
|
this._distance = global.screen_height;
|
||||||
this._orientation = Clutter.Orientation.VERTICAL;
|
|
||||||
|
|
||||||
global.display.connect('grab-op-begin', () => {
|
global.display.connect('grab-op-begin', () => {
|
||||||
this.cancel();
|
this.cancel();
|
||||||
@ -183,18 +156,6 @@ const TouchSwipeGesture = GObject.registerClass({
|
|||||||
this.notify('distance');
|
this.notify('distance');
|
||||||
}
|
}
|
||||||
|
|
||||||
get orientation() {
|
|
||||||
return this._orientation;
|
|
||||||
}
|
|
||||||
|
|
||||||
set orientation(orientation) {
|
|
||||||
if (this._orientation === orientation)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this._orientation = orientation;
|
|
||||||
this.notify('orientation');
|
|
||||||
}
|
|
||||||
|
|
||||||
vfunc_gesture_prepare(actor) {
|
vfunc_gesture_prepare(actor) {
|
||||||
if (!super.vfunc_gesture_prepare(actor))
|
if (!super.vfunc_gesture_prepare(actor))
|
||||||
return false;
|
return false;
|
||||||
@ -207,7 +168,7 @@ const TouchSwipeGesture = GObject.registerClass({
|
|||||||
let [x, y] = this.get_motion_coords(0);
|
let [x, y] = this.get_motion_coords(0);
|
||||||
|
|
||||||
this._lastPosition =
|
this._lastPosition =
|
||||||
this._orientation === Clutter.Orientation.VERTICAL ? y : x;
|
this.orientation === Clutter.Orientation.VERTICAL ? y : x;
|
||||||
|
|
||||||
this.emit('begin', time, xPress, yPress);
|
this.emit('begin', time, xPress, yPress);
|
||||||
return true;
|
return true;
|
||||||
@ -215,7 +176,7 @@ const TouchSwipeGesture = GObject.registerClass({
|
|||||||
|
|
||||||
vfunc_gesture_progress(_actor) {
|
vfunc_gesture_progress(_actor) {
|
||||||
let [x, y] = this.get_motion_coords(0);
|
let [x, y] = this.get_motion_coords(0);
|
||||||
let pos = this._orientation === Clutter.Orientation.VERTICAL ? y : x;
|
let pos = this.orientation === Clutter.Orientation.VERTICAL ? y : x;
|
||||||
|
|
||||||
let delta = pos - this._lastPosition;
|
let delta = pos - this._lastPosition;
|
||||||
this._lastPosition = pos;
|
this._lastPosition = pos;
|
||||||
@ -262,7 +223,6 @@ const ScrollGesture = GObject.registerClass({
|
|||||||
this._allowedModes = allowedModes;
|
this._allowedModes = allowedModes;
|
||||||
this._began = false;
|
this._began = false;
|
||||||
this._enabled = true;
|
this._enabled = true;
|
||||||
this._orientation = Clutter.Orientation.VERTICAL;
|
|
||||||
|
|
||||||
actor.connect('scroll-event', this._handleEvent.bind(this));
|
actor.connect('scroll-event', this._handleEvent.bind(this));
|
||||||
}
|
}
|
||||||
@ -281,18 +241,6 @@ const ScrollGesture = GObject.registerClass({
|
|||||||
this.notify('enabled');
|
this.notify('enabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
get orientation() {
|
|
||||||
return this._orientation;
|
|
||||||
}
|
|
||||||
|
|
||||||
set orientation(orientation) {
|
|
||||||
if (this._orientation === orientation)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this._orientation = orientation;
|
|
||||||
this.notify('orientation');
|
|
||||||
}
|
|
||||||
|
|
||||||
canHandleEvent(event) {
|
canHandleEvent(event) {
|
||||||
if (event.type() !== Clutter.EventType.SCROLL)
|
if (event.type() !== Clutter.EventType.SCROLL)
|
||||||
return false;
|
return false;
|
||||||
@ -332,7 +280,7 @@ const ScrollGesture = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
let delta;
|
let delta;
|
||||||
if (this._orientation === Clutter.Orientation.VERTICAL)
|
if (this.orientation === Clutter.Orientation.VERTICAL)
|
||||||
delta = dy / TOUCHPAD_BASE_HEIGHT;
|
delta = dy / TOUCHPAD_BASE_HEIGHT;
|
||||||
else
|
else
|
||||||
delta = dx / TOUCHPAD_BASE_WIDTH;
|
delta = dx / TOUCHPAD_BASE_WIDTH;
|
||||||
@ -401,7 +349,6 @@ var SwipeTracker = GObject.registerClass({
|
|||||||
|
|
||||||
this._allowedModes = allowedModes;
|
this._allowedModes = allowedModes;
|
||||||
this._enabled = true;
|
this._enabled = true;
|
||||||
this._orientation = Clutter.Orientation.VERTICAL;
|
|
||||||
this._distance = global.screen_height;
|
this._distance = global.screen_height;
|
||||||
|
|
||||||
this._reset();
|
this._reset();
|
||||||
@ -481,18 +428,6 @@ var SwipeTracker = GObject.registerClass({
|
|||||||
this.notify('enabled');
|
this.notify('enabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
get orientation() {
|
|
||||||
return this._orientation;
|
|
||||||
}
|
|
||||||
|
|
||||||
set orientation(orientation) {
|
|
||||||
if (this._orientation === orientation)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this._orientation = orientation;
|
|
||||||
this.notify('orientation');
|
|
||||||
}
|
|
||||||
|
|
||||||
get distance() {
|
get distance() {
|
||||||
return this._distance;
|
return this._distance;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user