diff options
Diffstat (limited to 'extension.js')
-rw-r--r-- | extension.js | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/extension.js b/extension.js new file mode 100644 index 0000000..69095aa --- /dev/null +++ b/extension.js @@ -0,0 +1,64 @@ + +// Extension to display a Fedora logo on Activities button + +// Copyright (C) 2011 by Timur Kristóf <venemo@msn.com> + +/* Licensed under the MIT license (copied from the http://en.wikipedia.org/wiki/MIT_License site) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. */ + +const St = imports.gi.St; +const Mainloop = imports.mainloop; +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;' }); + 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)); + Mainloop.timeout_add(3000, function () { text.destroy(); }); +} + +// Extension initialization code - adding the Fedora logo :) +function main() { + // The following lines can be used for debugging purposes + //Main.panel.button.connect('button-release-event', _debugStuff); + //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'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;'; + } + 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;'; + } + + // Setting the new style to the button + Main.panel.button.set_style(newStyle); +} + |