From 16e41c4fb5aa0c511b61ae02fe6e86ffe64016a8 Mon Sep 17 00:00:00 2001 From: Ajay Garg Date: Sun, 19 Feb 2012 13:42:10 +0530 Subject: [PATCH 80/82] au#911, au#1074: Add launcher for nm-connection-editor in My Settings Organization: Sugar Labs Foundation --- This patch adds a launcher which upon executing launches the nm-connection-editor. This 'hack' is included as a last-ditch workaround in case network setting tools provided within sugar are unable to handle a weird connection type. extensions/cpsection/network/model.py | 10 +++++++++ extensions/cpsection/network/view.py | 37 +++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 0 deletions(-) diff --git a/extensions/cpsection/network/model.py b/extensions/cpsection/network/model.py index 9592fdd..11ed615 100644 --- a/extensions/cpsection/network/model.py +++ b/extensions/cpsection/network/model.py @@ -190,3 +190,13 @@ def set_ssids(ssids): if len(ssid) > 0: f.write(ssid + '\n') f.close() + +def launch_nm_connection_editor(): + environment = os.environ.copy() + environment['PATH'] = '%s:/usr/sbin' % (environment['PATH'], ) + + try: + subprocess.Popen(['-c', 'sudo nm-connection-editor --type=802-11-wireless'], + shell=True) + except: + _logger.exception('Error running nm-connection-editor') diff --git a/extensions/cpsection/network/view.py b/extensions/cpsection/network/view.py index e55a48d..48ecfd1 100644 --- a/extensions/cpsection/network/view.py +++ b/extensions/cpsection/network/view.py @@ -758,6 +758,40 @@ class Network(SectionView): workspace.pack_start(proxy, expand=False) proxy.show() + separator_nm_connection_editor = gtk.HSeparator() + workspace.pack_start(separator_nm_connection_editor, False) + separator_nm_connection_editor.show() + + label_nm_connection_editor = gtk.Label(_('NetworkManager' + ' Connection Editor')) + label_nm_connection_editor.set_alignment(0, 0) + workspace.pack_start(label_nm_connection_editor, expand=False) + label_nm_connection_editor.show() + + box_nm_connection_editor = gtk.VBox() + box_nm_connection_editor.set_border_width(style.DEFAULT_SPACING * 2) + box_nm_connection_editor.set_spacing(style.DEFAULT_SPACING) + + info = gtk.Label(_("Press the 'Launch' button, to launch the" + " Connection Editor.")) + info.set_alignment(0, 0) + info.set_line_wrap(True) + box_nm_connection_editor.pack_start(info, expand=False) + + launch_button = gtk.Button() + launch_button.set_alignment(0, 0) + launch_button.set_label(_('Launch')) + launch_button.connect('clicked', self.__launch_button_clicked_cb) + box_launch_button = gtk.HBox() + box_launch_button.set_homogeneous(False) + box_launch_button.pack_start(launch_button, expand=False) + box_launch_button.show_all() + + box_nm_connection_editor.pack_start(box_launch_button, expand=False) + workspace.pack_start(box_nm_connection_editor, expand=False) + box_nm_connection_editor.show_all() + + scrolled = gtk.ScrolledWindow() scrolled.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) scrolled.add_with_viewport(workspace) @@ -859,3 +893,6 @@ class Network(SectionView): def __save_button_clicked_cb(self, save_button): self._model.set_ssids(self._widget_table._get_entries()) save_button.set_sensitive(False) + + def __launch_button_clicked_cb(self, launch_button): + self._model.launch_nm_connection_editor() -- 1.7.4.4