<commit_before>/**
 * TagSpaces - universal file and folder organizer
 * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License (version 3) as
 * published by the Free Software Foundation..
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 * @flow
 */

import fsextra from 'fs-extra';
import winattr from 'winattr';
import {
  extractParentDirectoryPath,
  getMetaDirectoryPath,
  // extractFileExtension
} from '../utils/paths';
import { arrayBufferToBuffer } from '../utils/misc';
import AppConfig from '../config';
import PlatformIO from './platform-io';
import TrayIcon from '../assets/icons/trayIcon.png';
// import TrayIconWin from '../assets/icons/trayIcon.ico';
import TrayIcon2x from '../assets/icons/trayIcon@2x.png';
import TrayIcon3x from '../assets/icons/trayIcon@3x.png';
import { Pro } from '../pro';

export default class ElectronIO {
  electron: Object;
  win: Object;
  app: Object;
  ipcRenderer: Object;
  remote: Object;
  workerWindow: Object;
  pathUtils: Object;
  fs: Object;
  fsWatcher: Object;
  webFrame: Object;

  constructor() {
    if (window.require) {
      this.electron = window.require('electron');
      this.ipcRenderer = this.electron.ipcRenderer;
      this.webFrame = this.electron.webFrame;
      this.remote = this.electron.remote;
      this.workerWindow = this.remote.getGlobal('splashWorkerWindow');
      this.win = this.remote.getCurrentWindow();
      this.app = this.remote.app;
      this.fs = fsextra; // window.require('fs-extra');
      this.pathUtils = window.require('path');
    }
  }

  initMainMenu = (menuConfig: Array<Object>) => {
    const Menu = this.remote.Menu;
    const defaultMenu = Menu.buildFromTemplate(menuConfig);
    Menu.setApplicationMenu(defaultMenu);
  };

  initTrayMenu = (menuConfig: Array<Object>) => {
    const mainWindow = this.win;
    const Menu = this.remote.Menu;
    const Tray = this.remote.Tray;
    const nativeImage = this.remote.nativeImage;

    // let trayIconPath;
    // if (process.platform === 'darwin') {
    //   trayIconPath = this.pathUtils.join(__dirname, '/assets/icons/64x64.png');
    // } else if (process.platform === 'win32') {
    //   trayIconPath = this.pathUtils.join(__dirname, '/assets/icons/128x128.png');
    // } else {
    //   trayIconPath = this.pathUtils.join(__dirname, '/assets/icons/64x64.png');
    // }
    // const appPath = this.getAppPath();
    // const nImage = nativeImage.createFromPath(appPath + trayIconPath);<commit_msg>Disabling the tray icon and menu on Mac OS<commit_after>/**
 * TagSpaces - universal file and folder organizer
 * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License (version 3) as
 * published by the Free Software Foundation..
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 * @flow
 */

import fsextra from 'fs-extra';
import winattr from 'winattr';
import {
  extractParentDirectoryPath,
  getMetaDirectoryPath,
  // extractFileExtension
} from '../utils/paths';
import { arrayBufferToBuffer } from '../utils/misc';
import AppConfig from '../config';
import PlatformIO from './platform-io';
import TrayIcon from '../assets/icons/trayIcon.png';
// import TrayIconWin from '../assets/icons/trayIcon.ico';
import TrayIcon2x from '../assets/icons/trayIcon@2x.png';
import TrayIcon3x from '../assets/icons/trayIcon@3x.png';
import { Pro } from '../pro';

export default class ElectronIO {
  electron: Object;
  win: Object;
  app: Object;
  ipcRenderer: Object;
  remote: Object;
  workerWindow: Object;
  pathUtils: Object;
  fs: Object;
  fsWatcher: Object;
  webFrame: Object;

  constructor() {
    if (window.require) {
      this.electron = window.require('electron');
      this.ipcRenderer = this.electron.ipcRenderer;
      this.webFrame = this.electron.webFrame;
      this.remote = this.electron.remote;
      this.workerWindow = this.remote.getGlobal('splashWorkerWindow');
      this.win = this.remote.getCurrentWindow();
      this.app = this.remote.app;
      this.fs = fsextra; // window.require('fs-extra');
      this.pathUtils = window.require('path');
    }
  }

  initMainMenu = (menuConfig: Array<Object>) => {
    const Menu = this.remote.Menu;
    const defaultMenu = Menu.buildFromTemplate(menuConfig);
    Menu.setApplicationMenu(defaultMenu);
  };

  initTrayMenu = (menuConfig: Array<Object>) => {
    // Temp. disabling the tray support on Mac OS due to instability‚
    if (process.platform === 'darwin') {
      return true
    }
    
    const mainWindow = this.win;
    const Menu = this.remote.Menu;
    const Tray = this.remote.Tray;
    const nativeImage = this.remote.nativeImage;

    // let trayIconPath;
    // if (process.platform === 'darwin') {
    //   trayIconPath = this.pathUtils.join(__dirname, '/assets/icons/64x64.png');
    // } else if (process.platform === 'win32') {
    //   trayIconPath = this.pathUtils.join(__dirname, '/assets/icons/128x128.png');
    // } else {
    //   trayIconPath = this.pathUtils.join(__dirname, '/assets/icons/64x64.png');
    // }
    // const appPath = this.getAppPath();
    // const nImage = nativeImage.createFromPath(appPath + trayIconPath);
{'fraction_non_alphanumeric': 0.12567501227295041, 'fraction_numerical': 0.008181966944853543, 'mean_word_length': 3.403458213256484, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3799403', 'n_tokens_mistral': 1860, 'n_tokens_neox': 1816, 'n_words': 519}