public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
* Patch: view menu -vs- multiple source windows
@ 2000-12-06 15:56 Tom Tromey
  2000-12-06 20:25 ` Syd Polk
  0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2000-12-06 15:56 UTC (permalink / raw)
  To: Insight List

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  <tromey@redhat.com>

	* 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
     }
   }
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2000-12-07 12:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-12-06 15:56 Patch: view menu -vs- multiple source windows Tom Tromey
2000-12-06 20:25 ` Syd Polk
2000-12-06 23:37   ` Fernando Nasser
2000-12-07  8:38     ` Tom Tromey
2000-12-07  9:03       ` Fernando Nasser
2000-12-07 12:07   ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).