Exemplo n.º 1
0
    def _NH_BlinkFileTransferNewOutgoing(self, sender, data):
        try:
            item = next((item for item in self.listView.subviews().copy()
                         if item.file_path == sender.ft_info.file_path
                         and item.remote_uri == sender.ft_info.remote_uri))
            item.replaceWithTransfer_(sender)
            self.listView.relayout()

        except StopIteration:
            item = FileTransferItemView.alloc().initWithFrame_transfer_(
                NSMakeRect(0, 0, 100, 100), sender)
            self.listView.addItemView_(item)
            h = NSHeight(self.listView.frame())
            self.listView.scrollRectToVisible_(NSMakeRect(0, h - 1, 100, 1))

        file_path = sender.ft_info.file_path.decode() if isinstance(
            sender.ft_info.file_path, bytes) else sender.ft_info.file_path
        if 'screencapture' not in file_path:
            self.window.orderFront_(None)

        count = len(self.listView.subviews())
        if count == 1:
            self.bottomLabel.setStringValue_(
                NSLocalizedString("1 item", "Label"))
        else:
            self.bottomLabel.setStringValue_(
                NSLocalizedString("%i items", "Label") % count)
Exemplo n.º 2
0
    def render_previous_transfers(self, transfers):
        last_displayed_item = self.listView.subviews().lastObject()

        for transfer in transfers:
            item = FileTransferItemView.alloc().initWithFrame_oldTransfer_(
                NSMakeRect(0, 0, 100, 100), transfer)
            if last_displayed_item:
                self.listView.insertItemView_before_(item, last_displayed_item)
            else:
                self.listView.addItemView_(item)

            self.listView.relayout()
            self.listView.display()
            h = self.listView.minimumHeight()
            self.listView.scrollRectToVisible_(NSMakeRect(0, h - 1, 100, 1))

        count = len(self.listView.subviews())
        if count == 1:
            self.bottomLabel.setStringValue_(
                NSLocalizedString("1 item", "Label"))
        else:
            self.bottomLabel.setStringValue_(
                NSLocalizedString("%i items", "Label") %
                count if count else "")

        self.loaded = True
    def _NH_BlinkFileTransferInitializing(self, sender, data):
        item = FileTransferItemView.alloc().initWithFrame_transfer_(NSMakeRect(0, 0, 100, 100), sender)

        self.listView.addItemView_(item)
        h = NSHeight(self.listView.frame())
        self.listView.scrollRectToVisible_(NSMakeRect(0, h-1, 100, 1))

        if 'xscreencapture' not in sender.file_path:
            self.window.orderFront_(None)

        count = len(self.listView.subviews())
        if count == 1:
            self.bottomLabel.setStringValue_(NSLocalizedString("1 item", "Label"))
        else:
            self.bottomLabel.setStringValue_(NSLocalizedString("%i items", "Label") % count)
    def _NH_BlinkFileTransferInitializing(self, sender, data):
        item = FileTransferItemView.alloc().initWithFrame_transfer_(NSMakeRect(0, 0, 100, 100), sender)

        self.listView.addItemView_(item)
        h = NSHeight(self.listView.frame())
        self.listView.scrollRectToVisible_(NSMakeRect(0, h-1, 100, 1))

        if not (isinstance(sender, IncomingFileTransferHandler) and sender.file_name.startswith('xscreencapture')):
            self.window.orderFront_(None)

        count = len(self.listView.subviews())
        if count == 1:
            self.bottomLabel.setStringValue_(u"1 item")
        else:
            self.bottomLabel.setStringValue_(u"%i items"%count)
    def render_previous_transfers(self, transfers):
        last_displayed_item = self.listView.subviews().lastObject()

        for transfer in transfers:
            item = FileTransferItemView.alloc().initWithFrame_oldTransfer_(NSMakeRect(0, 0, 100, 100), transfer)
            if last_displayed_item:
                self.listView.insertItemView_before_(item, last_displayed_item)
            else:
                self.listView.addItemView_(item)

            self.listView.relayout()
            self.listView.display()
            h = self.listView.minimumHeight()
            self.listView.scrollRectToVisible_(NSMakeRect(0, h - 1, 100, 1))

        count = len(self.listView.subviews())
        if count == 1:
            self.bottomLabel.setStringValue_(u"1 item")
        else:
            self.bottomLabel.setStringValue_(u"%i items" % count if count else u"")

        self.loaded = True