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_(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 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
예제 #4
0
    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)
예제 #5
0
    def applicationDidFinishLaunching_(self, aNotification):
        """
        Create a toolbar and menu for the mac application that can be used
        to close shut down the application.
        """
        self.statusItem = NSStatusBar\
            .systemStatusBar()\
            .statusItemWithLength_(NSVariableStatusItemLength)

        self.statusItem.setTitle_(u"M")
        self.statusItem.setHighlightMode_(TRUE)
        self.statusItem.setEnabled_(TRUE)

        self.quit = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
            "Quit", "terminate:", "")

        # ugly but... it provides the information.
        self.port = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
            "Listening on localhost:{0}".format(_PORT), "", "")

        self.menubarMenu = NSMenu.alloc().init()
        self.menubarMenu.addItem_(self.port)
        self.menubarMenu.addItem_(self.quit)

        # add the menu to status bar item
        self.statusItem.setMenu_(self.menubarMenu)
        self.statusItem.setToolTip_(u"mimic - rackspace mock api")

        AppHelper.callLater(1, startMimic)
예제 #6
0
파일: start-app.py 프로젝트: derwolfe/mimic
    def applicationDidFinishLaunching_(self, aNotification):
        """
        Create a toolbar and menu for the mac application that can be used
        to close shut down the application.
        """
        self.statusItem = NSStatusBar\
            .systemStatusBar()\
            .statusItemWithLength_(NSVariableStatusItemLength)

        self.statusItem.setTitle_(u"M")
        self.statusItem.setHighlightMode_(TRUE)
        self.statusItem.setEnabled_(TRUE)

        self.quit = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
            "Quit", "terminate:", "")

        # ugly but... it provides the information.
        self.port = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(
            "Listening on localhost:{0}".format(_PORT), "", "")

        self.menubarMenu = NSMenu.alloc().init()
        self.menubarMenu.addItem_(self.port)
        self.menubarMenu.addItem_(self.quit)

        # add the menu to status bar item
        self.statusItem.setMenu_(self.menubarMenu)
        self.statusItem.setToolTip_(u"mimic - rackspace mock api")

        AppHelper.callLater(1, startMimic)
    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)
 def show(self, item):
     if not self.items:
         self.statusItem = NSStatusBar.systemStatusBar().statusItemWithLength_(30)
         self.menu = NSMenu.alloc().init()
         image = NSImage.imageNamed_("display").copy()
         image.setSize_(NSMakeSize(24, 24))
         self.statusItem.setImage_(image)
         self.statusItem.setMenu_(self.menu)
     self.items.append(item)
     mitem = self.menu.addItemWithTitle_action_keyEquivalent_("%s - Waiting" % item.sessionController.getTitle(),  "activateItem:", "")
     mitem.setTag_(item.sessionController.identifier)
     mitem.setTarget_(self)
예제 #9
0
 def show(self, item):
     if not self.items:
         #self.statusItem = NSStatusBar.systemStatusBar().statusItemWithLength_(30)
         self.statusItem = Null
         self.menu = NSMenu.alloc().init()
         image = NSImage.imageNamed_("display").copy()
         image.setSize_(NSMakeSize(24, 24))
         self.statusItem.setImage_(image)
         self.statusItem.setMenu_(self.menu)
     self.items.append(item)
     mitem = self.menu.addItemWithTitle_action_keyEquivalent_(
         NSLocalizedString("%s - Waiting", "Menu item") %
         item.sessionController.titleLong, "activateItem:", "")
     mitem.setTag_(item.sessionController.identifier)
     mitem.setTarget_(self)
예제 #10
0
    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)
예제 #11
0
 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)
예제 #12
0
 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)