Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAjay Garg <ajay@activitycentral.com>2012-10-17 09:16:27 (GMT)
committer Ajay Garg <ajay@activitycentral.com>2012-10-17 09:20:25 (GMT)
commit3a6858641e8369d89d8df0a8b8d5791a61e4c195 (patch)
tree7b1ba23c1fd9595761ee902a34af474077d91e75
parente79e280d25043d54ba005f4d9a01734c176b6659 (diff)
Add "nm-connection-editor" in "My Settings" -> "Network" (gconf-controllable).
Signed-off-by: Ajay Garg <ajay@activitycentral.com>
-rw-r--r--extensions/cpsection/network/model.py17
-rw-r--r--extensions/cpsection/network/view.py55
2 files changed, 72 insertions, 0 deletions
diff --git a/extensions/cpsection/network/model.py b/extensions/cpsection/network/model.py
index ae9e64d..83c3cf1 100644
--- a/extensions/cpsection/network/model.py
+++ b/extensions/cpsection/network/model.py
@@ -18,6 +18,10 @@
import logging
import dbus
+import os
+import subprocess
+import logging
+
from gettext import gettext as _
from gi.repository import GConf
@@ -30,6 +34,8 @@ _NM_IFACE = 'org.freedesktop.NetworkManager'
KEYWORDS = ['network', 'jabber', 'radio', 'server']
+_logger = logging.getLogger('ControlPanel - Network')
+
class ReadError(Exception):
def __init__(self, value):
@@ -154,3 +160,14 @@ def set_publish_information(value):
client = GConf.Client.get_default()
client.set_bool('/desktop/sugar/collaboration/publish_gadget', value)
return 0
+
+
+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 9b89375..e4332e4 100644
--- a/extensions/cpsection/network/view.py
+++ b/extensions/cpsection/network/view.py
@@ -17,6 +17,7 @@
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GObject
+from gi.repository import GConf
from gettext import gettext as _
from sugar3.graphics import style
@@ -30,6 +31,9 @@ ICON = 'module-network'
TITLE = _('Network')
_APPLY_TIMEOUT = 3000
+EXPLICIT_REBOOT_MESSAGE = _('Please restart your computer for changes to take effect.')
+
+gconf_client = GConf.Client.get_default()
class Network(SectionView):
@@ -51,6 +55,7 @@ class Network(SectionView):
self._radio_alert_box = Gtk.HBox(spacing=style.DEFAULT_SPACING)
self._jabber_alert_box = Gtk.HBox(spacing=style.DEFAULT_SPACING)
+ self._nm_connection_editor_alert_box = Gtk.HBox(spacing=style.DEFAULT_SPACING)
scrolled = Gtk.ScrolledWindow()
scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
@@ -178,8 +183,54 @@ class Network(SectionView):
workspace.pack_start(box_mesh, False, True, 0)
box_mesh.show()
+ if gconf_client.get_bool('/desktop/sugar/extensions/network/show_nm_connection_editor') is True:
+ box_nm_connection_editor = self.add_nm_connection_editor_launcher(workspace)
+
self.setup()
+ def add_nm_connection_editor_launcher(self, workspace):
+ separator_nm_connection_editor = Gtk.HSeparator()
+ workspace.pack_start(separator_nm_connection_editor, False, True, 0)
+ separator_nm_connection_editor.show()
+
+ label_nm_connection_editor = Gtk.Label(_('Advanced Network Settings'))
+ label_nm_connection_editor.set_alignment(0, 0)
+ workspace.pack_start(label_nm_connection_editor, False, True, 0)
+ 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(_("For more specific network settings, use "
+ "the NetworkManager Connection Editor."))
+
+ info.set_alignment(0, 0)
+ info.set_line_wrap(True)
+ box_nm_connection_editor.pack_start(info, False, True, 0)
+
+ self._nm_connection_editor_alert = InlineAlert()
+ self._nm_connection_editor_alert.props.msg = EXPLICIT_REBOOT_MESSAGE
+ self._nm_connection_editor_alert_box.pack_start(self._nm_connection_editor_alert,
+ False, True, 0)
+ box_nm_connection_editor.pack_end(self._nm_connection_editor_alert_box,
+ False, True, 0)
+ self._nm_connection_editor_alert_box.show()
+ self._nm_connection_editor_alert.show()
+
+ 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, False, True, 0)
+ box_launch_button.show_all()
+
+ box_nm_connection_editor.pack_start(box_launch_button, False, True, 0)
+ workspace.pack_start(box_nm_connection_editor, False, True, 0)
+ box_nm_connection_editor.show_all()
+
def setup(self):
self._entry.set_text(self._model.get_jabber())
try:
@@ -260,3 +311,7 @@ class Network(SectionView):
self._model.clear_networks()
if not self._model.have_networks():
self._clear_history_button.set_sensitive(False)
+
+ def __launch_button_clicked_cb(self, launch_button):
+ self._model.launch_nm_connection_editor()
+