Skip to content

Commit

Permalink
fix: Remove Lang module
Browse files Browse the repository at this point in the history
Fix #139
  • Loading branch information
c84c committed Jan 22, 2023
1 parent 5a96082 commit 666feb7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 36 deletions.
21 changes: 10 additions & 11 deletions net_speed.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

const Lang = imports.lang;
const Extension = imports.misc.extensionUtils.getCurrentExtension();
const Lib = Extension.imports.lib;
const Gettext = imports.gettext;
Expand Down Expand Up @@ -324,7 +323,7 @@ var NetSpeed = class NetSpeed {
let m_timer = this._setting.get_int('timer');
if (m_timer !== this.timer) {
Mainloop.source_remove(this._timerid);
this._timerid = Mainloop.timeout_add(m_timer, Lang.bind(this, this._update));
this._timerid = Mainloop.timeout_add(m_timer, this._update.bind(this));
// this.timer will be updated within this._load, so no need to update it here
}
this._load();
Expand All @@ -346,12 +345,12 @@ var NetSpeed = class NetSpeed {
this._devices = new Array();
this._client = NetworkManager.Client.new(null);
this._nm_signals = new Array();
this._nm_signals.push(this._client.connect('any-device-added', Lang.bind(this, this._nm_device_changed)));
this._nm_signals.push(this._client.connect('any-device-removed', Lang.bind(this, this._nm_device_changed)));
this._nm_signals.push(this._client.connect('connection-added', Lang.bind(this, this._nm_connection_changed)));
this._nm_signals.push(this._client.connect('connection-removed', Lang.bind(this, this._nm_connection_changed)));
this._nm_signals.push(this._client.connect('active-connection-added', Lang.bind(this, this._nm_connection_changed)));
this._nm_signals.push(this._client.connect('active-connection-removed', Lang.bind(this, this._nm_connection_changed)));
this._nm_signals.push(this._client.connect('any-device-added', this._nm_device_changed.bind(this)));
this._nm_signals.push(this._client.connect('any-device-removed', this._nm_device_changed.bind(this)));
this._nm_signals.push(this._client.connect('connection-added', this._nm_connection_changed.bind(this)));
this._nm_signals.push(this._client.connect('connection-removed', this._nm_connection_changed.bind(this)));
this._nm_signals.push(this._client.connect('active-connection-added', this._nm_connection_changed.bind(this)));
this._nm_signals.push(this._client.connect('active-connection-removed', this._nm_connection_changed.bind(this)));

// store NM Device 'state-changed' signal bindings to disconnect on disable
this._nm_devices_signals_map = new Map();
Expand All @@ -365,8 +364,8 @@ var NetSpeed = class NetSpeed {
this._saving = 0;
this._load();

this._changed = this._setting.connect('changed', Lang.bind(this, this._reload));
this._timerid = Mainloop.timeout_add(this.timer, Lang.bind(this, this._update));
this._changed = this._setting.connect('changed', this._reload.bind(this));
this._timerid = Mainloop.timeout_add(this.timer, this._update.bind(this));
this._status_icon = new NetSpeedStatusIcon.NetSpeedStatusIcon(this);
let placement = this._setting.get_string('placement');
Panel.addToStatusArea('netspeed', this._status_icon, 0, placement);
Expand Down Expand Up @@ -469,7 +468,7 @@ var NetSpeed = class NetSpeed {
*/
_connect_nm_device_state_changed(nm_device) {
if (!this._nm_devices_signals_map.has(nm_device.get_iface())) {
let signal_id = nm_device.connect('state-changed', Lang.bind(this, this._nm_device_state_changed));
let signal_id = nm_device.connect('state-changed', this._nm_device_state_changed.bind(this));
this._nm_devices_signals_map.set(nm_device.get_iface(), [nm_device, signal_id]);
}
}
Expand Down
7 changes: 3 additions & 4 deletions net_speed_status_icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
const ExtensionUtils = imports.misc.extensionUtils;
const Extension = ExtensionUtils.getCurrentExtension();
const Gettext = imports.gettext;
const Lang = imports.lang;
const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
const Clutter = imports.gi.Clutter;
Expand Down Expand Up @@ -48,7 +47,7 @@ var NetSpeedStatusIcon = GObject.registerClass(class NetSpeedStatusIcon extends
// extension button
this._box = new St.BoxLayout();
this.add_actor(this._box);
this.connect('button-release-event', Lang.bind(this, this._toggle_showsum));
this.connect('button-release-event', this._toggle_showsum.bind(this));

// download
this._download_box = new St.BoxLayout();
Expand Down Expand Up @@ -95,7 +94,7 @@ var NetSpeedStatusIcon = GObject.registerClass(class NetSpeedStatusIcon extends
});

this._menu_title = new NetSpeedLayoutMenuItem.NetSpeedLayoutMenuItem(_("Device"), this._pref, this._net_speed.menu_label_size);
this._menu_title.connect("activate", Lang.bind(this, this._change_device, ""));
this._menu_title.connect("activate", this._change_device.bind(this, ""));
this._menu_title.update_speeds({ up: _("Up"), down: _("Down") });
this._menu_title.update_ips([_("IP")]);
this._menu_title.show_ip(this._net_speed.show_ips);
Expand Down Expand Up @@ -260,7 +259,7 @@ var NetSpeedStatusIcon = GObject.registerClass(class NetSpeedStatusIcon extends
let icon = this._get_icon(types[i]);
let layout = new NetSpeedLayoutMenuItem.NetSpeedLayoutMenuItem(devices[i], icon, this._net_speed.menu_label_size);
layout.show_ip(this._net_speed.show_ips);
layout.connect("activate", Lang.bind(this, this._change_device, devices[i]));
layout.connect("activate", this._change_device.bind(this, devices[i]));
this._layouts.push(layout);
this.menu.addMenuItem(layout);
}
Expand Down
40 changes: 19 additions & 21 deletions prefs.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
/*
* Copyright 2011-2019 Amir Hedayaty < hedayaty AT gmail DOT com >
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/*
* Copyright 2011-2019 Amir Hedayaty < hedayaty AT gmail DOT com >
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

const Extension = imports.misc.extensionUtils.getCurrentExtension();
const Lib = Extension.imports.lib;
Expand All @@ -25,7 +24,6 @@ const Gdk = imports.gi.Gdk;
const Gettext = imports.gettext;
const Gio = imports.gi.Gio;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
const NM = imports.gi.NM;
const _ = Gettext.domain('netspeed').gettext;

Expand Down Expand Up @@ -309,10 +307,10 @@ const App = class NetSpeed_App {
this._pick_dev();
this._factor = Schema.get_int('hi-dpi-factor');

this.dev.connect('changed', Lang.bind(this, this._put_dev));
Schema.connect('changed', Lang.bind(this, this._dpi_changed));
this.dev.connect('changed', this._put_dev.bind(this));
Schema.connect('changed', this._dpi_changed.bind(this));

this.placement.connect('changed', Lang.bind(this, this._change_placement))
this.placement.connect('changed', this._change_placement.bind(this));

}
};
Expand Down

0 comments on commit 666feb7

Please sign in to comment.