On Mon, Jun 14, 2010 at 06:14, Andrés Ambrois <andresambr...@gmail.com> wrote: > Display comboboxes for selecting a data plan for each country and > provider if the mobile-broadband-providers-info package is installed. > Populate the connection parameters with the info from the selected data > plan. > > Signed-off-by: Andrés Ambrois <andresambr...@gmail.com> > > diff --git a/extensions/cpsection/modemconfiguration/view.py > b/extensions/cpsection/modemconfiguration/view.py > index b236f3f..e2fdd53 100644 > --- a/extensions/cpsection/modemconfiguration/view.py > +++ b/extensions/cpsection/modemconfiguration/view.py > @@ -160,61 +160,142 @@ class ModemConfiguration(SectionView): > 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) > + > + label_group = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL) > + > + scrolled_win = gtk.ScrolledWindow()
Better try to avoid abbreviations. > + scrolled_win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) > + scrolled_win.show() > + self.add(scrolled_win) > + > + main_box = gtk.VBox(spacing=style.DEFAULT_SPACING) > + main_box.set_border_width(style.DEFAULT_SPACING) > + main_box.show() > + scrolled_win.add_with_viewport(main_box) > > 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) > + main_box.pack_start(self._text, False) > self._text.show() > > + if model.has_providers_db(): Put this in a separate private method so __init__ doesn't grow so big? Nothing else, please wait a bit before pushing this so people have time to comment on the UX. Next time is better to start the design discussion as soon as possible, even if there's no code or mockups yet. Also may be better to hold off the commits and do one more review round if you aren't 100% confident about the XDG data dirs thing. Thanks a lot for following the code style of the existing code, this has made the review much faster. Regards, Tomeu > + self._upper_box = gtk.VBox(spacing=style.DEFAULT_SPACING) > + self._upper_box.set_border_width(style.DEFAULT_SPACING) > + main_box.pack_start(self._upper_box, expand=False) > + self._upper_box.show() > + > + combo_group = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL) > + > + box = gtk.HBox(spacing=style.DEFAULT_SPACING) > + label = gtk.Label(_('Country:')) > + label_group.add_widget(label) > + box.pack_start(label, False) > + label.show() > + country_store = model.CountryListStore() > + country_combo = gtk.ComboBox(country_store) > + combo_group.add_widget(country_combo) > + cell = gtk.CellRendererText() > + cell.props.xalign = 0.5 > + country_combo.pack_start(cell) > + country_combo.add_attribute(cell, 'text', 0) > + country_combo.connect('changed', self.__country_selected_cb) > + box.pack_start(country_combo, False) > + country_combo.show() > + self._upper_box.pack_start(box, False) > + box.show() > + > + box = gtk.HBox(spacing=style.DEFAULT_SPACING) > + label = gtk.Label(_('Provider:')) > + label_group.add_widget(label) > + box.pack_start(label, False) > + label.show() > + self._providers_combo = gtk.ComboBox() > + combo_group.add_widget(self._providers_combo) > + cell = gtk.CellRendererText() > + cell.props.xalign = 0.5 > + self._providers_combo.pack_start(cell) > + self._providers_combo.add_attribute(cell, 'text', 0) > + self._providers_combo.connect('changed', > + self.__provider_selected_cb) > + box.pack_start(self._providers_combo, False) > + self._providers_combo.show() > + self._upper_box.pack_start(box, False) > + box.show() > + > + box = gtk.HBox(spacing=style.DEFAULT_SPACING) > + label = gtk.Label(_('Plan:')) > + label_group.add_widget(label) > + box.pack_start(label, False) > + label.show() > + self._plan_combo = gtk.ComboBox() > + combo_group.add_widget(self._plan_combo) > + cell = gtk.CellRendererText() > + cell.props.xalign = 0.5 > + self._plan_combo.pack_start(cell) > + self._plan_combo.add_attribute(cell, 'text', 0) > + self._plan_combo.connect('changed', self.__plan_selected_cb) > + box.pack_start(self._plan_combo, False) > + self._plan_combo.show() > + self._upper_box.pack_start(box, False) > + box.show() > + > + country_combo.set_active(country_store.guess_country_row()) > + > + separator = gtk.HSeparator() > + main_box.pack_start(separator, False) > + separator.show() > + > + self._lower_box = gtk.VBox(spacing=style.DEFAULT_SPACING) > + self._lower_box.set_border_width(style.DEFAULT_SPACING) > + main_box.pack_start(self._lower_box, expand=False) > + self._lower_box.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) > + label_group.add_widget(self._username_entry.label) > + self._lower_box.pack_start(self._username_entry, fill=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) > + label_group.add_widget(self._password_entry.label) > + self._lower_box.pack_start(self._password_entry, fill=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) > + label_group.add_widget(self._number_entry.label) > + self._lower_box.pack_start(self._number_entry, fill=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) > + label_group.add_widget(self._apn_entry.label) > + self._lower_box.pack_start(self._apn_entry, fill=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) > + label_group.add_widget(self._pin_entry.label) > + self._lower_box.pack_start(self._pin_entry, fill=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) > + label_group.add_widget(self._puk_entry.label) > + self._lower_box.pack_start(self._puk_entry, fill=False) > self._puk_entry.show() > > self.setup() > @@ -232,6 +313,29 @@ class ModemConfiguration(SectionView): > def undo(self): > self._model.undo() > > + def __country_selected_cb(self, combo): > + model = combo.get_model() > + providers = model.get_row_providers(combo.get_active()) > + self._providers_combo.set_model( > + self._model.ProviderListStore(providers)) > + > + def __provider_selected_cb(self, combo): > + model = combo.get_model() > + plans = model.get_row_plans(combo.get_active()) > + self._plan_combo.set_model(self._model.PlanListStore(plans)) > + > + def __plan_selected_cb(self, combo): > + model = combo.get_model() > + plan = model.get_row_plan(combo.get_active()) > + self._username_entry.set_value(plan['username']) > + self._username_entry.set_text_from_model() > + self._password_entry.set_value(plan['password']) > + self._password_entry.set_text_from_model() > + self._number_entry.set_value(plan['number']) > + self._number_entry.set_text_from_model() > + self._apn_entry.set_value(plan['apn']) > + self._apn_entry.set_text_from_model() > + > def _validate(self): > if self._username_entry.is_valid and \ > self._password_entry.is_valid and \ > -- > 1.6.3.3 > > _______________________________________________ > Sugar-devel mailing list > Sugar-devel@lists.sugarlabs.org > http://lists.sugarlabs.org/listinfo/sugar-devel > _______________________________________________ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel