How to use the nw.gui.Tray function in nw

To help you get started, we’ve selected a few nw 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 nwjs / nw.js / tests / manual_tests / menu / index.html View on Github external
submenu.items[0].enabled == false,
  submenu.items[1].enabled == true,
  submenu.items[2].enabled == true,
  submenu.items[3].enabled == true,
  'After flip checked and enabled');

  // Click to flip other items
  var lastone = submenu.items[0];
  submenu.items[0].click = submenu.items[1].click = submenu.items[2].click = submenu.items[3].click = function() {
    lastone.checked = !lastone.checked;
    lastone.enabled = !lastone.enabled;
    this.enabled = !this.enabled;
    lastone = this;
  }

  var tray = new gui.Tray({ title: 'Test Menu', menu: menu });
  menu.items[0].icon = 'icon1.png';
  assert(
  menu.items[0].icon == 'icon1.png',
  'Set Menu Icon');

  menu.items[0].icon = '';
  assert(
  menu.items[0].icon == '',
  'Clear Menu Icon');

  menu.items[1].icon = tray.icon = 'icon1.png';

  menu.items[1].on('click', function() {
    console.log('Item Mama');
  });
github armadito / armadito-av / gui / node_webkit / js / systray_menu.js View on Github external
function initSystray(){
 
	console.log("Init systray !\n");

	var ffi = require("ffi");
	/*var libm = new ffi.Library("libm", { "ceil": [ "double", [ "double" ] ] });
	libm.ceil(1.5); // 2

	console.log(" libm ceil(1.5) = "+ libm);*/

	// Create a tray icon
	tray = new gui.Tray({ title: 'Uhuru-AV', icon: 'img/uhuru_systray.png' });
	tray.menu = SystrayMenu();
}
github capablemonkey / sleep / app / js / index.js View on Github external
function initTray() {
	// TODO: maybe have a giant display for the time that spans 5 menu items; make the time more prominent

	// add tray icon to statusbar:
	tray = new gui.Tray({ icon: 'assets/icon2.png'});

	/*
	 *	create the main tray menu and its items
	 */

	trayMenu = new gui.Menu();
	trayMenuItems.lastSlept = new gui.MenuItem({ type: 'normal', label: 'ugh', enabled: false });
	trayMenuItems.lastWoke = new gui.MenuItem({ type: 'normal', label: 'ugh', enabled: false });
	trayMenuItems.duration = new gui.MenuItem({ type: 'normal', label: 'ugh', enabled: false });
	trayMenuItems.sep1 = new gui.MenuItem({type: 'separator'});
	trayMenuItems.reasonLabel = new gui.MenuItem({type: 'normal', label: 'reason for sleep:', enabled: false});
	trayMenuItems.reason = new gui.MenuItem({ type: 'normal', label: 'ugh', enabled: false });
	trayMenuItems.sep2 = new gui.MenuItem({type: 'separator'});
	trayMenuItems.startup = new gui.MenuItem({type: 'checkbox', label: 'run on login?', checked: false});
	trayMenuItems.about = new gui.MenuItem({type: 'normal', label: 'about'});
	trayMenuItems.quit = new gui.MenuItem({ type: 'normal', label: 'quit', enabled: true });
github sindresorhus / yo-app / main.js View on Github external
setTimeout(updateTray, TRAY_UPDATE_INTERVAL);

		if (!dirPath) {
			return;
		}

		findPkg(dirPath, function (err, pkgPath, pkgData) {
			// package.json name or fallback to dir name
			var name = pkgData && pkgData.name || path.basename(dirPath, path.extname(dirPath));
			tray.menu = createTrayMenu(name, generators);
		});
	});
}

var win = gui.Window.get();
var tray = new gui.Tray({
	icon: 'menubar-icon@2x.png',
	alticon: 'menubar-icon@2x.png'
});

var menu = new gui.Menu();
menu.append(new gui.MenuItem({
	label: 'No Yeoman project found',
	enabled: false
}));

tray.menu = menu;
updateTray();
github cgrossde / Pullover / src / js / app.js View on Github external
}

function hideWindow() {
	win.hide();
	win.setShowInTaskbar(false);
}

function showWindow() {
	win.show();
	win.setShowInTaskbar(true);
}

// Create permanent tray icon
// Tray icon
var icon = (os.platform() === 'darwin') ? 'images/tray_mac.png' : 'images/tray.png';
tray = new gui.Tray({
	icon: icon
});

// Create tray menu items:
	// Separator
	var itemSeparator = new gui.MenuItem({ type: 'separator' });
	// Show status
	var itemStatus = new gui.MenuItem({ type: 'normal', label: 'Status' });
	itemStatus.on('click', function() {
		showWindow();
		showStatus();
	});
	// Quit app
	var itemQuit = new gui.MenuItem({ type: 'normal', label: 'Quit Pullover' });
	itemQuit.on('click', quitApp);
github Jermolene / TiddlyDesktop / source / js / main.js View on Github external
var gui = require("nw.gui"),
	fs = require("fs"),
	path = require("path");

var WindowList = require("../js/window-list.js").WindowList;

// Use the main window as the backstage window
var backstageWindow = gui.Window.get();
// backstageWindow.showDevTools();

function showBackstageWindow() {
	backstageWindow.show();
}

// Create the tray icon
var tray = new gui.Tray({
	title: "",
	icon: window.devicePixelRatio > 1 ? "images/tray_icon@2x.png" : "images/tray_icon.png",
	alticon: "",
	tooltip: "TiddlyDesktop",
	iconsAreTemplates: true
});

// Give it a menu
var trayMenu = new gui.Menu();
trayMenu.append(new gui.MenuItem({
	label: "TiddlyDesktop v" + require("../package.json").version,
	enabled: false
}));
trayMenu.append(new gui.MenuItem({
	label: "Wiki List",
	click: function() {
github octalmage / HotGifs / app.js View on Github external
var skiptext = "Press tab to skip.";

var startup;

if (process.platform === "darwin")
{
	var nativeMenuBar = new gui.Menu(
	{
		type: "menubar"
	});
	nativeMenuBar.createMacBuiltin("Hot Gifs");
	win.menu = nativeMenuBar;
}

//Create tray icon.
var tray = new gui.Tray(
{
	icon: "assets/img/tray.png",
	iconsAreTemplates: false
});

//Give it a menu.
var menu = new gui.Menu();
menu.append(new gui.MenuItem(
{
	label: "Hot Gifs"
}));
menu.append(new gui.MenuItem(
{
	type: "separator"
}));
menu.append(new gui.MenuItem(
github matthewn4444 / Lightpack-Filter-and-API / directshow / Lightpack-filter-gui / app / src / js / script.js View on Github external
function initTray() {
    tray = new gui.Tray({ icon: "/app/src/images/icon.png" });
    tray.tooltip = "Lightpack Filter";

    var trayMenu = new gui.Menu();
    trayMenu.append(new gui.MenuItem({ label: "Edit Settings", click: showWindow }));
    trayMenu.append(new gui.MenuItem({ type: "separator" }));
    trayMenu.append(new gui.MenuItem({ label: "Close", click: close }));
    tray.menu = trayMenu;
    tray.on("click", showWindow);
}
win.on("minimize", function() {
github nihgwu / Nevermore / js / services.js View on Github external
});

  var hideWin = function() {
    self.show = false;
    hideItem.label = 'Show';
    return win.hide();
  }
  this.hideWin = hideWin;
  this.showDebug = function() {
    win.showDevTools();
  }
  this.resizeTo = function(width, height) {
    win.resizeTo(width, height);
  }

  var tray = new gui.Tray({
    icon: 'img/off_tray_icon.png'
  });
  var menu = new gui.Menu();
  tray.on('click', function() {
    if (!self.show) win.show();
    self.show = true;
    hideItem.label = 'Hide';
    return win.focus();
  });
  this.running = false;
  var startItem = new gui.MenuItem({
    type: 'normal',
    label: 'Nevermore',
    icon: 'img/off_icon.png',
    click: function() {
      $rootScope.$broadcast('running', !self.running);