コード例 #1
0
ファイル: device.py プロジェクト: john-peterson/calibre
    def set_smartdevice_action_state(self):
        from calibre.gui2.dialogs.smartdevice import get_all_ip_addresses
        dm = self.gui.device_manager

        forced_ip = dm.get_option('smartdevice', 'force_ip_address')
        if forced_ip:
            formatted_addresses = forced_ip
            show_port = True
        else:
            all_ips = get_all_ip_addresses()
            if len(all_ips) > 3:
                formatted_addresses = _('Many IP addresses. See Start/Stop dialog.')
                show_port = False
            else:
                formatted_addresses = ' or '.join(get_all_ip_addresses())
                show_port = True

        running = dm.is_running('smartdevice')
        if not running:
            text = self.share_conn_menu.DEVICE_MSGS[0]
        else:
            use_fixed_port = dm.get_option('smartdevice', 'use_fixed_port')
            port_number = dm.get_option('smartdevice', 'port_number')
            if show_port and use_fixed_port:
                text = self.share_conn_menu.DEVICE_MSGS[1]  + ' [%s, port %s]'%(
                                            formatted_addresses, port_number)
            else:
                text = self.share_conn_menu.DEVICE_MSGS[1] + ' [' + formatted_addresses + ']'

        icon = 'green' if running else 'red'
        ac = self.share_conn_menu.control_smartdevice_action
        ac.setIcon(QIcon(I('dot_%s.png'%icon)))
        ac.setText(text)
コード例 #2
0
ファイル: device.py プロジェクト: exedre/calibre
    def set_smartdevice_action_state(self):
        from calibre.gui2.dialogs.smartdevice import get_all_ip_addresses
        dm = self.gui.device_manager

        forced_ip = dm.get_option('smartdevice', 'force_ip_address')
        if forced_ip:
            formatted_addresses = forced_ip
            show_port = True
        else:
            all_ips = get_all_ip_addresses()
            if len(all_ips) == 0:
                formatted_addresses = _('Still looking for IP addresses')
                show_port = False
            elif len(all_ips) > 3:
                formatted_addresses = _('Many IP addresses. See Start/Stop dialog.')
                show_port = False
            else:
                formatted_addresses = ' or '.join(get_all_ip_addresses())
                show_port = True

        running = dm.is_running('smartdevice')
        if not running:
            text = self.share_conn_menu.DEVICE_MSGS[0]
        else:
            use_fixed_port = dm.get_option('smartdevice', 'use_fixed_port')
            port_number = dm.get_option('smartdevice', 'port_number')
            if show_port and use_fixed_port:
                text = self.share_conn_menu.DEVICE_MSGS[1]  + ' [%s, port %s]'%(
                                            formatted_addresses, port_number)
            else:
                text = self.share_conn_menu.DEVICE_MSGS[1] + ' [' + formatted_addresses + ']'

        icon = 'green' if running else 'red'
        ac = self.share_conn_menu.control_smartdevice_action
        ac.setIcon(QIcon(I('dot_%s.png'%icon)))
        ac.setText(text)
コード例 #3
0
ファイル: device.py プロジェクト: mirror/calibre
    def set_smartdevice_action_state(self):
        from calibre.gui2.dialogs.smartdevice import get_all_ip_addresses

        dm = self.gui.device_manager

        forced_ip = dm.get_option("smartdevice", "force_ip_address")
        if forced_ip:
            formatted_addresses = forced_ip
            show_port = True
        else:
            all_ips = get_all_ip_addresses()
            if len(all_ips) == 0:
                formatted_addresses = _("Still looking for IP addresses")
                show_port = False
            elif len(all_ips) > 3:
                formatted_addresses = _("Many IP addresses. See Start/Stop dialog.")
                show_port = False
            else:
                formatted_addresses = " or ".join(get_all_ip_addresses())
                show_port = True

        running = dm.is_running("smartdevice")
        if not running:
            text = self.share_conn_menu.DEVICE_MSGS[0]
        else:
            use_fixed_port = dm.get_option("smartdevice", "use_fixed_port")
            port_number = dm.get_option("smartdevice", "port_number")
            if show_port and use_fixed_port:
                text = self.share_conn_menu.DEVICE_MSGS[1] + " [%s, port %s]" % (formatted_addresses, port_number)
            else:
                text = self.share_conn_menu.DEVICE_MSGS[1] + " [" + formatted_addresses + "]"

        icon = "green" if running else "red"
        ac = self.share_conn_menu.control_smartdevice_action
        ac.setIcon(QIcon(I("dot_%s.png" % icon)))
        ac.setText(text)