home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / alt / sources / 2563 < prev    next >
Encoding:
Text File  |  1992-11-18  |  50.1 KB  |  2,018 lines

  1. Newsgroups: alt.sources
  2. Path: sparky!uunet!sun-barr!cs.utexas.edu!zaphod.mps.ohio-state.edu!darwin.sura.net!sgiblab!munnari.oz.au!manuel.anu.edu.au!csc.canberra.edu.au!pandonia!jan
  3. From: jan@pandonia.canberra.edu.au (Jan Newmarch)
  4. Subject: X11/Motif file manager - part 08 of 17
  5. Message-ID: <1992Nov19.052335.25838@csc.canberra.edu.au>
  6. Sender: news@csc.canberra.edu.au
  7. Organization: University of Canberra
  8. Date: Thu, 19 Nov 92 05:23:35 GMT
  9. Lines: 2007
  10.  
  11.  
  12.  
  13. #!/bin/sh
  14. # this is part.08 (part 8 of a multipart archive)
  15. # do not concatenate these parts, unpack them in order with /bin/sh
  16. # file xmfm/rdd.c continued
  17. #
  18. if test ! -r _shar_seq_.tmp; then
  19.     echo 'Please unpack part 1 first!'
  20.     exit 1
  21. fi
  22. (read Scheck
  23.  if test "$Scheck" != 8; then
  24.     echo Please unpack part "$Scheck" next!
  25.     exit 1
  26.  else
  27.     exit 0
  28.  fi
  29. ) < _shar_seq_.tmp || exit 1
  30. if test ! -f _shar_wnt_.tmp; then
  31.     echo 'x - still skipping xmfm/rdd.c'
  32. else
  33. echo 'x - continuing file xmfm/rdd.c'
  34. sed 's/^X//' << 'SHAR_EOF' >> 'xmfm/rdd.c' &&
  35. X
  36. X    rddStartAction (w, event, args, nargs);        /* then use default action */
  37. }
  38. X
  39. /* RDD myDropAction */
  40. void myDropAction (w, event, args, nargs)
  41. X    Widget w;
  42. X    XButtonEvent *event;
  43. X    String *args;
  44. X    int *nargs;
  45. {
  46. X    static char *data = "my drop data";
  47. X
  48. X    /* copy data to rdd, use filename as data type  */
  49. X    rddSetDropDataType (data, strlen(data), RDD_FILENAME_TYPE);
  50. X
  51. X    /* then use default action */
  52. X    rddDropAction (w, event, args, nargs);    
  53. }
  54. X
  55. /* RDD dropTraceProc */
  56. void
  57. dropTraceProc(w, call, cbs)
  58. X    Widget w;
  59. X    char *call;
  60. X    RddCallbackStruct *cbs;
  61. {
  62. X    fprintf (stderr,
  63. X             "dropTraceProc entered w = %s call=%s len=%d data=<%s> type=%d keymask=%d\n",
  64. X             XtName(w), call, cbs->len, cbs->data, cbs->type, cbs->keymask);
  65. }
  66. X
  67. X
  68. main(argc, argv)
  69. X    int argc;
  70. X    char *argv[];
  71. {
  72. X    Widget        toplevel, button;
  73. X    void i_was_pushed();
  74. X    XmString label;
  75. X
  76. X    toplevel = XtVaAppInitialize(&app, "Hello", (XrmOptionDescList)NULL, 0,
  77. X        (Cardinal*)&argc, argv, (String*)NULL, (String*)NULL);
  78. X
  79. X    /* RDD add action myAction */
  80. X    {
  81. X        static XtActionsRec actions[] = 
  82. X        {
  83. X            "myDropAction", myDropAction,
  84. X            "myStartAction", myStartAction,
  85. X            NULL, NULL,
  86. X        };
  87. X        XtAppAddActions (app, actions, XtNumber(actions));
  88. X    }
  89. X
  90. X    /* RDD  initialize the rdd package */
  91. X    rddInit (toplevel, app);
  92. X
  93. X    label = XmStringCreateSimple("Push here to say hello"); 
  94. X    button = XtVaCreateManagedWidget("pushme",
  95. X        xmPushButtonWidgetClass, toplevel,
  96. X        XmNlabelString, label,
  97. X        NULL);
  98. X    XmStringFree(label);
  99. X
  100. #if 1
  101. X    /* RDD  set new translations on button. 
  102. X     * This causes click and drag on button to initiate drag action.
  103. X     */
  104. X    XtAddCallback(button, XmNactivateCallback, i_was_pushed, NULL);
  105. X
  106. X    XtVaSetValues (button,
  107. X                   XmNtranslations, XtParseTranslationTable(myTranslations),
  108. X                   NULL);
  109. #else
  110. X    /* RDD Callback when button pushed to grap pointer and start drag action */
  111. X    XtAddCallback(button, XmNactivateCallback, rddDragCallback, NULL);
  112. #endif
  113. X
  114. X    XtRealizeWidget(toplevel);
  115. X
  116. X
  117. X    /* RDD  add drop callback to button */
  118. X    rddAddDropHandler (button, dropTraceProc, "no client data");
  119. X
  120. X    /* RDD  use rddAppMainLoop instead of XtAppMainLoop */
  121. X    rddAppMainLoop(app);
  122. }
  123. X
  124. void
  125. i_was_pushed(w, client_data, cbs)
  126. Widget w;
  127. XXtPointer client_data;
  128. XXmPushButtonCallbackStruct *cbs;
  129. {
  130. X    XEvent event;
  131. X    fprintf(stderr, "i_was_pushed: w = 0x%x\n", cbs->event->xany.window);
  132. }
  133. X
  134. X
  135. #endif /*MAIN*/
  136. SHAR_EOF
  137. echo 'File xmfm/rdd.c is complete' &&
  138. chmod 0644 xmfm/rdd.c ||
  139. echo 'restore of xmfm/rdd.c failed'
  140. Wc_c="`wc -c < 'xmfm/rdd.c'`"
  141. test 21454 -eq "$Wc_c" ||
  142.     echo 'xmfm/rdd.c: original size 21454, current size' "$Wc_c"
  143. rm -f _shar_wnt_.tmp
  144. fi
  145. # ============= xmfm/refresh.c ==============
  146. if test -f 'xmfm/refresh.c' -a X"$1" != X"-c"; then
  147.     echo 'x - skipping xmfm/refresh.c (File already exists)'
  148.     rm -f _shar_wnt_.tmp
  149. else
  150. > _shar_wnt_.tmp
  151. echo 'x - extracting xmfm/refresh.c (Text)'
  152. sed 's/^X//' << 'SHAR_EOF' > 'xmfm/refresh.c' &&
  153. /****************************************************************************
  154. X * File: refresh.c
  155. X * Author: Jan Newmarch
  156. X * Last modified: $Date: 1992/11/17 00:35:55 $
  157. X * Version: $Revision: 1.2 $
  158. X * Purpose: this file contains routines that look out for a child dying.
  159. X *    This presumably is a function called by executing an action on
  160. X *    a file, and this may have modified the directory contents. The
  161. X *    stuff here catches SIGCHLD events.
  162. X * Revision history:
  163. X ***************************************************************************/
  164. X
  165. #include "copyright.h"
  166. X
  167. /***************************************************************************
  168. X * System includes
  169. X ***************************************************************************/
  170. #include <sys/wait.h>
  171. #include <sys/types.h>
  172. #include <signal.h>
  173. #include <sys/stat.h>
  174. #include <stdio.h>
  175. X
  176. /***************************************************************************
  177. X * Local includes
  178. X ***************************************************************************/
  179. #include "types.h"
  180. #include "DirMgr.h"
  181. X
  182. /***************************************************************************
  183. X * Extern variables
  184. X ***************************************************************************/
  185. X
  186. /***************************************************************************
  187. X * Extern functions 
  188. X ***************************************************************************/
  189. extern void ResetPanesAndSelectFile (
  190. #ifdef UseFunctionPrototypes
  191. X    dir_pane_info *dpi, char *file_name
  192. #endif
  193. );
  194. X
  195. /***************************************************************************
  196. X * Functions exported 
  197. X ***************************************************************************/
  198. void child_died (
  199. #ifdef UseFunctionPrototypes
  200. X    void
  201. #endif
  202. );
  203. void add_pid (
  204. #ifdef UseFunctionPrototypes
  205. X    pid_t pid, dir_pane_info *dpi
  206. #endif
  207. );
  208. X
  209. /***************************************************************************
  210. X * Variables exported 
  211. X ***************************************************************************/
  212. X
  213. /***************************************************************************
  214. X * Forward functions
  215. X ***************************************************************************/
  216. static void refresh_dir (
  217. #ifdef UseFunctionPrototypes
  218. X    XtPointer client_data, XtIntervalId *id
  219. #endif
  220. );
  221. X
  222. /***************************************************************************
  223. X * Local variables 
  224. X ***************************************************************************/
  225. typedef struct pid_list_elmt
  226. {
  227. X    pid_t pid;
  228. X    dir_pane_info *dpi;
  229. X    struct pid_list_elmt *next;
  230. }
  231. X    pid_pair, *pid_list_t;
  232. X
  233. static pid_list_t pid_list = NULL;
  234. X
  235. /***************************************************************************
  236. X * Function: child_died
  237. X * Purpose: catch a SIGCHLD signal, and set a work-proc if needed
  238. X * In parameters:
  239. X * Out parameters:
  240. X * Precondition:
  241. X * Postcondition: work proc set if directory contents have changed
  242. X ***************************************************************************/
  243. void
  244. child_died 
  245. #ifdef UseFunctionPrototypes
  246. X    (void)
  247. #else
  248. X    ()
  249. X
  250. #endif
  251. {    int status;
  252. X    pid_t pid;
  253. X    pid_list_t p = pid_list,
  254. X           trail = pid_list;
  255. X    DirectoryMgr *dm;
  256. X    DirEntry *de;
  257. X    time_t prev_modified, last_modified;
  258. X    struct stat stat_buf;
  259. X
  260. #ifdef DEBUG_SIGNAL
  261. X    fprintf (stderr, "SIGCHLD caught\n");
  262. #endif
  263. X    if ((pid = wait (&status)) == -1)
  264. X        return;
  265. X    signal (SIGCHLD, SIG_IGN);
  266. X    while (p != NULL)
  267. X    {
  268. X        if (p -> pid == pid)
  269. X        {    /* does the dir need updating?
  270. X               first find the info in dpi
  271. X             */
  272. X            dm = p -> dpi -> directory_manager;
  273. X            DirectoryMgrGotoNamedItem (dm, ".");
  274. X            de = DirectoryMgrCurrentEntry (dm);
  275. X            prev_modified = DirEntryLastModify (de);
  276. X
  277. X            /* now find current info */
  278. X            if (stat (DirectoryPath (DirectoryMgrDir (dm)),
  279. X                        &stat_buf) == -1)
  280. X                return;    /* error - e.g. dir has vanished */
  281. X            last_modified = stat_buf.st_mtime;
  282. #ifdef DEBUG_SIGNAL
  283. X            fprintf (stderr, "directory previously modified %ld\n\
  284. last modified %ld\n", 
  285. X                    prev_modified, last_modified);
  286. #endif
  287. X
  288. X            /* add timeout to update if dir has changed */
  289. X            if (last_modified > prev_modified)
  290. X                XtAddTimeOut (0, refresh_dir, p -> dpi);
  291. X            else
  292. X                signal (SIGCHLD, child_died);
  293. X
  294. X            /* remove this element anyway */
  295. X            if (trail == p)        /* start of list */
  296. X                pid_list = p -> next;
  297. X            else            /* later in list */
  298. X                trail -> next = p -> next;
  299. X            XtFree ((char *) p);
  300. X
  301. X            return;
  302. X        }
  303. X        trail = p;
  304. X        p = p -> next;
  305. X
  306. X    }
  307. X    signal (SIGCHLD, child_died );
  308. }
  309. X
  310. X
  311. /***************************************************************************
  312. X * Function: add_pid
  313. X * Purpose: add a pid/dpi pair to the pid list
  314. X * In parameters: pid,dpi
  315. X * Out parameters:
  316. X * Precondition:
  317. X * Postcondition: pid added to list of undead children
  318. X ***************************************************************************/
  319. void
  320. add_pid 
  321. #ifdef UseFunctionPrototypes
  322. X    (pid_t pid, dir_pane_info *dpi)
  323. #else
  324. X    (pid, dpi)
  325. X    pid_t pid;
  326. X    dir_pane_info *dpi;
  327. X
  328. #endif
  329. {
  330. X    pid_list_t p;
  331. X
  332. X    p = (pid_list_t) XtMalloc (sizeof (struct pid_list_elmt));
  333. X    p -> pid = pid;
  334. X    p -> dpi = dpi;
  335. X    p -> next = pid_list;
  336. X    pid_list = p;
  337. }
  338. X
  339. X
  340. /***************************************************************************
  341. X * Function: refresh_dir
  342. X * Purpose: refresh directory contents
  343. X * In parameters: dpi
  344. X * Out parameters:
  345. X * Precondition:
  346. X * Postcondition: new directory contents showing, focus on slected file
  347. X ***************************************************************************/
  348. /* ARGSUSED */
  349. static void
  350. refresh_dir 
  351. #ifdef UseFunctionPrototypes
  352. X    (XtPointer client_data, XtIntervalId *id)
  353. #else
  354. X    (client_data, id)
  355. X    XtPointer client_data;
  356. X    XtIntervalId *id;
  357. X
  358. #endif
  359. {
  360. X    dir_pane_info *dpi = (dir_pane_info *) client_data;
  361. X
  362. #ifdef DEBUG_SIGNAL
  363. X    fprintf ("Timeout called, refreshing dir\n");
  364. #endif
  365. X    ResetPanesAndSelectFile (dpi, dpi -> file_selected);
  366. X    signal (SIGCHLD, child_died);
  367. }
  368. SHAR_EOF
  369. chmod 0644 xmfm/refresh.c ||
  370. echo 'restore of xmfm/refresh.c failed'
  371. Wc_c="`wc -c < 'xmfm/refresh.c'`"
  372. test 5845 -eq "$Wc_c" ||
  373.     echo 'xmfm/refresh.c: original size 5845, current size' "$Wc_c"
  374. rm -f _shar_wnt_.tmp
  375. fi
  376. # ============= xmfm/runcb.c ==============
  377. if test -f 'xmfm/runcb.c' -a X"$1" != X"-c"; then
  378.     echo 'x - skipping xmfm/runcb.c (File already exists)'
  379.     rm -f _shar_wnt_.tmp
  380. else
  381. > _shar_wnt_.tmp
  382. echo 'x - extracting xmfm/runcb.c (Text)'
  383. sed 's/^X//' << 'SHAR_EOF' > 'xmfm/runcb.c' &&
  384. /*************************************************************************
  385. X * File: $Source: /usr/usrs/xsource/xmfm/RCS/runcb.c,v $
  386. X * Author: Jan Newmarch
  387. X * Last modified: $Date: 1992/11/10 05:12:41 $
  388. X * Version: $Revision: 1.6 $
  389. X * Purpose: This file handles the run operations from the system menu
  390. X *
  391. X * Revision history:
  392. X *      22 Aug 92      Separate run dialogs per pane (needed in case a pane
  393. X *                     gets iconified or destroyed
  394. X *    16 Oct 92    caddr_t changed to XtPointer
  395. X *       3 Nov 92      lint-ed
  396. X ************************************************************************/ 
  397. X
  398. #include "copyright.h"
  399. X
  400. /*************************************************************************
  401. X * System includes
  402. X ************************************************************************/ 
  403. #include <stdlib.h>
  404. #include <stdio.h> 
  405. X
  406. #include <Xm/CascadeB.h>     
  407. #include <Xm/FileSB.h>      
  408. #include <Xm/Label.h>
  409. #include <Xm/PushB.h>    
  410. #include <Xm/RowColumn.h>    
  411. #include <Xm/SelectioB.h>    
  412. X
  413. /*************************************************************************
  414. X * Local includes
  415. X ************************************************************************/ 
  416. #include "Directory.h"
  417. #include "DirMgr.h"
  418. #include "filecb.h"
  419. #include "types.h"
  420. #include "xmvararg.h"
  421. X
  422. /*************************************************************************
  423. X * Functions exported
  424. X ************************************************************************/ 
  425. extern void RunCommandCB (
  426. #ifdef UseFunctionPrototypes
  427. X    Widget w, XtPointer client_data, XtPointer call_data
  428. #endif
  429. );
  430. extern void RunXtermCB (
  431. #ifdef UseFunctionPrototypes
  432. X    Widget w, XtPointer client_data, XtPointer call_data
  433. #endif
  434. );
  435. X
  436. /*************************************************************************
  437. X * Variables exported
  438. X ************************************************************************/ 
  439. X
  440. /*************************************************************************
  441. X * Extern variables
  442. X ************************************************************************/ 
  443. X
  444. /*************************************************************************
  445. X * Extern functions
  446. X ************************************************************************/ 
  447. extern void GotoCurrentDir (
  448. #ifdef UseFunctionPrototypes
  449. X    Widget w
  450. #endif
  451. );
  452. extern void do_command (
  453. #ifdef UseFunctionPrototypes
  454. X    char *command, int run_in_xterm, int pause_after_exec, dir_pane_info *dpi
  455. #endif
  456. );
  457. X
  458. /*************************************************************************
  459. X * Forward functions
  460. X ************************************************************************/ 
  461. X
  462. /*************************************************************************
  463. X * Local variables
  464. X ************************************************************************/ 
  465. static Bool run_in_xterm = False;
  466. static Bool pause_after_exec = False;
  467. X
  468. #define LIST_SIZE 10
  469. X
  470. #define min(x,y)    ((x) < (y) ? (x) : (y))
  471. X
  472. /*************************************************************************
  473. X * Function: ButtonToggledCB ()
  474. X * Purpose: a check button has been changed
  475. X * In parameters: w, client_data, call_data
  476. X * Out parameters:
  477. X * Precondition; 
  478. X * Postcondition: appropriate Boolean for Check box is updated
  479. X ************************************************************************/
  480. X
  481. /* ARGSUSED */ 
  482. static void
  483. ButtonToggledCB 
  484. #ifdef UseFunctionPrototypes
  485. X    (Widget w, XtPointer client_data, XtPointer call_data)
  486. #else
  487. X    (w, client_data, call_data)
  488. X    Widget w;
  489. X    XtPointer client_data;
  490. X    XtPointer call_data;
  491. X
  492. #endif
  493. {
  494. X    /* toggle value of correct Boolean */
  495. X    if ( (int) client_data == 0)
  496. X        run_in_xterm = (run_in_xterm ? False : True);
  497. X    else     pause_after_exec = (pause_after_exec ? False : True);
  498. }
  499. X
  500. /*************************************************************************
  501. X * Function: OkCB ()
  502. X * Purpose: run the command entered
  503. X * In parameters: w, client_data, call_data
  504. X * Out parameters:
  505. X * Precondition: Ok button pressed in Command dialog
  506. X * Postcondition: user command executed, dialog killed
  507. X ************************************************************************/ 
  508. X
  509. /* ARGSUSED */
  510. static void
  511. OkCB 
  512. #ifdef UseFunctionPrototypes
  513. X    (Widget w, XtPointer client_data, XtPointer call_data)
  514. #else
  515. X    (w, client_data, call_data)
  516. X    Widget w;
  517. X    XtPointer client_data;
  518. X    XtPointer call_data;
  519. X
  520. #endif
  521. {
  522. X    XmString xmstr_command;
  523. X    String command;
  524. X    int i, new_size, curr_size;
  525. X    XmString new_list[LIST_SIZE], *curr_list;
  526. X        dir_pane_info *dpi;
  527. X
  528. X    XtVaGetValues (w,
  529. X            XmNtextString, &xmstr_command,
  530. X                        XmNuserData, &dpi,
  531. X            NULL);
  532. X    XmStringGetLtoR (xmstr_command, XmSTRING_DEFAULT_CHARSET, &command);
  533. X
  534. X    do_command (command, run_in_xterm, pause_after_exec, dpi);
  535. X    
  536. X    XtFree (command);
  537. X
  538. X    XtUnmanageChild (w);
  539. X
  540. X    /* before we leave this: add the command into the list of
  541. X      previous commands, as long as it isn't already there */
  542. X    XtVaGetValues (w,
  543. X            XmNlistItems, &curr_list,
  544. X            XmNlistItemCount, &curr_size,
  545. X            NULL);
  546. X    for (i = 0; i < curr_size; i++)
  547. X        if (XmStringCompare (xmstr_command, curr_list[i]))
  548. X            /* already in list */
  549. X            return;
  550. X    /* new elmt. put in front, and shuffle up the rest */
  551. X    new_list[0] = xmstr_command;
  552. X    new_size = min (curr_size + 1, LIST_SIZE);
  553. X    for (i = 1; i < new_size; i++)
  554. X        new_list[i] = XmStringCopy (curr_list[i - 1]);
  555. X    XtVaSetValues (w,
  556. X            XmNlistItems, new_list,
  557. X            XmNlistItemCount, (XtArgVal) new_size,
  558. X            NULL);
  559. X    /* and garbage collect */
  560. /*
  561. X    for (i = 0; i < new_size; i++)
  562. X        XmStringFree (new_list[i]);
  563. */
  564. }
  565. X
  566. /*************************************************************************
  567. X * Function: RunCommandCB ()
  568. X * Purpose: run a user command in current dir
  569. X * In parameters: w, client_data, call_data
  570. X * Out parameters:
  571. X * Precondition; Command button pressed in Run menu
  572. X * Postcondition: user command dialog showing
  573. X ************************************************************************/ 
  574. X
  575. /* ARGSUSED */
  576. void
  577. RunCommandCB 
  578. #ifdef UseFunctionPrototypes
  579. X    (Widget w, XtPointer client_data, XtPointer call_data)
  580. #else
  581. X    (w, client_data, call_data)  
  582. X    Widget        w;        /*  widget id        */ 
  583. X    XtPointer        client_data;    /*  data from applicaiton   */ 
  584. X    XtPointer        call_data;    /*  data from widget class  */ 
  585. X
  586. #endif
  587. {     
  588. X    dir_pane_info *dpi;
  589. X    Widget    run_command;
  590. X    Widget    rowcol;
  591. X    XmString xmstr_buttons[2];
  592. X    XmString xmstr_prompt;
  593. X    Widget help_button, apply_button;
  594. X    static XmString null_str;
  595. X
  596. X    GotoCurrentDir (w);
  597. X
  598. X        XtVaGetValues (w, XmNuserData, &dpi, NULL);
  599. X        run_command = dpi -> run_dialog;
  600. X    /* create new dialog if not already existing */
  601. X    if (run_command == NULL)
  602. X    {
  603. X        xmstr_prompt = XmStringCreateSimple ("Enter run command:");
  604. X        run_command = XmVaCreateSelectionDialog (w,
  605. X                    "run command",
  606. X                    XmNpromptString, xmstr_prompt,
  607. X                    NULL);
  608. X                /* save this back into dpi */
  609. X                dpi -> run_dialog = run_command;
  610. X
  611. X        XmStringFree (xmstr_prompt);
  612. X
  613. X        XtAddCallback (run_command, XmNokCallback, OkCB, NULL);
  614. X        /* no cancel callback - default pops it down */
  615. X
  616. X        /* remove the help and cancel */
  617. X        help_button = XmSelectionBoxGetChild (run_command, 
  618. X                XmDIALOG_HELP_BUTTON);
  619. X        XtUnmanageChild (help_button);
  620. X        apply_button = XmSelectionBoxGetChild (run_command, 
  621. X                XmDIALOG_APPLY_BUTTON);
  622. X        XtUnmanageChild (apply_button);
  623. X    
  624. X        xmstr_buttons[0] = XmStringCreateSimple ("Run in xterm");
  625. X        xmstr_buttons[1] = XmStringCreateSimple ("Pause after exec");
  626. X    
  627. X        null_str = XmStringCreateSimple ("");
  628. X
  629. X        rowcol = XmVaCreateSimpleCheckBox (run_command, "rowcol",
  630. X                ButtonToggledCB,
  631. X                XmNbuttonCount, (XtArgVal) 2,
  632. X                XmNbuttons, xmstr_buttons,
  633. X                XmVaCHECKBUTTON, xmstr_buttons[0],
  634. X                    NULL, NULL, NULL,
  635. X                XmVaCHECKBUTTON, xmstr_buttons[1],
  636. X                    NULL, NULL, NULL,
  637. X                NULL);
  638. X        XtManageChild (rowcol);
  639. X
  640. X        XmStringFree (xmstr_buttons[0]);
  641. X        XmStringFree (xmstr_buttons[1]);
  642. X    }
  643. X
  644. X    /* ensure text field is empty for new command */
  645. /*    both these methods dump core
  646. X    XtVaSetValues (w,
  647. X            XmNtextString, null_str,
  648. X            NULL);
  649. X    XmCommandSetValue (w, null_str);
  650. */
  651. X
  652. X        XtVaSetValues (run_command, XmNuserData, dpi, NULL);
  653. X          XtManageChild (run_command);
  654. }
  655. /*************************************************************************
  656. X * Function: RunXtermCB()
  657. X * Purpose: run a new xterm
  658. X * In parameters: w, client_data, call_data
  659. X * Out parameters:
  660. X * Precondition; Xterm selected from Run menu
  661. X * Postcondition: new xterm running
  662. X ************************************************************************/ 
  663. X
  664. /* ARGSUSED */
  665. void
  666. RunXtermCB 
  667. #ifdef UseFunctionPrototypes
  668. X    (Widget w, XtPointer client_data, XtPointer call_data)
  669. #else
  670. X    (w, client_data, call_data)  
  671. X    Widget        w;        /*  widget id        */ 
  672. X    XtPointer        client_data;    /*  data from applicaiton   */ 
  673. X    XtPointer        call_data;
  674. X
  675. #endif
  676. {
  677. X        dir_pane_info *dpi;
  678. X
  679. X        XtVaGetValues (w, XmNuserData, &dpi, NULL);
  680. X
  681. X    GotoCurrentDir (w);
  682. X
  683. #ifdef DEBUG
  684. X    fprintf (stderr, "xterm, display is %s\n",
  685. X        DisplayString (XtDisplay (w));
  686. #endif
  687. X    do_command ("xterm", False, False, dpi);
  688. }
  689. X
  690. SHAR_EOF
  691. chmod 0644 xmfm/runcb.c ||
  692. echo 'restore of xmfm/runcb.c failed'
  693. Wc_c="`wc -c < 'xmfm/runcb.c'`"
  694. test 8900 -eq "$Wc_c" ||
  695.     echo 'xmfm/runcb.c: original size 8900, current size' "$Wc_c"
  696. rm -f _shar_wnt_.tmp
  697. fi
  698. # ============= xmfm/utils.c ==============
  699. if test -f 'xmfm/utils.c' -a X"$1" != X"-c"; then
  700.     echo 'x - skipping xmfm/utils.c (File already exists)'
  701.     rm -f _shar_wnt_.tmp
  702. else
  703. > _shar_wnt_.tmp
  704. echo 'x - extracting xmfm/utils.c (Text)'
  705. sed 's/^X//' << 'SHAR_EOF' > 'xmfm/utils.c' &&
  706. /*************************************************************************
  707. X * File: $Source: /usr/usrs/xsource/xmfm/RCS/utils.c,v $
  708. X * Author: Jan Newmarch
  709. X * Last modified: $Date: 1992/11/10 05:12:43 $
  710. X * Version: $Revision: 1.6 $
  711. X * Purpose: general purpose routines of use in various places
  712. X *
  713. X * Revision history:
  714. X *    6 Aug 92    BusyCursor covers whole of a pane, rather than 1 widget
  715. X *      22 Aug 92       NULL terminated string for tilde expansion
  716. X *       3 Nov 92       lint-ed
  717. X ************************************************************************/ 
  718. X
  719. #include "copyright.h"
  720. X
  721. /*************************************************************************
  722. X * System includes
  723. X ************************************************************************/ 
  724. #include <sys/param.h>
  725. #include <string.h>
  726. #include <Xm/Xm.h>
  727. #include <X11/cursorfont.h>
  728. #include <pwd.h>
  729. X
  730. /*************************************************************************
  731. X * Local includes
  732. X ************************************************************************/ 
  733. #include "DirMgr.h"
  734. #include "types.h"
  735. X
  736. /*************************************************************************
  737. X * Functions exported
  738. X ************************************************************************/ 
  739. extern Bool XtChdir (
  740. #ifdef UseFunctionPrototypes
  741. X    char *dir
  742. #endif
  743. );
  744. extern void BusyCursor (
  745. #ifdef UseFunctionPrototypes
  746. X    Widget toplevel
  747. #endif
  748. );
  749. extern void UnBusyCursor (
  750. #ifdef UseFunctionPrototypes
  751. X    Widget toplevel
  752. #endif
  753. );
  754. extern void GotoCurrentDir (
  755. #ifdef UseFunctionPrototypes
  756. X    Widget w
  757. #endif
  758. );
  759. X
  760. /*************************************************************************
  761. X * Variables exported
  762. X ************************************************************************/ 
  763. X
  764. /*************************************************************************
  765. X * Extern variables
  766. X ************************************************************************/ 
  767. X
  768. /*************************************************************************
  769. X * Extern functions
  770. X ************************************************************************/ 
  771. extern char *getlogin ();   /* gcc (?) has no prototype for this */
  772. extern void ErrorDialog (
  773. #ifdef UseFunctionPrototypes
  774. X    char *str
  775. #endif
  776. );
  777. X
  778. /*************************************************************************
  779. X * Forward functions
  780. X ************************************************************************/ 
  781. X
  782. /*************************************************************************
  783. X * Local variables
  784. X ************************************************************************/ 
  785. static Window busy_window;
  786. #define IS_WHITE_SPACE(ch)    ((ch) == ' ' || (ch) == '\t' || (ch) == '\n')
  787. X
  788. /*************************************************************************
  789. X * Function        : BusyCursor ()
  790. X * Purpose         : make the cursor turn busy for this window
  791. X * In parameters   : w
  792. X * Out parameters  :
  793. X * Side effects    :
  794. X * Function returns:
  795. X * Precondition    :
  796. X * Postcondition   : cursor over current window is busy
  797. X ************************************************************************/ 
  798. void
  799. BusyCursor 
  800. #ifdef UseFunctionPrototypes
  801. X    (Widget toplevel)
  802. #else
  803. X    (toplevel)
  804. X    Widget toplevel;
  805. X
  806. #endif
  807. {  
  808. X        static Cursor watch = NULL; 
  809. X        unsigned long valuemask;
  810. X        XSetWindowAttributes attributes;
  811. X           if(!watch)
  812. X                   watch = XCreateFontCursor(XtDisplay(toplevel),XC_watch);
  813. X
  814. X        /* Ignore device events while the busy cursor is displayed. */
  815. X        valuemask = CWDontPropagate | CWCursor;
  816. X        attributes.do_not_propagate_mask =  (KeyPressMask | KeyReleaseMask |
  817. X           ButtonPressMask | ButtonReleaseMask | PointerMotionMask);
  818. X        attributes.cursor = watch;
  819. X
  820. X        /* The window will be as big as the display screen, and clipped by
  821. X           its own parent window, so we never have to worry about resizing */
  822. X        /* on multiple clicks, this function can get called multiple times.
  823. X           check that we haven't already got such a window mapped */
  824. X        if (busy_window != NULL)
  825. X                return;
  826. X        busy_window = XCreateWindow(XtDisplay(toplevel), XtWindow(toplevel), 0, 0,
  827. X                       65535, 65535, (unsigned int) 0, CopyFromParent, InputOnly,
  828. X                       CopyFromParent, valuemask, &attributes);
  829. X        XMapWindow (XtDisplay (toplevel), busy_window);
  830. X   
  831. X
  832. X        XmUpdateDisplay(toplevel);
  833. X
  834. }
  835. X
  836. /*************************************************************************
  837. X * Function        : UnBusyCursor ()
  838. X * Purpose         : set it back again
  839. X * In parameters   : w
  840. X * Out parameters  :
  841. X * Side effects    :
  842. X * Function returns:
  843. X * Precondition    :
  844. X * Postcondition   : cursor is back to previous cursor
  845. X ************************************************************************/ 
  846. void
  847. UnBusyCursor 
  848. #ifdef UseFunctionPrototypes
  849. X    (Widget toplevel)
  850. #else
  851. X    (toplevel)
  852. X    Widget toplevel;
  853. X
  854. #endif
  855. {
  856. X        /* check that we have a window to destroy */
  857. X        if (busy_window == NULL)
  858. X               return;       
  859. X        XDestroyWindow (XtDisplay (toplevel), busy_window);
  860. X        busy_window = NULL;
  861. }
  862. X
  863. /*************************************************************************
  864. X * Function        : XtChdir ()
  865. X * Purpose         : perform a chdir and report on any error. also does
  866. X *    tilde expansion
  867. X * In parameters   : dir
  868. X * Out parameters  :
  869. X * Side effects    :
  870. X * Function returns: success or fail
  871. X * Precondition    :
  872. X * Postcondition   : application now in new dir (success)
  873. X *        error dialog posted (failure)
  874. X ************************************************************************/ 
  875. Bool
  876. XXtChdir 
  877. #ifdef UseFunctionPrototypes
  878. X    (char *dir)
  879. #else
  880. X    (dir)
  881. X    char *dir;
  882. X
  883. #endif
  884. {    char warning[MAXPATHLEN + 20];
  885. X    char full_dir[MAXPATHLEN];
  886. X    char name_buf[MAXPATHLEN];
  887. X    char *name;
  888. X    char *orig_dir = dir;
  889. X        struct passwd *pw_ent;
  890. X
  891. X    while (IS_WHITE_SPACE (*dir))
  892. X        dir++;
  893. X    /* should it undergo ~ expansion?
  894. X    */ 
  895. X    if (*dir == '~')
  896. X    {    /* Found a tilde. This isn't full globbing.
  897. X           We only have these cases:
  898. X            ~
  899. X            ~/...
  900. X            ~name
  901. X            ~name/...
  902. X        */
  903. X        /* move past ~ */
  904. X        dir++;
  905. X        if ( *dir == '\0' || *dir == '/')
  906. X        {    /* name is login name */
  907. X            name = getlogin ();
  908. X            /* dir now points to next char after user name */
  909. X        }
  910. X        else    /* name is someone else */
  911. X        {    char *p = dir;
  912. X
  913. X            while ( ! IS_WHITE_SPACE (*p) &&
  914. X                *p != '/' && *p != '\0')
  915. X                p++;
  916. X                        /* leave space for \0 */
  917. X            strncpy (name_buf, dir, (int) (p - dir));
  918. X                        name_buf[(int) (p - dir)] = '\0';
  919. X            name = name_buf;
  920. X
  921. X            dir = p;
  922. X            /* dir now points to next char after user name */
  923. X        }
  924. X        /* put in users home dir */
  925. X        pw_ent = getpwnam (name);
  926. X        if (pw_ent == NULL)
  927. X            /* no such user, restore original pattern */
  928. X            dir = orig_dir;
  929. X        else
  930. X        {
  931. X            strcpy (full_dir, pw_ent -> pw_dir);
  932. X            /* and what followed after */
  933. X            strcat (full_dir, dir);
  934. X            /* set dir to point to all of this */
  935. X            dir = full_dir;
  936. X        }
  937. X    }
  938. X    if (chdir (dir) == -1)
  939. X    {
  940. X        strcpy (warning, "cannot chdir to ");
  941. X        strcat (warning, dir);
  942. X        ErrorDialog (warning);
  943. X        return False;
  944. X    }
  945. X    return True;
  946. }
  947. X
  948. /*************************************************************************
  949. X * Function        : GotoCurrentDir ()
  950. X * Purpose         : make sure we are in current dir
  951. X * In parameters   : w
  952. X * Out parameters  :
  953. X * Side effects    :
  954. X * Function returns:
  955. X * Precondition    :
  956. X * Postcondition   : application now in new dir
  957. X ************************************************************************/ 
  958. void
  959. GotoCurrentDir 
  960. #ifdef UseFunctionPrototypes
  961. X    (Widget w)
  962. #else
  963. X    (w)
  964. X    Widget w;
  965. X
  966. #endif
  967. {    dir_pane_info *dpi;
  968. X
  969. X    XtVaGetValues (w,
  970. X            XmNuserData, &dpi,
  971. X            NULL);
  972. X    XtChdir (DirectoryPath (DirectoryMgrDir (dpi -> directory_manager)));
  973. }
  974. SHAR_EOF
  975. chmod 0644 xmfm/utils.c ||
  976. echo 'restore of xmfm/utils.c failed'
  977. Wc_c="`wc -c < 'xmfm/utils.c'`"
  978. test 7705 -eq "$Wc_c" ||
  979.     echo 'xmfm/utils.c: original size 7705, current size' "$Wc_c"
  980. rm -f _shar_wnt_.tmp
  981. fi
  982. # ============= xmfm/warning.c ==============
  983. if test -f 'xmfm/warning.c' -a X"$1" != X"-c"; then
  984.     echo 'x - skipping xmfm/warning.c (File already exists)'
  985.     rm -f _shar_wnt_.tmp
  986. else
  987. > _shar_wnt_.tmp
  988. echo 'x - extracting xmfm/warning.c (Text)'
  989. sed 's/^X//' << 'SHAR_EOF' > 'xmfm/warning.c' &&
  990. /*************************************************************************
  991. X * File: $Source: /usr/usrs/xsource/xmfm/RCS/warning.c,v $
  992. X * Author: Jan Newmarch
  993. X * Last modified: $Date: 1992/11/17 00:35:58 $
  994. X * Version: $Revision: 1.5 $
  995. X * Purpose: display a modal warning dialog
  996. X *
  997. X * Revision history:
  998. X *      3 Nov 92      lint-ed
  999. X ************************************************************************/ 
  1000. X
  1001. #include "copyright.h"
  1002. X
  1003. /*************************************************************************
  1004. X * System includes
  1005. X ************************************************************************/ 
  1006. #include <stdio.h> 
  1007. #include <string.h> 
  1008. #include <sys/types.h> 
  1009. #include <sys/stat.h> 
  1010. #include <Xm/MainW.h> 
  1011. #include <Xm/MessageB.h> 
  1012. #include <Xm/SelectioB.h>
  1013. X
  1014. /*************************************************************************
  1015. X * Local includes
  1016. X ************************************************************************/ 
  1017. #include "const.h"
  1018. #include "types.h"
  1019. X
  1020. /*************************************************************************
  1021. X * Functions exported
  1022. X ************************************************************************/ 
  1023. extern void WarningDialog (
  1024. #ifdef UseFunctionPrototypes
  1025. X    Widget parent, char *prompt, int modal, int *answer
  1026. #endif
  1027. );
  1028. X
  1029. /*************************************************************************
  1030. X * Variables exported
  1031. X ************************************************************************/ 
  1032. X
  1033. /*************************************************************************
  1034. X * Extern variables
  1035. X ************************************************************************/ 
  1036. extern XtAppContext app_context;
  1037. X
  1038. /*************************************************************************
  1039. X * Extern functions
  1040. X ************************************************************************/ 
  1041. X
  1042. /*************************************************************************
  1043. X * Forward functions
  1044. X ************************************************************************/ 
  1045. X
  1046. /*************************************************************************
  1047. X * Local variables
  1048. X ************************************************************************/ 
  1049. static Bool dialog_over;
  1050. X
  1051. /*************************************************************************
  1052. X * Function: modal_dialog_loop ()
  1053. X * Purpose: force user to acknowledge dialog
  1054. X * In parameters: w
  1055. X * Out parameters:
  1056. X * Side effects: modifies dialog_over
  1057. X * Precondition: 
  1058. X * Postcondition: dialog_over = True
  1059. X ************************************************************************/ 
  1060. static void
  1061. modal_dialog_loop 
  1062. #ifdef UseFunctionPrototypes
  1063. X    (Widget w)
  1064. #else
  1065. X    (w)
  1066. X    Widget w;
  1067. X
  1068. #endif
  1069. {
  1070. X    dialog_over = False;
  1071. X    XtVaSetValues (w,
  1072. X            XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL,
  1073. X            NULL);
  1074. X    XtManageChild (w);
  1075. X    while (dialog_over == False)
  1076. X        XtAppProcessEvent (app_context, XtIMAll);
  1077. }
  1078. X
  1079. X
  1080. /*-------------------------------------------------------------
  1081. **    Destroy a Dialog
  1082. */
  1083. X
  1084. /*************************************************************************
  1085. X * Function: OkDialogCB ()
  1086. X * Purpose: handle the dialog OK button
  1087. X * In parameters: w, call_data
  1088. X * Out parameters: answer
  1089. X * Precondition: w is a child of a popup shell
  1090. X * Postcondition: parent on down all destroyed, text field first copied
  1091. X ************************************************************************/ 
  1092. static void
  1093. OkDialogCB
  1094. #ifdef UseFunctionPrototypes
  1095. X    (Widget w, XtPointer client_data, XtPointer call_data)
  1096. #else
  1097. X    (w, client_data, call_data)
  1098. X    Widget w;
  1099. X    XtPointer client_data;
  1100. X    XtPointer call_data;
  1101. X
  1102. #endif
  1103. {
  1104. X    int *answer = (int *) client_data;
  1105. X    XmAnyCallbackStruct * c_data = (XmAnyCallbackStruct *) call_data;
  1106. X
  1107. X    dialog_over = True;
  1108. X
  1109. X    if (c_data -> reason == (int) XmCR_OK)
  1110. X        *answer = OK_ANSWER;
  1111. X    else    *answer = CANCEL_ANSWER;
  1112. X
  1113. X    XtUnmanageChild (w);
  1114. X    XtDestroyWidget (XtParent (w));
  1115. }
  1116. X
  1117. /*************************************************************************
  1118. X * Function: WarningDialog ()
  1119. X * Purpose: show a warning dialog
  1120. X * In parameters: parent, prompt, modal
  1121. X * Out parameters: answer 
  1122. X * Precondition: 
  1123. X * Postcondition: 
  1124. X ************************************************************************/ 
  1125. void
  1126. WarningDialog
  1127. #ifdef UseFunctionPrototypes
  1128. X    (Widget parent, char *prompt, int modal, int *answer)
  1129. #else
  1130. X    (parent, prompt, modal, answer)
  1131. X    Widget parent;
  1132. X    char * prompt;
  1133. X    Bool modal;
  1134. X    int *answer;
  1135. X
  1136. #endif
  1137. {    int n;
  1138. X    Arg    args[MAX_ARGS];
  1139. X    Widget  help, dialog;
  1140. X    XmString xmstr;
  1141. X
  1142. X    n = 0;
  1143. X    xmstr = XmStringCreateSimple (prompt);
  1144. X    XtSetArg (args[n], XmNmessageString, xmstr); n++;
  1145. X    dialog = XmCreateWarningDialog(parent, prompt, args, n);
  1146. X    XmStringFree(xmstr);
  1147. X    XtAddCallback(dialog, XmNokCallback, OkDialogCB, (XtPointer) answer);
  1148. X    XtAddCallback(dialog, XmNcancelCallback, OkDialogCB, (XtPointer) answer);
  1149. X
  1150. X    help = XmMessageBoxGetChild(dialog, 
  1151. X            XmDIALOG_HELP_BUTTON);
  1152. X    XtUnmanageChild(help);
  1153. X
  1154. X    if (modal)
  1155. X        modal_dialog_loop(dialog);
  1156. }
  1157. SHAR_EOF
  1158. chmod 0644 xmfm/warning.c ||
  1159. echo 'restore of xmfm/warning.c failed'
  1160. Wc_c="`wc -c < 'xmfm/warning.c'`"
  1161. test 4885 -eq "$Wc_c" ||
  1162.     echo 'xmfm/warning.c: original size 4885, current size' "$Wc_c"
  1163. rm -f _shar_wnt_.tmp
  1164. fi
  1165. # ============= xmfm/xmvararg.c ==============
  1166. if test -f 'xmfm/xmvararg.c' -a X"$1" != X"-c"; then
  1167.     echo 'x - skipping xmfm/xmvararg.c (File already exists)'
  1168.     rm -f _shar_wnt_.tmp
  1169. else
  1170. > _shar_wnt_.tmp
  1171. echo 'x - extracting xmfm/xmvararg.c (Text)'
  1172. sed 's/^X//' << 'SHAR_EOF' > 'xmfm/xmvararg.c' &&
  1173. /*************************************************************************
  1174. X * File: xmvarargs.c
  1175. X * Author: Jan Newmarch
  1176. X * Last modified: $Date: 1992/11/10 05:12:47 $
  1177. X * Version: $Revision: 1.4 $
  1178. X * Purpose: varargs interface to Motif, supplying varargs version
  1179. X *          of all the XmCreate<widget> () functions
  1180. X *
  1181. X * Revision history:
  1182. X *      3 Nov 92      lint-ed
  1183. X ************************************************************************/ 
  1184. X
  1185. #include "copyright.h"
  1186. X
  1187. /*************************************************************************
  1188. X * System includes
  1189. X ************************************************************************/ 
  1190. #include <stdio.h>
  1191. #include <varargs.h>
  1192. #include <X11/StringDefs.h>
  1193. #include <X11/Intrinsic.h>
  1194. #include <Xm/Xm.h>
  1195. #include <Xm/ArrowB.h>
  1196. #include <Xm/BulletinB.h>
  1197. #include <Xm/CascadeB.h>
  1198. #include <Xm/Command.h>
  1199. #include <Xm/DialogS.h>
  1200. #include <Xm/DrawingA.h>
  1201. #include <Xm/DrawnB.h>
  1202. #include <Xm/FileSB.h>
  1203. #include <Xm/Form.h>
  1204. #include <Xm/Frame.h>
  1205. #include <Xm/Label.h>
  1206. #include <Xm/List.h>
  1207. #include <Xm/MainW.h>
  1208. #include <Xm/MenuShell.h>
  1209. #include <Xm/MessageB.h>
  1210. #include <Xm/PanedW.h>
  1211. #include <Xm/PushB.h>
  1212. #include <Xm/RowColumn.h>
  1213. #include <Xm/Scale.h>
  1214. #include <Xm/ScrollBar.h>
  1215. #include <Xm/ScrolledW.h>
  1216. #include <Xm/SelectioB.h>
  1217. #include <Xm/Separator.h>
  1218. #include <Xm/Text.h>
  1219. #include <Xm/ToggleB.h>
  1220. X
  1221. /*************************************************************************
  1222. X * Local includes
  1223. X ************************************************************************/ 
  1224. X
  1225. /*************************************************************************
  1226. X * Functions exported
  1227. X ************************************************************************/ 
  1228. /* exported if not defined by Xt (i.e. X11R3) */
  1229. extern    Widget    XtVaCreateManagedWidget(
  1230. #ifdef UseFunctionPrototypes
  1231. X    const char *, WidgetClass, Widget, ...
  1232. #endif
  1233. );
  1234. extern    void    XtVaGetValues(
  1235. #ifdef UseFunctionPrototypes
  1236. X    Widget, ...
  1237. #endif
  1238. );
  1239. extern    void    XtVaSetValues(
  1240. #ifdef UseFunctionPrototypes
  1241. X    Widget, ...
  1242. #endif
  1243. );
  1244. X
  1245. /* exported anyway */
  1246. extern  Widget XmVaCreateArrowButton (
  1247. #ifdef UseFunctionPrototypes
  1248. X    int __builtin_va_alist
  1249. #endif
  1250. );  /* etc */
  1251. X
  1252. /*************************************************************************
  1253. X * Variables exported
  1254. X ************************************************************************/ 
  1255. X
  1256. /*************************************************************************
  1257. X * Extern variables
  1258. X ************************************************************************/ 
  1259. X
  1260. /*************************************************************************
  1261. X * Extern functions
  1262. X ************************************************************************/ 
  1263. extern    Widget    XtVaCreateManagedWidget(
  1264. #ifdef UseFunctionPrototypes
  1265. X    const char *, WidgetClass, Widget, ...
  1266. #endif
  1267. );
  1268. extern    void    XtVaGetValues(
  1269. #ifdef UseFunctionPrototypes
  1270. X    Widget, ...
  1271. #endif
  1272. );
  1273. extern    void    XtVaSetValues(
  1274. #ifdef UseFunctionPrototypes
  1275. X    Widget, ...
  1276. #endif
  1277. );
  1278. extern     Widget     XmVaCreateLabel(
  1279. #ifdef UseFunctionPrototypes
  1280. X    int __builtin_va_alist
  1281. #endif
  1282. );
  1283. X
  1284. /*************************************************************************
  1285. X * Forward functions
  1286. X ************************************************************************/ 
  1287. X
  1288. /*************************************************************************
  1289. X * Local variables
  1290. X ************************************************************************/ 
  1291. #define        NXARGS    100
  1292. X
  1293. static va_list        args;
  1294. static Arg        xargs[NXARGS];
  1295. static Widget        parent;
  1296. static String        name;
  1297. X
  1298. /*************************************************************************
  1299. X * Function: SetArgs
  1300. X * Purpose: store args in array
  1301. X * In parameters:
  1302. X * Out parameters:
  1303. X * Precondition;
  1304. X * Postcondition:
  1305. X ************************************************************************/ 
  1306. static int
  1307. SetArgs
  1308. #ifdef UseFunctionPrototypes
  1309. X    (void)
  1310. #else
  1311. X    ()
  1312. X
  1313. #endif
  1314. {    register int n;
  1315. X
  1316. X    for (n = 0; n < NXARGS; ++n)
  1317. X    {
  1318. X        xargs[n].name = va_arg(args, String);
  1319. X        if (xargs[n].name == NULL) 
  1320. X            break;
  1321. X        xargs[n].value = va_arg(args, XtArgVal);
  1322. X    }
  1323. X    return (n);
  1324. }
  1325. X
  1326. /*************************************************************************
  1327. X * Function: SetNameArgs
  1328. X * Purpose: peel off first 2 params (fixed), then loop through rest
  1329. X * In parameters:
  1330. X * Out parameters:
  1331. X * Precondition;
  1332. X * Postcondition:
  1333. X ************************************************************************/ 
  1334. static int
  1335. SetNameArgs
  1336. #ifdef UseFunctionPrototypes
  1337. X    (void)
  1338. #else
  1339. X    ()
  1340. X
  1341. #endif
  1342. {    register int n;
  1343. X
  1344. X    parent = va_arg(args, Widget);
  1345. X    name = va_arg(args, String);
  1346. X
  1347. X    for (n = 0; n < NXARGS; ++n)
  1348. X    {
  1349. X        xargs[n].name = va_arg(args, String);
  1350. X        if (xargs[n].name == NULL) 
  1351. X            break;
  1352. X        xargs[n].value = va_arg(args, XtArgVal);
  1353. X    }
  1354. X    return (n);
  1355. }
  1356. X
  1357. X
  1358. /*
  1359. **      varargs interface for Xt not defined for Motif 1.0
  1360. **      because it is based on X11 R3. In this case, define
  1361. **      equivalents to the Xt functions
  1362. */
  1363. #if XmVersion == 1000
  1364. X
  1365. /*
  1366. X *    Variable arg list version of XtCreateManagedWidget
  1367. X */
  1368. /* VARARGS */
  1369. /*************************************************************************
  1370. X * Function: XtVaCreatemanagedWidget
  1371. X * Purpose:
  1372. X * In parameters:
  1373. X * Out parameters:
  1374. X * Precondition;
  1375. X * Postcondition:
  1376. X ************************************************************************/ 
  1377. Widget
  1378. XXtVaCreateManagedWidget(va_alist)
  1379. va_dcl
  1380. {
  1381. X    String        name;
  1382. X    String        class;
  1383. X    Widget        parent;
  1384. X
  1385. X    register int    n;
  1386. X
  1387. X    va_start(args);
  1388. X    name = va_arg(args, String);
  1389. X    class = va_arg(args, String);
  1390. X    parent = va_arg(args, Widget);
  1391. X
  1392. X    n = SetArgs();
  1393. X
  1394. X    va_end(args);
  1395. X    return (XtCreateManagedWidget(name, class, parent, xargs, n));
  1396. }
  1397. X
  1398. /*************************************************************************
  1399. X * Function: XtVaSetvalues
  1400. X * Purpose:
  1401. X * In parameters:
  1402. X * Out parameters:
  1403. X * Precondition;
  1404. X * Postcondition:
  1405. X ************************************************************************/ 
  1406. /* VARARGS */
  1407. void
  1408. XXtVaSetValues(va_alist)
  1409. va_dcl
  1410. {
  1411. X    Widget        w;
  1412. X    register int    n;
  1413. X
  1414. X    va_start(args);
  1415. X    w = va_arg(args, Widget);
  1416. X
  1417. X    n = SetArgs();
  1418. X
  1419. X    va_end(args);
  1420. X    XtSetValues(w, xargs, n);
  1421. }
  1422. X
  1423. /*************************************************************************
  1424. X * Function: XtVaGetValues
  1425. X * Purpose:
  1426. X * In parameters:
  1427. X * Out parameters:
  1428. X * Precondition;
  1429. X * Postcondition:
  1430. X ************************************************************************/ 
  1431. /* VARARGS */
  1432. void
  1433. XXtVaGetValues(va_alist)
  1434. va_dcl
  1435. {
  1436. X    register int     n;
  1437. X    Widget        w;
  1438. X
  1439. X    va_start(args);
  1440. X    w = va_arg(args, Widget);
  1441. X
  1442. X    n = SetArgs();
  1443. X
  1444. X    va_end(args);
  1445. X    XtGetValues(w, xargs, n);
  1446. }
  1447. #endif /* Xmversion == 1000 */
  1448. X
  1449. /**********************************************************************
  1450. **    Variable arg list versions of widgets
  1451. **
  1452. */
  1453. X
  1454. /*
  1455. **    Variable arg list version of XmCreateArrowButton
  1456. */
  1457. /*************************************************************************
  1458. X * Function: XmVACreateArrowButton
  1459. X * Purpose: varargs interface to XmCreateArrowButton
  1460. X * In parameters: parent, name, args...
  1461. X * Out parameters:
  1462. X * Precondition;
  1463. X * Postcondition: arrow button created with resources set as in args
  1464. X ************************************************************************/ 
  1465. /* VARARGS */
  1466. Widget
  1467. XXmVaCreateArrowButton
  1468. #ifdef UseFunctionPrototypes
  1469. X    (int __builtin_va_alist)
  1470. #else
  1471. X    (va_alist)
  1472. va_dcl
  1473. X
  1474. #endif
  1475. {
  1476. X    register int    n;
  1477. X
  1478. X    va_start(args);
  1479. X
  1480. X    n = SetNameArgs();
  1481. X
  1482. X    va_end(args);
  1483. X    return (XtCreateWidget(name, xmArrowButtonWidgetClass, 
  1484. X                parent, xargs, n));
  1485. }
  1486. X
  1487. /*
  1488. **    Variable arg list version of XmCreateBulletinBoard
  1489. */
  1490. /*************************************************************************
  1491. X * Function:
  1492. X * Purpose:
  1493. X * In parameters:
  1494. X * Out parameters:
  1495. X * Precondition;
  1496. X * Postcondition:
  1497. X ************************************************************************/ 
  1498. /* VARARGS */
  1499. Widget
  1500. XXmVaCreateBulletinBoard
  1501. #ifdef UseFunctionPrototypes
  1502. X    (int __builtin_va_alist)
  1503. #else
  1504. X    (va_alist)
  1505. va_dcl
  1506. X
  1507. #endif
  1508. {
  1509. X    register int    n;
  1510. X
  1511. X    va_start(args);
  1512. X
  1513. X    n = SetNameArgs();
  1514. X
  1515. X    va_end(args);
  1516. X    return (XtCreateWidget(name, xmBulletinBoardWidgetClass, 
  1517. X                parent, xargs, n));
  1518. }
  1519. X
  1520. /*
  1521. **    Variable arg list version of XmCreateCascadeButton
  1522. */
  1523. /*************************************************************************
  1524. X * Function:
  1525. X * Purpose:
  1526. X * In parameters:
  1527. X * Out parameters:
  1528. X * Precondition;
  1529. X * Postcondition:
  1530. X ************************************************************************/ 
  1531. /* VARARGS */
  1532. Widget
  1533. XXmVaCreateCascadeButton
  1534. #ifdef UseFunctionPrototypes
  1535. X    (int __builtin_va_alist)
  1536. #else
  1537. X    (va_alist)
  1538. va_dcl
  1539. X
  1540. #endif
  1541. {
  1542. X    register int    n;
  1543. X
  1544. X    va_start(args);
  1545. X
  1546. X    n = SetNameArgs();
  1547. X
  1548. X    va_end(args);
  1549. X    return (XtCreateWidget(name, xmCascadeButtonWidgetClass, 
  1550. X                parent, xargs, n));
  1551. }
  1552. X
  1553. /*
  1554. **    Variable arg list version of XmCreateCommand
  1555. */
  1556. /*************************************************************************
  1557. X * Function:
  1558. X * Purpose:
  1559. X * In parameters:
  1560. X * Out parameters:
  1561. X * Precondition;
  1562. X * Postcondition:
  1563. X ************************************************************************/ 
  1564. /* VARARGS */
  1565. Widget
  1566. XXmVaCreateCommand
  1567. #ifdef UseFunctionPrototypes
  1568. X    (int __builtin_va_alist)
  1569. #else
  1570. X    (va_alist)
  1571. va_dcl
  1572. X
  1573. #endif
  1574. {
  1575. X    register int    n;
  1576. X
  1577. X    va_start(args);
  1578. X
  1579. X    n = SetNameArgs();
  1580. X
  1581. X    va_end(args);
  1582. X    return (XtCreateWidget(name, xmCommandWidgetClass, 
  1583. X                parent, xargs, n));
  1584. }
  1585. X
  1586. /*
  1587. **    Variable arg list version of XmCreateDialogShell
  1588. */
  1589. /*************************************************************************
  1590. X * Function:
  1591. X * Purpose:
  1592. X * In parameters:
  1593. X * Out parameters:
  1594. X * Precondition;
  1595. X * Postcondition:
  1596. X ************************************************************************/ 
  1597. /* VARARGS */
  1598. Widget
  1599. XXmVaCreateDialogShell
  1600. #ifdef UseFunctionPrototypes
  1601. X    (int __builtin_va_alist)
  1602. #else
  1603. X    (va_alist)
  1604. va_dcl
  1605. X
  1606. #endif
  1607. {
  1608. X    register int    n;
  1609. X
  1610. X    va_start(args);
  1611. X
  1612. X    n = SetNameArgs();
  1613. X
  1614. X    va_end(args);
  1615. X    return (XtCreateWidget(name, xmDialogShellWidgetClass, 
  1616. X                parent, xargs, n));
  1617. }
  1618. X
  1619. /*
  1620. **    Variable arg list version of XmCreateDrawingArea
  1621. */
  1622. /*************************************************************************
  1623. X * Function:
  1624. X * Purpose:
  1625. X * In parameters:
  1626. X * Out parameters:
  1627. X * Precondition;
  1628. X * Postcondition:
  1629. X ************************************************************************/ 
  1630. /* VARARGS */
  1631. Widget
  1632. XXmVaCreateDrawingArea
  1633. #ifdef UseFunctionPrototypes
  1634. X    (int __builtin_va_alist)
  1635. #else
  1636. X    (va_alist)
  1637. va_dcl
  1638. X
  1639. #endif
  1640. {
  1641. X    register int    n;
  1642. X
  1643. X    va_start(args);
  1644. X
  1645. X    n = SetNameArgs();
  1646. X
  1647. X    va_end(args);
  1648. X    return (XtCreateWidget(name, xmDrawingAreaWidgetClass, 
  1649. X                parent, xargs, n));
  1650. }
  1651. X
  1652. /*
  1653. **    Variable arg list version of XmCreateDrawnButton
  1654. */
  1655. /*************************************************************************
  1656. X * Function:
  1657. X * Purpose:
  1658. X * In parameters:
  1659. X * Out parameters:
  1660. X * Precondition;
  1661. X * Postcondition:
  1662. X ************************************************************************/ 
  1663. /* VARARGS */
  1664. Widget
  1665. XXmVaCreateDrawnButton
  1666. #ifdef UseFunctionPrototypes
  1667. X    (int __builtin_va_alist)
  1668. #else
  1669. X    (va_alist)
  1670. va_dcl
  1671. X
  1672. #endif
  1673. {
  1674. X    register int    n;
  1675. X
  1676. X    va_start(args);
  1677. X
  1678. X    n = SetNameArgs();
  1679. X
  1680. X    va_end(args);
  1681. X    return (XtCreateWidget(name, xmDrawnButtonWidgetClass, 
  1682. X                parent, xargs, n));
  1683. }
  1684. X
  1685. /*
  1686. **    Variable arg list version of XmCreateFileSelectionBox
  1687. */
  1688. /* VARARGS */
  1689. Widget
  1690. XXmVaCreateFileSelectionBox
  1691. #ifdef UseFunctionPrototypes
  1692. X    (int __builtin_va_alist)
  1693. #else
  1694. X    (va_alist)
  1695. va_dcl
  1696. X
  1697. #endif
  1698. {
  1699. X    register int    n;
  1700. X
  1701. X    va_start(args);
  1702. X
  1703. X    n = SetNameArgs();
  1704. X
  1705. X    va_end(args);
  1706. X    return (XtCreateWidget(name, xmFileSelectionBoxWidgetClass, 
  1707. X                parent, xargs, n));
  1708. }
  1709. X
  1710. /*
  1711. **    Variable arg list version of XmCreateForm
  1712. */
  1713. /*************************************************************************
  1714. X * Function:
  1715. X * Purpose:
  1716. X * In parameters:
  1717. X * Out parameters:
  1718. X * Precondition;
  1719. X * Postcondition:
  1720. X ************************************************************************/ 
  1721. /* VARARGS */
  1722. Widget
  1723. XXmVaCreateForm
  1724. #ifdef UseFunctionPrototypes
  1725. X    (int __builtin_va_alist)
  1726. #else
  1727. X    (va_alist)
  1728. va_dcl
  1729. X
  1730. #endif
  1731. {
  1732. X    register int    n;
  1733. X
  1734. X    va_start(args);
  1735. X
  1736. X    n = SetNameArgs();
  1737. X
  1738. X    va_end(args);
  1739. X    return (XtCreateWidget(name, xmFormWidgetClass, 
  1740. X                parent, xargs, n));
  1741. }
  1742. X
  1743. /*
  1744. **    Variable arg list version of XmCreateFrame
  1745. */
  1746. /* VARARGS */
  1747. Widget
  1748. XXmVaCreateFrame
  1749. #ifdef UseFunctionPrototypes
  1750. X    (int __builtin_va_alist)
  1751. #else
  1752. X    (va_alist)
  1753. va_dcl
  1754. X
  1755. #endif
  1756. {
  1757. X    register int    n;
  1758. X
  1759. X    va_start(args);
  1760. X
  1761. X    n = SetNameArgs();
  1762. X
  1763. X    va_end(args);
  1764. X    return (XtCreateWidget(name, xmFrameWidgetClass, 
  1765. X                parent, xargs, n));
  1766. }
  1767. X
  1768. /*
  1769. **    Variable arg list version of XmCreateLabel
  1770. */
  1771. /*************************************************************************
  1772. X * Function:
  1773. X * Purpose:
  1774. X * In parameters:
  1775. X * Out parameters:
  1776. X * Precondition;
  1777. X * Postcondition:
  1778. X ************************************************************************/ 
  1779. /* VARARGS */
  1780. Widget
  1781. XXmVaCreateLabel
  1782. #ifdef UseFunctionPrototypes
  1783. X    (int __builtin_va_alist)
  1784. #else
  1785. X    (va_alist)
  1786. va_dcl
  1787. X
  1788. #endif
  1789. {
  1790. X    register int    n;
  1791. X
  1792. X    va_start(args);
  1793. X
  1794. X    n = SetNameArgs();
  1795. X
  1796. X    va_end(args);
  1797. X    return (XtCreateWidget(name, xmLabelWidgetClass, 
  1798. X                parent, xargs, n));
  1799. }
  1800. X
  1801. /*
  1802. **    Variable arg list version of XmCreateList
  1803. */
  1804. /*************************************************************************
  1805. X * Function:
  1806. X * Purpose:
  1807. X * In parameters:
  1808. X * Out parameters:
  1809. X * Precondition;
  1810. X * Postcondition:
  1811. X ************************************************************************/ 
  1812. /* VARARGS */
  1813. Widget
  1814. XXmVaCreateList
  1815. #ifdef UseFunctionPrototypes
  1816. X    (int __builtin_va_alist)
  1817. #else
  1818. X    (va_alist)
  1819. va_dcl
  1820. X
  1821. #endif
  1822. {
  1823. X    register int    n;
  1824. X
  1825. X    va_start(args);
  1826. X
  1827. X    n = SetNameArgs();
  1828. X
  1829. X    va_end(args);
  1830. X    return (XtCreateWidget(name, xmListWidgetClass, 
  1831. X                parent, xargs, n));
  1832. }
  1833. X
  1834. /*
  1835. **    Variable arg list version of XmCreateMainWindow
  1836. */
  1837. /*************************************************************************
  1838. X * Function:
  1839. X * Purpose:
  1840. X * In parameters:
  1841. X * Out parameters:
  1842. X * Precondition;
  1843. X * Postcondition:
  1844. X ************************************************************************/ 
  1845. /* VARARGS */
  1846. Widget
  1847. XXmVaCreateMainWindow
  1848. #ifdef UseFunctionPrototypes
  1849. X    (int __builtin_va_alist)
  1850. #else
  1851. X    (va_alist)
  1852. va_dcl
  1853. X
  1854. #endif
  1855. {
  1856. X    register int    n;
  1857. X
  1858. X    va_start(args);
  1859. X
  1860. X    n = SetNameArgs();
  1861. X
  1862. X    va_end(args);
  1863. X    return (XtCreateWidget(name, xmMainWindowWidgetClass, 
  1864. X                parent, xargs, n));
  1865. }
  1866. X
  1867. /*
  1868. **    Variable arg list version of XmCreateMessageBox
  1869. */
  1870. /*************************************************************************
  1871. X * Function:
  1872. X * Purpose:
  1873. X * In parameters:
  1874. X * Out parameters:
  1875. X * Precondition;
  1876. X * Postcondition:
  1877. X ************************************************************************/ 
  1878. /* VARARGS */
  1879. Widget
  1880. XXmVaCreateMessageBox
  1881. #ifdef UseFunctionPrototypes
  1882. X    (int __builtin_va_alist)
  1883. #else
  1884. X    (va_alist)
  1885. va_dcl
  1886. X
  1887. #endif
  1888. {
  1889. X    register int    n;
  1890. X
  1891. X    va_start(args);
  1892. X
  1893. X    n = SetNameArgs();
  1894. X
  1895. X    va_end(args);
  1896. X    return (XtCreateWidget(name, xmMessageBoxWidgetClass, 
  1897. X                parent, xargs, n));
  1898. }
  1899. X
  1900. /*
  1901. **    Variable arg list version of XmCreatePanedWindow
  1902. */
  1903. /*************************************************************************
  1904. X * Function:
  1905. X * Purpose:
  1906. X * In parameters:
  1907. X * Out parameters:
  1908. X * Precondition;
  1909. X * Postcondition:
  1910. X ************************************************************************/ 
  1911. /* VARARGS */
  1912. Widget
  1913. XXmVaCreatePanedWindow
  1914. #ifdef UseFunctionPrototypes
  1915. X    (int __builtin_va_alist)
  1916. #else
  1917. X    (va_alist)
  1918. va_dcl
  1919. X
  1920. #endif
  1921. {
  1922. X    register int    n;
  1923. X
  1924. X    va_start(args);
  1925. X
  1926. X    n = SetNameArgs();
  1927. X
  1928. X    va_end(args);
  1929. X    return (XtCreateWidget(name, xmPanedWindowWidgetClass, 
  1930. X                parent, xargs, n));
  1931. }
  1932. X
  1933. /*
  1934. **    Variable arg list version of XmCreatePushButton
  1935. */
  1936. /*************************************************************************
  1937. X * Function:
  1938. X * Purpose:
  1939. X * In parameters:
  1940. X * Out parameters:
  1941. X * Precondition;
  1942. X * Postcondition:
  1943. X ************************************************************************/ 
  1944. /* VARARGS */
  1945. Widget
  1946. XXmVaCreatePushButton
  1947. #ifdef UseFunctionPrototypes
  1948. X    (int __builtin_va_alist)
  1949. #else
  1950. X    (va_alist)
  1951. va_dcl
  1952. X
  1953. #endif
  1954. {
  1955. X    register int    n;
  1956. X
  1957. X    va_start(args);
  1958. X
  1959. X    n = SetNameArgs();
  1960. X
  1961. X    va_end(args);
  1962. X    return (XtCreateWidget(name, xmPushButtonWidgetClass, 
  1963. X                parent, xargs, n));
  1964. }
  1965. X
  1966. /*
  1967. **    Variable arg list version of XmCreateRowColumn
  1968. */
  1969. /*************************************************************************
  1970. X * Function:
  1971. X * Purpose:
  1972. X * In parameters:
  1973. X * Out parameters:
  1974. X * Precondition;
  1975. X * Postcondition:
  1976. X ************************************************************************/ 
  1977. /* VARARGS */
  1978. Widget
  1979. XXmVaCreateRowColumn
  1980. #ifdef UseFunctionPrototypes
  1981. X    (int __builtin_va_alist)
  1982. #else
  1983. X    (va_alist)
  1984. va_dcl
  1985. X
  1986. #endif
  1987. {
  1988. X    register int    n;
  1989. X
  1990. X    va_start(args);
  1991. X
  1992. X    n = SetNameArgs();
  1993. X
  1994. X    va_end(args);
  1995. X    return (XtCreateWidget(name, xmRowColumnWidgetClass, 
  1996. X                parent, xargs, n));
  1997. }
  1998. X
  1999. /*
  2000. **    Variable arg list version of XmCreateScale
  2001. */
  2002. /*************************************************************************
  2003. SHAR_EOF
  2004. true || echo 'restore of xmfm/xmvararg.c failed'
  2005. fi
  2006. echo 'End of  part 8'
  2007. echo 'File xmfm/xmvararg.c is continued in part 9'
  2008. echo 9 > _shar_seq_.tmp
  2009. exit 0
  2010. --
  2011. +----------------------+---+
  2012.   Jan Newmarch, Information Science and Engineering,
  2013.   University of Canberra, PO Box 1, Belconnen, Act 2616
  2014.   Australia. Tel: (Aust) 6-2012422. Fax: (Aust) 6-2015041
  2015.