animationUtils: Group together various animation helpers

The environment module is used to initialize the environment, yet it
currently also defines the adjustAnimationTime() function.

Ideally it should not export any utility functions, in particular
once converted to ESM.

The function cannot be moved to the existing Utils module, as that
depends on an initialized environment, and can therefore not be
imported from environment.js, so use that opportunity to group
together several animation helpers in a new animationUtils module.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2822>
This commit is contained in:
Evan Welsh
2023-07-09 21:58:21 -07:00
parent 3c9857abad
commit 87d1248dc1
11 changed files with 136 additions and 112 deletions

View File

@ -13,7 +13,7 @@ const MessageList = imports.ui.messageList;
const MessageTray = imports.ui.messageTray;
const Mpris = imports.ui.mpris;
const PopupMenu = imports.ui.popupMenu;
const Util = imports.misc.util;
const {ensureActorVisibleInScrollView} = imports.misc.animationUtils;
const {formatDateWithCFormatString, formatTimeSpan} = imports.misc.dateUtils;
const {loadInterfaceXML} = imports.misc.fileUtils;
@ -1016,7 +1016,7 @@ class CalendarMessageList extends St.Widget {
'notify::can-clear', this._sync.bind(this),
'destroy', () => this._sectionList.remove_actor(section),
'message-focused', (_s, messageActor) => {
Util.ensureActorVisibleInScrollView(this._scrollView, messageActor);
ensureActorVisibleInScrollView(this._scrollView, messageActor);
}, this);
this._sectionList.add_actor(section);
}

View File

@ -13,7 +13,7 @@ const Dialog = imports.ui.dialog;
const ModalDialog = imports.ui.modalDialog;
const ShellEntry = imports.ui.shellEntry;
const CheckBox = imports.ui.checkBox;
const Util = imports.misc.util;
const {wiggle} = imports.misc.animationUtils;
var KeyringDialog = GObject.registerClass(
class KeyringDialog extends ModalDialog.ModalDialog {
@ -83,7 +83,7 @@ class KeyringDialog extends ModalDialog.ModalDialog {
});
this.prompt.connect('notify::warning', () => {
if (this._passwordEntry && this.prompt.warning !== '')
Util.wiggle(this._passwordEntry);
wiggle(this._passwordEntry);
});
warningBox.add_child(warning);

View File

@ -16,7 +16,7 @@ const Main = imports.ui.main;
const ModalDialog = imports.ui.modalDialog;
const ShellEntry = imports.ui.shellEntry;
const UserWidget = imports.ui.userWidget;
const Util = imports.misc.util;
const {wiggle} = imports.misc.animationUtils;
const DialogMode = {
AUTH: 0,
@ -267,7 +267,7 @@ var AuthenticationDialog = GObject.registerClass({
this._infoMessageLabel.hide();
this._nullMessageLabel.hide();
Util.wiggle(this._passwordEntry);
wiggle(this._passwordEntry);
}
/* Try and authenticate again */

View File

@ -44,6 +44,7 @@ const Shell = imports.gi.Shell;
const St = imports.gi.St;
const Gettext = imports.gettext;
const SignalTracker = imports.misc.signalTracker;
const {adjustAnimationTime} = imports.misc.animationUtils;
Gio._promisify(Gio.DataInputStream.prototype, 'fill_async');
Gio._promisify(Gio.DataInputStream.prototype, 'read_line_async');
@ -389,17 +390,3 @@ function init() {
// Prevent extensions from opening a display connection to ourselves
Gdk.set_allowed_backends('');
}
// adjustAnimationTime:
// @msecs: time in milliseconds
//
// Adjust @msecs to account for St's enable-animations
// and slow-down-factor settings
function adjustAnimationTime(msecs) {
let settings = St.Settings.get();
if (!settings.enable_animations)
return 0;
return settings.slow_down_factor * msecs;
}

View File

@ -22,7 +22,7 @@ const MessageTray = imports.ui.messageTray;
const ShellDBus = imports.ui.shellDBus;
const SmartcardManager = imports.misc.smartcardManager;
const { adjustAnimationTime } = imports.ui.environment;
const {adjustAnimationTime} = imports.misc.animationUtils;
const SCREENSAVER_SCHEMA = 'org.gnome.desktop.screensaver';
const LOCK_ENABLED_KEY = 'lock-enabled';

View File

@ -14,7 +14,7 @@ const IconGrid = imports.ui.iconGrid;
const Main = imports.ui.main;
const ParentalControlsManager = imports.misc.parentalControlsManager;
const RemoteSearch = imports.ui.remoteSearch;
const Util = imports.misc.util;
const {ensureActorVisibleInScrollView} = imports.misc.animationUtils;
const { Highlighter } = imports.misc.util;
@ -746,7 +746,7 @@ var SearchResultsView = GObject.registerClass({
}
_focusChildChanged(provider) {
Util.ensureActorVisibleInScrollView(this._scrollView, provider.focusChild);
ensureActorVisibleInScrollView(this._scrollView, provider.focusChild);
}
_ensureProviderDisplay(provider) {
@ -877,7 +877,7 @@ var SearchResultsView = GObject.registerClass({
if (selected) {
result.add_style_pseudo_class('selected');
Util.ensureActorVisibleInScrollView(this._scrollView, result);
ensureActorVisibleInScrollView(this._scrollView, result);
} else {
result.remove_style_pseudo_class('selected');
}

View File

@ -19,7 +19,7 @@ const Params = imports.misc.params;
const ShellEntry = imports.ui.shellEntry;
const { loadInterfaceXML } = imports.misc.fileUtils;
const Util = imports.misc.util;
const {wiggle} = imports.misc.animationUtils;
var LIST_ITEM_ICON_SIZE = 48;
var WORK_SPINNER_ICON_SIZE = 16;
@ -421,7 +421,7 @@ var ShellMountPasswordDialog = GObject.registerClass({
this._errorMessageLabel.text = _('Sorry, that didnt work. Please try again.');
this._errorMessageLabel.opacity = 255;
Util.wiggle(this._passwordEntry);
wiggle(this._passwordEntry);
}
_onCancelButton() {