def _add_proxy_section(self, workspace): label_proxy = Gtk.Label(_('Proxy')) label_proxy.set_alignment(0, 0) workspace.pack_start(label_proxy, False, True, 0) label_proxy.show() box_proxy = Gtk.VBox() box_proxy.set_border_width(style.DEFAULT_SPACING * 2) box_proxy.set_spacing(style.DEFAULT_SPACING) workspace.pack_start(box_proxy, False, True, 0) box_proxy.show() self._proxy_alert = Alert() self._proxy_alert.props.title = _('Error') self._proxy_alert.props.msg = _('Proxy settings cannot be verified') box_proxy.pack_start(self._proxy_alert, False, False, 0) self._proxy_alert.connect('response', self._response_cb) self._proxy_alert.hide() # GSettings schemas for proxy: schemas = [ 'org.sugarlabs.system.proxy', 'org.sugarlabs.system.proxy.http', 'org.sugarlabs.system.proxy.https', 'org.sugarlabs.system.proxy.ftp', 'org.sugarlabs.system.proxy.socks' ] for schema in schemas: proxy_setting = Gio.Settings.new(schema) # We are not going to apply the settings immediatly. # We'll apply them if the user presses the "accept" # button, or we'll revert them if the user presses the # "cancel" button. proxy_setting.delay() alert = InlineAlert() self._proxy_settings[schema] = proxy_setting self._proxy_inline_alerts[schema] = alert size_group = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL) automatic_proxy_box = Gtk.VBox(spacing=style.DEFAULT_SPACING) manual_proxy_box = Gtk.VBox(spacing=style.DEFAULT_SPACING) option_sets = [('None', 'none', Gtk.VBox()), ('Use system proxy', 'system', Gtk.VBox()), ('Manual', 'manual', manual_proxy_box), ('Automatic', 'auto', automatic_proxy_box)] box_mode = ComboSettingBox( _('Method:'), self._proxy_settings['org.sugarlabs.system.proxy'], 'mode', option_sets, size_group) box_proxy.pack_start(box_mode, False, False, 0) box_mode.show() url_box = StringSettingBox( _('Configuration URL:'), self._proxy_settings['org.sugarlabs.system.proxy'], 'autoconfig-url', size_group) automatic_proxy_box.pack_start(url_box, True, True, 0) url_box.show() wpad_help_text = _('Web Proxy Autodiscovery is used when a' ' Configuration URL is not provided. This is not' ' recommended for untrusted public networks.') automatic_proxy_help = Gtk.Label(wpad_help_text) automatic_proxy_help.set_alignment(0, 0) automatic_proxy_help.set_line_wrap(True) automatic_proxy_help.show() automatic_proxy_box.pack_start(automatic_proxy_help, True, True, 0) # HTTP Section schema = 'org.sugarlabs.system.proxy.http' box_http = HostPortSettingBox(_('HTTP Proxy:'), self._proxy_inline_alerts[schema], self._proxy_settings[schema], size_group) manual_proxy_box.pack_start(box_http, False, False, 0) box_http.show() auth_contents_box = Gtk.VBox(spacing=style.DEFAULT_SPACING) auth_box = OptionalSettingsBox(_('Use authentication'), self._proxy_settings[schema], 'use-authentication', auth_contents_box) manual_proxy_box.pack_start(auth_box, False, False, 0) auth_box.show() proxy_http_setting = Gio.Settings.new(schema) proxy_http_setting.delay() box_username = StringSettingBox(_('Username:'******'authentication-user', size_group) auth_contents_box.pack_start(box_username, False, False, 0) box_username.show() box_password = StringSettingBox(_('Password:'******'authentication-password', size_group, password_field=True) auth_contents_box.pack_start(box_password, False, False, 0) box_password.show() # HTTPS Section schema = 'org.sugarlabs.system.proxy.https' box_https = HostPortSettingBox(_('HTTPS Proxy:'), self._proxy_inline_alerts[schema], self._proxy_settings[schema], size_group) manual_proxy_box.pack_start(box_https, False, False, 0) box_https.show() # FTP Section schema = 'org.sugarlabs.system.proxy.ftp' box_ftp = HostPortSettingBox(_('FTP Proxy:'), self._proxy_inline_alerts[schema], self._proxy_settings[schema], size_group) manual_proxy_box.pack_start(box_ftp, False, False, 0) box_ftp.show() # SOCKS Section schema = 'org.sugarlabs.system.proxy.socks' box_socks = HostPortSettingBox(_('SOCKS Proxy:'), self._proxy_inline_alerts[schema], self._proxy_settings[schema], size_group) manual_proxy_box.pack_start(box_socks, False, False, 0) box_socks.show() box_ignore = StringSettingBox_with_convert( _('Ignore Hosts:'), self._proxy_settings['org.sugarlabs.system.proxy'], 'ignore-hosts', type_as_to_string, string_to_type_as, size_group) manual_proxy_box.pack_start(box_ignore, False, False, 0) box_ignore.show()
def __init__(self, model, alerts): SectionView.__init__(self) self._model = model self.restart_alerts = alerts self._lang_sid = 0 self._selected_lang_count = 0 self._labels = [] self._language_dict = {} self._country_dict = {} self._language_buttons = [] self._country_buttons = [] self._language_widgets = [] self._country_widgets = [] self._country_codes = [] self._add_remove_boxes = [] self._changed = False self._cursor_change_handler = None self._available_locales = self._model.read_all_languages() self._selected_locales = self._model.get_languages() for language, country, code in self._available_locales: if language not in self._language_dict: self._language_dict[language] = _translate_language(language) self._country_dict[language] = [[code, country]] else: self._country_dict[language].append([code, country]) self.set_border_width(style.DEFAULT_SPACING * 2) self.set_spacing(style.DEFAULT_SPACING) explanation = gettext.gettext('Add languages in the order you prefer.' ' If a translation is not available,' ' the next in the list will be used.') self._text = Gtk.Label(label=explanation) self._text.set_line_wrap(True) self._text.set_alignment(0, 0) self.pack_start(self._text, False, False, 0) self._text.show() scrolled = Gtk.ScrolledWindow() scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) scrolled.show() self.pack_start(scrolled, True, True, 0) self._table = Gtk.Table(rows=2, columns=4, homogeneous=False) self._table.set_border_width(style.DEFAULT_SPACING * 2) self._table.show() scrolled.add_with_viewport(self._table) self._lang_alert_box = Gtk.HBox(spacing=style.DEFAULT_SPACING) self.pack_start(self._lang_alert_box, False, True, 0) self._lang_alert = InlineAlert() self._lang_alert_box.pack_start(self._lang_alert, True, True, 0) if 'lang' in self.restart_alerts: self._lang_alert.props.msg = self.restart_msg self._lang_alert.show() self._lang_alert_box.show() self.setup()
def __init__(self, model, alerts): SectionView.__init__(self) self._model = model self.restart_alerts = alerts self._jabber_sid = 0 self._radio_valid = True self._jabber_change_handler = None self._radio_change_handler = None self._wireless_configuration_reset_handler = None self._start_jabber = self._model.get_jabber() self._proxy_settings = {} self._proxy_inline_alerts = {} self.set_border_width(style.DEFAULT_SPACING * 2) self.set_spacing(style.DEFAULT_SPACING) group = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL) self._radio_alert_box = Gtk.HBox(spacing=style.DEFAULT_SPACING) scrolled = Gtk.ScrolledWindow() scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) self.add(scrolled) scrolled.show() workspace = Gtk.VBox() scrolled.add_with_viewport(workspace) workspace.show() separator_wireless = Gtk.HSeparator() workspace.pack_start(separator_wireless, False, True, 0) separator_wireless.show() label_wireless = Gtk.Label(label=_('Wireless')) label_wireless.set_alignment(0, 0) workspace.pack_start(label_wireless, False, True, 0) label_wireless.show() box_wireless = Gtk.VBox() box_wireless.set_border_width(style.DEFAULT_SPACING * 2) box_wireless.set_spacing(style.DEFAULT_SPACING) radio_info = Gtk.Label(label=_('The wireless radio may be turned' ' off to save battery life.')) radio_info.set_alignment(0, 0) radio_info.set_line_wrap(True) radio_info.show() box_wireless.pack_start(radio_info, False, True, 0) box_radio = Gtk.HBox(spacing=style.DEFAULT_SPACING) self._button = Gtk.CheckButton() self._button.set_alignment(0, 0) box_radio.pack_start(self._button, False, True, 0) self._button.show() label_radio = Gtk.Label(label=_('Radio')) label_radio.set_alignment(0, 0.5) box_radio.pack_start(label_radio, False, True, 0) label_radio.show() box_wireless.pack_start(box_radio, False, True, 0) box_radio.show() self._radio_alert = InlineAlert() self._radio_alert_box.pack_start(self._radio_alert, False, True, 0) box_radio.pack_end(self._radio_alert_box, False, True, 0) self._radio_alert_box.show() if 'radio' in self.restart_alerts: self._radio_alert.props.msg = self.restart_msg self._radio_alert.show() wireless_info = Gtk.Label( label=_('Discard wireless connections if' ' you have trouble connecting to the network')) wireless_info.set_alignment(0, 0) wireless_info.set_line_wrap(True) wireless_info.show() box_wireless.pack_start(wireless_info, False, True, 0) box_clear_wireless = Gtk.HBox(spacing=style.DEFAULT_SPACING) self._clear_wireless_button = Gtk.Button() self._clear_wireless_button.set_label( _('Discard wireless connections')) box_clear_wireless.pack_start(self._clear_wireless_button, False, True, 0) if not self._model.have_wireless_networks(): self._clear_wireless_button.set_sensitive(False) self._clear_wireless_button.show() box_wireless.pack_start(box_clear_wireless, False, True, 0) box_clear_wireless.show() workspace.pack_start(box_wireless, False, True, 0) box_wireless.show() separator_mesh = Gtk.HSeparator() workspace.pack_start(separator_mesh, False, False, 0) separator_mesh.show() label_mesh = Gtk.Label(label=_('Collaboration')) label_mesh.set_alignment(0, 0) workspace.pack_start(label_mesh, False, True, 0) label_mesh.show() box_mesh = Gtk.VBox() box_mesh.set_border_width(style.DEFAULT_SPACING * 2) box_mesh.set_spacing(style.DEFAULT_SPACING) server_info = Gtk.Label( _("The server is the equivalent of what" " room you are in; people on the same server" " will be able to see each other, even when" " they aren't on the same network.")) server_info.set_alignment(0, 0) server_info.set_line_wrap(True) box_mesh.pack_start(server_info, False, True, 0) server_info.show() box_server = Gtk.HBox(spacing=style.DEFAULT_SPACING) label_server = Gtk.Label(label=_('Server:')) label_server.set_alignment(1, 0.5) label_server.modify_fg(Gtk.StateType.NORMAL, style.COLOR_SELECTION_GREY.get_gdk_color()) box_server.pack_start(label_server, False, True, 0) group.add_widget(label_server) label_server.show() self._entry = Gtk.Entry() self._entry.set_alignment(0) self._entry.set_size_request(int(Gdk.Screen.width() / 3), -1) box_server.pack_start(self._entry, False, True, 0) self._entry.show() box_mesh.pack_start(box_server, False, True, 0) box_server.show() social_help_info = Gtk.Label( _('Social Help is a forum that lets you connect with developers' ' and discuss Sugar Activities. Changing servers means' ' discussions will happen in a different place with' ' different people.')) social_help_info.set_alignment(0, 0) social_help_info.set_line_wrap(True) box_mesh.pack_start(social_help_info, False, True, 0) social_help_info.show() social_help_box = Gtk.HBox(spacing=style.DEFAULT_SPACING) social_help_label = Gtk.Label(label=_('Social Help Server:')) social_help_label.set_alignment(1, 0.5) social_help_label.modify_fg(Gtk.StateType.NORMAL, style.COLOR_SELECTION_GREY.get_gdk_color()) social_help_box.pack_start(social_help_label, False, True, 0) group.add_widget(social_help_label) social_help_label.show() self._social_help_entry = Gtk.Entry() self._social_help_entry.set_alignment(0) self._social_help_entry.set_size_request(int(Gdk.Screen.width() / 3), -1) social_help_box.pack_start(self._social_help_entry, False, True, 0) self._social_help_entry.show() box_mesh.pack_start(social_help_box, False, True, 0) social_help_box.show() workspace.pack_start(box_mesh, False, True, 0) box_mesh.show() separator_proxy = Gtk.HSeparator() workspace.pack_start(separator_proxy, False, False, 0) separator_proxy.show() self._add_proxy_section(workspace) self.setup()