Tk Library Source Code

Artifact [68b9a3886f]
Login

Artifact 68b9a3886f5608086400d2838fd810509e32538e:

Attachment "tkchat-diff-u.txt" to ticket [1344350fff] added by treincke 2005-11-01 05:47:11.
--- tkchat.vfs/bin/tkchat.tcl	2005-10-31 23:27:59.000000000 +0100
+++ tkchat-patched.tcl	2005-10-31 23:32:28.000000000 +0100
@@ -1158,34 +1158,52 @@
     # this code from  http://purl.org/mini/tcl/557.html
     switch -- $tcl_platform(platform) {
 	"unix" {
-	    expr {
-		[info exists Options(BROWSER)]
-		|| [findExecutable mozilla		Options(BROWSER)]
-		|| [findExecutable mozilla-firefox	Options(BROWSER)]
-		|| [findExecutable mozilla-firebird	Options(BROWSER)]
-		|| [findExecutable konqueror		Options(BROWSER)]
-		|| [findExecutable netscape		Options(BROWSER)]
-		|| [findExecutable iexplorer		Options(BROWSER)]
-		|| [findExecutable lynx			Options(BROWSER)]
-	    }
+	    # special case for MacOS X:
+	    if {$tcl_platform(os) == "Darwin"} {
+		    # assume all goes well:
+		    set notOK 0
+		    if {[info exists Options(BROWSER)]} {
+			    set noOK [catch {exec open -a $Options(BROWSER) $url} emsg]
+			    
+		    }
+		    if {$notOK} {
+		    	# Safari should always be there:
+			set notOK [catch {exec open -a Safari $url} emsg]
+			if {$notOK} {
+				tk_messageBox -message \
+					"Error displaying $url in browser\n$emsg"
+			}
+		    }
+	    } else {
+		expr {
+		    [info exists Options(BROWSER)]
+		    || [findExecutable mozilla		Options(BROWSER)]
+		    || [findExecutable mozilla-firefox	Options(BROWSER)]
+		    || [findExecutable mozilla-firebird	Options(BROWSER)]
+		    || [findExecutable konqueror		Options(BROWSER)]
+		    || [findExecutable netscape		Options(BROWSER)]
+		    || [findExecutable iexplorer		Options(BROWSER)]
+		    || [findExecutable lynx			Options(BROWSER)]
+		}
 
-	    # lynx can also output formatted text to a variable
-	    # with the -dump option, as a last resort:
-	    # set formatted_text [ exec lynx -dump $url ] - PSE
-	    #
-	    # -remote argument might need formatting as a command
-	    # 		Try that first
-	    if { [catch {
-		exec $Options(BROWSER) -remote openURL($url) 2> /dev/null
-	    }] } then {
-		# Try -remote with raw URL argument
+		# lynx can also output formatted text to a variable
+		# with the -dump option, as a last resort:
+		# set formatted_text [ exec lynx -dump $url ] - PSE
+		#
+		# -remote argument might need formatting as a command
+		# 		Try that first
 		if { [catch {
-		    exec $Options(BROWSER) -remote $url 2> /dev/null
-		}]} then {
-		    # perhaps browser doesn't understand -remote flag
-		    if { [catch { exec $Options(BROWSER) $url & } emsg] } {
-			tk_messageBox -message \
-				"Error displaying $url in browser\n$emsg"
+		    exec $Options(BROWSER) -remote openURL($url) 2> /dev/null
+		}] } then {
+		    # Try -remote with raw URL argument
+		    if { [catch {
+			exec $Options(BROWSER) -remote $url 2> /dev/null
+		    }]} then {
+			# perhaps browser doesn't understand -remote flag
+			if { [catch { exec $Options(BROWSER) $url & } emsg] } {
+			    tk_messageBox -message \
+				    "Error displaying $url in browser\n$emsg"
+			}
 		    }
 		}
 	    }