def tableView_acceptDrop_row_dropOperation_(self, table, info, row, oper):
        pboard = info.draggingPasteboard()
        if pboard.availableTypeFromArray_(["x-blink-sip-uri"]):
            group, blink_contact = eval(pboard.stringForType_("dragged-contact"))
            if blink_contact is not None:
                sourceGroup = NSApp.delegate().contactsWindowController.model.groupsList[group]
                sourceContact = sourceGroup.contacts[blink_contact]

                if len(sourceContact.uris) > 1:
                    point = table.window().convertScreenToBase_(NSEvent.mouseLocation())
                    event = NSEvent.mouseEventWithType_location_modifierFlags_timestamp_windowNumber_context_eventNumber_clickCount_pressure_(
                                                                                                                                              NSLeftMouseUp, point, 0, NSDate.timeIntervalSinceReferenceDate(), table.window().windowNumber(),
                                                                                                                                              table.window().graphicsContext(), 0, 1, 0)
                    invite_menu = NSMenu.alloc().init()
                    titem = invite_menu.addItemWithTitle_action_keyEquivalent_(NSLocalizedString("Invite To Conference", "Menu item"), "", "")
                    titem.setEnabled_(False)
                    for uri in sourceContact.uris:
                        titem = invite_menu.addItemWithTitle_action_keyEquivalent_('%s (%s)' % (uri.uri, uri.type), "addContactUriToInvitationList:", "")
                        titem.setIndentationLevel_(1)
                        titem.setTarget_(self)
                        titem.setRepresentedObject_(uri.uri)

                    NSMenu.popUpContextMenu_withEvent_forView_(invite_menu, event, table)
                    return True
                else:
                    participant = info.draggingPasteboard().stringForType_("x-blink-sip-uri")
                    self.addContactUriToInvitationList(participant)
                    return True
        return False
    def rightMouseDown_(self, event):
        point = self.window().convertScreenToBase_(NSEvent.mouseLocation())
        event = NSEvent.mouseEventWithType_location_modifierFlags_timestamp_windowNumber_context_eventNumber_clickCount_pressure_(
                  NSRightMouseUp, point, 0, NSDate.timeIntervalSinceReferenceDate(), self.window().windowNumber(),
                  self.window().graphicsContext(), 0, 1, 0)

        videoDevicesMenu = NSMenu.alloc().init()
        lastItem = videoDevicesMenu.addItemWithTitle_action_keyEquivalent_(NSLocalizedString("Select Video Camera", "Menu item"), "", "")
        lastItem.setEnabled_(False)
        videoDevicesMenu.addItem_(NSMenuItem.separatorItem())

        i = 0
        for item in Engine().video_devices:
            if item not in (None, 'system_default'):
                i += 1

            lastItem = videoDevicesMenu.addItemWithTitle_action_keyEquivalent_(item, "changeVideoDevice:", "")
            lastItem.setRepresentedObject_(item)
            if SIPApplication.video_device.real_name == item:
                lastItem.setState_(NSOnState)

        if i > 1:
              videoDevicesMenu.addItem_(NSMenuItem.separatorItem())
              settings = SIPSimpleSettings()
              lastItem = videoDevicesMenu.addItemWithTitle_action_keyEquivalent_(NSLocalizedString("Auto Rotate Cameras", "Menu item"), "toggleAutoRotate:", "")
              lastItem.setState_(NSOnState if settings.video.auto_rotate_cameras else NSOffState)

        NSMenu.popUpContextMenu_withEvent_forView_(videoDevicesMenu, event, self.window().contentView())
    def tableView_acceptDrop_row_dropOperation_(self, table, info, row, oper):
        pboard = info.draggingPasteboard()
        if pboard.availableTypeFromArray_(["x-blink-sip-uri"]):
            group, blink_contact = eval(pboard.stringForType_("dragged-contact"))
            if blink_contact is not None:
                sourceGroup = NSApp.delegate().contactsWindowController.model.groupsList[group]
                sourceContact = sourceGroup.contacts[blink_contact]

                if len(sourceContact.uris) > 1:
                    point = table.window().convertScreenToBase_(NSEvent.mouseLocation())
                    event = NSEvent.mouseEventWithType_location_modifierFlags_timestamp_windowNumber_context_eventNumber_clickCount_pressure_(
                                                                                                                                              NSLeftMouseUp, point, 0, NSDate.timeIntervalSinceReferenceDate(), table.window().windowNumber(),
                                                                                                                                              table.window().graphicsContext(), 0, 1, 0)
                    invite_menu = NSMenu.alloc().init()
                    titem = invite_menu.addItemWithTitle_action_keyEquivalent_(u'Invite To Conference', "", "")
                    titem.setEnabled_(False)
                    for uri in sourceContact.uris:
                        titem = invite_menu.addItemWithTitle_action_keyEquivalent_('%s (%s)' % (uri.uri, uri.type), "addContactUriToInvitationList:", "")
                        titem.setIndentationLevel_(1)
                        titem.setTarget_(self)
                        titem.setRepresentedObject_(uri.uri)

                    NSMenu.popUpContextMenu_withEvent_forView_(invite_menu, event, table)
                    return True
                else:
                    participant = info.draggingPasteboard().stringForType_("x-blink-sip-uri")
                    self.addContactUriToInvitationList(participant)
                    return True
        return False
    def performDragOperation_(self, info):
        if self.delegate is None:
            return

        source = info.draggingSource()
        pboard = info.draggingPasteboard()

        if pboard.types().containsObject_(NSFilenamesPboardType):
            filenames = [unicodedata.normalize('NFC', file) for file in pboard.propertyListForType_(NSFilenamesPboardType) if os.path.isfile(file)]
            if filenames:
                self.sessionControllersManager.send_files_to_contact(self.delegate.sessionController.account, self.delegate.sessionController.target_uri, filenames)
            return

        def unhighlight(view):
            view.highlighted = False
            view.setNeedsDisplay_(True)
        unhighlight(self)
        self.foreachConferenceSession(unhighlight)

        if hasattr(self.delegate, 'sessionBoxDidAddConferencePeer'):
            if pboard.availableTypeFromArray_(["x-blink-audio-session"]):
                info.draggingSource().draggedOut = False
                info.draggingSource().setNeedsDisplay_(True)
                return self.delegate.sessionBoxDidAddConferencePeer(self, source.delegate)

            elif pboard.availableTypeFromArray_(["dragged-contact"]):
                group, blink_contact = eval(pboard.stringForType_("dragged-contact"))
                if blink_contact is not None:
                    sourceGroup = NSApp.delegate().contactsWindowController.model.groupsList[group]
                    sourceContact = sourceGroup.contacts[blink_contact]

                    if len(sourceContact.uris) > 1:
                        point = self.window().convertScreenToBase_(NSEvent.mouseLocation())
                        event = NSEvent.mouseEventWithType_location_modifierFlags_timestamp_windowNumber_context_eventNumber_clickCount_pressure_(
                                                                                                                                                  NSLeftMouseUp, point, 0, NSDate.timeIntervalSinceReferenceDate(), self.window().windowNumber(),
                                                                                                                                                  self.window().graphicsContext(), 0, 1, 0)
                        invite_menu = NSMenu.alloc().init()
                        titem = invite_menu.addItemWithTitle_action_keyEquivalent_(u'Invite To Conference', "", "")
                        titem.setEnabled_(False)
                        for uri in sourceContact.uris:
                            titem = invite_menu.addItemWithTitle_action_keyEquivalent_('%s (%s)' % (uri.uri, uri.type), "userClickedInviteToConference:", "")
                            titem.setIndentationLevel_(1)
                            titem.setTarget_(self)
                            titem.setRepresentedObject_(str(uri.uri))

                        NSMenu.popUpContextMenu_withEvent_forView_(invite_menu, event, self)
                    elif pboard.availableTypeFromArray_(["x-blink-sip-uri"]):
                        uri = str(pboard.stringForType_("x-blink-sip-uri"))
                        return self.delegate.sessionBoxDidAddConferencePeer(self, uri)

            elif pboard.availableTypeFromArray_(["x-blink-sip-uri"]):
                uri = str(pboard.stringForType_("x-blink-sip-uri"))
                return self.delegate.sessionBoxDidAddConferencePeer(self, uri)
    def draggedItem_event_(self, sender, event):
        p = sender.convertPoint_fromView_(event.locationInWindow(), None)
        dx = self.dragPos.x - p.x
        dy = self.dragPos.y - p.y

        frame = sender.frame()

        if abs(dy) > 25 or self.dragWindow:
            if not self.dragWindow:
                self.dragWindow = self.createDragWindowForTab_(sender)
                self.dragWindow.makeKeyAndOrderFront_(None)
                self.draggedOut = True
                sender.setDraggedOut_(True)
            pos = NSEvent.mouseLocation()
            pos.x -= self.dragPos.x
            pos.y -= self.dragPos.y
            self.dragWindow.setFrameOrigin_(pos)



            if abs(dy) < 25 and p.x > NSMinX(frame) and p.x < NSMaxX(frame):
                self.dragWindow.close()
                self.dragWindow = None
                self.draggedOut = False
                sender.setDraggedOut_(False)
            else:
                return

        frame.origin.x -= dx
        sender.setFrame_(frame)

        self.reorderByPosition_(sender)
    def draggedItem_event_(self, sender, event):
        p = sender.convertPoint_fromView_(event.locationInWindow(), None)
        dx = self.dragPos.x - p.x
        dy = self.dragPos.y - p.y

        frame = sender.frame()

        if abs(dy) > 25 or self.dragWindow:
            if not self.dragWindow:
                self.dragWindow = self.createDragWindowForTab_(sender)
                self.dragWindow.makeKeyAndOrderFront_(None)
                self.draggedOut = True
                sender.setDraggedOut_(True)
            pos = NSEvent.mouseLocation()
            pos.x -= self.dragPos.x
            pos.y -= self.dragPos.y
            self.dragWindow.setFrameOrigin_(pos)

            if abs(dy) < 25 and p.x > NSMinX(frame) and p.x < NSMaxX(frame):
                self.dragWindow.close()
                self.dragWindow = None
                self.draggedOut = False
                sender.setDraggedOut_(False)
            else:
                return

        frame.origin.x -= dx
        sender.setFrame_(frame)

        self.reorderByPosition_(sender)
 def finishedDraging_event_(self, sender, event):
     sender.setHidden_(False)
     self.rearrange()
     if self.dragWindow:
         self.dragWindow.close()
         self.dragWindow = None
         sender.setDraggedOut_(False)
     if self.draggedOut:
         self.delegate.tabView_didDettachTabViewItem_atPosition_(
             self.tabView, sender.item, NSEvent.mouseLocation())
         self.draggedOut = False
    def rightMouseDown_(self, event):
        point = self.parentWindow.convertScreenToBase_(NSEvent.mouseLocation())
        event = NSEvent.mouseEventWithType_location_modifierFlags_timestamp_windowNumber_context_eventNumber_clickCount_pressure_(
                                                                                                    NSRightMouseUp, point, 0, NSDate.timeIntervalSinceReferenceDate(), self.parentWindow.windowNumber(),
                                                                            self.parentWindow.graphicsContext(), 0, 1, 0)

        videoDevicesMenu = NSMenu.alloc().init()
        lastItem = videoDevicesMenu.addItemWithTitle_action_keyEquivalent_(NSLocalizedString("Select Video Device", "Menu item"), "", "")
        lastItem.setEnabled_(False)
        videoDevicesMenu.addItem_(NSMenuItem.separatorItem())

        for item in Engine().video_devices:
            if str(item) == "Colorbar generator":
                continue
            lastItem = videoDevicesMenu.addItemWithTitle_action_keyEquivalent_(item, "changeVideoDevice:", "")
            lastItem.setRepresentedObject_(item)
            if SIPApplication.video_device.real_name == item:
                lastItem.setState_(NSOnState)

        NSMenu.popUpContextMenu_withEvent_forView_(videoDevicesMenu, event, self)
#MenuTitle: Realign BCPs
# -*- coding: utf-8 -*-
from __future__ import division, print_function, unicode_literals
__doc__ = """
Realigns handles (BCPs) in current layers of selected glyphs. Useful for resetting out-of-sync handles, e.g., after a transform operation, after interpolation or after switching to a different grid. Hold down Option to process ALL layers of the glyph.
"""

from Foundation import NSPoint, NSEvent, NSNumber, NSMutableArray

optionKeyFlag = 524288
optionKeyPressed = NSEvent.modifierFlags() & optionKeyFlag == optionKeyFlag

thisFont = Glyphs.font
moveForward = NSPoint(1, 1)
moveBackward = NSPoint(-1, -1)
noModifier = NSNumber.numberWithUnsignedInteger_(0)
Tool = GlyphsPathPlugin.alloc().init()


def realignLayer(thisLayer):
    countOfHandlesOnLayer = 0
    for thisPath in thisLayer.paths:
        for thisNode in thisPath.nodes:
            if thisNode.type == GSOFFCURVE:
                countOfHandlesOnLayer += 1
                selectedNode = NSMutableArray.arrayWithObject_(thisNode)
                thisLayer.setSelection_(selectedNode)
                Tool.moveSelectionLayer_shadowLayer_withPoint_withModifier_(
                    thisLayer, thisLayer, moveForward, noModifier)
                Tool.moveSelectionLayer_shadowLayer_withPoint_withModifier_(
                    thisLayer, thisLayer, moveBackward, noModifier)
 def finishedDraging_event_(self, sender, event):
     sender.setHidden_(False)
     self.rearrange()
     if self.dragWindow:
         self.dragWindow.close()
         self.dragWindow = None
         sender.setDraggedOut_(False)
     if self.draggedOut:
         self.delegate.tabView_didDettachTabViewItem_atPosition_(self.tabView, sender.item, NSEvent.mouseLocation())
         self.draggedOut = False
Exemple #11
0
#MenuTitle: Remove Nodes and Try to Keep Shape
# -*- coding: utf-8 -*-
from __future__ import division, print_function, unicode_literals
__doc__="""
Delete the selected on-curve nodes, but try to keep the shape of the path. Hold down Shift for balanced handles.
"""

from Foundation import NSEvent

thisFont = Glyphs.font # frontmost font
thisLayer = thisFont.selectedLayers[0] # first of active layers of selected glyphs
thisGlyph = thisLayer.parent # current glyph
selection = thisLayer.selection # node selection in edit mode

# check if Shift is held down:
shiftKeyFlag = 131072
shiftKeyPressed = NSEvent.modifierFlags() & shiftKeyFlag == shiftKeyFlag

if selection:
	selectedNodes = [obj for obj in selection if type(obj)==GSNode and obj.type==GSCURVE]
	if selectedNodes:
		thisGlyph.beginUndo() # begin undo grouping
		thisLayer.selection = None
		for thisNode in selectedNodes:
			thisPath = thisNode.parent
			if not shiftKeyPressed:
				thisPath.removeNodeCheckKeepShape_( thisNode )
			else:
				thisPath.removeNodeCheckKeepShape_normalizeHandles_( thisNode, True )
		thisGlyph.endUndo()   # end undo grouping
    def performDragOperation_(self, info):
        if self.delegate is None:
            return

        source = info.draggingSource()
        pboard = info.draggingPasteboard()

        if pboard.types().containsObject_(NSFilenamesPboardType):
            filenames = [
                unicodedata.normalize('NFC', file)
                for file in pboard.propertyListForType_(NSFilenamesPboardType)
                if os.path.isfile(file) or os.path.isdir(file)
            ]
            if filenames:
                self.sessionControllersManager.send_files_to_contact(
                    self.delegate.sessionController.account,
                    self.delegate.sessionController.target_uri, filenames)
            return

        def unhighlight(view):
            view.highlighted = False
            view.setNeedsDisplay_(True)

        unhighlight(self)
        self.foreachConferenceSession(unhighlight)

        if hasattr(self.delegate, 'sessionBoxDidAddConferencePeer'):
            if pboard.availableTypeFromArray_(["x-blink-audio-session"]):
                info.draggingSource().draggedOut = False
                info.draggingSource().setNeedsDisplay_(True)
                return self.delegate.sessionBoxDidAddConferencePeer(
                    self, source.delegate)

            elif pboard.availableTypeFromArray_(["dragged-contact"]):
                group, blink_contact = eval(
                    pboard.stringForType_("dragged-contact"))
                if blink_contact is not None:
                    sourceGroup = NSApp.delegate(
                    ).contactsWindowController.model.groupsList[group]
                    sourceContact = sourceGroup.contacts[blink_contact]

                    if len(sourceContact.uris) > 1:
                        point = self.window().convertScreenToBase_(
                            NSEvent.mouseLocation())
                        event = NSEvent.mouseEventWithType_location_modifierFlags_timestamp_windowNumber_context_eventNumber_clickCount_pressure_(
                            NSLeftMouseUp, point, 0,
                            NSDate.timeIntervalSinceReferenceDate(),
                            self.window().windowNumber(),
                            self.window().graphicsContext(), 0, 1, 0)
                        invite_menu = NSMenu.alloc().init()
                        titem = invite_menu.addItemWithTitle_action_keyEquivalent_(
                            NSLocalizedString("Invite To Conference",
                                              "Menu item"), "", "")
                        titem.setEnabled_(False)
                        for uri in sourceContact.uris:
                            titem = invite_menu.addItemWithTitle_action_keyEquivalent_(
                                '%s (%s)' % (uri.uri, uri.type),
                                "userClickedInviteToConference:", "")
                            titem.setIndentationLevel_(1)
                            titem.setTarget_(self)
                            titem.setRepresentedObject_(str(uri.uri))

                        NSMenu.popUpContextMenu_withEvent_forView_(
                            invite_menu, event, self)
                    elif pboard.availableTypeFromArray_(["x-blink-sip-uri"]):
                        uri = str(pboard.stringForType_("x-blink-sip-uri"))
                        return self.delegate.sessionBoxDidAddConferencePeer(
                            self, uri)

            elif pboard.availableTypeFromArray_(["x-blink-sip-uri"]):
                uri = str(pboard.stringForType_("x-blink-sip-uri"))
                return self.delegate.sessionBoxDidAddConferencePeer(self, uri)
 def userClickedActionsButton_(self, sender):
     point = sender.window().convertScreenToBase_(NSEvent.mouseLocation())
     event = NSEvent.mouseEventWithType_location_modifierFlags_timestamp_windowNumber_context_eventNumber_clickCount_pressure_(
                 NSLeftMouseUp, point, 0, NSDate.timeIntervalSinceReferenceDate(), sender.window().windowNumber(),
                 sender.window().graphicsContext(), 0, 1, 0)
     NSMenu.popUpContextMenu_withEvent_forView_(self.contactMenu, event, sender)
Exemple #14
0
    def update(self, sender):
        # check if Option key is pressed or not:
        optionKeyFlag = 524288
        optionKeyPressed = NSEvent.modifierFlags(
        ) & optionKeyFlag == optionKeyFlag

        # some predetermined guesses:
        betterGuesses = {
            "perthousand": "percent",
            "brokenbar": "bar",
            "daggerdbl": "dagger",
            "dollar": "S",
            "cent": "c",
            "Fhook": "florin",
            "endash": "hyphen",
            "emdash": "endash",
            "Eng": "N",
            "eng": "n",
            "thorn": "p",
            "Thorn": "I",
            "ae": "e",
            "oe": "e",
            "AE": "E",
            "OE": "E",
            "germandbls": "f",
            "Germandbls": "F",
        }

        thisFont = Glyphs.font
        if thisFont:
            if thisFont.selectedLayers:
                currentLayer = thisFont.selectedLayers[0]
                currentGlyph = currentLayer.parent

                # do predetermined guesses apply:
                if currentGlyph.name in betterGuesses:
                    glyphName = betterGuesses[currentGlyph.name]
                    self.w.componentName.set(glyphName)
                    self.SavePreferences(sender)
                    return True

                # check for the dot suffix:
                suffix = ""
                if "." in currentGlyph.name:
                    offset = currentGlyph.name.find(".")
                    suffix = currentGlyph.name[offset:]

                # if glyph info has components, take the base letter name:
                thisInfo = currentGlyph.glyphInfo
                if thisInfo and thisInfo.components:
                    firstComponentName = thisInfo.components[0].name
                    if firstComponentName:
                        if not optionKeyPressed:  # hold down OPT to ignore suffix
                            firstComponentName += suffix
                        self.w.componentName.set(firstComponentName)
                        self.SavePreferences(sender)
                        return True

                # no first component found, so try same name without suffix:
                if suffix:
                    self.w.componentName.set(currentGlyph.name[:offset])
                    self.SavePreferences(sender)
                    return True

        return False
 def userClickedActionsButton_(self, sender):
     point = sender.window().convertScreenToBase_(NSEvent.mouseLocation())
     event = NSEvent.mouseEventWithType_location_modifierFlags_timestamp_windowNumber_context_eventNumber_clickCount_pressure_(
                 NSLeftMouseUp, point, 0, NSDate.timeIntervalSinceReferenceDate(), sender.window().windowNumber(),
                 sender.window().graphicsContext(), 0, 1, 0)
     NSMenu.popUpContextMenu_withEvent_forView_(self.contactMenu, event, sender)