home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume18 / bibview / part02 < prev    next >
Encoding:
Text File  |  1992-08-26  |  50.2 KB  |  1,654 lines

  1. Path: uunet!dtix!darwin.sura.net!mips!msi!dcmartin
  2. From: liebla@informatik.tu-muenchen.de (Armin Liebl)
  3. Newsgroups: comp.sources.x
  4. Subject: v18i100: bibview - BibTeX GUI, Part02/20
  5. Message-ID: <1992Aug27.161348.25167@msi.com>
  6. Date: 27 Aug 92 16:13:48 GMT
  7. References: <csx-18i099-bibview@uunet.UU.NET>
  8. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  9. Organization: Molecular Simulations, Inc.
  10. Lines: 1640
  11. Approved: dcmartin@msi.com
  12. Originator: dcmartin@fascet
  13.  
  14. Submitted-by: Armin Liebl <liebla@informatik.tu-muenchen.de>
  15. Posting-number: Volume 18, Issue 100
  16. Archive-name: bibview/part02
  17.  
  18. #!/bin/sh
  19. # this is part.02 (part 2 of a multipart archive)
  20. # do not concatenate these parts, unpack them in order with /bin/sh
  21. # file ComboBoP.h continued
  22. #
  23. if test ! -r _shar_seq_.tmp; then
  24.     echo 'Please unpack part 1 first!'
  25.     exit 1
  26. fi
  27. (read Scheck
  28.  if test "$Scheck" != 2; then
  29.     echo Please unpack part "$Scheck" next!
  30.     exit 1
  31.  else
  32.     exit 0
  33.  fi
  34. ) < _shar_seq_.tmp || exit 1
  35. if test ! -f _shar_wnt_.tmp; then
  36.     echo 'x - still skipping ComboBoP.h'
  37. else
  38. echo 'x - continuing file ComboBoP.h'
  39. sed 's/^X//' << 'SHAR_EOF' >> 'ComboBoP.h' &&
  40. /*  bibView: Administration of bibTex-Databases                      */
  41. /*           (Verwaltung von bibTeX-Literaturdatenbanken)            */
  42. /*                                                                   */
  43. /*  Module:  ComboBoP.h                                              */
  44. /*                                                                   */
  45. /*             - Combo Box Widget                                    */
  46. /*               Text widget with selection list                     */
  47. /*                                                                   */
  48. /*  Author:  Holger Martin,  martinh@informatik.tu-muenchen.de       */
  49. /*           Peter M. Urban, urban@informatik.tu-muenchen.de         */
  50. /*                                                                   */
  51. /*  History:                                                         */
  52. /*    11.22.91  HM   created                                         */
  53. /*                                                                   */
  54. /*  Copyright 1991 Martin, Urban                                     */
  55. /*    See ./Copyright for complete rights and liability information. */
  56. /*                                                                   */
  57. /*********************************************************************/
  58. X
  59. X
  60. #ifndef ComboBoxP_h
  61. #define ComboBoxP_h
  62. X
  63. #include "ComboBo.h"
  64. X
  65. #define XtCSelectMenu "SelectMenu"
  66. #define XtCShowDotFiles "ShowDotFiles"
  67. #define XtCBellLevel "BellLevel"
  68. #define XtCName "Name"           /* NEU: Label fuer Eingabefeld */
  69. #define XtCRcList "RcList"       /* NEU: LISTE */
  70. X
  71. X
  72. typedef struct {
  73. X    /* resources */
  74. X    XtCallbackList      select_callback;
  75. X    String              select_menu;
  76. X    XtCallbackList      cancel_callback;
  77. X    Dimension           margin;
  78. X    int                 number_rows;
  79. X    Boolean             show_dot_files;
  80. X    int                 bell_level;
  81. X    String              name;        /* NEU */
  82. X    RcListNode          *rclist;     /* NEU */
  83. X    /* private data */
  84. X    Widget              viewport_widget;
  85. X    Widget              list_widget;
  86. X    Widget        filename_widget;
  87. X    Widget              select_widget;
  88. X    Widget              path_widget;
  89. X    Widget        cancel_widget;    
  90. X    Widget              name_widget;    /* NEU */
  91. X    Widget              shell_widget;
  92. X    String              *listList;
  93. X    char                currentDir[MAXPATHLEN];
  94. X    Boolean             watchingChanges;
  95. X    ComboBoxStruct nomination;
  96. } ComboBoxPart;
  97. X
  98. typedef struct _ComboBoxRec {
  99. X    CorePart        core;
  100. X    ComboBoxPart    comboBox;
  101. } ComboBoxRec;
  102. X
  103. typedef struct {
  104. X    XtPointer        extension;
  105. } ComboBoxClassPart;
  106. X
  107. typedef struct _ComboBoxClassRec {
  108. X    CoreClassPart            core_class;
  109. X    ComboBoxClassPart    comboBox_class;
  110. } ComboBoxClassRec, *ComboBoxClass;
  111. X
  112. extern ComboBoxClassRec comboBoxClassRec;
  113. X
  114. #endif /* ComboBoxP_h */
  115. X
  116. SHAR_EOF
  117. echo 'File ComboBoP.h is complete' &&
  118. chmod 0644 ComboBoP.h ||
  119. echo 'restore of ComboBoP.h failed'
  120. Wc_c="`wc -c < 'ComboBoP.h'`"
  121. test 2925 -eq "$Wc_c" ||
  122.     echo 'ComboBoP.h: original size 2925, current size' "$Wc_c"
  123. rm -f _shar_wnt_.tmp
  124. fi
  125. # ============= FileNom.c ==============
  126. if test -f 'FileNom.c' -a X"$1" != X"-c"; then
  127.     echo 'x - skipping FileNom.c (File already exists)'
  128.     rm -f _shar_wnt_.tmp
  129. else
  130. > _shar_wnt_.tmp
  131. echo 'x - extracting FileNom.c (Text)'
  132. sed 's/^X//' << 'SHAR_EOF' > 'FileNom.c' &&
  133. /*********************************************************************/
  134. /*  bibView: Administration of bibTex-Databases                      */
  135. /*           (Verwaltung von bibTeX-Literaturdatenbanken)            */
  136. /*                                                                   */
  137. /*  Module:  FileNom.c                                               */
  138. /*                                                                   */
  139. /*             - File Selection Box                                  */
  140. /*               Adapted and modified Widget from aXe editor         */
  141. /*                                                                   */
  142. /*  Author:  Holger Martin,  martinh@informatik.tu-muenchen.de       */
  143. /*           Peter M. Urban, urban@informatik.tu-muenchen.de         */
  144. /*                                                                   */
  145. /*  History:                                                         */
  146. /*    11.22.91  HM   created                                         */
  147. /*    05.26.92       Version 1.0 released                            */
  148. /*                                                                   */
  149. /*  Copyright 1992 TU MUENCHEN                                         */
  150. /*    See ./Copyright for complete rights and liability information. */
  151. /*                                                                   */
  152. /*********************************************************************/
  153. X
  154. /*
  155. X * Copyright 1991 The University of Newcastle upon Tyne
  156. X * 
  157. X * Permission to use, copy, modify and distribute this software and its
  158. X * documentation for any purpose other than its commercial exploitation
  159. X * is hereby granted without fee, provided that the above copyright
  160. X * notice appear in all copies and that both that copyright notice and
  161. X * this permission notice appear in supporting documentation, and that
  162. X * the name of The University of Newcastle upon Tyne not be used in
  163. X * advertising or publicity pertaining to distribution of the software
  164. X * without specific, written prior permission. The University of
  165. X * Newcastle upon Tyne makes no representations about the suitability of
  166. X * this software for any purpose. It is provided "as is" without express
  167. X * or implied warranty.
  168. X * 
  169. X * THE UNIVERSITY OF NEWCASTLE UPON TYNE DISCLAIMS ALL WARRANTIES WITH
  170. X * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
  171. X * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF
  172. X * NEWCASTLE UPON TYNE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  173. X * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  174. X * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  175. X * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  176. X * PERFORMANCE OF THIS SOFTWARE.
  177. X * 
  178. X * Author:  Jim Wight (j.k.wight@newcastle.ac.uk)
  179. X *          Computing Laboratory, University of Newcastle upon Tyne, UK
  180. X */
  181. X
  182. #include <X11/IntrinsicP.h>    
  183. #include <X11/StringDefs.h>    
  184. #include <X11/Xaw/MenuButton.h>
  185. #include <X11/Xaw/SimpleMenu.h>
  186. #include <X11/Xaw/SmeBSB.h>
  187. #include <X11/Xaw/Viewport.h>
  188. #include <X11/Xaw/List.h>
  189. #include <X11/Xaw/Scrollbar.h>
  190. #include <X11/Xaw/AsciiText.h>
  191. #include <X11/Xaw/Command.h>
  192. #include <X11/Xos.h>
  193. X
  194. #include <sys/param.h>
  195. #include <sys/stat.h>
  196. #include <errno.h>
  197. #ifndef HAVE_DIR
  198. #include <dirent.h>
  199. #else
  200. #include <sys/dir.h>
  201. #define dirent direct
  202. #endif
  203. #include <stdio.h>
  204. X
  205. extern char *getenv();
  206. X
  207. #include "FileNomP.h"
  208. X
  209. #define Offset(field) XtOffsetOf(FileNominatorRec, fileNominator.field)
  210. X
  211. static XtResource resources[] = {
  212. X    {XtNselectCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
  213. X     Offset(select_callback), XtRCallback, (XtPointer) NULL},
  214. X    {XtNselectMenu, XtCSelectMenu, XtRString, sizeof(String),
  215. X     Offset(select_menu), XtRString, (XtPointer) NULL},
  216. X    {XtNcancelCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
  217. X     Offset(cancel_callback), XtRCallback, (XtPointer) NULL},
  218. X    {XtNmargin, XtCMargin, XtRDimension, sizeof(Dimension),
  219. X     Offset(margin), XtRImmediate, (XtPointer) 10},
  220. X    {XtNnumberRows, XtCNumberStrings, XtRInt, sizeof(int),
  221. X     Offset(number_rows), XtRImmediate, (XtPointer) 12},
  222. X    {XtNshowDotFiles, XtCShowDotFiles, XtRBoolean, sizeof(Boolean),
  223. X     Offset(show_dot_files), XtRImmediate, (XtPointer) True},
  224. X    {XtNbellLevel, XtCBellLevel, XtRInt, sizeof(int),
  225. X     Offset(bell_level), XtRImmediate, (XtPointer) 100},
  226. };
  227. X
  228. #undef Offset
  229. X
  230. #define Child(w,child) (((FileNominatorWidget) w)->fileNominator.child)
  231. #define List(w) (((FileNominatorWidget) w)->fileNominator.listList)
  232. #define Rows(w) (((FileNominatorWidget) w)->fileNominator.number_rows)
  233. #define CurrentDir(w) (((FileNominatorWidget) w)->fileNominator.currentDir)
  234. #define WatchingChanges(w) (((FileNominatorWidget) w)->fileNominator.watchingChanges)
  235. #define Nomination(w) (((FileNominatorWidget) w)->fileNominator.nomination)
  236. #define ShowDotFiles(w) (((FileNominatorWidget) w)->fileNominator.show_dot_files)
  237. #define BellLevel(w) (((FileNominatorWidget) w)->fileNominator.bell_level)
  238. X
  239. static char pathTranslations[] =
  240. X    "<BtnDown>:reset() MakeMenu() XawPositionSimpleMenu(menu) MenuPopup(menu)";
  241. X
  242. static char listTranslations[] =
  243. X    "<Btn1Up>(2):         Set() Nominate() Unset()\n\
  244. X     <Btn1Down>,<Btn1Up>: Set() Notify() \n\
  245. X     <Btn2Up>:            Set() Notify() Nominate() Unset()";
  246. X
  247. static char filenameTranslations[] =
  248. X     "<Key>Return: Nominate() \n\
  249. X      <Key>Escape: ToggleDotFiles()";
  250. X
  251. static char selectTranslations[] =
  252. X    "<Btn1Up>: Nominate() unset()";
  253. X
  254. static char selectMenuTranslations[] =
  255. X    "<Btn3Down>: XawPositionSimpleMenu(selectMenu) MenuPopup(selectMenu)";
  256. X
  257. static void MakeMenu(), Nominate(), ToggleDotFiles();
  258. X
  259. static XtActionsRec pathActions[] = {
  260. X    "MakeMenu", MakeMenu,
  261. X    "Nominate", Nominate,
  262. X    "ToggleDotFiles", ToggleDotFiles,
  263. };
  264. X
  265. static void                     CancelCallback();
  266. static void                     ChangeDir();
  267. static void                     SelectDir();
  268. static void                     FillWindow();
  269. static void                     ReplaceFilename();
  270. static void                     AsciiSourceChanged();
  271. static void                     WatchForChanges();
  272. static void                     DontWatchForChanges();
  273. static void                     CollapsePath();
  274. X
  275. static void Initialize(), PositionChildren(), Realize(), Destroy();
  276. X
  277. FileNominatorClassRec fileNominatorClassRec = {
  278. X    /* Core class part */
  279. X  {
  280. X    /* superclass         */    (WidgetClass) &widgetClassRec,
  281. X    /* class_name         */ "FileNominator",
  282. X    /* widget_size         */ sizeof(FileNominatorRec),
  283. X    /* class_initialize      */ NULL,
  284. X    /* class_part_initialize */ NULL,
  285. X    /* class_inited          */    FALSE,
  286. X    /* initialize         */    Initialize,
  287. X    /* initialize_hook       */    NULL,
  288. X    /* realize             */    Realize,
  289. X    /* actions             */    NULL,
  290. X    /* num_actions         */    0,
  291. X    /* resources         */    resources,
  292. X    /* num_resources         */    XtNumber(resources),
  293. X    /* xrm_class         */    NULLQUARK,
  294. X    /* compress_motion         */    TRUE,
  295. X    /* compress_exposure     */    XtExposeCompressMultiple,
  296. X    /* compress_enterleave   */    TRUE,
  297. X    /* visible_interest         */    FALSE,
  298. X    /* destroy             */    Destroy,
  299. X    /* resize             */    PositionChildren,
  300. X    /* expose             */    NULL,
  301. X    /* set_values         */    NULL,
  302. X    /* set_values_hook       */    NULL,            
  303. X    /* set_values_almost     */    XtInheritSetValuesAlmost,  
  304. X    /* get_values_hook       */    NULL,
  305. X    /* accept_focus         */    NULL,
  306. X    /* version             */    XtVersion,
  307. X    /* callback offsets      */    NULL,
  308. X    /* tm_table              */    NULL,
  309. X    /* query_geometry         */    XtInheritQueryGeometry,
  310. X    /* display_accelerator   */    NULL,
  311. X    /* extension         */    NULL,
  312. X  },
  313. X   /* FileNominator class part */
  314. X  {
  315. X    /* extension         */    NULL,
  316. X  }
  317. };
  318. X
  319. WidgetClass fileNominatorWidgetClass = (WidgetClass) &fileNominatorClassRec;
  320. X
  321. static void
  322. CalculateSize(fnw, width, height)
  323. X    FileNominatorWidget fnw;
  324. X    Dimension *width, *height;
  325. {
  326. X    int file_width = Child(fnw,filename_widget)->core.width +
  327. X    2 * Child(fnw,filename_widget)->core.border_width;
  328. X    int select_width = Child(fnw,select_widget)->core.width + 
  329. X    2 * Child(fnw,select_widget)->core.border_width + fnw->fileNominator.margin +
  330. X        Child(fnw,cancel_widget)->core.width +
  331. X        2 * Child(fnw,cancel_widget)->core.border_width +
  332. X            Child(fnw,path_widget)->core.width +
  333. X    2 * Child(fnw,path_widget)->core.border_width + fnw->fileNominator.margin;
  334. X
  335. X    int max;
  336. X
  337. X    if (fnw->fileNominator.margin == 0)
  338. X    {
  339. X    max = select_width - 4 * (Child(fnw,select_widget)->core.border_width) >
  340. X        file_width - 2 * Child(fnw,filename_widget)->core.border_width ?
  341. X        select_width - 4 * (Child(fnw,select_widget)->core.border_width) :
  342. X            file_width - 2 * Child(fnw,filename_widget)->core.border_width;
  343. X    }
  344. X    else
  345. X    {
  346. X    max = select_width > file_width ? select_width : file_width;
  347. X    }
  348. X
  349. X    *width = max + 2 * fnw->fileNominator.margin;
  350. X    *height = Child(fnw,viewport_widget)->core.height +
  351. X        Child(fnw,filename_widget)->core.height +
  352. X        Child(fnw,select_widget)->core.height +
  353. X            4 * fnw->fileNominator.margin;
  354. X
  355. X    if (fnw->fileNominator.margin == 0)
  356. X    {
  357. X    *height += 2 * (Child(fnw,filename_widget)->core.border_width);
  358. X    }
  359. X    else
  360. X    {
  361. X    *height += 2 * (Child(fnw,filename_widget)->core.border_width +
  362. X               Child(fnw,viewport_widget)->core.border_width +
  363. X               Child(fnw,select_widget)->core.border_width);
  364. X    }
  365. }
  366. X
  367. static void
  368. PositionChildren(fnw)
  369. X    FileNominatorWidget fnw;
  370. {
  371. X    if (fnw->fileNominator.margin == 0)
  372. X    {
  373. X    XtConfigureWidget(Child(fnw,filename_widget),
  374. X              0, 0,
  375. X              fnw->core.width,
  376. X              fnw->core.height -
  377. X              Child(fnw,viewport_widget)->core.height -
  378. X              2 * Child(fnw,viewport_widget)->core.border_width -
  379. X              Child(fnw,select_widget)->core.height,
  380. X              0);
  381. X    }
  382. X    else
  383. X    {
  384. X          XtConfigureWidget(Child(fnw,filename_widget),
  385. X              fnw->fileNominator.margin,
  386. X              fnw->fileNominator.margin,
  387. X                  fnw->core.width -
  388. X                      2 * fnw->fileNominator.margin -
  389. X                      2 * Child(fnw,filename_widget)->core.border_width,
  390. X              fnw->core.height -
  391. X              2 * Child(fnw,filename_widget)->core.border_width -
  392. X              Child(fnw,viewport_widget)->core.height -
  393. X              2 * Child(fnw,viewport_widget)->core.border_width -
  394. X              Child(fnw,select_widget)->core.height -
  395. X              2 * Child(fnw,select_widget)->core.border_width -
  396. X              4 * fnw->fileNominator.margin,
  397. X              Child(fnw,filename_widget)->core.border_width);
  398. X      }
  399. X
  400. X    if (fnw->fileNominator.margin == 0)
  401. X    {
  402. X    XtConfigureWidget(Child(fnw,viewport_widget),
  403. X              -(Child(fnw,viewport_widget)->core.border_width),
  404. X              Child(fnw,filename_widget)->core.height,
  405. X              fnw->core.width,
  406. X              Child(fnw,viewport_widget)->core.height,
  407. X              Child(fnw,viewport_widget)->core.border_width);
  408. X    }
  409. X    else
  410. X    {
  411. X    XtConfigureWidget(Child(fnw,viewport_widget),
  412. X                          fnw->fileNominator.margin,
  413. X              fnw->core.height -
  414. X              Child(fnw,select_widget)->core.height -
  415. X              2 * Child(fnw,select_widget)->core.border_width -
  416. X              Child(fnw,viewport_widget)->core.height -
  417. X              2 * Child(fnw,viewport_widget)->core.border_width -
  418. X              2 * fnw->fileNominator.margin,
  419. X              fnw->core.width -
  420. X              2 * fnw->fileNominator.margin -
  421. X              2 * Child(fnw,viewport_widget)->core.border_width,
  422. X              Child(fnw,viewport_widget)->core.height,
  423. X              Child(fnw,viewport_widget)->core.border_width);
  424. X    }
  425. X
  426. X    if (fnw->fileNominator.margin == 0)
  427. X    {
  428. X    XtMoveWidget(Child(fnw,select_widget), -1,
  429. X             fnw->core.height -
  430. X             Child(fnw,select_widget)->core.height - 1);
  431. X    }
  432. X    else
  433. X    {
  434. X    XtMoveWidget(Child(fnw,select_widget), fnw->fileNominator.margin,
  435. X             fnw->core.height -
  436. X             fnw->fileNominator.margin -
  437. X             2 * Child(fnw,select_widget)->core.border_width -
  438. X             Child(fnw,select_widget)->core.height);
  439. X    }
  440. X    
  441. X
  442. X    if (fnw->fileNominator.margin == 0)
  443. X    {
  444. X    XtMoveWidget(Child(fnw,path_widget),
  445. X             Child(fnw,select_widget)->core.width,
  446. X             fnw->core.height -
  447. X             Child(fnw,select_widget)->core.height - 1);
  448. X    }
  449. X    else
  450. X    {
  451. X    XtMoveWidget(Child(fnw,path_widget),
  452. X             Child(fnw,select_widget)->core.width +
  453. X             2 * Child(fnw,select_widget)->core.border_width +
  454. X             2 * fnw->fileNominator.margin,
  455. X             fnw->core.height -
  456. X             fnw->fileNominator.margin -
  457. X             2 * Child(fnw,select_widget)->core.border_width -
  458. X             Child(fnw,select_widget)->core.height);
  459. X    }
  460. X    
  461. X    if (fnw->fileNominator.margin == 0)
  462. X    {
  463. X    XtMoveWidget(Child(fnw,cancel_widget), 
  464. X             Child(fnw,select_widget)->core.width +
  465. X             Child(fnw,path_widget)->core.width +
  466. X             Child(fnw,select_widget)->core.border_width,
  467. X             fnw->core.height -
  468. X             Child(fnw,select_widget)->core.height - 1);
  469. X    }
  470. X    else
  471. X    {
  472. X    XtMoveWidget(Child(fnw,cancel_widget), 
  473. X             Child(fnw,path_widget)->core.width +
  474. X             2 * Child(fnw,path_widget)->core.border_width +
  475. X             Child(fnw,select_widget)->core.width +
  476. X             2 * Child(fnw,select_widget)->core.border_width +
  477. X             3 * fnw->fileNominator.margin,
  478. X             fnw->core.height -
  479. X             fnw->fileNominator.margin -
  480. X             2 * Child(fnw,select_widget)->core.border_width -
  481. X             Child(fnw,select_widget)->core.height);
  482. X    }
  483. }
  484. X
  485. /* ARGSUSED */
  486. static void
  487. Initialize(req, new, args, num_args)
  488. X    Widget req, new;
  489. X    ArgList args;
  490. X    Cardinal *num_args;
  491. {
  492. X    FileNominatorWidget fnw = (FileNominatorWidget) new;
  493. X    Widget sMenu, menuEntry;
  494. X    String menuList, p, q;
  495. X
  496. X    List(new) = NULL;
  497. X    Nomination(new).directoryPart = NULL;
  498. X    Nomination(new).filenamePart = NULL;
  499. #ifdef SYSV
  500. X    (void) getcwd(CurrentDir(new), MAXPATHLEN);
  501. #else    
  502. X    (void) getwd(CurrentDir(new));
  503. #endif
  504. X    if (CurrentDir(new)[strlen(CurrentDir(new)) - 1] != '/')
  505. X    {
  506. X    strcat(CurrentDir(new), "/");
  507. X    }
  508. X    WatchingChanges(new) = False;
  509. X
  510. X    Child(fnw,viewport_widget)
  511. X    = XtVaCreateWidget("viewport", viewportWidgetClass, new,
  512. X               XtNallowVert, True,
  513. X               NULL);
  514. X
  515. X    Child(fnw,list_widget) =
  516. X    XtVaCreateManagedWidget("list", listWidgetClass, Child(fnw,viewport_widget),
  517. X                XtNdefaultColumns, 1,
  518. X                XtNforceColumns, True,
  519. X                NULL);
  520. X    XtOverrideTranslations(Child(fnw,list_widget),
  521. X               XtParseTranslationTable(listTranslations));
  522. X    XtAddCallback(Child(fnw,list_widget), XtNcallback, ReplaceFilename, NULL); 
  523. X    FillWindow(fnw);
  524. X
  525. X    Child(fnw,filename_widget)
  526. X    = XtVaCreateWidget("filename", asciiTextWidgetClass, new,
  527. X               XtNeditType, XawtextEdit,
  528. X               NULL);
  529. X    XtOverrideTranslations(Child(fnw,filename_widget),
  530. X               XtParseTranslationTable(filenameTranslations));
  531. X    
  532. X    XtSetKeyboardFocus(new, Child(fnw,filename_widget));
  533. X    WatchForChanges(fnw);
  534. X
  535. X    Child(fnw,select_widget)
  536. X    = XtVaCreateWidget("select", commandWidgetClass, new,
  537. X                           XtNlabel,  "OK",
  538. X               NULL);
  539. X    XtOverrideTranslations(Child(fnw,select_widget),
  540. X               XtParseTranslationTable(selectTranslations));
  541. X    if (fnw->fileNominator.select_menu)
  542. X    {
  543. X    sMenu = XtVaCreatePopupShell("selectMenu",
  544. X                     simpleMenuWidgetClass, Child(fnw,select_widget),
  545. X                     NULL);
  546. X    menuList = XtNewString(fnw->fileNominator.select_menu);
  547. X    p = menuList;
  548. X    for (p = menuList;  (q = (char *)index(p, ':'));  p = q + 1)
  549. X    {
  550. X        *q = '\0';
  551. X        menuEntry = XtVaCreateManagedWidget(p,
  552. X                        smeBSBObjectClass, sMenu,
  553. X                        NULL);
  554. X        XtAddCallback(menuEntry, XtNcallback, SelectDir, NULL);
  555. X    }
  556. X    menuEntry = XtVaCreateManagedWidget(p,
  557. X                        smeBSBObjectClass, sMenu,
  558. X                        NULL);
  559. X    XtAddCallback(menuEntry, XtNcallback, SelectDir, NULL);
  560. X    XtVaSetValues(sMenu,
  561. X              XtNpopupOnEntry, menuEntry,
  562. X              NULL);
  563. X    
  564. X    XtOverrideTranslations(Child(fnw,select_widget),
  565. X                  XtParseTranslationTable(selectMenuTranslations));
  566. X    
  567. X    XtFree(menuList);
  568. X    }
  569. X
  570. #ifdef GERMAN
  571. X    Child(fnw,path_widget)
  572. X    = XtVaCreateWidget("path", menuButtonWidgetClass, new,
  573. X                           XtNlabel,  "Pfad",
  574. X               NULL);
  575. #else    
  576. X    Child(fnw,path_widget)
  577. X    = XtVaCreateWidget("path", menuButtonWidgetClass, new,
  578. X                           XtNlabel,  "Path",
  579. X               NULL);
  580. #endif    
  581. X    XtOverrideTranslations(Child(fnw,path_widget),
  582. X               XtParseTranslationTable(pathTranslations));
  583. X    XtAppAddActions(XtWidgetToApplicationContext(new),
  584. X            pathActions, XtNumber(pathActions));
  585. X    XawSimpleMenuAddGlobalActions(XtWidgetToApplicationContext(new));
  586. X
  587. #ifdef GERMAN
  588. X    Child(fnw,cancel_widget)
  589. X    = XtVaCreateWidget("cancel", commandWidgetClass, new,
  590. X                             XtNlabel,  "Abbruch",
  591. X                             NULL);
  592. #else    
  593. X    Child(fnw,cancel_widget)
  594. X    = XtVaCreateWidget("cancel", commandWidgetClass, new,
  595. X                             XtNlabel,  "Cancel",
  596. X                             NULL);
  597. #endif    
  598. X    XtAddCallback(Child(fnw,cancel_widget), XtNcallback, CancelCallback, NULL); 
  599. X
  600. X    CalculateSize(fnw, &fnw->core.width, &fnw->core.height);
  601. X    PositionChildren(fnw);
  602. }
  603. X
  604. static void 
  605. Realize(w, valueMask, attributes)
  606. X    Widget w;
  607. X    XtValueMask *valueMask;
  608. X    XSetWindowAttributes *attributes;
  609. {
  610. X    (*fileNominatorWidgetClass->core_class.superclass->core_class.realize)
  611. X    (w, valueMask, attributes);
  612. X
  613. X    XtRealizeWidget(Child(w,viewport_widget));
  614. X    XtRealizeWidget(Child(w,list_widget));
  615. X    XtRealizeWidget(Child(w,filename_widget));
  616. X    XtRealizeWidget(Child(w,select_widget));
  617. X    XtRealizeWidget(Child(w,path_widget));
  618. X    XtRealizeWidget(Child(w,cancel_widget));
  619. X
  620. X    XMapSubwindows(XtDisplay(w), XtWindow(w));
  621. }
  622. X
  623. static void Destroy(w)
  624. X    Widget w;
  625. {
  626. X    int idx;
  627. X    FileNominatorWidget fnw = (FileNominatorWidget) w;
  628. X    XtDestroyWidget(Child(fnw,list_widget));
  629. X    XtDestroyWidget(Child(fnw,viewport_widget));
  630. X    XtDestroyWidget(Child(fnw,filename_widget));
  631. X    XtDestroyWidget(Child(fnw,select_widget));
  632. X    XtDestroyWidget(Child(fnw,path_widget));
  633. X    XtDestroyWidget(Child(fnw,cancel_widget));
  634. X
  635. X    idx = 0;
  636. X    while (List(fnw)[idx])
  637. X    {
  638. X    XtFree(List(fnw)[idx++]);
  639. X    }
  640. X    XtFree(List(fnw)[idx]);
  641. X    XtFree((char *)List(fnw));
  642. X
  643. X    XtFree(Nomination(fnw).directoryPart);
  644. X    XtFree(Nomination(fnw).filenamePart);
  645. }
  646. X
  647. /* ARGSUSED */
  648. static void 
  649. CancelCallback(w, client_data, call_data)
  650. X     Widget w;
  651. X     XtPointer client_data, call_data;
  652. {
  653. X    XtCallCallbacks(XtParent(w), XtNcancelCallback, NULL);
  654. }
  655. X
  656. /* ARGSUSED */
  657. static void
  658. DestroyMenu(w, client_data, call_data)
  659. X     Widget w;
  660. X     XtPointer client_data, call_data;
  661. {
  662. X    XtDestroyWidget(w);
  663. }
  664. X
  665. /* ARGSUSED */
  666. static void
  667. MakeMenu(w, event, params, num_params)
  668. X     Widget w;
  669. X     XEvent *event;
  670. X     String *params;
  671. X     Cardinal *num_params;
  672. {
  673. X    FileNominatorWidget fnw = (FileNominatorWidget) XtParent(w);
  674. X    String menuName;
  675. X    Widget menu, menuEntry;
  676. X    char *where, *p1, *p2;
  677. X    int menuItem = 1, len;
  678. X
  679. X    XtVaGetValues(w,
  680. X          XtNmenuName, &menuName,
  681. X          NULL);
  682. X    
  683. X    menu = XtVaCreatePopupShell(menuName,
  684. X                simpleMenuWidgetClass, w,
  685. X                NULL);
  686. X    XtAddCallback(menu, XtNpopdownCallback, DestroyMenu, NULL);
  687. X
  688. X    where = XtNewString(CurrentDir(fnw));
  689. X    menuEntry = XtVaCreateManagedWidget("/",
  690. X                    smeBSBObjectClass, menu, NULL);
  691. X    XtAddCallback(menuEntry, XtNcallback, ChangeDir, (XtPointer) menuItem++);
  692. X    p1 = where + 1;
  693. X    len = strlen(where);
  694. X    while (p1 < &where[len])
  695. X    {
  696. X    if (!(p2 = (char *)index(p1, '/')))
  697. X    {
  698. X        p2 = &where[len];
  699. X    }
  700. X    *p2 = '\0';
  701. X    menuEntry = XtVaCreateManagedWidget(p1,
  702. X                        smeBSBObjectClass, menu, NULL);
  703. X    XtAddCallback(menuEntry, XtNcallback, ChangeDir,
  704. X              (XtPointer) menuItem++);
  705. X    p1 = p2 + 1;
  706. X    }
  707. X    
  708. X    XtVaSetValues(menu,
  709. X          XtNpopupOnEntry, menuEntry,
  710. X          NULL);
  711. X    
  712. X    XtFree(where);
  713. }
  714. X
  715. static void
  716. ChangeDirectory(fnw, position)
  717. X     FileNominatorWidget fnw;
  718. X     int position;
  719. {
  720. X    String p;
  721. X    int m;
  722. X
  723. X    if (position > 0)
  724. X    {
  725. X    p = CurrentDir(fnw);
  726. X    for (m = 0;  m < position;  ++m)
  727. X    {
  728. X        while(*p++ != '/')
  729. X        ;
  730. X    }
  731. X    *p = '\0';
  732. X    }
  733. X
  734. X    XtVaSetValues(Child(fnw, filename_widget),
  735. X          XtNstring, "",
  736. X          NULL);
  737. X
  738. X    FillWindow(fnw);
  739. X
  740. X    PositionChildren(fnw);
  741. }
  742. X     
  743. /* ARGSUSED */
  744. static void
  745. ChangeDir(w, client_data, call_data)
  746. X     Widget w;
  747. X     XtPointer client_data, call_data;
  748. {
  749. X    FileNominatorWidget fnw
  750. X        = (FileNominatorWidget) XtParent(XtParent(XtParent(w)));
  751. X
  752. X    ChangeDirectory(fnw, (int) client_data);
  753. }
  754. X
  755. /* ARGSUSED */
  756. static void
  757. SelectDir(w, client_data, call_data)
  758. X     Widget w;
  759. X     XtPointer client_data, call_data;
  760. {
  761. X    FileNominatorWidget fnw
  762. X        = (FileNominatorWidget) XtParent(XtParent(XtParent(w)));
  763. X    String label;
  764. X
  765. X    XtVaGetValues(w,
  766. X          XtNlabel, &label,
  767. X          NULL);
  768. X
  769. X    XtVaSetValues(Child(fnw,filename_widget),
  770. X          XtNstring, label,
  771. X          NULL);
  772. X
  773. X    Nominate(Child(fnw,select_widget), NULL, NULL, NULL);
  774. }
  775. X
  776. /* ARGSUSED */
  777. static void
  778. Nominate(w, event, params, num_params)
  779. X     Widget w;
  780. X     XEvent *event;
  781. X     String *params;
  782. X     Cardinal *num_params;
  783. {
  784. X    FileNominatorWidget fnw;
  785. X    char *nomination, *home, selection[MAXPATHLEN], *newPath, *r;
  786. X    struct stat fstats;
  787. X    int status, len;
  788. X
  789. X    if (XtIsSubclass(w, listWidgetClass))
  790. X    {
  791. X    fnw = (FileNominatorWidget) XtParent(XtParent(w));
  792. X    }
  793. X    else
  794. X    {
  795. X    fnw = (FileNominatorWidget) XtParent(w);
  796. X    }
  797. X    
  798. X    XtVaGetValues(Child(fnw,filename_widget),
  799. X          XtNstring, &nomination,
  800. X          NULL);
  801. X
  802. X    selection[0] = '\0';
  803. X    if (*nomination == '/')
  804. X    {
  805. X    strcpy(selection, nomination);
  806. X    }
  807. X    else if (*nomination == '~' && (home = getenv("HOME")))
  808. X    {
  809. X    strcpy(selection, home);
  810. X    strcat(selection, &nomination[1]);
  811. X    }
  812. X    else
  813. X    {
  814. X    if (strlen(CurrentDir(fnw)) > 1)
  815. X    {
  816. X        strcpy(selection, CurrentDir(fnw));
  817. X    }
  818. X    strcat(selection, "/");
  819. X    strcat(selection, nomination);
  820. X    }
  821. X
  822. X    len = strlen(selection);
  823. X    if (len != 0)
  824. X    {
  825. X    newPath = (char *) XtMalloc(len + 2);
  826. X    CollapsePath(selection, newPath);
  827. X    status = stat(newPath, &fstats);
  828. X    if (status != -1 && fstats.st_mode & S_IFDIR)
  829. X    {
  830. X        if (access(newPath, R_OK) == 0)
  831. X        {
  832. X        if (newPath[strlen(newPath) - 1] != '/')
  833. X        {
  834. X            strcat(newPath, "/");
  835. X        }
  836. X        strcpy(CurrentDir(fnw), newPath);
  837. X        ChangeDirectory(fnw, 0);
  838. X        }
  839. X        else
  840. X        {
  841. X        XBell(XtDisplay(fnw), BellLevel(fnw));
  842. X        }
  843. X    }
  844. X    else if (status == 0 || (status == -1 && errno == ENOENT))
  845. X    {
  846. X        status = access(newPath, R_OK | W_OK);
  847. X        r = (char *)rindex(newPath, '/');
  848. X        XtFree(Nomination(fnw).filenamePart);
  849. X        Nomination(fnw).filenamePart = XtNewString(r + 1);
  850. X        Nomination(fnw).filenameStatus = (status == 0) ? status : errno;
  851. X        *(r + 1) = '\0';
  852. X        XtFree(Nomination(fnw).directoryPart);
  853. X        status = access(newPath, R_OK);
  854. X        if (strcmp(newPath, CurrentDir(fnw)) != 0 && status == 0)
  855. X        {
  856. X        strcpy(CurrentDir(fnw), newPath);
  857. X        ChangeDirectory(fnw, 0);
  858. X        Nomination(fnw).directoryPart = XtNewString(CurrentDir(fnw));
  859. X        }
  860. X        else
  861. X        {
  862. X        Nomination(fnw).directoryPart = XtNewString(newPath);
  863. X        }
  864. X        Nomination(fnw).directoryStatus = (status == 0) ? status : errno;
  865. X        XtCallCallbacks((Widget) fnw, XtNselectCallback,
  866. X                                    (XtPointer) &Nomination(fnw));
  867. X    }
  868. X    else
  869. X    {
  870. X            XBell(XtDisplay(fnw), BellLevel(fnw));
  871. X    }
  872. X    XtFree(newPath);
  873. X    }
  874. }
  875. X
  876. static void
  877. FillWindow(fnw)
  878. X     Widget fnw;
  879. {
  880. X    XFontStruct *font;
  881. X    Dimension height, internalHeight, rowSpacing;
  882. X    int num, newNum, idx;
  883. X    struct dirent **namelist;
  884. X    extern int alphasort();
  885. X    char buf[MAXPATHLEN], *bp;
  886. X    String name;
  887. X    struct stat fstats;
  888. X
  889. X    num = scandir(CurrentDir(fnw), &namelist, (int(*)())0, alphasort);
  890. X    if (num <= 0)
  891. X    {
  892. X    return;
  893. X    }
  894. X
  895. X    if (List(fnw))
  896. X    {
  897. X        idx = 0;
  898. X        while (List(fnw)[idx])
  899. X        {
  900. X            XtFree(List(fnw)[idx++]);
  901. X        }
  902. X    XtFree(List(fnw)[idx]);
  903. X    XtFree((char *)List(fnw));
  904. X    }
  905. X    List(fnw) = (String *) XtMalloc((num + 1) * sizeof(String));
  906. X
  907. X    strcpy(buf, CurrentDir(fnw));
  908. X    strcat(buf, "/");
  909. X    bp = buf + strlen(buf);
  910. X    for(idx = 0, newNum = 0; idx < num;  idx++)
  911. X    {
  912. X    name = namelist[idx]->d_name;
  913. X    if (ShowDotFiles(fnw) || (!ShowDotFiles(fnw) &&
  914. X                  (*name != '.' 
  915. X                  || ((strcmp(name, ".") == 0) ||
  916. X                      (strcmp(name, "..") == 0)))))
  917. X    {
  918. X        List(fnw)[newNum] = XtMalloc(strlen(name) + 2);
  919. X        strcpy(List(fnw)[newNum], name);
  920. X        strcpy(bp, name);
  921. X        (void) stat(buf, &fstats);
  922. X        if (fstats.st_mode & S_IFDIR)
  923. X        {
  924. X        strcat(List(fnw)[newNum], "/");
  925. X        }
  926. X        ++newNum;
  927. X    }
  928. X    }
  929. X
  930. X    for(idx = 0; idx < num;  idx++)
  931. X    {
  932. X    XtFree((char *)namelist[idx]);
  933. X    }
  934. X    XtFree((char *)namelist);
  935. X
  936. X    List(fnw)[newNum] = NULL;
  937. X
  938. X    XtVaGetValues(Child(fnw,list_widget),
  939. X                  XtNfont, &font,
  940. X                  XtNinternalHeight, &internalHeight,
  941. X          XtNrowSpacing, &rowSpacing,
  942. X                  NULL);
  943. X
  944. X    height = Rows(fnw) * (font->max_bounds.ascent +
  945. X             font->max_bounds.descent + rowSpacing) -
  946. X             rowSpacing + 2 * internalHeight; 
  947. X
  948. X    XtVaSetValues(Child(fnw,viewport_widget),
  949. X                  XtNheight, height,
  950. X                  NULL);
  951. X
  952. X    XawListChange(Child(fnw,list_widget), List(fnw), newNum, -1, True);
  953. }
  954. X
  955. /* ARGSUSED */
  956. static void
  957. ToggleDotFiles(w, event, params, num_params)
  958. X     Widget w;
  959. X     XEvent *event;
  960. X     String *params;
  961. X     Cardinal *num_params;
  962. {
  963. X    Widget fnw = XtParent(w);
  964. X    Boolean showDotFiles;
  965. X
  966. X    XtVaGetValues(fnw,
  967. X          XtNshowDotFiles, &showDotFiles,
  968. X          NULL);
  969. X
  970. X    XtVaSetValues(fnw,
  971. X          XtNshowDotFiles, !showDotFiles,
  972. X          NULL);
  973. X
  974. X    XtVaSetValues(w,
  975. X          XtNstring, "./",
  976. X          NULL);
  977. X
  978. X    Nominate(Child(fnw,select_widget), NULL, NULL, NULL);
  979. }
  980. X
  981. /* ARGSUSED */
  982. static void
  983. ReplaceFilename(w, client_data, call_data)
  984. X     Widget w;
  985. X     XtPointer client_data, call_data;
  986. {
  987. X    FileNominatorWidget fnw
  988. X    = (FileNominatorWidget) XtParent(XtParent(w));
  989. X
  990. X    XawListReturnStruct *list = XawListShowCurrent(Child(fnw,list_widget));
  991. X
  992. X    XtVaSetValues(Child(fnw,filename_widget),
  993. X          XtNstring, list->string,
  994. X          NULL);
  995. X
  996. X    XawTextSetInsertionPoint(Child(fnw,filename_widget),
  997. X                 (XawTextPosition) strlen(list->string));
  998. X
  999. X    WatchForChanges(fnw);
  1000. }
  1001. X
  1002. /* ARGSUSED */
  1003. static void
  1004. AsciiSourceChanged(w, client_data, call_data)
  1005. Widget w;
  1006. XXtPointer client_data, call_data;
  1007. {
  1008. X    FileNominatorWidget fnw = (FileNominatorWidget) client_data;
  1009. X
  1010. X    DontWatchForChanges(fnw);
  1011. X
  1012. X    XawListUnhighlight(Child(fnw,list_widget));
  1013. }
  1014. X
  1015. static void
  1016. WatchForChanges(fnw)
  1017. X     Widget fnw;
  1018. {
  1019. X    if (!WatchingChanges(fnw))
  1020. X    {
  1021. X    XtAddCallback(XawTextGetSource(Child(fnw,filename_widget)), XtNcallback,
  1022. X              AsciiSourceChanged, (XtPointer) fnw);
  1023. X
  1024. X    WatchingChanges(fnw) = True;
  1025. X    }
  1026. }
  1027. X
  1028. static void
  1029. DontWatchForChanges(fnw)
  1030. X     Widget fnw;
  1031. {
  1032. X    XtRemoveCallback(XawTextGetSource(Child(fnw,filename_widget)), XtNcallback,
  1033. X             AsciiSourceChanged, (XtPointer) fnw);
  1034. X
  1035. X    WatchingChanges(fnw) = False;
  1036. }
  1037. X
  1038. static void 
  1039. CollapsePath(in, out)
  1040. X     char *in, *out;
  1041. {
  1042. X    char *p = in, *q = out, *pend = p + strlen(p);
  1043. X    
  1044. X    while (p < pend)
  1045. X    {
  1046. X    if (*p != '/')
  1047. X    {
  1048. X        *q++ = *p++;
  1049. X    }
  1050. X    else if (p + 1 < pend && *(p + 1) == '/')
  1051. X    {
  1052. X        ++p;
  1053. X    }
  1054. X    else if ( (p + 2 == pend && *(p + 1) == '.') || 
  1055. X          (p + 2 < pend && *(p + 1) == '.' && *(p + 2) == '/') )
  1056. X    {
  1057. X        p += 2;
  1058. X    }
  1059. X    else if ( (p + 3 == pend && *(p + 1) == '.' && *(p + 2) == '.') ||
  1060. X         (p + 3 < pend && *(p + 1) == '.'
  1061. X                              && *(p + 2) == '.' && *(p + 3) == '/') )
  1062. X    {
  1063. X        while (q > out && *--q != '/')
  1064. X        ;
  1065. X        p += 3;
  1066. X    }
  1067. X    else
  1068. X    {
  1069. X        *q++ = *p++;
  1070. X    }
  1071. X    }
  1072. X    if (q == out)
  1073. X    {
  1074. X    *q++ = '/';
  1075. X    }
  1076. X
  1077. X    while (q > out)
  1078. X    {
  1079. X    if (*--q != '/')
  1080. X        break;
  1081. X    }
  1082. X    *++q = '\0';
  1083. }
  1084. X
  1085. String
  1086. FileNominatorGetDirectory(fnw)
  1087. X     Widget fnw;
  1088. {
  1089. X    if (XtIsSubclass(fnw, fileNominatorWidgetClass))
  1090. X    {
  1091. X    return CurrentDir(fnw);
  1092. X    }
  1093. X    else
  1094. X    {
  1095. X    return NULL;
  1096. X    }
  1097. }
  1098. X
  1099. String
  1100. FileNominatorGetFileName(fnw)
  1101. Widget fnw;
  1102. {
  1103. X    String newName;
  1104. X
  1105. X    if (XtIsSubclass(fnw, fileNominatorWidgetClass))
  1106. X    {
  1107. X    
  1108. X      FileNominatorStruct data =  Nomination(fnw);
  1109. X
  1110. X      if (data.directoryStatus == 0)
  1111. X      {
  1112. X    newName = XtMalloc(strlen(data.filenamePart) + 1);
  1113. X    strcpy(newName, data.filenamePart);
  1114. X        return newName;
  1115. X      }
  1116. X    }
  1117. X    else
  1118. X    {
  1119. X    return NULL;
  1120. X    }
  1121. }
  1122. X
  1123. String
  1124. FileNominatorGetFullFileName(fnw)
  1125. X     Widget fnw;
  1126. {
  1127. X    String newName;
  1128. X
  1129. X    if (XtIsSubclass(fnw, fileNominatorWidgetClass))
  1130. X    {
  1131. X    
  1132. X      FileNominatorStruct data =  Nomination(fnw);
  1133. X
  1134. X      if (data.directoryStatus == 0)
  1135. X      {
  1136. X    newName = XtMalloc(strlen(data.directoryPart)
  1137. X               + strlen(data.filenamePart) + 1);
  1138. X    strcpy(newName, data.directoryPart);
  1139. X    strcat(newName, data.filenamePart);
  1140. X        return newName;
  1141. X      }
  1142. X    }
  1143. X    else
  1144. X    {
  1145. X    return NULL;
  1146. X    }
  1147. }
  1148. X
  1149. X
  1150. void
  1151. FileNominatorSetDirectory(fnw, dir)
  1152. X     Widget fnw;
  1153. X     String dir;
  1154. {
  1155. X    if (!XtIsSubclass(fnw, fileNominatorWidgetClass))
  1156. X    {
  1157. X    return;
  1158. X    }
  1159. X
  1160. X    /* Should do more checks */
  1161. X    strcpy(CurrentDir(fnw), dir);
  1162. X    if (dir[strlen(dir) - 1] != '/')
  1163. X    {
  1164. X    strcat(CurrentDir(fnw), "/");
  1165. X    }
  1166. X
  1167. X    ChangeDirectory(fnw, 0);
  1168. }
  1169. SHAR_EOF
  1170. chmod 0644 FileNom.c ||
  1171. echo 'restore of FileNom.c failed'
  1172. Wc_c="`wc -c < 'FileNom.c'`"
  1173. test 28730 -eq "$Wc_c" ||
  1174.     echo 'FileNom.c: original size 28730, current size' "$Wc_c"
  1175. rm -f _shar_wnt_.tmp
  1176. fi
  1177. # ============= FileNom.h ==============
  1178. if test -f 'FileNom.h' -a X"$1" != X"-c"; then
  1179.     echo 'x - skipping FileNom.h (File already exists)'
  1180.     rm -f _shar_wnt_.tmp
  1181. else
  1182. > _shar_wnt_.tmp
  1183. echo 'x - extracting FileNom.h (Text)'
  1184. sed 's/^X//' << 'SHAR_EOF' > 'FileNom.h' &&
  1185. /*********************************************************************/
  1186. /*  bibView: Administration of bibTex-Databases                      */
  1187. /*           (Verwaltung von bibTeX-Literaturdatenbanken)            */
  1188. /*                                                                   */
  1189. /*  Module:  FileNom.h                                               */
  1190. /*                                                                   */
  1191. /*             - File Selection Box                                  */
  1192. /*               Adapted and modified Widget from aXe editor         */
  1193. /*                                                                   */
  1194. /*  Author:  Holger Martin,  martinh@informatik.tu-muenchen.de       */
  1195. /*           Peter M. Urban, urban@informatik.tu-muenchen.de         */
  1196. /*                                                                   */
  1197. /*  History:                                                         */
  1198. /*    11.22.91  HM   created                                         */
  1199. /*                                                                   */
  1200. /*  Copyright 1991 Martin, Urban                                     */
  1201. /*    See ./Copyright for complete rights and liability information. */
  1202. /*                                                                   */
  1203. /*********************************************************************/
  1204. X
  1205. /*
  1206. X * Copyright 1991 The University of Newcastle upon Tyne
  1207. X * 
  1208. X * Permission to use, copy, modify and distribute this software and its
  1209. X * documentation for any purpose other than its commercial exploitation
  1210. X * is hereby granted without fee, provided that the above copyright
  1211. X * notice appear in all copies and that both that copyright notice and
  1212. X * this permission notice appear in supporting documentation, and that
  1213. X * the name of The University of Newcastle upon Tyne not be used in
  1214. X * advertising or publicity pertaining to distribution of the software
  1215. X * without specific, written prior permission. The University of
  1216. X * Newcastle upon Tyne makes no representations about the suitability of
  1217. X * this software for any purpose. It is provided "as is" without express
  1218. X * or implied warranty.
  1219. X * 
  1220. X * THE UNIVERSITY OF NEWCASTLE UPON TYNE DISCLAIMS ALL WARRANTIES WITH
  1221. X * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
  1222. X * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF
  1223. X * NEWCASTLE UPON TYNE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  1224. X * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  1225. X * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  1226. X * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1227. X * PERFORMANCE OF THIS SOFTWARE.
  1228. X * 
  1229. X * Author:  Jim Wight (j.k.wight@newcastle.ac.uk)
  1230. X *          Computing Laboratory, University of Newcastle upon Tyne, UK
  1231. X */
  1232. X
  1233. X
  1234. #ifndef FileNominator_h
  1235. #define FileNominator_h
  1236. X
  1237. #define XtNselectCallback "selectCallback"
  1238. #define XtNselectMenu "selectMenu"
  1239. #define XtNcancelCallback "cancelCallback"
  1240. #define XtNmargin "margin"
  1241. #define XtNnumberRows "numberRows"
  1242. #define XtNshowDotFiles "showDotFiles"
  1243. #define XtNbellLevel "bellLevel"
  1244. X
  1245. extern WidgetClass fileNominatorWidgetClass;
  1246. X
  1247. typedef struct _FileNominatorRec *FileNominatorWidget;
  1248. typedef struct {
  1249. X    String  directoryPart;
  1250. X    int     directoryStatus;
  1251. X    String  filenamePart;
  1252. X    int     filenameStatus;
  1253. } FileNominatorStruct;
  1254. X
  1255. String FileNominatorGetDirectory();
  1256. String FileNominatorGetFileName();
  1257. String FileNominatorGetFullFileName();
  1258. void   FileNominatorSetDirectory();
  1259. X
  1260. #endif /* FileNominator_h */
  1261. SHAR_EOF
  1262. chmod 0644 FileNom.h ||
  1263. echo 'restore of FileNom.h failed'
  1264. Wc_c="`wc -c < 'FileNom.h'`"
  1265. test 3548 -eq "$Wc_c" ||
  1266.     echo 'FileNom.h: original size 3548, current size' "$Wc_c"
  1267. rm -f _shar_wnt_.tmp
  1268. fi
  1269. # ============= FileNomP.h ==============
  1270. if test -f 'FileNomP.h' -a X"$1" != X"-c"; then
  1271.     echo 'x - skipping FileNomP.h (File already exists)'
  1272.     rm -f _shar_wnt_.tmp
  1273. else
  1274. > _shar_wnt_.tmp
  1275. echo 'x - extracting FileNomP.h (Text)'
  1276. sed 's/^X//' << 'SHAR_EOF' > 'FileNomP.h' &&
  1277. /*********************************************************************/
  1278. /*  bibView: Administration of bibTex-Databases                      */
  1279. /*           (Verwaltung von bibTeX-Literaturdatenbanken)            */
  1280. /*                                                                   */
  1281. /*  Module:  FileNomP.c                                              */
  1282. /*                                                                   */
  1283. /*             - File Selection Box                                  */
  1284. /*               Adapted and modified Widget from aXe editor         */
  1285. /*                                                                   */
  1286. /*  Author:  Holger Martin,  martinh@informatik.tu-muenchen.de       */
  1287. /*           Peter M. Urban, urban@informatik.tu-muenchen.de         */
  1288. /*                                                                   */
  1289. /*  History:                                                         */
  1290. /*    11.22.91  HM   created                                         */
  1291. /*                                                                   */
  1292. /*  Copyright 1991 Martin, Urban                                     */
  1293. /*    See ./Copyright for complete rights and liability information. */
  1294. /*                                                                   */
  1295. /*********************************************************************/
  1296. X
  1297. /*
  1298. X * Copyright 1991 The University of Newcastle upon Tyne
  1299. X * 
  1300. X * Permission to use, copy, modify and distribute this software and its
  1301. X * documentation for any purpose other than its commercial exploitation
  1302. X * is hereby granted without fee, provided that the above copyright
  1303. X * notice appear in all copies and that both that copyright notice and
  1304. X * this permission notice appear in supporting documentation, and that
  1305. X * the name of The University of Newcastle upon Tyne not be used in
  1306. X * advertising or publicity pertaining to distribution of the software
  1307. X * without specific, written prior permission. The University of
  1308. X * Newcastle upon Tyne makes no representations about the suitability of
  1309. X * this software for any purpose. It is provided "as is" without express
  1310. X * or implied warranty.
  1311. X * 
  1312. X * THE UNIVERSITY OF NEWCASTLE UPON TYNE DISCLAIMS ALL WARRANTIES WITH
  1313. X * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
  1314. X * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF
  1315. X * NEWCASTLE UPON TYNE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  1316. X * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  1317. X * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  1318. X * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1319. X * PERFORMANCE OF THIS SOFTWARE.
  1320. X * 
  1321. X * Author:  Jim Wight (j.k.wight@newcastle.ac.uk)
  1322. X *          Computing Laboratory, University of Newcastle upon Tyne, UK
  1323. X */
  1324. X
  1325. X
  1326. #ifndef FileNominatorP_h
  1327. #define FileNominatorP_h
  1328. X
  1329. #include "FileNom.h"
  1330. X
  1331. #define XtCSelectMenu "SelectMenu"
  1332. #define XtCShowDotFiles "ShowDotFiles"
  1333. #define XtCBellLevel "BellLevel"
  1334. X
  1335. typedef struct {
  1336. X    /* resources */
  1337. X    XtCallbackList      select_callback;
  1338. X    String              select_menu;
  1339. X    XtCallbackList      cancel_callback;
  1340. X    Dimension           margin;
  1341. X    int                 number_rows;
  1342. X    Boolean             show_dot_files;
  1343. X    int                 bell_level;
  1344. X    
  1345. X    /* private data */
  1346. X    Widget              viewport_widget;
  1347. X    Widget              list_widget;
  1348. X    Widget        filename_widget;
  1349. X    Widget              select_widget;
  1350. X    Widget              path_widget;
  1351. X    Widget        cancel_widget;    
  1352. X    String              *listList;
  1353. X    char                currentDir[MAXPATHLEN];
  1354. X    Boolean             watchingChanges;
  1355. X    FileNominatorStruct nomination;
  1356. } FileNominatorPart;
  1357. X
  1358. typedef struct _FileNominatorRec {
  1359. X    CorePart        core;
  1360. X    FileNominatorPart    fileNominator;
  1361. } FileNominatorRec;
  1362. X
  1363. typedef struct {
  1364. X    XtPointer        extension;
  1365. } FileNominatorClassPart;
  1366. X
  1367. typedef struct _FileNominatorClassRec {
  1368. X    CoreClassPart            core_class;
  1369. X    FileNominatorClassPart    fileNominator_class;
  1370. } FileNominatorClassRec, *FileNominatorClass;
  1371. X
  1372. extern FileNominatorClassRec fileNominatorClassRec;
  1373. X
  1374. #endif /* FileNominatorP_h */
  1375. X
  1376. SHAR_EOF
  1377. chmod 0644 FileNomP.h ||
  1378. echo 'restore of FileNomP.h failed'
  1379. Wc_c="`wc -c < 'FileNomP.h'`"
  1380. test 4158 -eq "$Wc_c" ||
  1381.     echo 'FileNomP.h: original size 4158, current size' "$Wc_c"
  1382. rm -f _shar_wnt_.tmp
  1383. fi
  1384. # ============= Imakefile ==============
  1385. if test -f 'Imakefile' -a X"$1" != X"-c"; then
  1386.     echo 'x - skipping Imakefile (File already exists)'
  1387.     rm -f _shar_wnt_.tmp
  1388. else
  1389. > _shar_wnt_.tmp
  1390. echo 'x - extracting Imakefile (Text)'
  1391. sed 's/^X//' << 'SHAR_EOF' > 'Imakefile' &&
  1392. #
  1393. # bibView
  1394. #
  1395. #
  1396. X
  1397. SYS_LIBRARIES = -lm
  1398. CDEBUGFLAGS = 
  1399. X
  1400. #ifdef HPArchitecture
  1401. DEFINES = -D_HPUX_SOURCE
  1402. SYS_LIBRARIES = -lm
  1403. CDEBUGFLAGS = 
  1404. CC = cc -Aa 
  1405. #else
  1406. CCOPTIONS =
  1407. CFLAGS = 
  1408. CC = gcc -fstrength-reduce -fpcc-struct-return
  1409. #endif /* HPArchitecture */
  1410. X
  1411. LOCAL_LIBRARIES = -lc $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
  1412. DEPLIBS = $(DEPXLIB)
  1413. X
  1414. SRCS=    bibview.c FileNom.c gui_main.c ctl_open.c ctl_opt.c\
  1415. X    gui_bibl.c gui_help.c ctl_srch.c gui_widg.c ctl_save.c\
  1416. X    gui_list.c gui_card.c ctl_card.c ctl_serv.c\
  1417. X    db_tree.c bib_file.c globdata.c bib_flex.c\
  1418. X    ComboBo.c rc_file.c ctl_prt.c gui_edit.c
  1419. OBJS=    bibview.o FileNom.o gui_main.o ctl_open.o ctl_opt.o\
  1420. X    gui_bibl.o gui_help.o ctl_srch.o gui_widg.o ctl_save.o\
  1421. X    gui_list.o gui_card.o ctl_card.o ctl_serv.o\
  1422. X    db_tree.o bib_file.o globdata.o bib_flex.o\
  1423. X    ComboBo.o rc_file.o ctl_prt.o gui_edit.o
  1424. X
  1425. PROGRAMS = bibview
  1426. all::  $(PROGRAMS)
  1427. X
  1428. ComplexProgramTarget(bibview)
  1429. X
  1430. SHAR_EOF
  1431. chmod 0640 Imakefile ||
  1432. echo 'restore of Imakefile failed'
  1433. Wc_c="`wc -c < 'Imakefile'`"
  1434. test 905 -eq "$Wc_c" ||
  1435.     echo 'Imakefile: original size 905, current size' "$Wc_c"
  1436. rm -f _shar_wnt_.tmp
  1437. fi
  1438. # ============= Makefile ==============
  1439. if test -f 'Makefile' -a X"$1" != X"-c"; then
  1440.     echo 'x - skipping Makefile (File already exists)'
  1441.     rm -f _shar_wnt_.tmp
  1442. else
  1443. > _shar_wnt_.tmp
  1444. echo 'x - extracting Makefile (Text)'
  1445. sed 's/^X//' << 'SHAR_EOF' > 'Makefile' &&
  1446. # Makefile generated by imake - do not edit!
  1447. # $XConsortium: imake.c,v 1.65 91/07/25 17:50:17 rws Exp $
  1448. #
  1449. # The cpp used on this machine replaces all newlines and multiple tabs and
  1450. # spaces in a macro expansion with a single space.  Imake tries to compensate
  1451. # for this, but is not always successful.
  1452. #
  1453. X
  1454. # -------------------------------------------------------------------------
  1455. # Makefile generated from "Imake.tmpl" and </tmp/IIf.a02095>
  1456. # $XConsortium: Imake.tmpl,v 1.139 91/09/16 08:52:48 rws Exp $
  1457. #
  1458. # Platform-specific parameters may be set in the appropriate <vendor>.cf
  1459. # configuration files.  Site-specific parameters should be set in the file
  1460. # site.def.  Full rebuilds are recommended if any parameters are changed.
  1461. #
  1462. # If your C preprocessor does not define any unique symbols, you will need
  1463. # to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
  1464. # "make World" the first time).
  1465. #
  1466. X
  1467. # -------------------------------------------------------------------------
  1468. # site-specific configuration parameters that need to come before
  1469. # the platform-specific parameters - edit site.def to change
  1470. X
  1471. # site:  $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $
  1472. X
  1473. # -------------------------------------------------------------------------
  1474. # platform-specific configuration parameters - edit hp.cf to change
  1475. X
  1476. # platform:  $XConsortium: hp.cf,v 1.47 91/07/28 22:39:35 rws Exp $
  1477. X
  1478. # operating system:  HP-UX 8.05
  1479. X
  1480. # we have shared libs
  1481. X
  1482. # -------------------------------------------------------------------------
  1483. # site-specific configuration parameters that go after
  1484. # the platform-specific parameters - edit site.def to change
  1485. X
  1486. # site:  $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $
  1487. X
  1488. X            SHELL = /bin/sh
  1489. X
  1490. X              TOP = .
  1491. X      CURRENT_DIR = .
  1492. X
  1493. X               AR = ar clq
  1494. X  BOOTSTRAPCFLAGS =
  1495. X               CC = cc
  1496. X               AS = as
  1497. X
  1498. X         COMPRESS = compress
  1499. X              CPP = /lib/cpp $(STD_CPP_DEFINES)
  1500. X    PREPROCESSCMD = cc -E $(STD_CPP_DEFINES)
  1501. X          INSTALL = $(BINDIR)/bsdinst
  1502. X               LD = ld
  1503. X             LINT = lint
  1504. X      LINTLIBFLAG = -o
  1505. X         LINTOPTS = -ax
  1506. X               LN = ln -s
  1507. X             MAKE = make
  1508. X               MV = mv -f
  1509. X               CP = cp
  1510. X
  1511. X               RM = rm -f
  1512. X            TROFF = psroff
  1513. X         MSMACROS = -ms
  1514. X              TBL = tbl
  1515. X              EQN = eqn
  1516. X     STD_INCLUDES =
  1517. X  STD_CPP_DEFINES = -DSYSV
  1518. X      STD_DEFINES = -DSYSV
  1519. X EXTRA_LOAD_FLAGS =
  1520. X  EXTRA_LIBRARIES =
  1521. X             TAGS = ctags
  1522. X
  1523. X           MFLAGS = -$(MAKEFLAGS)
  1524. X
  1525. X    SHAREDCODEDEF = -DSHAREDCODE
  1526. X         SHLIBDEF =
  1527. X
  1528. X
  1529. X    PROTO_DEFINES =
  1530. X
  1531. X     INSTPGMFLAGS =
  1532. X
  1533. X     INSTBINFLAGS = -m 0755
  1534. X     INSTUIDFLAGS = -m 4755
  1535. X     INSTLIBFLAGS = -m 0644
  1536. X     INSTINCFLAGS = -m 0444
  1537. X     INSTMANFLAGS = -m 0444
  1538. X     INSTDATFLAGS = -m 0444
  1539. X    INSTKMEMFLAGS = -m 4755
  1540. X
  1541. X      CDEBUGFLAGS = +O1 -Wp,-H200000
  1542. X        CCOPTIONS =
  1543. X
  1544. X      ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(STD_INCLUDES)
  1545. X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(DEFINES)
  1546. X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES)
  1547. X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES)
  1548. X
  1549. X           LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  1550. X
  1551. X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) $(LOCAL_LDFLAGS)
  1552. X
  1553. X   LDCOMBINEFLAGS = -X -r
  1554. X      DEPENDFLAGS =
  1555. X
  1556. X        MACROFILE = hp.cf
  1557. X           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut
  1558. X
  1559. X    IMAKE_DEFINES =
  1560. X
  1561. X         IRULESRC = $(CONFIGDIR)
  1562. X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
  1563. X
  1564. X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \
  1565. X            $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \
  1566. X            $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
  1567. X
  1568. # -------------------------------------------------------------------------
  1569. # X Window System Build Parameters
  1570. # $XConsortium: Project.tmpl,v 1.138 91/09/10 09:02:12 rws Exp $
  1571. X
  1572. X          PATHSEP = /
  1573. X        USRLIBDIR = /usr/lib
  1574. X           BINDIR = /usr/bin/X11
  1575. X          INCROOT = /usr/include
  1576. X     BUILDINCROOT = $(TOP)
  1577. X      BUILDINCDIR = $(BUILDINCROOT)/X11
  1578. X      BUILDINCTOP = ..
  1579. X           INCDIR = $(INCROOT)/X11
  1580. X           ADMDIR = /usr/adm
  1581. X           LIBDIR = $(USRLIBDIR)/X11
  1582. X        CONFIGDIR = $(LIBDIR)/config
  1583. X       LINTLIBDIR = $(USRLIBDIR)/lint
  1584. X
  1585. X          FONTDIR = $(LIBDIR)/fonts
  1586. X         XINITDIR = $(LIBDIR)/xinit
  1587. X           XDMDIR = $(LIBDIR)/xdm
  1588. X           TWMDIR = $(LIBDIR)/twm
  1589. X          MANPATH = /usr/man
  1590. X    MANSOURCEPATH = $(MANPATH)/man
  1591. X        MANSUFFIX = n
  1592. X     LIBMANSUFFIX = 3
  1593. X           MANDIR = $(MANSOURCEPATH)$(MANSUFFIX)
  1594. X        LIBMANDIR = $(MANSOURCEPATH)$(LIBMANSUFFIX)
  1595. X           NLSDIR = $(LIBDIR)/nls
  1596. X        PEXAPIDIR = $(LIBDIR)/PEX
  1597. X      XAPPLOADDIR = $(LIBDIR)/app-defaults
  1598. X       FONTCFLAGS = -t
  1599. X
  1600. X     INSTAPPFLAGS = $(INSTDATFLAGS)
  1601. X
  1602. X            IMAKE = imake
  1603. X           DEPEND = makedepend
  1604. X              RGB = rgb
  1605. X
  1606. X            FONTC = bdftopcf
  1607. X
  1608. X        MKFONTDIR = mkfontdir
  1609. X        MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier
  1610. X
  1611. X        CONFIGSRC = $(TOP)/config
  1612. X       DOCUTILSRC = $(TOP)/doc/util
  1613. X        CLIENTSRC = $(TOP)/clients
  1614. X          DEMOSRC = $(TOP)/demos
  1615. X           LIBSRC = $(TOP)/lib
  1616. X          FONTSRC = $(TOP)/fonts
  1617. X       INCLUDESRC = $(TOP)/X11
  1618. X        SERVERSRC = $(TOP)/server
  1619. X          UTILSRC = $(TOP)/util
  1620. X        SCRIPTSRC = $(UTILSRC)/scripts
  1621. X       EXAMPLESRC = $(TOP)/examples
  1622. X       CONTRIBSRC = $(TOP)/../contrib
  1623. X           DOCSRC = $(TOP)/doc
  1624. X           RGBSRC = $(TOP)/rgb
  1625. X        DEPENDSRC = $(UTILSRC)/makedepend
  1626. X         IMAKESRC = $(CONFIGSRC)
  1627. X         XAUTHSRC = $(LIBSRC)/Xau
  1628. X          XLIBSRC = $(LIBSRC)/X
  1629. X           XMUSRC = $(LIBSRC)/Xmu
  1630. X       TOOLKITSRC = $(LIBSRC)/Xt
  1631. X       AWIDGETSRC = $(LIBSRC)/Xaw
  1632. X       OLDXLIBSRC = $(LIBSRC)/oldX
  1633. X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
  1634. X      BDFTOSNFSRC = $(FONTSRC)/bdftosnf
  1635. X      BDFTOSNFSRC = $(FONTSRC)/clients/bdftosnf
  1636. X      BDFTOPCFSRC = $(FONTSRC)/clients/bdftopcf
  1637. X     MKFONTDIRSRC = $(FONTSRC)/clients/mkfontdir
  1638. X         FSLIBSRC = $(FONTSRC)/lib/fs
  1639. X    FONTSERVERSRC = $(FONTSRC)/server
  1640. X     EXTENSIONSRC = $(TOP)/extensions
  1641. SHAR_EOF
  1642. true || echo 'restore of Makefile failed'
  1643. fi
  1644. echo 'End of  part 2'
  1645. echo 'File Makefile is continued in part 3'
  1646. echo 3 > _shar_seq_.tmp
  1647. exit 0
  1648. -- 
  1649. Senior Systems Scientist        mail: dcmartin@msi.com
  1650. Molecular Simulations, Inc.        uucp: uunet!dcmartin
  1651. 796 North Pastoria Avenue        at&t: 408/522-9236
  1652. Sunnyvale, California 94086        fax: 408/732-0831
  1653.