Index: tkgnats.config
#######  => 
*** /tkgnats.config	Fri Feb 26 15:03:08 1999
--- tkgnats.config	Mon Apr 26 15:14:57 1999
***************
*** 45,46 ****
--- 45,50 ----
+ 
+ # Yes or No
+ set TkGnats(HierMode) "yes"
  
  #set TkGnats(GNATS_BINDIR)	/dir/not/in/my/path
                                  # Set this if the GNATS programs query-pr 
Index: tkpr_library.tcl
#######  => 
*** /tkpr_library.tcl	Fri Feb 26 15:03:08 1999
--- tkpr_library.tcl	Mon Apr 26 15:02:10 1999
***************
*** 1,3 ****
--- 1,87 ----
+ 
+ proc SetCategory {Cat} {
+   global TkGnats Query Category Category_regexp
+ 
+   set Category $Cat;
+   
+   if {([info exists Category_regexp]) && ([winfo exists $Category_regexp])} {
+     $Category_regexp._RegExp.text delete 0 end;
+     if {$Cat != "''"} {
+       $Category_regexp._RegExp.text insert 0 $Cat;
+     }
+   } elseif {[winfo exists .eboxs.clb.cat.ent]} {
+     .eboxs.clb.cat.ent delete 0 end;
+     .eboxs.clb.cat.ent insert 0 $Cat;
+   }
+ }
+ 
+ proc CreateHierCatButtons {p ParentCat level category_list} {
+   # global TkGnats Query Category Category_regexp
+ 
+   if {$level < 0} {
+     set level 0;
+   }
+   foreach w [winfo children $p] {
+     if {[regexp {\.fl[0-9]$} $w]} {
+       pack forget $w;
+     }
+   }
+   catch "destroy $p.fl$level";
+   set f [frame $p.fl$level -height 500];
+   pack $f;
+   foreach Cat $category_list {
+     set asCatPath [split $Cat "-"];
+     set CatName [lindex $asCatPath $level]
+     if {   ($CatName != "") && (![info exists asCats($CatName)]) \
+         && (($ParentCat == "TOP") || ([regexp "$ParentCat-$CatName" $Cat]))} {
+       lappend tmpList "$CatName";
+       set asCats($CatName) $Cat;
+     }
+   }
+   if {! [info exists tmpList]} {
+     set iMaxW 4;
+   } else {
+ #    set iMaxW [expr 2 + [get_max_strlen $tmpList]]
+     set iMaxW [get_max_strlen $tmpList]
+   }
+ 
+   set MyF [frame $f.f1];
+   pack $MyF -side left -fill both;
+   set iNumSubFrames 1;
+   set iNumButtons 0;
+   if {$ParentCat != "TOP"} {
+     set iNumButtons [expr $iNumButtons + 1]
+     regsub -- {-[^-]+$} $ParentCat {} Cat
+     if {$level == 1} {
+       button $MyF.b_BackLevel -text ".." -width $iMaxW \
+           -command "SetCategory {};CreateHierCatButtons $p {TOP} 0 {$category_list}";
+     } else {
+       button $MyF.b_BackLevel -text ".." -width $iMaxW \
+           -command "SetCategory $Cat;CreateHierCatButtons $p {$Cat} [expr $level - 1] {$category_list}";
+     }
+     pack $MyF.b_BackLevel;
+ 
+   }
+   if {! [info exists tmpList]} {
+     return;
+   }
+ 
+   foreach CatName $tmpList {
+     if {$iNumButtons == 5} {
+       set iNumSubFrames [expr $iNumSubFrames + 1];
+       set MyF [frame $f.f$iNumSubFrames];
+       pack $MyF -side left -fill both;
+       set iNumButtons 0;
+     }
+     button $MyF.b_$asCats($CatName) -text $CatName -width $iMaxW \
+         -command "SetCategory $asCats($CatName);CreateHierCatButtons $p $asCats($CatName) [expr $level + 1] {$category_list}";
+     pack $MyF.b_$asCats($CatName);
+     set iNumButtons [expr $iNumButtons + 1]
+   }
+ 
+ }
+ 
+ 
  proc dputs {text} {
      global env tcl_platform
      if {$tcl_platform(platform) == "unix"} {
Index: tkquerypr.tcl
#######  => 
*** /tkquerypr.tcl	Fri Feb 26 15:03:08 1999
--- tkquerypr.tcl	Thu Apr 29 14:09:37 1999
***************
*** 128,133 ****
--- 128,150 ----
          Closed-Date   " %-10s" \
          Synopsis      " %s"    \
  ]
+ array set list_flds_default_lengths  [list \
+         Number        6    \
+         Submitter-Id  8  \
+         Originator    10 \
+         Responsible   11 \
+         Category      16 \
+         Class         5  \
+         Confidential  4  \
+         State         9  \
+         Priority      8  \
+         Severity      12 \
+         Release       28 \
+         Arrival-Date  10 \
+         Last-Modified 10 \
+         Closed-Date   10 \
+         Synopsis      0 \
+ ]
  
  array set list_flds_defaults  [list \
          Number        " Number"     \
***************
*** 298,303 ****
--- 315,344 ----
      }
  }
  
+ proc category_hierbox {parent} {
+     global TkGnats Query Category Category_regexp
+     if {![winfo exists $parent.cat]} {
+         set wid [expr 2 + [get_max_strlen $TkGnats(CategoryList)]]
+         
+         frame   $parent.cat -width 400 -height 400
+         pack    $parent.cat -side top -expand yes -fill both
+         button  $parent.cat.tit -anchor center -text "Category:" \
+                 -command "helpMsg Category" -relief flat -padx 0 -pady 0 -borderwidth 0
+         pack    $parent.cat.tit -side top -fill x
+         
+         frame   $parent.cat.cat 
+         pack    $parent.cat.cat -side top
+         frame   $parent.reg
+         pack    $parent.reg -side top -fill x
+         
+         lappend Query(tlist) [singletext $parent.reg "RegExp" 10 "" 7]
+         set Category_regexp $parent.reg
+     }
+     CreateHierCatButtons $parent.cat.cat "TOP" 0 $TkGnats(CategoryList);
+ }
+ 
+ 
+ 
  proc category_listbox {parent} {
      global TkGnats Query Category Category_regexp
  
***************
*** 556,561 ****
--- 597,603 ----
  proc set_query_view_fields {} {
      global Query list_flds_selected list_flds_heading
      set_query_view_heading
+     set list_flds_heading [string trimright $list_flds_heading " "];
      .qlb.query.label configure -text $list_flds_heading
  }
  
***************
*** 986,991 ****
--- 1028,1036 ----
  proc load_query_listbox { s {re {}}} {
      global TkGnats $s
      case $s Category {
+ 	if {$TkGnats(HierMode) == "yes"} {
+ 	    return;
+ 	}
  	set lb .eboxs.clb.cat
  	set ew .eboxs.clb
      } Submitter {
***************
*** 1213,1219 ****
      }
  
      # Query listboxes
!     category_listbox    .eboxs.clb
      submitter_listbox   .eboxs.slb
      responsible_listbox .eboxs.rlb
      textset RegExp ""   .eboxs.clb.reg
--- 1258,1268 ----
      }
  
      # Query listboxes
!     if {$TkGnats(HierMode) == "yes"} {
!       category_hierbox    .eboxs.clb
!     } else {
!       category_listbox    .eboxs.clb
!     }
      submitter_listbox   .eboxs.slb
      responsible_listbox .eboxs.rlb
      textset RegExp ""   .eboxs.clb.reg
***************
*** 1253,1259 ****
  
  proc query_fill_listbox {} {
      global TkGnats Query Mappings \
!             lbpath list_flds_formats list_flds_format list_flds_list list_flds_selected
  
      if {![info exists Query(PrList)]} {
          return
--- 1302,1309 ----
  
  proc query_fill_listbox {} {
      global TkGnats Query Mappings \
!             lbpath list_flds_formats list_flds_format list_flds_list \
! 	    list_flds_selected list_flds_default_lengths;
  
      if {![info exists Query(PrList)]} {
          return
***************
*** 1277,1282 ****
--- 1327,1420 ----
      $lbpath delete 0 end; # clear current list
      set c 0
      set Query(maxlen) 0
+     
+     array set list_flds_lengths [array get list_flds_default_lengths];
+     
+     foreach ln $Query(PrList) {
+ 	if {"$ln" == ""} {
+ 	    continue
+ 	}
+ 	#
+ 	# XXX TBD BUG XXX there is a problemo here if the synopsis
+ 	# has a '|' character in it..
+ 	#
+ 	set l    [split $ln "|"]
+ 	set llen [llength $l]
+         set len  16
+         if {$TkGnats(ReleaseBased)} {
+             incr len 3
+         }
+ 	if {$llen != $len} {
+             Msg "tkquerypr: Line $ln has $llen fields. It should have $len fields.\n" \
+                     "Have the GNATS administrator check the index file for bogus entries. (Especially for |'s in any of the text fields)"
+ 	    continue
+ 	}
+ 
+         if {$Query(query_mode) == "sql2"} {
+             set flds(Number)        [lindex $l  0]
+             set flds(Category)      [lindex $l  1]
+             set flds(Synopsis)      [lindex $l  2]
+             set flds(Confidential)  [lindex $l  3]
+             set flds(Severity)      [lindex $l  4]
+             set flds(Priority)      [lindex $l  5]
+             set flds(Responsible)   [lindex $l  6]
+             set flds(State)         [lindex $l  7]
+             set flds(Class)         [lindex $l  8]
+             set flds(Submitter-Id)  [lindex $l  9]
+             set flds(Arrival-Date)  [lindex $l 10]
+             set flds(Originator)    [lindex $l 11]
+             set flds(Release)       [lindex $l 12]
+             set flds(Last-Modified) [lindex $l 13]
+             set flds(Closed-Date)   [lindex $l 14]
+             if {$TkGnats(ReleaseBased)} {
+                 set flds($TkGnats(Quarter)) [lindex $l 15]
+                 set flds(Keywords)          [lindex $l 16]
+                 set flds(Date-Required)     [lindex $l 17]
+             }
+         } {
+             set flds(Number)        [string trimright [lindex $l  0] " "]
+             set flds(Category)      [string trimright [lindex $l  1] " "]
+             set flds(Synopsis)      [string trimright [lindex $l  2] " "]
+             set flds(Confidential)  [string trimright [lindex $l  3] " "]
+             set flds(Severity)      [string trimright [lindex $l  4] " "]
+             set flds(Priority)      [string trimright [lindex $l  5] " "]
+             set flds(Responsible)   [string trimright [lindex $l  6] " "]
+             set flds(State)         [string trimright [lindex $l  7] " "]
+             set flds(Class)         [string trimright [lindex $l  8] " "]
+             set flds(Submitter-Id)  [string trimright [lindex $l  9] " "]
+             set flds(Arrival-Date)  [string trimright [lindex $l 10] " "]
+             set flds(Originator)    [string trimright [lindex $l 11] " "]
+             set flds(Release)       [string trimright [lindex $l 12] " "]
+             set flds(Last-Modified) [string trimright [lindex $l 13] " "]
+             set flds(Closed-Date)   [string trimright [lindex $l 14] " "]
+             if {$TkGnats(ReleaseBased)} {
+                 set flds($TkGnats(Quarter)) [string trimright [lindex $l 15] " "]
+                 set flds(Keywords)          [string trimright [lindex $l 16] " "]
+                 set flds(Date-Required)     [string trimright [lindex $l 17] " "]
+             }
+         }
+         
+ 	# re-map the numeric fields into text
+ 	foreach f {State Priority Severity Class} {
+ 	    set flds($f) [lindex $Mappings($f) [expr "$flds($f) - 1"]]
+ 	}
+ 	for {set i 0} {$i < [llength $list_flds_list]} {incr i 2} {
+ 	    set x [lindex $list_flds_list $i];
+ 	    if {   ([ info exists list_flds_lengths($x)]) \
+                 && ([string length $flds($x)] > $list_flds_lengths($x))} {
+               set list_flds_lengths($x) [string length $flds($x)];
+             }
+ 	}
+ 
+     }
+     foreach x [array names list_flds_formats] {
+ 	if {$x == "Number"} {
+ 	    continue;
+ 	}
+ 	set list_flds_formats($x) " %-$list_flds_lengths($x)s";
+     }
+     set_query_view_fields;
+     
      foreach ln $Query(PrList) {
  	incr c
  	if {"$ln" == ""} {
***************
*** 1349,1355 ****
  	foreach f {State Priority Severity Class} {
  	    set flds($f) [lindex $Mappings($f) [expr "$flds($f) - 1"]]
  	}
- 
          #####   "%5d %-11s %-16s %-5s %-9s %-8s %-12s %s"
          
          # list_flds_format doesn't seem to be used anymore?
--- 1487,1492 ----
***************
*** 1823,1829 ****
  
  frame .eboxs
  frame .eboxs.clb -relief groove -borderwidth 2
! set   cbpath [category_listbox    .eboxs.clb]
  frame .eboxs.slb -relief groove -borderwidth 2
  set   sbpath [submitter_listbox   .eboxs.slb]
  frame .eboxs.rlb -relief groove -borderwidth 2
--- 1960,1970 ----
  
  frame .eboxs
  frame .eboxs.clb -relief groove -borderwidth 2
! if {$TkGnats(HierMode) == "yes"} {
!   set   cbpath [category_hierbox    .eboxs.clb]
! } else {
!   set   cbpath [category_listbox    .eboxs.clb]
! }  
  frame .eboxs.slb -relief groove -borderwidth 2
  set   sbpath [submitter_listbox   .eboxs.slb]
  frame .eboxs.rlb -relief groove -borderwidth 2
Index: tksendpr.tcl
#######  => 
*** /tksendpr.tcl	Fri Feb 26 15:03:08 1999
--- tksendpr.tcl	Mon Apr 26 15:02:11 1999
***************
*** 255,278 ****
              -relief sunken -borderwidth 2 -background $TkGnats(EditFieldBackground) -highlightthickness 2 \
              -textvariable Category]
      lappend Tksendpr(tlist) $ew
-     trace variable Category w set_snd_category_ew
      set_focus_style $ew
      bind $ew <BackSpace> { tkEntrySetCursor %W [%W index insert] }
      bind $ew <Control-h> { tkEntrySetCursor %W [%W index insert] }
      set height [llength $category_list]
      if {$height > 6 } {
!         set height 6
      }
      scrollbar $p.cat.sb -command "$p.cat.list yview" -borderwidth 2 -relief sunken
      listbox $p.cat.list -yscroll "$p.cat.sb set" -setgrid 1 -relief sunken -borderwidth 2 \
!             -width $Category_wid -height $height -exportselection false
      eval   $p.cat.list insert end $category_list
-     pack   $p.cat.msg  -side left  -anchor n
-     pack   $p.cat.ent  -side left  -anchor n
-     pack   $p.cat.sb   -side left  -fill y
-     pack   $p.cat.list -side right -fill both -expand true
      bind   $p.cat.list <B1-ButtonRelease> "set_snd_category $p.cat.ent %W %y"
!     return $p.cat.list
  }
  
  proc snd_submitter_listbox {p submitters_list} {
--- 255,285 ----
              -relief sunken -borderwidth 2 -background $TkGnats(EditFieldBackground) -highlightthickness 2 \
              -textvariable Category]
      lappend Tksendpr(tlist) $ew
      set_focus_style $ew
      bind $ew <BackSpace> { tkEntrySetCursor %W [%W index insert] }
      bind $ew <Control-h> { tkEntrySetCursor %W [%W index insert] }
+ 
+   pack   $p.cat.msg  -side left  -anchor n
+   pack   $p.cat.ent  -side left  -anchor n
+   if {$TkGnats(HierMode) == "yes"} {
+     frame $p.cat.list
+     #      pack  $p.cat.list -side right -fill both -expand true
+     CreateHierCatButtons $p.cat.list "TOP" 0 $category_list;
+   } else {
+     trace variable Category w set_snd_category_ew
      set height [llength $category_list]
      if {$height > 6 } {
!       set height 6
      }
      scrollbar $p.cat.sb -command "$p.cat.list yview" -borderwidth 2 -relief sunken
      listbox $p.cat.list -yscroll "$p.cat.sb set" -setgrid 1 -relief sunken -borderwidth 2 \
! 	-width $Category_wid -height $height -exportselection false
      eval   $p.cat.list insert end $category_list
      bind   $p.cat.list <B1-ButtonRelease> "set_snd_category $p.cat.ent %W %y"
!     pack   $p.cat.sb   -side left  -fill y
!   }
!   pack   $p.cat.list -side right -fill both -expand true
!   return $p.cat.list
  }
  
  proc snd_submitter_listbox {p submitters_list} {
