<commit_before>// ----- Requires ----- //

var fileMenu = require('./fileMenu.js');


// ----- Export ----- //

exports.build = function buildMenus (gui, file) {

	// ----- Setup ----- //

	// Creates the menu bar.
	var menu = new gui.Menu({ type: 'menubar' });


	// ----- Functions ----- //

	// Creates the default OS X menu controls.
	function buildMacMenu () {
		menu.createMacBuiltin('Didactylos');
	}

	// Adds an item to the menu.
	function addMenuItem (menu, item) {

		var menuItem = new gui.MenuItem(item);
		menu.append(menuItem);

	}

	// Creates the File submenu (to hold Open, Save, etc.).
	function buildFileSubmenu () {

		var fileSubmenu = new gui.Menu();
		var menuItems = fileMenu.items(gui, file);

		for (var item in menuItems) {
			addMenuItem(fileSubmenu, menuItems[item]);
		}

		return fileSubmenu;

	}

	// Creates the File option on the menu bar.
	function addFileMenu () {

		var fileSubmenu = buildFileSubmenu();

		var fileMenu = new gui.MenuItem({
			label: 'File',
			submenu: fileSubmenu
		});

		menu.insert(fileMenu, 1);

	}


	// ----- Build GUI ----- //

	// Builds the menus.
	buildMacMenu();
	addFileMenu();

	// Adds the menu to the window.
	gui.Window.get().menu = menu;
<commit_msg>Generalised addition of menus to the menubar.<commit_after>// ----- Requires ----- //

var fileMenu = require('./fileMenu.js');


// ----- Export ----- //

exports.build = function buildMenus (gui, file) {

	// ----- Setup ----- //

	// Creates the menu bar.
	var menu = new gui.Menu({ type: 'menubar' });


	// ----- Functions ----- //

	// Creates the default OS X menu controls.
	function buildMacMenu () {
		menu.createMacBuiltin('Didactylos');
	}

	// Adds a submenu to the menubar.
	function addSubmenu (menuItems) {

		var subMenu = new gui.Menu();

		for (var item in menuItems) {
			var menuItem = new gui.MenuItem(menuItems[item]);
			subMenu.append(menuItem);
		}

		return subMenu;

	}

	// Adds a menu to the menubar.
	function addMenu (name, position, items) {

		var subMenu = addSubmenu(items);

		var newMenu = new gui.MenuItem({
			label: name,
			submenu: subMenu
		});

		menu.insert(newMenu, position);

	}

	// Builds out the menubar with menus.
	function buildMenubar () {

		var fileMenuItems = fileMenu.items(gui, file);
		addMenu('File', 1, fileMenuItems);

	}


	// ----- Build GUI ----- //

	// Builds the menus.
	buildMacMenu();
	buildMenubar();

	// Adds the menu to the window.
	gui.Window.get().menu = menu;

{'fraction_non_alphanumeric': 0.17119675456389452, 'fraction_numerical': 0.0008113590263691683, 'mean_word_length': 2.4683544303797467, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '4499076', 'n_tokens_mistral': 901, 'n_tokens_neox': 805, 'n_words': 232}