Fl_Help_View now ignores links when the link callback returns NULL, and

displays a sensible error message when the URI scheme isn't handled.

Fl_File_Icon no longer tries to load icon files that don't exist.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1860 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2001-12-17 14:27:03 +00:00
parent 6d4bda28b5
commit 8408e863de
4 changed files with 63 additions and 30 deletions

View File

@ -1,5 +1,12 @@
CHANGES IN FLTK 1.1.0b8
- Fl_Help_View now ignores links when the link callback
returns NULL, and displays a sensible error message
when an unhandled URI scheme is used (e.g. http:,
ftp:)
- Fl_File_Icon::load_system_icons() no longer complains
about missing icon files, just files that exist but
can't be loaded.
- FLUID didn't list the plastic box and frame types.
- Now hide the tooltip window whenever a window is
hidden. Otherwise a tooltip window could keep an

View File

@ -69,11 +69,23 @@ in the buffer.
followed or a file is loaded (via
<CODE>Fl_Help_View::load()</CODE>) that requires a different
file or path. The callback function receives a pointer to the
<CODE>Fl_Help_View</CODE> widget and the full pathname for the
file in question and must return a pathname that can be opened
as a local file. This can also be used to retrieve remote or
virtual documents, returning the temporary file that contains
the actual data.</P>
<CODE>Fl_Help_View</CODE> widget and the URI or full pathname
for the file in question. It must return a pathname that can be
opened as a local file or <TT>NULL</TT>:</P>
<UL><PRE>
const char *fn(Fl_Widget *w, const char *uri);
</PRE></UL>
<P>The link function can be used to retrieve remote or virtual
documents, returning a temporary file that contains the actual
data. If the link function returns <TT>NULL</TT>, the value of
the <TT>Fl_Help_View</TT> widget will remain unchanged.</P>
<P>If the link callback cannot handle the URI scheme, it should
return the <TT>uri</TT> value unchanged or set the <A
HREF="Fl_Help_View.value"><TT>value()</TT></A> of the widget
before returning <TT>NULL</TT>.</P>
<H4><A NAME="Fl_Help_View.load">int load(const char *f)</A></H4>

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_File_Icon2.cxx,v 1.1.2.7 2001/12/05 00:21:40 easysw Exp $"
// "$Id: Fl_File_Icon2.cxx,v 1.1.2.8 2001/12/17 14:27:03 easysw Exp $"
//
// Fl_File_Icon system icon routines.
//
@ -819,6 +819,7 @@ load_kde_mimelnk(const char *filename)
{
if (!access("/usr/share/icons/hicolor", F_OK))
{
// KDE 2.x icons
int i; // Looping var
static const char *paths[] = { // Subdirs to look in...
"32x32/actions",
@ -849,11 +850,14 @@ load_kde_mimelnk(const char *filename)
}
if (i >= (int)(sizeof(paths) / sizeof(paths[0]))) return;
}
else
} else {
// KDE 1.x icons
snprintf(full_iconfilename, sizeof(full_iconfilename),
"/usr/share/icons/%s", iconfilename);
if (access(full_iconfilename, F_OK)) return;
}
if (strncmp(mimetype, "inode/", 6) == 0) {
if (strcmp(mimetype + 6, "directory") == 0)
icon = new Fl_File_Icon("*", Fl_File_Icon::DIRECTORY);
@ -926,5 +930,5 @@ get_kde_val(char *str,
//
// End of "$Id: Fl_File_Icon2.cxx,v 1.1.2.7 2001/12/05 00:21:40 easysw Exp $".
// End of "$Id: Fl_File_Icon2.cxx,v 1.1.2.8 2001/12/17 14:27:03 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Help_View.cxx,v 1.1.2.18 2001/12/11 16:03:12 easysw Exp $"
// "$Id: Fl_Help_View.cxx,v 1.1.2.19 2001/12/17 14:27:03 easysw Exp $"
//
// Fl_Help_View widget routines.
//
@ -2225,26 +2225,36 @@ Fl_Help_View::load(const char *f)// I - Filename to load (may also have target)
else
localname = filename_;
if (localname != NULL &&
(strncmp(localname, "ftp:", 4) == 0 ||
strncmp(localname, "http:", 5) == 0 ||
strncmp(localname, "https:", 6) == 0 ||
strncmp(localname, "ipp:", 4) == 0 ||
strncmp(localname, "mailto:", 7) == 0 ||
strncmp(localname, "news:", 5) == 0))
localname = NULL; // Remote link wasn't resolved...
else if (localname != NULL &&
strncmp(localname, "file:", 5) == 0)
localname += 5; // Adjust for local filename...
if (!localname)
return (0);
if (value_ != NULL)
{
free((void *)value_);
value_ = NULL;
}
if (localname)
if (strncmp(localname, "ftp:", 4) == 0 ||
strncmp(localname, "http:", 5) == 0 ||
strncmp(localname, "https:", 6) == 0 ||
strncmp(localname, "ipp:", 4) == 0 ||
strncmp(localname, "mailto:", 7) == 0 ||
strncmp(localname, "news:", 5) == 0)
{
// Remote link wasn't resolved...
snprintf(error, sizeof(error),
"<HTML><HEAD><TITLE>Error</TITLE></HEAD>"
"<BODY><H1>Error</H1>"
"<P>Unable to follow the link \"%s\" - "
"no handler exists for this URI scheme.</P></BODY>",
localname);
value_ = strdup(error);
}
else
{
if (strncmp(localname, "file:", 5) == 0)
localname += 5; // Adjust for local filename...
if ((fp = fopen(localname, "rb")) != NULL)
{
fseek(fp, 0, SEEK_END);
@ -2257,15 +2267,15 @@ Fl_Help_View::load(const char *f)// I - Filename to load (may also have target)
}
else
{
sprintf(error, "%s: %s\n", localname, strerror(errno));
snprintf(error, sizeof(error),
"<HTML><HEAD><TITLE>Error</TITLE></HEAD>"
"<BODY><H1>Error</H1>"
"<P>Unable to follow the link \"%s\" - "
"%s.</P></BODY>",
localname, strerror(errno));
value_ = strdup(error);
}
}
else
{
sprintf(error, "%s: %s\n", filename_, strerror(errno));
value_ = strdup(error);
}
format();
@ -2552,5 +2562,5 @@ hscrollbar_callback(Fl_Widget *s, void *)
//
// End of "$Id: Fl_Help_View.cxx,v 1.1.2.18 2001/12/11 16:03:12 easysw Exp $".
// End of "$Id: Fl_Help_View.cxx,v 1.1.2.19 2001/12/17 14:27:03 easysw Exp $".
//