def awakeFromNib(self):
        self.outputView.setShouldCloseWithWindow_(True)
        self.outputView.registerForDraggedTypes_(NSArray.arrayWithObject_(NSFilenamesPboardType))
        NSNotificationCenter.defaultCenter().addObserver_selector_name_object_(self, "webviewFinishedLoading:", WebViewProgressFinishedNotification, self.outputView)
        if self.inputText:
            self.inputText.registerForDraggedTypes_(NSArray.arrayWithObject_(NSFilenamesPboardType))
            self.inputText.setOwner(self)
            NSNotificationCenter.defaultCenter().addObserver_selector_name_object_(self, "textDidChange:", NSTextDidChangeNotification, self.inputText)

        self.messageQueue = []
 def tableView_writeRows_toPasteboard_(self, table, rows, pboard):
     index = rows[0]
     pboard.declareTypes_owner_(NSArray.arrayWithObject_("dragged-row"),
                                self)
     pboard.setString_forType_(NSString.stringWithString_(str(index)),
                               "dragged-row")
     return True
Example #3
0
 def copy_(self, sender):
     if self.delegate is None:
         return
     pb = NSPasteboard.generalPasteboard()
     copy_text = format_identity_to_string(self.delegate.sessionController.remotePartyObject, check_contact=True, format='full')
     pb.declareTypes_owner_(NSArray.arrayWithObject_(NSStringPboardType), self)
     pb.setString_forType_(copy_text, NSStringPboardType)
    def awakeFromNib(self):
        self.outputView.setShouldCloseWithWindow_(True)
        self.outputView.registerForDraggedTypes_(
            NSArray.arrayWithObject_(NSFilenamesPboardType))
        NSNotificationCenter.defaultCenter().addObserver_selector_name_object_(
            self, "webviewFinishedLoading:",
            WebViewProgressFinishedNotification, self.outputView)
        if self.inputText:
            self.inputText.registerForDraggedTypes_(
                NSArray.arrayWithObject_(NSFilenamesPboardType))
            self.inputText.setOwner(self)
            NSNotificationCenter.defaultCenter(
            ).addObserver_selector_name_object_(self, "textDidChange:",
                                                NSTextDidChangeNotification,
                                                self.inputText)

        self.messageQueue = []
 def awakeFromNib(self):
     NotificationCenter().add_observer(self, name="BlinkGroupsHaveChanged")
     self.addressTable.tableColumnWithIdentifier_(
         "0").dataCell().setPlaceholderString_(
             NSLocalizedString("Click to add a new address",
                               "Text placeholder"))
     self.addressTable.setDraggingSourceOperationMask_forLocal_(
         NSDragOperationGeneric, True)
     self.addressTable.registerForDraggedTypes_(
         NSArray.arrayWithObject_("dragged-row"))
 def copy_(self, sender):
     if self.delegate is None:
         return
     pb = NSPasteboard.generalPasteboard()
     copy_text = format_identity_to_string(
         self.delegate.sessionController.remoteIdentity,
         check_contact=True,
         format='full')
     pb.declareTypes_owner_(NSArray.arrayWithObject_(NSStringPboardType),
                            self)
     pb.setString_forType_(copy_text, NSStringPboardType)
 def copy_img(self, image_data, mime='image/png', clear_first=True):
     image = NSImage.alloc().initWithData_(image_data)
     array = NSArray.arrayWithObject_(image)
     pb = NSPasteboard.generalPasteboard()
     if clear_first:
         pb.clearContents()
     # end def
     if mime in self.FORMAT_CONVERTER:
         pb.declareTypes_owner_([self._f(mime)], None)
     # end def
     success = pb.writeObjects_(array)
     return success  # todo: throw
    def init_sdl_window(self):
        if self.sdl_window:
            return
        if self.window is not None:
            return
        if self.streamController.stream is None:
            return
        if self.streamController.stream.video_windows is None:
            return
        if self.streamController.stream.video_windows.remote is None:
            return

        self.sdl_window = self.streamController.stream.video_windows.remote

        self.initial_size = self.streamController.stream.video_windows.remote.size
        self.aspect_ratio = float(self.initial_size[0]) / self.initial_size[1]
        self.sessionController.log_debug('Remote aspect ratio is %.2f' % self.aspect_ratio)

        self.initial_aspect_ratio = self.aspect_ratio

        found = False
        for ratio in self.valid_aspect_ratios:
            if ratio is None:
                continue
            diff = ratio - self.aspect_ratio
            if diff < 0:
                diff = diff * -1
            if self.aspect_ratio > 0.95 * ratio and self.aspect_ratio < 1.05 * ratio:
                found = True
                break

        if not found:
            self.valid_aspect_ratios.append(self.aspect_ratio)

        self.window = NSWindow(cobject=self.sdl_window.native_handle)
        self.window.setTitle_(self.title)
        self.window.setDelegate_(self)
        self.sessionController.log_debug('Init %s in %s' % (self.window, self))
        self.dif_y = self.window.frame().size.height - self.streamController.stream.video_windows.remote.size[1]
        #self.toogleAlwaysOnTop()
        self.updateTrackingAreas()

        frame = self.window.frame()
        self.sessionController.log_info('Remote video stream at %0.fx%0.f resolution' % (frame.size.width, frame.size.height-self.dif_y))
        frame.size.width = 640
        frame.size.height = frame.size.width / self.aspect_ratio
        frame.size.height += self.dif_y
        self.window.setFrame_display_(frame, True)
        self.window.center()
        self.window.registerForDraggedTypes_(NSArray.arrayWithObject_(NSFilenamesPboardType))
Example #9
0
    def mouseDragged_(self, event):
        if self.delegate is None:
            return
        pos = event.locationInWindow()
        if abs(self.dragPos.x - pos.x) > 3 or abs(self.dragPos.y - pos.y) > 3:
            image = self.makeDragImage()

            pos.x -= image.size().width/2
            pos.y -= image.size().height/2
            pboard = NSPasteboard.pasteboardWithName_(NSDragPboard)
            pboard.declareTypes_owner_(NSArray.arrayWithObject_("x-blink-audio-session"), self)
            uri = format_identity_to_string(self.delegate.sessionController.remotePartyObject, check_contact=False, format='compact')
            pboard.setString_forType_(uri, "x-blink-audio-session")
            self.window().dragImage_at_offset_event_pasteboard_source_slideBack_(image,
                    pos, NSZeroPoint, event, pboard, self, False)
            self.draggedOut = False
    def mouseDragged_(self, event):
        if self.delegate is None:
            return
        pos = event.locationInWindow()
        if abs(self.dragPos.x - pos.x) > 3 or abs(self.dragPos.y - pos.y) > 3:
            image = self.makeDragImage()

            pos.x -= image.size().width / 2
            pos.y -= image.size().height / 2
            pboard = NSPasteboard.pasteboardWithName_(NSDragPboard)
            pboard.declareTypes_owner_(
                NSArray.arrayWithObject_("x-blink-audio-session"), self)
            uri = format_identity_to_string(
                self.delegate.sessionController.remoteIdentity,
                check_contact=False,
                format='compact')
            pboard.setString_forType_(uri, "x-blink-audio-session")
            self.window(
            ).dragImage_at_offset_event_pasteboard_source_slideBack_(
                image, pos, NSZeroPoint, event, pboard, self, False)
            self.draggedOut = False
 def tableView_writeRows_toPasteboard_(self, table, rows, pboard):
     index = rows[0]
     pboard.declareTypes_owner_(NSArray.arrayWithObject_("dragged-row"), self)
     pboard.setString_forType_(NSString.stringWithString_(str(index)), "dragged-row")
     return True
 def awakeFromNib(self):
     NotificationCenter().add_observer(self, name="BlinkGroupsHaveChanged")
     self.addressTable.tableColumnWithIdentifier_("0").dataCell().setPlaceholderString_(NSLocalizedString("Click to add a new address", "Text placeholder"))
     self.addressTable.setDraggingSourceOperationMask_forLocal_(NSDragOperationGeneric, True)
     self.addressTable.registerForDraggedTypes_(NSArray.arrayWithObject_("dragged-row"))