From 4710753700551870bba07d2e8a19053b4e058dc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Tue, 16 Apr 2013 16:57:46 +0200 Subject: [PATCH] panel: Pick up spinner icon from CSS In order to use a different spinner image in classic mode (or any other mode specific style), get it from CSS rather than hardcoding a particular image. https://bugzilla.gnome.org/show_bug.cgi?id=693688 --- data/theme/gnome-shell.css | 1 + js/ui/panel.js | 33 +++++++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/data/theme/gnome-shell.css b/data/theme/gnome-shell.css index 954d50a55..c4d49ed42 100644 --- a/data/theme/gnome-shell.css +++ b/data/theme/gnome-shell.css @@ -512,6 +512,7 @@ StScrollBar StButton#vhandle:active { } #appMenu { + spinner-image: url("process-working.svg"); spacing: 4px; } diff --git a/js/ui/panel.js b/js/ui/panel.js index 49f176939..303e24169 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -258,6 +258,7 @@ const AppMenuButton = new Lang.Class({ this._actionGroupNotifyId = 0; let bin = new St.Bin({ name: 'appMenu' }); + bin.connect('style-changed', Lang.bind(this, this._onStyleChanged)); this.actor.add_actor(bin); this.actor.bind_property("reactive", this.actor, "can-focus", 0); @@ -297,11 +298,7 @@ const AppMenuButton = new Lang.Class({ this._stop = true; - let spinnerIcon = global.datadir + '/theme/process-working.svg'; - this._spinner = new AnimatedIcon(spinnerIcon, PANEL_ICON_SIZE); - this._container.add_actor(this._spinner.actor); - this._spinner.actor.hide(); - this._spinner.actor.lower_bottom(); + this._spinner = null; let tracker = Shell.WindowTracker.get_default(); let appSys = Shell.AppSystem.get_default(); @@ -354,6 +351,18 @@ const AppMenuButton = new Lang.Class({ onCompleteScope: this }); }, + _onStyleChanged: function(actor) { + let node = actor.get_theme_node(); + let [success, icon] = node.lookup_url('spinner-image', false); + if (!success || this._spinnerIcon == icon) + return; + this._spinnerIcon = icon; + this._spinner = new AnimatedIcon(this._spinnerIcon, PANEL_ICON_SIZE); + this._container.add_actor(this._spinner.actor); + this._spinner.actor.hide(); + this._spinner.actor.lower_bottom(); + }, + _onIconBoxStyleChanged: function() { let node = this._iconBox.get_theme_node(); this._iconBottomClip = node.get_length('app-icon-bottom-clip'); @@ -385,6 +394,10 @@ const AppMenuButton = new Lang.Class({ this._stop = true; this.actor.reactive = true; + + if (this._spinner == null) + return; + Tweener.addTween(this._spinner.actor, { opacity: 0, time: SPINNER_ANIMATION_TIME, @@ -401,6 +414,10 @@ const AppMenuButton = new Lang.Class({ startAnimation: function() { this._stop = false; this.actor.reactive = false; + + if (this._spinner == null) + return; + this._spinner.play(); this._spinner.actor.show(); }, @@ -463,6 +480,9 @@ const AppMenuButton = new Lang.Class({ } this._label.actor.allocate(childBox, flags); + if (this._spinner == null) + return; + if (direction == Clutter.TextDirection.LTR) { childBox.x1 = Math.floor(iconWidth / 2) + this._label.actor.width; childBox.x2 = childBox.x1 + this._spinner.actor.width; @@ -553,7 +573,8 @@ const AppMenuButton = new Lang.Class({ return; } - this._spinner.actor.hide(); + if (this._spinner) + this._spinner.actor.hide(); if (this._iconBox.child != null) this._iconBox.child.destroy(); this._iconBox.hide();