OSDN Git Service

2002-11-11 Martin M. Hunt <hunt@redhat.com>
authorMartin Hunt <hunt@redhat.com>
Mon, 11 Nov 2002 22:29:24 +0000 (22:29 +0000)
committerMartin Hunt <hunt@redhat.com>
Mon, 11 Nov 2002 22:29:24 +0000 (22:29 +0000)
* library/helpviewer.tcl: New file. Finds
an appropriate help browser and displays the help files.

* library/vartree.itb: Fix open_help calls.

* library/helpviewer.ith: Deleted.
* library/helpviewer.itb: Deleted.

* library/prefs.tcl (pref_set_defaults): Remove
pref gdb/help/browser. Add pref gdb/help/browsername.
We couldn't simply rename because it would break older
versions of Insight that expect gdb/help/browser to be
a number.

gdb/gdbtk/ChangeLog
gdb/gdbtk/library/helpviewer.itb [deleted file]
gdb/gdbtk/library/helpviewer.ith [deleted file]
gdb/gdbtk/library/helpviewer.tcl [new file with mode: 0644]
gdb/gdbtk/library/prefs.tcl
gdb/gdbtk/library/vartree.itb

index ce63221..90bf2d3 100644 (file)
@@ -1,8 +1,24 @@
+2002-11-11  Martin M. Hunt  <hunt@redhat.com>  
+
+       * library/helpviewer.tcl: New file. Finds
+       an appropriate help browser and displays the help files.
+
+       * library/vartree.itb: Fix open_help calls.
+       
+       * library/helpviewer.ith: Deleted.
+       * library/helpviewer.itb: Deleted.
+       
+       * library/prefs.tcl (pref_set_defaults): Remove 
+       pref gdb/help/browser. Add pref gdb/help/browsername.  
+       We couldn't simply rename because it would break older 
+       versions of Insight that expect gdb/help/browser to be 
+       a number.
+
 2002-11-08  Martin M. Hunt  <hunt@redhat.com>
 
        * library/prefs.tcl (pref_save): Fix GDBtkInitVersion.
        (pref_save): Check that value is not null before writing.
-
+       
 2002-11-07  Martin M. Hunt  <hunt@redhat.com>
 
        * library/util.tcl (CygScrolledListbox): Delete.
diff --git a/gdb/gdbtk/library/helpviewer.itb b/gdb/gdbtk/library/helpviewer.itb
deleted file mode 100644 (file)
index 3ee506a..0000000
+++ /dev/null
@@ -1,286 +0,0 @@
-# Viewer for HTML help info
-# Copyright 1998, 1999 Cygnus Solutions
-#
-# 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.
-
-
-# -----------------------------------------------------------------------------
-# NAME:        
-#      HtmlViewer::constructor
-#
-# SYNOPSIS:    
-#      constructor args
-#
-# DESC:        
-#      Creates the Help Viewer window.
-# -----------------------------------------------------------------------------
-itcl::body HtmlViewer::constructor {args} {
-  window_name "Help"
-  eval itk_initialize $args
-  _buildwin
-}
-
-
-# -----------------------------------------------------------------------------
-# NAME:        
-#      private method HtmlViewer::_buildwin
-#
-# SYNOPSIS:    
-#      _buildwin args
-#
-# DESC:        
-#      This function is called by the constructor to build the widget. It
-#      creates pulldown menus, buttons, a stack, and a scrolledhtml widget.
-#      Finally it loads help/index.html.  This last step should change if
-#      this widget is ever used for anything but help.
-# -----------------------------------------------------------------------------
-itcl::body HtmlViewer::_buildwin {} {
-  global GDBTK_LIBRARY gdb_ImageDir
-
-  set _links [PageStack \#auto]
-  
-  # create pulldown menu
-  set menu [menu $itk_interior.m -tearoff 0]
-  $menu add cascade -menu $menu.file -label "File" -underline 0
-  set _m [menu $menu.file]
-  $_m add command -label "Back" -underline 0 -command "$this back"
-  $_m add command -label "Forward" -underline 0 -command "$this forward"
-  $_m add command -label "Home" -underline 0 -command "$this link $file"
-  $_m add separator
-  $_m add command -label "Close" -underline 0 -command "delete object $this"
-  $menu add cascade -menu $menu.topic -label "Topics" -underline 0
-  set _t [menu $menu.topic]
-  foreach t $topics {
-    $_t add command -label [lindex $t 0] -command "$this link [lindex $t 1]"
-  }
-  [winfo toplevel $itk_interior] configure -menu $menu
-  
-  # create buttons
-  set _f [frame $itk_interior.b]
-  button $_f.back -command "$this back" \
-    -image [image create photo -file [file join $gdb_ImageDir back.gif]]
-  button $_f.fore -command "$this forward" \
-    -image [image create photo -file [file join $gdb_ImageDir fore.gif]]
-  button $_f.home -command "$this link $file" \
-    -image [image create photo -file [file join $gdb_ImageDir home.gif]]
-  standard_toolbar $_f $_f.back $_f.fore $_f.home
-  
-  _enable 0 back fore
-
-  # create html widget
-  set _html [iwidgets::scrolledhtml $itk_interior.a -linkcommand "$this link"]
-
-  # get things going by loading index.html
-  $_html import [file join $GDBTK_LIBRARY help $file]
-  $_links push $file
-  
-  pack $_f -side top -fill x
-  pack $_html -expand yes -fill both
-
-}
-
-# -----------------------------------------------------------------------------
-# NAME:                public method PageStack::push
-# SYNOPSIS:    push val
-# DESC:                Pushes a value onto the stack.
-# -----------------------------------------------------------------------------
-itcl::body PageStack::push {val} {
-  incr _ptr
-  incr _max
-  if {$_ptr < $_max} {
-    set _max $_ptr
-  }
-  set _stack($_ptr) $val
-}
-
-# -----------------------------------------------------------------------------
-# NAME:                public method PageStack::back
-# SYNOPSIS:    back
-# DESC:                Moves the stack pointer back by one.
-# RETURNS:     Returns the value on the stack, or 0 on error.
-# -----------------------------------------------------------------------------
-itcl::body PageStack::back {} {
-  if {$_ptr > 0} {
-    incr _ptr -1
-    return $_stack($_ptr)
-  }
-  return 0
-}
-
-# -----------------------------------------------------------------------------
-# NAME:                public method PageStack::next
-# SYNOPSIS:    next
-# DESC:                Moves the stack pointer forward by one.
-# RETURNS:     Returns the value on the stack, or 0 on error.
-# -----------------------------------------------------------------------------
-itcl::body PageStack::next {} {
-  if {$_ptr < $_max} {
-    incr _ptr
-    return $_stack($_ptr)
-  }
-  return 0
-}
-
-# -----------------------------------------------------------------------------
-# NAME:                public method PageStack:more
-# SYNOPSIS:    more
-# DESC:                Indicates if the stack pointer is not at the top.
-# RETURNS:     Returns 1 if PageStack::next will suceed, 0 otherwise.
-# -----------------------------------------------------------------------------
-itcl::body PageStack::more {} {
-  if {$_ptr < $_max} {
-    return 1
-  }
-  return 0
-}
-
-# -----------------------------------------------------------------------------
-# NAME:                public method PageStack:less
-# SYNOPSIS:    less
-# DESC:                Indicates if the stack pointer is not at the bottom of stack.
-# RETURNS:     Returns 1 if PageStack::back will suceed, 0 otherwise.
-# -----------------------------------------------------------------------------
-itcl::body PageStack::less {} {
-  if {$_ptr > 0} {
-    return 1
-  }
-  return 0
-}
-
-# -----------------------------------------------------------------------------
-# NAME:                public method PageStack:current
-# SYNOPSIS:    current
-# RETURNS:     Returns the current value on the stack.
-# -----------------------------------------------------------------------------
-itcl::body PageStack::current {} {
-  if {$_ptr > 0} {
-    return $_stack($_ptr)
-  }
-  return 0
-}
-
-# ------------------------------------------------------------------------------
-# NAME:                
-#      private method HtmlViewer::_enable
-#
-# SYNOPSIS:    
-#      _enable { on args }
-#
-# DESC:                
-#      Enables or disables buttons and menus.
-#
-# ARGS:        
-#      on - "1" to enable, "0" to disable
-#      args - things to enable/disable.  May include "back",
-#      "fore", and "home"
-#
-# ------------------------------------------------------------------------------
-itcl::body HtmlViewer::_enable { on args } {
-  if {$on} {
-    set state normal
-  } else {
-    set state disabled
-  }
-  
-  foreach a $args {
-    switch $a {
-      back {
-       # set state of "back"
-       $_m entryconfigure 0 -state $state
-       $_f.back configure -state $state
-      }
-      fore {
-       # set state of "forward"
-       $_m entryconfigure 1 -state $state
-       $_f.fore configure -state $state
-      }
-      home {
-       # set state of "home"
-       $_m entryconfigure 2 -state $state
-       $_f.home configure -state $state
-      }
-    }
-  }
-}
-
-# ------------------------------------------------------------------------------
-# NAME:                public method HtmlViewer::back
-# SYNOPSIS:    back
-# DESC:                Moves to the previous page
-# ------------------------------------------------------------------------------
-itcl::body HtmlViewer::back {} {
-  set res [$_links back]
-  if {$res != 0} {
-    load $res
-    if {![$_links less]} {
-      _enable 0 back
-    }
-  }
-}
-
-# ------------------------------------------------------------------------------
-# NAME:                public method HtmlViewer::forward
-# SYNOPSIS:    forward
-# DESC:                Moves to the next page
-# ------------------------------------------------------------------------------
-itcl::body HtmlViewer::forward {} {
-  set res [$_links next]
-  if {$res != 0} {
-    load $res
-    if {![$_links more]} {
-      _enable 0 fore
-    }
-  }
-}
-
-# ------------------------------------------------------------------------------
-# NAME:                public method HtmlViewer::link
-# SYNOPSIS:    link page
-# ARDS:                page - link to the page to load
-# DESC:                Saves the page on the stack and calls the "load" method
-# ------------------------------------------------------------------------------
-itcl::body HtmlViewer::link {page} {
-  if {$page != [$_links current]} {
-    $_links push $page
-    load $page
-    if {![$_links more]} {
-      _enable 0 fore
-    }
-  }
-}
-
-# ------------------------------------------------------------------------------
-# NAME:                private method HtmlViewer::load
-# SYNOPSIS:    load link
-# DESC:                Disables menus and buttons, sets cursor, loads a page into 
-#              the html widget, then resets cursor and enables the menus 
-#              and buttons
-# ------------------------------------------------------------------------------
-itcl::body HtmlViewer::load {link} {
-  _enable 0 back fore home
-  $itk_interior configure -cursor watch
-  $_html import -link $link
-  $itk_interior configure -cursor ""    
-  _enable 1 back fore home
-}
-
-# ------------------------------------------------------------------------------
-# NAME:                public proc HtmlViewer::open_help
-# SYNOPSIS:    HtmlViewer::open_help file
-# DESC:                If the prefs are set to use a browser, attempts
-#              to do so. Otherwise, uses builtin HtmlViewer class.
-# ------------------------------------------------------------------------------
-itcl::body HtmlViewer::open_help {hfile} {
-  set link file://[file join $::GDBTK_LIBRARY help $hfile]
-  if {![pref get gdb/help/browser] || ![::open_url $link]} {
-    ManagedWin::open HtmlViewer -file $hfile
-  }
-}
diff --git a/gdb/gdbtk/library/helpviewer.ith b/gdb/gdbtk/library/helpviewer.ith
deleted file mode 100644 (file)
index 8a120f7..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-# HtmlViewer class definition
-# Copyright 1998, 1999 Cygnus Solutions
-#
-# 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.
-
-
-# -----------------------------------------------------------------------------
-# NAME:
-#      class HtmlViewer
-#
-# DESC:
-#      This class implements a simple HTML browser.  It has both pulldown
-#      menus and buttons for navigating.  It uses the scrolledhtml iwidget
-#      to do its rendering.
-#
-# NOTES:
-#      Currently used as a help window.
-#
-# -----------------------------------------------------------------------------
-itcl::class HtmlViewer {
-  inherit EmbeddedWin
-  
-  public {
-    variable topics { 
-      {index index.html}
-      {"Attach Dialog" attach.html}
-      {"Breakpoint Window" breakpoint.html}
-      {"Console Window" console.html }
-      {"Function Browser" browser.html }
-      {"Locals Window" locals.html }
-      {"Memory Window" memory.html}
-      {"Register Window" register.html}
-      {"Source Window" source.html}
-      {"Stack Window" stack.html}
-      {"Target Window" target.html }
-      {"Thread Window" thread.html }
-      {"Watch Window" watch.html}
-    }
-    variable file "index.html"
-    method back {}
-    method forward {}
-    method link {link}
-    method load {link}
-    method close {}
-    method constructor {args}
-    proc open_help {file}
-  }
-  
-  private {
-    variable _html
-    variable _links
-    variable _m
-    variable _f
-    
-    method _enable {on args}
-    method _buildwin {}
-  }
-  
-}
-
-# -----------------------------------------------------------------------------
-# NAME:
-#      class PageStack
-#
-# DESC:
-#      Implements a stack-like class for saving and recalling items
-#      like pages in a help browser. It differs from a traditional
-#      stack only by the 'back' and 'next' methods which move up and
-#      down the stack without disturbing it, unlike 'push' and 'pop'.
-#
-# NOTES:
-#      Currently used by the HtmlViewer class.
-#
-# -----------------------------------------------------------------------------
-itcl::class PageStack {
-  private {
-    variable _ptr -1
-    variable _max -1
-    variable _stack
-  }
-  public {
-    method push {val}
-    method back {}
-    method next {}
-    method more {}
-    method less {}
-    method current {}
-  }
-}
diff --git a/gdb/gdbtk/library/helpviewer.tcl b/gdb/gdbtk/library/helpviewer.tcl
new file mode 100644 (file)
index 0000000..0ef45b2
--- /dev/null
@@ -0,0 +1,99 @@
+# Open a viewer for HTML help info
+# Copyright 2002, 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.
+
+# ------------------------------------------------------------------------------
+# NAME:                public proc open_help
+# SYNOPSIS:    open_help file
+# DESC:                Opens html help file using an appropriate
+#              browser.
+# ------------------------------------------------------------------------------
+
+proc open_help {hfile} {
+  debug $hfile
+  # create full pathname link
+  set link file://[file join $::GDBTK_LIBRARY help $hfile]
+
+  # windows is easy
+  if {$::tcl_platform(platform) == "windows"} {
+    ide_shell_execute open $link
+    return
+  }
+
+  #
+  # for Unix, we never know what is installed
+  #
+
+  # set list of viewer apps to try
+  switch [pref get gdb/compat] {
+    "KDE" {
+      #        set apps {htmlview khelpcenter mozilla}
+      set apps {xhtmlview xkhelpcenter xmozilla}
+    }
+    "GNOME" {
+      set apps {htmlview mozilla gnome-help khelpcenter}
+    }      
+    default {
+      set apps {htmlview mozilla gnome-help khelpcenter netscape}
+    }
+  }
+
+  # If the user has previously entered a browser name, append it
+  # to the list. Should it go first or last? 
+  set bname [pref get gdb/help/browsername]
+  if {$bname != ""} {
+    lappend apps $bname
+  }
+  
+  # now loop through list checking each application
+  foreach app $apps {
+    debug "app=$app"
+    if {[catch "exec $app $link &" result]} {
+      debug "$app failed: $result"
+    } else {
+      return
+    }
+  }
+  
+  # if we reached here, nothing worked, so prompt for a name
+  set text "No help browser was found on your system.\n\
+Please enter the name of an HTML viewer application."
+  while {[set app [prompt_helpname  $text]] != "0"} {
+    if {$app != ""} {
+      if {[catch "exec $app $link &" result]} {
+       dbug W "$app failed: $result"
+       set text "Could not run application $app.\n\
+Please enter the name of an HTML viewer application."
+      } else {
+       pref set gdb/help/browsername $app
+       return
+      }
+    }
+  }
+}
+
+# displays an entry dialog and asks for the name of an application
+# returns 0 on cancel
+#         name on success
+proc prompt_helpname {text} {
+  iwidgets::promptdialog .pd -title "Browser Query" -modality application \
+    -labeltext  $text
+  if {[.pd activate]} {
+    set app [string trim [.pd get]]
+    destroy .pd
+    return $app
+  }
+  destroy .pd
+  debug "cancelled"
+  return 0
+}
+
index 2f59794..dbfd3da 100644 (file)
@@ -385,7 +385,7 @@ proc pref_set_defaults {} {
   pref define gdb/bp/show_threads         0
 
   # Help
-  pref define gdb/help/browser           0
+  pref define gdb/help/browsername     ""
 
   # Kernel Objects (kod)
   pref define gdb/kod/show_icon           0
index a3c46e0..fa6bc8b 100644 (file)
@@ -335,9 +335,9 @@ itcl::body  VarTree::_but3 {x y X Y} {
   $pop add command -label "Delete" -command [code $this remove $var]
   $pop add separator
   if {$type == "local"} {
-    $pop add command -label "Help" -command "HtmlViewer::open_help watch.html"
+    $pop add command -label "Help" -command "open_help watch.html"
   } else {
-    $pop add command -label "Help" -command "HtmlViewer::open_help locals.html"
+    $pop add command -label "Help" -command "open_help locals.html"
   }
   $pop add separator
   $pop add command -label "Close" -command "destroy [winfo toplevel $itk_interior]"
@@ -356,9 +356,9 @@ itcl::body  VarTree::_do_default_menu {X Y} {
   $pop add separator
   $pop add command -label "Sort" -command [code $this _sort]
   if {$type == "local"} {
-    $pop add command -label "Help" -command "HtmlViewer::open_help watch.html"
+    $pop add command -label "Help" -command "open_help watch.html"
   } else {
-    $pop add command -label "Help" -command "HtmlViewer::open_help locals.html"
+    $pop add command -label "Help" -command "open_help locals.html"
   }
   $pop add separator
   $pop add command -label "Close" -command "destroy [winfo toplevel $itk_interior]"