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)
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)
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
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
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)
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
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
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
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
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)
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
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
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
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
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
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
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
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
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
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
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
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
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
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