[gnome-shell/wip/fmuellner/spinner: 29/30] animation: Add dedicated Spinner class



commit 22e21ad7d1a59bcea434e78f9e715f666a055789
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Nov 28 16:41:09 2018 +0100

    animation: Add dedicated Spinner class
    
    We use AnimatedIcon with the same resource all over the place, cut
    down on the duplication by providing a dedicated class.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/316

 js/gdm/authPrompt.js            |  3 +--
 js/ui/animation.js              | 11 +++++++++++
 js/ui/components/keyring.js     |  3 +--
 js/ui/components/polkitAgent.js |  3 +--
 js/ui/status/network.js         |  3 +--
 5 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/js/gdm/authPrompt.js b/js/gdm/authPrompt.js
index a0a4a21d6..fcb1a585b 100644
--- a/js/gdm/authPrompt.js
+++ b/js/gdm/authPrompt.js
@@ -127,8 +127,7 @@ var AuthPrompt = new Lang.Class({
 
         this._initButtons();
 
-        let spinnerIcon = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/process-working.svg');
-        this._spinner = new Animation.AnimatedIcon(spinnerIcon, DEFAULT_BUTTON_WELL_ICON_SIZE);
+        this._spinner = new Animation.Spinner(DEFAULT_BUTTON_WELL_ICON_SIZE);
         this._spinner.actor.opacity = 0;
         this._spinner.actor.show();
         this._defaultButtonWell.add_child(this._spinner.actor);
diff --git a/js/ui/animation.js b/js/ui/animation.js
index fbd2cafdf..ebd7972c1 100644
--- a/js/ui/animation.js
+++ b/js/ui/animation.js
@@ -1,6 +1,7 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 
 const GLib = imports.gi.GLib;
+const Gio = imports.gi.Gio;
 const Lang = imports.lang;
 const Mainloop = imports.mainloop;
 const St = imports.gi.St;
@@ -86,3 +87,13 @@ var AnimatedIcon = new Lang.Class({
         this.parent(file, size, size, ANIMATED_ICON_UPDATE_TIMEOUT);
     }
 });
+
+var Spinner = new Lang.Class({
+    Name: 'Spinner',
+    Extends: AnimatedIcon,
+
+    _init(size) {
+        let file = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/process-working.svg');
+        this.parent(file, size);
+    }
+});
diff --git a/js/ui/components/keyring.js b/js/ui/components/keyring.js
index 3dd58e828..037bc097a 100644
--- a/js/ui/components/keyring.js
+++ b/js/ui/components/keyring.js
@@ -114,8 +114,7 @@ var KeyringDialog = new Lang.Class({
             ShellEntry.addContextMenu(this._passwordEntry, { isPassword: true });
             this._passwordEntry.clutter_text.connect('activate', this._onPasswordActivate.bind(this));
 
-            let spinnerIcon = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/process-working.svg');
-            this._workSpinner = new Animation.AnimatedIcon(spinnerIcon, WORK_SPINNER_ICON_SIZE);
+            this._workSpinner = new Animation.Spinner(WORK_SPINNER_ICON_SIZE);
             this._workSpinner.actor.opacity = 0;
 
             if (rtl) {
diff --git a/js/ui/components/polkitAgent.js b/js/ui/components/polkitAgent.js
index 7a0682c4b..4bcbe30e7 100644
--- a/js/ui/components/polkitAgent.js
+++ b/js/ui/components/polkitAgent.js
@@ -117,8 +117,7 @@ var AuthenticationDialog = new Lang.Class({
         this._passwordBox.add(this._passwordEntry,
                               { expand: true });
 
-        let spinnerIcon = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/process-working.svg');
-        this._workSpinner = new Animation.AnimatedIcon(spinnerIcon, WORK_SPINNER_ICON_SIZE);
+        this._workSpinner = new Animation.Spinner(WORK_SPINNER_ICON_SIZE);
         this._workSpinner.actor.opacity = 0;
 
         this._passwordBox.add(this._workSpinner.actor);
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index d5567dc3c..92a00301b 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -865,8 +865,7 @@ var NMWirelessDialog = new Lang.Class({
                                                  x_align: Clutter.ActorAlign.CENTER,
                                                  y_align: Clutter.ActorAlign.CENTER });
 
-        let file = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/process-working.svg');
-        this._noNetworksSpinner = new Animation.AnimatedIcon(file, 16, 16);
+        this._noNetworksSpinner = new Animation.Spinner(16);
         this._noNetworksBox.add_actor(this._noNetworksSpinner.actor);
         this._noNetworksBox.add_actor(new St.Label({ style_class: 'no-networks-label',
                                                      text: _("No Networks") }));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]