diff --git a/README.md b/README.md index a1e59ee..e9bdd80 100644 --- a/README.md +++ b/README.md @@ -11,3 +11,4 @@ Simply showing network speed. Left click to change modes: 1. Up & down speed in Bytes per second 1. Total of downloaded in Bytes (Right click to reset counter) +Middle click to change font size diff --git a/extension.js b/extension.js index ce34c00..6addb77 100644 --- a/extension.js +++ b/extension.js @@ -16,10 +16,9 @@ let settings; let button, timeout; // let icon, iconDark; let ioSpeed; -let ioSpeedW; -let lbl; let lastCount = 0, lastSpeed = 0, lastCountUp = 0; let mode; // 0: kbps 1: K/s 2: U:kbps D:kbps 3: U:K/s D:K/s 4: Total KB +let fontmode; let resetNextCount = false, resetCount = 0; function init() { @@ -27,6 +26,7 @@ function init() { settings = Convenience.getSettings(PREFS_SCHEMA); mode = settings.get_int('mode'); // default mode using bit (bps, kbps) + fontmode = settings.get_int('fontmode'); button = new St.Bin({ style_class: 'panel-button', @@ -50,11 +50,6 @@ function init() { style_class: 'simplenetspeed-label' }); - ioSpeedW = new St.Label({ - text: '---', - style_class: 'simplenetspeed-label-w' - }); - // ioSpeedStaticIcon = new St.Label({ // text: '💾', // style_class: 'simplenetspeed-static-icon' @@ -70,8 +65,16 @@ function changeMode(widget, event) { resetNextCount = true; parseStat(); } - else if (event.get_button() == 1) - { + else if (event.get_button() == 2) { // change font + fontmode++; + if (fontmode > 3) { + fontmode=0; + } + settings.set_int('fontmode', fontmode); + button.set_child(chooseLabel()); + parseStat(); + } + else if (event.get_button() == 1) { mode++; if (mode > 4) { mode = 0; @@ -80,16 +83,23 @@ function changeMode(widget, event) { button.set_child(chooseLabel()); parseStat(); } + log('mode:' + mode + ' font:' + fontmode); } function chooseLabel() { if (mode == 0 || mode == 1 || mode == 4) { - lbl=ioSpeed; + styleName = 'simplenetspeed-label'; } else { - lbl=ioSpeedW; + styleName = 'simplenetspeed-label-w'; } - return lbl; + + if (fontmode > 0) { + styleName = styleName + '-' + fontmode; + } + + ioSpeed.set_style_class_name(styleName); + return ioSpeed; } function parseStat() { @@ -135,24 +145,24 @@ function parseStat() { } if (mode >= 0 && mode <= 1) { - lbl.set_text(dot + speedToString(speed)); + ioSpeed.set_text(dot + speedToString(speed)); } else if (mode >= 2 && mode <= 3) { - lbl.set_text("↓" + speedToString(speed - speedUp) + " ↑" + speedToString(speedUp)); + ioSpeed.set_text("↓" + speedToString(speed - speedUp) + " ↑" + speedToString(speedUp)); } else if (mode == 4) { if (resetNextCount == true) { resetNextCount = false; resetCount = count; } - lbl.set_text("∑ " + speedToString(count - resetCount)); + ioSpeed.set_text("∑ " + speedToString(count - resetCount)); } lastCount = count; lastCountUp = countUp; lastSpeed = speed; } catch (e) { - lbl.set_text(e.message); + ioSpeed.set_text(e.message); } /* diff --git a/metadata.json b/metadata.json index d26037f..254ec77 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "_generated": "Generated by SweetTooth, do not edit", - "description": "Simply showing network speed. Click to change mode", + "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", diff --git a/schemas/gschemas.compiled b/schemas/gschemas.compiled index 4865581..6d4c39a 100644 Binary files a/schemas/gschemas.compiled and b/schemas/gschemas.compiled differ diff --git a/schemas/org.gnome.shell.extensions.simplenetspeed.gschema.xml b/schemas/org.gnome.shell.extensions.simplenetspeed.gschema.xml index f6d8ce1..a921c55 100644 --- a/schemas/org.gnome.shell.extensions.simplenetspeed.gschema.xml +++ b/schemas/org.gnome.shell.extensions.simplenetspeed.gschema.xml @@ -5,5 +5,9 @@ 0 + + + 0 + diff --git a/stylesheet.css b/stylesheet.css index d295f58..93c9082 100644 --- a/stylesheet.css +++ b/stylesheet.css @@ -1,15 +1,65 @@ .simplenetspeed-label { width: 70px; text-align: right; - margin-left: 2px; + margin-left: 1px; margin-right: 2px; + font-size: 1em; } .simplenetspeed-label-w { width: 120px; text-align: right; - margin-left: 2px; + margin-left: 1px; + margin-right: 1px; + font-size: 1em; +} + +.simplenetspeed-label-1 { + width: 70px; + text-align: right; + margin-left: 1px; + margin-right: 2px; + font-size: .8em; +} + +.simplenetspeed-label-w-1 { + width: 120px; + text-align: right; + margin-left: 1px; + margin-right: 1px; + font-size: .8em; +} + +.simplenetspeed-label-2 { + width: 70px; + text-align: right; + margin-left: 1px; + margin-right: 2px; + font-size: .9em; +} + +.simplenetspeed-label-w-2 { + width: 120px; + text-align: right; + margin-left: 1px; + margin-right: 1px; + font-size: .9em; +} + +.simplenetspeed-label-3 { + width: 80px; + text-align: right; + margin-left: 1px; margin-right: 2px; + font-size: 1.1em; +} + +.simplenetspeed-label-w-3 { + width: 135px; + text-align: right; + margin-left: 1px; + margin-right: 1px; + font-size: 1.1em; } /*.simplenetspeed-static-icon {