From ee2d4a4b05bb942ae5bd3ea84dd8a654d4f4f4f6 Mon Sep 17 00:00:00 2001 From: Timur Kristóf Date: Tue, 3 May 2011 22:44:10 +0200 Subject: Initial commit --- LICENSE | 24 ++++++++++++++++++++++ README | 28 ++++++++++++++++++++++++++ extension.js | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ metadata.json | 1 + 4 files changed, 117 insertions(+) create mode 100644 LICENSE create mode 100644 README create mode 100644 extension.js create mode 100644 metadata.json diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0944be7 --- /dev/null +++ b/LICENSE @@ -0,0 +1,24 @@ + +fedora-logo-gnome-shell-extension +Gnome Shell extension to display a Fedora logo on Activities button +Copyright (C) 2011 by Timur Kristóf + +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. diff --git a/README b/README new file mode 100644 index 0000000..6f56072 --- /dev/null +++ b/README @@ -0,0 +1,28 @@ +Readme for fedora-logo-gnome-shell-extension +---------- + +This is a gnome-shell extension that adds a Fedora logo +to the Activities button of the shell. +(On right-to-left locales it appears on the top right corner, +otherwise on the top left corner.) + +The extension is supposed to work with any Gnome shell theme. +(Tested with some popular ones and the default one.) + +Link to the announcement: +http://lists.fedoraproject.org/pipermail/design-team/2011-April/004215.html + +Link to the source: +http://sources.venemo.net/ + +Credits +---------- +Created by Timur Kristóf, Copyright (C) 2011 + - Licensed under the terms of the MIT License. See the LICENSE file for details. + - The Fedora logo itself is NOT contained within this package (it's in fedora-logos) + and is licensed under its own license. + See https://fedoraproject.org/wiki/Logo for details. +Special thanks to: + - Elad Alfassa for testing it on right-to-left locales. + - Rahul Sundaram for reviewing this package before submission. + 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 + +/* 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); +} + diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000..42c2598 --- /dev/null +++ b/metadata.json @@ -0,0 +1 @@ +{"shell-version": ["3.0"], "uuid": "fedoralogo@fedoraproject.org", "name": "Fedora Logo", "description": "Displays a Fedora logo on the Activities button"} -- cgit