def __init__(self, name, text_size=TITLE_FONT_SIZE, always_show=False, toggle_callback=None, label_right=False): gtk.HBox.__init__(self) self.set_size_request(-1, 30) self.label = Label( name, text_size=text_size, text_color=app_theme.get_color("globalTitleForeground"), enable_select=False, enable_double_click=False) if label_right: self.label_box = style.wrap_with_align(self.label, width=210) else: self.label_box = style.wrap_with_align(self.label, align="left", width=210) self.label_box.set_size_request(210, 30) self.pack_start(self.label_box, False, False) if not always_show: self.switch = SwitchButton( False, inactive_disable_dpixbuf=app_theme.get_pixbuf( "toggle_button/inactive_normal.png"), active_disable_dpixbuf=app_theme.get_pixbuf( "toggle_button/active_disable.png")) align = style.wrap_with_align(self.switch, align="left") self.pack_start(align, False, False) self.switch.connect("toggled", toggle_callback) align.set_padding(0, 0, 15, 0)
def __init__(self, name, text_size = TITLE_FONT_SIZE, always_show = False, toggle_callback=None, label_right=False): gtk.HBox.__init__(self) self.set_size_request(-1, 30) self.label = Label(name, text_size=text_size, text_color=app_theme.get_color("globalTitleForeground"), enable_select=False, enable_double_click=False) if label_right: self.label_box = style.wrap_with_align(self.label, width=210) else: self.label_box = style.wrap_with_align(self.label, align="left", width=210) self.label_box.set_size_request(210, 30) self.pack_start(self.label_box, False, False) if not always_show: self.switch = SwitchButton( False, inactive_disable_dpixbuf = app_theme.get_pixbuf("toggle_button/inactive_normal.png"), active_disable_dpixbuf = app_theme.get_pixbuf("toggle_button/active_disable.png")) align = style.wrap_with_align(self.switch, align="left") self.pack_start(align, False, False) self.switch.connect("toggled", toggle_callback) align.set_padding(0, 0, 15, 0)
def wrap_all_with_align(obj, attr_list, w=None): for attr in attr_list: target = getattr(obj, attr) if w: align = style.wrap_with_align(target, width=w) else: align = style.wrap_with_align(target) setattr(obj, attr + "_align", align)
def __table_attach(self, table, row_item, row): for i, item in enumerate(row_item): if i >= 1: align = style.wrap_with_align(item, align="left") else: align = style.wrap_with_align(item) align.set_size_request(210, -1) table.attach(align, i, i + 1, row, row + 1)
def __table_attach(self, table, row_item, row): for i, item in enumerate(row_item): if i >=1: align = style.wrap_with_align(item, align="left") else: align = style.wrap_with_align(item) align.set_size_request(210, -1) table.attach(align, i, i +1, row, row + 1)
def _wrap_align(self, row_item, table): left, right = row_item left_align = style.wrap_with_align(left, width = self.left_width) right_align = style.wrap_with_align(right, align="left", width=self.right_width) if table == None: self.shared.append((left_align, right_align)) else: table.append((left_align, right_align))
def _wrap_align(self, row_item, table): left, right = row_item left_align = style.wrap_with_align(left, width=self.left_width) right_align = style.wrap_with_align(right, align="left", width=self.right_width) if table == None: self.shared.append((left_align, right_align)) else: table.append((left_align, right_align))
def add_ssid_entry(self): self.wireless = self.connection.get_setting("802-11-wireless") self.ssid_label = Label(_("SSID:"), enable_select=False, enable_double_click=False) self.ssid_label_align = style.wrap_with_align(self.ssid_label, width=210) self.ssid_entry = InputEntry() self.ssid_entry.set_size(self.ENTRY_WIDTH, 22) self.ssid_entry_align = style.wrap_with_align(self.ssid_entry, align="left") self.ssid_entry.entry.connect("changed", self.set_ssid) self.ssid_entry.set_text(self.wireless.ssid)
def __init__(self, pixbuf, title, has_separator=True, text_size=TITLE_FONT_SIZE, text_color=app_theme.get_color("globalTitleForeground"), width=222, left_padding = 0, spacing=10): gtk.VBox.__init__(self) self.set_size_request(width, -1) hbox = gtk.HBox(spacing=spacing) label = Label(title, text_color, text_size, enable_select=False, enable_double_click=False) if pixbuf == None: self.__box_pack_start(hbox, [label]) else: image_box = ImageBox(pixbuf) self.__box_pack_start(hbox, [image_box,label]) align = style.wrap_with_align(hbox, align="left") self.__box_pack_start(self, [align]) if has_separator: separator = HSeparator(app_theme.get_shadow_color("hSeparator").get_color_info(), 0, 0) separator.set_size_request(-1, 10) self.__box_pack_start(self, [separator])
def __init__(self, pixbuf, title, has_separator=True, text_size=TITLE_FONT_SIZE, text_color=app_theme.get_color("globalTitleForeground"), width=222, left_padding=0, spacing=10): gtk.VBox.__init__(self) self.set_size_request(width, -1) hbox = gtk.HBox(spacing=spacing) label = Label(title, text_color, text_size, enable_select=False, enable_double_click=False) if pixbuf == None: self.__box_pack_start(hbox, [label]) else: image_box = ImageBox(pixbuf) self.__box_pack_start(hbox, [image_box, label]) align = style.wrap_with_align(hbox, align="left") self.__box_pack_start(self, [align]) if has_separator: separator = HSeparator( app_theme.get_shadow_color("hSeparator").get_color_info(), 0, 0) separator.set_size_request(-1, 10) self.__box_pack_start(self, [separator])
def add_new_box(self): table = gtk.Table() #hbox.set_size_request(-1, 30) name_label = Label(_("Name:"), enable_select=False) name_label.set_can_focus(False) exec_label = Label(_("Exec:"), enable_select=False) exec_label.set_can_focus(False) desc_label = Label(_("Comment:"), enable_select=False) desc_label.set_can_focus(False) self.name_entry = InputEntry() self.exec_entry = InputEntry() self.desc_entry = InputEntry() self.name_entry.set_size(200, 22) self.exec_entry.set_size(200, 22) self.desc_entry.set_size(200, 22) name_label_align = self.wrap_with_align(name_label) exec_label_align = self.wrap_with_align(exec_label) desc_label_align = self.wrap_with_align(desc_label) name_align = style.wrap_with_align(self.name_entry) exec_align = style.wrap_with_align(self.exec_entry) desc_align = style.wrap_with_align(self.desc_entry) table = gtk.Table(3, 4) self.table_add(table, [name_label_align, exec_label_align, desc_label_align], 0) self.table_add(table, [name_align, exec_align, desc_align], 1) open_folder = ImageButton(self.icon_pixbuf, self.icon_pixbuf, self.icon_pixbuf) open_folder.connect( "clicked", lambda w: OpenFileDialog( "Choose file", self, ok_callback=self.ok_callback)) table.attach(style.wrap_with_align(open_folder), 2, 3, 1, 2) align = gtk.Alignment(0.5, 0, 0, 0) style.set_table(table) align.add(table) return align
def __row_entry_spin(self, label_name, table, types): label = Label(label_name, text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) label.set_can_focus(False) label_align = style.wrap_with_align(label, width = 260) entry = InputEntry() entry.set_size(self.ENTRY_WIDTH, 22) spin = SpinBox(0, 0, 49151, 1, 60) spin.value_entry.connect("changed", lambda w, v: spin.update_and_emit(int(v))) hbox = gtk.HBox(spacing=10) hbox.set_size_request(-1 ,22) hbox_align = style.wrap_with_align(hbox, align="left") hbox.pack_start(entry) hbox.pack_start(spin) table.row_attach((label_align, hbox_align)) return [entry, spin]
def __row_entry_spin(self, label_name, table, types): label = Label(label_name, text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) label.set_can_focus(False) label_align = style.wrap_with_align(label, width=260) entry = InputEntry() entry.set_size(self.ENTRY_WIDTH, 22) spin = SpinBox(0, 0, 49151, 1, 60) spin.value_entry.connect("changed", lambda w, v: spin.update_and_emit(int(v))) hbox = gtk.HBox(spacing=10) hbox.set_size_request(-1, 22) hbox_align = style.wrap_with_align(hbox, align="left") hbox.pack_start(entry) hbox.pack_start(spin) table.row_attach((label_align, hbox_align)) return [entry, spin]
def add_new_box(self): table = gtk.Table() #hbox.set_size_request(-1, 30) name_label = Label(_("Name:"), enable_select=False) name_label.set_can_focus(False) exec_label = Label(_("Exec:"), enable_select=False) exec_label.set_can_focus(False) desc_label = Label(_("Comment:"), enable_select=False) desc_label.set_can_focus(False) self.name_entry = InputEntry() self.exec_entry = InputEntry() self.desc_entry = InputEntry() self.name_entry.set_size(200, 22) self.exec_entry.set_size(200, 22) self.desc_entry.set_size(200, 22) name_label_align = self.wrap_with_align(name_label) exec_label_align = self.wrap_with_align(exec_label) desc_label_align = self.wrap_with_align(desc_label) name_align = style.wrap_with_align(self.name_entry) exec_align = style.wrap_with_align(self.exec_entry) desc_align = style.wrap_with_align(self.desc_entry) table = gtk.Table(3, 4) self.table_add(table, [name_label_align, exec_label_align, desc_label_align], 0) self.table_add(table, [name_align, exec_align, desc_align], 1) open_folder = ImageButton(self.icon_pixbuf, self.icon_pixbuf, self.icon_pixbuf) open_folder.connect("clicked", lambda w: OpenFileDialog("Choose file", self, ok_callback=self.ok_callback)) table.attach(style.wrap_with_align(open_folder), 2, 3, 1, 2) align = gtk.Alignment(0.5, 0, 0, 0) style.set_table(table) align.add(table) return align
def __init__(self, settings_obj=None): gtk.VBox.__init__(self) #self.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) #Dispatcher.set_button = set_button_callback #self.module_frame = module_frame # 新增settings_obj变量,用于访问shared_methods.Settings对象 self.settings_obj = settings_obj self.method_title = TitleBar(None, _("Configure Method"), width=self.TABLE_WIDTH, has_separator=False) self.refuse_eap_label = Label(_("EAP"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.refuse_pap_label = Label(_("PAP"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.refuse_chap_label = Label(_("CHAP"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.refuse_mschap_label = Label(_("MSCHAP"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.refuse_mschapv2_label = Label(_("MSCHAP v2"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.refuse_eap = SwitchButton() self.refuse_pap = SwitchButton() self.refuse_chap = SwitchButton() self.refuse_mschap = SwitchButton() self.refuse_mschapv2 = SwitchButton() self.method_table = gtk.Table(23, 3, False) # visible settings self.compression_title = TitleBar(None, _("Compression"), width=self.TABLE_WIDTH, has_separator=False) self.echo_title = TitleBar(None, _("Echo"), width=self.TABLE_WIDTH, has_separator=False) #compressio))n = Label(_("Compression"), text_size=TITLE_FONT_SIZE) self.require_mppe_label = Label( _("Use point-to-point encryption(mppe)"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.require_mppe_128_label = Label(_("Require 128-bit encryption"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.mppe_stateful_label = Label(_("Use stateful MPPE"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.nobsdcomp_label = Label(_("Allow BSD data Compression"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.nodeflate_label = Label(_("Allow Deflate data compression"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.no_vj_comp_label = Label(_("Use TCP header compression"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) #echo = Label("Echo", text_size=TITLE_FONT_SIZE) self.ppp_echo_label = Label(_("Send PPP echo packets"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.nopcomp_label = Label( _("Use protocal field compression negotiation"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.noaccomp_label = Label(_("Use Address/Control compression"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.require_mppe = SwitchButton() self.require_mppe_128 = SwitchButton() self.mppe_stateful = SwitchButton() self.nobsdcomp = SwitchButton() self.nodeflate = SwitchButton() self.no_vj_comp = SwitchButton() self.nopcomp = SwitchButton() self.noaccomp = SwitchButton() self.ppp_echo = SwitchButton() self.ip_sec_enable = SwitchButton() ## Settings for IPSec self.ipsec_title = TitleBar(None, _("IPSec Setting"), width=self.TABLE_WIDTH, has_separator=False) self.ip_sec_enable_label = Label(_("Enable IPSec tunnel to l2tp host"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.group_name_label = Label(_("Group Name:"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.gateway_id_label = Label(_("Gateway ID:"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.pre_shared_key_label = Label(_("Pre_Shared_key"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.group_name = InputEntry() self.group_name.set_size(self.TABLE_WIDTH, 22) self.gateway_id = InputEntry() self.gateway_id.set_size(self.TABLE_WIDTH, 22) self.pre_shared_key = PasswordEntry() self.pre_shared_key.set_text = self.pre_shared_key.entry.set_text self.pre_shared_key.set_size(self.TABLE_WIDTH, 22) methods_list = [ "refuse_eap", "refuse_eap_label", "refuse_pap", "refuse_pap_label", "refuse_chap", "refuse_chap_label", "refuse_mschap", "refuse_mschap_label", "refuse_mschapv2", "refuse_mschapv2_label" ] compression_list = [ "require_mppe_label", "require_mppe", "require_mppe_128_label", "require_mppe_128", "mppe_stateful_label", "mppe_stateful", "nobsdcomp_label", "nobsdcomp", "nodeflate_label", "nodeflate", "no_vj_comp_label", "no_vj_comp", "nopcomp_label", "nopcomp", "noaccomp_label", "noaccomp" ] echo_list = ["ppp_echo_label", "ppp_echo"] ip_sec_list = [ "ip_sec_enable_label", "ip_sec_enable", "group_name_label", "group_name", "gateway_id_label", "gateway_id", "pre_shared_key_label", "pre_shared_key" ] for name in (compression_list + echo_list + methods_list + ip_sec_list): widget = getattr(self, name) if not name.endswith("label"): align = style.wrap_with_align(widget, align="left") else: align = style.wrap_with_align(widget, width=210) setattr(self, name + "_align", align) #vbox = gtk.VBox() table_align = gtk.Alignment(0, 0, 0, 0) table_align.add(self.method_table) style.set_table(self.method_table) self.pack_start(table_align, False, False) self.method_table.set_row_spacing(5, 20) self.method_table.set_row_spacing(15, 20) self.method_table.set_row_spacing(18, 20) Dispatcher.connect("vpn-type-change", lambda w, c: self.refresh(c))
def __row_check(self, label_name, table, main=None): check = RadioButton(main, label_name) check_align = style.wrap_with_align(check, align="left", width=260) check_align.set_padding(0, 0, 200, 1) table.row_attach(check_align) return check
def init_table(self, network_type): #container_remove_all(self.table) if self.table.get_children() != []: pass else: #self.table.attach(self.label_basic, 0,2 ,0, 1) self.table.attach(style.wrap_with_align(self.label_number, width=self.LEFT_PADDING), 0, 1, 1, 2) self.table.attach(style.wrap_with_align(self.label_username, width=self.LEFT_PADDING), 0, 1, 2, 3) self.table.attach(style.wrap_with_align(self.label_password, width=self.LEFT_PADDING), 0, 1, 3, 4) self.table.attach(style.wrap_with_align(self.number), 1, 2, 1, 2) self.table.attach(style.wrap_with_align(self.username), 1, 2, 2, 3) self.table.attach(style.wrap_with_align(self.password), 1, 2, 3, 4) self.table.attach(style.wrap_with_align(self.password_show, align="left"), 1, 2, 4, 5) def to_region(widget): region = slider.get_page_by_name("region") region.init(self.connection) #region.need_new_connection =False slider._slide_to_page("region", "none") if network_type == "gsm": self.button_to_region.connect("clicked", to_region) self.table.attach(style.wrap_with_align(self.button_to_region), 1,2,5,6) self.table.attach(self.label_advanced, 0, 2, 6, 7) self.table.attach(style.wrap_with_align(self.label_apn), 0, 1 , 7, 8) self.table.attach(style.wrap_with_align(self.label_network), 0, 1, 8, 9) self.table.attach(style.wrap_with_align(self.label_type), 0, 1, 9, 10) self.table.attach(style.wrap_with_align(self.label_pin), 0, 1, 11, 12) self.table.attach(style.wrap_with_align(self.apn), 1, 2, 7, 8) self.table.attach(style.wrap_with_align(self.network_id), 1, 2, 8, 9) self.table.attach(style.wrap_with_align(self.network_type), 1, 2, 9, 10) self.table.attach(style.wrap_with_align(self.roam_check, align="left"), 1, 2, 10, 11) self.table.attach(style.wrap_with_align(self.pin), 1, 2, 11, 12) #TODO ui change #style.set_table_items(self.table, 'entry') entry_list = ["number", "username", "password", "apn", "network_id", "pin"] for entry in entry_list: widget = getattr(self, entry) widget.entry.set_size_request(self.ENTRY_WIDTH, 22) style.set_table(self.table) self.table.show_all()
def init_table(self): table = gtk.Table(8, 3, False) #info_label = Label(_("You can choose the operation after plugining media or device")) cd_label = Label(_("CD")) dvd_label = Label(_("DVD")) player_label = Label(_("Audio Player")) photo_label = Label(_("Camera")) software_label = Label(_("Applications")) auto_mount_label = Label(_("Automatically Mount")) self.all_label_list = [cd_label, dvd_label, player_label, photo_label, software_label] default_list = [(_("Other applications"), "other_app"), (_("Ask"), "ask"), (_("Do nothing"), "do_nothing"), (_("Open folder"),"open_folder")] auto_mount_list = [(_("Do nothing"), "do_nothing"), (_("Ask"), "ask"), (_("Mount"), "mount"), (_("Mount and open folder"), "mount_and_open")] #self.auto_mount_box = gtk.HBox(spacing = WIDGET_SPACING) #self.auto_mount_label = Label(_("apply auto open for all media and devices")) self.auto_mount_label = Label(_("AutoPlay")) self.auto_mount_toggle = ToggleButton(app_theme.get_pixbuf("toggle_button/inactive_normal.png"), app_theme.get_pixbuf("toggle_button/active_normal.png")) #self.auto_mount_box.pack_start(self.auto_mount_label, False, False) #self.auto_mount_box.pack_start(self.auto_mount_toggle, False, False) self.cd = ComboBox(default_list, fixed_width=self.ENTRY_WIDTH) self.dvd = ComboBox(default_list, fixed_width=self.ENTRY_WIDTH) self.player= ComboBox(default_list, fixed_width=self.ENTRY_WIDTH) self.photo = ComboBox(default_list, fixed_width=self.ENTRY_WIDTH) self.software = ComboBox(default_list, fixed_width=self.ENTRY_WIDTH) self.auto_mount = ComboBox(auto_mount_list, fixed_width=self.ENTRY_WIDTH) self.auto_mount.set_select_index(self.__get_index_from_value(get_auto_mount(), auto_mount_list)) #self.more_option = Button(_("more option")) ###below content type displayed as more option is clicked" self.audio_dvd = ComboBox(default_list, fixed_width=self.ENTRY_WIDTH) self.blank_bd = ComboBox(default_list, fixed_width=self.ENTRY_WIDTH) self.blank_cd = ComboBox(default_list, fixed_width=self.ENTRY_WIDTH) self.blank_hddvd = ComboBox(default_list, fixed_width=self.ENTRY_WIDTH) self.video_bluray = ComboBox(default_list, fixed_width=self.ENTRY_WIDTH) self.ebook_reader = ComboBox(default_list, fixed_width=self.ENTRY_WIDTH) self.video_hddvd = ComboBox(default_list, fixed_width=self.ENTRY_WIDTH) self.image_picturecd = ComboBox(default_list, fixed_width=self.ENTRY_WIDTH) self.video_svcd = ComboBox(default_list, fixed_width=self.ENTRY_WIDTH) self.video_vcd = ComboBox(default_list, fixed_width=self.ENTRY_WIDTH) #table.attach(style.wrap_with_align(info_label, width=self.LEFT_WIDTH), 0, 3, 0, 1) table.attach(style.wrap_with_align(cd_label, width=self.LEFT_WIDTH), 0, 1, 4, 5) table.attach(style.wrap_with_align(dvd_label, width=self.LEFT_WIDTH), 0, 1, 5, 6) table.attach(style.wrap_with_align(player_label, width=self.LEFT_WIDTH), 0, 1, 6, 7) table.attach(style.wrap_with_align(photo_label, width=self.LEFT_WIDTH), 0, 1, 7, 8) table.attach(style.wrap_with_align(software_label, width=self.LEFT_WIDTH), 0, 1, 8, 9) table.attach(style.wrap_with_align(auto_mount_label, width=self.LEFT_WIDTH), 0, 1, 9, 10) #table.attach(style.wrap_with_align(self.auto_mount_box, align = "left", left = 180), 0, 3, 1, 2) table.attach(style.wrap_with_align(self.auto_mount_label, width=self.LEFT_WIDTH), 0, 1, 1, 2) table.attach(style.wrap_with_align(self.auto_mount_toggle), 1, 3, 1, 2) table.attach(style.wrap_with_align(self.cd), 1, 3, 4, 5) table.attach(style.wrap_with_align(self.dvd), 1, 3, 5, 6) table.attach(style.wrap_with_align(self.player), 1, 3, 6, 7) table.attach(style.wrap_with_align(self.photo), 1, 3, 7, 8) table.attach(style.wrap_with_align(self.software), 1, 3, 8, 9) table.attach(style.wrap_with_align(self.auto_mount), 1, 3, 9, 10) # UI style table_align = style.set_box_with_align(table, "text") style.set_table(table) self.pack_start(table_align, False, False) combo_list = [self.cd, self.dvd, self.player, self.photo, self.software] for combo in combo_list: combo.set_size_request(self.ENTRY_WIDTH, 22) self.refresh_app_list(default_list) self.media_handle.auto_mount = True if self.media_handle.automount_open: for combo in self.all_app_dict: combo.set_sensitive(True) for l in self.all_label_list: l.set_sensitive(True) else: for combo in self.all_app_dict: combo.set_sensitive(False) for l in self.all_label_list: l.set_sensitive(False) self.auto_mount_toggle.set_active(self.media_handle.automount_open) self.connect_signal_to_combos()
def __init__(self, connection, set_button_callback, settings_obj=None): gtk.VBox.__init__(self) self.tab_name = _("PPP") #self.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.connection = connection self.set_button = set_button_callback # 新增settings_obj变量,用于访问shared_methods.Settings对象 self.settings_obj = settings_obj self.ppp_setting = self.connection.get_setting("ppp") self.method_title = TitleBar(None, _("Configure Method"), width=self.TABLE_WIDTH, has_separator=False) self.refuse_eap_label = Label(_("EAP"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.refuse_pap_label = Label(_("PAP"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.refuse_chap_label = Label(_("CHAP"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.refuse_mschap_label = Label(_("MSCHAP"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.refuse_mschapv2_label = Label(_("MSCHAP v2"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.refuse_eap = SwitchButton() self.refuse_pap = SwitchButton() self.refuse_chap = SwitchButton() self.refuse_mschap = SwitchButton() self.refuse_mschapv2 = SwitchButton() self.method_table = gtk.Table(16, 3, False) # visible settings self.compression_title = TitleBar(None, _("Compression"), width=self.TABLE_WIDTH, has_separator=False) self.echo_title = TitleBar(None, _("Echo"), width=self.TABLE_WIDTH, has_separator=False) self.require_mppe_label = Label(_("Use point-to-point encryption(mppe)"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.require_mppe_128_label = Label(_("Require 128-bit encryption"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.mppe_stateful_label = Label(_("Use stateful MPPE"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.nobsdcomp_label = Label(_("Allow BSD data Compression"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.nodeflate_label = Label(_("Allow Deflate data compression"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.no_vj_comp_label = Label(_("Use TCP header compression"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.ppp_echo_label = Label(_("Send PPP echo packets"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.require_mppe = SwitchButton() self.require_mppe_128 = SwitchButton() self.mppe_stateful = SwitchButton() self.nobsdcomp = SwitchButton() self.nodeflate = SwitchButton() self.no_vj_comp = SwitchButton() self.ppp_echo = SwitchButton() compression_list = ["require_mppe_label", "require_mppe", "require_mppe_128_label", "require_mppe_128", "mppe_stateful_label", "mppe_stateful", "nobsdcomp_label", "nobsdcomp", "nodeflate_label", "nodeflate", "no_vj_comp_label", "no_vj_comp"] echo_list = ["ppp_echo_label","ppp_echo"] methods_list = ["refuse_eap", "refuse_eap_label", "refuse_pap", "refuse_pap_label", "refuse_chap", "refuse_chap_label", "refuse_mschap", "refuse_mschap_label", "refuse_mschapv2", "refuse_mschapv2_label"] for name in (compression_list+echo_list+methods_list): widget = getattr(self, name) if name.endswith("label"): align = style.wrap_with_align(widget, width=self.LEFT_PADDING) else: align = style.wrap_with_align(widget) setattr(self, name + "_align", align) vbox = gtk.VBox() table_align = gtk.Alignment(0, 0, 0, 0) table_align.add(self.method_table) self.pack_start(table_align, False, False) self.method_table.set_col_spacing(1, 10) self.method_table.set_row_spacing(6, 20) self.method_table.set_row_spacing(8, 20) #align = style.set_box_with_align(vbox, "text") #self.add_with_viewport(align) #style.draw_background_color(align) self.refresh() self.refuse_eap.connect("toggled", self.check_button_cb, "refuse_eap") self.refuse_pap.connect("toggled", self.check_button_cb, "refuse_pap") self.refuse_chap.connect("toggled", self.check_button_cb, "refuse_chap") self.refuse_mschap.connect("toggled", self.check_button_cb, "refuse_mschap") self.refuse_mschapv2.connect("toggled", self.check_button_cb, "refuse_mschapv2") self.require_mppe.connect("toggled", self.check_button_cb, "require_mppe") self.require_mppe_128.connect("toggled", self.check_button_cb, "require_mppe_128") self.mppe_stateful.connect("toggled", self.check_button_cb,"mppe_stateful") self.nobsdcomp.connect("toggled", self.check_button_cb, "nobsdcomp") self.nodeflate.connect("toggled", self.check_button_cb, "nodeflate") self.no_vj_comp.connect("toggled", self.check_button_cb, "no_vj_comp") self.ppp_echo.connect("toggled", self.check_button_cb, "echo")
def __init__(self, connection, set_button_cb, settings_obj=None): gtk.VBox.__init__(self) self.tab_name = _("Wireless") self.connection = connection self.set_button = set_button_cb # 新增settings_obj变量,用于访问shared_methods.Settings对象 self.settings_obj = settings_obj self.wireless = self.connection.get_setting("802-11-wireless") ### UI self.ssid_label = Label(_("SSID:"), enable_select=False, enable_double_click=False) self.ssid_entry = InputEntry() self.ssid_entry.set_size(self.ENTRY_WIDTH, 22) self.mode_label = Label(_("Mode:"), enable_select=False, enable_double_click=False) self.mode_combo = ComboBox([(_("Infrastructure"), "infrastructure"), (_("Ad-hoc"), "adhoc")], fixed_width=130) # TODO need to put this section to personal wifi self.band_label = Label(_("Band:"), enable_select=False, enable_double_click=False) self.band_combo = ComboBox([(_("Automatic"), None), ("a (5 GHZ)", "a"), ("b/g (2.4)", "bg")], fixed_width=self.ENTRY_WIDTH) self.channel_label = Label(_("Channel:"), enable_select=False, enable_double_click=False) self.channel_spin = SpinBox(0, 0, 1500, 1, self.ENTRY_WIDTH) # BSSID self.bssid_label = Label(_("BSSID:"), enable_select=False, enable_double_click=False) self.bssid_entry = MACEntry() self.mac_address_label = Label(_("Device Mac Address:"), enable_select=False, enable_double_click=False) self.mac_entry = MACEntry() self.clone_addr_label = Label(_("Cloned Mac Address:"), enable_select=False, enable_double_click=False) self.clone_entry = MACEntry() self.mtu_label = Label(_("MTU:"), enable_select=False, enable_double_click=False) self.mtu_spin = SpinBox(0, 0, 1500, 1, 130) self.table = gtk.Table(8, 2, False) """ wrap with alignment """ widget_list = [ "ssid_label", "ssid_entry", "mode_label", "mode_combo", "band_label", "band_combo", "channel_label", "channel_spin", "bssid_label", "bssid_entry", "mac_address_label", "mac_entry", "clone_addr_label", "clone_entry", "mtu_label", "mtu_spin" ] for widget in widget_list: item = getattr(self, widget) if widget.endswith("label"): item.set_can_focus(False) align = style.wrap_with_align(item, width=210) else: align = style.wrap_with_align(item, align="left") setattr(self, widget + "_align", align) #TODO UI change style.draw_background_color(self) #align = style.set_box_with_align(self.table, 'text') style.set_table(self.table) self.section = SettingSection(_("Default Settings"), always_show=False, revert=True, label_right=True, has_seperator=False) self.pack_start(self.section, False, False) self.section.toggle_off = self.use_default_setting self.section.toggle_on = self.use_user_setting self.section.load([self.table]) #self.pack_start(self.table, False, False) #self.table.set_size_request(340, 227) #self.ssid_entry.set_size_request(130, 22) self.bssid_entry.set_size_request(130, 22) self.mac_entry.set_size_request(130, 22) self.clone_entry.set_size_request(130, 22) self.reset() #self.mode_combo.connect("item-selected", self.mode_combo_selected) self.band_combo.connect("item-selected", self.band_combo_selected) self.mtu_spin.connect("value-changed", self.spin_value_changed, "mtu") self.mtu_spin.value_entry.connect("changed", self.spin_user_set) self.channel_spin.connect("value-changed", self.spin_value_changed, "channel") self.ssid_entry.entry.connect("changed", self.entry_changed, "ssid") self.bssid_entry.connect("changed", self.entry_changed, "bssid") self.mac_entry.connect("changed", self.entry_changed, "mac_address") self.clone_entry.connect("changed", self.entry_changed, "cloned_mac_address")
def __init__(self, connection, set_button, settings_obj=None): gtk.VBox.__init__(self) self.tab_name = _("Wired") self.set_button = set_button # 新增settings_obj变量,用于访问shared_methods.Settings对象 self.settings_obj = settings_obj self.connection = connection self.ethernet_setting = connection.get_setting("802-3-ethernet") table = gtk.Table(3, 2, False) mac_address = Label(_("Device Mac Address:"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) mac_address.set_can_focus(False) self.mac_entry = MACEntry() clone_addr = Label(_("Cloned Mac Address:"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) clone_addr.set_can_focus(False) self.clone_entry = MACEntry() mtu = Label("MTU:", text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) mtu.set_can_focus(False) self.mtu_spin = SpinBox(0,0, 1500, 1, 130) ''' Park table ''' table.attach(style.wrap_with_align(mac_address, width=self.LEFT_PADDING), 0, 1, 0, 1) table.attach(style.wrap_with_align(self.mac_entry), 1, 2, 0, 1) table.attach(style.wrap_with_align(clone_addr, width=self.LEFT_PADDING), 0, 1, 1, 2) table.attach(style.wrap_with_align(self.clone_entry), 1,2, 1, 2) table.attach(style.wrap_with_align(mtu, width=self.LEFT_PADDING), 0,1,2,3) table.attach(style.wrap_with_align(self.mtu_spin), 1,2,2,3) # TODO UI change style.draw_background_color(self) #align = style.set_box_with_align(table, "text") #self.add(align) style.set_table(table) table_align = gtk.Alignment(0, 0, 0, 0) default_button = DefaultToggle(_("Default Setting")) default_button.toggle_off = self.use_default_setting default_button.toggle_on = self.use_user_setting default_button.load([table]) table_align.add(default_button) self.pack_start(table_align, False, False) self.mac_entry.set_size_request(130, 22) self.clone_entry.set_size_request(130, 22) ## retrieve wired info self._init = True self.mac_entry.connect("changed", self.save_settings, "mac_address") self.clone_entry.connect("changed", self.save_settings, "cloned_mac_address") self.mtu_spin.connect("value_changed", self.save_settings, "mtu") self.mtu_spin.value_entry.connect("changed", self.spin_user_set) setting_list = (mac, clone_mac, mtu) = self.ethernet_setting.mac_address, self.ethernet_setting.cloned_mac_address, self.ethernet_setting.mtu #print mac, clone_mac, mtu if mac != None: self.mac_entry.set_address(mac) if clone_mac !=None: self.clone_entry.set_address(clone_mac) if mtu != None: self.mtu_spin.set_value(int(mtu)) if any(setting_list): default_button.set_active(False) self._init = False
def __init__(self, settings_obj=None): gtk.VBox.__init__(self) #self.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) #Dispatcher.set_button = set_button_callback #self.module_frame = module_frame # 新增settings_obj变量,用于访问shared_methods.Settings对象 self.settings_obj = settings_obj self.method_title = TitleBar(None, _("Configure Method"), width=self.TABLE_WIDTH, has_separator=False) self.refuse_eap_label = Label(_("EAP"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.refuse_pap_label = Label(_("PAP"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.refuse_chap_label = Label(_("CHAP"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.refuse_mschap_label = Label(_("MSCHAP"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.refuse_mschapv2_label = Label(_("MSCHAP v2"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.refuse_eap = SwitchButton() self.refuse_pap = SwitchButton() self.refuse_chap = SwitchButton() self.refuse_mschap = SwitchButton() self.refuse_mschapv2 = SwitchButton() self.method_table = gtk.Table(23, 3, False) # visible settings self.compression_title = TitleBar(None, _("Compression"), width=self.TABLE_WIDTH, has_separator=False) self.echo_title = TitleBar(None, _("Echo"), width=self.TABLE_WIDTH, has_separator=False) #compressio))n = Label(_("Compression"), text_size=TITLE_FONT_SIZE) self.require_mppe_label = Label(_("Use point-to-point encryption(mppe)"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.require_mppe_128_label = Label(_("Require 128-bit encryption"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.mppe_stateful_label = Label(_("Use stateful MPPE"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.nobsdcomp_label = Label(_("Allow BSD data Compression"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.nodeflate_label = Label(_("Allow Deflate data compression"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.no_vj_comp_label = Label(_("Use TCP header compression"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) #echo = Label("Echo", text_size=TITLE_FONT_SIZE) self.ppp_echo_label = Label(_("Send PPP echo packets"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.nopcomp_label = Label(_("Use protocal field compression negotiation"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.noaccomp_label = Label(_("Use Address/Control compression"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.require_mppe = SwitchButton() self.require_mppe_128 = SwitchButton() self.mppe_stateful = SwitchButton() self.nobsdcomp = SwitchButton() self.nodeflate = SwitchButton() self.no_vj_comp = SwitchButton() self.nopcomp = SwitchButton() self.noaccomp = SwitchButton() self.ppp_echo = SwitchButton() self.ip_sec_enable = SwitchButton() ## Settings for IPSec self.ipsec_title = TitleBar(None, _("IPSec Setting"), width=self.TABLE_WIDTH, has_separator=False) self.ip_sec_enable_label = Label(_("Enable IPSec tunnel to l2tp host"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.group_name_label = Label(_("Group Name:"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.gateway_id_label = Label(_("Gateway ID:"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.pre_shared_key_label = Label(_("Pre_Shared_key"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) self.group_name = InputEntry() self.group_name.set_size(self.TABLE_WIDTH, 22) self.gateway_id = InputEntry() self.gateway_id.set_size(self.TABLE_WIDTH, 22) self.pre_shared_key = PasswordEntry() self.pre_shared_key.set_text = self.pre_shared_key.entry.set_text self.pre_shared_key.set_size(self.TABLE_WIDTH, 22) methods_list = ["refuse_eap", "refuse_eap_label", "refuse_pap", "refuse_pap_label", "refuse_chap", "refuse_chap_label", "refuse_mschap", "refuse_mschap_label", "refuse_mschapv2", "refuse_mschapv2_label"] compression_list = ["require_mppe_label", "require_mppe", "require_mppe_128_label", "require_mppe_128", "mppe_stateful_label", "mppe_stateful", "nobsdcomp_label", "nobsdcomp", "nodeflate_label", "nodeflate", "no_vj_comp_label", "no_vj_comp", "nopcomp_label", "nopcomp", "noaccomp_label", "noaccomp"] echo_list = ["ppp_echo_label","ppp_echo"] ip_sec_list = ["ip_sec_enable_label", "ip_sec_enable", "group_name_label", "group_name", "gateway_id_label", "gateway_id", "pre_shared_key_label", "pre_shared_key"] for name in (compression_list+echo_list+methods_list + ip_sec_list): widget = getattr(self, name) if not name.endswith("label"): align = style.wrap_with_align(widget, align="left") else: align = style.wrap_with_align(widget, width=210) setattr(self, name + "_align", align) #vbox = gtk.VBox() table_align = gtk.Alignment(0, 0, 0, 0) table_align.add(self.method_table) style.set_table(self.method_table) self.pack_start(table_align, False, False) self.method_table.set_row_spacing(5, 20) self.method_table.set_row_spacing(15, 20) self.method_table.set_row_spacing(18, 20) Dispatcher.connect("vpn-type-change", lambda w,c:self.refresh(c))
def __init__(self, connection, set_button_callback=None, settings_obj=None): gtk.VBox.__init__(self) self.tab_name = _("DSL") self.connection = connection self.set_button = set_button_callback # 新增settings_obj变量,用于访问shared_methods.Settings对象 self.settings_obj = settings_obj self.dsl_setting = self.connection.get_setting("pppoe") # UI dsl_table = gtk.Table(5, 3, False) ssid_label = Label(_("Connection Name:"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) ssid_label.set_can_focus(False) username_label = Label(_("Username:"******"Service:"), text_size=CONTENT_FONT_SIZE, enable_select=False, enable_double_click=False) service_label.set_can_focus(False) password_label = Label(_("Password:"******"Show Password"), font_size=CONTENT_FONT_SIZE, padding_x=0) def show_password(widget): if widget.get_active(): self.password_entry.show_password(True) else: self.password_entry.show_password(False) self.show_password.connect("toggled", show_password) #pack entries dsl_table.attach(style.wrap_with_align(self.ssid_entry, align="left"), 1, 3, 0, 1) dsl_table.attach(style.wrap_with_align(self.username_entry, align="left"), 1, 3, 1, 2) dsl_table.attach(style.wrap_with_align(self.service_entry, align="left"), 1, 3, 2, 3) dsl_table.attach(style.wrap_with_align(self.password_entry, align="left"), 1, 3, 3, 4) dsl_table.attach(style.wrap_with_align(self.show_password, align="left"), 1, 3, 4, 5) style.draw_background_color(self) style.set_table(dsl_table) # just make table postion looks right table_align = gtk.Alignment(0, 0, 0, 0) table_align.add(dsl_table) self.pack_start(table_align, False, False) #self.add(align) self.show_all() self.refresh() self.ssid_entry.entry.connect("changed", self.save_changes, "ssid") self.username_entry.entry.connect("changed", self.save_changes, "username") self.service_entry.entry.connect("changed", self.save_changes, "service") self.password_entry.entry.connect("changed", self.save_changes, "password")
def __init__(self, connection, set_button_cb, need_ssid=False, settings_obj=None): gtk.VBox.__init__(self) self.tab_name = _("Security") self.connection = connection self.set_button = set_button_cb # 新增settings_obj变量,用于访问shared_methods.Settings对象 self.settings_obj = settings_obj self.settings_obj.initial_lock = True self.need_ssid = need_ssid self.presave_index = None if self.need_ssid: log.info("enter hidden network settings") self.add_ssid_entry() if self.connection.get_setting("802-11-wireless").security == "802-11-wireless-security": self.has_security = True self.setting = self.connection.get_setting("802-11-wireless-security") else: self.has_security = False self.security_label = Label(_("Security:"), enable_select=False, enable_double_click=False) self.key_label = Label(_("Key:"), enable_select=False, enable_double_click=False) self.wep_index_label = Label(_("Wep index:"), enable_select=False, enable_double_click=False) self.auth_label = Label(_("Authentication:"), enable_select=False, enable_double_click=False) self.password_label = Label(_("Password:"******"None"), None), (_("WEP (Hex or ASCII)"), "none"), (_("WEP 104/128-bit Passphrase"), "none"), (_("WPA WPA2 Personal"), "wpa-psk")] #entry_item = map(lambda l: (l[1],l[0]), enumerate(self.encry_list)) self.security_combo = ComboBox(self.encry_list, fixed_width=self.ENTRY_WIDTH) #self.security_combo.set_size_request(self.ENTRY_WIDTH, 22) self.key_entry = PasswordEntry() self.password_entry = PasswordEntry() self.show_key_check = CheckButton(_("Show password"), padding_x=0) self.show_key_check.connect("toggled", self.show_key_check_button_cb) self.wep_index_spin = SpinBox(0, 1, 4, 1, self.ENTRY_WIDTH) self.auth_combo = ComboBox([ (_("Shared Key"), "shared"), (_("Open System"), "open")],fixed_width=self.ENTRY_WIDTH) ## advance button self.align = gtk.Alignment(0, 1.0, 0, 0) self.align.set_padding(0, 0, 376, 0) self.align.set_size_request(-1 ,30) self.button = Button(_("Advanced")) self.align.add(self.button) ## Create table self.table = gtk.Table(5, 4) #TODO UI change label_list = ["security_label", "key_label", "wep_index_label", "auth_label", "password_label"] widget_list = ["password_entry", "key_entry", "wep_index_spin", "auth_combo", "security_combo"] for label in label_list: l = getattr(self, label) l.set_can_focus(False) align = style.wrap_with_align(l, width=210) setattr(self, label+"_align", align) for w in widget_list: l = getattr(self, w) align = style.wrap_with_align(l, align="left") setattr(self, w+"_align", align) self.show_key_check_align = style.wrap_with_align(self.show_key_check, align="left") self.reset(self.has_security) self.security_combo.connect("item-selected", self.change_encry_type) self.key_entry.entry.connect("changed", self.save_wep_pwd) self.password_entry.entry.connect("changed", self.save_wpa_pwd) self.wep_index_spin.connect("value-changed", self.wep_index_spin_cb) self.auth_combo.connect("item-selected", self.save_auth_cb) style.set_table(self.table) table_align = gtk.Alignment(0, 0, 0, 0) table_align.add(self.table) style.draw_background_color(self) width, height = self.ENTRY_WIDTH, 22 self.key_entry.set_size(width, height) self.password_entry.set_size(width, height) self.wep_index_spin.set_size_request(width, height) self.auth_combo.set_size_request(width, height) self.security_combo.set_size_request(width, height) self.pack_start(table_align, False, False) self.pack_start(self.align, False, False, 0) self.settings_obj.initial_lock = False
def attach_to(self, table, widget_list, row, width): for index, widget in enumerate(widget_list): align = style.wrap_with_align(widget, width=width[index]) table.attach(align, index, index + 1, row, row +1)
def app_table(self): # Labels #info_label = Label("您可以根据自己需要对深度系统在默认情况下使用的程序进行设置") web_label = Label(_("Web")) mail_label = Label(_("Mail")) editor_label = Label(_("Editor")) music_label = Label(_("Music")) movie_label = Label(_("Video")) pic_label = Label(_("Photo")) terminal_label = Label(_("Terminal")) self.web = ComboBox([("None",0)], fixed_width=self.ENTRY_WIDTH) self.mail = ComboBox([("None",0)], fixed_width=self.ENTRY_WIDTH) self.editor = ComboBox([("None",0)], fixed_width=self.ENTRY_WIDTH) self.music = ComboBox([("None",0)], fixed_width=self.ENTRY_WIDTH) self.movie = ComboBox([("None",0)], fixed_width=self.ENTRY_WIDTH) self.pic = ComboBox([("None",0)], fixed_width=self.ENTRY_WIDTH) self.terminal = self.get_terminal_combo() table = gtk.Table(8, 2, False) #table.attach(style.wrap_with_align(info_label), 0, 2, 0, 1) table.attach(style.wrap_with_align(web_label, width=self.LEFT_WIDTH), 0, 1, 1, 2) table.attach(style.wrap_with_align(mail_label, width=self.LEFT_WIDTH), 0, 1, 2, 3) table.attach(style.wrap_with_align(editor_label, width=self.LEFT_WIDTH), 0, 1, 3, 4) table.attach(style.wrap_with_align(music_label, width=self.LEFT_WIDTH), 0, 1, 4, 5) table.attach(style.wrap_with_align(movie_label, width=self.LEFT_WIDTH), 0, 1, 5, 6) table.attach(style.wrap_with_align(pic_label, width=self.LEFT_WIDTH), 0, 1, 6, 7) table.attach(style.wrap_with_align(terminal_label, width=self.LEFT_WIDTH), 0, 1, 7, 8) table.attach(style.wrap_with_align(self.web), 1, 2, 1, 2, 0) table.attach(style.wrap_with_align(self.mail),1, 2, 2, 3, 0) table.attach(style.wrap_with_align(self.editor), 1, 2, 3, 4) table.attach(style.wrap_with_align(self.music), 1, 2, 4, 5) table.attach(style.wrap_with_align(self.movie), 1, 2, 5, 6) table.attach(style.wrap_with_align(self.pic), 1, 2, 6, 7) table.attach(style.wrap_with_align(self.terminal), 1, 2, 7, 8) align = style.set_box_with_align(table, "text") style.set_table(table) self.pack_start(align, False, False) all_app_dict = self.get_all_app() #print all_app_dict apps = [self.web, self.mail, self.editor, self.music, self.movie, self.pic] for app in apps: app.set_size_request(self.ENTRY_WIDTH, 22) for key in all_app_dict.iterkeys(): if self.get_default_app: apps[key].add_items(all_app_dict[key]) else: apps[key].add_items(all_app_dict[key], clear_first = False)
def __init__(self, connection, module_frame, set_button_callback=None, settings_obj=None): gtk.VBox.__init__(self) self.connection = connection self.tab_name = _("PPTP") self.module_frame = module_frame self.set_button = set_button_callback # 新增settings_obj变量,用于访问shared_methods.Settings对象 self.settings_obj = settings_obj self.vpn_setting = self.connection.get_setting("vpn") # UI pptp_table = gtk.Table(7, 4, False) name_label = Label(_("Connection Name:"), enable_select=False, enable_double_click=False) name_label.set_can_focus(False) gateway_label = Label(_("Gateway:"), enable_select=False, enable_double_click=False) gateway_label.set_can_focus(False) user_label = Label(_("Username:"******"Password:"******"NT Domain:"), enable_select=False, enable_double_click=False) nt_domain_label.set_can_focus(False) # Radio Button self.pptp_radio = RadioButton(_("PPTP")) self.l2tp_radio = RadioButton(_("L2TP")) radio_box = gtk.HBox(spacing=30) radio_box.pack_start(self.pptp_radio, True, True) radio_box.pack_start(self.l2tp_radio, True, True) #pack labels pptp_table.attach(style.wrap_with_align(radio_box, align="left"), 2, 4, 0, 1) pptp_table.attach( style.wrap_with_align(name_label, width=self.LEFT_PADDING), 0, 2, 1, 2) pptp_table.attach( style.wrap_with_align(gateway_label, width=self.LEFT_PADDING), 0, 2, 2, 3) pptp_table.attach( style.wrap_with_align(user_label, width=self.LEFT_PADDING), 0, 2, 3, 4) pptp_table.attach( style.wrap_with_align(password_label, width=self.LEFT_PADDING), 0, 2, 4, 5) #pptp_table.attach(style.wrap_with_align(nt_domain_label), 0, 2, 5, 6) # entries self.name_entry = InputEntry() self.name_entry.set_size(self.ENTRY_WIDTH, 22) self.gateway_entry = InputEntry() self.gateway_entry.set_size(self.ENTRY_WIDTH, 22) self.user_entry = InputEntry() self.user_entry.set_size(self.ENTRY_WIDTH, 22) # FIXME should change to new_entry PasswordEntry self.password_entry = PasswordEntry() self.password_entry.set_size(self.ENTRY_WIDTH, 22) self.password_show = CheckButton(_("Show Password"), padding_x=0) self.password_show.set_active(False) self.password_show.connect("toggled", self.show_password) self.nt_domain_entry = InputEntry() self.nt_domain_entry.set_size(self.ENTRY_WIDTH, 22) #pack entries pptp_table.attach(style.wrap_with_align(self.name_entry, align="left"), 2, 4, 1, 2) pptp_table.attach( style.wrap_with_align(self.gateway_entry, align="left"), 2, 4, 2, 3) pptp_table.attach(style.wrap_with_align(self.user_entry, align="left"), 2, 4, 3, 4) pptp_table.attach( style.wrap_with_align(self.password_entry, align="left"), 2, 4, 4, 5) pptp_table.attach( style.wrap_with_align(self.password_show, align="left"), 2, 4, 5, 6) #pptp_table.attach(style.wrap_with_align(self.nt_domain_entry), 2, 4, 5, 6) # Advance setting button #advanced_button = Button(_("Advanced Setting")) #advanced_button.connect("clicked", self.advanced_button_click) #pptp_table.attach(style.wrap_with_align(advanced_button), 3, 4, 6, 7) self.service_type = self.vpn_setting.service_type.split(".")[-1] if self.service_type == "l2tp": self.l2tp_radio.set_active(True) else: self.pptp_radio.set_active(True) self.pptp_radio.connect("toggled", self.radio_toggled, "pptp") self.l2tp_radio.connect("toggled", self.radio_toggled, "l2tp") # set signals #align = style.set_box_with_align(pptp_table, "text") table_align = gtk.Alignment(0, 0, 0, 0) table_align.add(pptp_table) #style.set_table_items(pptp_table, "entry") style.draw_background_color(self) style.set_table(pptp_table) self.add(table_align) self.show_all() self.refresh() self.name_entry.entry.connect("changed", self.entry_changed, "name") self.gateway_entry.entry.connect("changed", self.entry_changed, "gateway") self.user_entry.entry.connect("changed", self.entry_changed, "user") self.password_entry.entry.connect("changed", self.entry_changed, "password") self.nt_domain_entry.entry.connect("changed", self.entry_changed, "domain")
def __init__(self, connection, set_button_cb, need_ssid=False, settings_obj=None): gtk.VBox.__init__(self) self.tab_name = _("Security") self.connection = connection self.set_button = set_button_cb # 新增settings_obj变量,用于访问shared_methods.Settings对象 self.settings_obj = settings_obj self.settings_obj.initial_lock = True self.need_ssid = need_ssid self.presave_index = None if self.need_ssid: log.info("enter hidden network settings") self.add_ssid_entry() if self.connection.get_setting( "802-11-wireless").security == "802-11-wireless-security": self.has_security = True self.setting = self.connection.get_setting( "802-11-wireless-security") else: self.has_security = False self.security_label = Label(_("Security:"), enable_select=False, enable_double_click=False) self.key_label = Label(_("Key:"), enable_select=False, enable_double_click=False) self.wep_index_label = Label(_("Wep index:"), enable_select=False, enable_double_click=False) self.auth_label = Label(_("Authentication:"), enable_select=False, enable_double_click=False) self.password_label = Label(_("Password:"******"None"), None), (_("WEP (Hex or ASCII)"), "none"), (_("WEP 104/128-bit Passphrase"), "none"), (_("WPA WPA2 Personal"), "wpa-psk")] #entry_item = map(lambda l: (l[1],l[0]), enumerate(self.encry_list)) self.security_combo = ComboBox(self.encry_list, fixed_width=self.ENTRY_WIDTH) #self.security_combo.set_size_request(self.ENTRY_WIDTH, 22) self.key_entry = PasswordEntry() self.password_entry = PasswordEntry() self.show_key_check = CheckButton(_("Show password"), padding_x=0) self.show_key_check.connect("toggled", self.show_key_check_button_cb) self.wep_index_spin = SpinBox(0, 1, 4, 1, self.ENTRY_WIDTH) self.auth_combo = ComboBox([(_("Shared Key"), "shared"), (_("Open System"), "open")], fixed_width=self.ENTRY_WIDTH) ## advance button self.align = gtk.Alignment(0, 1.0, 0, 0) self.align.set_padding(0, 0, 376, 0) self.align.set_size_request(-1, 30) self.button = Button(_("Advanced")) self.align.add(self.button) ## Create table self.table = gtk.Table(5, 4) #TODO UI change label_list = [ "security_label", "key_label", "wep_index_label", "auth_label", "password_label" ] widget_list = [ "password_entry", "key_entry", "wep_index_spin", "auth_combo", "security_combo" ] for label in label_list: l = getattr(self, label) l.set_can_focus(False) align = style.wrap_with_align(l, width=210) setattr(self, label + "_align", align) for w in widget_list: l = getattr(self, w) align = style.wrap_with_align(l, align="left") setattr(self, w + "_align", align) self.show_key_check_align = style.wrap_with_align(self.show_key_check, align="left") self.reset(self.has_security) self.security_combo.connect("item-selected", self.change_encry_type) self.key_entry.entry.connect("changed", self.save_wep_pwd) self.password_entry.entry.connect("changed", self.save_wpa_pwd) self.wep_index_spin.connect("value-changed", self.wep_index_spin_cb) self.auth_combo.connect("item-selected", self.save_auth_cb) style.set_table(self.table) table_align = gtk.Alignment(0, 0, 0, 0) table_align.add(self.table) style.draw_background_color(self) width, height = self.ENTRY_WIDTH, 22 self.key_entry.set_size(width, height) self.password_entry.set_size(width, height) self.wep_index_spin.set_size_request(width, height) self.auth_combo.set_size_request(width, height) self.security_combo.set_size_request(width, height) self.pack_start(table_align, False, False) self.pack_start(self.align, False, False, 0) self.settings_obj.initial_lock = False
def attach_to(self, table, widget_list, row, width): for index, widget in enumerate(widget_list): align = style.wrap_with_align(widget, width=width[index]) table.attach(align, index, index + 1, row, row + 1)
def __init__(self, connection, set_button_cb, settings_obj=None): gtk.VBox.__init__(self) self.tab_name = _("Wireless") self.connection = connection self.set_button = set_button_cb # 新增settings_obj变量,用于访问shared_methods.Settings对象 self.settings_obj = settings_obj self.wireless = self.connection.get_setting("802-11-wireless") ### UI self.ssid_label = Label(_("SSID:"), enable_select=False, enable_double_click=False) self.ssid_entry = InputEntry() self.ssid_entry.set_size(self.ENTRY_WIDTH, 22) self.mode_label = Label(_("Mode:"), enable_select=False, enable_double_click=False) self.mode_combo = ComboBox([(_("Infrastructure"),"infrastructure"),(_("Ad-hoc"), "adhoc")], fixed_width=130) # TODO need to put this section to personal wifi self.band_label = Label(_("Band:"), enable_select=False, enable_double_click=False) self.band_combo = ComboBox([(_("Automatic"), None), ("a (5 GHZ)", "a"), ("b/g (2.4)", "bg")], fixed_width=self.ENTRY_WIDTH) self.channel_label = Label(_("Channel:"), enable_select=False, enable_double_click=False) self.channel_spin = SpinBox(0, 0, 1500, 1, self.ENTRY_WIDTH) # BSSID self.bssid_label = Label(_("BSSID:"), enable_select=False, enable_double_click=False) self.bssid_entry = MACEntry() self.mac_address_label = Label(_("Device Mac Address:"), enable_select=False, enable_double_click=False) self.mac_entry = MACEntry() self.clone_addr_label = Label(_("Cloned Mac Address:"), enable_select=False, enable_double_click=False) self.clone_entry = MACEntry() self.mtu_label = Label(_("MTU:"), enable_select=False, enable_double_click=False) self.mtu_spin = SpinBox(0, 0, 1500, 1, 130) self.table = gtk.Table(8, 2, False) """ wrap with alignment """ widget_list = ["ssid_label", "ssid_entry", "mode_label", "mode_combo", "band_label", "band_combo", "channel_label", "channel_spin", "bssid_label", "bssid_entry", "mac_address_label", "mac_entry", "clone_addr_label", "clone_entry", "mtu_label", "mtu_spin"] for widget in widget_list: item = getattr(self, widget) if widget.endswith("label"): item.set_can_focus(False) align = style.wrap_with_align(item, width=210) else: align = style.wrap_with_align(item, align="left") setattr(self, widget + "_align", align) #TODO UI change style.draw_background_color(self) #align = style.set_box_with_align(self.table, 'text') style.set_table(self.table) self.section = SettingSection(_("Default Settings"), always_show= False, revert=True, label_right=True, has_seperator=False) self.pack_start(self.section, False, False) self.section.toggle_off = self.use_default_setting self.section.toggle_on = self.use_user_setting self.section.load([self.table]) #self.pack_start(self.table, False, False) #self.table.set_size_request(340, 227) #self.ssid_entry.set_size_request(130, 22) self.bssid_entry.set_size_request(130, 22) self.mac_entry.set_size_request(130, 22) self.clone_entry.set_size_request(130, 22) self.reset() #self.mode_combo.connect("item-selected", self.mode_combo_selected) self.band_combo.connect("item-selected", self.band_combo_selected) self.mtu_spin.connect("value-changed", self.spin_value_changed, "mtu") self.mtu_spin.value_entry.connect("changed", self.spin_user_set) self.channel_spin.connect("value-changed", self.spin_value_changed, "channel") self.ssid_entry.entry.connect("changed", self.entry_changed, "ssid") self.bssid_entry.connect("changed", self.entry_changed, "bssid") self.mac_entry.connect("changed", self.entry_changed, "mac_address") self.clone_entry.connect("changed", self.entry_changed, "cloned_mac_address")
def app_table(self): # Labels #info_label = Label("您可以根据自己需要对深度系统在默认情况下使用的程序进行设置") web_label = Label(_("Web")) mail_label = Label(_("Mail")) editor_label = Label(_("Editor")) music_label = Label(_("Music")) movie_label = Label(_("Video")) pic_label = Label(_("Photo")) terminal_label = Label(_("Terminal")) self.web = ComboBox([("None", 0)], fixed_width=self.ENTRY_WIDTH) self.mail = ComboBox([("None", 0)], fixed_width=self.ENTRY_WIDTH) self.editor = ComboBox([("None", 0)], fixed_width=self.ENTRY_WIDTH) self.music = ComboBox([("None", 0)], fixed_width=self.ENTRY_WIDTH) self.movie = ComboBox([("None", 0)], fixed_width=self.ENTRY_WIDTH) self.pic = ComboBox([("None", 0)], fixed_width=self.ENTRY_WIDTH) self.terminal = self.get_terminal_combo() table = gtk.Table(8, 2, False) #table.attach(style.wrap_with_align(info_label), 0, 2, 0, 1) table.attach(style.wrap_with_align(web_label, width=self.LEFT_WIDTH), 0, 1, 1, 2) table.attach(style.wrap_with_align(mail_label, width=self.LEFT_WIDTH), 0, 1, 2, 3) table.attach( style.wrap_with_align(editor_label, width=self.LEFT_WIDTH), 0, 1, 3, 4) table.attach(style.wrap_with_align(music_label, width=self.LEFT_WIDTH), 0, 1, 4, 5) table.attach(style.wrap_with_align(movie_label, width=self.LEFT_WIDTH), 0, 1, 5, 6) table.attach(style.wrap_with_align(pic_label, width=self.LEFT_WIDTH), 0, 1, 6, 7) table.attach( style.wrap_with_align(terminal_label, width=self.LEFT_WIDTH), 0, 1, 7, 8) table.attach(style.wrap_with_align(self.web), 1, 2, 1, 2, 0) table.attach(style.wrap_with_align(self.mail), 1, 2, 2, 3, 0) table.attach(style.wrap_with_align(self.editor), 1, 2, 3, 4) table.attach(style.wrap_with_align(self.music), 1, 2, 4, 5) table.attach(style.wrap_with_align(self.movie), 1, 2, 5, 6) table.attach(style.wrap_with_align(self.pic), 1, 2, 6, 7) table.attach(style.wrap_with_align(self.terminal), 1, 2, 7, 8) align = style.set_box_with_align(table, "text") style.set_table(table) self.pack_start(align, False, False) all_app_dict = self.get_all_app() #print all_app_dict apps = [ self.web, self.mail, self.editor, self.music, self.movie, self.pic ] for app in apps: app.set_size_request(self.ENTRY_WIDTH, 22) for key in all_app_dict.iterkeys(): if self.get_default_app: apps[key].add_items(all_app_dict[key]) else: apps[key].add_items(all_app_dict[key], clear_first=False)
def __init__(self, connection, module_frame, set_button_callback=None, settings_obj=None): gtk.VBox.__init__(self) self.connection = connection self.tab_name = _("PPTP") self.module_frame = module_frame self.set_button = set_button_callback # 新增settings_obj变量,用于访问shared_methods.Settings对象 self.settings_obj = settings_obj self.vpn_setting = self.connection.get_setting("vpn") # UI pptp_table = gtk.Table(7, 4, False) name_label = Label(_("Connection Name:"), enable_select=False, enable_double_click=False) name_label.set_can_focus(False) gateway_label = Label(_("Gateway:"), enable_select=False, enable_double_click=False) gateway_label.set_can_focus(False) user_label = Label(_("Username:"******"Password:"******"NT Domain:"), enable_select=False, enable_double_click=False) nt_domain_label.set_can_focus(False) # Radio Button self.pptp_radio = RadioButton(_("PPTP")) self.l2tp_radio = RadioButton(_("L2TP")) radio_box = gtk.HBox(spacing=30) radio_box.pack_start(self.pptp_radio, True, True) radio_box.pack_start(self.l2tp_radio, True, True) #pack labels pptp_table.attach(style.wrap_with_align(radio_box, align="left"), 2,4, 0, 1) pptp_table.attach(style.wrap_with_align(name_label, width=self.LEFT_PADDING), 0, 2, 1, 2) pptp_table.attach(style.wrap_with_align(gateway_label, width=self.LEFT_PADDING), 0, 2 , 2, 3) pptp_table.attach(style.wrap_with_align(user_label, width=self.LEFT_PADDING), 0, 2, 3, 4) pptp_table.attach(style.wrap_with_align(password_label, width=self.LEFT_PADDING), 0, 2, 4, 5) #pptp_table.attach(style.wrap_with_align(nt_domain_label), 0, 2, 5, 6) # entries self.name_entry = InputEntry() self.name_entry.set_size(self.ENTRY_WIDTH, 22) self.gateway_entry = InputEntry() self.gateway_entry.set_size(self.ENTRY_WIDTH,22) self.user_entry = InputEntry() self.user_entry.set_size(self.ENTRY_WIDTH, 22) # FIXME should change to new_entry PasswordEntry self.password_entry = PasswordEntry() self.password_entry.set_size(self.ENTRY_WIDTH, 22) self.password_show = CheckButton(_("Show Password"), padding_x=0) self.password_show.set_active(False) self.password_show.connect("toggled", self.show_password) self.nt_domain_entry = InputEntry() self.nt_domain_entry.set_size(self.ENTRY_WIDTH, 22) #pack entries pptp_table.attach(style.wrap_with_align(self.name_entry, align="left"), 2, 4, 1, 2) pptp_table.attach(style.wrap_with_align(self.gateway_entry, align="left"), 2, 4, 2, 3) pptp_table.attach(style.wrap_with_align(self.user_entry, align="left"), 2, 4, 3, 4) pptp_table.attach(style.wrap_with_align(self.password_entry, align="left"), 2, 4, 4, 5) pptp_table.attach(style.wrap_with_align(self.password_show, align="left"), 2, 4, 5, 6) #pptp_table.attach(style.wrap_with_align(self.nt_domain_entry), 2, 4, 5, 6) # Advance setting button #advanced_button = Button(_("Advanced Setting")) #advanced_button.connect("clicked", self.advanced_button_click) #pptp_table.attach(style.wrap_with_align(advanced_button), 3, 4, 6, 7) self.service_type = self.vpn_setting.service_type.split(".")[-1] if self.service_type == "l2tp": self.l2tp_radio.set_active(True) else: self.pptp_radio.set_active(True) self.pptp_radio.connect("toggled",self.radio_toggled, "pptp") self.l2tp_radio.connect("toggled",self.radio_toggled, "l2tp") # set signals #align = style.set_box_with_align(pptp_table, "text") table_align = gtk.Alignment(0, 0, 0, 0) table_align.add(pptp_table) #style.set_table_items(pptp_table, "entry") style.draw_background_color(self) style.set_table(pptp_table) self.add(table_align) self.show_all() self.refresh() self.name_entry.entry.connect("changed", self.entry_changed, "name") self.gateway_entry.entry.connect("changed", self.entry_changed, "gateway") self.user_entry.entry.connect("changed", self.entry_changed, "user") self.password_entry.entry.connect("changed", self.entry_changed, "password") self.nt_domain_entry.entry.connect("changed", self.entry_changed, "domain")