def download_decideDestinationWithSuggestedFilename_(self, download, filename):
     panel = NSSavePanel.savePanel()
     panel.setTitle_("Download File")
     if panel.runModalForDirectory_file_("", filename) == NSFileHandlingPanelOKButton:
         download.setDestination_allowOverwrite_(panel.filename(), True)
         BlinkLogger().log_info(u"Downloading file to %s" % panel.filename())
     else:
         download.cancel()
         BlinkLogger().log_info(u"Download cancelled")
 def download_decideDestinationWithSuggestedFilename_(
         self, download, filename):
     panel = NSSavePanel.savePanel()
     panel.setTitle_(NSLocalizedString("Download File", "Window title"))
     if panel.runModalForDirectory_file_(
             "", filename) == NSFileHandlingPanelOKButton:
         download.setDestination_allowOverwrite_(panel.filename(), True)
         BlinkLogger().log_info("Downloading file to %s" % panel.filename())
     else:
         download.cancel()
         BlinkLogger().log_info("Download cancelled")
 def saveLayerAs_(self, sender):
     _doc = self.getCurrentDocument()
     if _doc is None:
         return  # this is odd
     _sp = NSSavePanel.savePanel()
     _sp.setTitle_("Save Layer")
     _sp.setRequiredFileType_("xml.gz")
     _layer = _doc.getImage().getActiveLayer()
     _win = _doc.windowForSheet()
     _name = _layer.getName()
     _sp.beginSheetForDirectory_file_modalForWindow_modalDelegate_didEndSelector_contextInfo_(None, _name, _win, self, "savePanelDidEnd:returnCode:contextInfo:", 0)
Exemple #4
0
def save_dialog(directory, filename):
    panel = NSSavePanel.savePanel()
    panel.setTitle_("Save PDF booklet")
    myUrl = NSURL.fileURLWithPath_isDirectory_(directory, True)
    panel.setDirectoryURL_(myUrl)
    panel.setNameFieldStringValue_(filename)
    NSApp.activateIgnoringOtherApps_(True)
    ret_value = panel.runModal()
    if ret_value:
        return panel.filename()
    else:
        return ''
Exemple #5
0
def darwin_save_dialog(window, title, current_filename):
    from AppKit import NSSavePanel
    directory, filename = os.path.split(current_filename)
    panel = NSSavePanel.savePanel()
    panel.setTitle_(title or _("Save"))
    panel.setDirectoryURL_(u"file:///%s" % directory)
    panel.setNameFieldStringValue_(filename)
    ret_value = panel.runModal()
    if ret_value:
        return panel.filename()
    else:
        return u''
Exemple #6
0
def darwin_save_dialog(window, title, current_filename):
    from AppKit import NSSavePanel
    directory, filename = os.path.split(current_filename)
    panel = NSSavePanel.savePanel()
    panel.setTitle_(title or _("Save"))
    panel.setDirectoryURL_(u"file:///%s" % directory)
    panel.setNameFieldStringValue_(filename)
    ret_value = panel.runModal()
    if ret_value:
        return panel.filename()
    else:
        return u''
Exemple #7
0
def save_dialog(directory, filename):
	panel = NSSavePanel.savePanel()
	panel.setTitle_("Save PDF booklet")
	myUrl = NSURL.fileURLWithPath_isDirectory_(directory, True)
	panel.setDirectoryURL_(myUrl)
	panel.setNameFieldStringValue_(filename)
	NSApp.activateIgnoringOtherApps_(True)
	ret_value = panel.runModal()
	if ret_value:
		return panel.filename()
	else:
		return ''
Exemple #8
0
 def saveLayerAs_(self, sender):
     _doc = self.getCurrentDocument()
     if _doc is None:
         return  # this is odd
     _sp = NSSavePanel.savePanel()
     _sp.setTitle_("Save Layer")
     _sp.setRequiredFileType_("xml.gz")
     _layer = _doc.getImage().getActiveLayer()
     _win = _doc.windowForSheet()
     _name = _layer.getName()
     _sp.beginSheetForDirectory_file_modalForWindow_modalDelegate_didEndSelector_contextInfo_(
         None, _name, _win, self, "savePanelDidEnd:returnCode:contextInfo:",
         0)
 def run(self):
     panel = NSSavePanel.alloc().init()
     if self.messageText:
         panel.setMessage_(self.messageText)
     if self.title:
         panel.setTitle_(self.title)
     if self.directory:
         panel.setDirectory_(self.directory)
     if self.fileTypes:
         panel.setAllowedFileTypes_(self.fileTypes)
     panel.setCanCreateDirectories_(self.canCreateDirectories)
     panel.setCanSelectHiddenExtension_(True)
     panel.setAccessoryView_(self.accessoryView)
     if self._parentWindow is not None:
         panel.beginSheetForDirectory_file_modalForWindow_modalDelegate_didEndSelector_contextInfo_(
                 self.directory, self.fileName, self._parentWindow, self, "savePanelDidEnd:returnCode:contextInfo:", 0)
     else:
         isOK = panel.runModalForDirectory_file_(self.directory, self.fileName)
         if isOK == NSOKButton:
             self._result = panel.filename()
Exemple #10
0
 def run(self):
     self.panel = NSSavePanel.alloc().init()
     if self.messageText:
         self.panel.setMessage_(self.messageText)
     if self.title:
         self.panel.setTitle_(self.title)
     if self.fileName:
         self.panel.setNameFieldStringValue_(self.fileName)
     if self.directory:
         self.panel.setDirectoryURL_(NSURL.fileURLWithPath_(self.directory))
     if self.fileTypes:
         self.panel.setAllowedFileTypes_(self.fileTypes)
     self.panel.setCanCreateDirectories_(self.canCreateDirectories)
     self.panel.setCanSelectHiddenExtension_(True)
     self.panel.setAccessoryView_(self.accessoryView)
     if self._parentWindow is not None:
         self.panel.beginSheetModalForWindow_completionHandler_(self._parentWindow, self.completionHandler_)
     else:
         isOK = self.panel.runModalForDirectory_file_(self.directory, self.fileName)
         if isOK == NSOKButton:
             self._result = self.panel.filename()
Exemple #11
0
 def run(self):
     panel = NSSavePanel.alloc().init()
     if self.messageText:
         panel.setMessage_(self.messageText)
     if self.title:
         panel.setTitle_(self.title)
     if self.directory:
         panel.setDirectory_(self.directory)
     if self.fileTypes:
         panel.setAllowedFileTypes_(self.fileTypes)
     panel.setCanCreateDirectories_(self.canCreateDirectories)
     panel.setCanSelectHiddenExtension_(True)
     panel.setAccessoryView_(self.accessoryView)
     if self._parentWindow is not None:
         panel.beginSheetForDirectory_file_modalForWindow_modalDelegate_didEndSelector_contextInfo_(
             self.directory, self.fileName, self._parentWindow, self,
             "savePanelDidEnd:returnCode:contextInfo:", 0)
     else:
         isOK = panel.runModalForDirectory_file_(self.directory,
                                                 self.fileName)
         if isOK == NSOKButton:
             self._result = panel.filename()
Exemple #12
0
def _request_new(prompt, default_dir, default_name, file_type, dir):
    ns_panel = NSSavePanel.savePanel()
    #if prompt.endswith(":"):
    #	prompt = prompt[:-1]
    #if prompt.lower().endswith(" as"):
    #	prompt = prompt[:-3]
    #ns_panel.setTitle_(prompt)
    #print "_request_new: setting label to", repr(prompt) ###
    ns_panel.setNameFieldLabel_(prompt)
    if default_dir:
        ns_dir = default_dir.path
    else:
        ns_dir = None
    if file_type:
        suffix = file_type.suffix
        if suffix:
            ns_panel.setCanSelectHiddenExtension_(True)
            if not file_type.mac_type or file_type.mac_force_suffix:
                ns_panel.setRequiredFileType_(suffix)
    result = ns_panel.runModalForDirectory_file_(ns_dir, default_name)
    if result == NSOKButton:
        return FileRef(path=ns_panel.filename())
    else:
        return None
def _request_new(prompt, default_dir, default_name, file_type, dir):
    ns_panel = NSSavePanel.savePanel()
    #if prompt.endswith(":"):
    #	prompt = prompt[:-1]
    #if prompt.lower().endswith(" as"):
    #	prompt = prompt[:-3]
    #ns_panel.setTitle_(prompt)
    #print "_request_new: setting label to", repr(prompt) ###
    ns_panel.setNameFieldLabel_(prompt)
    if default_dir:
        ns_dir = default_dir.path
    else:
        ns_dir = None
    if file_type:
        suffix = file_type.suffix
        if suffix:
            ns_panel.setCanSelectHiddenExtension_(True)
            if not file_type.mac_type or file_type.mac_force_suffix:
                ns_panel.setRequiredFileType_(suffix)
    result = ns_panel.runModalForDirectory_file_(ns_dir, default_name)
    if result == NSOKButton:
        return FileRef(path = ns_panel.filename())
    else:
        return None
Exemple #14
0
# Try to look for a file .<DocumentName>.omnigraffle_export
export_info_fname = "Untitled"
if schema_fname.rfind('.') != -1:
  export_info_fname = os.path.join(schema_dir, '.' + schema_fname[0:schema_fname.rindex('.')] + '.omnigraffle_export')

if os.path.exists(export_info_fname):
	# if it exists it should contain one line that gives a relative path to a
	# directory where to export
	with open(export_info_fname) as f:
		target_dir = f.read().strip()
	target_dir = os.path.join(schema_dir, target_dir)
	target_dir = os.path.normpath(target_dir)
	target_path = os.path.join(target_dir, canvas_name + '.' + format)
else:
	# otherwise ask for a path
	savePanel = NSSavePanel.savePanel()
	savePanel.setTitle_("Save %s as" % canvas_name)
	savePanel.setDirectoryURL_(NSURL.fileURLWithPath_(schema_dir))
	savePanel.setCanCreateDirectories_(True)
	savePanel.setExtensionHidden_(False)
	savePanel.setNameFieldStringValue_(canvas_name+'.pdf')
	NSApplication.sharedApplication().activateIgnoringOtherApps_(True);

	if savePanel.runModal() == NSFileHandlingPanelOKButton:
	    target_path = savePanel.URL().path()
	    format = target_path[target_path.rindex('.')+1:]

if not target_path:
	sys.exit(0)

try: