mirror of
https://github.com/morgan9e/dash-to-panel
synced 2026-04-14 00:04:17 +09:00
refactor: port away from Mainloop
This commit is contained in:
17
appIcons.js
17
appIcons.js
@@ -23,6 +23,7 @@
|
||||
|
||||
|
||||
import Clutter from 'gi://Clutter';
|
||||
import Gio from 'gi://GLib';
|
||||
import Gio from 'gi://Gio';
|
||||
import Graphene from 'gi://Graphene';
|
||||
import GObject from 'gi://GObject';
|
||||
@@ -47,8 +48,6 @@ import * as Progress from './progress.js';
|
||||
import {DTP_EXTENSION, SETTINGS, DESKTOPSETTINGS, EXTENSION_PATH} from './extension.js';
|
||||
import {gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js';
|
||||
|
||||
const Mainloop = imports.mainloop;
|
||||
|
||||
//timeout names
|
||||
const T2 = 'mouseScrollTimeout';
|
||||
const T3 = 'showDotsTimeout';
|
||||
@@ -1336,9 +1335,10 @@ export function cycleThroughWindows(app, reversed, shouldMinimize, monitor) {
|
||||
app_windows.push("MINIMIZE");
|
||||
|
||||
if (recentlyClickedAppLoopId > 0)
|
||||
Mainloop.source_remove(recentlyClickedAppLoopId);
|
||||
GLib.Source.remove(recentlyClickedAppLoopId);
|
||||
|
||||
recentlyClickedAppLoopId = Mainloop.timeout_add(MEMORY_TIME, resetRecentlyClickedApp);
|
||||
recentlyClickedAppLoopId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
|
||||
MEMORY_TIME, resetRecentlyClickedApp);
|
||||
|
||||
// If there isn't already a list of windows for the current app,
|
||||
// or the stored list is outdated, use the current windows list.
|
||||
@@ -1368,7 +1368,7 @@ export function cycleThroughWindows(app, reversed, shouldMinimize, monitor) {
|
||||
|
||||
export function resetRecentlyClickedApp() {
|
||||
if (recentlyClickedAppLoopId > 0)
|
||||
Mainloop.source_remove(recentlyClickedAppLoopId);
|
||||
GLib.Source.remove(recentlyClickedAppLoopId);
|
||||
|
||||
recentlyClickedAppLoopId=0;
|
||||
recentlyClickedApp =null;
|
||||
@@ -1491,9 +1491,12 @@ export class TaskbarSecondaryMenu extends AppMenu.AppMenu {
|
||||
|
||||
if (windows.length == this._app.get_windows().length)
|
||||
this._app.request_quit()
|
||||
|
||||
GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
|
||||
windows.forEach((w) => !!w.get_compositor_private() && w.delete(time++));
|
||||
|
||||
Mainloop.idle_add(() =>
|
||||
windows.forEach((w) => !!w.get_compositor_private() && w.delete(time++)))
|
||||
return GLib.SOURCE_REMOVE;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
36
prefs.js
36
prefs.js
@@ -32,8 +32,6 @@ import * as Pos from './panelPositions.js';
|
||||
|
||||
import {ExtensionPreferences, gettext as _, ngettext} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
|
||||
|
||||
const Mainloop = imports.mainloop;
|
||||
|
||||
const SCALE_UPDATE_TIMEOUT = 500;
|
||||
const DEFAULT_PANEL_SIZES = [ 128, 96, 64, 48, 32, 24, 16 ];
|
||||
const DEFAULT_FONT_SIZES = [ 96, 64, 48, 32, 24, 16, 0 ];
|
||||
@@ -2225,9 +2223,9 @@ const BuilderScope = GObject.registerClass({
|
||||
panel_size_scale_value_changed_cb(scale) {
|
||||
// Avoid settings the size continuously
|
||||
if (this._preferences._panel_size_timeout > 0)
|
||||
Mainloop.source_remove(this._preferences._panel_size_timeout);
|
||||
GLib.Source.remove(this._preferences._panel_size_timeout);
|
||||
|
||||
this._preferences._panel_size_timeout = Mainloop.timeout_add(SCALE_UPDATE_TIMEOUT, (() => {
|
||||
this._preferences._panel_size_timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, SCALE_UPDATE_TIMEOUT, () => {
|
||||
const value = scale.get_value();
|
||||
const monitorSync = this._preferences._settings.get_boolean('panel-element-positions-monitors-sync');
|
||||
const monitorsToSetFor = monitorSync ? this._preferences.monitors : [this._preferences._currentMonitorIndex];
|
||||
@@ -2237,15 +2235,15 @@ const BuilderScope = GObject.registerClass({
|
||||
|
||||
this._preferences._panel_size_timeout = 0;
|
||||
return GLib.SOURCE_REMOVE;
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
tray_size_scale_value_changed_cb(scale) {
|
||||
// Avoid settings the size consinuosly
|
||||
if (this._preferences._tray_size_timeout > 0)
|
||||
Mainloop.source_remove(this._preferences._tray_size_timeout);
|
||||
GLib.Source.remove(this._preferences._tray_size_timeout);
|
||||
|
||||
this._preferences._tray_size_timeout = Mainloop.timeout_add(SCALE_UPDATE_TIMEOUT, () => {
|
||||
this._preferences._tray_size_timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, SCALE_UPDATE_TIMEOUT, () => {)
|
||||
this._preferences._settings.set_int('tray-size', scale.get_value());
|
||||
this._preferences._tray_size_timeout = 0;
|
||||
return GLib.SOURCE_REMOVE;
|
||||
@@ -2255,9 +2253,9 @@ const BuilderScope = GObject.registerClass({
|
||||
leftbox_size_scale_value_changed_cb(scale) {
|
||||
// Avoid settings the size consinuosly
|
||||
if (this._preferences._leftbox_size_timeout > 0)
|
||||
Mainloop.source_remove(this._preferences._leftbox_size_timeout);
|
||||
GLib.Source.remove(this._preferences._leftbox_size_timeout);
|
||||
|
||||
this._preferences._leftbox_size_timeout = Mainloop.timeout_add(SCALE_UPDATE_TIMEOUT, () => {
|
||||
this._preferences._leftbox_size_timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, SCALE_UPDATE_TIMEOUT, () => {
|
||||
this._preferences._settings.set_int('leftbox-size', scale.get_value());
|
||||
this._preferences._leftbox_size_timeout = 0;
|
||||
return GLib.SOURCE_REMOVE;
|
||||
@@ -2267,9 +2265,9 @@ const BuilderScope = GObject.registerClass({
|
||||
appicon_margin_scale_value_changed_cb(scale) {
|
||||
// Avoid settings the size consinuosly
|
||||
if (this._preferences._appicon_margin_timeout > 0)
|
||||
Mainloop.source_remove(this._preferences._appicon_margin_timeout);
|
||||
GLib.Source.remove(this._preferences._appicon_margin_timeout);
|
||||
|
||||
this._preferences._appicon_margin_timeout = Mainloop.timeout_add(SCALE_UPDATE_TIMEOUT, () => {
|
||||
this._preferences._appicon_margin_timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, SCALE_UPDATE_TIMEOUT, () => {
|
||||
this._preferences._settings.set_int('appicon-margin', scale.get_value());
|
||||
this._preferences._appicon_margin_timeout = 0;
|
||||
return GLib.SOURCE_REMOVE;
|
||||
@@ -2279,9 +2277,9 @@ const BuilderScope = GObject.registerClass({
|
||||
appicon_padding_scale_value_changed_cb(scale) {
|
||||
// Avoid settings the size consinuosly
|
||||
if (this._preferences._appicon_padding_timeout > 0)
|
||||
Mainloop.source_remove(this._preferences._appicon_padding_timeout);
|
||||
GLib.Source.remove(this._preferences._appicon_padding_timeout);
|
||||
|
||||
this._preferences._appicon_padding_timeout = Mainloop.timeout_add(SCALE_UPDATE_TIMEOUT, () => {
|
||||
this._preferences._appicon_padding_timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, SCALE_UPDATE_TIMEOUT, () => {
|
||||
this._preferences._settings.set_int('appicon-padding', scale.get_value());
|
||||
this._preferences._appicon_padding_timeout = 0;
|
||||
return GLib.SOURCE_REMOVE;
|
||||
@@ -2291,9 +2289,9 @@ const BuilderScope = GObject.registerClass({
|
||||
tray_padding_scale_value_changed_cb(scale) {
|
||||
// Avoid settings the size consinuosly
|
||||
if (this._preferences._tray_padding_timeout > 0)
|
||||
Mainloop.source_remove(this._preferences._tray_padding_timeout);
|
||||
GLib.Source.remove(this._preferences._tray_padding_timeout);
|
||||
|
||||
this._preferences._tray_padding_timeout = Mainloop.timeout_add(SCALE_UPDATE_TIMEOUT, () => {
|
||||
this._preferences._tray_padding_timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, SCALE_UPDATE_TIMEOUT, () => {
|
||||
this._preferences._settings.set_int('tray-padding', scale.get_value());
|
||||
this._preferences._tray_padding_timeout = 0;
|
||||
return GLib.SOURCE_REMOVE;
|
||||
@@ -2303,9 +2301,9 @@ const BuilderScope = GObject.registerClass({
|
||||
statusicon_padding_scale_value_changed_cb(scale) {
|
||||
// Avoid settings the size consinuosly
|
||||
if (this._preferences._statusicon_padding_timeout > 0)
|
||||
Mainloop.source_remove(this._preferences._statusicon_padding_timeout);
|
||||
GLib.Source.remove(this._preferences._statusicon_padding_timeout);
|
||||
|
||||
this._preferences._statusicon_padding_timeout = Mainloop.timeout_add(SCALE_UPDATE_TIMEOUT, () => {
|
||||
this._preferences._statusicon_padding_timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, SCALE_UPDATE_TIMEOUT, () => {
|
||||
this._preferences._settings.set_int('status-icon-padding', scale.get_value());
|
||||
this._preferences._statusicon_padding_timeout = 0;
|
||||
return GLib.SOURCE_REMOVE;
|
||||
@@ -2315,9 +2313,9 @@ const BuilderScope = GObject.registerClass({
|
||||
leftbox_padding_scale_value_changed_cb(scale) {
|
||||
// Avoid settings the size consinuosly
|
||||
if (this._preferences._leftbox_padding_timeout > 0)
|
||||
Mainloop.source_remove(this._preferences._leftbox_padding_timeout);
|
||||
GLib.Source.remove(this._preferences._leftbox_padding_timeout);
|
||||
|
||||
this._preferences._leftbox_padding_timeout = Mainloop.timeout_add(SCALE_UPDATE_TIMEOUT, () => {
|
||||
this._preferences._leftbox_padding_timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, SCALE_UPDATE_TIMEOUT, () => {
|
||||
this._preferences._settings.set_int('leftbox-padding', scale.get_value());
|
||||
this._preferences._leftbox_padding_timeout = 0;
|
||||
return GLib.SOURCE_REMOVE;
|
||||
|
||||
12
taskbar.js
12
taskbar.js
@@ -44,7 +44,6 @@ import * as Utils from './utils.js';
|
||||
import * as WindowPreview from './windowPreview.js';
|
||||
import {SETTINGS} from './extension.js';
|
||||
|
||||
const Mainloop = imports.mainloop;
|
||||
const SearchController = Main.overview.searchController;
|
||||
|
||||
export const DASH_ANIMATION_TIME = Dash.DASH_ANIMATION_TIME / (Dash.DASH_ANIMATION_TIME > 1 ? 1000 : 1);
|
||||
@@ -560,9 +559,11 @@ export const Taskbar = class extends EventEmitter {
|
||||
}
|
||||
|
||||
if (initial != this.fullScrollView && !this._waitIdleId) {
|
||||
this._waitIdleId = Mainloop.idle_add(() => {
|
||||
this._waitIdleId = GLib.idle_add(() => {
|
||||
this._getAppIcons().forEach(a => a.updateTitleStyle())
|
||||
this._waitIdleId = 0
|
||||
this._waitIdleId = 0;
|
||||
|
||||
return GLib.SOURCE_REMOVE;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1433,7 +1434,10 @@ export const TaskbarItemContainer = GObject.registerClass({
|
||||
this._raisedClone.connect('destroy', () => {
|
||||
adjustment.disconnect(adjustmentChangedId);
|
||||
taskbarBox.disconnect(taskbarBoxAllocationChangedId);
|
||||
Mainloop.idle_add(() => cloneContainer.destroy());
|
||||
GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
|
||||
cloneContainer.destroy();
|
||||
return GLib.SOURCE_REMOVE;
|
||||
});
|
||||
delete this._raisedClone;
|
||||
});
|
||||
|
||||
|
||||
7
utils.js
7
utils.js
@@ -34,7 +34,6 @@ import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
||||
import * as MessageTray from 'resource:///org/gnome/shell/ui/messageTray.js';
|
||||
|
||||
const Gi = imports._gi;
|
||||
const Mainloop = imports.mainloop;
|
||||
|
||||
var SCROLL_TIME = Util.SCROLL_TIME / (Util.SCROLL_TIME > 1 ? 1000 : 1);
|
||||
|
||||
@@ -165,9 +164,11 @@ export const 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]];
|
||||
@@ -181,7 +182,7 @@ export const TimeoutsHandler = class extends BasicHandler {
|
||||
let name = item[0];
|
||||
|
||||
if (this[name]) {
|
||||
Mainloop.source_remove(this[name]);
|
||||
GLib.Source.remove(this[name]);
|
||||
this[name] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,8 +29,6 @@ import * as Utils from './utils.js';
|
||||
import {SETTINGS, DESKTOPSETTINGS} from './extension.js';
|
||||
import {gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js';
|
||||
|
||||
const Mainloop = imports.mainloop;
|
||||
|
||||
//timeout intervals
|
||||
const ENSURE_VISIBLE_MS = 200;
|
||||
|
||||
@@ -807,12 +805,14 @@ export const Preview = GObject.registerClass({
|
||||
this._addClone(cloneBin, animateSize);
|
||||
this._previewMenu.updatePosition();
|
||||
} else if (!this._waitWindowId) {
|
||||
this._waitWindowId = Mainloop.idle_add(() => {
|
||||
this._waitWindowId = GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
|
||||
this._waitWindowId = 0;
|
||||
|
||||
if (this._previewMenu.opened) {
|
||||
_assignWindowClone();
|
||||
}
|
||||
|
||||
return GLib.SOURCE_REMOVE;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user