Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GNOME 45 support - ESM porting #2070

Merged
merged 3 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ overrides:
- code: 110
ignoreUrls: true
ignoreTemplateLiterals: true

parserOptions:
sourceType: module
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ EXTRA_MODULES = \
appIcons.js \
appIconIndicators.js \
fileManager1API.js \
imports.js \
launcherAPI.js \
locations.js \
locationsWorker.js \
Expand Down Expand Up @@ -126,6 +127,7 @@ _build: all
-rm -fR ./_build
mkdir -p _build
cp $(BASE_MODULES) $(EXTRA_MODULES) _build
cp -a dependencies _build
cp stylesheet.css _build
mkdir -p _build/media
cd media ; cp $(EXTRA_MEDIA) ../_build/media/
Expand Down
114 changes: 56 additions & 58 deletions appIconIndicators.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
/* exported AppIconIndicator */

const { cairo: Cairo } = imports;
const { main: Main } = imports.ui;

const {
import {
Clutter,
GdkPixbuf,
Gio,
GObject,
Pango,
St,
} = imports.gi;
St
} from './dependencies/gi.js';

import {Main} from './dependencies/shell/ui.js';

const Me = imports.misc.extensionUtils.getCurrentExtension();
const {
docking: Docking,
utils: Utils,
} = Me.imports;
import {
Docking,
Utils
} from './imports.js';

const {cairo: Cairo} = imports;

const RunningIndicatorStyle = Object.freeze({
DEFAULT: 0,
Expand All @@ -38,19 +36,19 @@ const MAX_WINDOWS_CLASSES = 4;
* obtained by composing the desired classes below based on the settings.
*
*/
var AppIconIndicator = class DashToDockAppIconIndicator {
export class AppIconIndicator {
constructor(source) {
this._indicators = [];

// Choose the style for the running indicators
let runningIndicator = null;
let runningIndicatorStyle;

const { settings } = Docking.DockManager;
const {settings} = Docking.DockManager;
if (settings.applyCustomTheme)
runningIndicatorStyle = RunningIndicatorStyle.DOTS;
else
({ runningIndicatorStyle } = settings);
({runningIndicatorStyle} = settings);

if (settings.showIconsEmblems &&
!Docking.DockManager.getDefault().notificationsMonitor.dndMode) {
Expand Down Expand Up @@ -114,12 +112,12 @@ var AppIconIndicator = class DashToDockAppIconIndicator {
indicator.destroy();
}
}
};
}

/*
* Base class to be inherited by all indicators of any kind
*/
var IndicatorBase = class DashToDockIndicatorBase {
class IndicatorBase {
constructor(source) {
this._source = source;
this._signalsHandler = new Utils.GlobalSignalsHandler(this._source);
Expand All @@ -133,14 +131,14 @@ var IndicatorBase = class DashToDockIndicatorBase {
this._signalsHandler.destroy();
this._signalsHandler = null;
}
};
}

/*
* A base indicator class for running style, from which all other EunningIndicators should derive,
* providing some basic methods, variables definitions and their update, css style classes handling.
*
*/
var RunningIndicatorBase = class DashToDockRunningIndicatorBase extends IndicatorBase {
class RunningIndicatorBase extends IndicatorBase {
constructor(source) {
super(source);

Expand Down Expand Up @@ -224,11 +222,11 @@ var RunningIndicatorBase = class DashToDockRunningIndicatorBase extends Indicato

super.destroy();
}
};
}

// We add a css class so third parties themes can limit their indicaor customization
// to the case we do nothing
var RunningIndicatorDefault = class DashToDockRunningIndicatorDefault extends RunningIndicatorBase {
class RunningIndicatorDefault extends RunningIndicatorBase {
constructor(source) {
super(source);
this._source.add_style_class_name('default');
Expand All @@ -238,9 +236,9 @@ var RunningIndicatorDefault = class DashToDockRunningIndicatorDefault extends Ru
this._source.remove_style_class_name('default');
super.destroy();
}
};
}

var IndicatorDrawingArea = GObject.registerClass(
const IndicatorDrawingArea = GObject.registerClass(
class IndicatorDrawingArea extends St.DrawingArea {
vfunc_allocate(box) {
if (box.x1 !== 0 || box.y1 !== 0)
Expand All @@ -256,7 +254,7 @@ class IndicatorDrawingArea extends St.DrawingArea {
}
});

var RunningIndicatorDots = class DashToDockRunningIndicatorDots extends RunningIndicatorBase {
class RunningIndicatorDots extends RunningIndicatorBase {
constructor(source) {
super(source);

Expand Down Expand Up @@ -311,7 +309,8 @@ var RunningIndicatorDots = class DashToDockRunningIndicatorDots extends RunningI
// Apply glossy background
// TODO: move to enable/disableBacklit to apply itonly to the running apps?
// TODO: move to css class for theming support
this._glossyBackgroundStyle = `background-image: url('${Me.path}/media/glossy.svg');` +
const {extension} = Docking.DockManager;
this._glossyBackgroundStyle = `background-image: url('${extension.path}/media/glossy.svg');` +
'background-size: contain;';
}

Expand Down Expand Up @@ -350,7 +349,7 @@ var RunningIndicatorDots = class DashToDockRunningIndicatorDots extends RunningI
this._borderWidth = themeNode.get_border_width(this._side);
this._bodyColor = themeNode.get_background_color();

const { settings } = Docking.DockManager;
const {settings} = Docking.DockManager;
if (!settings.applyCustomTheme) {
// Adjust for the backlit case
if (settings.unityBacklitItems) {
Expand Down Expand Up @@ -431,11 +430,11 @@ var RunningIndicatorDots = class DashToDockRunningIndicatorDots extends RunningI
this._area.destroy();
super.destroy();
}
};
}

// Adapted from dash-to-panel by Jason DeRose
// https://github.com/jderose9/dash-to-panel
var RunningIndicatorCiliora = class DashToDockRunningIndicatorCiliora extends RunningIndicatorDots {
class RunningIndicatorCiliora extends RunningIndicatorDots {
_drawIndicator(cr) {
if (this._source.running) {
const size = Math.max(this._width / 20, this._borderWidth);
Expand Down Expand Up @@ -464,11 +463,11 @@ var RunningIndicatorCiliora = class DashToDockRunningIndicatorCiliora extends Ru
cr.fill();
}
}
};
}

// Adapted from dash-to-panel by Jason DeRose
// https://github.com/jderose9/dash-to-panel
var RunningIndicatorSegmented = class DashToDockRunningIndicatorSegmented extends RunningIndicatorDots {
class RunningIndicatorSegmented extends RunningIndicatorDots {
_drawIndicator(cr) {
if (this._source.running) {
const size = Math.max(this._width / 20, this._borderWidth);
Expand All @@ -495,11 +494,11 @@ var RunningIndicatorSegmented = class DashToDockRunningIndicatorSegmented extend
cr.fill();
}
}
};
}

// Adapted from dash-to-panel by Jason DeRose
// https://github.com/jderose9/dash-to-panel
var RunningIndicatorSolid = class DashToDockRunningIndicatorSolid extends RunningIndicatorDots {
class RunningIndicatorSolid extends RunningIndicatorDots {
_drawIndicator(cr) {
if (this._source.running) {
const size = Math.max(this._width / 20, this._borderWidth);
Expand All @@ -522,11 +521,11 @@ var RunningIndicatorSolid = class DashToDockRunningIndicatorSolid extends Runnin
cr.fill();
}
}
};
}

// Adapted from dash-to-panel by Jason DeRose
// https://github.com/jderose9/dash-to-panel
var RunningIndicatorSquares = class DashToDockRunningIndicatorSquares extends RunningIndicatorDots {
class RunningIndicatorSquares extends RunningIndicatorDots {
_drawIndicator(cr) {
if (this._source.running) {
const size = Math.max(this._width / 11, this._borderWidth);
Expand All @@ -550,11 +549,11 @@ var RunningIndicatorSquares = class DashToDockRunningIndicatorSquares extends Ru
cr.fill();
}
}
};
}

// Adapted from dash-to-panel by Jason DeRose
// https://github.com/jderose9/dash-to-panel
var RunningIndicatorDashes = class DashToDockRunningIndicatorDashes extends RunningIndicatorDots {
class RunningIndicatorDashes extends RunningIndicatorDots {
_drawIndicator(cr) {
if (this._source.running) {
const size = Math.max(this._width / 20, this._borderWidth);
Expand All @@ -580,11 +579,11 @@ var RunningIndicatorDashes = class DashToDockRunningIndicatorDashes extends Runn
cr.fill();
}
}
};
}

// Adapted from dash-to-panel by Jason DeRose
// https://github.com/jderose9/dash-to-panel
var RunningIndicatorMetro = class DashToDockRunningIndicatorMetro extends RunningIndicatorDots {
class RunningIndicatorMetro extends RunningIndicatorDots {
constructor(source) {
super(source);
this._source.add_style_class_name('metro');
Expand Down Expand Up @@ -637,9 +636,9 @@ var RunningIndicatorMetro = class DashToDockRunningIndicatorMetro extends Runnin
}
}
}
};
}

var RunningIndicatorBinary = class DashToDockRunningIndicatorBinary extends RunningIndicatorDots {
class RunningIndicatorBinary extends RunningIndicatorDots {
_drawIndicator(cr) {
// Draw the required numbers of dots
const n = Math.min(15, this._source.windowsCount);
Expand Down Expand Up @@ -672,12 +671,12 @@ var RunningIndicatorBinary = class DashToDockRunningIndicatorBinary extends Runn
cr.fill();
}
}
};
}

/*
* Unity like notification and progress indicators
*/
var UnityIndicator = class DashToDockUnityIndicator extends IndicatorBase {
class UnityIndicator extends IndicatorBase {
constructor(source) {
super(source);

Expand All @@ -695,7 +694,7 @@ var UnityIndicator = class DashToDockUnityIndicator extends IndicatorBase {
this._source._iconContainer.add_child(this._notificationBadgeBin);
this.updateNotificationBadgeStyle();

const { remoteModel, notificationsMonitor } = Docking.DockManager.getDefault();
const {remoteModel, notificationsMonitor} = Docking.DockManager.getDefault();
const remoteEntry = remoteModel.lookupById(this._source.app.id);
this._remoteEntry = remoteEntry;

Expand All @@ -706,12 +705,12 @@ var UnityIndicator = class DashToDockUnityIndicator extends IndicatorBase {
], [
remoteEntry,
['progress-changed', 'progress-visible-changed'],
(sender, { progress, progress_visible: progressVisible }) =>
(sender, {progress, progress_visible: progressVisible}) =>
this.setProgress(progressVisible ? progress : -1),
], [
remoteEntry,
'urgent-changed',
(sender, { urgent }) => this.setUrgent(urgent),
(sender, {urgent}) => this.setUrgent(urgent),
], [
notificationsMonitor,
'changed',
Expand Down Expand Up @@ -742,7 +741,7 @@ var UnityIndicator = class DashToDockUnityIndicator extends IndicatorBase {
const fontDesc = themeContext.get_font();
const defaultFontSize = fontDesc.get_size() / 1024;
let fontSize = defaultFontSize * 0.9;
const { iconSize } = Main.overview.dash;
const {iconSize} = Main.overview.dash;
const defaultIconSize = Docking.DockManager.settings.get_default_value(
'dash-max-icon-size').unpack();

Expand Down Expand Up @@ -799,7 +798,7 @@ var UnityIndicator = class DashToDockUnityIndicator extends IndicatorBase {
return;
}

const { notificationsMonitor } = Docking.DockManager.getDefault();
const {notificationsMonitor} = Docking.DockManager.getDefault();
const notificationsCount = notificationsMonitor.getAppNotificationsCount(
this._source.app.id);

Expand All @@ -822,7 +821,7 @@ var UnityIndicator = class DashToDockUnityIndicator extends IndicatorBase {
return;
}

this._progressOverlayArea = new St.DrawingArea({ x_expand: true, y_expand: true });
this._progressOverlayArea = new St.DrawingArea({x_expand: true, y_expand: true});
this._progressOverlayArea.add_style_class_name('progress-bar');
this._progressOverlayArea.connect('repaint', () => {
this._drawProgressOverlay(this._progressOverlayArea);
Expand All @@ -842,7 +841,7 @@ var UnityIndicator = class DashToDockUnityIndicator extends IndicatorBase {
}

_drawProgressOverlay(area) {
const { scaleFactor } = St.ThemeContext.get_for_stage(global.stage);
const {scaleFactor} = St.ThemeContext.get_for_stage(global.stage);
const [surfaceWidth, surfaceHeight] = area.get_surface_size();
const cr = area.get_context();

Expand Down Expand Up @@ -894,11 +893,11 @@ var UnityIndicator = class DashToDockUnityIndicator extends IndicatorBase {

[hasColor, bg] = node.lookup_color('-progress-bar-background', false);
if (!hasColor)
bg = new Clutter.Color({ red: 204, green: 204, blue: 204, alpha: 255 });
bg = new Clutter.Color({red: 204, green: 204, blue: 204, alpha: 255});

[hasColor, bd] = node.lookup_color('-progress-bar-border', false);
if (!hasColor)
bd = new Clutter.Color({ red: 230, green: 230, blue: 230, alpha: 255 });
bd = new Clutter.Color({red: 230, green: 230, blue: 230, alpha: 255});

stroke = Cairo.SolidPattern.createRGBA(
bd.red / 255, bd.green / 255, bd.blue / 255, bd.alpha / 255);
Expand Down Expand Up @@ -935,7 +934,7 @@ var UnityIndicator = class DashToDockUnityIndicator extends IndicatorBase {
else
delete this._isUrgent;
}
};
}


// Global icon cache. Used for Unity7 styling.
Expand All @@ -951,7 +950,7 @@ const DOMINANT_COLOR_ICON_SIZE = 64;

// Compute dominant color frim the app icon.
// The color is cached for efficiency.
var DominantColorExtractor = class DashToDockDominantColorExtractor {
class DominantColorExtractor {
constructor(app) {
this._app = app;
}
Expand Down Expand Up @@ -982,11 +981,10 @@ var DominantColorExtractor = class DashToDockDominantColorExtractor {
const iconNames = iconTexture.get_names();
const iconInfo = themeLoader.choose_icon(iconNames, DOMINANT_COLOR_ICON_SIZE, 0);

if (iconInfo) {
if (iconInfo)
return iconInfo.load_icon();
} else {
else
return null;
}
}

// Use GdkPixBuf to load the pixel buffer from memory
Expand Down Expand Up @@ -1124,4 +1122,4 @@ var DominantColorExtractor = class DashToDockDominantColorExtractor {

return resampledPixels;
}
};
}
Loading
Loading