コード例 #1
0
    def runModal(self):
        BlinkLogger().log_info('Starting Enrollment')
        self.newDisplayNameText.setStringValue_(NSFullUserName() or "")
        self.displayNameText.setStringValue_(NSFullUserName() or "")

        self.window.center()
        NSApp.runModalForWindow_(self.window)
        self.window.orderOut_(self)
コード例 #2
0
    def runModal(self):
        BlinkLogger().log_info('Starting Enrollment')
        self.newDisplayNameText.setStringValue_(NSFullUserName() or "")
        self.displayNameText.setStringValue_(NSFullUserName() or "")

        self.window.center()
        NSApp.runModalForWindow_(self.window)
        self.window.orderOut_(self)
コード例 #3
0
    def cropAndAddImage(self, path):
        try:
            image = NSImage.alloc().initWithContentsOfFile_(path)
        except:
            NSRunAlertPanel(
                NSLocalizedString("Camera Capture Error", "Window title"),
                NSLocalizedString("%s is not a valid image", "Label") % path,
                NSLocalizedString("OK", "Button title"), None, None)
            return

        rect = NSZeroRect.copy()
        rect.size = image.size()
        curSize = self.cropWindow.frame().size
        if rect.size.width > curSize.width or rect.size.height > curSize.height:
            self.cropWindowImage.setFrame_(rect)
        self.cropOriginalImage = image.copy()
        self.cropWindowImage.setImage_(image)

        if NSApp.runModalForWindow_(self.cropWindow) == NSOKButton:
            dt = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
            image = self.cropWindowImage.getCropped()

            path = self.storage_folder + "/photo%s.png" % dt
            jpg_data = NSBitmapImageRep.alloc().initWithData_(
                image.
                TIFFRepresentation()).representationUsingType_properties_(
                    NSJPEGFileType, {NSImageCompressionFactor: 0.9})
            data = jpg_data.bytes().tobytes()
            with open(path, 'wb') as f:
                f.write(data)

            self.cropWindow.orderOut_(None)
            self.refreshLibrary()
        else:
            self.cropWindow.orderOut_(None)
コード例 #4
0
 def runModal(self):
     self.window.makeKeyAndOrderFront_(None)
     rc = NSApp.runModalForWindow_(self.window)
     self.window.orderOut_(self)
     if rc == NSOKButton:
         return unicode(self.inputText.string().rstrip("\n"))
     return None
コード例 #5
0
    def run(self):
        contactsWindow = NSApp.delegate().contactsWindowController.window()
        worksWhenModal = contactsWindow.worksWhenModal()
        contactsWindow.setWorksWhenModal_(True)
        if not self.autostart:
            self.window.makeKeyAndOrderFront_(None)
            rc = NSApp.runModalForWindow_(self.window)
        self.window.orderOut_(self)
        contactsWindow.setWorksWhenModal_(worksWhenModal)

        if (self.autostart and self.validateConference()) or rc == NSOKButton:
            if self.audio.state() == NSOnState and self.chat.state() == NSOnState:
                media_type = ("chat", "audio")
            elif self.chat.state() == NSOnState:
                media_type = "chat"
            else:
                media_type = "audio"

            # make a copy of the participants and reset the table data source,
            participants = self._participants

            # Cocoa crashes if something is selected in the table view when clicking OK or Cancel button
            # reseting the data source works around this
            self._participants = []
            self.participantsTable.reloadData()
            # prevent loops
            if self.target in participants:
                participants.remove(self.target)
            return ServerConferenceRoom(self.target, media_type=media_type, participants=participants, nickname=self.nickname, start_when_participants_available=bool(self.startWhenParticipantsAvailable.state()))
        else:
            return None
コード例 #6
0
    def cropAndAddImage(self, path):
        try:
            image = NSImage.alloc().initWithContentsOfFile_(path)
        except:
            NSRunAlertPanel(NSLocalizedString("Camera Capture Error", "Window title"), NSLocalizedString("%s is not a valid image", "Label") % path, NSLocalizedString("OK", "Button title"), None, None)
            return

        rect = NSZeroRect.copy()
        rect.size = image.size()
        curSize = self.cropWindow.frame().size
        if rect.size.width > curSize.width or rect.size.height > curSize.height:
            self.cropWindowImage.setFrame_(rect)
        self.cropOriginalImage = image.copy()
        self.cropWindowImage.setImage_(image)

        if NSApp.runModalForWindow_(self.cropWindow) == NSOKButton:
            dt = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
            image = self.cropWindowImage.getCropped()

            tiff_data = image.TIFFRepresentation()

            #path = self.storage_folder + "/photo%s.tiff" % dt
            #tiff_data.writeToFile_atomically_(path, False)

            path = self.storage_folder + "/photo%s.png" % dt
            bitmap_data = NSBitmapImageRep.alloc().initWithData_(tiff_data)
            png_data = bitmap_data.representationUsingType_properties_(NSPNGFileType, None)
            data = png_data.bytes().tobytes()
            with open(path, 'w') as f:
                f.write(data)

            self.cropWindow.orderOut_(None)
            self.refreshLibrary()
        else:
            self.cropWindow.orderOut_(None)
コード例 #7
0
 def runModal(self):
     self.window.makeKeyAndOrderFront_(None)
     rc = NSApp.runModalForWindow_(self.window)
     self.window.orderOut_(self)
     if rc == NSOKButton:
         return str(self.nameText.stringValue())
     return None
コード例 #8
0
    def run(self):
        contactsWindow = NSApp.delegate().contactsWindowController.window()
        worksWhenModal = contactsWindow.worksWhenModal()
        contactsWindow.setWorksWhenModal_(True)
        if not self.autostart:
            self.window.makeKeyAndOrderFront_(None)
            rc = NSApp.runModalForWindow_(self.window)
        self.window.orderOut_(self)
        contactsWindow.setWorksWhenModal_(worksWhenModal)

        if (self.autostart and self.validateConference()) or rc == NSOKButton:
            if self.audio.state() == NSOnState and self.chat.state() == NSOnState:
                media_type = ("chat", "audio")
            elif self.chat.state() == NSOnState:
                media_type = "chat"
            else:
                media_type = "audio"

            # make a copy of the participants and reset the table data source,
            participants = self._participants

            # Cocoa crashes if something is selected in the table view when clicking OK or Cancel button
            # reseting the data source works around this
            self._participants = []
            self.participantsTable.reloadData()
            # prevent loops
            if self.target in participants:
                participants.remove(self.target)
            return ServerConferenceRoom(self.target, media_type=media_type, participants=participants, nickname=self.nickname, start_when_participants_available=bool(self.startWhenParticipantsAvailable.state()))
        else:
            return None
コード例 #9
0
 def runModal(self):
     self.window.makeKeyAndOrderFront_(None)
     rc = NSApp.runModalForWindow_(self.window)
     self.window.orderOut_(self)
     if rc == NSOKButton:
         return unicode(self.nameText.stringValue())
     return None
コード例 #10
0
 def runModal(self):
     self.window.makeKeyAndOrderFront_(None)
     rc = NSApp.runModalForWindow_(self.window)
     self.window.orderOut_(self)
     if rc == NSOKButton:
         return str(self.inputText.string().rstrip("\n"))
     return None
コード例 #11
0
    def runModal(self):
        rc = NSApp.runModalForWindow_(self.window)
        self.window.orderOut_(self)
        if rc == NSOKButton:
            NotificationCenter().remove_observer(self, name="BlinkGroupsHaveChanged")

            # TODO: how to handle xmmp: uris?
            #for uri in self.uris:
            #    if uri.type is not None and uri.type.lower() == 'xmpp' and ';xmpp' not in uri.uri:
            #        uri.uri = uri.uri + ';xmpp'
            i = 0
            for uri in self.uris:
                uri.position = i
                i += 1

            contact = {
                    'default_uri'     : self.default_uri,
                    'uris'            : self.uris,
                    'name'            : str(self.nameText.stringValue()),
                    'organization'    : str(self.organizationText.stringValue()),
                    'groups'          : self.belonging_groups,
                    'auto_answer'     : True if self.autoanswerCheckbox.state() == NSOnState else False,
                    'icon'            : None if self.photoImage.image() is self.defaultPhotoImage else self.photoImage.image(),
                    'preferred_media' : self.preferred_media,
                    'subscriptions'   : self.subscriptions
                    }
            return contact
        return False
コード例 #12
0
ファイル: PhotoPicker.py プロジェクト: uditha-atukorala/blink
    def cropAndAddImage(self, path):
        try:
            image = NSImage.alloc().initWithContentsOfFile_(path)
        except:
            NSRunAlertPanel(NSLocalizedString("Camera Capture Error", "Window title"), NSLocalizedString("%s is not a valid image" % path, "Alert panel label"), NSLocalizedString("OK", "Button title"), None, None)
            return

        rect = NSZeroRect.copy()
        rect.size = image.size()
        curSize = self.cropWindow.frame().size
        if rect.size.width > curSize.width or rect.size.height > curSize.height:
            self.cropWindowImage.setFrame_(rect)
        self.cropOriginalImage = image.copy()
        self.cropWindowImage.setImage_(image)

        if NSApp.runModalForWindow_(self.cropWindow) == NSOKButton:
            path = ApplicationData.get('photos')
            dt = datetime.datetime.now().strftime("%Y%m%d%H%M%S")

            image = self.cropWindowImage.getCropped()
            path = path+"/photo%s.tiff"%dt
            image.TIFFRepresentation().writeToFile_atomically_(path, False)

            self.cropWindow.orderOut_(None)

            self.refreshLibrary()
        else:
            self.cropWindow.orderOut_(None)
コード例 #13
0
 def runModal_(self, text):
     self.textLabel.setStringValue_(text)
     self.window.makeKeyAndOrderFront_(None)
     rc = NSApp.runModalForWindow_(self.window)
     self.window.orderOut_(self)
     if rc == NSOKButton:
         return True
     return False
コード例 #14
0
 def runModal(self, subject=''):
     self.window.makeKeyAndOrderFront_(None)
     if subject is not None:
         self.nameText.setStringValue_(subject)
     rc = NSApp.runModalForWindow_(self.window)
     self.window.orderOut_(self)
     if rc == NSOKButton:
         return unicode(self.nameText.stringValue())
     return None
コード例 #15
0
 def runModalForRename_(self, name):
     self.nameText.setStringValue_(name)
     self.window.setTitle_(u"Rename Conference Configuration")
     self.window.makeKeyAndOrderFront_(None)
     rc = NSApp.runModalForWindow_(self.window)
     self.window.orderOut_(self)
     if rc == NSOKButton:
         return unicode(self.nameText.stringValue())
     return None
コード例 #16
0
 def runModal(self):
     self.window.makeKeyAndOrderFront_(None)
     rc = NSApp.runModalForWindow_(self.window)
     self.window.orderOut_(self)
     if rc == NSOKButton:
         return {'name': unicode(self.name.stringValue()),
                 'address': unicode(self.address.stringValue())
                 }
     return None
コード例 #17
0
 def runModal(self, nickname=''):
     self.window.makeKeyAndOrderFront_(None)
     if nickname is not None:
         self.nameText.setStringValue_(nickname)
     rc = NSApp.runModalForWindow_(self.window)
     self.window.orderOut_(self)
     if rc == NSOKButton:
         return str(self.nameText.stringValue())
     return None
コード例 #18
0
 def runModalForRename_(self, name):
     self.nameText.setStringValue_(name)
     self.window.setTitle_(NSLocalizedString("Rename Group", "Window title"))
     self.caption.setStringValue_(NSLocalizedString("Enter a new name for the group:", "Alert panel label"))
     self.window.makeKeyAndOrderFront_(None)
     rc = NSApp.runModalForWindow_(self.window)
     self.window.orderOut_(self)
     if rc == NSOKButton:
         return unicode(self.nameText.stringValue())
     return None
コード例 #19
0
 def runModal(self):
     self.window.makeKeyAndOrderFront_(None)
     rc = NSApp.runModalForWindow_(self.window)
     self.window.orderOut_(self)
     if rc == NSOKButton:
         return {
             'name': str(self.name.stringValue()),
             'address': str(self.address.stringValue())
         }
     return None
コード例 #20
0
 def runModalForRename_(self, name):
     self.nameText.setStringValue_(name)
     self.window.setTitle_(
         NSLocalizedString("Rename Conference Configuration",
                           "Window title"))
     self.window.makeKeyAndOrderFront_(None)
     rc = NSApp.runModalForWindow_(self.window)
     self.window.orderOut_(self)
     if rc == NSOKButton:
         return str(self.nameText.stringValue())
     return None
コード例 #21
0
 def runModal(self):
     self.window.makeKeyAndOrderFront_(None)
     rc = NSApp.runModalForWindow_(self.window)
     self.window.orderOut_(self)
     if rc == NSOKButton:
         note = str(self.nameText.stringValue())
         settings = SIPSimpleSettings()
         settings.presence_state.offline_note = note
         settings.save()
         return note
     return None
コード例 #22
0
 def runModal(self):
     self.window.makeKeyAndOrderFront_(None)
     rc = NSApp.runModalForWindow_(self.window)
     self.window.orderOut_(self)
     if rc == NSOKButton:
         note = unicode(self.nameText.stringValue())
         settings = SIPSimpleSettings()
         settings.presence_state.offline_note = note
         settings.save()
         return note
     return None
コード例 #23
0
 def runModalForRename_(self, name):
     self.nameText.setStringValue_(name)
     self.window.setTitle_(NSLocalizedString("Rename Group",
                                             "Window title"))
     self.caption.setStringValue_(
         NSLocalizedString("Enter a new name for the group:", "Label"))
     self.window.makeKeyAndOrderFront_(None)
     rc = NSApp.runModalForWindow_(self.window)
     self.window.orderOut_(self)
     if rc == NSOKButton:
         return str(self.nameText.stringValue())
     return None
コード例 #24
0
 def runModal(self):
     self.window.makeKeyAndOrderFront_(None)
     self.refreshLibrary()
     result = NSApp.runModalForWindow_(self.window)
     if result:
         if self.tabView.selectedTabViewItem().identifier() == "recent":
             selected = self.contentArrayController.selectedObjects()
             if selected.count() > 0:
                 path = selected.lastObject().objectForKey_("path")
                 image = selected.lastObject().objectForKey_("picture")
                 return path, image
         else:
             return self.storeCaptured()
     return None, None
コード例 #25
0
 def runModal(self):
     self.window.makeKeyAndOrderFront_(None)
     self.refreshLibrary()
     result = NSApp.runModalForWindow_(self.window)
     if result:
         if self.tabView.selectedTabViewItem().identifier() == "recent":
             selected = self.contentArrayController.selectedObjects()
             if selected.count() > 0:
                 path = selected.lastObject().objectForKey_("path")
                 image = selected.lastObject().objectForKey_("picture")
                 return path, image
         else:
             return self.storeCaptured()
     return None, None
コード例 #26
0
 def runModal(self):
     rc = NSApp.runModalForWindow_(self.window)
     self.window.orderOut_(self)
     if rc == NSOKButton:
         # TODO: how to handle xmmp: uris?
         #for uri in self.uris:
         #    if uri.type is not None and uri.type.lower() == 'xmpp' and ';xmpp' not in uri.uri:
         #        uri.uri = uri.uri + ';xmpp'
         contact = {'default_uri'     : self.default_uri,
                    'uris'            : self.uris,
                    'name'            : unicode(self.nameText.stringValue()),
                    'groups'          : self.belonging_groups,
                    'icon'            : None if self.photoImage.image() == self.defaultPhotoImage else self.photoImage.image(),
                    'preferred_media' : self.preferred_media,
                    'subscriptions'   : self.subscriptions
                     }
         return contact
     return False
コード例 #27
0
    def run(self):
        self._participants = []
        contactsWindow = NSApp.delegate().contactsWindowController.window()
        worksWhenModal = contactsWindow.worksWhenModal()
        contactsWindow.setWorksWhenModal_(True)
        self.window.makeKeyAndOrderFront_(None)
        rc = NSApp.runModalForWindow_(self.window)
        self.window.orderOut_(self)
        contactsWindow.setWorksWhenModal_(worksWhenModal)

        if rc == NSOKButton:
            # make a copy of the participants and reset the table data source,
            participants = self._participants

            # Cocoa crashes if something is selected in the table view when clicking OK or Cancel button
            # reseting the data source works around this
            self._participants = []
            self.participantsTable.reloadData()
            return participants
        else:
            return None
コード例 #28
0
    def run(self):
        self._participants = []
        contactsWindow = NSApp.delegate().contactsWindowController.window()
        worksWhenModal = contactsWindow.worksWhenModal()
        contactsWindow.setWorksWhenModal_(True)
        self.window.makeKeyAndOrderFront_(None)
        rc = NSApp.runModalForWindow_(self.window)
        self.window.orderOut_(self)
        contactsWindow.setWorksWhenModal_(worksWhenModal)

        if rc == NSOKButton:
            # make a copy of the participants and reset the table data source,
            participants = self._participants

            # Cocoa crashes if something is selected in the table view when clicking OK or Cancel button
            # reseting the data source works around this
            self._participants = []
            self.participantsTable.reloadData()
            return participants
        else:
            return None