TclApps Library Source Code
Check-in [634a4cd47c]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:[wm state] doesn't support zoomed on x11. changed the web browser handling for unix to look for more recent commands line xdg-open and chrome. Avoid the -remote stuff (can still be set manually)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 634a4cd47c4d2cb1ea1ce4e383162a52cd794444
User & Date: patthoyts 2009-12-13 01:23:58.000
Context
2010-01-12
01:45
Fix initialization of the browser list (ferrieux) check-in: bdd206fbe7 user: patthoyts tags: trunk
2009-12-13
01:23
[wm state] doesn't support zoomed on x11. changed the web browser handling for unix to look for more recent commands line xdg-open and chrome. Avoid the -remote stuff (can still be set manually) check-in: 634a4cd47c user: patthoyts tags: trunk
2009-10-15
20:52
Fixed typo in nickchange message check-in: 516d875231 user: patthoyts tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to apps/tkchat/ChangeLog.






1
2
3
4
5
6
7






2009-10-15  Pat Thoyts  <[email protected]>

	* tkchat.tcl: Fix typo spotted by mistachkin.

2009-09-24  Reinhard Max  <[email protected]>

	* tkchat.tcl (::tkchat::Smile): Unset IMGre before reinitializing
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
2009-12-13  Pat Thoyts  <[email protected]>

	* tkchat.tcl: [wm state] doesn't support zoomed on x11.
	* tkchat.tcl: change web browser handling to look for a more
	modern list of commands and avoid the old -remote stuff.

2009-10-15  Pat Thoyts  <[email protected]>

	* tkchat.tcl: Fix typo spotted by mistachkin.

2009-09-24  Reinhard Max  <[email protected]>

	* tkchat.tcl (::tkchat::Smile): Unset IMGre before reinitializing
Changes to apps/tkchat/tkchat.tcl.
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
    }
}

namespace eval ::tkchat {
    variable chatWindowTitle "The Tcler's Chat"

    variable HEADUrl {http://tcllib.cvs.sourceforge.net/*checkout*/tcllib/tclapps/apps/tkchat/tkchat.tcl?revision=HEAD}
    variable rcsid   {$Id: tkchat.tcl,v 1.476 2009/10/15 20:52:14 patthoyts Exp $}

    variable MSGS
    set MSGS(entered) [list \
	    "%user% has entered the chat!" \
	    "Out of a cloud of smoke, %user% appears!" \
	    "%user% saunters in." \
	    "%user% wanders in." \







|







275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
    }
}

namespace eval ::tkchat {
    variable chatWindowTitle "The Tcler's Chat"

    variable HEADUrl {http://tcllib.cvs.sourceforge.net/*checkout*/tcllib/tclapps/apps/tkchat/tkchat.tcl?revision=HEAD}
    variable rcsid   {$Id: tkchat.tcl,v 1.477 2009/12/13 01:23:58 patthoyts Exp $}

    variable MSGS
    set MSGS(entered) [list \
	    "%user% has entered the chat!" \
	    "Out of a cloud of smoke, %user% appears!" \
	    "%user% saunters in." \
	    "%user% wanders in." \
409
410
411
412
413
414
415

416
417
418
419
420
421
422
    }
    return $w
}

proc ::tkchat::Dialog {w args} {
    lappend args -class Dialog
    set dlg [eval [linsert $args 0 Toplevel $w]]

    wm transient $dlg [winfo parent $dlg]
    wm group $dlg .
    return $dlg
}

# trace handler to set the log level whenever Options(LogLevel) is changed
# enable the selected level and above







>







409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
    }
    return $w
}

proc ::tkchat::Dialog {w args} {
    lappend args -class Dialog
    set dlg [eval [linsert $args 0 Toplevel $w]]
    catch {wm attributes $w -type dialog}
    wm transient $dlg [winfo parent $dlg]
    wm group $dlg .
    return $dlg
}

# trace handler to set the log level whenever Options(LogLevel) is changed
# enable the selected level and above
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565



1566

1567
1568
1569
1570
1571
1572
1573
1574
1575
1576

1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593

1594
1595
1596





1597







1598
1599
1600
1601
1602
1603
1604

    global tcl_platform Options

    # this code from  http://purl.org/mini/tcl/557.html
    switch -- $tcl_platform(platform) {
	"unix" {
	    # special case for MacOS X:
	    if {$tcl_platform(os) == "Darwin"} {
		# assume all goes well:
		set notOK 0
		if { $Options(Browser) ne "" } {
		    set notOK \
			    [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 {
		    $Options(Browser) ne ""
		    || [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 {
		    if {$Options(BrowserTab)} {
			exec $Options(Browser) -remote "openURL($url,new-tab)" 2> /dev/null
		    } else {
		    	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"
			}
		    }





		}







	    }
	}
	"windows" {
	    # DDE uses commas to separate command parts
	    set url [string map {, %2c} $url]

	    # See if we can use dde and an existing browser. Firefox, Opera and IE all







|















|
|
|
>
>
>
|
>
|
|
|
|
|
|
|
<
<
<
>
|
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
|
>
|
|
|
>
>
>
>
>
|
>
>
>
>
>
>
>







1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578



1579
1580



1581











1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606

    global tcl_platform Options

    # this code from  http://purl.org/mini/tcl/557.html
    switch -- $tcl_platform(platform) {
	"unix" {
	    # special case for MacOS X:
	    if {$tcl_platform(os) eq "Darwin"} {
		# assume all goes well:
		set notOK 0
		if { $Options(Browser) ne "" } {
		    set notOK \
			    [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 {
                # List of browsers to search for if not specified.
                set Browsers {
                    "Use default browser" xdg-open ""
                    "Mozilla Firefox" firefox "-new-tab"
                    "Google Chrome" google-chrome ""
                    "Opera" opera "-newtab"
                    "Gnome Web Browser" gnome-www-browser "--new-tab"
                }
                
                if {$Options(Browser) eq ""} {
                    foreach {display cmd arg} $Browsers {
                        if {[findExecutable $exe cmd]} {
                            set Options(Browser) "$cmd $arg"
                        }
                    }



                }




                if {$Options(Browser) eq ""} {











                    tk_messageBox -icon error -title "No browser defined" \
                        -message "No web browser could be found. Please go to\
                        the Options dialog and select a browser to use."
                }

                # permit stuff like '-remote openURL(%url,new-tab)'
                if {[string first "%url" $Options(Browser)] != -1} {
                    set cmd [string map [list %url [list $url]] $Options(Browser)]
                } else {
                    set cmd [list $Options(Browser) $url]
                }
                if {[catch {
                    log::log debug "open url with '$cmd'"
                    eval exec $cmd &
                } err]} {
                    tk_messageBox -icon error -title "Error opening browser" \
                        -message "Error displaying $url in browser\n$err"
                }
	    }
	}
	"windows" {
	    # DDE uses commas to separate command parts
	    set url [string map {, %2c} $url]

	    # See if we can use dde and an existing browser. Firefox, Opera and IE all
2991
2992
2993
2994
2995
2996
2997



2998

2999
3000
3001
3002
3003
3004
3005
    if { $::tcl_platform(os) eq "Windows CE" } {
	wm geometry . 240x300+0+0
    } else {
	wm geometry . $Options(Geometry)
    }
    wm deiconify .
    if { [info exists Options(StartZoomed)] && $Options(StartZoomed) == 1 } {



	wm state . zoomed

    }

    update
    if {[info exists $Options(Pane)] && [llength $Options(Pane)] == 2 } {
	if {$useTile} {
		eval [linsert $Options(Pane) 0 .pane sashpos 0]
	} else {







>
>
>
|
>







2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
    if { $::tcl_platform(os) eq "Windows CE" } {
	wm geometry . 240x300+0+0
    } else {
	wm geometry . $Options(Geometry)
    }
    wm deiconify .
    if { [info exists Options(StartZoomed)] && $Options(StartZoomed) == 1 } {
        if {[tk windowingsystem] eq "x11"} {
            wm attributes . -zoomed 1
        } else {
            wm state . zoomed
        }
    }

    update
    if {[info exists $Options(Pane)] && [llength $Options(Pane)] == 2 } {
	if {$useTile} {
		eval [linsert $Options(Pane) 0 .pane sashpos 0]
	} else {
5466
5467
5468
5469
5470
5471
5472



5473


5474
5475




5476
5477
5478
5479
5480
5481
5482
5483
5484
	return
    }

    set rcfile [file join $::env(HOME) .tkchatrc]
    array set tmp [GetDefaultOptions]

    # Options that need to be computed at save time



    if { [wm state .] eq "zoomed" } {


	    set Options(StartZoomed) 1
	    wm state . normal




    } else {
	    set Options(StartZoomed) 0
    }
    set Options(Geometry) [wm geometry .]
    if {[package provide khim] ne {}} {
	set Options(Khim) [::khim::getConfig]
    }
    if { [winfo exists .pane] && $Options(DisplayUsers) } {
	if {$useTile} {







>
>
>
|
>
>
|
|
>
>
>
>

|







5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
	return
    }

    set rcfile [file join $::env(HOME) .tkchatrc]
    array set tmp [GetDefaultOptions]

    # Options that need to be computed at save time
    if {[tk windowingsystem] eq "x11"} {
        set zoomed [wm attributes . -zoomed]
    } else {
        set zoomed [expr {[wm state .] eq "zoomed"}]
    }
    if { $zoomed } {
        set Options(StartZoomed) 1
        wm state . normal
        if {[tk windowingsystem] eq "x11"} {
            wm attributes . -zoomed 0
            update
        }
    } else {
        set Options(StartZoomed) 0
    }
    set Options(Geometry) [wm geometry .]
    if {[package provide khim] ne {}} {
	set Options(Khim) [::khim::getConfig]
    }
    if { [winfo exists .pane] && $Options(DisplayUsers) } {
	if {$useTile} {