Commit fb9d3390 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

add interface for opening an external document in an external browser/app

parent c60038a0
......@@ -11,6 +11,9 @@ pdgui.set_pwd(pwd);
pdgui.set_gui_dir(gui_dir);
pdgui.set_pd_window(this);
pdgui.set_app_quitfn(app_quit);
pdgui.set_open_html_fn(open_html);
pdgui.set_open_textfile_fn(open_textfile);
pdgui.set_open_external_doc_fn(open_external_doc);
// gui preset
pdgui.skin.apply(this);
......@@ -23,6 +26,18 @@ function app_quit () {
gui.App.quit();
}
function open_html(target) {
gui.Shell.openItem(target);
}
function open_textfile(target) {
gui.Shell.openItem(target);
}
function open_external_doc(target) {
gui.Shell.openExternal(target);
}
var chooser = document.querySelector("#fileDialog");
chooser.addEventListener("change", function(evt) {
var file_array = this.value;
......@@ -627,7 +642,7 @@ function nw_create_pd_window_menus () {
helpMenu.append(new gui.MenuItem({
label: l("menu.about"),
click: function() {
// pd_doc_open("doc/1.manual", "1.introduc
pdgui.pd_doc_open("doc/1.manual", "1.introduction.txt");
},
//key: "c",
//modifiers: "ctrl",
......@@ -636,7 +651,9 @@ function nw_create_pd_window_menus () {
helpMenu.append(new gui.MenuItem({
label: l("menu.manual"),
click: pdmenu_manual,
click: function() {
pdgui.pd_doc_open("doc/1.manual", "index.htm");
},
//key: "a",
//modifiers: "ctrl",
tooltip: l("menu.manual_tt")
......@@ -656,7 +673,9 @@ function nw_create_pd_window_menus () {
helpMenu.append(new gui.MenuItem({
label: l("menu.l2ork_list"),
click: pdmenu_l2ork_mailinglist,
click: function() {
pdgui.external_doc_open("http://disis.music.vt.edu/listinfo/l2ork-dev");
},
//key: "a",
//modifiers: "ctrl",
tooltip: l("menu.l2ork_list_tt")
......@@ -664,7 +683,9 @@ function nw_create_pd_window_menus () {
helpMenu.append(new gui.MenuItem({
label: l("menu.pd_list"),
click: pdmenu_pd_mailinglists,
click: function() {
pdgui.external_doc_open("http://puredata.info/community/lists");
},
//key: "a",
//modifiers: "ctrl",
tooltip: l("menu.pd_list_tt")
......@@ -672,19 +693,23 @@ function nw_create_pd_window_menus () {
helpMenu.append(new gui.MenuItem({
label: l("menu.forums"),
click: pdmenu_forums,
click: function() {
pdgui.external_doc_open("http://forum.pdpatchrepo.info/");
},
//key: "a",
//modifiers: "ctrl",
tooltip: l("menu.forums_tt")
}));
helpMenu.append(new gui.MenuItem({
label: l("menu.irc"),
click: pdmenu_irc,
//key: "a",
//modifiers: "ctrl",
tooltip: l("menu.irc_tt")
}));
//helpMenu.append(new gui.MenuItem({
// label: l("menu.irc"),
// click: function() {
// pdgui.external_doc_open("irc://irc.freenode.net/dataflow");
// },
// //key: "a",
// //modifiers: "ctrl",
// tooltip: l("menu.irc_tt")
//}));
// Assign to window
gui.Window.get().menu = windowMenu;
......
......@@ -40,6 +40,9 @@ exports.set_pd_window = function(win) {
var nw_create_window;
var nw_close_window;
var nw_app_quit;
var nw_open_html;
var nw_open_textfile;
var nw_open_external_doc;
exports.set_new_window_fn = function (nw_context_fn) {
nw_create_window = nw_context_fn;
......@@ -49,6 +52,18 @@ exports.set_close_window_fn = function (nw_context_fn) {
nw_close_window = nw_context_fn;
}
exports.set_open_html_fn = function (nw_context_fn) {
nw_open_html = nw_context_fn;
}
exports.set_open_textfile_fn = function (nw_context_fn) {
nw_open_textfile = nw_context_fn;
}
exports.set_open_external_doc_fn = function (nw_context_fn) {
nw_open_external_doc = nw_context_fn;
}
// Global variables from tcl
var pd_myversion, // Pd version string
pd_apilist, // Available Audio APIs (tcl list)
......@@ -515,6 +530,14 @@ function gui_open_files_via_unique(filenames)
}
}
function open_html(target) {
nw_open_html(target);
}
function open_textfile(target) {
nw_open_textfile(target);
}
// Think about renaming this and pd_doc_open...
// Open a file-- html, text, or Pd.
......@@ -523,11 +546,12 @@ function doc_open (dir, basename) {
var norm_path = path.normalize(dir);
if (basename.slice(-4) === ".txt"
|| basename.slice(-2) === ".c") {
open_text(path.join(norm_path, basename));
open_textfile(path.join(norm_path, basename));
} else if (basename.slice(-5) === ".html"
|| basename.slice(-4) === ".htm"
|| basename.slice(-4) === ".pdf") {
open_html(path.join(norm_path, basename));
} else {
pdsend("pd open", enquote(basename), enquote(norm_path));
}
......@@ -540,6 +564,12 @@ function pd_doc_open(dir, basename) {
exports.pd_doc_open = pd_doc_open;
function external_doc_open(url) {
nw_open_external_doc(url);
}
exports.external_doc_open = external_doc_open;
function gui_build_filelist(file) {
startup_files.push(file);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment