From 5f1cbc7fa0b6322492ad1efd2a40d698655c77be Mon Sep 17 00:00:00 2001 From: biji Date: Thu, 3 Mar 2022 21:51:43 +0700 Subject: [PATCH] remove convenience.js, clean up --- convenience.js | 92 -------------------------------------------------- extension.js | 8 ++--- metadata.json | 19 +---------- stylesheet.css | 33 ++++++------------ 4 files changed, 15 insertions(+), 137 deletions(-) delete mode 100644 convenience.js diff --git a/convenience.js b/convenience.js deleted file mode 100644 index 4fc44ab..0000000 --- a/convenience.js +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- mode: js -*- */ -/* - Copyright (c) 2011-2012, Giovanni Campagna - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the GNOME nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -const Gettext = imports.gettext; -const Gio = imports.gi.Gio; - -const Config = imports.misc.config; -const ExtensionUtils = imports.misc.extensionUtils; - -/** - * initTranslations: - * @domain: (optional): the gettext domain to use - * - * Initialize Gettext to load translations from extensionsdir/locale. - * If @domain is not provided, it will be taken from metadata['gettext-domain'] - */ -function initTranslations(domain) { - let extension = ExtensionUtils.getCurrentExtension(); - - domain = domain || extension.metadata['gettext-domain']; - - // check if this extension was built with "make zip-file", and thus - // has the locale files in a subfolder - // otherwise assume that extension has been installed in the - // same prefix as gnome-shell - let localeDir = extension.dir.get_child('locale'); - if (localeDir.query_exists(null)) - Gettext.bindtextdomain(domain, localeDir.get_path()); - else - Gettext.bindtextdomain(domain, Config.LOCALEDIR); -} - -/** - * getSettings: - * @schema: (optional): the GSettings schema id - * - * Builds and return a GSettings schema for @schema, using schema files - * in extensionsdir/schemas. If @schema is not provided, it is taken from - * metadata['settings-schema']. - */ -function getSettings(schema) { - let extension = ExtensionUtils.getCurrentExtension(); - - schema = schema || extension.metadata['settings-schema']; - - const GioSSS = Gio.SettingsSchemaSource; - - // check if this extension was built with "make zip-file", and thus - // has the schema files in a subfolder - // otherwise assume that extension has been installed in the - // same prefix as gnome-shell (and therefore schemas are available - // in the standard folders) - let schemaDir = extension.dir.get_child('schemas'); - let schemaSource; - if (schemaDir.query_exists(null)) - schemaSource = GioSSS.new_from_directory(schemaDir.get_path(), - GioSSS.get_default(), - false); - else - schemaSource = GioSSS.get_default(); - - let schemaObj = schemaSource.lookup(schema, true); - if (!schemaObj) - throw new Error('Schema ' + schema + ' could not be found for extension ' - + extension.metadata.uuid + '. Please check your installation.'); - - return new Gio.Settings({ settings_schema: schemaObj }); -} diff --git a/extension.js b/extension.js index 853e4ec..c223ba7 100644 --- a/extension.js +++ b/extension.js @@ -8,7 +8,6 @@ const ByteArray = imports.byteArray; const ExtensionUtils = imports.misc.extensionUtils; const Me = ExtensionUtils.getCurrentExtension(); -const Convenience = Me.imports.convenience; const PREFS_SCHEMA = 'org.gnome.shell.extensions.simplenetspeed'; const refreshTime = 3; @@ -38,7 +37,7 @@ function changeMode(widget, event) { fontmode=0; } settings.set_int('fontmode', fontmode); - button.set_child(chooseLabel()); + chooseLabel(); parseStat(); } else if (event.get_button() == 1) { @@ -47,7 +46,7 @@ function changeMode(widget, event) { mode = 0; } settings.set_int('mode', mode); - button.set_child(chooseLabel()); + chooseLabel(); parseStat(); } log('mode:' + mode + ' font:' + fontmode); @@ -173,7 +172,7 @@ function speedToString(amount) { } function enable() { - settings = Convenience.getSettings(PREFS_SCHEMA); + settings = ExtensionUtils.getSettings(PREFS_SCHEMA); mode = settings.get_int('mode'); // default mode using bit (bps, kbps) fontmode = settings.get_int('fontmode'); @@ -208,5 +207,6 @@ function disable() { timeout = null; Main.panel._rightBox.remove_child(button); button.destroy(); + settings = button = ioSpeed = null; } } diff --git a/metadata.json b/metadata.json index 6064611..526e352 100644 --- a/metadata.json +++ b/metadata.json @@ -3,23 +3,6 @@ "description": "Simply showing network speed. Left click to change modes:\n\n1. Total net speed in bits per second\n2. Total net speed in Bytes per second\n3. Up & down speed in bits per second\n4. Up & down speed in Bytes per second\n5. Total of downloaded in Bytes (Right click to reset counter)\n\nMiddle click to change font size", "name": "Simple net speed", "shell-version": [ - "3.14", - "3.15", - "3.16", - "3.17", - "3.18", - "3.19", - "3.20", - "3.21", - "3.22", - "3.23", - "3.24", - "3.25", - "3.26", - "3.27", - "3.28", - "3.29", - "3.30", "3.32", "3.34", "3.36", @@ -29,5 +12,5 @@ ], "url": "https://github.com/biji/simplenetspeed", "uuid": "simplenetspeed@biji.extension", - "version": 23 + "version": 24 } diff --git a/stylesheet.css b/stylesheet.css index f16ab15..5c66dbf 100644 --- a/stylesheet.css +++ b/stylesheet.css @@ -1,5 +1,5 @@ .simplenetspeed-label { - width: 7em; + min-width: 7em; text-align: right; margin-left: 1px; margin-right: 2px; @@ -7,7 +7,7 @@ } .simplenetspeed-label-w { - width: 12em; + min-width: 13em; text-align: right; margin-left: 1px; margin-right: 1px; @@ -15,7 +15,7 @@ } .simplenetspeed-label-1 { - width: 7em; + min-width: 7em; text-align: right; margin-left: 1px; margin-right: 2px; @@ -23,7 +23,7 @@ } .simplenetspeed-label-w-1 { - width: 12em; + min-width: 13em; text-align: right; margin-left: 1px; margin-right: 1px; @@ -31,7 +31,7 @@ } .simplenetspeed-label-2 { - width: 7em; + min-width: 7em; text-align: right; margin-left: 1px; margin-right: 2px; @@ -39,7 +39,7 @@ } .simplenetspeed-label-w-2 { - width: 12em; + min-width: 13em; text-align: right; margin-left: 1px; margin-right: 1px; @@ -47,7 +47,7 @@ } .simplenetspeed-label-3 { - width: 7em; + min-width: 7em; text-align: right; margin-left: 1px; margin-right: 2px; @@ -55,7 +55,7 @@ } .simplenetspeed-label-w-3 { - width: 12em; + min-width: 13em; text-align: right; margin-left: 1px; margin-right: 1px; @@ -63,7 +63,7 @@ } .simplenetspeed-label-4 { - width: 7em; + min-width: 7em; text-align: right; margin-left: 1px; margin-right: 2px; @@ -71,22 +71,9 @@ } .simplenetspeed-label-w-4 { - width: 12em; + min-width: 13em; text-align: right; margin-left: 1px; margin-right: 1px; font-size: 1.1em; } - -/*.simplenetspeed-static-icon { - font-size: 14px; - width: 15px; - text-align: left; -} - -.simplenetspeed-icon { - font-size: 12px; - width: 14px; - text-align: center; - color: lime; -}*/