1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
|
/*
* FIG : Facility for Interactive Generation of figures
* Copyright (c) 1989-2000 by Brian V. Smith
*
* Any party obtaining a copy of these files is granted, free of charge, a
* full and unrestricted irrevocable, world-wide, paid up, royalty-free,
* nonexclusive right and license to deal in this software and
* documentation files (the "Software"), including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons who receive
* copies from any such party to do so, with the only requirement being
* that this copyright notice remain intact.
*
*/
#include "fig.h"
#include "figx.h"
#include "resources.h"
#include "object.h"
#include "mode.h"
#include "f_util.h"
#include "w_msgpanel.h"
#include "w_util.h"
char *browsecommand;
Boolean check_docfile();
char filename[PATH_MAX];
void help_ok();
static String about_translations =
"<Message>WM_PROTOCOLS: DismissAbout()\n";
static XtActionsRec about_actions[] =
{
{"DismissAbout", (XtActionProc) help_ok},
};
void
launch_refman(w, closure, call_data)
Widget w;
XtPointer closure;
XtPointer call_data;
{
int pid;
/* first check if at least the index file is installed */
sprintf(filename, "%s/html/index.html", XFIGDOCDIR);
#ifdef I18N
if (appres.international && getenv("LANG")) {
/* check localized file ($XFIGDOCDIR/html/$LANG/index.html) first */
sprintf(filename, "%s/html/%s/index.html", XFIGDOCDIR, getenv("LANG"));
if (!check_docfile(filename))
sprintf(filename, "%s/html/index.html", XFIGDOCDIR);
}
#endif
if (!check_docfile(filename))
return;
launch_viewer(filename, "Launching Web browser for html pages", appres.browser);
}
void
launch_howto(w, closure, call_data)
Widget w;
XtPointer closure;
XtPointer call_data;
{
sprintf(filename,"%s/xfig-howto.pdf",XFIGDOCDIR);
launch_viewer(filename,"Launching PDF viewer for How-to Tutorial", appres.pdf_viewer);
}
void
launch_man(w, closure, call_data)
Widget w;
XtPointer closure;
XtPointer call_data;
{
sprintf(filename,"%s/xfig.html",XFIGDOCDIR);
launch_viewer(filename,"Launching Web browser for man pages", appres.browser);
}
launch_viewer(filename, message, viewer)
char *filename, *message, *viewer;
{
int pid;
/* first check if the file is installed */
if (!check_docfile(filename))
return;
/* now replace the %f in the browser command with the filename and add the "&" */
browsecommand = build_command(viewer, filename);
put_msg(message);
system(browsecommand);
free(browsecommand);
}
Boolean
check_docfile(name)
char *name;
{
struct stat file_status;
if (stat(name, &file_status) != 0) { /* something wrong */
if (errno == ENOENT) {
file_msg("%s is not installed, please install package xfig-doc.",name);
} else {
file_msg("System error: %s on file %s",sys_errlist[errno],name);
}
beep();
return False;
}
return True;
}
static Widget help_popup = (Widget) 0;
void
help_ok(w, closure, call_data)
Widget w;
XtPointer closure;
XtPointer call_data;
{
XtPopdown(help_popup);
}
void
launch_about(w, closure, call_data)
Widget w;
XtPointer closure;
XtPointer call_data;
{
DeclareArgs(10);
Widget form, icon, ok;
Position x, y;
char info[400];
/* don't make more than one */
if (!help_popup) {
/* get the position of the help button */
XtTranslateCoords(w, (Position) 0, (Position) 0, &x, &y);
FirstArg(XtNx, x);
NextArg(XtNy, y);
help_popup = XtCreatePopupShell("About Xfig",transientShellWidgetClass,
tool, Args, ArgCount);
XtOverrideTranslations(help_popup,
XtParseTranslationTable(about_translations));
XtAppAddActions(tool_app, about_actions, XtNumber(about_actions));
FirstArg(XtNborderWidth, 0);
form = XtCreateManagedWidget("help_form", formWidgetClass, help_popup,
Args, ArgCount);
/* put the xfig icon in a label and another label saying which version this is */
FirstArg(XtNbitmap, fig_icon);
NextArg(XtNinternalHeight, 0);
NextArg(XtNinternalWidth, 0);
NextArg(XtNborderWidth, 0);
icon = XtCreateManagedWidget("xfig_icon", labelWidgetClass, form, Args, ArgCount);
/* make up some information */
strcpy(info,xfig_version);
strcat(info,"\n Copyright \251 1985-1988 by Supoj Sutanthavibul");
strcat(info,"\n Parts Copyright \251 1989-2000 by Brian V. Smith (BVSmith@lbl.gov)");
strcat(info,"\n Parts Copyright \251 1991 by Paul King");
strcat(info,"\n See source files and man pages for other copyrights");
FirstArg(XtNlabel, info);
NextArg(XtNfromHoriz, icon);
NextArg(XtNhorizDistance, 20);
NextArg(XtNborderWidth, 0);
XtCreateManagedWidget("xfig_icon", labelWidgetClass, form, Args, ArgCount);
FirstArg(XtNlabel, " Ok ");
NextArg(XtNwidth, 50);
NextArg(XtNheight, 30);
NextArg(XtNfromVert, icon);
NextArg(XtNvertDistance, 20);
ok = XtCreateManagedWidget("help_ok", commandWidgetClass, form, Args, ArgCount);
XtAddCallback(ok, XtNcallback, help_ok, (XtPointer) NULL);
}
XtPopup(help_popup,XtGrabNone);
(void) XSetWMProtocols(tool_d, XtWindow(help_popup), &wm_delete_window, 1);
}
|