mirror of
https://github.com/morgan9e/dash-to-panel
synced 2026-04-15 00:34:05 +09:00
refactor: port away from Mainloop
This commit is contained in:
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;
|
||||
|
||||
Reference in New Issue
Block a user