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)
 def device_deactive(self, name, event, data):
     print "device deactive"
     new_state, old_state, reason = data
     if reason == 39:
         self.dsl.set_active(False)
         return
     if reason == 36:
         print "in fact there had device removed"
         ########################
         net_manager.init_devices()
         self.wired_devices = net_manager.wired_devices
         self._init_signals()
         self.tree.delete_all_items()
         item_list = self.get_list()
         if item_list:
             item_list[-1].is_last = True
             self.tree.add_items(item_list, 0, True)
             self.tree.set_size_request(-1,
                                        len(self.tree.visible_items) * 30)
     index = 0
     for d in self.wired_devices:
         if d.get_state() == 100:
             self.tree.visible_items[index].set_net_state(2)
         index += 1
     if not any([d.get_state() == 100 for d in net_manager.wired_devices]):
         self.dsl.set_active(False)
 def device_deactive(self, name, event, data):
     print "device deactive"
     new_state, old_state, reason = data
     if reason == 39:
         self.dsl.set_active(False)
         return
     if reason == 36:
         print "in fact there had device removed"
     ########################
         net_manager.init_devices()
         self.wired_devices = net_manager.wired_devices
         self._init_signals()
         self.tree.delete_all_items()
         item_list = self.get_list()
         if item_list:
             item_list[-1].is_last = True
             self.tree.add_items(item_list, 0, True)
             self.tree.set_size_request(-1, len(self.tree.visible_items)*30)
     index = 0
     for d in self.wired_devices:
         if d.get_state() == 100:
             self.tree.visible_items[index].set_net_state(2)
         index += 1
     if not any([d.get_state() == 100 for d in net_manager.wired_devices]):
         self.dsl.set_active(False)
 def wired_device_deactive(self, widget, new_state, old_state, reason):
     log.debug(new_state, old_state, reason, widget)
     if reason == 36:
         print "in fact there's device removed"
         ########################
         net_manager.init_devices()
         self.wired_devices = net_manager.wired_devices
         self._init_signals()
         self.tree.delete_all_items()
         item_list = self.get_list()
         if item_list:
             item_list[-1].is_last = True
             self.tree.add_items(item_list, 0, True)
             self.tree.set_size_request(-1,
                                        len(self.tree.visible_items) * 30)
     for i, d in enumerate(self.wired_devices):
         if d.get_state() == 100:
             self.tree.visible_items[i].set_net_state(2)
         elif d.get_state() <= 30:
             self.tree.visible_items[i].set_net_state(0)
     if not any([
             d.get_state() == 100
             for d in net_manager.device_manager.wired_devices
     ]):
         self.wire.set_active(False)
    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)
 def init_sections_state(self):
     net_manager.init_devices()
     for section in self.vbox.get_children():
         if section.show_or_hide():
             section.section_show()
             section.init_state()
         else:
             section.section_hide()
     slider._append_page(Region(), "region")
     from setting_page_ui import SettingUI
     self.setting_page_ui = SettingUI(None, None)
     slider._append_page(self.setting_page_ui, "setting")
 def init_sections_state(self):
     net_manager.init_devices()
     for section in self.vbox.get_children():
         if section.show_or_hide():
             section.section_show()
             section.init_state()
         else:
             section.section_hide()
     slider._append_page(Region(), "region")
     from setting_page_ui import SettingUI
     self.setting_page_ui = SettingUI(None, None)
     slider._append_page(self.setting_page_ui, "setting")
 def wired_device_deactive(self, widget, new_state, old_state, reason):
     log.debug(new_state, old_state, reason, widget)
     if reason == 36:
         print "in fact there's device removed"
     ########################
         net_manager.init_devices()
         self.wired_devices = net_manager.wired_devices
         self._init_signals()
         self.tree.delete_all_items()
         item_list = self.get_list()
         if item_list:
             item_list[-1].is_last = True
             self.tree.add_items(item_list, 0, True)
             self.tree.set_size_request(-1, len(self.tree.visible_items)*30)
     for i, d in enumerate(self.wired_devices):
         if d.get_state() == 100:
             self.tree.visible_items[i].set_net_state(2)
         elif d.get_state() <= 30:
             self.tree.visible_items[i].set_net_state(0)
     if not any([d.get_state() == 100 for d in net_manager.device_manager.wired_devices]):
         self.wire.set_active(False)
#!/usr/bin/env python
#-*- coding:utf-8 -*-

#import dss
import time
t = time.time()
from shared_methods import net_manager, nm_module
net_manager.init_devices()
print time.time() - t
import gtk

def get_ap_list(widget):
    print net_manager.get_ap_list()

def get_wired_connection(widget):
    print nm_module.nm_remote_settings.get_wired_connections()

def get_wireless_connection(widget):
    print nm_module.nm_remote_settings.get_wireless_connections()

def get_devices(widget):
    print "wired", net_manager.wired_devices
    print "wireless", net_manager.wireless_devices
    print "nmclient", nm_module.nmclient.get_wired_devices()

    assert net_manager.wired_devices == nm_module.nmclient.get_wired_devices()
    print "wired_spec",nm_module.cache.get_spec_object(net_manager.wired_device.object_path)
    print "wireless_spec",nm_module.cache.get_spec_object(net_manager.wireless_device.object_path)


def init_all(widget):