def load_list(self, network_object):
        '''
        will add hasattr part for network_object
        '''

        log.info("sidebar start load list")
        self.network_object = network_object
        self.connections = self.network_object.get_connections()
        #print self.connections, "load_list"
        connections = []
        for connection in self.connections:
            if isinstance(connection, NMRemoteConnection):
                connection.init_settings_prop_dict()
            connections.append(connection)
        self.connections = connections
        self.connection_tree = EntryTreeView()
        self.connection_tree.set_expand_column(1)
        self.__init_tree(self.connections)

        if hasattr(self.network_object, "add_new_connection"):
            self.new_connection = self.network_object.add_new_connection
            #self.add_button.change_add_setting(self.network_object.add_new_connection)
        if hasattr(self.network_object, "delete_request_redraw"):
            self.request_redraw = self.network_object.delete_request_redraw
        self.init_select(network_object.spec_connection)
        # FIXME: COME ON, why check the connections count?!
        #if self.connections !=[]:
        crumb_name = network_object.crumb_name
        if crumb_name == "":
            crumb_name = _("Hidden network")
        Dispatcher.send_submodule_crumb(2, crumb_name)
        Dispatcher.slide_to_page("setting", "none")
    def load_list(self, network_object):
        '''
        will add hasattr part for network_object
        '''
        
        log.info("sidebar start load list")
        self.network_object = network_object
        self.connections = self.network_object.get_connections()
        #print self.connections, "load_list"
        connections = []
        for connection in self.connections:
            if isinstance(connection, NMRemoteConnection):
                connection.init_settings_prop_dict()
            connections.append(connection)
        self.connections = connections
        self.connection_tree = EntryTreeView()
        self.connection_tree.set_expand_column(1)
        self.__init_tree(self.connections)

        if hasattr(self.network_object, "add_new_connection"):
            self.new_connection = self.network_object.add_new_connection
            #self.add_button.change_add_setting(self.network_object.add_new_connection)
        if hasattr(self.network_object, "delete_request_redraw"):
            self.request_redraw = self.network_object.delete_request_redraw
        self.init_select(network_object.spec_connection)
        # FIXME: COME ON, why check the connections count?!
        #if self.connections !=[]:
        crumb_name = network_object.crumb_name
        if crumb_name == "":
            crumb_name = _("Hidden network")
        Dispatcher.send_submodule_crumb(2, crumb_name)
        Dispatcher.slide_to_page("setting", "none")
    def wireless_device_deactive(self, widget, new_state, old_state, reason):
        log.info(widget, new_state, old_state, reason)
        if widget not in net_manager.device_manager.wireless_devices:
            return
        #self.wireless.set_sensitive(True)
        if reason == 36:
            log.info("some device removed")
            net_manager.init_devices()
            self.remove_switcher()
            return
        if old_state == 120:
            if self.selected_item:
                log.debug("try disconnect")
                wifi = nm_module.cache.get_spec_object(widget.object_path)
                wifi.device_wifi_disconnect()

        if old_state == 50:
            if self._get_active_item():
                for item in self._get_active_item():
                    item.set_net_state(0)
            return
        if reason == 39:
            if any([
                    d.get_state() == 100
                    for d in net_manager.device_manager.wireless_devices
            ]):
                return
            else:

                self.wireless.set_active(False)
                return

        if self._get_active_item():
            for item in self._get_active_item():
                item.set_net_state(0)
Ejemplo n.º 4
0
    def wireless_device_deactive(self, widget, new_state, old_state, reason):
        log.info(widget, new_state, old_state, reason)
        if widget not in net_manager.device_manager.wireless_devices:
            return
        #self.wireless.set_sensitive(True)
        if reason == 36:
            log.info("some device removed")
            net_manager.init_devices()
            self.remove_switcher() 
            return 
        if old_state == 120:
            if self.selected_item: 
                log.debug("try disconnect")
                wifi = nm_module.cache.get_spec_object(widget.object_path)
                wifi.device_wifi_disconnect()

        if old_state == 50:
            if self._get_active_item():
                for item in self._get_active_item():
                    item.set_net_state(0)
            return
        if reason == 39:
            if any([d.get_state() == 100 for d in net_manager.device_manager.wireless_devices]):
                return
            else:

                self.wireless.set_active(False)
                return

        if self._get_active_item():
            for item in self._get_active_item():
                item.set_net_state(0)
Ejemplo n.º 5
0
    def wireless_device_active(self,  widget, new_state, old_state, reason):
        log.info(widget, widget.get_state())
        if widget not in net_manager.device_manager.wireless_devices:
            return

        if self.selected_item:
            self.selected_item.set_net_state(2)
            return

        index = self.get_actives(self.ap_list)
        if index:
            map(lambda (i, s): self.tree.visible_items[i].set_net_state(2), index)
    def wireless_device_active(self, widget, new_state, old_state, reason):
        log.info(widget, widget.get_state())
        if widget not in net_manager.device_manager.wireless_devices:
            return

        if self.selected_item:
            self.selected_item.set_net_state(2)
            return

        index = self.get_actives(self.ap_list)
        if index:
            map(lambda (i, s): self.tree.visible_items[i].set_net_state(2),
                index)
    def load_module(self, module_obj, hide_left):
        # create a reference
        self.setting_group = module_obj
        
        # init paned
        self.__init_paned(None)
        log.info("dss start load module", module_obj)
        self.hpaned.set_button_show(hide_left)
        
        # init foot_box
        self.foot_box.set_setting(module_obj)

        # init sidebar
        self.sidebar.load_list(module_obj)
        self.apply_method = module_obj.apply_changes
        self.save_method = module_obj.save_changes
Ejemplo n.º 8
0
    def load_module(self, module_obj, hide_left):
        # create a reference
        self.setting_group = module_obj

        # init paned
        self.__init_paned(None)
        log.info("dss start load module", module_obj)
        self.hpaned.set_button_show(hide_left)

        # init foot_box
        self.foot_box.set_setting(module_obj)

        # init sidebar
        self.sidebar.load_list(module_obj)
        self.apply_method = module_obj.apply_changes
        self.save_method = module_obj.save_changes
Ejemplo n.º 9
0
    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 __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