summaryrefslogtreecommitdiff
path: root/gdb/gdbtk/library/browserwin.itb
blob: d8f42db6faa4e0b1a65ce2f4aa9872ea7a8b8d19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
# Browswer window for Insight.
# Copyright (C) 1998, 1999, 2001, 2002, 2003 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License (GPL) as published by
# the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.


# ----------------------------------------------------------------------
# Implements Browser window for Insight
#
# ----------------------------------------------------------------------

option add *BrowserWin.textBackground  $::Colors(textbg)

# ------------------------------------------------------------------
#  CONSTRUCTOR - create new browser window
# ------------------------------------------------------------------
itcl::body BrowserWin::constructor {args} {
  debug
  #eval itk_initialize $args 
  window_name "Function Browser"

  set _layout [pref get gdb/browser/layout]
  set Current(filename) {}
  set Current(function) {}
  _build_win

  eval itk_initialize $args
  add_hook file_changed_hook [code $this _fill_file_box]
}

# ------------------------------------------------------------------
#  DESTRUCTOR - destroy window containing widget
# ------------------------------------------------------------------
itcl::body BrowserWin::destructor {} {
  debug
  if {$filter_trace_after != ""} {
    after cancel $filter_trace_after
  }

  remove_hook file_changed_hook [code $this _fill_file_box]
  trace vdelete [pref varname gdb/search/last_symbol] \
    w [code $this _filter_trace_proc]
}

# ------------------------------------------------------------------
#  METHOD:  _build_win - build the main browser window
# ------------------------------------------------------------------
itcl::body BrowserWin::_build_win {} {
  debug

  # popup menu
  itk_component add popup {
    menu $itk_interior.pop -tearoff 0
  } {}
  set pop $itk_component(popup)
  $pop add command -label "Toggle Layout" -command [code $this _switch_layout]
  $pop add command -label "Help" -command "open_help browser.html"
  $pop add separator
  $pop add command -label "Close" -command "destroy [winfo toplevel $itk_interior]"
  bind [winfo toplevel $itk_interior] <3> "tk_popup $itk_component(popup) %X %Y"

  # Four Main Frames: filter, files, functions, and view (source)
  # Their layout depends on _layout

  if {$_layout == 1} {
    set p [cyg::panedwindow $itk_interior.p -orient vertical -height 5i \
	     -width 5i]
    $p add left
    set p2 [cyg::panedwindow [$p childsite left].p]
   
    $p2 add file
    _build_file_frame [$p2 childsite file]

    $p2 add filter
    set f [frame [$p2 childsite filter].f]
    _build_filter_frame $f
    _build_function_frame $f
    pack $f -fill both -expand yes
    pack $p2 -fill both -expand yes

    $p add view
    _build_view_frame [$p childsite view]

  } else {
    set p [cyg::panedwindow $itk_interior.p -height 5i -width 5i]
    $p add top
    set f [frame [$p childsite top].f]
    _build_filter_frame $f

    set browser [cyg::panedwindow $f.p -orient vertical]
    $browser add file
    _build_file_frame [$browser childsite file]
    $browser add function
    _build_function_frame [$browser childsite function]

    pack $browser -fill both -expand yes
    pack $f -fill both -expand yes

    $p add view
    _build_view_frame [$p childsite view]
  }
  
  # Fill file box
  _fill_file_box

  pack $p -fill both -expand yes
}

# ------------------------------------------------------------------
#  METHOD:  _filter_trace_proc
#           This is called when something is entered in the filter
#           box.  The actual filtering is done in an after to avoid
#           flashing too much if the user is typing quickly.
# ------------------------------------------------------------------
itcl::body BrowserWin::_filter_trace_proc {v1 v2 mode} {
  if {$filter_trace_after != ""} {
    after cancel $filter_trace_after
  }
  set filter_trace_after [after 100 [code $this _filter_trace_after]]
}

# ------------------------------------------------------------------
#  METHOD:  _filter_trace_after
#           This is a wrapper around search, needed to pass to trace
# ------------------------------------------------------------------
itcl::body BrowserWin::_filter_trace_after {} {
  set filter_trace_after ""
  search
}

# ------------------------------------------------------------------
#  METHOD:  _search_src
#           Search for text or jump to a specific line
#           in source window, going in the specified DIRECTION.
# ------------------------------------------------------------------
itcl::body BrowserWin::_search_src {direction} {
  set exp [$itk_component(view_search) get]
  $itk_component(view_src) search $exp $direction
}

# ------------------------------------------------------------------
#  METHOD:  search
#           Search for functions matching regexp/pattern
#           in specified files
# ------------------------------------------------------------------
itcl::body BrowserWin::search {} {

  set files [$itk_component(file_box) getcurselection]

  if {[llength $files] == 0} {
    return
  }

  _freeze_me

  set filt_pat [format $filter_regexp($cur_filter_mode) \
		  [pref get gdb/search/last_symbol]]

  if {[llength $files] == [$itk_component(file_box) size]} {
    set err [catch {gdb_search functions $filt_pat \
		    -filename 1} matches]
  } else {
    set err [catch {gdb_search functions $filt_pat \
		      -files $files -filename 1} matches]
  }

  if {$err} {
    debug "ERROR searching for [pref get gdb/search/last_symbol]: $matches"
    _thaw_me
    return
  }

  $itk_component(func_box) delete 0 end

  set i -1
  catch {unset index_to_file}

  foreach func [lsort -command "list_element_strcmp 0" $matches] {
    $itk_component(func_box) insert end [lindex $func 0]
    set index_to_file([incr i]) [lindex $func 1]
  }
  _thaw_me
}

# ------------------------------------------------------------------
#  METHOD:  _process_file_selection
#            This fills the func combo, and the more window if it
#            is currently open with the hit in the File combobox.
# ------------------------------------------------------------------
itcl::body BrowserWin::_process_file_selection {y} {

  set curIndex [$itk_component(file_box) nearest $y]
  set curSelection [$itk_component(file_box) curselection]

  # We got a button-release - First make sure the click selected the item...

  if {[lsearch $curIndex $curSelection] >= 0} {
    _fill_source [$itk_component(file_box) get $curIndex] 0
  } else {
    # If the item was deselected, go back to the first one in the list...
    # It would be better to keep a stack of the clicked items, and go to the
    # last one on the stack.  But in extended mode, this is tricky.  FIXME

    if {[llength $curSelection] > 0} {
      _fill_source [$itk_component(file_box) get [lindex $curSelection 0]] 0
    } else {
      _fill_source ""
    }
  }

  search
}

# ------------------------------------------------------------------
#  METHOD:  _process_func_selection
#            This points the  more window to the hit in the Func combobox
#            if it is currently open.
# ------------------------------------------------------------------
itcl::body BrowserWin::_process_func_selection {y} {

  set curIndex [$itk_component(func_box) nearest $y]
  set curSelection [$itk_component(func_box) curselection]

  # We got a button-release - First make sure the click selected the item...

  if {[lsearch $curIndex $curSelection] >= 0} {
    set funcName [$itk_component(func_box) get $curIndex]
    set fileName $index_to_file($curIndex)
    _fill_source $funcName 1 $fileName
  }
}

# ------------------------------------------------------------------
#  METHOD:  do_all_bp
#           Toggle a bp at every selected function in FuncLB
# ------------------------------------------------------------------
itcl::body BrowserWin::do_all_bp {onp} {

  set funcs [$itk_component(func_box) getcurselection]
  _freeze_me

  foreach f $funcs {
    if {[catch {gdb_loc $f} linespec]} {
      dbug W "Could not gdb_loc \"$f\""
      return
    }
    set bpnum [bp_exists $linespec]
    if {$bpnum == -1 && $onp} {

      # FIXME: gdb_set_bp is the preferred method, but it requires
      # a file and line number. This doesn't work very well for
      # templates...
      gdb_cmd "break $f"
    } elseif {!$onp} {
      catch {gdb_cmd "delete $bpnum"}
    }
  }
  _thaw_me
}

# ------------------------------------------------------------------
#  METHOD:  _toggle_bp
#           Toggle bp at function specified by the given Y
#           coordinate in the listbox
# ------------------------------------------------------------------
itcl::body BrowserWin::_toggle_bp {y} {

  set f [$itk_component(func_box) get [$itk_component(func_box) nearest $y]]
  if {$f != ""} {
    if {[catch {gdb_loc $f} linespec]} {
      return
    }
    set bpnum [bp_exists $linespec]
    if {$bpnum == -1} {	
      # FIXME: gdb_set_bp is the preferred method, but it requires
      # a file and line number. This doesn't work very well for
      # templates...
      gdb_cmd "break $f"
    } else {
      catch {gdb_cmd "delete $bpnum"}
    }
  }
}

# ------------------------------------------------------------------  
#  METHOD:  _select
#           Un/Highlight all files in the files list
# ------------------------------------------------------------------  
itcl::body BrowserWin::_select {highlight} {
  if {$highlight} {
    $itk_component(file_box) selection set 0 end
  } else {
    $itk_component(file_box) selection clear 0 end
  }
  search
}

# ------------------------------------------------------------------  
#  METHOD:  _set_filter_mode
#           React to changes in the filter mode
# ------------------------------------------------------------------  
itcl::body BrowserWin::_set_filter_mode {w mode} {
  if {[string compare $mode $cur_filter_mode] != 0} {
    set cur_filter_mode $mode
    pref set gdb/search/filter_mode $mode
    search
  }
}

# ------------------------------------------------------------------
#  METHOD:  _file_hide_h
#           Run when the "Hide .h files" preference is chosen.
# ------------------------------------------------------------------
itcl::body BrowserWin::_file_hide_h {} {
  _fill_file_box
  search
}

# ------------------------------------------------------------------
#  METHOD:  _fill_source
#           Helper function to fill the srctextwin
#           when needed.
# ------------------------------------------------------------------
itcl::body BrowserWin::_fill_source {f {funcp 1} {filename ""}} {
  if {($funcp && [string compare $f $Current(function)]) \
	|| [string compare $f $Current(filename)]} {
    if {!$funcp} {
      if {$filename == ""} {
	set f $f:1
      } else {
	set f $f:$filename
      }
    }

    if {[catch {gdb_loc $f} linespec]} {
      return
    }

    lassign $linespec foo funcname name line addr pc_addr lib
    set file_changed [string compare $Current(filename) $name]

    if {$file_changed} {
      # Set the file name label:
      $itk_component(view_name) configure -text $name:
      _freeze_me
    }

    # fill srctextwin
    $itk_component(view_src) location BROWSE_TAG $name $funcname \
      $line $addr $pc_addr lib

    if {$file_changed} {
      _thaw_me
    }

    set Current(function) $funcname
    # fill func combo
    if {$file_changed} {
      set Current(filename) $name
      _fill_funcs_combo $name
    }
    # Set current function in combo box
    $itk_component(view_func) entryset $f
  }
}

# ------------------------------------------------------------------
#  METHOD:  mode
#           Function called by srctextwin when the display
#           mode changes
# ------------------------------------------------------------------
itcl::body BrowserWin::mode {w {mode ""} {go 1}} {
  if {$mode != ""} {
    $itk_component(view_src) mode_set $mode $go
    $itk_component(view_mode) entryset $mode
  }
}

# ------------------------------------------------------------------
# METHOD:  _goto_func
#          Callback for the function combo box which
#          sets the srctextwin looking at the given function (VAL)
# ------------------------------------------------------------------
itcl::body BrowserWin::_goto_func {w {val ""}} {
  if {$val != ""} {
    set mang 0
    if {[info exists _mangled_func($val)]} {
      set mang $_mangled_func($val)
    }
    if {$mang} {
      set loc $val
    } else {
      set fn [lindex [::file split $Current(filename)] end]
      set loc $fn:$val
    }
    debug "GOTO \"$loc\""
    if {![catch {gdb_loc $loc} result]} {
      lassign $result foo funcname name line addr pc_addr lib
      $itk_component(view_src) location BROWSE_TAG $name $funcname \
	$line $addr $pc_addr lib
    } else {
      dbug W "gdb_loc returned \"$result\""
    }
  }
}

# ------------------------------------------------------------------
#  METHOD:  _fill_file_box
#           This private method fills the file listbox
# ------------------------------------------------------------------
itcl::body BrowserWin::_fill_file_box {} {
  # It would be cool if gdb_listfiles took a regexp to match,
  # but it doesn't...

  $itk_component(file_box) clear
  set allFiles [gdb_listfiles]

  if {[pref get gdb/browser/hide_h]} {
    foreach file $allFiles {
      if {[string compare [file extension $file] ".h"]} {
	$itk_component(file_box) insert end $file
      }
    }
  } else {
    foreach file $allFiles {
      $itk_component(file_box) insert end $file
    } 
  }
  search
}

# ------------------------------------------------------------------
#  METHOD:  _fill_funcs_combo
#           This private method fills the functions combo box
#           with all the functions in NAME.
# ------------------------------------------------------------------
itcl::body BrowserWin::_fill_funcs_combo {name} {

  $itk_component(view_func) list delete 0 end
  if {$name != ""} {
    set maxlen 10
    if {[catch {gdb_listfuncs $name} listfuncs]} {
      tk_messageBox -icon error -default ok \
	-title "GDB" -type ok \
	-message "This file can not be found or does not contain\ndebugging information."
      return
    }
    foreach f [lsort $listfuncs] {
      lassign $f func mang
      if {$func == "global constructors keyed to main"} {continue}
      set _mangled_func($func) $mang
      $itk_component(view_func) list insert end $func
      if {[string length $func] > $maxlen} {
	set maxlen [string length $func]
      }
    }
    # limit size to 40 chars because if we don't set a reasonable limit
    # then the combobox can be wider than the screen
    if {$maxlen > 40} {set maxlen 40}

    $itk_component(view_func) configure -width [expr {$maxlen + 1}]
  }
}

# ------------------------------------------------------------------
#  METHOD:  _build_filter_frame
#	This private method builds the filter frame
# ------------------------------------------------------------------
itcl::body BrowserWin::_build_filter_frame {parent} {
  
  itk_component add filter {
    iwidgets::labeledframe $parent.filter -labeltext "Function Filter" \
      -relief groove -borderwidth 2 -ipadx 6 -ipady 4
  }

  # Set up the contents of the Filter frame
  if {$_layout == 2} {
    itk_component add filt_label {
      label [$itk_component(filter) childsite].lbl -text "Show if function " \
	-font global/fixed
    }
  }

  itk_component add filt_type {
    combobox::combobox [$itk_component(filter) childsite].type -height 4 \
      -width 15 -editable 0 \
      -command [code $this _set_filter_mode] \
      -font global/fixed
  } { 
    rename -background -textbackground textBackground Background
  }

  # Fill the filter mode combo-box
  foreach elem $filter_modes {
    $itk_component(filt_type) list insert end $elem
  }

  set cur_filter_mode [pref get gdb/search/filter_mode]
  if {[lsearch $filter_modes $cur_filter_mode] < 0} {
    set cur_filter_mode [lindex $filter_modes 0]
  }
  $itk_component(filt_type) entryset $cur_filter_mode

  itk_component add filt_entry {
    entry [$itk_component(filter) childsite].ent -font global/fixed \
      -textvariable [pref varname gdb/search/last_symbol] 
  } {}
  bind_plain_key $itk_component(filt_entry) Return [list $this search]

  # Watch keystrokes into the entry box and filter on them...
  trace variable [pref varname gdb/search/last_symbol] w \
    [code $this _filter_trace_proc]

  if {$_layout == 2} {
    pack $itk_component(filt_label) -side left 
  }
  pack $itk_component(filt_type) -side left -padx 4 -fill y -pady 5
  pack $itk_component(filt_entry) -side right -fill both -expand 1 \
    -padx 6 -pady 5

  pack $itk_component(filter) -fill x -anchor n -pady 3
}

# ------------------------------------------------------------------
#  METHOD:  _build_file_frame
#	This private method builds the files frame
# ------------------------------------------------------------------
itcl::body BrowserWin::_build_file_frame {parent} {

  # Labeled Frame
  itk_component add file_frame {
    iwidgets::labeledframe $parent.file -labeltext "Files" \
      -relief groove -borderwidth 2 -ipadx 6 -ipady 4
  }

  # Listbox with files
  itk_component add file_box {
    iwidgets::scrolledlistbox  [$itk_component(file_frame) childsite].listbox \
      -selectmode extended -exportselection false \
      -hscrollmode dynamic -vscrollmode dynamic -foreground $::Colors(textfg) \
      -textbackground $::Colors(textbg)
  } {}

  bind [$itk_component(file_box) component listbox] <ButtonRelease-1> \
    [code $this _process_file_selection %y]

  itk_component add file_sep {
    frame [$itk_component(file_frame) childsite].sep -relief raised -height 2 \
      -borderwidth 1
  }

  itk_component add file_hide {
    checkbutton [$itk_component(file_frame) childsite].hide \
      -text "Hide .h files" \
      -variable [pref varname gdb/browser/hide_h] \
      -command [code $this _file_hide_h]
  }

  itk_component add file_all {
    button [$itk_component(file_frame) childsite].sel \
      -text "Select All" \
      -command [code $this _select 1]
  }

  # pack all the pieces
  grid $itk_component(file_box) -column 0 -row 0 -columnspan 2 \
    -sticky news
  grid $itk_component(file_sep) -column 0 -row 1 -columnspan 2 \
    -sticky ew -pady 8
  grid $itk_component(file_hide) -column 0 -row 2 -padx 5 -sticky w
  grid $itk_component(file_all) -column 1 -row 2 -padx 5 -sticky e

  grid columnconfigure [$itk_component(file_frame) childsite] 0 -weight 1
  grid rowconfigure [$itk_component(file_frame) childsite] 0 -weight 1

  # finally pack the main frame
  pack $itk_component(file_frame) -side left -fill both -expand yes
}

# ------------------------------------------------------------------
#  METHOD:  _build_function_frame
#	This private method builds the functions frame
# ------------------------------------------------------------------
itcl::body BrowserWin::_build_function_frame {parent} {

  # Labeled Frame
  itk_component add func_frame {
    iwidgets::labeledframe $parent.file -labeltext "Function" \
      -relief groove -borderwidth 2 -ipadx 6 -ipady 4
  }

  # Functions Listbox
  itk_component add func_box {
    iwidgets::scrolledlistbox [$itk_component(func_frame) childsite].listbox \
      -selectmode extended -hscrollmode dynamic -vscrollmode dynamic \
      -exportselection false -foreground $::Colors(textfg) \
      -textbackground $::Colors(textbg)
  } {}
	    
  bind [$itk_component(func_box) component listbox] <ButtonRelease-1> \
    [code $this _process_func_selection %y]
  bind $itk_component(func_box) <3> [code $this _toggle_bp %y]

  itk_component add func_sep {
    frame [$itk_component(func_frame) childsite].sep -relief raised \
      -height 2 -borderwidth 1
  }
	
  itk_component add func_add_bp {   
    button [$itk_component(func_frame) childsite].abp -text "Set BP" \
      -command [code $this do_all_bp 1]
  }

  itk_component add func_remove_bp {
    button [$itk_component(func_frame) childsite].rbp -text "Delete BP" \
      -command [code $this do_all_bp 0]
  }

  # pack all the pieces
  grid $itk_component(func_box) -column 0 -row 0 -columnspan 2 -sticky news
  grid $itk_component(func_sep) -row 1 -column 0 -columnspan 2 \
    -sticky ew -pady 8
  grid $itk_component(func_remove_bp) -row 2 -column 0 -padx 5 -sticky w
  grid $itk_component(func_add_bp) -row 2 -column 1  -padx 5 -sticky e

  grid columnconfigure [$itk_component(func_frame) childsite] 0 -weight 1
  grid rowconfigure [$itk_component(func_frame) childsite] 0 -weight 1

  # finally pack the main frame
  pack $itk_component(func_frame) -fill both -expand yes
}

# ------------------------------------------------------------------
#  METHOD:  _build_view_frame
#	This private method builds the view frame
# ------------------------------------------------------------------
itcl::body BrowserWin::_build_view_frame {parent} {
  itk_component add view {
    frame $parent.view
  }

  itk_component add view_src {
    SrcTextWin $itk_component(view).src -Tracing 0 \
      -parent $this -ignore_var_balloons 0
  } {
    rename -background -textbackground textBackground Background
  }

  itk_component add view_bottom {
    frame $itk_component(view).bottom
  }

  itk_component add view_name {
    label $itk_component(view).name -font global/fixed
  }

  itk_component add view_func {
    combobox::combobox $itk_component(view_bottom).combo -maxheight 15\
      -font global/fixed -command [code $this _goto_func]
  } {
    rename -background -textbackground textBackground Background
  }
  
  itk_component add view_mode {
    combobox::combobox $itk_component(view_bottom).mode -width 9 \
      -font global/fixed -command [code $this mode]
  } {
    rename -background -textbackground textBackground Background
  }

  itk_component add view_search {
    entry $itk_component(view_bottom).search -borderwidth 2 \
      -font global/fixed -width 10 -background $::Colors(textbg)
  } {}

  # Pack all the components of view into the frame:
  pack $itk_component(view_func) -side left -anchor w
  pack $itk_component(view_mode) -side left -padx 5
  pack $itk_component(view_search) -side right -padx 5 -expand 1 -anchor e
  pack $itk_component(view_name) -side top -fill x -padx 5 -pady 3
  pack $itk_component(view_bottom) -side bottom -fill x -pady 3 -padx 5
  pack $itk_component(view_src) -fill both -expand 1 -padx 5 -pady 3
  
  # Fill combo boxes
  $itk_component(view_mode) list insert end SOURCE
  $itk_component(view_mode) list insert end ASSEMBLY
  $itk_component(view_mode) list insert end MIXED
  # don't allow SRC+ASM mode... $itk_component(view_mode) insert end SRC+ASM
  $itk_component(view_mode) entryset [$itk_component(view_src) mode_get]

  # Key bindings
  bind_plain_key $itk_component(view_search) Return \
    [code $this _search_src forwards]
  bind_plain_key $itk_component(view_search) Shift-Return \
    [code $this _search_src backwards]

  pack  $itk_component(view) -fill both -expand yes
}

# ------------------------------------------------------------------
#  METHOD:  _switch_layout
#           Switch between different layouts
#
# ------------------------------------------------------------------
itcl::body BrowserWin::_switch_layout {} {
  # only 2 right now, so toggle
  if {$_layout == 1} {
    set _layout 2
  } else {
    set _layout 1
  }
  pref set gdb/browser/layout $_layout
  destroy $itk_interior.p
  destroy $itk_component(popup)
  set Current(filename) {}
  set Current(function) {}
  if {$filter_trace_after != ""} {
    after cancel $filter_trace_after
  }
  trace vdelete [pref varname gdb/search/last_symbol] \
    w [code $this _filter_trace_proc]
  _build_win
}