This is the mail archive of the
insight@sources.redhat.com
mailing list for the Insight project.
[patch] new help browser code
- From: "Martin M. Hunt" <hunt at redhat dot com>
- To: "insight at sources dot redhat dot com" <insight at sources dot redhat dot com>
- Date: 11 Nov 2002 14:35:18 -0800
- Subject: [patch] new help browser code
This patch removes the old, broken htmlviewer used to display the help
pages. Instead the new code attempts to find an appropriate help viewer
based on the OS and compatibility settings. If one cannot be found, the
user is prompted.
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.
Index: prefs.tcl
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/prefs.tcl,v
retrieving revision 1.20
diff -p -r1.20 prefs.tcl
*** prefs.tcl 8 Nov 2002 20:56:44 -0000 1.20
--- prefs.tcl 11 Nov 2002 22:28:03 -0000
*************** proc pref_set_defaults {} {
*** 385,391 ****
pref define gdb/bp/show_threads 0
# Help
! pref define gdb/help/browser 0
# Kernel Objects (kod)
pref define gdb/kod/show_icon 0
--- 385,391 ----
pref define gdb/bp/show_threads 0
# Help
! pref define gdb/help/browsername ""
# Kernel Objects (kod)
pref define gdb/kod/show_icon 0
Index: vartree.itb
===================================================================
RCS file: /cvs/src/src/gdb/gdbtk/library/vartree.itb,v
retrieving revision 1.1
diff -p -r1.1 vartree.itb
*** vartree.itb 6 Nov 2002 21:05:23 -0000 1.1
--- vartree.itb 11 Nov 2002 22:28:03 -0000
*************** itcl::body VarTree::_but3 {x y X Y} {
*** 335,343 ****
$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"
} else {
! $pop add command -label "Help" -command "HtmlViewer::open_help locals.html"
}
$pop add separator
$pop add command -label "Close" -command "destroy [winfo toplevel $itk_interior]"
--- 335,343 ----
$pop add command -label "Delete" -command [code $this remove $var]
$pop add separator
if {$type == "local"} {
! $pop add command -label "Help" -command "open_help watch.html"
} else {
! $pop add command -label "Help" -command "open_help locals.html"
}
$pop add separator
$pop add command -label "Close" -command "destroy [winfo toplevel $itk_interior]"
*************** itcl::body VarTree::_do_default_menu {X
*** 356,364 ****
$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"
} else {
! $pop add command -label "Help" -command "HtmlViewer::open_help locals.html"
}
$pop add separator
$pop add command -label "Close" -command "destroy [winfo toplevel $itk_interior]"
--- 356,364 ----
$pop add separator
$pop add command -label "Sort" -command [code $this _sort]
if {$type == "local"} {
! $pop add command -label "Help" -command "open_help watch.html"
} else {
! $pop add command -label "Help" -command "open_help locals.html"
}
$pop add separator
$pop add command -label "Close" -command "destroy [winfo toplevel $itk_interior]"
# 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
}