Improved handling of case where child is killed by a signal
[tcl-tlc.git] / scripts / browse_treeview_list.itk
bloba208fa9b0485d88c8f9649202fb3dfc482153d24
1 # vim: foldmarker=<<<,>>>
3 option add *Browse_treeview_list.actionsOrient                  v               widgetDefault
4 option add *Browse_treeview_list.actionButtonWidth              1               widgetDefault
5 option add *Browse_treeview_list.actionsPos             {10,11 -fill y} widgetDefault
7 class tlc::Browse_treeview_list {
8         inherit tlc::Mywidget tlc::Handlers
10         constructor {args} {}
11         destructor {}
13         public {
14                 variable state                          "normal"        ;# not currently used
15                 variable textvariable
16                 variable headers                        {}
17                 variable item_schema            {}
18                 variable id_column                      0
20                 method column_configure {args} {return [eval $w.list column_configure $args]}
21         }
23         private {
24                 variable oldtextvariable        ""
25                 variable listlink
26                 variable ds
27                 variable lock                           0
28                 variable afterid                        ""
30                 method newvalue {args}
31                 method newvalue2 {}
32                 method getlist {}
33         }
37 configbody tlc::Browse_treeview_list::textvariable { #<<<1
38         if {$oldtextvariable != ""} {
39                 trace vdelete $oldtextvariable wu [code $this newvalue]
40         }
42         if {$textvariable != ""} {
43                 trace variable $textvariable wu [code $this newvalue]
44         }
46         set oldtextvariable     $textvariable
48         newvalue
52 configbody tlc::Browse_treeview_list::headers { #<<<1
53         $ds configure -headers $headers
57 configbody tlc::Browse_treeview_list::item_schema { #<<<1
58         $ds configure -item_schema $item_schema
62 configbody tlc::Browse_treeview_list::id_column { #<<<1
63         $ds configure -id_column $id_column
67 body tlc::Browse_treeview_list::constructor {args} { #<<<1
68         set ds          [tlc::DSlist ::#auto]
70         itk_component add list {
71                 tlc::Browse_treeview_flat $w.list -datasource $ds
72         } {
73                 keep -hide_id_col -show_criteria -criteriapos -filterpos -actionspos
74                 keep -actions_orient -listpos -criteria_label -showfilter
75                 keep -action_buttonwidth -width -height -column_widths
76         }
78         $w.list action_add "+" add
79         $w.list action_add "-" del
81         table $w \
82                         $w.list                 1,1 -fill both
84         $ds register_handler onchange [code $this newvalue2]
86         eval itk_initialize $args
90 body tlc::Browse_treeview_list::destructor {} { #<<<1
91         if {[info exists ds]} {
92                 delete object $ds
93         }
95         if {$afterid != ""} {
96                 after cancel $afterid;  set afterid     ""
97         }
101 body tlc::Browse_treeview_list::newvalue {args} { #<<<1
102         if {$lock} return
104         set lock        1
105         $ds configure -list [set $textvariable]
106         set lock        0
110 body tlc::Browse_treeview_list::newvalue2 {} { #<<<1
111         invoke_handlers onchange
112         if {$lock} return
113         puts "tlc::Browse_treeview_list::newvalue2"
114         if {$afterid != ""} return
115         set afterid             [after idle [code $this getlist]] 
119 body tlc::Browse_treeview_list::getlist {} { #<<<1
120         puts "tlc::Browse_treeview_list::getlist"
121         after cancel $afterid; set afterid      ""
122         if {$textvariable == ""} return
124         set lock        1
125         set $textvariable       [$ds get_list {}]
126         set lock        0
127         invoke_handlers onchange