diff options
author | Timur Kristóf <venemo@msn.com> | 2011-05-03 22:45:02 +0200 |
---|---|---|
committer | Timur Kristóf <venemo@msn.com> | 2011-05-03 22:45:02 +0200 |
commit | da76684517fa1a25642f55a8df932fb7b8ce3642 (patch) | |
tree | d815b414b1417430edb0fd4bc94055cfb6613ddc /extension.js | |
parent | ee2d4a4b05bb942ae5bd3ea84dd8a654d4f4f4f6 (diff) | |
download | gnome-shell-extension-fedora-logo-da76684517fa1a25642f55a8df932fb7b8ce3642.tar.gz gnome-shell-extension-fedora-logo-da76684517fa1a25642f55a8df932fb7b8ce3642.tar.xz gnome-shell-extension-fedora-logo-da76684517fa1a25642f55a8df932fb7b8ce3642.zip |
Now the extension adds an St.Icon instead of messing with the CSS.
This is useful because now it works with various other shell themes.
Diffstat (limited to 'extension.js')
-rw-r--r-- | extension.js | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/extension.js b/extension.js index 69095aa..2b8465a 100644 --- a/extension.js +++ b/extension.js @@ -1,5 +1,5 @@ -// Extension to display a Fedora logo on Activities button +// Gnome Shell extension to display a Fedora logo on Activities button // Copyright (C) 2011 by Timur Kristóf <venemo@msn.com> @@ -29,7 +29,8 @@ const Main = imports.ui.main; // This is for debugging purposes function _debugStuff() { - let text = new St.Label({ text: Main.panel.button.get_style(), style: 'font-size: 10px; background: #000000; color: #ffffff;' }); + // If you are debugging, change 'text' to whatever you want to check + let text = new St.Label({ text: 'text', style: 'font-size: 10px; background: #000000; color: #ffffff;' }); let monitor = global.get_primary_monitor(); global.stage.add_actor(text); text.set_position(Math.floor (monitor.width / 2 - text.width / 2), Math.floor(monitor.height / 2 - text.height / 2)); @@ -43,22 +44,21 @@ function main() { //Main.panel.actor.set_direction(St.TextDirection.RTL); // Getting the old style and using it as a base if it's not null - let oldStyle = Main.panel.button.get_style(); - let newStyle = ''; - if (oldStyle != null) - newStyle = oldStyle; + let label = Main.panel.button.get_child(); + let logo = new St.Icon({ icon_type: St.IconType.FULLCOLOR, icon_size: label.height, icon_name: 'fedora-logo-icon' }); + let box = new St.BoxLayout(); + Main.panel.button.set_child(box); + + box.add_actor(logo); + box.add_actor(label); // Let's care about both RTL and LTR directions let currentDirection = Main.panel.actor.get_direction(); - if (currentDirection == St.TextDirection.LTR) { - newStyle += ' padding-left: 36px; background-image: url(/usr/share/icons/hicolor/24x24/apps/fedora-logo-icon.png); background-position: 8px 0px;'; + logo.set_style('padding-right: 10px;'); } else if (currentDirection == St.TextDirection.RTL) { - newStyle += ' padding-right: 36px; background-image: url(/usr/share/icons/hicolor/24x24/apps/fedora-logo-icon.png); background-position: ' + Main.panel.button.width + 'px 0px;'; + logo.set_style('padding-left: 10px;'); } - - // Setting the new style to the button - Main.panel.button.set_style(newStyle); } |