def __setup_combo(self, items=[], width=HSCALEBAR_WIDTH): if len(items) == 0: return None combo = ComboBox(items = items, select_index = 0, max_width = width, fixed_width = width) combo.set_size_request(width, WIDGET_HEIGHT) return combo
def __setup_combo(self, items=[], width=HSCALEBAR_WIDTH): if len(items) == 0: return None combo = ComboBox(items=items, select_index=0, max_width=width, fixed_width=width) combo.set_size_request(width, WIDGET_HEIGHT) return combo
class DetailWindow(Window): ''' class docs ''' def __init__(self): ''' init docs ''' Window.__init__(self, enable_resize=True) self.set_size_request(WINDOW_WIDTH, WINDOW_HEIGHT) self.set_position(gtk.WIN_POS_CENTER) self.set_skip_taskbar_hint(True) self.set_skip_pager_hint(True) self.resizable = True self.classified_items = None self.__init_pixbuf() self.main_box = gtk.VBox() self.titlebar_box = gtk.HBox() self.toolbar_box = gtk.HBox() self.toolbar_box.set_size_request(-1, TOOLBAR_HEIGHT) self.main_view_box = gtk.HBox() self.main_view_box.set_size_request(WINDOW_WIDTH, WINDOW_HEIGHT - TITLEBAR_HEIGHT - TOOLBAR_HEIGHT - 23) self.add_titlebar() self.treeview_box = gtk.VBox() self.main_view_box.pack_start(self.treeview_box, False, False) self.listview_box = gtk.VBox() self.main_view_box.pack_start(self.listview_box, True, True) self.refresh_view() #add treeview and listview self.main_box.pack_start(self.toolbar_box, False, False) # self.main_box.pack_start(self.main_view_box, False, False) self.main_box.pack_start(self.main_view_box, True, True) # self.main_box.connect("expose-event", self.on_main_box_expose_event) main_box_align = gtk.Alignment(0.5, 0.5, 1, 1) main_box_align.set_padding(2, 2, 2, 2) main_box_align.add(self.main_box) self.window_frame.pack_start(self.titlebar_box, False, False) self.window_frame.pack_start(main_box_align) @property def is_empty(self): return not bool(len(self.classified_items)) def __init_pixbuf(self): self.import_btn_pixbuf = gtk.gdk.pixbuf_new_from_file(app_theme.get_theme_file_path("image/toolbar_import.png")) self.export_btn_pixbuf = gtk.gdk.pixbuf_new_from_file(app_theme.get_theme_file_path("image/toolbar_export.png")) self.delete_btn_pixbuf = gtk.gdk.pixbuf_new_from_file(app_theme.get_theme_file_path("image/toolbar_delete.png")) self.refresh_btn_pixbuf = gtk.gdk.pixbuf_new_from_file(app_theme.get_theme_file_path("image/toolbar_refresh.png")) self.skin_preview_pixbuf = app_theme.get_pixbuf("frame.png") def _init_data(self): self.__init_data() def __init_data(self): self.classified_items = {} rows = db.get_all() for row in rows: app_name = row[MESSAGE].app_name self.classified_items.setdefault(app_name, []).append(row) def add_to_view(self): row = db.get_last() # add to data app_name = row[MESSAGE].app_name if app_name in self.classified_items.keys(): self.classified_items[app_name].insert(0, row) else: self.classified_items.setdefault(app_name, []).insert(0, row) self.treeview_add_item(app_name) # add to view if app_name == self.treeview.get_highlight_item().get_title(): self.factory.prepend_item(row) def refresh_view(self): self.__init_data() if len(self.classified_items): self.add_treeview() self.current_showed_items = self.get_items_from_treeview_highlight() self.add_listview(self.current_showed_items) else: align = gtk.Alignment(0.5, 0.5, 0, 0) align.add(Label(_("(Empty)"))) container_remove_all(self.treeview_box) container_remove_all(self.listview_box) self.listview_box.pack_start(align, True, True) self.main_view_box.show_all() container_remove_all(self.toolbar_box) self.add_toolbar() self.toolbar_box.show_all() def on_main_box_expose_event(self, widget, event): cr = widget.window.cairo_create() rect = widget.allocation cr.rectangle(*rect) cr.set_source_rgb(*STROKE_LINE_COLOR) cr.stroke_preserve() cr.set_source_rgb(1, 1, 1) cr.fill() def on_treeview_draw_mask(self, cr, x, y, w, h): cr.set_source_rgb(1, 1, 1) cr.rectangle(x, y, w, h) cr.fill() cr.move_to(x, y) cr.line_to(x + w, y) cr.set_source_rgb(*STROKE_LINE_COLOR) cr.stroke() draw_line(cr, (x+w-1, y), (x+w-1, y+h), "#b2b2b2") def on_treeview_click_item(self, widget, item, column, x, y): if not item.is_parent: widget.set_highlight_item(item) self.current_showed_items = self.get_items_from_treeview_highlight() self.add_listview(self.current_showed_items) for comb_item in self.category_comb.items: if comb_item.title == item.title: self.category_comb.set_select_index(comb_item_value_to_index(comb_item.item_value)) def on_treeview_double_click_item(self, widget, item, column, x, y): if item.is_parent: if item.is_expand: item.unexpand() else: item.expand() def on_treeview_right_press_items(self, widget, root_x, root_y, current_item, select_items): ''' docs ''' self.treeview.set_highlight_item(current_item) if not current_item.is_parent: def on_add_to_bl(): blacklist.add(current_item.title) current_item.is_in_blacklist = True current_item.emit_redraw_request() def on_remove_from_bl(): blacklist.remove(current_item.title) current_item.is_in_blacklist = False current_item.emit_redraw_request() menu_items = [] if current_item.title in blacklist.bl: menu_items.append((None, _("Remove from Blacklist"), on_remove_from_bl)) else: menu_items.append((None, _("Add to Blacklist"), on_add_to_bl)) Menu(menu_items, True).show((int(root_x), int(root_y))) def add_treeview(self): categories = self.classified_items.keys() # root eles self.root_ele_software = TreeViewItem(_("Software Messages"), True) self.root_ele_system = TreeViewItem(_("System Messages"), True) self.treeview = TreeView([self.root_ele_software, self.root_ele_system], expand_column=0) # add child items , CAN'T add_child_items before treeview constructed software_children = [] system_children = [] for category in categories: treeview_item = TreeViewItem(category) if category in blacklist.bl: treeview_item.is_in_blacklist = True if category in SYSTEM_SOFTWARE_LIST: system_children.append(treeview_item) else: software_children.append(treeview_item) self.root_ele_software.add_child_items(software_children) self.root_ele_system.add_child_items(system_children) self.treeview.draw_mask = self.on_treeview_draw_mask if len(software_children): self.treeview.set_highlight_item(software_children[0]) elif len(system_children): self.treeview.set_highlight_item(system_children[0]) self.treeview.set_size_request(220, -1) self.treeview.connect("single-click-item", self.on_treeview_click_item) self.treeview.connect("right-press-items", self.on_treeview_right_press_items) self.treeview.connect("double-click-item", self.on_treeview_double_click_item) container_remove_all(self.treeview_box) self.treeview_box.pack_start(self.treeview, True, True) self.treeview_box.show_all() def treeview_add_item(self, item): if item in SYSTEM_SOFTWARE_LIST: self.root_ele_system.add_child_items([TreeViewItem(item)]) else: self.root_ele_software.add_child_items([TreeViewItem(item)]) self.treeview_box.show_all() def add_listview(self, items): container_remove_all(self.listview_box) if len(items) != 0: self.factory = ListviewFactory(items, "detail") self.listview = self.factory.listview self.listview_box.pack_start(self.listview) else: empty_box_align = gtk.Alignment(0.5, 0.5, 0, 0) empty_box_align.add(Label("(Empty)")) self.listview_box.pack_start(empty_box_align) self.listview_box.show_all() def get_items_from_treeview_highlight(self): ''' docs ''' app_name = self.treeview.get_highlight_item().get_title() return self.classified_items[app_name] def add_titlebar(self, button_mask=["min", "max", "close"], icon_path=app_theme.get_theme_file_path("image/icon_little.png"), app_name=_("Message Manager"), title=None, add_separator=False, show_title=True, enable_gaussian=True, ): # Init titlebar. self.titlebar = Titlebar(button_mask, icon_path, app_name, title, add_separator, show_title=show_title, enable_gaussian=enable_gaussian, ) self.titlebar.max_button.connect("clicked", lambda w: self.toggle_max_window()) self.titlebar.min_button.connect("clicked", self.close_callback) self.titlebar.close_button.connect("clicked", self.close_callback) if self.resizable: self.add_toggle_event(self.titlebar) self.add_move_event(self.titlebar) self.titlebar_box.add(self.titlebar) def add_toolbar(self): toolbar_btn_box = gtk.HBox() toolbar_btn_box_align = gtk.Alignment(0.5, 0.5, 0, 0) import_btn = ToolbarItem(self.import_btn_pixbuf, _("Import")) import_btn.connect("clicked", self.on_toolbar_import_clicked) export_btn = ToolbarItem(self.export_btn_pixbuf, _("Export")) export_btn.connect("clicked", self.on_toolbar_export_clicked) delete_btn = ToolbarItem(self.delete_btn_pixbuf, _("Delete")) delete_btn.connect("clicked", self.on_toolbar_delete_clicked) refresh_btn = ToolbarItem(self.refresh_btn_pixbuf, _("Refresh")) refresh_btn.connect("clicked", self.on_toolbar_refresh_clicked) toolbar_btn_box.pack_start(import_btn, False, False, 2) toolbar_btn_box.pack_start(export_btn, False, False, 2) toolbar_btn_box.pack_start(delete_btn, False, False, 2) toolbar_btn_box.pack_start(refresh_btn, False, False, 2) toolbar_btn_box_align.add(toolbar_btn_box) look_in_Label = Label( _("Look up in"), text_color=ui_theme.get_color("title_text"), ) self.category_comb = ComboBox([(_("All"), 0)]) self.category_comb.add_items([(item, index) for index, item in enumerate(self.classified_items)], clear_first=False) self.time_comb = ComboBox([(_("Today"), 0), (_("Last week"), 1), (_("Last month"), 2), (_("Last three months"), 3), (_("Last year"), 4), (_("All"), 5) ]) self.category_comb.set_size_request(-1, TOOLBAR_ENTRY_HEIGHT) self.category_comb.connect("item-selected", self.on_category_comb_item_selected) self.time_comb.set_size_request(-1, TOOLBAR_ENTRY_HEIGHT) self.time_comb.connect("item-selected", self.on_time_comb_item_selected) combos_box = gtk.HBox() combos_box.pack_start(self.category_comb, False, False, 5) combos_box.pack_start(self.time_comb, False, False) combos_box_align = gtk.Alignment(0.5, 0.5, 1, 1) padding_height = (TOOLBAR_HEIGHT - TOOLBAR_ENTRY_HEIGHT) / 2 combos_box_align.set_padding(padding_height, padding_height, 5, 5) combos_box_align.add(combos_box) find_content_Label = Label( _("Find in content"), text_color=ui_theme.get_color("title_text"), ) search_entry = SearchEntry() search_entry.connect("action-active", self.on_search_entry_action_active) search_entry_align = gtk.Alignment(0.5, 0.5, 1, 1) search_entry_align.set_padding(padding_height, padding_height, 5, 5) search_entry_align.add(search_entry) #Align left self.toolbar_box.pack_start(toolbar_btn_box_align, False, False, 5) #Align right self.toolbar_box.pack_end(search_entry_align, False, True, 5) self.toolbar_box.pack_end(find_content_Label, False, False, 5) self.toolbar_box.pack_end(combos_box_align, False, False, 0) self.toolbar_box.pack_end(look_in_Label, False, False, 5) self.toolbar_box.pack_end(ToolbarSep(), False, False, 5) def on_category_comb_item_selected(self, widget, item_title, item_value, item_index): if item_title != "All": for item in self.treeview.get_items(): if item.title == item_title: self.treeview.set_highlight_item(item) self.current_showed_items = self.get_items_from_treeview_highlight() self.add_listview(self.current_showed_items) break def on_time_comb_item_selected(self, widget, item_title, item_value, item_index): if item_value != 5: filtrated_result = [] for item in self.current_showed_items: item_datetime = datetime.strptime(item[TIME], "%Y/%m/%d-%H:%M:%S") if datetime.today() - item_datetime < timedelta_dict[item_value]: filtrated_result.append(item) self.current_showed_items = filtrated_result self.add_listview(filtrated_result) def get_search_result_iter(self, search_str): filter_keywords = search_str.split() for item in self.current_showed_items: item_message = item[MESSAGE] for keyword in filter_keywords: # print "from %s search %s result %s:" % (item_message.body, keyword, item_message.body.find(keyword) != -1) if item_message.body.find(keyword) != -1: yield item continue def on_search_entry_action_active(self, widget, text): search_result_iter = self.get_search_result_iter(text) self.add_listview(list(search_result_iter)) def on_toolbar_import_clicked(self, widget): self.filename_to_import = "" def ok_clicked(filename): self.filename_to_import = filename OpenFileDialog(_("Select File to Import"), self, ok_clicked, None) if len(self.filename_to_import) != 0: try: def import_db_func(): db.import_db(self.filename_to_import) self.refresh_view() threading.Thread(target=import_db_func).start() except Exception, e: pass
def __setup_combo(self, items=[]): combo = ComboBox(items, None, 0, max_width = 285, fixed_width = 285) combo.set_size_request(-1, WIDGET_HEIGHT) return combo
class Security(gtk.VBox): ENTRY_WIDTH = 222 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 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) #self.add(align) def set_ssid(self, widget, content): self.wireless.ssid = content check_settings(self.connection, None) def advand_cb(self, widget): pass def reset(self, security=True): ## Add security container_remove_all(self.table) if self.need_ssid: self.table.attach(self.ssid_label_align, 0, 1, 0, 1) self.table.attach(self.ssid_entry_align, 1, 4, 0, 1) self.table.resize(2, 4) self.table.attach(self.security_label_align, 0, 1, 1, 2) self.table.attach(self.security_combo_align, 1, 4, 1, 2) if not security: self.presave_index = self.security_combo.get_select_index() return keys = [None, "none", "none", "wpa-psk"] self.key_mgmt = self.setting.key_mgmt if self.key_mgmt == "none": key_type = self.setting.wep_key_type self.security_combo.set_select_index(key_type) else: self.security_combo.set_select_index(keys.index(self.key_mgmt)) if not self.security_combo.get_current_item()[1] == None: try: (setting_name, method) = self.connection.guess_secret_info() secret = nm_module.secret_agent.agent_get_secrets( self.connection.object_path, setting_name, method) if secret == None: secret = '' log.debug("get secret", setting_name, method, "secret") except Exception, e: log.error("get secret error", e) secret = "" if self.security_combo.get_current_item()[1] == "wpa-psk": self.table.resize(4, 4) self.table.attach(self.password_label_align, 0, 1, 2, 3) self.table.attach(self.password_entry_align, 1, 4, 2, 3) self.table.attach(self.show_key_check_align, 1, 4, 3, 4) self.password_entry.entry.set_text(secret) if secret: #Dispatcher.set_button("save", True) ########### self.settings_obj.wlan_encry_is_valid = True self.settings_obj.set_button("save", True) self.setting.psk = secret elif self.security_combo.get_current_item()[1] == "none": self.table.resize(6, 4) # Add Key self.table.attach(self.key_label_align, 0, 1, 2, 3) self.table.attach(self.key_entry_align, 1, 4, 2, 3) self.table.attach(self.show_key_check_align, 1, 4, 3, 4) # Add wep index self.table.attach(self.wep_index_label_align, 0, 1, 4, 5) self.table.attach(self.wep_index_spin_align, 1, 4, 4, 5) # Add Auth self.table.attach(self.auth_label_align, 0, 1, 5, 6) self.table.attach(self.auth_combo_align, 1, 4, 5, 6) # Retrieve wep properties try: index = self.setting.wep_tx_keyidx auth = self.setting.auth_alg log.debug(auth, index) self.auth_combo.set_select_index(["shared", "open"].index(auth)) except Exception, e: log.error(e) index = 0 auth = "shared" # must convert long int to int index = int(index) #init_key = True #if isinstance(self.connection, NMRemoteConnection): #init_setting = self.connection.get_setting("802-11-wireless-security") #if init_setting.wep_key_type != self.setting.wep_key_type: #init_key = False #if init_key: self.key_entry.entry.set_text(secret) self.setting.set_wep_key(index, secret) self.wep_index_spin.set_value(index + 1) self.auth_combo.set_select_index(["shared", "open"].index(auth))
def __setup_combo(self, items=[], width=HSCALEBAR_WIDTH): combo = ComboBox(items, None, 0, width, width) combo.set_size_request(width, WIDGET_HEIGHT) return combo
class Security(gtk.VBox): ENTRY_WIDTH = 222 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 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) #self.add(align) def set_ssid(self, widget, content): self.wireless.ssid = content check_settings(self.connection, None) def advand_cb(self, widget): pass def reset(self, security=True): ## Add security container_remove_all(self.table) if self.need_ssid: self.table.attach(self.ssid_label_align, 0, 1, 0, 1) self.table.attach(self.ssid_entry_align, 1, 4, 0, 1) self.table.resize(2, 4) self.table.attach(self.security_label_align, 0, 1, 1, 2) self.table.attach(self.security_combo_align, 1, 4, 1, 2) if not security: self.presave_index = self.security_combo.get_select_index() return keys = [None, "none", "none","wpa-psk"] self.key_mgmt = self.setting.key_mgmt if self.key_mgmt == "none": key_type = self.setting.wep_key_type self.security_combo.set_select_index(key_type) else: self.security_combo.set_select_index(keys.index(self.key_mgmt)) if not self.security_combo.get_current_item()[1] == None: try: (setting_name, method) = self.connection.guess_secret_info() secret = nm_module.secret_agent.agent_get_secrets(self.connection.object_path, setting_name, method) if secret == None: secret = '' log.debug("get secret", setting_name, method, "secret") except Exception, e: log.error("get secret error", e) secret = "" if self.security_combo.get_current_item()[1] == "wpa-psk": self.table.resize(4, 4) self.table.attach(self.password_label_align, 0, 1, 2, 3) self.table.attach(self.password_entry_align, 1, 4, 2, 3) self.table.attach(self.show_key_check_align, 1, 4, 3, 4) self.password_entry.entry.set_text(secret) if secret: #Dispatcher.set_button("save", True) ########### self.settings_obj.wlan_encry_is_valid = True self.settings_obj.set_button("save", True) self.setting.psk = secret elif self.security_combo.get_current_item()[1] == "none": self.table.resize(6, 4) # Add Key self.table.attach(self.key_label_align, 0, 1, 2, 3) self.table.attach(self.key_entry_align, 1, 4, 2, 3) self.table.attach(self.show_key_check_align, 1, 4, 3, 4) # Add wep index self.table.attach(self.wep_index_label_align, 0, 1, 4, 5) self.table.attach(self.wep_index_spin_align, 1, 4, 4, 5) # Add Auth self.table.attach(self.auth_label_align, 0, 1, 5, 6) self.table.attach(self.auth_combo_align, 1, 4, 5, 6) # Retrieve wep properties try: index = self.setting.wep_tx_keyidx auth = self.setting.auth_alg log.debug(auth, index) self.auth_combo.set_select_index(["shared", "open"].index(auth)) except Exception, e: log.error(e) index = 0 auth = "shared" # must convert long int to int index = int(index) #init_key = True #if isinstance(self.connection, NMRemoteConnection): #init_setting = self.connection.get_setting("802-11-wireless-security") #if init_setting.wep_key_type != self.setting.wep_key_type: #init_key = False #if init_key: self.key_entry.entry.set_text(secret) self.setting.set_wep_key(index, secret) self.wep_index_spin.set_value(index + 1) self.auth_combo.set_select_index(["shared", "open"].index(auth))