diff options
Diffstat (limited to 'extensions/cpsection/modemconfiguration/view.py')
-rw-r--r-- | extensions/cpsection/modemconfiguration/view.py | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/extensions/cpsection/modemconfiguration/view.py b/extensions/cpsection/modemconfiguration/view.py index b236f3f..c31edba 100644 --- a/extensions/cpsection/modemconfiguration/view.py +++ b/extensions/cpsection/modemconfiguration/view.py @@ -25,10 +25,12 @@ from sugar.graphics import style from jarabe.controlpanel.sectionview import SectionView + APPLY_TIMEOUT = 1000 + class EntryWithLabel(gtk.HBox): - __gtype_name__ = "SugarEntryWithLabel" + __gtype_name__ = 'SugarEntryWithLabel' def __init__(self, label_text): gtk.HBox.__init__(self, spacing=style.DEFAULT_SPACING) @@ -53,7 +55,7 @@ class EntryWithLabel(gtk.HBox): 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_sid = gobject.timeout_add(APPLY_TIMEOUT, self.__timeout_cb) def __timeout_cb(self): @@ -63,7 +65,7 @@ class EntryWithLabel(gtk.HBox): return False try: - self.set_value(self._entry.get_text()) + self.set_value(self._entry.get_text()) except ValueError: self._is_valid = False else: @@ -74,18 +76,19 @@ class EntryWithLabel(gtk.HBox): return False def set_text_from_model(self): - self._entry.set_text(self.get_value()) + self._entry.set_text(self.get_value()) def get_value(self): raise NotImplementedError def set_value(self): - raise NotImplementedError + 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:')) @@ -97,6 +100,7 @@ class UsernameEntry(EntryWithLabel): def set_value(self, username): self._model.set_username(username) + class PasswordEntry(EntryWithLabel): def __init__(self, model): EntryWithLabel.__init__(self, _('Password:')) @@ -108,6 +112,7 @@ class PasswordEntry(EntryWithLabel): def set_value(self, password): self._model.set_password(password) + class NumberEntry(EntryWithLabel): def __init__(self, model): EntryWithLabel.__init__(self, _('Number:')) @@ -119,6 +124,7 @@ class NumberEntry(EntryWithLabel): def set_value(self, number): self._model.set_number(number) + class ApnEntry(EntryWithLabel): def __init__(self, model): EntryWithLabel.__init__(self, _('Access Point Name (APN):')) @@ -130,6 +136,7 @@ class ApnEntry(EntryWithLabel): def set_value(self, apn): self._model.set_apn(apn) + class PinEntry(EntryWithLabel): def __init__(self, model): EntryWithLabel.__init__(self, _('Personal Identity Number (PIN):')) @@ -141,6 +148,7 @@ class PinEntry(EntryWithLabel): def set_value(self, pin): self._model.set_pin(pin) + class PukEntry(EntryWithLabel): def __init__(self, model): EntryWithLabel.__init__(self, _('Personal Unblocking Key (PUK):')) @@ -164,10 +172,9 @@ class ModemConfiguration(SectionView): 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.") + 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) @@ -209,12 +216,12 @@ class ModemConfiguration(SectionView): 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.pack_start(self._puk_entry, expand=False) self._puk_entry.show() self.setup() @@ -247,4 +254,3 @@ class ModemConfiguration(SectionView): if entry.is_valid: self.needs_restart = True self._validate() - |