Example #1
0
 function chooseFileOrDirWithDialog() {
     const filters = [
         {
             name: 'Markdown',
             extensions: config.file_ext.markdown,
         },
         {
             name: 'HTML',
             extensions: config.file_ext.html,
         },
     ];
     const properties = ['openFile'] as ('openFile' | 'openDirectory' | 'multiSelections' | 'createDirectory')[];
     if (on_darwin) {
         // Note:
         // On Windows and Linux an open dialog can not be both a file selector
         // and a directory selector, so if you set properties to
         // ['openFile', 'openDirectory'] on these platforms, a directory
         // selector will be shown.
         properties.push('openDirectory');
     }
     const paths = remote.dialog.showOpenDialog({
         title: 'Choose file or directory to watch',
         defaultPath: getDialogDefaultPath(),
         filters,
         properties,
     });
     if (!paths || paths.length === 0) {
         return '';
     }
     return paths[0];
 }
Example #2
0
$('body').on('click', '.button#load-template', function(event) {
  dialog.showOpenDialog(
  {
    title: 'Open New Email Template',
    filters: [
      {name: 'Templates', extensions: ['html']},
      {name: 'All Files', extensions: ['*']}
    ]
  }, function(fileNames: string[]) {
    if (fileNames !== undefined) {
      storage.get('templates', function(error, templates) {
        if (_.isEmpty(templates)) {
          templates = [];
        }
        if (! _.contains(templates, fileNames[0])) {
          templates.push(fileNames[0]);
          storage.set('templates', templates, function(error) {
            if (error) {
              console.error(error);
            }
          });
        }
      });
      openTemplate(fileNames[0]);
    }
  });
});
Example #3
0
File: ctrl.ts Project: rose-m/oSeed
 function installFailed() {
     remote.dialog.showMessageBox({
         type: 'error',
         title: 'Installation failed',
         message: 'Failed to install PIP',
         detail: 'Please refer to https://pip.pypa.io for a detailed installation guide.',
         buttons: ['OK']
     });
 }
Example #4
0
File: ctrl.ts Project: rose-m/oSeed
 .then((out) => {
     console.log(out);
     remote.dialog.showMessageBox({
         type: 'info',
         title: 'Installation successful',
         message: 'PIP was successfully installed.',
         buttons: ['OK']
     });
 }, (out) => {
Example #5
0
export function directoryChooser(title?: string, defaultPath?: string) {

    return remote.dialog.showOpenDialog({
        defaultPath,
        title,
        properties: [
            "openDirectory",
        ],
    })[0];
}
 /**
  * Display a dialog for selecting the library dir.
  */
 add() {
     dialog.showOpenDialog({
         title: 'Select Visualization Folder(s)',
         defaultPath: this.state.lastPath.value || DEFAULT_LIBRARY_PATH,
         properties: ['openDirectory', 'multiSelections']
     }, (paths: string[]) => {
         const entries = this.loadFromPaths(paths);
         if (0 < entries.length) {
             this.state.update('activeId', entries[0].id);
         }
     });
 }
Example #7
0
export function fileChooser(multi: boolean, title?: string, defaultPath?: string) {

    const properties: OpenDialogOptions["properties"] = [
        "openFile",
    ];

    if (multi) {

        properties.push("multiSelections");
    }

    return remote.dialog.showOpenDialog({
        defaultPath,
        title,
        properties,
    });
}
Example #8
0
 r.onloadend = () => {
   const data = {
     name: sanitizeFilename(self.visState.title.toLowerCase().replace(/\s/g, '-')),
     image: r.result,
     format: 'png'
   };
   remote.dialog.showSaveDialog(
     remote.BrowserWindow.getAllWindows()[0],
     {
       title: 'Export to Image',
       defaultPath: sanitizeFilename(data.name + '.' + data.format)
     },
     (name: string) => {
       name && writeFileSync(name, arrayBufferToBuffer(data.image));
     }
   );
 };
Example #9
0
{
    const opened: boolean = webview.isDevToolsOpened();
    const focused: boolean = webview.isDevToolsFocused();
    const focused2: boolean = webview.getWebContents().isFocused();
}

// In guest page.
ipcRenderer.on('ping', function() {
	ipcRenderer.sendToHost('pong');
});


// showOpenDialog
// https://electron.atom.io/docs/api/dialog/#dialogshowopendialogbrowserwindow-options-callback

remote.dialog.showOpenDialog(win);
remote.dialog.showOpenDialog(win, {}, fileNames => fileNames);
remote.dialog.showOpenDialog(win, {
	title: 'foo',
	defaultPath: '/bar',
	buttonLabel: 'foo bar',
	filters: [
		{name: 'Images', extensions: ['jpg', 'png', 'gif']},
		{name: 'Movies', extensions: ['mkv', 'avi', 'mp4']},
		{name: 'Custom File Type', extensions: ['as']},
		{name: 'All Files', extensions: ['*']}
	],
	properties: ['openFile', 'openDirectory', 'multiSelections', 'showHiddenFiles', 'createDirectory', 'promptToCreate', 'noResolveAliases'],
	normalizeAccessKeys: true,
	message: 'foo message',
});