Re: [Sugar-devel] [PATCH 2/3] Show Country/Provider/Plan comboboxes if DB exists.
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)
[Sugar-devel] [PATCH 2/3] Show Country/Provider/Plan comboboxes if DB exists.
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() +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(): +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)