Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/extensions/cpsection
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/cpsection')
-rw-r--r--extensions/cpsection/Makefile.am3
-rw-r--r--extensions/cpsection/aboutcomputer/view.py2
-rw-r--r--extensions/cpsection/modemconfiguration/Makefile.am6
-rw-r--r--extensions/cpsection/modemconfiguration/__init__.py22
-rw-r--r--extensions/cpsection/modemconfiguration/model.py70
-rw-r--r--extensions/cpsection/modemconfiguration/view.py250
-rw-r--r--extensions/cpsection/network/model.py115
-rw-r--r--extensions/cpsection/network/view.py8
-rw-r--r--extensions/cpsection/power/model.py31
-rw-r--r--extensions/cpsection/power/view.py58
10 files changed, 112 insertions, 453 deletions
diff --git a/extensions/cpsection/Makefile.am b/extensions/cpsection/Makefile.am
index 90d36ea..73e5164 100644
--- a/extensions/cpsection/Makefile.am
+++ b/extensions/cpsection/Makefile.am
@@ -1,5 +1,4 @@
-SUBDIRS = aboutme aboutcomputer datetime frame language \
- modemconfiguration network power
+SUBDIRS = aboutme aboutcomputer datetime frame language network power
sugardir = $(pkgdatadir)/extensions/cpsection
sugar_PYTHON = __init__.py
diff --git a/extensions/cpsection/aboutcomputer/view.py b/extensions/cpsection/aboutcomputer/view.py
index 4b638ff..dd4f8f3 100644
--- a/extensions/cpsection/aboutcomputer/view.py
+++ b/extensions/cpsection/aboutcomputer/view.py
@@ -174,7 +174,7 @@ class AboutComputer(SectionView):
vbox_copyright.set_border_width(style.DEFAULT_SPACING * 2)
vbox_copyright.set_spacing(style.DEFAULT_SPACING)
- label_copyright = gtk.Label("© 2006-2010 One Laptop per Child "
+ label_copyright = gtk.Label("© 2006-2009 One Laptop per Child "
"Association Inc; Red Hat Inc; Collabora Ltd; "
"and Contributors.")
label_copyright.set_alignment(0, 0)
diff --git a/extensions/cpsection/modemconfiguration/Makefile.am b/extensions/cpsection/modemconfiguration/Makefile.am
deleted file mode 100644
index 3e2613e..0000000
--- a/extensions/cpsection/modemconfiguration/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-sugardir = $(pkgdatadir)/extensions/cpsection/modemconfiguration
-
-sugar_PYTHON = \
- __init__.py \
- model.py \
- view.py
diff --git a/extensions/cpsection/modemconfiguration/__init__.py b/extensions/cpsection/modemconfiguration/__init__.py
deleted file mode 100644
index 8a219dc..0000000
--- a/extensions/cpsection/modemconfiguration/__init__.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright (C) 2009 Paraguay Educa, Martin Abente
-#
-# 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 2 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, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US
-
-from gettext import gettext as _
-
-CLASS = 'ModemConfiguration'
-ICON = 'module-modemconfiguration'
-TITLE = _('Modem Configuration')
-
diff --git a/extensions/cpsection/modemconfiguration/model.py b/extensions/cpsection/modemconfiguration/model.py
deleted file mode 100644
index 2545ce1..0000000
--- a/extensions/cpsection/modemconfiguration/model.py
+++ /dev/null
@@ -1,70 +0,0 @@
-# Copyright (C) 2009 Paraguay Educa, Martin Abente
-#
-# 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 2 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, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US
-
-import gconf
-
-from jarabe.model.network import GSM_USERNAME_PATH, GSM_PASSWORD_PATH, \
- GSM_NUMBER_PATH, GSM_APN_PATH, GSM_PIN_PATH, \
- GSM_PUK_PATH
-
-def get_username():
- client = gconf.client_get_default()
- return client.get_string(GSM_USERNAME_PATH) or ''
-
-def get_password():
- client = gconf.client_get_default()
- return client.get_string(GSM_PASSWORD_PATH) or ''
-
-def get_number():
- client = gconf.client_get_default()
- return client.get_string(GSM_NUMBER_PATH) or ''
-
-def get_apn():
- client = gconf.client_get_default()
- return client.get_string(GSM_APN_PATH) or ''
-
-def get_pin():
- client = gconf.client_get_default()
- return client.get_string(GSM_PIN_PATH) or ''
-
-def get_puk():
- client = gconf.client_get_default()
- return client.get_string(GSM_PUK_PATH) or ''
-
-def set_username(username):
- client = gconf.client_get_default()
- client.set_string(GSM_USERNAME_PATH, username)
-
-def set_password(password):
- client = gconf.client_get_default()
- client.set_string(GSM_PASSWORD_PATH, password)
-
-def set_number(number):
- client = gconf.client_get_default()
- client.set_string(GSM_NUMBER_PATH, number)
-
-def set_apn(apn):
- client = gconf.client_get_default()
- client.set_string(GSM_APN_PATH, apn)
-
-def set_pin(pin):
- client = gconf.client_get_default()
- client.set_string(GSM_PIN_PATH, pin)
-
-def set_puk(puk):
- client = gconf.client_get_default()
- client.set_string(GSM_PUK_PATH, puk)
-
diff --git a/extensions/cpsection/modemconfiguration/view.py b/extensions/cpsection/modemconfiguration/view.py
deleted file mode 100644
index b236f3f..0000000
--- a/extensions/cpsection/modemconfiguration/view.py
+++ /dev/null
@@ -1,250 +0,0 @@
-# Copyright (C) 2009 Paraguay Educa, Martin Abente
-#
-# 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 2 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, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US
-
-import os
-import logging
-from gettext import gettext as _
-
-import gtk
-import gobject
-
-from sugar.graphics import style
-
-from jarabe.controlpanel.sectionview import SectionView
-
-APPLY_TIMEOUT = 1000
-
-class EntryWithLabel(gtk.HBox):
- __gtype_name__ = "SugarEntryWithLabel"
-
- def __init__(self, label_text):
- gtk.HBox.__init__(self, spacing=style.DEFAULT_SPACING)
-
- self._timeout_sid = 0
- self._changed_handler = None
- self._is_valid = True
-
- self.label = gtk.Label(label_text)
- self.label.modify_fg(gtk.STATE_NORMAL,
- style.COLOR_SELECTION_GREY.get_gdk_color())
- self.label.set_alignment(1, 0.5)
- self.pack_start(self.label, expand=False)
- self.label.show()
-
- self._entry = gtk.Entry(25)
- self._entry.connect('changed', self.__entry_changed_cb)
- self._entry.set_width_chars(25)
- self.pack_start(self._entry, expand=False)
- self._entry.show()
-
- def __entry_changed_cb(self, widget, data=None):
- if self._timeout_sid:
- gobject.source_remove(self._timeout_sid)
- self._timeout_sid = gobject.timeout_add(APPLY_TIMEOUT,
- self.__timeout_cb)
-
- def __timeout_cb(self):
- self._timeout_sid = 0
-
- if self._entry.get_text() == self.get_value():
- return False
-
- try:
- self.set_value(self._entry.get_text())
- except ValueError:
- self._is_valid = False
- else:
- self._is_valid = True
-
- self.notify('is-valid')
-
- return False
-
- def set_text_from_model(self):
- self._entry.set_text(self.get_value())
-
- def get_value(self):
- raise NotImplementedError
-
- def set_value(self):
- raise NotImplementedError
-
- def _get_is_valid(self):
- return self._is_valid
- is_valid = gobject.property(type=bool, getter=_get_is_valid, default=True)
-
-class UsernameEntry(EntryWithLabel):
- def __init__(self, model):
- EntryWithLabel.__init__(self, _('Username:'))
- self._model = model
-
- def get_value(self):
- return self._model.get_username()
-
- def set_value(self, username):
- self._model.set_username(username)
-
-class PasswordEntry(EntryWithLabel):
- def __init__(self, model):
- EntryWithLabel.__init__(self, _('Password:'))
- self._model = model
-
- def get_value(self):
- return self._model.get_password()
-
- def set_value(self, password):
- self._model.set_password(password)
-
-class NumberEntry(EntryWithLabel):
- def __init__(self, model):
- EntryWithLabel.__init__(self, _('Number:'))
- self._model = model
-
- def get_value(self):
- return self._model.get_number()
-
- def set_value(self, number):
- self._model.set_number(number)
-
-class ApnEntry(EntryWithLabel):
- def __init__(self, model):
- EntryWithLabel.__init__(self, _('Access Point Name (APN):'))
- self._model = model
-
- def get_value(self):
- return self._model.get_apn()
-
- def set_value(self, apn):
- self._model.set_apn(apn)
-
-class PinEntry(EntryWithLabel):
- def __init__(self, model):
- EntryWithLabel.__init__(self, _('Personal Identity Number (PIN):'))
- self._model = model
-
- def get_value(self):
- return self._model.get_pin()
-
- def set_value(self, pin):
- self._model.set_pin(pin)
-
-class PukEntry(EntryWithLabel):
- def __init__(self, model):
- EntryWithLabel.__init__(self, _('Personal Unblocking Key (PUK):'))
- self._model = model
-
- def get_value(self):
- return self._model.get_puk()
-
- def set_value(self, puk):
- self._model.set_puk(puk)
-
-
-class ModemConfiguration(SectionView):
- def __init__(self, model, alerts=None):
- SectionView.__init__(self)
-
- self._model = model
- self.restart_alerts = alerts
-
- self.set_border_width(style.DEFAULT_SPACING)
- self.set_spacing(style.DEFAULT_SPACING)
- self._group = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
-
- explanation = _("You will need to provide the following " \
- "information to set up a mobile " \
- "broadband connection to a cellular "\
- "(3G) network.")
- self._text = gtk.Label(explanation)
- self._text.set_width_chars(100)
- self._text.set_line_wrap(True)
- self._text.set_alignment(0, 0)
- self.pack_start(self._text, False)
- self._text.show()
-
- self._username_entry = UsernameEntry(model)
- self._username_entry.connect('notify::is-valid',
- self.__notify_is_valid_cb)
- self._group.add_widget(self._username_entry.label)
- self.pack_start(self._username_entry, expand=False)
- self._username_entry.show()
-
- self._password_entry = PasswordEntry(model)
- self._password_entry.connect('notify::is-valid',
- self.__notify_is_valid_cb)
- self._group.add_widget(self._password_entry.label)
- self.pack_start(self._password_entry, expand=False)
- self._password_entry.show()
-
- self._number_entry = NumberEntry(model)
- self._number_entry.connect('notify::is-valid',
- self.__notify_is_valid_cb)
- self._group.add_widget(self._number_entry.label)
- self.pack_start(self._number_entry, expand=False)
- self._number_entry.show()
-
- self._apn_entry = ApnEntry(model)
- self._apn_entry.connect('notify::is-valid',
- self.__notify_is_valid_cb)
- self._group.add_widget(self._apn_entry.label)
- self.pack_start(self._apn_entry, expand=False)
- self._apn_entry.show()
-
- self._pin_entry = PinEntry(model)
- self._pin_entry.connect('notify::is-valid',
- self.__notify_is_valid_cb)
- self._group.add_widget(self._pin_entry.label)
- self.pack_start(self._pin_entry, expand=False)
- self._pin_entry.show()
-
- self._puk_entry = PukEntry(model)
- self._puk_entry.connect('notify::is-valid',
- self.__notify_is_valid_cb)
- self._group.add_widget(self._puk_entry.label)
- self.pack_start(self._puk_entry, expand=False)
- self._puk_entry.show()
-
- self.setup()
-
- def setup(self):
- self._username_entry.set_text_from_model()
- self._password_entry.set_text_from_model()
- self._number_entry.set_text_from_model()
- self._apn_entry.set_text_from_model()
- self._pin_entry.set_text_from_model()
- self._puk_entry.set_text_from_model()
-
- self.needs_restart = False
-
- def undo(self):
- self._model.undo()
-
- def _validate(self):
- if self._username_entry.is_valid and \
- self._password_entry.is_valid and \
- self._number_entry.is_valid and \
- self._apn_entry.is_valid and \
- self._pin_entry.is_valid and \
- self._puk_entry.is_valid:
- self.props.is_valid = True
- else:
- self.props.is_valid = False
-
- def __notify_is_valid_cb(self, entry, pspec):
- if entry.is_valid:
- self.needs_restart = True
- self._validate()
-
diff --git a/extensions/cpsection/network/model.py b/extensions/cpsection/network/model.py
index 945254a..87db6d9 100644
--- a/extensions/cpsection/network/model.py
+++ b/extensions/cpsection/network/model.py
@@ -15,14 +15,9 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
-import logging
import dbus
from gettext import gettext as _
-from jarabe.model import network
import gconf
-import os
-
-_logger = logging.getLogger('ControlPanel - Network')
_NM_SERVICE = 'org.freedesktop.NetworkManager'
_NM_PATH = '/org/freedesktop/NetworkManager'
@@ -67,107 +62,50 @@ def _restart_jabber():
_PS_INTERFACE)
except dbus.DBusException:
raise ReadError('%s service not available' % _PS_SERVICE)
- ps.RetryConnections()
+ ps.RestartServerConnection()
-def print_radio():
- print ('off', 'on')[get_radio()]
-
-def get_radio_nm():
- """ Get the state of NetworkManager
- The user can enable/disable wireless and/or networking
- return true only if wireless and network are enabled
- """
+def get_radio():
bus = dbus.SystemBus()
try:
obj = bus.get_object(_NM_SERVICE, _NM_PATH)
- nm_props = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
+ nm_props = dbus.Interface(obj, 'org.freedesktop.DBus.Properties')
except dbus.DBusException:
raise ReadError('%s service not available' % _NM_SERVICE)
- state = nm_props.Get(_NM_IFACE, 'NetworkingEnabled')
- wireless_state = nm_props.Get(_NM_IFACE, 'WirelessEnabled')
- _logger.debug('nm state: %s' % state)
- _logger.debug('nm wireless_state: %s' % wireless_state)
- if state in (0, 1) and wireless_state in (0, 1):
- return (state == 1) and (wireless_state == 1)
+ state = nm_props.Get(_NM_IFACE, 'WirelessEnabled')
+ if state in (0, 1):
+ return state
else:
raise ReadError(_('State is unknown.'))
-def set_radio_nm(state):
- """Enable/disable NetworkManager
- state : 'on/off'
- """
- if not state in ('on', 1, 'off', 0):
- raise ValueError(_("Error in specified radio argument use on/off."))
-
- bus = dbus.SystemBus()
- try:
- obj = bus.get_object(_NM_SERVICE, _NM_PATH)
- nm_props = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
- nm = dbus.Interface(obj, _NM_IFACE)
- except dbus.DBusException:
- raise ReadError('%s service not available' % _NM_SERVICE)
-
- if state == 'on' or state == 1:
- new_state = True
- else:
- new_state = False
-
- prev_state = nm_props.Get(_NM_IFACE, 'NetworkingEnabled')
- if prev_state != new_state:
- nm.Enable(new_state)
- nm_props.Set(_NM_IFACE, 'WirelessEnabled', new_state)
-
- return 0
-
-def get_radio_rfkill():
- pipe_stdout = os.popen('/sbin/rfkill list wifi', 'r')
- try:
- output = pipe_stdout.read()
- _logger.debug('rfkill said: %s' % output)
- blocked = " blocked: yes" in output
- # if not soft- or hard-blocked, radio is on
- return not blocked
-
- finally:
- pipe_stdout.close()
-
-RFKILL_STATE_FILE = '/home/olpc/.rfkill_block_wifi'
-
-def set_radio_rfkill(state):
+def print_radio():
+ print ('off', 'on')[get_radio()]
+
+def set_radio(state):
"""Turn Radio 'on' or 'off'
state : 'on/off'
- """
+ """
if state == 'on' or state == 1:
- os.spawnl(os.P_WAIT, "/sbin/rfkill", "rfkill", "unblock", "wifi")
- # remove the flag file (checked at boot)
+ bus = dbus.SystemBus()
try:
- os.unlink(RFKILL_STATE_FILE)
- except:
- _logger.debug('File %s was not unlinked' % RFKILL_STATE_FILE)
+ obj = bus.get_object(_NM_SERVICE, _NM_PATH)
+ nm_props = dbus.Interface(obj, 'org.freedesktop.DBus.Properties')
+ except dbus.DBusException:
+ raise ReadError('%s service not available' % _NM_SERVICE)
+ nm_props.Set(_NM_IFACE, 'WirelessEnabled', True)
elif state == 'off' or state == 0:
- os.spawnl(os.P_WAIT, "/sbin/rfkill", "rfkill", "block", "wifi")
- # touch the flag file
+ bus = dbus.SystemBus()
try:
- fd = open(RFKILL_STATE_FILE, 'w')
- except IOError:
- _logger.debug('File %s is not writeable' % RFKILL_STATE_FILE)
- else:
- fd.close()
+ obj = bus.get_object(_NM_SERVICE, _NM_PATH)
+ nm_props = dbus.Interface(obj, 'org.freedesktop.DBus.Properties')
+ except dbus.DBusException:
+ raise ReadError('%s service not available' % _NM_SERVICE)
+ nm_props.Set(_NM_IFACE, 'WirelessEnabled', False)
else:
raise ValueError(_("Error in specified radio argument use on/off."))
return 0
-def get_radio():
- """Get status from rfkill and nm"""
- return get_radio_rfkill() and get_radio_nm()
-
-def set_radio(state):
- """ Set status to dot-file and rfkill, and nm"""
- set_radio_rfkill(state)
- set_radio_nm(state)
-
def clear_registration():
"""Clear the registration with the schoolserver
"""
@@ -178,16 +116,13 @@ def clear_registration():
def clear_networks():
"""Clear saved passwords and network configurations.
"""
- network.clear_connections()
-
-def count_networks():
- return network.count_connections()
+ pass
def get_publish_information():
client = gconf.client_get_default()
publish = client.get_bool('/desktop/sugar/collaboration/publish_gadget')
return publish
-
+
def print_publish_information():
print get_publish_information()
diff --git a/extensions/cpsection/network/view.py b/extensions/cpsection/network/view.py
index c387667..ef28f00 100644
--- a/extensions/cpsection/network/view.py
+++ b/extensions/cpsection/network/view.py
@@ -101,8 +101,6 @@ class Network(SectionView):
self._clear_history_button = gtk.Button()
self._clear_history_button.set_label(_('Discard network history'))
box_clear_history.pack_start(self._clear_history_button, expand=False)
- if self._model.count_networks() == 0:
- self._clear_history_button.set_sensitive(False)
self._clear_history_button.show()
box_wireless.pack_start(box_clear_history, expand=False)
box_clear_history.show()
@@ -210,9 +208,7 @@ class Network(SectionView):
self._radio_alert.props.msg = detail
self._radio_valid = False
else:
- self._radio_valid = True
- if self._model.count_networks() != 0:
- self._clear_history_button.set_sensitive(True)
+ self._radio_valid = True
self._validate()
return False
@@ -243,5 +239,3 @@ class Network(SectionView):
def __network_configuration_reset_cb(self, widget):
self._model.clear_networks()
- if self._model.count_networks() == 0:
- self._clear_history_button.set_sensitive(False)
diff --git a/extensions/cpsection/power/model.py b/extensions/cpsection/power/model.py
index c580439..33ec905 100644
--- a/extensions/cpsection/power/model.py
+++ b/extensions/cpsection/power/model.py
@@ -66,10 +66,7 @@ def set_automatic_pm(enabled):
else:
fd.close()
else:
- try:
- os.unlink(POWERD_INHIBIT_FLAG)
- except:
- _logger.debug('File %s was not unlinked' % POWERD_INHIBIT_FLAG)
+ os.unlink(POWERD_INHIBIT_FLAG)
return 0
# ohmd
@@ -90,3 +87,29 @@ def set_automatic_pm(enabled):
client.set_bool('/desktop/sugar/power/automatic', enabled)
return 0
+def get_extreme_pm():
+ client = gconf.client_get_default()
+ return client.get_bool('/desktop/sugar/power/extreme')
+
+def print_extreme_pm():
+ print ('off', 'on')[get_extreme_pm()]
+
+def set_extreme_pm(enabled):
+ """Extreme power management on/off."""
+
+ bus = dbus.SystemBus()
+ proxy = bus.get_object(OHM_SERVICE_NAME, OHM_SERVICE_PATH)
+ keystore = dbus.Interface(proxy, OHM_SERVICE_IFACE)
+
+ if enabled == 'on' or enabled == 1:
+ keystore.SetKey("suspend.extreme_pm", 1)
+ enabled = True
+ elif enabled == 'off' or enabled == 0:
+ keystore.SetKey("suspend.extreme_pm", 0)
+ enabled = False
+ else:
+ raise ValueError(_("Error in extreme pm argument, use on/off."))
+
+ client = gconf.client_get_default()
+ client.set_bool('/desktop/sugar/power/extreme', enabled)
+ return 0
diff --git a/extensions/cpsection/power/view.py b/extensions/cpsection/power/view.py
index d6e2b8c..8f1ed56 100644
--- a/extensions/cpsection/power/view.py
+++ b/extensions/cpsection/power/view.py
@@ -29,6 +29,8 @@ class Power(SectionView):
self._model = model
self.restart_alerts = alerts
self._automatic_pm_valid = True
+ self._extreme_pm_valid = True
+ self._extreme_pm_change_handler = None
self._automatic_pm_change_handler = None
self.set_border_width(style.DEFAULT_SPACING * 2)
@@ -36,6 +38,7 @@ class Power(SectionView):
group = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
self._automatic_pm_alert_box = gtk.HBox(spacing=style.DEFAULT_SPACING)
+ self._extreme_pm_alert_box = gtk.HBox(spacing=style.DEFAULT_SPACING)
separator_pm = gtk.HSeparator()
self.pack_start(separator_pm, expand=False)
@@ -77,6 +80,35 @@ class Power(SectionView):
self._automatic_pm_alert.props.msg = self.restart_msg
self._automatic_pm_alert.show()
+ box_extreme_pm = gtk.HBox(spacing=style.DEFAULT_SPACING)
+ label_extreme_pm = gtk.Label(
+ _('Extreme power management (disables' \
+ 'wireless radio, increases battery life)'))
+ label_extreme_pm.set_alignment(0, 0.5)
+ self._extreme_button = gtk.CheckButton()
+ self._extreme_button.set_alignment(0, 0)
+ box_extreme_pm.pack_start(self._extreme_button, expand=False)
+ self._extreme_button.show()
+ box_extreme_pm.pack_start(label_extreme_pm, expand=False)
+ group.add_widget(label_extreme_pm)
+ label_extreme_pm.show()
+ box_pm.pack_start(box_extreme_pm, expand=False)
+ box_extreme_pm.show()
+
+ self._extreme_pm_alert = InlineAlert()
+ label_extreme_pm_error = gtk.Label()
+ group.add_widget(label_extreme_pm_error)
+ self._extreme_pm_alert_box.pack_start(label_extreme_pm_error,
+ expand=False)
+ label_extreme_pm_error.show()
+ self._extreme_pm_alert_box.pack_start(self._extreme_pm_alert,
+ expand=False)
+ box_pm.pack_end(self._extreme_pm_alert_box, expand=False)
+ self._extreme_pm_alert_box.show()
+ if 'extreme_pm' in self.restart_alerts:
+ self._extreme_pm_alert.props.msg = self.restart_msg
+ self._extreme_pm_alert.show()
+
self.pack_start(box_pm, expand=False)
box_pm.show()
@@ -85,26 +117,38 @@ class Power(SectionView):
def setup(self):
try:
automatic_state = self._model.get_automatic_pm()
+ extreme_state = self._model.get_extreme_pm()
except Exception, detail:
self._automatic_pm_alert.props.msg = detail
self._automatic_pm_alert.show()
+ self._extreme_pm_alert.props.msg = detail
+ self._extreme_pm_alert.show()
else:
self._automatic_button.set_active(automatic_state)
+ self._extreme_button.set_active(extreme_state)
+ self._extreme_pm_valid = True
self._automatic_pm_valid = True
self.needs_restart = False
self._automatic_pm_change_handler = self._automatic_button.connect( \
'toggled', self.__automatic_pm_toggled_cb)
+ self._extreme_pm_change_handler = self._extreme_button.connect( \
+ 'toggled', self.__extreme_pm_toggled_cb)
def undo(self):
self._automatic_button.disconnect(self._automatic_pm_change_handler)
+ self._extreme_button.disconnect(self._extreme_pm_change_handler)
self._model.undo()
+ self._extreme_pm_alert.hide()
self._automatic_pm_alert.hide()
def _validate(self):
- self.props.is_valid = self._automatic_pm_valid
+ if self._extreme_pm_valid and self._automatic_pm_valid:
+ self.props.is_valid = True
+ else:
+ self.props.is_valid = False
def __automatic_pm_toggled_cb(self, widget, data=None):
state = widget.get_active()
@@ -119,3 +163,15 @@ class Power(SectionView):
self._validate()
return False
+ def __extreme_pm_toggled_cb(self, widget, data=None):
+ state = widget.get_active()
+ try:
+ self._model.set_extreme_pm(state)
+ except Exception, detail:
+ print detail
+ self._extreme_pm_alert.props.msg = detail
+ else:
+ self._extreme_pm_valid = True
+
+ self._validate()
+ return False