Пример #1
0
    def drawInteriorWithFrame_inView_(self, frame, view):
        """Draw the button image as specified by the current button state

        Note: this is necessary (as opposed to self.setImage_(...) and the
        default drawing logic) because it takes a final chance to check if the
        mouse is actually hovering over the frame before drawing the button
        image. If this is not done, and the mouse is being moved quickly from
        one hover button to the next then the previous button may remain in the
        hovered state even though the mouse has moved out of its frame.
        """
        # if log.isEnabledFor(logging.DEBUG):
        #   point = self.hover_info[0]
        #   inside = False if point is None else NSPointInRect(point, frame)
        #   log.debug("draw: %s inside=%s", self.hover_info, inside)
        image = self.buttonImageForFrame_inView_(frame, view)
        if image is not None:
            dest = self.buttonRectForFrame_imageSize_(frame, image.size())

            # Decrease the cell width by the width of the image we drew and its left padding
            frame.size.width -= dest.size.width

            ak.NSGraphicsContext.currentContext().saveGraphicsState()
            ak.NSGraphicsContext.currentContext().setImageInterpolation_(ak.NSImageInterpolationHigh)
            image.drawInRect_fromRect_operation_fraction_(
                fn.NSMakeRect(dest.origin.x, dest.origin.y, dest.size.width, dest.size.height),
                fn.NSMakeRect(0.0, 0.0, image.size().width, image.size().height),
                ak.NSCompositeSourceOver,
                1.0,
            )
            ak.NSGraphicsContext.currentContext().restoreGraphicsState()

        # draw the rest of the cell
        super(HoverButtonCell, self).drawInteriorWithFrame_inView_(frame, view)
 def deleteWordForward_(self, sender):
     ranges = self.selectedRanges()
     if len(ranges) == 1:
         newRange = ranges[0].rangeValue()
         if newRange.length == 0:
             self.moveWordRightAndModifySelection_(sender)
     super(CodeNSTextView, self).deleteWordForward_(sender)
Пример #3
0
 def __init__(self, posSize):
     objc.super(DrawView, self).__init__(posSize)
     pdfView = self.getNSView()
     pdfView.setAutoScales_(True)
     view = pdfView.documentView()
     scrollview = view.enclosingScrollView()
     scrollview.setBorderType_(NSBezelBorder)
Пример #4
0
 def sendEvent_(self, theEvent):
     if theEvent.type() == Cocoa.NSSystemDefined and \
            theEvent.subtype() == kEventHotKeyPressedSubtype:
         self.activateIgnoringOtherApps_(True)
         Cocoa.NSRunAlertPanel('Hot Key Pressed', 'Hot Key Pressed',
             None, None, None)
     super(HotKeyApp, self).sendEvent_(theEvent)
Пример #5
0
 def resetCursorRects(self):
     super(ThinSplitView, self).resetCursorRects()
     if self.resizeSlider is not None:
         rect = self.frame()
         location = self.resizeSlider.frame()
         location.origin.y = rect.size.height - location.size.height
         self.addCursorRect_cursor_(location, ak.NSCursor.resizeLeftRightCursor())
Пример #6
0
    def __init__(self):
        super(_SyncDeviceInquiry, self).__init__()

        self._inquiry = _AsyncDeviceInquiry.alloc().init()
        self._inquiry.cb_completed = self._inquirycomplete

        self._inquiring = False
Пример #7
0
 def mouseDown_(self, event):
     super().mouseDown_(event)
     point = self.convertPoint_fromView_(event.locationInWindow(), None)
     char_index = self.char_index_at_point(point)
     self.original_selection = self.textview.selectedRange()
     self.mouse_down_char_index = char_index
     self.mouse_dragged = False
Пример #8
0
    def mouseDragged_(self, event):
        if self.resizeOffset is None:
            super(ThinSplitView, self).mouseDragged_(event)
            return

        fn.NSNotificationCenter.defaultCenter().postNotificationName_object_(
            ak.NSSplitViewWillResizeSubviewsNotification, self)
        clickloc = event.locationInWindow()
        frame = self.fixedSizeView.frame()
        frame.size.width = clickloc.x + self.resizeOffset

        delegate = self.delegate()
        if delegate:
            if delegate.respondsToSelector_("splitView:constrainSplitPosition:ofSubviewAt:"):
                wid = delegate.splitView_constrainSplitPosition_ofSubviewAt_(self, frame.size.width, 0)
                frame.size.width = wid
            if delegate.respondsToSelector_("splitView:constrainMinCoordinate:ofSubviewAt:"):
                wid = delegate.splitView_constrainMinCoordinate_ofSubviewAt_(self, 0.0, 0)
                frame.size.width = max(wid, frame.size.width)
            if delegate.respondsToSelector_("splitView:constrainMaxCoordinate:ofSubviewAt:"):
                wid = delegate.splitView_constrainMaxCoordinate_ofSubviewAt_(self, 0.0, 0)
                frame.size.width = min(wid, frame.size.width)

        self.fixedSizeView.setFrame_(frame)
        self.adjustSubviews()

        fn.NSNotificationCenter.defaultCenter().postNotificationName_object_(
            ak.NSSplitViewDidResizeSubviewsNotification, self)
Пример #9
0
        def mouseDragged_(self, event):
            i = BrowserView.get_instance('webkit', self)
            window = self.window()

            if i.frameless:
                screenFrame = AppKit.NSScreen.mainScreen().frame()
                if screenFrame is None:
                    raise RuntimeError('Failed to obtain screen')

                windowFrame = window.frame()
                if windowFrame is None:
                    raise RuntimeError('Failed to obtain frame')

                currentLocation = window.convertBaseToScreen_(window.mouseLocationOutsideOfEventStream())
                newOrigin = AppKit.NSMakePoint((currentLocation.x - self.initialLocation.x),
                                        (currentLocation.y - self.initialLocation.y))
                if (newOrigin.y + windowFrame.size.height) > \
                    (screenFrame.origin.y + screenFrame.size.height):
                    newOrigin.y = screenFrame.origin.y + \
                                (screenFrame.size.height + windowFrame.size.height)
                window.setFrameOrigin_(newOrigin)

            if event.modifierFlags() & getattr(AppKit, 'NSEventModifierFlagControl', 1 << 18):
                i = BrowserView.get_instance('webkit', self)
                if i and not i.debug:
                    return

            super(BrowserView.WebKitHost, self).mouseDown_(event)
    def setBackgroundColor_(self, color):
        # invert the insertioin pointer color
        # and the fallback text color and background color
        try:
            color = color.colorUsingColorSpaceName_(AppKit.NSCalibratedRGBColorSpace)
            r = color.redComponent()
            g = color.greenComponent()
            b = color.blueComponent()
            s = sum([r, g, b]) / 3.
            inverseColor = s < .6
            if inverseColor:
                self._fallbackBackgroundColor = AppKit.NSColor.blackColor()
                self._fallbackTextColor = AppKit.NSColor.whiteColor()
                self.setInsertionPointColor_(AppKit.NSColor.whiteColor())
            else:
                self._fallbackBackgroundColor = AppKit.NSColor.whiteColor()
                self._fallbackTextColor = AppKit.NSColor.blackColor()
                self.setInsertionPointColor_(AppKit.NSColor.blackColor())

            if self.enclosingScrollView():
                self.enclosingScrollView().setBackgroundColor_(color)
            self._updateRulersColors()
        except:
            print(traceback.format_exc())
        super(CodeNSTextView, self).setBackgroundColor_(color)
Пример #11
0
 def drawRect_(self, rect):
     if self._wakeup:
         # try to minimize the f.o.u.c. while the webview starts up
         bgcolor = editor_info('colors')['background']
         bgcolor.setFill()
         NSRectFillUsingOperation(rect, NSCompositeCopy)
     super(EditorView, self).drawRect_(rect)
    def mouseDragged_(self, event):
        if self._canDrag:
            try:
                selRng = self.selectedRange()
                value = self._getSelectedValueForRange(selRng)
                if value is not None:
                    altDown = event.modifierFlags() & AppKit.NSAlternateKeyMask
                    shiftDown = event.modifierFlags() & AppKit.NSShiftKeyMask
                    altDown = event.modifierFlags() & AppKit.NSAlternateKeyMask
                    add = 1
                    if altDown and shiftDown:
                        add = .01
                    elif altDown:
                        add = .1
                    elif shiftDown:
                        add = 10

                    if isinstance(value, tuple):
                        valueX, valueY = value
                        valueX += int(event.deltaX()*2) * add
                        valueY -= int(event.deltaY()*2) * add
                        txtValue = "%s, %s" % (valueX, valueY)
                    else:
                        value += int(event.deltaX()*2) * add
                        txtValue = "%s" % value

                    self._insertTextAndRun(txtValue, selRng)
            except:
                pass
        super(CodeNSTextView, self).mouseDragged_(event)
 def _newPage(self, width, height):
     super(MOVContext, self)._newPage(width, height)
     self._frameDurationData.append((self._frameLength, self._frameScale))
     self.save()
     self.fill(1, 1, 1, 1)
     self.rect(0, 0, self.width, self.height)
     self.restore()
Пример #14
0
    def mouseDown_(self, theEvent):
        super(SelectionNotifyMatrix, self).mouseDown_(theEvent)

        row = self.selectedRow()
        if row != -1:
            Cocoa.NSNotificationCenter.defaultCenter(
            ).postNotificationName_object_userInfo_(RowSelectedNotification,
                                                    self, None)
Пример #15
0
        def initWithFilter_(self, file_filter):
            super(BrowserView.FileFilterChooser, self).init()
            self.filter = file_filter

            self.addItemsWithTitles_([i[0] for i in self.filter])
            self.setAction_('onChange:')
            self.setTarget_(self)
            return self
 def moveWordRight_(self, sender):
     ranges = self.selectedRanges()
     if len(ranges) == 1:
         newRange = ranges[0].rangeValue()
         location = self._getRightWordRange(newRange)
         self.setSelectedRange_((location, 0))
     else:
         super(CodeNSTextView, self).moveWordRight_(sender)
Пример #17
0
 def doCommandBySelector_(self, selector):
     editor = self.window_.current_editor
     if editor is not None:
         # 'cancelOperation:' gets converted to 'cancel:'; convert it back
         sel = ESCAPE if selector == "cancel:" else selector
         if editor.do_command(sel):
             return
     super().doCommandBySelector_(selector)
 def moveRight_(self, sender):
     super(CodeNSTextView, self).moveRight_(sender)
     string = self.string()
     if not string:
         return
     selectedRange = self.selectedRange()
     char = string[selectedRange.location-1]
     self._balanceParenForChar(char, selectedRange.location)
Пример #19
0
 def save_options(self):
     options = self.options
     if not (options.find_text and self.validate_expression()):
         return False
     save_to_find_pasteboard(options.find_text)
     if len(options.find_text) < 1000 and len(options.replace_text) < 1000:
         super(FindController, self).save_options()
     return True
Пример #20
0
        def initWithFilter_(self, file_filter):
            super(BrowserView.FileFilterChooser, self).init()
            self.filter = file_filter

            self.addItemsWithTitles_([i[0] for i in self.filter])
            self.setAction_('onChange:')
            self.setTarget_(self)
            return self
Пример #21
0
 def dealloc(self):
     # make sure we remove ourselves as an observer of the text storage
     view = self.clientView()
     if view is not None:
         NSNotificationCenter.defaultCenter().removeObserver_name_object_(
             self, NSTextStorageDidProcessEditingNotification,
             view.textStorage())
     super(LineNumberNSRulerView, self).dealloc()
Пример #22
0
 def reloadData(self):
     # based on Jonathan Dann's ESOutlineView
     super(OutlineView, self).reloadData()
     for row in reversed(range(self.numberOfRows())):
         item = self.itemAtRow_(row)
         obj = representedObject(item)
         if getattr(obj, "expanded", False):
             self.expandItem_(item)
Пример #23
0
    def selectCellAtRow_column_(self, row, col):
        super(SelectionNotifyMatrix, self).selectCellAtRow_column_(row, col)

        Cocoa.NSNotificationCenter.defaultCenter(
            ).postNotificationName_object_userInfo_(
                RowSelectedNotification,
                self,
                None)
Пример #24
0
 def dealloc(self):
     self.audio_packet_loss_rx_graph.removeFromSuperview()
     self.audio_packet_loss_tx_graph.removeFromSuperview()
     self.audio_rtt_graph.removeFromSuperview()
     self.rx_speed_graph.removeFromSuperview()
     self.tx_speed_graph.removeFromSuperview()
     self.video_rx_speed_graph.removeFromSuperview()
     self.video_tx_speed_graph.removeFromSuperview()
     objc.super(SessionInfoController, self).dealloc()
Пример #25
0
 def keyDown_(self, event):
     """."""
     handled = False
     characters = event.charactersIgnoringModifiers()
     if characters.isEqual_('r'):
         handled = True
         self.setItemPropertiesToDefault_(self)
     if handled is False:
         super(DraggableItemView, self).keyDown_(event)
Пример #26
0
 def linearGradient(self,
                    startPoint=None,
                    endPoint=None,
                    colors=None,
                    locations=None):
     super(SVGContext, self).linearGradient(startPoint, endPoint, colors,
                                            locations)
     if self._state.gradient is not None:
         self._state.gradient.writeDefs(self._svgContext)
Пример #27
0
 def dealloc(self):
     if self.app is not None and self in self.app.panels:
         self.app.panels.remove(self)
     self.app = None
     self.textview = None
     self.scroller = None
     self.spinner = None
     self.editor = None
     super().dealloc()
Пример #28
0
 def setTypingAttributes_(self, attrs):
     super().setTypingAttributes_(attrs)
     fg_color = ak.NSForegroundColorAttributeName
     if fg_color in attrs:
         theme = self.app.theme
         self.setInsertionPointColor_(attrs[fg_color])
         self.setSelectedTextAttributes_({
             ak.NSBackgroundColorAttributeName: theme.selection_color,
         })
Пример #29
0
 def init(self):
     super(FullscreenView, self).init()
     self.mousedown = False
     self.keydown = False
     self.key = None
     self.keycode = None
     # self.scrollwheel = False
     # self.wheeldelta = 0.0
     return self
 def keyDown_(self, event):
     if event.keyCode() == 36 and (event.modifierFlags() & NSShiftKeyMask):
         self.insertText_('\r\n')
     elif (event.modifierFlags() & NSCommandKeyMask):
         keys = event.characters()
         if keys[0] == 'i' and self.owner.delegate.sessionController.info_panel is not None:
             self.owner.delegate.sessionController.info_panel.toggle()
     elif self.isEditable():
         objc.super(ChatInputTextView, self).keyDown_(event)
 def dealloc(self):
     if self.typingTimer:
         self.typingTimer.invalidate()
         self.typingTimer = None
     if self.scrollingTimer:
         self.scrollingTimer.invalidate()
         self.scrollingTimer = None
     NSNotificationCenter.defaultCenter().removeObserver_(self)
     objc.super(ChatViewController, self).dealloc()
Пример #32
0
 def init(self):
     super(FullscreenView, self).init()
     self.mousedown = False
     self.keydown = False
     self.key = None
     self.keycode = None
     # self.scrollwheel = False
     # self.wheeldelta = 0.0
     return self
Пример #33
0
 def keyDown_(self, event):
     """."""
     handled = False
     characters = event.charactersIgnoringModifiers()
     if characters.isEqual_("r"):
         handled = True
         self.setItemPropertiesToDefault_(self)
     if handled is False:
         super(DraggableItemView, self).keyDown_(event)
Пример #34
0
 def mouseDown_(self, event):
     clickloc = event.locationInWindow()
     clickrec = self.hitTest_(clickloc)
     if clickrec is self.resizeSlider and clickrec is not None:
         frame = self.fixedSizeView.frame()
         self.resizeOffset = (frame.origin.x + frame.size.width) - clickloc.x
     else:
         self.resizeOffset = None
         super(ThinSplitView, self).mouseDown_(event)
Пример #35
0
    def windowControllerDidLoadNib_(self, controller):
        super(MyPDFDocument, self).windowControllerDidLoadNib_(controller)

        if self.fileName():
            pdfDoc = Quartz.PDFDocument.alloc().initWithURL_(
                Cocoa.NSURL.fileURLWithPath_(self.fileName()))
            self._pdfView.setDocument_(pdfDoc)

        # Page changed notification.
        Cocoa.NSNotificationCenter.defaultCenter(
        ).addObserver_selector_name_object_(
            self, "pageChanged:", Quartz.PDFViewPageChangedNotification,
            self._pdfView)

        # Find notifications.
        center = Cocoa.NSNotificationCenter.defaultCenter()
        center.addObserver_selector_name_object_(
            self, 'startFind:', Quartz.PDFDocumentDidBeginFindNotification,
            self._pdfView.document())
        center.addObserver_selector_name_object_(
            self, 'findProgress:',
            Quartz.PDFDocumentDidEndPageFindNotification,
            self._pdfView.document())
        center.addObserver_selector_name_object_(
            self, 'endFind:', Quartz.PDFDocumentDidEndFindNotification,
            self._pdfView.document())

        # Set self to be delegate (find).
        self._pdfView.document().setDelegate_(self)

        # Get outline.
        self._outline = self._pdfView.document().outlineRoot()
        if self._outline is not None:
            # Remove text that says, "No outline."
            self._noOutlineText.removeFromSuperview()
            self._noOutlineText = None

            # Force it to load up.
            self._outlineView.reloadData()

        else:
            # Remove outline view (leaving instead text that says,
            # "No outline.").
            self._outlineView.enclosingScrollView().removeFromSuperview()
            self._outlineView = None

        # Open drawer.
        self._drawer.open()

        # Size the window.
        windowSize = self._pdfView.rowSizeForPage_(self._pdfView.currentPage())

        if (self._pdfView.displayMode()
                & 0x01) and (self._pdfView.document().pageCount() > 1):
            windowSize.width += Cocoa.NSScroller.scrollerWidth()
        controller.window().setContentSize_(windowSize)
Пример #36
0
	def willDeactivate(self):
		"""
		Do stuff when the tool is deselected.
		"""
		try:
			objc.super(SelectTool, self).willDeactivate()
			if hasattr(self, 'deactivate'):
				self.deactivate()
		except:
			self.logError(traceback.format_exc())
Пример #37
0
def NSMOsetValue_ForKey_(self, name, value):
    try:
        first = _first_python(self.__class__)
        if first is not None:
            super(first, self).setValue_forKey_(value, name)
        else:
            self.setValue_forKey_(value, name)

    except KeyError:
        NSObject.__setattr__(self, name, value)
Пример #38
0
    def testBoth(self):
        o = PyObjC_ClsInst2.alloc().init()

        self.assertEqual(o.both(), 20)
        self.assertEqual(objc.super(PyObjC_ClsInst2, o).both(), 2)

        cls = PyObjC_ClsInst2

        self.assertEqual(cls.both(), 30)
        self.assertEqual(objc.super(cls, cls).both(), 3)
Пример #39
0
    def mouseDown_(self, theEvent):
        super(SelectionNotifyMatrix, self).mouseDown_(theEvent)

        row = self.selectedRow()
        if row != -1:
            Cocoa.NSNotificationCenter.defaultCenter(
                ).postNotificationName_object_userInfo_(
                    RowSelectedNotification,
                    self,
                    None)
Пример #40
0
    def testBoth(self):
        o = PyObjC_ClsInst2.alloc().init()

        self.assertEquals(o.both(), 20)
        self.assertEquals(objc.super(PyObjC_ClsInst2, o).both(), 2)

        cls = PyObjC_ClsInst2

        self.assertEquals(cls.both(), 30)
        self.assertEquals(objc.super(cls, cls).both(), 3)
Пример #41
0
def NSMOsetValue_ForKey_(self, name, value):
    try:
        first = _first_python(self.__class__)
        if first is not None:
            super(first, self).setValue_forKey_(value, name)
        else:
            self.setValue_forKey_(value, name)

    except KeyError as msg:
        NSObject.__setattr__(self, name, value)
Пример #42
0
 def dealloc(self):
     self.notification_center.remove_observer(
         self, name='BonjourConferenceServicesDidRemoveServer')
     self.notification_center.remove_observer(
         self, name='BonjourConferenceServicesDidUpdateServer')
     self.notification_center.remove_observer(
         self, name='BonjourConferenceServicesDidAddServer')
     self.notification_center.remove_observer(
         self, name='SIPAccountManagerDidChangeDefaultAccount')
     objc.super(JoinConferenceWindowController, self).dealloc()
Пример #43
0
	def willDeactivate(self):
		"""
		Do stuff when the tool is deselected.
		"""
		try:
			objc.super(SelectTool, self).willDeactivate()
			if hasattr(self, 'deactivate'):
				self.deactivate()
		except:
			self.logError(traceback.format_exc())
Пример #44
0
    def mouseUp_(self, event):
        super().mouseUp_(event)
        point = self.convertPoint_fromView_(event.locationInWindow(), None)
        if not ak.NSPointInRect(point, self.frame()):
            view_point = self.convertPoint_toView_(point, self.textview)
            doc_rect = self.scrollView().documentVisibleRect()
            if not ak.NSPointInRect(view_point, doc_rect):
                self.textview.setSelectedRange_(self.original_selection)
                return
        elif not self.mouse_dragged:
            view = self.textview
            font = view.font()
            layout = view.layoutManager()
            line_height = layout.defaultLineHeightForFont_(font)

            char_index = self.char_index_at_point(point)
            point2 = ak.NSPoint(point.x, point.y + line_height)
            char_index2 = self.char_index_at_point(point2)
            length = view.textStorage().length()
            mods = event.modifierFlags() & ak.NSDeviceIndependentModifierFlagsMask
            extend_selection = mods == ak.NSShiftKeyMask

            if char_index == char_index2 and char_index >= length - 1:
                # clicked below last line
                if extend_selection:
                    start = self.original_selection[0]
                    rng = (start, length - start)
                else:
                    rng = (length, 0)
            else:
                lines = view.editor.line_numbers
                line = lines[char_index]
                try:
                    next_index = lines.index_of(line + 1)
                except ValueError:
                    next_index = length
                start = min(char_index, next_index)
                length = abs(next_index - char_index)
                if extend_selection:
                    orig = self.original_selection
                    if orig[0] < start:
                        # beginning of original to end of clicked line
                        length = length + start - orig[0]
                        start = orig[0]
                    elif sum(orig) > start + length:
                        # beginning of clicked line to end of original
                        length = sum(orig) - start
                    elif start <= orig[0] and (start + length) > sum(orig):
                        # beginning of clicked line to end of original on same line
                        length = sum(orig) - start
                rng = (start, length)
            view.setSelectedRange_(rng)
        self.original_selection = None
        self.mouse_down_char_index = None
        self.mouse_dragged = None
Пример #45
0
	def willActivate(self):
		"""
		Do stuff when the tool is selected.
		E.g. show a window, or set a cursor.
		"""
		try:
			objc.super(SelectTool, self).willActivate()
			if hasattr(self, 'activate'):
				self.activate()
		except:
			self.logError(traceback.format_exc())
 def remove_observer(self, observer):
     """
     Stops thread and invalidates source.
     """
     super(PowerManagement, self).remove_observer(observer)
     if len(self._weak_observers) == 0:
         if not self._cf_run_loop:
             PowerManagement.notifications_observer.removeObserver(self)
         else:
             CFRunLoopSourceInvalidate(self._source)
             self._source = None
Пример #47
0
    def init(self):
        global N
        if N == 1:
            print("Calling super.init")
            N = 0

            # Call super-class implementation.
            super(MyObject, self).init()

        else:
            print("Cyclic call detected")
Пример #48
0
 def performFindPanelAction_(self, sender):
     # frustrating bug:
     # when the find bar is dismissed with esc, the *other* textview becomes
     # first responder. the `solution' here is to monitor the find bar's field
     # editor and notice when it is detached from the view hierarchy. it then
     # re-sets itself as first responder
     super(OutputTextView, self).performFindPanelAction_(sender)
     if self._findTimer:
         self._findTimer.invalidate()
     self._findEditor = self.window().firstResponder().superview(
     ).superview()
     self._findTimer = set_timeout(self, 'stillFinding:', 0.05, repeat=True)
Пример #49
0
	def setup(self):
		try:
			objc.super(FilterWithDialog, self).setup()
			
			if hasattr(self, 'start'):
				self.start()
			
			self.process_(None)
			
			return None
		except:
			self.logError(traceback.format_exc())
Пример #50
0
 def dealloc(self):
     self.sessionController.log_debug("Dealloc %s" % self)
     self.notification_center.discard_observer(
         self, sender=self.sessionController)
     self.notification_center.discard_observer(self, sender=self.stream)
     self.videoWindowController.release()
     self.videoWindowController = None
     self.videoRecorder = None
     self.stream = None
     self.sessionController = None
     self.notification_center = None
     objc.super(VideoController, self).dealloc()
Пример #51
0
    def setClientView_(self, view):
        oldClientView = self.clientView()

        if oldClientView != view and isinstance(oldClientView, NSTextView):
            NSNotificationCenter.defaultCenter().removeObserver_name_object_(self, NSTextStorageDidProcessEditingNotification, oldClientView.textStorage())

        super(NSLineNumberRuler, self).setClientView_(view)

        if view is not None and isinstance(view, NSTextView):
            NSNotificationCenter.defaultCenter().addObserver_selector_name_object_(self, "textDidChange:",
                                                    NSTextStorageDidProcessEditingNotification,
                                                    view.textStorage())
Пример #52
0
        def mouseDown_(self, event):
            i = BrowserView.get_instance('webkit', self)
            window = self.window()

            if i.frameless and i.easy_drag:
                windowFrame = window.frame()
                if windowFrame is None:
                    raise RuntimeError('Failed to obtain screen')

                self.initialLocation = window.convertBaseToScreen_(event.locationInWindow())
                self.initialLocation.x -= windowFrame.origin.x
                self.initialLocation.y -= windowFrame.origin.y

            super(BrowserView.WebKitHost, self).mouseDown_(event)
Пример #53
0
    def windowControllerDidLoadNib_(self, controller):
        super(GraphicsBindingsDocument,
              self).windowControllerDidLoadNib_(controller)

        # we can't do these in IB at the moment, as
        # we don't have palette items for them

        # allow the shadow inspector (joystick) to handle multiple selections
        offsetOptions = {"NSAllowsEditingMultipleValuesSelection": True}
        angleOptions = {
            "NSValueTransformerName": "RadiansToDegreesTransformer",
            "NSAllowsEditingMultipleValuesSelection": True,
        }

        BINDINGS = [
            (
                "graphics",
                self.graphicsView,
                self.graphicsController,
                "arrangedObjects",
                None,
            ),
            (
                "selectionIndexes",
                self.graphicsView,
                self.graphicsController,
                "selectionIndexes",
                None,
            ),
            (
                "offset",
                self.shadowInspector,
                self.graphicsController,
                "selection.shadowOffset",
                offsetOptions,
            ),
            (
                "angle",
                self.shadowInspector,
                self.graphicsController,
                "selection.shadowAngle",
                angleOptions,
            ),
        ]
        for binding in BINDINGS:
            self.makeBinding_fromObject_toObject_withKeyPath_options_(*binding)

        # "fake" what should be set in IB if we had a palette...
        self.shadowInspector.maxOffset = 15
Пример #54
0
    def initWithFrame_(self, frameRect):
        global startPoint, startRadius, startExtend
        global endPoint, endRadius, endExtend

        super(MyQuartzView, self).initWithFrame_(frameRect)

        startPoint = Quartz.CGPoint(0, 0)
        startRadius = 0
        startExtend = False

        endPoint = Quartz.CGPointMake(0, 0)
        endRadius = 0
        endExtend = False

        return self
Пример #55
0
    def initWithPeripheral_(self, peripheral: CBPeripheral):
        """macOS init function for NSObject"""
        self = objc.super(PeripheralDelegate, self).init()

        if self is None:
            return None

        self.peripheral = peripheral
        self.peripheral.setDelegate_(self)

        self._event_loop = asyncio.get_event_loop()
        self._services_discovered_future = self._event_loop.create_future()

        self._service_characteristic_discovered_futures: Dict[
            int, asyncio.Future] = {}
        self._characteristic_descriptor_discover_futures: Dict[
            int, asyncio.Future] = {}

        self._characteristic_read_futures: Dict[int, asyncio.Future] = {}
        self._characteristic_write_futures: Dict[int, asyncio.Future] = {}

        self._descriptor_read_futures: Dict[int, asyncio.Future] = {}
        self._descriptor_write_futures: Dict[int, asyncio.Future] = {}

        self._characteristic_notify_change_futures: Dict[int,
                                                         asyncio.Future] = {}
        self._characteristic_notify_callbacks: Dict[int, Callable[[str, Any],
                                                                  Any]] = {}

        self._read_rssi_futures: Dict[NSUUID, asyncio.Future] = {}

        return self
Пример #56
0
    def init(self):
        self = super(DragSupportDataSource, self).init()
        if self is None:
            return None

        self.registeredTableViews = Cocoa.NSMutableSet.alloc().init()
        return self
Пример #57
0
    def initWithPeripheral_(self, peripheral: CBPeripheral):
        """macOS init function for NSObject"""
        self = objc.super(PeripheralDelegate, self).init()

        if self is None:
            return None

        self.peripheral = peripheral
        self.peripheral.setDelegate_(self)

        self._event_loop = asyncio.get_event_loop()
        self._services_discovered_event = asyncio.Event()

        self._service_characteristic_discovered_events = _EventDict()
        self._characteristic_descriptor_discover_events = _EventDict()

        self._characteristic_read_events = _EventDict()
        self._characteristic_write_events = _EventDict()

        self._descriptor_read_events = _EventDict()
        self._descriptor_write_events = _EventDict()

        self._characteristic_notify_change_events = _EventDict()
        self._characteristic_notify_callbacks = {}

        return self
Пример #58
0
 def init(self):
     self = objc.super(SMSWindowManagerClass, self).init()
     if self:
         self.notification_center = NotificationCenter()
         self.notification_center.add_observer(self,
                                               name="SIPEngineGotMessage")
     return self
Пример #59
0
    def init(self):
        """macOS init function for NSObjects"""
        self = objc.super(PeripheralManagerDelegate, self).init()

        self.event_loop: asyncio.AbstractEventLoop = asyncio.get_event_loop()

        self.peripheral_manager: CBPeripheralManager = (
            CBPeripheralManager.alloc().initWithDelegate_queue_(
                self,
                dispatch_queue_create(b"bleak.corebluetooth",
                                      DISPATCH_QUEUE_SERIAL),
            ))

        self._callbacks: Dict[str, Callable] = {}

        # Events
        self._powered_on_event: threading.Event = threading.Event()
        self._advertisement_started_event: asyncio.Event = asyncio.Event()
        self._services_added_events: Dict[str, asyncio.Event] = {}

        # Documentation requires that no calls be made until we can validate
        # that the bluetooth module is powered on
        self._powered_on_event.wait()

        self._central_subscriptions = {}

        if not self.compliant():
            logger.warning("PeripheralManagerDelegate is not compliant")

        return self
Пример #60
0
    def init(self):
        self = objc.super(TestUseKVOObserver, self).init()
        if self is None:
            return None

        self.observations = []
        return self