summaryrefslogtreecommitdiff
path: root/gdb/gdbtk
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2001-08-03 18:46:41 +0000
committerKeith Seitz <keiths@redhat.com>2001-08-03 18:46:41 +0000
commit24777862a1074cb33e262c65b697047c28a3b99a (patch)
treeca01ed5d5ffb47942943d28eec437ac639025e18 /gdb/gdbtk
parentdd69757619fc77049e9199a70febb91ae90e6911 (diff)
downloadgdb-24777862a1074cb33e262c65b697047c28a3b99a.tar.gz
* library/srcbar.itcl (_post): New method.
(_update_file_menu): New method. (create_file_menu): Move the guts to _update_file_menu. Add a post command to the menu. * library/interface.tcl (gdbtk_tcl_file_changed): Catch the call to run_hooks. (gdbtk_tcl_exec_file_display): Save the new session, too. (set_exe_name): Don't bother saving the session here. (_close_file): Save the session here, too. (gdbtk_clear_file): Catch the call to run_hooks, too. * library/gdbmenubar.itcl (menubar_new_menu): Allow caller to specify optional arguments to be passed to Tk when creating the menu. Tk's "menu add" command returns an empty string. Save the menu's index in the parent instead. This is what all the menu subcommands want.
Diffstat (limited to 'gdb/gdbtk')
-rw-r--r--gdb/gdbtk/ChangeLog19
-rw-r--r--gdb/gdbtk/library/gdbmenubar.itcl13
-rw-r--r--gdb/gdbtk/library/interface.tcl14
-rw-r--r--gdb/gdbtk/library/srcbar.itcl46
4 files changed, 74 insertions, 18 deletions
diff --git a/gdb/gdbtk/ChangeLog b/gdb/gdbtk/ChangeLog
index 69912937d7f..410775e6180 100644
--- a/gdb/gdbtk/ChangeLog
+++ b/gdb/gdbtk/ChangeLog
@@ -1,3 +1,22 @@
+2001-08-03 Keith Seitz <keiths@redhat.com>
+
+ * library/srcbar.itcl (_post): New method.
+ (_update_file_menu): New method.
+ (create_file_menu): Move the guts to _update_file_menu.
+ Add a post command to the menu.
+ * library/interface.tcl (gdbtk_tcl_file_changed): Catch the
+ call to run_hooks.
+ (gdbtk_tcl_exec_file_display): Save the new session, too.
+ (set_exe_name): Don't bother saving the session here.
+ (_close_file): Save the session here, too.
+ (gdbtk_clear_file): Catch the call to run_hooks, too.
+ * library/gdbmenubar.itcl (menubar_new_menu): Allow caller
+ to specify optional arguments to be passed to Tk when
+ creating the menu.
+ Tk's "menu add" command returns an empty string. Save the
+ menu's index in the parent instead. This is what all
+ the menu subcommands want.
+
2001-08-02 Keith Seitz <keiths@redhat.com>
* generic/gdbtk-bp.c (gdb_get_breakpoint_info): Update
diff --git a/gdb/gdbtk/library/gdbmenubar.itcl b/gdb/gdbtk/library/gdbmenubar.itcl
index 9e63c3f1e68..3b2372a3f7b 100644
--- a/gdb/gdbtk/library/gdbmenubar.itcl
+++ b/gdb/gdbtk/library/gdbmenubar.itcl
@@ -137,13 +137,16 @@ class GDBMenuBar {
# underline - the index of the underlined character for this menu item.
#
# ------------------------------------------------------------------
- private method menubar_new_menu {name label underline} {
+ private method menubar_new_menu {name label underline args} {
+
set current_menu $Menu.$name
- set menu_list($name) [$Menu add cascade -menu $current_menu \
- -label $label -underline $underline]
- menu $current_menu -tearoff 0
- set menu_list($name,label) $label
+ $Menu add cascade -menu $current_menu -label $label \
+ -underline $underline
+ eval menu $current_menu -tearoff 0 $args
+ # Save the index number of this menu. It is always the last one.
+ set menu_list($name) [$Menu index end]
+ set menu_list($name,label) $label
set item_number -1
}
diff --git a/gdb/gdbtk/library/interface.tcl b/gdb/gdbtk/library/interface.tcl
index 3737ddd9063..4353f3e5f82 100644
--- a/gdb/gdbtk/library/interface.tcl
+++ b/gdb/gdbtk/library/interface.tcl
@@ -712,7 +712,7 @@ proc gdbtk_tcl_file_changed {filename} {
if {$filename == ""} {
gdb_clear_file
- run_hooks gdb_clear_file_hook
+ catch {run_hooks gdb_clear_file_hook}
set ::gdb_exe_name ""
set ::gdb_loaded 0
set ::gdb_running 0
@@ -757,6 +757,9 @@ proc gdbtk_tcl_exec_file_display {filename} {
set_exe_name $filename
set gdb_exe_changed 0
+ # Add this new session to the session list
+ session_save
+
SrcWin::point_to_main
}
@@ -816,10 +819,6 @@ proc set_exe_name {exe} {
global gdb_exe_name gdb_exe_changed
#debug "exe=$exe gdb_exe_name=$gdb_exe_name"
- if {$gdb_exe_name != ""} then {
- session_save
- }
-
set gdb_exe_name $exe
set gdb_exe_changed 1
}
@@ -934,7 +933,7 @@ proc _open_file {{file ""}} {
gdbtk_idle
return 0
}
-
+
return 1
}
@@ -958,6 +957,7 @@ proc _close_file {} {
}
if {$okay} {
+ session_save
gdb_clear_file
gdbtk_tcl_file_changed ""
@@ -1669,7 +1669,7 @@ proc gdbtk_clear_file {} {
debug
# Give widgets a chance to clean up
- run_hooks gdb_clear_file_hook
+ catch {run_hooks gdb_clear_file_hook}
# Save the target name in case the user has already selected a
# target. No need to force the user to select it again.
diff --git a/gdb/gdbtk/library/srcbar.itcl b/gdb/gdbtk/library/srcbar.itcl
index 877fc8d6495..17727ccfb56 100644
--- a/gdb/gdbtk/library/srcbar.itcl
+++ b/gdb/gdbtk/library/srcbar.itcl
@@ -84,6 +84,24 @@ class SrcBar {
#destroy $this
}
+
+ # ------------------------------------------------------------------
+ # NAME: private method SrcBar::_post
+ # DESCRIPTION: Post the given menu
+ #
+ # ARGUMENTS:
+ # what - which menu to post
+ # RETURNS: Nothing
+ # ------------------------------------------------------------------
+ private method _post {what} {
+
+ switch $what {
+ file {
+ _update_file_menu
+ }
+ }
+ }
+
####################################################################
# The next set of functions create the common menu groupings that
@@ -122,13 +140,14 @@ class SrcBar {
}
# ------------------------------------------------------------------
- # METHOD: create_file_menu - Creates the standard file menu.
+ # PRIVATE METHOD: _update_file_menu - update the file menu
+ # Used really only to update the session list.
# ------------------------------------------------------------------
-
- private method create_file_menu {} {
- global enable_external_editor tcl_platform
+ private method _update_file_menu {} {
+ global enable_external_editor tcl_platform gdb_exe_name
- $Menu add menubutton file "File" 0
+ # Clear the File menu
+ $Menu clear file
if {[info exists enable_external_editor] && $enable_external_editor} {
$Menu add command None "Edit Source" \
@@ -138,8 +157,13 @@ class SrcBar {
$Menu add command Other "Open..." \
"_open_file" -underline 0 -accelerator "Ctrl+O"
+ if {$gdb_exe_name == ""} {
+ set state disabled
+ } else {
+ set state normal
+ }
$Menu add command Other "Close" \
- "_close_file" -underline 0 -accelerator "Ctrl+W"
+ "_close_file" -underline 0 -accelerator "Ctrl+W" -state $state
$Menu add command Other "Source..." \
"source_file" -underline 0
@@ -182,6 +206,16 @@ class SrcBar {
}
# ------------------------------------------------------------------
+ # METHOD: create_file_menu - Creates the standard file menu.
+ # ------------------------------------------------------------------
+
+ private method create_file_menu {} {
+
+ $Menu add menubutton file "File" 0 -postcommand [code $this _post file]
+ _update_file_menu
+ }
+
+ # ------------------------------------------------------------------
# METHOD: create_run_menu - Creates the standard run menu,
# or reconfigures it if it already exists.
# ------------------------------------------------------------------