From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tom Tromey To: Insight List Subject: Patch: view menu -vs- multiple source windows Date: Wed, 06 Dec 2000 15:56:00 -0000 Message-id: <87ofypnleq.fsf@creche.redhat.com> X-SW-Source: 2000-q4/msg00385.html This patch adds support for multiple source windows to the View menu. It requires my earlier multiple source window patch (not yet approved). The idea here is that each available source window is listed on the view menu. Also, an "Open Another Source Window" command is added to the view menu. 2000-12-06 Tom Tromey * toolbar.tcl (create_view_menu): Call _post_menu before View menu is posted. Added command to open another source window. (_post_menu): New method. Tom Index: toolbar.tcl =================================================================== RCS file: /cvs/src/src/gdb/gdbtk/library/toolbar.tcl,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 toolbar.tcl --- toolbar.tcl 2000/02/07 00:19:42 1.1.1.1 +++ toolbar.tcl 2000/12/06 23:53:57 @@ -605,7 +605,8 @@ # ------------------------------------------------------------------ method create_view_menu {} { - new_menu view "View" 0 + set vmenu [new_menu view "View" 0] + $vmenu configure -postcommand [code $this _post_menu $vmenu] add_menu_command Other "Stack" {ManagedWin::open StackWin} \ -underline 0 -accelerator "Ctrl+S" @@ -638,7 +639,7 @@ add_menu_command Other "Console" {ManagedWin::open Console} \ -underline 2 -accelerator "Ctrl+N" - + add_menu_command Other "Function Browser" {ManagedWin::open BrowserWin} \ -underline 1 -accelerator "Ctrl+F" add_menu_command Other "Thread List" {ManagedWin::open ProcessWin} \ @@ -648,6 +649,17 @@ add_menu_command Other "Debug Window" {ManagedWin::open DebugWin} \ -underline 3 -accelerator "Ctrl+U" } + + # Note that the layout from here down is relied on in _post_menu. + add_menu_separator + # This is a dummy entry that will be overwritten when the menu is + # posted for the first time. + add_menu_command Other "Source Window" \ + {ManagedWin::open SrcWin} + + add_menu_separator + add_menu_command Other "Open Another Source Window" \ + {ManagedWin::open SrcWin -force} -underline 0 } # ------------------------------------------------------------------ @@ -771,6 +783,43 @@ global gdb_kod_cmd set gdb_kod_cmd $value + } + } + + # ------------------------------------------------------------------ + # METHOD: _post_menu - Called when View menu posted + # ------------------------------------------------------------------ + method _post_menu {menu} { + # We search from the bottom of the window. Source window entries + # appear between the last two separators. + set index [$menu index end] + set firstSep -1 + set lastSep -1 + while {$index >= 0} { + if {[$menu type $index] == "separator"} { + if {$lastSep == -1} { + set lastSep [expr {$index - 1}] + } else { + set firstSep [expr {$index + 1}] + break + } + } + incr index -1 + } + + if {$index == -1} { + error "programming error in _post_menu" + } + + $menu delete $firstSep $lastSep + foreach src [ManagedWin::find SrcWin] { + set file [$src get_file] + if {$file == ""} { + set file "Source Window" + } + $menu insert $firstSep command -label $file \ + -command [list $src reveal] + incr firstSep } }