Skip to content

Commit

Permalink
support gnome 45 (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
remisiki authored Oct 13, 2023
1 parent 4d8544b commit 40eb4bf
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 65 deletions.
62 changes: 31 additions & 31 deletions extension.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
//Imports
const Clutter = imports.gi.Clutter,
St = imports.gi.St,
Main = imports.ui.main,
Gio = imports.gi.Gio,
PanelMenu = imports.ui.panelMenu,
Mainloop = imports.mainloop,
Me = imports.misc.extensionUtils.getCurrentExtension(),
ExtensionUtils = imports.misc.extensionUtils,
schema = 'org.gnome.shell.extensions.netspeedsimplified',
import Clutter from 'gi://Clutter';
import St from 'gi://St';
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js';
import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js';
const schema = 'org.gnome.shell.extensions.netspeedsimplified',
ButtonName = "ShowNetSpeedButton",
rCConst = 4; //Right Click 4 times to toggle Vertical Alignment

Expand Down Expand Up @@ -381,32 +380,33 @@ function parseStat() {
return true;
}

function _settingsChanged() {
if (settings.get_boolean('restartextension')) {
settings.set_boolean('restartextension', false);
disable();
enable();
parseStat();

export default class NetSpeedSimplifiedExtension extends Extension {
_settingsChanged() {
if (settings.get_boolean('restartextension')) {
settings.set_boolean('restartextension', false);
this.disable();
this.enable();
parseStat();
}
}
}

function init() { }
enable() {
settings = this.getSettings(schema);

function enable() {
settings = ExtensionUtils.getSettings(schema);
fetchSettings(); // Automatically creates the netSpeed Button.
this._settingsChangedId = settings.connect('changed', () => this._settingsChanged());
parseStat();

fetchSettings(); // Automatically creates the netSpeed Button.
this._settingsChangedId = settings.connect('changed', this._settingsChanged);
parseStat();
//Run infinite loop.
timeout = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, crStng.refreshTime, parseStat);
}

//Run infinite loop.
timeout = Mainloop.timeout_add_seconds(crStng.refreshTime, parseStat);
}
disable() {
crStng = null;
settings = null;

function disable() {
crStng = null;
settings = null;

Mainloop.source_remove(timeout);
nsDestroy();
GLib.source_remove(timeout);
nsDestroy();
}
}
49 changes: 15 additions & 34 deletions prefs.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,15 @@
const Gtk = imports.gi.Gtk,
Gdk = imports.gi.Gdk

const Config = imports.misc.config
import Gtk from 'gi://Gtk';
import Gdk from 'gi://Gdk';
import {ExtensionPreferences, gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
import * as Config from 'resource:///org/gnome/Shell/Extensions/js/misc/config.js';
const ShellVersion = parseFloat(Config.PACKAGE_VERSION)
const schema = "org.gnome.shell.extensions.netspeedsimplified"

const Me = imports.misc.extensionUtils.getCurrentExtension(),
ExtensionUtils = imports.misc.extensionUtils,
schema = "org.gnome.shell.extensions.netspeedsimplified"

function init() { }

function buildPrefsWidget() {
let prefs = new Prefs(schema)

return prefs.buildPrefsWidget()
}

function Prefs(schema) {
this.init(schema)
}

Prefs.prototype = {
settings: null,
init: function (schema) {
let settings = ExtensionUtils.getSettings(schema)
this.settings = settings
},
export default class NetSpeedSimplifiedPreferences extends ExtensionPreferences {
getPreferencesWidget() {
let settings = this.getSettings(schema);
window._settings = settings;

buildPrefsWidget: function () {
let settings = this.settings
let crStng

function fetchSettings() {
Expand Down Expand Up @@ -287,16 +268,16 @@ Prefs.prototype = {
let intArray = ["wpos", "wposext", "mode", "fontmode", "chooseiconset", "textalign"]
let doubleArray = ["refreshtime", "minwidth"]
let boolArray = ["isvertical", "togglebool", "reverseindicators", "lockmouseactions", "hideindicator", "shortenunits", "iconstoright"]
for (i in strArray) {
for (const i in strArray) {
settings.set_string(strArray[i], settings.get_default_value(strArray[i]).unpack())
}
for (j in intArray) {
for (const j in intArray) {
settings.set_int(intArray[j], settings.get_default_value(intArray[j]).unpack())
}
for (k in doubleArray) {
for (const k in doubleArray) {
settings.set_double(doubleArray[k], settings.get_default_value(doubleArray[k]).unpack())
}
for (l in boolArray) {
for (const l in boolArray) {
settings.set_boolean(boolArray[l], settings.get_default_value(boolArray[l]).unpack())
}
settings.set_boolean('restartextension', true)
Expand Down Expand Up @@ -396,6 +377,6 @@ Prefs.prototype = {
addIt(vbox, resetBtn)
frame.child = vbox

return frame
},
return frame;
}
}

0 comments on commit 40eb4bf

Please sign in to comment.