# ------------------------------------------------------------ # ::qw::dialog::status # ------------------------------------------------------------ /* { */ } ::itcl::class ::QW::STATUS { public common destroyed 0; protected variable _toplevel {}; protected variable _text_widget {}; protected variable _options ""; protected variable _line_count 0; protected variable _max_line_count 100; method option_get {Path} {::return [::sargs::get_poly $_options $Path];} method option_set {args} { ::qw::s_args_marshal; ::sargs::var::+= _options $s_args; } method constructor {args} { ::set _options [::sargs::+= $::qw::widget::options [::subst { .title "Status of [::string tolower [::info nameofexecutable]]" }]]; ::set _toplevel [::toplevel .qw_status_window_[::qw::id_factory]]; ::wm title $_toplevel [option_get .title]; ::set _text_widget [::iwidgets::scrolledtext $_toplevel.[::qw::id_factory] \ -textfont [option_get .font] \ -foreground [option_get .foreground] \ -textbackground [option_get .background] \ -hscrollmode [option_get /scroll/horizontal.mode] \ -vscrollmode [option_get /scroll/vertical.mode] \ -wrap none \ ]; ::grid $_text_widget -sticky news -padx 4 -pady 4; ::grid columnconfigure $_toplevel 0 -weight 1; ::grid rowconfigure $_toplevel 0 -weight 1; #::wm protocol $_toplevel WM_DELETE_WINDOW [::list ::qw::itcl_delete_object $this]; #209 ::wm protocol $_toplevel WM_DELETE_WINDOW [::list ::rename $this {}]; ::wm protocol $_toplevel WM_DELETE_WINDOW [::list ::itcl::delete object $this]; ::set ::qw::status::window $this; } destructor { ::destroy $_toplevel; ::set ::qw::status::_toplevel ""; ::set ::qw::status::window ""; ::set ::qw::status::window_destroyed 1; # ::update idletasks; } method toplevel {} {::return $_toplevel;} method raise {} { ::raise $_toplevel; } method append {Text} { $_text_widget configure -state normal; ::if {$_max_line_count>0} { ::while {$_line_count>$_max_line_count} { # Yes this is the way you delete a line in a text widget. $_text_widget delete 1.0 2.0; ::incr _line_count -1; } } $_text_widget insert end "$Text\n"; ::incr _line_count; $_text_widget see end; $_text_widget configure -state disabled; update; } } ::namespace eval ::qw::status {} ::set ::qw::status::window ""; ::set ::qw::status::window_destroyed 0; ::proc ::qw::status::raise {Arg} { ::qw::status::puts $Arg; ::if {$::qw::status::window ne ""} { $::qw::status::window raise; } ::return $Arg; } ::proc ::qw::status::puts {Arg} { ::if {!$::qw::verbose(status)} { ::return ""; } ::set Message "[::qw::date::from_number clock_second [::clock seconds]] $Arg"; ::puts "::qw::status::puts:$Message"; ::if {$::qw::status::window eq ""} { ::if {$::qw::status::window_destroyed} { ::return $Arg; } ::if {[[::qw::system] cpp_is_shutting_get]} { /* { We crashed (gp) when someone (i.e. transaction decompress script), had been using the status window, we shut down, and then, with ::qw::verbose(status) now set to true, the cpp shutdown code in qw_dll.cpp attempted to write to the status window, i.e. to put out the fact that we were shutting down. It is too late to attempt to create a status window at this time because some libraries needed (iwidgets) have been de-initialized. */ } ::return $Arg; } ::QW::STATUS [::qw::id_factory]; } # else { # ::if {![::winfo exists $::qw::status::window]} { # ::return; # } # } $::qw::status::window append $Message; ::return $Arg; } ::proc ::qw::status::destroy {} { ::if {[::winfo exists $::qw::status::window]} { #::qw::itcl_delete_object $::qw::status::window; #209 ::rename $::qw::status::window {}; ::itcl::delete object $::qw::status::window; ::set ::qw::status::destroyed 1; ::set ::qw::status::window ""; } }