summarylogtreecommitdiffstats
path: root/menu_openfile.patch
blob: 4dcc8e8793a8c19996394b937662bfbcb26a59c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
diff --git a/pd/src/pd_menus_SHORT.tcl b/pd/src/pd_menus_SHORT.tcl
index 929e985..5a7a8f1 100644
--- a/pd/src/pd_menus_SHORT.tcl
+++ b/pd/src/pd_menus_SHORT.tcl
@@ -90,4 +90,27 @@ proc ::pd_menus::update_recentfiles_on_menu {mymenu {write}} {
     }
     # write to config file
     if {$write == true} { ::pd_guiprefs::write_recentfiles }
-}
\ No newline at end of file
+}
+
+# for compatibility with vanilla (menu_openfile command)
+namespace eval ::pd_menucommands:: {
+    namespace export menu_*
+}
+
+# open HTML docs from the menu using the OS-default HTML viewer
+proc ::pd_menucommands::menu_openfile {filename} {
+    if {$::tcl_platform(os) eq "Darwin"} {
+        exec sh -c [format "open '%s'" $filename]
+    } elseif {$::tcl_platform(platform) eq "windows"} {
+        exec rundll32 url.dll,FileProtocolHandler [format "%s" $filename] &
+    } else {
+        foreach candidate { gnome-open xdg-open sensible-browser iceweasel firefox \
+                                mozilla galeon konqueror netscape lynx } {
+            set browser [lindex [auto_execok $candidate] 0]
+            if {[string length $browser] != 0} {
+                exec -- sh -c [format "%s '%s'" $browser $filename] &
+                break
+            }
+        }
+    }
+}