From c37b222cbff50517f09173562f85e578eda8709c Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Mon, 14 Jan 2013 10:20:59 -0500 Subject: [PATCH] network: support NM 0.9.6 again NM 0.9.7 is still not released even as a tarball, so fix this to work with 0.9.6 again for now (although it doesn't do any device name disambiguation in this case now). https://bugzilla.gnome.org/show_bug.cgi?id=691720 --- configure.ac | 2 +- js/ui/status/network.js | 28 ++++++++++++++++++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 33a6f9101..e68384c00 100644 --- a/configure.ac +++ b/configure.ac @@ -78,7 +78,7 @@ STARTUP_NOTIFICATION_MIN_VERSION=0.11 GCR_MIN_VERSION=3.3.90 GNOME_DESKTOP_REQUIRED_VERSION=3.7.1 GNOME_MENUS_REQUIRED_VERSION=3.5.3 -NETWORKMANAGER_MIN_VERSION=0.9.7 +NETWORKMANAGER_MIN_VERSION=0.9.6 PULSE_MIN_VERS=2.0 # Collect more than 20 libraries for a prize! diff --git a/js/ui/status/network.js b/js/ui/status/network.js index 92f5af55f..45e85494f 100644 --- a/js/ui/status/network.js +++ b/js/ui/status/network.js @@ -5,10 +5,17 @@ const Gio = imports.gi.Gio; const Lang = imports.lang; const NetworkManager = imports.gi.NetworkManager; const NMClient = imports.gi.NMClient; -const NMGtk = imports.gi.NMGtk; const Signals = imports.signals; const St = imports.gi.St; +// Some of the new code depends on as-yet-unreleased NM +var NMGtk; +try { + NMGtk = imports.gi.NMGtk; +} catch(e) { + NMGtk = null; +} + const Main = imports.ui.main; const PanelMenu = imports.ui.panelMenu; const PopupMenu = imports.ui.popupMenu; @@ -474,7 +481,8 @@ const NMDevice = new Lang.Class({ }, syncDescription: function() { - this.statusItem.label.text = this.device._description; + if (this.device._description) + this.statusItem.label.text = this.device._description; }, // protected @@ -638,6 +646,7 @@ const NMDeviceWired = new Lang.Class({ Extends: NMDeviceSimple, _init: function(client, device, connections) { + device._description = _("Wired"); this._autoConnectionName = _("Auto Ethernet"); this.category = NMConnectionCategory.WIRED; @@ -665,6 +674,7 @@ const NMDeviceModem = new Lang.Class({ _init: function(client, device, connections) { let is_wwan = false; + device._description = _("Mobile broadband"); this._enabled = true; this.mobileDevice = null; this._connectionType = 'ppp'; @@ -783,6 +793,7 @@ const NMDeviceBluetooth = new Lang.Class({ Extends: NMDevice, _init: function(client, device, connections) { + device._description = _("Bluetooth"); this._autoConnectionName = this._makeConnectionName(device); device.connect('notify::name', Lang.bind(this, this._updateAutoConnectionName)); @@ -1794,13 +1805,18 @@ const NMApplet = new Lang.Class({ }, _syncDeviceNames: function() { - let names = NMGtk.utils_disambiguate_device_names(this._nmDevices); - for (let i = 0; i < this._nmDevices.length; i++) { - let device = this._nmDevices[i]; - if (device._description != names[i]) { + if (NMGtk) { + let names = NMGtk.utils_disambiguate_device_names(this._nmDevices); + for (let i = 0; i < this._nmDevices.length; i++) { + let device = this._nmDevices[i]; device._description = names[i]; device._delegate.syncDescription(); } + } else { + for (let i = 0; i < this._nmDevices.length; i++) { + let device = this._nmDevices[i]; + device._delegate.syncDescription(); + } } },