Package: gnome-shell-extension-show-ip Version: 8-3 Severity: wishlist Forwarded: https://github.com/sgaraud/gnome-extension-show-ip/pull/19
Please apply the attached patch from upstream pull request #19 to show the primary IP address when no interface was chosen. -- System Information: Debian Release: bullseye/sid APT prefers testing-debug APT policy: (900, 'testing-debug'), (900, 'testing'), (800, 'unstable-debug'), (800, 'unstable'), (790, 'buildd-unstable'), (700, 'experimental-debug'), (700, 'experimental'), (690, 'buildd-experimental') Architecture: amd64 (x86_64) Kernel: Linux 5.3.0-2-amd64 (SMP w/4 CPU cores) Kernel taint flags: TAINT_FIRMWARE_WORKAROUND, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE Locale: LANG=en_AU.utf8, LC_CTYPE=en_AU.utf8 (charmap=UTF-8), LANGUAGE=en_AU:en (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) LSM: AppArmor: enabled Versions of packages gnome-shell-extension-show-ip depends on: ii gnome-shell 3.34.1+git20191024-1 gnome-shell-extension-show-ip recommends no packages. gnome-shell-extension-show-ip suggests no packages. -- no debconf information -- bye, pabs https://wiki.debian.org/PaulWise
From 795e42e1b3c43ec81c4226a5db3fe31e00c2fc4a Mon Sep 17 00:00:00 2001 From: Paul Wise <pa...@bonedaddy.net> Date: Thu, 2 Mar 2017 18:07:14 +0800 Subject: [PATCH] Show the primary IP address when no interface was chosen Makes it easier to see all IP addresses at a glance. Uses NM to get which interface(s) are in the default route. --- README.md | 1 + extension.js | 53 +++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 43 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 0fafb7a..eec47e3 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,7 @@ issues](https://github.com/sgaraud/gnome-extension-show-ip/issues). ### License Copyright (C) 2015 Sylvain Garaud +Copyright 2017 Paul Wise 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 diff --git a/extension.js b/extension.js index d9a7940..d998737 100644 --- a/extension.js +++ b/extension.js @@ -3,6 +3,7 @@ * https://github.com/sgaraud/gnome-extension-show-ip * * Copyright (C) 2015 Sylvain Garaud + * Copyright 2017 Paul Wise * * This file is part of Show-IP GNOME extension. * Show IP GNOME extension is free software: you can redistribute it and/or modify @@ -170,17 +171,30 @@ const IpMenuBase = new Lang.Class({ } }); + this._getPrimaryDevices(this.client); + let selectedIp = ''; + let primaryIp = ''; + let firstIp = ''; for (let device of this._devices) { - if (device.ifc == this.selectedDevice) { - if (Schema.get_boolean("menu")) { - this.label.set_text(_("IP: %s").format(device.ip)); - } else { - this.label.set_text(device.ip); - } - break; + if (!selectedIp && device.ifc == this.selectedDevice) { + selectedIp = device.ip; + } + if (!primaryIp && device.primary) { + primaryIp = device.ip; + } + if (!firstIp) { + firstIp = device.ip; } } - if ('' == this.selectedDevice) { + let ip = selectedIp ? selectedIp : primaryIp ? primaryIp : firstIp; + if (ip) { + if (Schema.get_boolean("menu")) { + this.label.set_text(_("IP: %s").format(device.ip)); + } else { + this.label.set_text(device.ip); + } + this.label.set_text(device.ip); + } else { this.label.set_text(NOT_CONNECTED); } }, @@ -207,6 +221,26 @@ const IpMenuBase = new Lang.Class({ this._createPopupMenu(); }, + _getPrimaryDevices: function (nmc) { + let primary_conn = nmc.get_primary_connection(); + let primary_devices = primary_conn.get_devices(); + let primary_ifcs = []; + let i = 0; + if (primary_devices) { + for (let device of primary_devices) { + primary_ifcs[i++] = device.get_iface(); + } + } + for (let device of this._devices) { + device.primary = false; + for (let ifc of primary_ifcs) { + if (device.ifc == ifc) { + device.primary = true; + } + } + } + }, + _getNetworkDevices: function (nmc) { let _device; this.devices = nmc.get_devices(); @@ -290,9 +324,6 @@ const IpMenuBase = new Lang.Class({ } else { device.ip = this._decodeIp4(ipadd); } - if ('' == this.selectedDevice) { - this.selectedDevice = device.ifc; - } break; } } -- 2.24.0
signature.asc
Description: This is a digitally signed message part