Bump to version 65.2
This commit is contained in:
@@ -21,27 +21,24 @@
|
||||
* Some code was also adapted from the upstream Gnome Shell source code.
|
||||
*/
|
||||
|
||||
const Clutter = imports.gi.Clutter;
|
||||
const GdkPixbuf = imports.gi.GdkPixbuf;
|
||||
const Gi = imports._gi;
|
||||
const Gio = imports.gi.Gio;
|
||||
const GLib = imports.gi.GLib;
|
||||
const Gtk = imports.gi.Gtk;
|
||||
const Meta = imports.gi.Meta;
|
||||
const Shell = imports.gi.Shell;
|
||||
const St = imports.gi.St;
|
||||
const Mainloop = imports.mainloop;
|
||||
const Config = imports.misc.config;
|
||||
const Util = imports.misc.util;
|
||||
const Main = imports.ui.main;
|
||||
const MessageTray = imports.ui.messageTray;
|
||||
import Clutter from 'gi://Clutter';
|
||||
import Cogl from 'gi://Cogl';
|
||||
import GdkPixbuf from 'gi://GdkPixbuf';
|
||||
import Gio from 'gi://Gio';
|
||||
import GLib from 'gi://GLib';
|
||||
import Graphene from 'gi://Graphene';
|
||||
import Meta from 'gi://Meta';
|
||||
import Shell from 'gi://Shell';
|
||||
import St from 'gi://St';
|
||||
import * as Util from 'resource:///org/gnome/shell/misc/util.js';
|
||||
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
||||
import * as MessageTray from 'resource:///org/gnome/shell/ui/messageTray.js';
|
||||
|
||||
var TRANSLATION_DOMAIN = imports.misc.extensionUtils.getCurrentExtension().metadata['gettext-domain'];
|
||||
var SCROLL_TIME = Util.SCROLL_TIME / (Util.SCROLL_TIME > 1 ? 1000 : 1);
|
||||
const SCROLL_TIME = Util.SCROLL_TIME / (Util.SCROLL_TIME > 1 ? 1000 : 1);
|
||||
|
||||
// simplify global signals and function injections handling
|
||||
// abstract class
|
||||
var BasicHandler = class {
|
||||
export const BasicHandler = class {
|
||||
|
||||
constructor() {
|
||||
this._storage = new Object();
|
||||
@@ -101,7 +98,7 @@ var BasicHandler = class {
|
||||
}
|
||||
|
||||
// Manage global signals
|
||||
var GlobalSignalsHandler = class extends BasicHandler {
|
||||
export const GlobalSignalsHandler = class extends BasicHandler {
|
||||
|
||||
_create(item) {
|
||||
let handlers = [];
|
||||
@@ -134,7 +131,7 @@ var GlobalSignalsHandler = class extends BasicHandler {
|
||||
* Manage function injection: both instances and prototype can be overridden
|
||||
* and restored
|
||||
*/
|
||||
var InjectionsHandler = class extends BasicHandler {
|
||||
export const InjectionsHandler = class extends BasicHandler {
|
||||
|
||||
_create(item) {
|
||||
let object = item[0];
|
||||
@@ -157,7 +154,7 @@ var InjectionsHandler = class extends BasicHandler {
|
||||
/**
|
||||
* Manage timeouts: the added timeouts have their id reset on completion
|
||||
*/
|
||||
var TimeoutsHandler = class extends BasicHandler {
|
||||
export const TimeoutsHandler = class extends BasicHandler {
|
||||
|
||||
_create(item) {
|
||||
let name = item[0];
|
||||
@@ -166,9 +163,11 @@ var TimeoutsHandler = class extends BasicHandler {
|
||||
|
||||
this._remove(item);
|
||||
|
||||
this[name] = Mainloop.timeout_add(delay, () => {
|
||||
this[name] = GLib.timeout_add(GLib.PRIORITY_DEFAULT, delay, () => {
|
||||
this[name] = 0;
|
||||
timeoutHandler();
|
||||
|
||||
return GLib.SOURCE_REMOVE;
|
||||
});
|
||||
|
||||
return [[name]];
|
||||
@@ -182,7 +181,7 @@ var TimeoutsHandler = class extends BasicHandler {
|
||||
let name = item[0];
|
||||
|
||||
if (this[name]) {
|
||||
Mainloop.source_remove(this[name]);
|
||||
GLib.Source.remove(this[name]);
|
||||
this[name] = 0;
|
||||
}
|
||||
}
|
||||
@@ -194,7 +193,7 @@ var TimeoutsHandler = class extends BasicHandler {
|
||||
|
||||
// This is wrapper to maintain compatibility with GNOME-Shell 3.30+ as well as
|
||||
// previous versions.
|
||||
var DisplayWrapper = {
|
||||
export const DisplayWrapper = {
|
||||
getScreen() {
|
||||
return global.screen || global.display;
|
||||
},
|
||||
@@ -209,7 +208,7 @@ var DisplayWrapper = {
|
||||
};
|
||||
|
||||
let unredirectEnabled = true
|
||||
var setDisplayUnredirect = (enable) => {
|
||||
export const setDisplayUnredirect = (enable) => {
|
||||
if (enable && !unredirectEnabled)
|
||||
Meta.enable_unredirect_for_display(global.display);
|
||||
else if (!enable && unredirectEnabled)
|
||||
@@ -218,40 +217,34 @@ var setDisplayUnredirect = (enable) => {
|
||||
unredirectEnabled = enable;
|
||||
};
|
||||
|
||||
var getSystemMenuInfo = function() {
|
||||
if (Config.PACKAGE_VERSION < '43')
|
||||
return {
|
||||
name: 'aggregateMenu',
|
||||
constructor: imports.ui.panel.AggregateMenu
|
||||
};
|
||||
|
||||
export const getSystemMenuInfo = function() {
|
||||
return {
|
||||
name: 'quickSettings',
|
||||
constructor: imports.ui.panel.QuickSettings
|
||||
constructor: Main.panel.statusArea.quickSettings.constructor
|
||||
};
|
||||
}
|
||||
|
||||
var getCurrentWorkspace = function() {
|
||||
export const getCurrentWorkspace = function() {
|
||||
return DisplayWrapper.getWorkspaceManager().get_active_workspace();
|
||||
};
|
||||
|
||||
var getWorkspaceByIndex = function(index) {
|
||||
export const getWorkspaceByIndex = function(index) {
|
||||
return DisplayWrapper.getWorkspaceManager().get_workspace_by_index(index);
|
||||
};
|
||||
|
||||
var getWorkspaceCount = function() {
|
||||
export const getWorkspaceCount = function() {
|
||||
return DisplayWrapper.getWorkspaceManager().n_workspaces;
|
||||
};
|
||||
|
||||
var getStageTheme = function() {
|
||||
export const getStageTheme = function() {
|
||||
return St.ThemeContext.get_for_stage(global.stage);
|
||||
};
|
||||
|
||||
var getScaleFactor = function() {
|
||||
export const getScaleFactor = function() {
|
||||
return getStageTheme().scale_factor || 1;
|
||||
};
|
||||
|
||||
var findIndex = function(array, predicate) {
|
||||
export const findIndex = function(array, predicate) {
|
||||
if (array) {
|
||||
if (Array.prototype.findIndex) {
|
||||
return array.findIndex(predicate);
|
||||
@@ -267,7 +260,7 @@ var findIndex = function(array, predicate) {
|
||||
return -1;
|
||||
};
|
||||
|
||||
var find = function(array, predicate) {
|
||||
export const find = function(array, predicate) {
|
||||
let index = findIndex(array, predicate);
|
||||
|
||||
if (index > -1) {
|
||||
@@ -275,8 +268,8 @@ var find = function(array, predicate) {
|
||||
}
|
||||
};
|
||||
|
||||
var mergeObjects = function(main, bck) {
|
||||
for (var prop in bck) {
|
||||
export const mergeObjects = function(main, bck) {
|
||||
for (const prop in bck) {
|
||||
if (!main.hasOwnProperty(prop) && bck.hasOwnProperty(prop)) {
|
||||
main[prop] = bck[prop];
|
||||
}
|
||||
@@ -285,24 +278,14 @@ var mergeObjects = function(main, bck) {
|
||||
return main;
|
||||
};
|
||||
|
||||
var hookVfunc = function(proto, symbol, func) {
|
||||
if (!func) return
|
||||
|
||||
if (Gi.gobject_prototype_symbol && proto[Gi.gobject_prototype_symbol]) {
|
||||
proto[Gi.gobject_prototype_symbol][Gi.hook_up_vfunc_symbol] (symbol, func);
|
||||
} else {
|
||||
proto[Gi.hook_up_vfunc_symbol] (symbol, func);
|
||||
}
|
||||
};
|
||||
|
||||
var getTrackedActorData = (actor) => {
|
||||
export const getTrackedActorData = (actor) => {
|
||||
let trackedIndex = Main.layoutManager._findActor(actor);
|
||||
|
||||
if (trackedIndex >= 0)
|
||||
return Main.layoutManager._trackedActors[trackedIndex]
|
||||
}
|
||||
|
||||
var getTransformedAllocation = function(actor) {
|
||||
export const getTransformedAllocation = function(actor) {
|
||||
let extents = actor.get_transformed_extents();
|
||||
let topLeft = extents.get_top_left();
|
||||
let bottomRight = extents.get_bottom_right();
|
||||
@@ -310,13 +293,13 @@ var getTransformedAllocation = function(actor) {
|
||||
return { x1: topLeft.x, x2: bottomRight.x, y1: topLeft.y, y2: bottomRight.y };
|
||||
};
|
||||
|
||||
var setClip = function(actor, x, y, width, height) {
|
||||
export const setClip = function(actor, x, y, width, height) {
|
||||
actor.set_clip(0, 0, width, height);
|
||||
actor.set_position(x, y);
|
||||
actor.set_size(width, height);
|
||||
};
|
||||
|
||||
var addKeybinding = function(key, settings, handler, modes) {
|
||||
export const addKeybinding = function(key, settings, handler, modes) {
|
||||
if (!Main.wm._allowedKeybindings[key]) {
|
||||
Main.wm.addKeybinding(
|
||||
key,
|
||||
@@ -328,19 +311,19 @@ var addKeybinding = function(key, settings, handler, modes) {
|
||||
}
|
||||
};
|
||||
|
||||
var removeKeybinding = function(key) {
|
||||
export const removeKeybinding = function(key) {
|
||||
if (Main.wm._allowedKeybindings[key]) {
|
||||
Main.wm.removeKeybinding(key);
|
||||
}
|
||||
};
|
||||
|
||||
var getrgbColor = function(color) {
|
||||
color = typeof color === 'string' ? Clutter.color_from_string(color)[1] : color;
|
||||
export const getrgbColor = function(color) {
|
||||
color = typeof color === 'string' ? ColorUtils.color_from_string(color)[1] : color;
|
||||
|
||||
return { red: color.red, green: color.green, blue: color.blue };
|
||||
};
|
||||
|
||||
var getrgbaColor = function(color, alpha, offset) {
|
||||
export const getrgbaColor = function(color, alpha, offset) {
|
||||
if (alpha <= 0) {
|
||||
return 'transparent; ';
|
||||
}
|
||||
@@ -360,14 +343,14 @@ var getrgbaColor = function(color, alpha, offset) {
|
||||
return 'rgba(' + rgb.red + ',' + rgb.green + ',' + rgb.blue + ',' + (Math.floor(alpha * 100) * 0.01) + '); ' ;
|
||||
};
|
||||
|
||||
var checkIfColorIsBright = function(color) {
|
||||
export const checkIfColorIsBright = function(color) {
|
||||
let rgb = getrgbColor(color);
|
||||
let brightness = 0.2126 * rgb.red + 0.7152 * rgb.green + 0.0722 * rgb.blue;
|
||||
|
||||
return brightness > 128;
|
||||
};
|
||||
|
||||
var getMouseScrollDirection = function(event) {
|
||||
export const getMouseScrollDirection = function(event) {
|
||||
let direction;
|
||||
|
||||
switch (event.get_scroll_direction()) {
|
||||
@@ -384,7 +367,7 @@ var getMouseScrollDirection = function(event) {
|
||||
return direction;
|
||||
};
|
||||
|
||||
var checkIfWindowHasTransient = function(window) {
|
||||
export const checkIfWindowHasTransient = function(window) {
|
||||
let hasTransient;
|
||||
|
||||
window.foreach_transient(t => !(hasTransient = true));
|
||||
@@ -392,7 +375,7 @@ var checkIfWindowHasTransient = function(window) {
|
||||
return hasTransient;
|
||||
};
|
||||
|
||||
var activateSiblingWindow = function(windows, direction, startWindow) {
|
||||
export const activateSiblingWindow = function(windows, direction, startWindow) {
|
||||
let windowIndex = windows.indexOf(global.display.focus_window);
|
||||
let nextWindowIndex = windowIndex < 0 ?
|
||||
startWindow ? windows.indexOf(startWindow) : 0 :
|
||||
@@ -409,7 +392,7 @@ var activateSiblingWindow = function(windows, direction, startWindow) {
|
||||
}
|
||||
};
|
||||
|
||||
var animateWindowOpacity = function(window, tweenOpts) {
|
||||
export const animateWindowOpacity = function(window, tweenOpts) {
|
||||
//there currently is a mutter bug with the windowactor opacity, starting with 3.34
|
||||
//https://gitlab.gnome.org/GNOME/mutter/issues/836
|
||||
|
||||
@@ -438,7 +421,7 @@ var animateWindowOpacity = function(window, tweenOpts) {
|
||||
animate(window, tweenOpts);
|
||||
};
|
||||
|
||||
var animate = function(actor, options) {
|
||||
export const animate = function(actor, options) {
|
||||
//the original animations used Tweener instead of Clutter animations, so we
|
||||
//use "time" and "delay" properties defined in seconds, as opposed to Clutter
|
||||
//animations "duration" and "delay" which are defined in milliseconds
|
||||
@@ -471,15 +454,15 @@ var animate = function(actor, options) {
|
||||
actor.ease.apply(actor, params);
|
||||
}
|
||||
|
||||
var isAnimating = function(actor, prop) {
|
||||
export const isAnimating = function(actor, prop) {
|
||||
return !!actor.get_transition(prop);
|
||||
}
|
||||
|
||||
var stopAnimations = function(actor) {
|
||||
export const stopAnimations = function(actor) {
|
||||
actor.remove_all_transitions();
|
||||
}
|
||||
|
||||
var getIndicators = function(delegate) {
|
||||
export const getIndicators = function(delegate) {
|
||||
if (delegate instanceof St.BoxLayout) {
|
||||
return delegate;
|
||||
}
|
||||
@@ -487,11 +470,11 @@ var getIndicators = function(delegate) {
|
||||
return delegate.indicators;
|
||||
}
|
||||
|
||||
var getPoint = function(coords) {
|
||||
return new imports.gi.Graphene.Point(coords);
|
||||
export const getPoint = function(coords) {
|
||||
return new Graphene.Point(coords);
|
||||
}
|
||||
|
||||
var notify = function(text, iconName, action, isTransient) {
|
||||
export const notify = function(text, iconName, action, isTransient) {
|
||||
let source = new MessageTray.SystemNotificationSource();
|
||||
let notification = new MessageTray.Notification(source, 'Dash to Panel', text);
|
||||
let notifyFunc = source.showNotification || source.notify;
|
||||
@@ -522,9 +505,9 @@ var notify = function(text, iconName, action, isTransient) {
|
||||
* it would be clamp to the current one in any case.
|
||||
* Return the amount of shift applied
|
||||
*/
|
||||
var ensureActorVisibleInScrollView = function(scrollView, actor, fadeSize, onComplete) {
|
||||
let vadjustment = scrollView.vscroll.adjustment;
|
||||
let hadjustment = scrollView.hscroll.adjustment;
|
||||
export const ensureActorVisibleInScrollView = function(scrollView, actor, fadeSize, onComplete) {
|
||||
const vadjustment = scrollView.vadjustment;
|
||||
const hadjustment = scrollView.hadjustment;
|
||||
let [vvalue, vlower, vupper, vstepIncrement, vpageIncrement, vpageSize] = vadjustment.get_values();
|
||||
let [hvalue, hlower, hupper, hstepIncrement, hpageIncrement, hpageSize] = hadjustment.get_values();
|
||||
|
||||
@@ -579,7 +562,12 @@ var ensureActorVisibleInScrollView = function(scrollView, actor, fadeSize, onCom
|
||||
/**
|
||||
* ColorUtils is adapted from https://github.com/micheleg/dash-to-dock
|
||||
*/
|
||||
var ColorUtils = {
|
||||
let colorNs = Clutter.Color ? Clutter : Cogl
|
||||
|
||||
export const ColorUtils = {
|
||||
color_from_string: colorNs.color_from_string,
|
||||
Color: colorNs.Color,
|
||||
|
||||
colorLuminance(r, g, b, dlum) {
|
||||
// Darken or brighten color by a fraction dlum
|
||||
// Each rgb value is modified by the same fraction.
|
||||
@@ -690,7 +678,7 @@ const MAX_CACHED_ITEMS = 1000;
|
||||
const BATCH_SIZE_TO_DELETE = 50;
|
||||
const DOMINANT_COLOR_ICON_SIZE = 64;
|
||||
|
||||
var DominantColorExtractor = class {
|
||||
export const DominantColorExtractor = class {
|
||||
|
||||
constructor(app){
|
||||
this._app = app;
|
||||
@@ -701,14 +689,9 @@ var DominantColorExtractor = class {
|
||||
*/
|
||||
_getIconPixBuf() {
|
||||
let iconTexture = this._app.create_icon_texture(16);
|
||||
let isGtk3 = !!Gtk.IconTheme.prototype.set_custom_theme;
|
||||
|
||||
if (themeLoader === null) {
|
||||
let ifaceSettings = new Gio.Settings({ schema: "org.gnome.desktop.interface" });
|
||||
let themeFunc = isGtk3 ? 'set_custom_theme' : 'set_theme_name';
|
||||
|
||||
themeLoader = new Gtk.IconTheme(),
|
||||
themeLoader[themeFunc](ifaceSettings.get_string('icon-theme')); // Make sure the correct theme is loaded
|
||||
themeLoader = new St.IconTheme();
|
||||
}
|
||||
|
||||
// Unable to load the icon texture, use fallback
|
||||
@@ -730,19 +713,11 @@ var DominantColorExtractor = class {
|
||||
|
||||
// Get the pixel buffer from the icon theme
|
||||
if (iconTexture instanceof Gio.ThemedIcon) {
|
||||
let params = [iconTexture.get_names()[0], DOMINANT_COLOR_ICON_SIZE, 0];
|
||||
|
||||
if (!isGtk3) {
|
||||
params.splice(1, 0, null);
|
||||
params.splice(3, 1, 1, 1, 1);
|
||||
}
|
||||
|
||||
let icon_info = themeLoader.lookup_icon.apply(themeLoader, params);
|
||||
let icon_info = themeLoader.lookup_icon(iconTexture.get_names()[0],
|
||||
DOMINANT_COLOR_ICON_SIZE, 0);
|
||||
|
||||
if (icon_info !== null) {
|
||||
if (isGtk3) return icon_info.load_icon();
|
||||
|
||||
return GdkPixbuf.Pixbuf.new_from_file(icon_info.get_file().get_path());
|
||||
return icon_info.load_icon();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -880,7 +855,7 @@ var DominantColorExtractor = class {
|
||||
|
||||
};
|
||||
|
||||
var drawRoundedLine = function(cr, x, y, width, height, isRoundLeft, isRoundRight, stroke, fill) {
|
||||
export const drawRoundedLine = function(cr, x, y, width, height, isRoundLeft, isRoundRight, stroke, fill) {
|
||||
if (height > width) {
|
||||
y += Math.floor((height - width) / 2.0);
|
||||
height = width;
|
||||
@@ -888,8 +863,8 @@ var drawRoundedLine = function(cr, x, y, width, height, isRoundLeft, isRoundRigh
|
||||
|
||||
height = 2.0 * Math.floor(height / 2.0);
|
||||
|
||||
var leftRadius = isRoundLeft ? height / 2.0 : 0.0;
|
||||
var rightRadius = isRoundRight ? height / 2.0 : 0.0;
|
||||
const leftRadius = isRoundLeft ? height / 2.0 : 0.0;
|
||||
const rightRadius = isRoundRight ? height / 2.0 : 0.0;
|
||||
|
||||
cr.moveTo(x + width - rightRadius, y);
|
||||
cr.lineTo(x + leftRadius, y);
|
||||
@@ -912,28 +887,3 @@ var drawRoundedLine = function(cr, x, y, width, height, isRoundLeft, isRoundRigh
|
||||
cr.setSource(stroke);
|
||||
cr.stroke();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an app exists in the system.
|
||||
*/
|
||||
var checkedCommandsMap = new Map();
|
||||
|
||||
function checkIfCommandExists(app) {
|
||||
let answer = checkedCommandsMap.get(app);
|
||||
if (answer === undefined) {
|
||||
// Command is a shell built in, use shell to call it.
|
||||
// Quotes around app value are important. They let command operate
|
||||
// on the whole value, instead of having shell interpret it.
|
||||
let cmd = "sh -c 'command -v \"" + app + "\"'";
|
||||
try {
|
||||
let out = GLib.spawn_command_line_sync(cmd);
|
||||
// out contains 1: stdout, 2: stderr, 3: exit code
|
||||
answer = out[3] == 0;
|
||||
} catch (ex) {
|
||||
answer = false;
|
||||
}
|
||||
|
||||
checkedCommandsMap.set(app, answer);
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user