How to use the gui.Menu function in gui

To help you get started, we’ve selected a few gui examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yue / wey / lib / view / notification-center.js View on Github external
constructor() {
    this.isRead = true
    this.mentions = 0

    if (process.platform !== 'darwin') {
      // Listen for new instances.
      singleInstance.listen(this.activateApp.bind(this))

      // Create tray icon.
      this.trayIcon = gui.Image.createFromPath(fs.realpathSync(path.join(__dirname, 'tray', 'icon.png')))
      this.attentionIcon = gui.Image.createFromPath(fs.realpathSync(path.join(__dirname, 'tray', 'attention.png')))
      this.mentionIcon = gui.Image.createFromPath(fs.realpathSync(path.join(__dirname, 'tray', 'mention.png')))
      this.tray = gui.Tray.createWithImage(this.trayIcon)
      this.tray.onClick = this.activateApp.bind(this)

      const menu = gui.Menu.create([
        {
          label: 'Show',
          onClick: this.activateApp.bind(this)
        },
        {
          label: 'Quit',
          onClick() { windowManager.quit() }
        },
      ])
      this.tray.setMenu(menu)
    }

    this.subscription = {
      onUpdateReadState: accountManager.onUpdateReadState.add(this.updateReadState.bind(this)),
      onUpdateMentions: accountManager.onUpdateMentions.add(this.updateMentions.bind(this)),
    }
github yue / wey / lib / view / channel-item.js View on Github external
_click(view, event) {
    // Click on the channel item.
    if (event.button === 1) {
      // Left click to open channel.
      this.parent.selectChannelItem(this)
    } else {  // for GTK+ button could be 3 for trackpad right click.
      // Right click to show context menu.
      if (!this.menu) {
        const leaveLabel = this.channel.type === 'channel' ? 'Leave channel'
                                                           : 'Close direct message'
        this.menu = gui.Menu.create([
          { label: 'Popup to new window', onClick: this._popup.bind(this) },
          { label: leaveLabel, onClick: this._leave.bind(this) },
        ])
      }
      this.menu.popup()
    }
  }
github yue / wey / lib / view / app-menu.js View on Github external
// Edit menu.
    menus.push({
      label: 'Edit',
      submenu: [
        { role: 'undo' },
        { role: 'redo' },
        { type: 'separator' },
        { role: 'cut' },
        { role: 'copy' },
        { role: 'paste' },
        { role: 'select-all' },
      ],
    })

    // Accounts menu.
    this.accountsMenu = gui.Menu.create([
      { type: 'separator' },
    ])
    for (let i = 0; i < accountManager.accounts.length; ++i)
      this.addAccount(win, i, accountManager.accounts[i])
    for (const service of accountManager.getServices()) {
      this.accountsMenu.append(gui.MenuItem.create({
        label: 'Login to ' + service.name,
        onClick: service.login.bind(service),
      }))
    }
    menus.push({label: 'Accounts', submenu: this.accountsMenu})
    this.subscription = {
      onAddAccount: accountManager.onAddAccount.add(this.accountCreated.bind(this, win)),
      onRemoveAccount: accountManager.onRemoveAccount.add(this.removeAccount.bind(this)),
    }
github yue / wey / lib / view / account-header.js View on Github external
constructor(account) {
    this.account = null

    this.font = gui.Font.default().derive(8, 'semi-bold', 'normal')
    this.hover = false

    // Toggle the menu when clicking on the panel.
    this.canShowMenu = false

    this.menu = gui.Menu.create([
      { label: 'Logout', onClick: this.logout.bind(this) },
    ])

    this.view = gui.Container.create()
    this.view.setStyle({width: '100%', height: 45})
    this.view.onDraw = this.draw.bind(this)
    this.view.onMouseEnter = () => {
      this.hover = true
      this.canShowMenu = true
      this.view.schedulePaint()
    }
    this.view.onMouseLeave = () => {
      this.hover = false
      this.canShowMenu = true
      this.view.schedulePaint()
    }
github yue / wey / lib / view / chat-box.js View on Github external
_openLinkContextMenu(link) {
    const menu = gui.Menu.create([
      { label: 'Copy Link', onClick: this._copyLink.bind(this, link)},
      { label: 'Open Link', onClick: this._openLink.bind(this, link)},
    ])
    menu.popup()
  }
github yue / wey / lib / view / accounts-panel.js View on Github external
addButton.onClick = () => {
      const services = accountManager.getServices()
      const menu = gui.Menu.create(services.map((s) => {
        return {label: s.name, onClick: s.login.bind(s)}
      }))
      menu.popup()
    }
    return addButton