From 887e539fb78e31da6a38ef6d46d6cb5800b68f9f Mon Sep 17 00:00:00 2001 From: Jonathan Wilkes <jon.w.wilkes@gmail.com> Date: Mon, 30 Nov 2015 20:12:14 -0500 Subject: [PATCH] put menu logic back into index.js and pd_canvas.js --- pd/nw/index.js | 445 +++++++++++++++++++++++++++++++++++++++++++- pd/nw/pd_canvas.js | 48 ++--- pd/nw/pd_menus.js | 447 --------------------------------------------- 3 files changed, 468 insertions(+), 472 deletions(-) delete mode 100644 pd/nw/pd_menus.js diff --git a/pd/nw/index.js b/pd/nw/index.js index 911cea5a5..dbf1f8516 100644 --- a/pd/nw/index.js +++ b/pd/nw/index.js @@ -1,7 +1,6 @@ "use strict"; var gui = require("nw.gui"); var pdgui = require("./pdgui.js"); -var pd_menus = require("./pd_menus.js"); // we're using pwd in fileDialog var pwd = process.env.PWD; @@ -14,7 +13,7 @@ var l = pdgui.get_local_string; // Set up the Pd Window set_vars(this); add_events(); -pd_menus.nw_create_pd_window_menus(gui, window); +nw_create_pd_window_menus(gui, window); gui.Window.get().setMinimumSize(350,250); // Now we create a connection from the GUI to Pd, in one of two ways: // 1) If the GUI was started by Pd, then we create a tcp client and @@ -318,3 +317,445 @@ function nw_create_window(cid, type, width, height, xpos, ypos, menu_flag, }); return new_win; } + +// Pd Window Menu Bar + +function pdmenu_help_browser (w) { + w.alert("Please implement pdmenu_preferences"); +} + +function pdmenu_l2ork_mailinglist () { + alert("Please implement pdmenu_preferences"); +} + +function pdmenu_pd_mailinglists () { + alert("Please implement pdmenu_preferences"); +} + +function pdmenu_forums () { + alert("Please implement pdmenu_preferences"); +} + +function pdmenu_irc () { + alert("Please implement pdmenu_preferences"); +} + +function nw_create_pd_window_menus(gui, w) { + // Command key for OSX, Control for GNU/Linux and Windows + var cmd_or_ctrl = process.platform === "darwin" ? "cmd" : "ctrl"; + // Window menu + var windowMenu = new gui.Menu({ + type: "menubar" + }); + + // File menu + var fileMenu = new gui.Menu(); + + // Add to window menu + windowMenu.append(new gui.MenuItem({ + label: l("menu.file"), + submenu: fileMenu + })); + + // File sub-entries + fileMenu.append(new gui.MenuItem({ + label: l("menu.new"), + click: pdgui.menu_new, + key: "n", + modifiers: cmd_or_ctrl, + tooltip: l("menu.new.tt") + })); + + fileMenu.append(new gui.MenuItem({ + label: l("menu.open"), + key: "o", + modifiers: cmd_or_ctrl, + tooltip: l("menu.open.tt"), + click: function (){ + var input, chooser, + span = w.document.querySelector("#fileDialogSpan"); + // Complicated workaround-- see comment in build_file_dialog_string + input = pdgui.build_file_dialog_string({ + style: "display: none;", + type: "file", + id: "fileDialog", + nwworkingdir: pdgui.get_pwd(), + multiple: null, + // These are copied from pd_filetypes in pdgui.js + accept: ".pd,.pat,.mxt,.mxb,.help" + }); + span.innerHTML = input; + var chooser = w.document.querySelector("#fileDialog"); + chooser.onchange = function() { + var file_array = this.value; + // reset value so that we can open the same file twice + this.value = null; + pdgui.menu_open(file_array); + console.log("tried to open something"); + }; + chooser.click(); + } + })); + + if (pdgui.k12_mode == 1) { + fileMenu.append(new gui.MenuItem({ + label: l("menu.k12.demos"), + tooltip: l("menu.k12.demos_tt"), + click: pdgui.menu_k12_open_demos + })); + } + + fileMenu.append(new gui.MenuItem({ + type: "separator" + })); + + // Note: this must be different for the main Pd window + fileMenu.append(new gui.MenuItem({ + label: l("menu.save"), + click: function () {}, + enabled: false, + key: "s", + tooltip: l("menu.save.tt"), + modifiers: cmd_or_ctrl + })); + + fileMenu.append(new gui.MenuItem({ + label: l("menu.saveas"), + click: function (){}, + enabled: false, + key: "S", + tooltip: l("menu.saveas_tt"), + modifiers: cmd_or_ctrl + })); + + if (pdgui.k12_mode == 0) { + fileMenu.append(new gui.MenuItem({ + type: "separator" + })); + } + + fileMenu.append(new gui.MenuItem({ + label: l("menu.message"), + click: pdgui.menu_send, + key: "m", + modifiers: cmd_or_ctrl, + tooltip: l("menu.message_tt") + })); + + if (pdgui.k12_mode == 0) { + fileMenu.append(new gui.MenuItem({ + type: "separator" + })); + } + + // recent files go here + + // anther separator goes here if there are any recent files + + // Note: there's no good reason to have this here + fileMenu.append(new gui.MenuItem({ + label: l("menu.close"), + click: function () {}, + enabled: false, + })); + + // Quit Pd + fileMenu.append(new gui.MenuItem({ + label: l("menu.quit"), + click: pdgui.menu_quit, + key: "q", + modifiers: cmd_or_ctrl, + tooltip: l("menu.quit_tt") + })); + + + // Edit menu + var editMenu = new gui.Menu(); + + // Add to window menu + windowMenu.append(new gui.MenuItem({ + label: l("menu.edit"), + submenu: editMenu + })); + + // Edit sub-entries + editMenu.append(new gui.MenuItem({ + label: l("menu.copy"), + click: function() { + w.document.execCommand("copy"); + }, + key: "c", + modifiers: cmd_or_ctrl, + tooltip: l("menu.copy_tt") + })); + + editMenu.append(new gui.MenuItem({ + label: l("menu.selectall"), + click: function () { + var container_id = "p1", range; + // This should work across browsers + if (w.document.selection) { + range = w.document.body.createTextRange(); + range.moveToElementText(w.document.getElementById(container_id)); + range.select(); + } else if (w.getSelection) { + range = w.document.createRange(); + range.selectNode(w.document.getElementById(container_id)); + // we need to empty the current selection to avoid a strange + // error when trying to select all right after Pd starts: + // "The given range and the current selection belong to two + // different document fragments." + // (I guess nw.js somehow starts up with the selection being + // somewhere outside the window...) + w.getSelection().empty(); + w.getSelection().addRange(range); + } + }, + key: "a", + modifiers: cmd_or_ctrl, + tooltip: l("menu.selectall_tt") + })); + + editMenu.append(new gui.MenuItem({ + type: "separator" + })); + + editMenu.append(new gui.MenuItem({ + label: l("menu.zoomin"), + click: function () { + gui.Window.get().zoomLevel += 1; + }, + key: "=", + modifiers: cmd_or_ctrl, + tooltip: l("menu.zoomin_tt") + })); + + editMenu.append(new gui.MenuItem({ + label: l("menu.zoomout"), + click: function () { + gui.Window.get().zoomLevel -= 1; + }, + key: "-", + modifiers: cmd_or_ctrl, + tooltip: l("menu.zoomout_tt") + })); + + editMenu.append(new gui.MenuItem({ + type: "separator" + })); + + editMenu.append(new gui.MenuItem({ + label: l("menu.find"), + click: function () { + var find_bar = w.document.getElementById("console_find"), + find_bar_text = w.document.getElementById("console_find_text"), + text_container = w.document.getElementById("console_bottom"), + state = find_bar.style.getPropertyValue("display"); + if (state === "none") { + text_container.style.setProperty("bottom", "1em"); + find_bar.style.setProperty("display", "inline"); + find_bar.style.setProperty("height", "1em"); + text_container.scrollTop = text_container.scrollHeight; + find_bar_text.focus(); + find_bar_text.select(); + } else { + text_container.style.setProperty("bottom", "0px"); + find_bar.style.setProperty("display", "none"); + } + }, + key: "f", + modifiers: cmd_or_ctrl, + tooltip: l("menu.find_tt") + })); + + editMenu.append(new gui.MenuItem({ + label: l("menu.preferences"), + click: pdgui.open_prefs, + key: "p", + modifiers: cmd_or_ctrl, + tooltip: l("menu.preferences_tt") + })); + + + // Windows menu... call it "winman" (i.e., window management) + // to avoid confusion + var winmanMenu = new gui.Menu(); + + // Add to windows menu + windowMenu.append(new gui.MenuItem({ + label: l("menu.windows"), + submenu: winmanMenu + })); + + // Winman sub-entries + winmanMenu.append(new gui.MenuItem({ + label: l("menu.nextwin"), + click: function() { + pdgui.raise_next("pd_window"); + }, + //key: "c", + //modifiers: cmd_or_ctrl, + tooltip: l("menu.nextwin_tt") + })); + + winmanMenu.append(new gui.MenuItem({ + label: l("menu.prevwin"), + click: function() { + pdgui.raise_prev("pd_window"); + }, + //key: "a", + //modifiers: cmd_or_ctrl, + tooltip: l("menu.prevwin_tt") + })); + + // Media menu + var mediaMenu = new gui.Menu(); + + // Add to window menu + windowMenu.append(new gui.MenuItem({ + label: l("menu.media"), + submenu: mediaMenu + })); + + // Media sub-entries + mediaMenu.append(new gui.MenuItem({ + label: l("menu.audio_on"), + click: function() { + pdgui.pdsend("pd dsp 1"); + }, + key: "/", + modifiers: cmd_or_ctrl, + tooltip: l("menu.audio_on_tt") + })); + + mediaMenu.append(new gui.MenuItem({ + label: l("menu.audio_off"), + click: function() { + pdgui.pdsend("pd dsp 0"); + }, + key: ".", + modifiers: cmd_or_ctrl, + tooltip: l("menu.audio_off_tt") + })); + + mediaMenu.append(new gui.MenuItem({ + type: "separator" + })); + + mediaMenu.append(new gui.MenuItem({ + label: l("menu.test"), + click: function() { + pdgui.pd_doc_open("doc/7.stuff/tools", "testtone.pd"); + }, + //key: "a", + //modifiers: cmd_or_ctrl, + tooltip: l("menu.test_tt") + })); + + mediaMenu.append(new gui.MenuItem({ + label: l("menu.loadmeter"), + click: function() { + pdgui.pd_doc_open("doc/7.stuff/tools", "load-meter.pd"); + }, + //key: "a", + //modifiers: cmd_or_ctrl, + tooltip: l("menu.loadmeter_tt") + })); + + // Help menu + var helpMenu = new gui.Menu(); + + // Add to window menu + windowMenu.append(new gui.MenuItem({ + label: l("menu.help"), + submenu: helpMenu + })); + + // Help sub-entries + helpMenu.append(new gui.MenuItem({ + label: l("menu.about"), + click: function() { + pdgui.pd_doc_open("doc/1.manual", "1.introduction.txt"); + }, + //key: "c", + //modifiers: cmd_or_ctrl, + tooltip: l("menu.about_tt") + })); + + helpMenu.append(new gui.MenuItem({ + label: l("menu.manual"), + click: function() { + pdgui.pd_doc_open("doc/1.manual", "index.htm"); + }, + //key: "a", + //modifiers: cmd_or_ctrl, + tooltip: l("menu.manual_tt") + })); + + helpMenu.append(new gui.MenuItem({ + label: l("menu.browser"), + click: function() { + pdmenu_help_browser(w); + }, + //key: "a", + //modifiers: cmd_or_ctrl, + tooltip: l("menu.browser_tt") + })); + + helpMenu.append(new gui.MenuItem({ + type: "separator" + })); + + helpMenu.append(new gui.MenuItem({ + label: l("menu.l2ork_list"), + click: function() { + pdgui.external_doc_open("http://disis.music.vt.edu/listinfo/l2ork-dev"); + }, + //key: "a", + //modifiers: cmd_or_ctrl, + tooltip: l("menu.l2ork_list_tt") + })); + + helpMenu.append(new gui.MenuItem({ + label: l("menu.pd_list"), + click: function() { + pdgui.external_doc_open("http://puredata.info/community/lists"); + }, + //key: "a", + //modifiers: cmd_or_ctrl, + tooltip: l("menu.pd_list_tt") + })); + + helpMenu.append(new gui.MenuItem({ + label: l("menu.forums"), + click: function() { + pdgui.external_doc_open("http://forum.pdpatchrepo.info/"); + }, + //key: "a", + //modifiers: cmd_or_ctrl, + tooltip: l("menu.forums_tt") + })); + + helpMenu.append(new gui.MenuItem({ + label: l("menu.devtools"), + click: function() { + gui.Window.get().showDevTools(); + }, + key: "b", // temporary convenience shortcut-- can change if needed + modifiers: cmd_or_ctrl, + tooltip: l("menu.devtools_tt") + })); + + //helpMenu.append(new gui.MenuItem({ + // label: l("menu.irc"), + // click: function() { + // pdgui.external_doc_open("irc://irc.freenode.net/dataflow"); + // }, + // //key: "a", + // //modifiers: cmd_or_ctrl, + // tooltip: l("menu.irc_tt") + //})); + + // Assign to window + gui.Window.get(w).menu = windowMenu; +} diff --git a/pd/nw/pd_canvas.js b/pd/nw/pd_canvas.js index 622c204e8..7379ea07b 100644 --- a/pd/nw/pd_canvas.js +++ b/pd/nw/pd_canvas.js @@ -1,4 +1,5 @@ "use strict"; + var gui = require("nw.gui"); var pdgui = require("./pdgui.js"); @@ -533,7 +534,7 @@ function register_canvas_id(cid) { // For OSX, we have a single menu and just track which window has the // focus. if (process.platform !== "darwin") { - nw_create_patch_window_menus(cid); + nw_create_patch_window_menus(gui, window, cid); } create_popup_menu(cid); canvas_events.register(cid); @@ -568,23 +569,6 @@ function create_popup_menu(name) { })); } -// stop-gap -function menu_generic () { - alert("Please implement this"); -} - -var modals = {}; // Edit menu items that should be disabled when editing - // an object box - -function set_edit_menu_modals(state) { - var item; - for (item in modals) { - if (modals.hasOwnProperty(item)) { - modals[item].enabled = state; - } - } -} - function nw_undo_menu(undo_text, redo_text) { if (undo_text === "no") { modals.undo.enabled = false; @@ -624,7 +608,25 @@ function instantiate_live_box() { } // Menus for the Patch window -function nw_create_patch_window_menus(name) { + +var modals = {}; // Edit menu items that should be disabled when editing + // an object box + +function set_edit_menu_modals(state) { + var item; + for (item in modals) { + if (modals.hasOwnProperty(item)) { + modals[item].enabled = state; + } + } +} + +// stop-gap +function menu_generic () { + alert("Please implement this"); +} + +function nw_create_patch_window_menus(gui, w, name) { // Window menu var windowMenu = new gui.Menu({ @@ -656,7 +658,7 @@ function nw_create_patch_window_menus(name) { tooltip: l("menu.open_tt"), click: function() { var input, chooser, - span = document.querySelector("#fileDialogSpan"); + span = w.document.querySelector("#fileDialogSpan"); input = pdgui.build_file_dialog_string({ id: "fileDialog", nwworkingdir: "/user/home", @@ -664,7 +666,7 @@ function nw_create_patch_window_menus(name) { type: "file", }); span.innerHTML = input; - chooser = document.querySelector("#fileDialog"); + chooser = w.document.querySelector("#fileDialog"); chooser.click(); } })); @@ -924,8 +926,8 @@ function nw_create_patch_window_menus(name) { editMenu.append(new gui.MenuItem({ label: l("menu.find"), click: function () { - var find_bar = document.getElementById("canvas_find"), - find_bar_text = document.getElementById("canvas_find_text"), + var find_bar = w.document.getElementById("canvas_find"), + find_bar_text = w.document.getElementById("canvas_find_text"), state = find_bar.style.getPropertyValue("display"); // if there's a box being edited, try to instantiate it in Pd instantiate_live_box(); diff --git a/pd/nw/pd_menus.js b/pd/nw/pd_menus.js deleted file mode 100644 index edb8501af..000000000 --- a/pd/nw/pd_menus.js +++ /dev/null @@ -1,447 +0,0 @@ -var pdgui = require("./pdgui.js"); - -// For translations -var l = pdgui.get_local_string; - -function pdmenu_help_browser (w) { - w.alert("Please implement pdmenu_preferences"); -} - -function pdmenu_l2ork_mailinglist () { - alert("Please implement pdmenu_preferences"); -} - -function pdmenu_pd_mailinglists () { - alert("Please implement pdmenu_preferences"); -} - -function pdmenu_forums () { - alert("Please implement pdmenu_preferences"); -} - -function pdmenu_irc () { - alert("Please implement pdmenu_preferences"); -} - -// Menus for the main Pd window -function nw_create_pd_window_menus(gui, w) { - // Command key for OSX, Control for GNU/Linux and Windows - var cmd_or_ctrl = process.platform === "darwin" ? "cmd" : "ctrl"; - // Window menu - var windowMenu = new gui.Menu({ - type: "menubar" - }); - - // File menu - var fileMenu = new gui.Menu(); - - // Add to window menu - windowMenu.append(new gui.MenuItem({ - label: l("menu.file"), - submenu: fileMenu - })); - - // File sub-entries - fileMenu.append(new gui.MenuItem({ - label: l("menu.new"), - click: pdgui.menu_new, - key: "n", - modifiers: cmd_or_ctrl, - tooltip: l("menu.new.tt") - })); - - fileMenu.append(new gui.MenuItem({ - label: l("menu.open"), - key: "o", - modifiers: cmd_or_ctrl, - tooltip: l("menu.open.tt"), - click: function (){ - var input, chooser, - span = w.document.querySelector("#fileDialogSpan"); - // Complicated workaround-- see comment in build_file_dialog_string - input = pdgui.build_file_dialog_string({ - style: "display: none;", - type: "file", - id: "fileDialog", - nwworkingdir: pdgui.get_pwd(), - multiple: null, - // These are copied from pd_filetypes in pdgui.js - accept: ".pd,.pat,.mxt,.mxb,.help" - }); - span.innerHTML = input; - var chooser = w.document.querySelector("#fileDialog"); - chooser.onchange = function() { - var file_array = this.value; - // reset value so that we can open the same file twice - this.value = null; - pdgui.menu_open(file_array); - console.log("tried to open something"); - }; - chooser.click(); - } - })); - - if (pdgui.k12_mode == 1) { - fileMenu.append(new gui.MenuItem({ - label: l("menu.k12.demos"), - tooltip: l("menu.k12.demos_tt"), - click: pdgui.menu_k12_open_demos - })); - } - - fileMenu.append(new gui.MenuItem({ - type: "separator" - })); - - // Note: this must be different for the main Pd window - fileMenu.append(new gui.MenuItem({ - label: l("menu.save"), - click: function () {}, - enabled: false, - key: "s", - tooltip: l("menu.save.tt"), - modifiers: cmd_or_ctrl - })); - - fileMenu.append(new gui.MenuItem({ - label: l("menu.saveas"), - click: function (){}, - enabled: false, - key: "S", - tooltip: l("menu.saveas_tt"), - modifiers: cmd_or_ctrl - })); - - if (pdgui.k12_mode == 0) { - fileMenu.append(new gui.MenuItem({ - type: "separator" - })); - } - - fileMenu.append(new gui.MenuItem({ - label: l("menu.message"), - click: pdgui.menu_send, - key: "m", - modifiers: cmd_or_ctrl, - tooltip: l("menu.message_tt") - })); - - if (pdgui.k12_mode == 0) { - fileMenu.append(new gui.MenuItem({ - type: "separator" - })); - } - - // recent files go here - - // anther separator goes here if there are any recent files - - // Note: there's no good reason to have this here - fileMenu.append(new gui.MenuItem({ - label: l("menu.close"), - click: function () {}, - enabled: false, - })); - - // Quit Pd - fileMenu.append(new gui.MenuItem({ - label: l("menu.quit"), - click: pdgui.menu_quit, - key: "q", - modifiers: cmd_or_ctrl, - tooltip: l("menu.quit_tt") - })); - - - // Edit menu - var editMenu = new gui.Menu(); - - // Add to window menu - windowMenu.append(new gui.MenuItem({ - label: l("menu.edit"), - submenu: editMenu - })); - - // Edit sub-entries - editMenu.append(new gui.MenuItem({ - label: l("menu.copy"), - click: function() { - w.document.execCommand("copy"); - }, - key: "c", - modifiers: cmd_or_ctrl, - tooltip: l("menu.copy_tt") - })); - - editMenu.append(new gui.MenuItem({ - label: l("menu.selectall"), - click: function () { - var container_id = "p1", range; - // This should work across browsers - if (w.document.selection) { - range = w.document.body.createTextRange(); - range.moveToElementText(w.document.getElementById(container_id)); - range.select(); - } else if (w.getSelection) { - range = w.document.createRange(); - range.selectNode(w.document.getElementById(container_id)); - // we need to empty the current selection to avoid a strange - // error when trying to select all right after Pd starts: - // "The given range and the current selection belong to two - // different document fragments." - // (I guess nw.js somehow starts up with the selection being - // somewhere outside the window...) - w.getSelection().empty(); - w.getSelection().addRange(range); - } - }, - key: "a", - modifiers: cmd_or_ctrl, - tooltip: l("menu.selectall_tt") - })); - - editMenu.append(new gui.MenuItem({ - type: "separator" - })); - - editMenu.append(new gui.MenuItem({ - label: l("menu.zoomin"), - click: function () { - gui.Window.get().zoomLevel += 1; - }, - key: "=", - modifiers: cmd_or_ctrl, - tooltip: l("menu.zoomin_tt") - })); - - editMenu.append(new gui.MenuItem({ - label: l("menu.zoomout"), - click: function () { - gui.Window.get().zoomLevel -= 1; - }, - key: "-", - modifiers: cmd_or_ctrl, - tooltip: l("menu.zoomout_tt") - })); - - editMenu.append(new gui.MenuItem({ - type: "separator" - })); - - editMenu.append(new gui.MenuItem({ - label: l("menu.find"), - click: function () { - var find_bar = w.document.getElementById("console_find"), - find_bar_text = w.document.getElementById("console_find_text"), - text_container = w.document.getElementById("console_bottom"), - state = find_bar.style.getPropertyValue("display"); - if (state === "none") { - text_container.style.setProperty("bottom", "1em"); - find_bar.style.setProperty("display", "inline"); - find_bar.style.setProperty("height", "1em"); - text_container.scrollTop = text_container.scrollHeight; - find_bar_text.focus(); - find_bar_text.select(); - } else { - text_container.style.setProperty("bottom", "0px"); - find_bar.style.setProperty("display", "none"); - } - }, - key: "f", - modifiers: cmd_or_ctrl, - tooltip: l("menu.find_tt") - })); - - editMenu.append(new gui.MenuItem({ - label: l("menu.preferences"), - click: pdgui.open_prefs, - key: "p", - modifiers: cmd_or_ctrl, - tooltip: l("menu.preferences_tt") - })); - - - // Windows menu... call it "winman" (i.e., window management) - // to avoid confusion - var winmanMenu = new gui.Menu(); - - // Add to windows menu - windowMenu.append(new gui.MenuItem({ - label: l("menu.windows"), - submenu: winmanMenu - })); - - // Winman sub-entries - winmanMenu.append(new gui.MenuItem({ - label: l("menu.nextwin"), - click: function() { - pdgui.raise_next("pd_window"); - }, - //key: "c", - //modifiers: cmd_or_ctrl, - tooltip: l("menu.nextwin_tt") - })); - - winmanMenu.append(new gui.MenuItem({ - label: l("menu.prevwin"), - click: function() { - pdgui.raise_prev("pd_window"); - }, - //key: "a", - //modifiers: cmd_or_ctrl, - tooltip: l("menu.prevwin_tt") - })); - - // Media menu - var mediaMenu = new gui.Menu(); - - // Add to window menu - windowMenu.append(new gui.MenuItem({ - label: l("menu.media"), - submenu: mediaMenu - })); - - // Media sub-entries - mediaMenu.append(new gui.MenuItem({ - label: l("menu.audio_on"), - click: function() { - pdgui.pdsend("pd dsp 1"); - }, - key: "/", - modifiers: cmd_or_ctrl, - tooltip: l("menu.audio_on_tt") - })); - - mediaMenu.append(new gui.MenuItem({ - label: l("menu.audio_off"), - click: function() { - pdgui.pdsend("pd dsp 0"); - }, - key: ".", - modifiers: cmd_or_ctrl, - tooltip: l("menu.audio_off_tt") - })); - - mediaMenu.append(new gui.MenuItem({ - type: "separator" - })); - - mediaMenu.append(new gui.MenuItem({ - label: l("menu.test"), - click: function() { - pdgui.pd_doc_open("doc/7.stuff/tools", "testtone.pd"); - }, - //key: "a", - //modifiers: cmd_or_ctrl, - tooltip: l("menu.test_tt") - })); - - mediaMenu.append(new gui.MenuItem({ - label: l("menu.loadmeter"), - click: function() { - pdgui.pd_doc_open("doc/7.stuff/tools", "load-meter.pd"); - }, - //key: "a", - //modifiers: cmd_or_ctrl, - tooltip: l("menu.loadmeter_tt") - })); - - // Help menu - var helpMenu = new gui.Menu(); - - // Add to window menu - windowMenu.append(new gui.MenuItem({ - label: l("menu.help"), - submenu: helpMenu - })); - - // Help sub-entries - helpMenu.append(new gui.MenuItem({ - label: l("menu.about"), - click: function() { - pdgui.pd_doc_open("doc/1.manual", "1.introduction.txt"); - }, - //key: "c", - //modifiers: cmd_or_ctrl, - tooltip: l("menu.about_tt") - })); - - helpMenu.append(new gui.MenuItem({ - label: l("menu.manual"), - click: function() { - pdgui.pd_doc_open("doc/1.manual", "index.htm"); - }, - //key: "a", - //modifiers: cmd_or_ctrl, - tooltip: l("menu.manual_tt") - })); - - helpMenu.append(new gui.MenuItem({ - label: l("menu.browser"), - click: function() { - pdmenu_help_browser(w); - }, - //key: "a", - //modifiers: cmd_or_ctrl, - tooltip: l("menu.browser_tt") - })); - - helpMenu.append(new gui.MenuItem({ - type: "separator" - })); - - helpMenu.append(new gui.MenuItem({ - label: l("menu.l2ork_list"), - click: function() { - pdgui.external_doc_open("http://disis.music.vt.edu/listinfo/l2ork-dev"); - }, - //key: "a", - //modifiers: cmd_or_ctrl, - tooltip: l("menu.l2ork_list_tt") - })); - - helpMenu.append(new gui.MenuItem({ - label: l("menu.pd_list"), - click: function() { - pdgui.external_doc_open("http://puredata.info/community/lists"); - }, - //key: "a", - //modifiers: cmd_or_ctrl, - tooltip: l("menu.pd_list_tt") - })); - - helpMenu.append(new gui.MenuItem({ - label: l("menu.forums"), - click: function() { - pdgui.external_doc_open("http://forum.pdpatchrepo.info/"); - }, - //key: "a", - //modifiers: cmd_or_ctrl, - tooltip: l("menu.forums_tt") - })); - - helpMenu.append(new gui.MenuItem({ - label: l("menu.devtools"), - click: function() { - gui.Window.get().showDevTools(); - }, - key: "b", // temporary convenience shortcut-- can change if needed - modifiers: cmd_or_ctrl, - tooltip: l("menu.devtools_tt") - })); - - //helpMenu.append(new gui.MenuItem({ - // label: l("menu.irc"), - // click: function() { - // pdgui.external_doc_open("irc://irc.freenode.net/dataflow"); - // }, - // //key: "a", - // //modifiers: cmd_or_ctrl, - // tooltip: l("menu.irc_tt") - //})); - - // Assign to window - gui.Window.get(w).menu = windowMenu; -} - -exports.nw_create_pd_window_menus = nw_create_pd_window_menus; -- GitLab