Ignore:
Timestamp:
Aug 18, 2010, 2:55:15 PM (14 years ago)
Author:
mmc
Message:

Fixed the bug report dialog so that it adjusts its height properly,
even on Windows and even with Tk8.4. Also, added a "comments" area
where the user can add comments to the bug report. Tweaked the fonts
to look better on Windows.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/bugreport.tcl

    r1861 r1864  
    1111#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    1212# ======================================================================
     13option add *BugReport*Label.font {Helvetica -12} startupFile
    1314option add *BugReport*banner*foreground white startupFile
    1415option add *BugReport*banner*background #a9a9a9 startupFile
    1516option add *BugReport*banner*highlightBackground #a9a9a9 startupFile
    16 option add *BugReport*banner*font \
    17     -*-helvetica-bold-r-normal-*-18-* startupFile
    18 option add *BugReport*Label.font \
    19     -*-helvetica-medium-r-normal-*-12-* startupFile
     17option add *BugReport*banner.title.font {Helvetica -18 bold} startupFile
    2018option add *BugReport*xmit*wrapLength 3i startupFile
    2119option add *BugReport*expl.width 50 startupFile
    22 option add *BugReport*expl.font \
    23     -*-helvetica-medium-r-normal-*-12-* startupFile
    24 option add *BugReport*expl.boldFont \
    25     -*-helvetica-bold-r-normal-*-12-* startupFile
     20option add *BugReport*expl.font {Helvetica -12} startupFile
     21option add *BugReport*expl.boldFont {Helvetica -12 bold} startupFile
     22option add *BugReport*comments.l.font {Helvetica -12 italic} startupFile
     23option add *BugReport*comments.info.text.font {Helvetica -12} startupFile
     24option add *BugReport*details*font {Courier -12} startupFile
    2625
    2726namespace eval Rappture::bugreport {
     
    6463        pack .bugreport.details -after .bugreport.banner \
    6564            -expand yes -fill both -padx 8 -pady 8
     65        pack .bugreport.comments -after .bugreport.details \
     66            -expand yes -fill both -padx 8 -pady {0 8}
    6667        return
    6768    }
     
    7576    pack .bugreport.expl -after .bugreport.banner \
    7677        -expand yes -fill both -padx 8 -pady 8
     78    pack .bugreport.comments -after .bugreport.expl \
     79        -expand yes -fill both -padx 8 -pady {0 8}
    7780
    7881    .bugreport.expl configure -state normal
     
    8689    } else {
    8790        .bugreport.expl insert end "Something went wrong with this tool.  We would ask you to submit a trouble report about the error, but we can't tell what hub it should be submitted to.  If you continue having trouble with this tool, please close it and restart."
     91        pack forget .bugreport.comments
    8892        .bugreport.cntls.send configure -state disabled
    8993        focus .bugreport.cntls.ok
     
    110114    set h [winfo reqheight .bugreport]
    111115    set x [expr {([winfo screenwidth .bugreport]-$w)/2}]
    112     set y [expr {([winfo screenheight .bugreport]-$w)/2}]
     116    if {$x < 0} {set x 0}
     117    set y [expr {([winfo screenheight .bugreport]-$h)/2}]
     118    if {$y < 0} {set y 0}
    113119
    114120    wm geometry .bugreport +$x+$y
     
    146152    pack forget .bugreport.details
    147153    pack forget .bugreport.expl
     154    pack forget .bugreport.comments
    148155    pack forget .bugreport.cntls
    149156    pack .bugreport.xmit -after .bugreport.banner -padx 8 -pady 8
     
    278285    http::register https 443 ::tls::socket
    279286
     287    set report $details(stackTrace)
     288    set cmts [string trim [.bugreport.comments.info.text get 1.0 end]]
     289    if {[string length $cmts] > 0} {
     290        set report "$cmts\n[string repeat = 72]\n$report"
     291    }
     292
    280293    set query [http::formatQuery \
    281294        option com_support \
    282295        task create \
    283296        no_html 1 \
    284         report $details(stackTrace) \
     297        report $report \
    285298        login $details(login) \
    286299        sesstoken $details(session) \
     
    298311    }
    299312
    300 #    set token [http::geturl $url -query $query -timeout 60000]
    301 
    302 #    if {[http::ncode $token] != 200} {
    303 #       error [http::code $token]
    304 #    }
    305 #    upvar #0 $token rval
    306 #    set info $rval(body)
    307 #    http::cleanup $token
    308 set info "foo bar"
     313    set token [http::geturl $url -query $query -timeout 60000]
     314
     315    if {[http::ncode $token] != 200} {
     316        error [http::code $token]
     317    }
     318    upvar #0 $token rval
     319    set info $rval(body)
     320    http::cleanup $token
    309321
    310322    if {[regexp {Ticket #[0-9]* +\(.*?\) +[0-9]+ +times} $info match]} {
     
    321333# ----------------------------------------------------------------------
    322334proc Rappture::bugreport::fixTextHeight {widget} {
    323     for {set h 1} {$h < 50} {incr h} {
    324         $widget configure -height $h
    325         $widget see 1.0
    326         update idletasks
    327         if {"" != [$widget bbox end-1char]} {
    328             break
    329         }
     335    #
     336    # HACK ALERT!  In Tk8.5, we can count display lines directly.
     337    #   But for earlier versions, we have to cook up something
     338    #   similar.
     339    #
     340    if {[catch {$widget count -displaylines 1.0 end} h] == 0 && $h > 0} {
     341        $widget configure -height $h
     342    } else {
     343        for {set h 1} {$h < 15} {incr h} {
     344            $widget configure -height $h
     345            $widget see 1.0
     346            update idletasks
     347            if {"" != [$widget bbox end-1char]} {
     348                break
     349            }
     350        }
    330351    }
    331352}
     
    396417    Rappture::bugreport::deactivate
    397418
    398 text .bugreport.expl -borderwidth 0 -highlightthickness 0 -wrap word
     419set bg [.bugreport cget -background]
     420text .bugreport.expl -borderwidth 0 -highlightthickness 0 -background $bg \
     421    -height 3 -wrap word
    399422.bugreport.expl tag configure bold \
    400423    -font [option get .bugreport.expl boldFont Font]
     424#
     425# HACK ALERT!  We have problems with fixTextHeight working correctly
     426#   on Windows for Tk8.4 and earlier.  To make it work properly, we
     427#   add the binding below.  At some point, we'll ditch 8.4 and we can
     428#   use the new "count -displaylines" option in Tk8.5.
     429#
     430bind .bugreport.expl <Map> {Rappture::bugreport::fixTextHeight %W}
     431
     432frame .bugreport.comments
     433label .bugreport.comments.l -text "What were you doing just before this error?" -anchor w
     434pack .bugreport.comments.l -side top -anchor w
     435Rappture::Scroller .bugreport.comments.info -xscrollmode none -yscrollmode auto
     436text .bugreport.comments.info.text -width 30 -height 3 -wrap word
     437.bugreport.comments.info contents .bugreport.comments.info.text
     438bind .bugreport.comments.info.text <ButtonPress> {focus %W}
     439pack .bugreport.comments.info -expand yes -fill both
    401440
    402441frame .bugreport.cntls
Note: See TracChangeset for help on using the changeset viewer.