home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume19 / xbmbrwsr / part01 < prev    next >
Encoding:
Text File  |  1993-04-27  |  44.5 KB  |  1,465 lines

  1. Newsgroups: comp.sources.x
  2. From: aroll@gucis.cit.gu.edu.au (Ashley Roll)
  3. Subject: v19i003:  xbmbrowser - browse bitmaps in a directory V1.0, Part01/01
  4. Message-ID: <1993Mar5.230603.9648@sparky.imd.sterling.com>
  5. X-Md4-Signature: ec03f207d9dc320f3294a5aa8c36be57
  6. Date: Fri, 5 Mar 1993 23:06:03 GMT
  7. Approved: chris@sparky.imd.sterling.com
  8.  
  9. Submitted-by: aroll@gucis.cit.gu.edu.au (Ashley Roll)
  10. Posting-number: Volume 19, Issue 3
  11. Archive-name: xbmbrowser/part01
  12. Environment: X11
  13.  
  14. This is a program that will display all the bitmaps in a directory. 
  15.  
  16. It make bitmap management eaiser as it will allow you to copy, rename, delete,
  17. and edit bitmaps as well as setting them as the root window decoration.
  18.  
  19. Cheers,
  20. Ashley Roll.
  21.  
  22. -----------8<-----------8<-----------8<-----------8<-----------8<-----------
  23. #! /bin/sh
  24. # This is a shell archive.  Remove anything before this line, then unpack
  25. # it by saving it into a file and typing "sh file".  To overwrite existing
  26. # files, type "sh file -c".  You can also feed this as standard input via
  27. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  28. # will see the following message at the end:
  29. #        "End of shell archive."
  30. # Contents:  Imakefile Makefile.std README callbacks.c icon.xbm misc.c
  31. #   patchlevel.h xbmbrowser.c xbmbrowser.h xbmbrowser.help
  32. #   xbmbrowser.man
  33. # Wrapped by aroll@gucis on Tue Aug  4 12:19:27 1992
  34. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  35. if test -f 'Imakefile' -a "${1}" != "-c" ; then 
  36.   echo shar: Will not clobber existing file \"'Imakefile'\"
  37. else
  38. echo shar: Extracting \"'Imakefile'\" \(345 characters\)
  39. sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
  40. XHELPFILE = -DHELPFILE=\"$(LIBDIR)$(PATHSEP)xbmbrowser.help\"
  41. X
  42. X        DEFINES = $(HELPFILE)
  43. X        DEPLIBS = XawClientDepLibs
  44. XLOCAL_LIBRARIES = XawClientLibs
  45. X  SYS_LIBRARIES = -lm
  46. X           SRCS = xbmbrowser.c callbacks.c misc.c
  47. X           OBJS = $(SRCS:.c=.o)
  48. X
  49. XComplexProgramTarget(xbmbrowser)
  50. XInstallNonExecFile(xbmbrowser.help,$(LIBDIR))
  51. X
  52. X
  53. END_OF_FILE
  54. if test 345 -ne `wc -c <'Imakefile'`; then
  55.     echo shar: \"'Imakefile'\" unpacked with wrong size!
  56. fi
  57. # end of 'Imakefile'
  58. fi
  59. if test -f 'Makefile.std' -a "${1}" != "-c" ; then 
  60.   echo shar: Will not clobber existing file \"'Makefile.std'\"
  61. else
  62. echo shar: Extracting \"'Makefile.std'\" \(324 characters\)
  63. sed "s/^X//" >'Makefile.std' <<'END_OF_FILE'
  64. X#
  65. X# This is the Makefile for xbmbrowser.
  66. X# 
  67. X
  68. XCFLAGS         = -O $(DEFS)
  69. XCC             = cc
  70. XLIBS = -lX11 -lXaw -lXt -lXmu -lXext
  71. XOBJS = xbmbrowser.o misc.o callbacks.o
  72. XSRCS = xbmbrowser.c misc.c callbakcs.c
  73. X
  74. Xxbmbrowser: $(OBJS)
  75. X    $(CC) -o xbmbrowser $(OBJS) $(DEFS) $(LIBS)
  76. X    strip xbmbrowser
  77. X
  78. Xclean:
  79. X    rm -f core  *.o *~ #*
  80. X
  81. END_OF_FILE
  82. if test 324 -ne `wc -c <'Makefile.std'`; then
  83.     echo shar: \"'Makefile.std'\" unpacked with wrong size!
  84. fi
  85. # end of 'Makefile.std'
  86. fi
  87. if test -f 'README' -a "${1}" != "-c" ; then 
  88.   echo shar: Will not clobber existing file \"'README'\"
  89. else
  90. echo shar: Extracting \"'README'\" \(3159 characters\)
  91. sed "s/^X//" >'README' <<'END_OF_FILE'
  92. XREADME file for xbmbrowser, By Ashley Roll                          Version 1.0
  93. X
  94. Xxbmbrowser is a program to let you easily manipulate Bitmap files.
  95. X
  96. XThis program has only been tested on Suns.
  97. X
  98. X******************************************************************************
  99. X** xbmbrowser is Public Domain. However it, and all the code still belong to me.
  100. X** I do, however grant permission for you to freely copy and distribute it on
  101. X** the condition that this and all other copyright notices remain unchanged in
  102. X** all distributions.
  103. X**
  104. X** This software comes with NO warranty whatsoever. I therefore take no
  105. X** responsibility for any damages, losses or problems that the program may
  106. X** cause.
  107. X******************************************************************************
  108. X
  109. XFILES:  README           - this file.
  110. X        Imakefile
  111. X        Makefile.std     - the standard make file.
  112. X        xbmbrowser.c     \ 
  113. X        xbmbrowser.h      -
  114. X        callbacks.c      - the 'C' code.
  115. X        misc.c          /
  116. X        xbmbrowser.man    - a simple manual page.
  117. X        xbmbrowser.help   - the help file that the program uses - see below.
  118. X
  119. X
  120. XThere are three things that you must setup for your site:
  121. X
  122. XEDITOR constant:
  123. XIn the file 'xbmbrowser.h' you must set the name (and possibly the full path 
  124. Xif it is not in the normal path) of the bitmap editor you wish to use.
  125. XThe editor MUST accept the command line of:
  126. X
  127. Xbitmapeditor <bitmap file to edit>
  128. X
  129. Xwhere bitmapeditor is the editor you select and <bitmap file to edit>
  130. Xis a bitmap file name (passed to it by xbmbrowser)
  131. X
  132. XNOTE: If you wish to pass arguments to the editor, then put them into this
  133. X      define, and the filename will be appended to the end.
  134. X
  135. XSETROOT constant:
  136. XAnd also in the file 'xbmbrowser.h' you must set the name (and possibly the 
  137. Xfull path if it is not in the normal path) of the program to set a bitmap 
  138. Xas the decoration for the root window. The default is 'xsetroot' and all
  139. Xthe things that you can do to the EDITOR setting apply to this.
  140. X
  141. XSETROOTINV constant:
  142. XThis is the name and options of the program to set a bitmap as the root window
  143. Xdecoration inverted (colors inverted).
  144. X
  145. X
  146. XIf you put and empty set of quotes ("") for any of these variables, then the
  147. Xcorresponding selection in the menu will be insensitive so it won't run. 
  148. X
  149. XThis is already setup to use 'bitmap' when it is in the path that the 
  150. Xprogram gets.
  151. X
  152. XInstallation:
  153. X
  154. XWith Imake:
  155. X
  156. X   type:
  157. X     xmkmf
  158. X     make
  159. X     make install
  160. X     make instal.man
  161. X
  162. XWith normal make:
  163. X
  164. X   type:
  165. X     mv Makefile.std Makefile
  166. X     make
  167. X   then you will have to manually move the executable and man page to where
  168. X   you want to put them.
  169. X
  170. XFor information on how to use xbmbrowser, look at xbmbrowser.help, or press the 
  171. X[Help] button when it is running.
  172. X
  173. XIf you wish to change the program, then please feel free. However You must
  174. Xleave the copyright notices unchanged but add one detailing your changes, you
  175. Xshould also not just increment the version number, but add something unique
  176. Xto it (like your name or something).
  177. X
  178. XIf you have any problems, then please feel free to drop me a line, my E-mail
  179. Xaddress (internet) is aroll@gucis.cit.gu.edu.au
  180. X
  181. END_OF_FILE
  182. if test 3159 -ne `wc -c <'README'`; then
  183.     echo shar: \"'README'\" unpacked with wrong size!
  184. fi
  185. # end of 'README'
  186. fi
  187. if test -f 'callbacks.c' -a "${1}" != "-c" ; then 
  188.   echo shar: Will not clobber existing file \"'callbacks.c'\"
  189. else
  190. echo shar: Extracting \"'callbacks.c'\" \(9410 characters\)
  191. sed "s/^X//" >'callbacks.c' <<'END_OF_FILE'
  192. X/*
  193. X*****************************************************************************
  194. X** xbmbrowser version 1.0  (c) Copyright Ashley Roll, 1992.
  195. X** FILE: callbacks.c
  196. X**
  197. X** xbmbrowser is Public Domain. However it, and all the code still belong to me.
  198. X** I do, however grant permission for you to freely copy and distribute it on 
  199. X** the condition that this and all other copyright notices remain unchanged in 
  200. X** all distributions.
  201. X**
  202. X** This software comes with NO warranty whatsoever. I therefore take no
  203. X** responsibility for any damages, losses or problems that the program may 
  204. X** cause.
  205. X*****************************************************************************
  206. X*/
  207. X
  208. X#include "xbmbrowser.h"
  209. X#include <pwd.h>
  210. X
  211. Xextern FileList *get_files();
  212. Xint mv;
  213. Xchar trans[] = 
  214. X  "<Key>Return:  Ok() \n\
  215. X   Ctrl<Key>M:   Ok() ";
  216. X
  217. XWidget delete,delete_q,getname,query;
  218. X
  219. X/*
  220. X** expand a tilder in situ
  221. X** This was sent to me by:
  222. X_______________________________________________________________________________
  223. XChris McDonald.            _--_|\
  224. X                          /      \
  225. X                          X_.--._/
  226. X                                v
  227. XDepartment of Computer Science,   AARNet: chris@budgie.cs.uwa.edu.au
  228. XUniversity of Western Australia,  FTP:    bilby.cs.uwa.edu.au,  130.95.1.11
  229. XCrawley, Western Australia, 6009. SCUD:   (31.97 +/-10% S, 115.81 +/-10% E)
  230. XPHONE:       +61 9 380 2533       FAX:    +61 9 380 1089
  231. X**
  232. X** and I have modified it slightly
  233. X*/
  234. Xstatic void expand_twiddle(text)                /* expand in-situ in twiddle */
  235. Xchar *text;
  236. X{
  237. X    static char buf[255];
  238. X    char *s, *t, *t1;
  239. X    struct passwd *p, *getpwnam();
  240. X
  241. X    s = text;
  242. X    s++;                                        /* skip leading twiddle */
  243. X    t = buf;
  244. X    while (*s && *s != '/')
  245. X        *t++ = *s++;
  246. X    *t = NULL;
  247. X    if(*buf && (p = getpwnam(buf)) == NULL)
  248. X        return;
  249. X    t1 = *buf ? p->pw_dir : (char *) getenv("HOME");
  250. X    t = buf;
  251. X    while( *t++ = *t1++ );                      /* buf <- home_dir */
  252. X    t--;
  253. X    while( *t++ = *s++ );                       /* buf += rest_of_a */
  254. X    t  = text;
  255. X    t1 = buf;
  256. X    while( *t++ = *t1++ );                      /* s   <- buf */
  257. X}
  258. X
  259. X/*
  260. X** callback for the cancel button
  261. X*/
  262. Xvoid Cancel(w,client_data,call_data )
  263. XWidget w;
  264. XXtPointer client_data,call_data;
  265. X{
  266. X  XtPopdown(query);
  267. X}
  268. X
  269. X/*
  270. X** callback for the cancel button in the delete requester */
  271. Xvoid Cancel_del(w,client_data,call_data )
  272. XWidget w;
  273. XXtPointer client_data,call_data;
  274. X{
  275. X  XtPopdown(delete_q);
  276. X}
  277. X
  278. X/*
  279. X** callback for the ok button in the delete requester
  280. X*/
  281. Xvoid Del(w,client_data,call_data )
  282. XWidget w;
  283. XXtPointer client_data,call_data;
  284. X{
  285. X  unlink(bname);
  286. X
  287. X  XtPopdown(delete_q);
  288. X
  289. Xsetup();
  290. X}
  291. X
  292. X/*
  293. X** callback for the OK button in the rename and copy requesters
  294. X*/
  295. Xvoid Ok(w,client_data,call_data )
  296. XWidget w;
  297. XXtPointer client_data,call_data;
  298. X{
  299. Xchar text[255];
  300. Xchar cmd[255];
  301. Xint i;
  302. X
  303. X  /* link the filename in the text part of the dialog widget, to the 
  304. X     filename in bname, and if client_data is TRUE, then unlink the 
  305. X     name in bname (this is a rename, a copy if the original is left) */
  306. X
  307. X  strcpy(text, XawDialogGetValueString(getname));
  308. X/* search for the first non-space char */
  309. X  i = 0;
  310. X  while(isspace(text[i])) i++;
  311. X
  312. X  if(text[i] == '~') expand_twiddle(&text[i]);
  313. X
  314. X  if(strcmp(bname,text) != 0) {
  315. X      sprintf(cmd,"%s %s %s",(mv)?"mv":"cp",bname,text);
  316. X      system(cmd);
  317. X  }
  318. X  XtPopdown(query);
  319. X
  320. Xsetup();
  321. X}
  322. X
  323. X/*
  324. X** setup the dialog window
  325. X*/
  326. Xvoid setup_dialog()
  327. X{
  328. X
  329. X  Position    x, y;
  330. X  Dimension   height,width;
  331. X
  332. X/* create and position an transsient window to put the stuff in */
  333. X  XtVaGetValues(toplevel,XtNwidth, &width,XtNheight, &height,NULL);
  334. X  XtTranslateCoords(toplevel,(Position)(width/2)-175,
  335. X                    (Position)(height/2),&x, &y);
  336. X
  337. X  query = XtVaCreatePopupShell("Query",transientShellWidgetClass,mainpw,
  338. X                       XtNx,(XtArgVal)x,XtNy,(XtArgVal)y,NULL);
  339. X
  340. X  getname = XtVaCreateManagedWidget("GetName",dialogWidgetClass,query,
  341. X                       XtNvalue,(XtArgVal)"",
  342. X                       NULL);
  343. X  XtOverrideTranslations(XtNameToWidget (getname, "value"),
  344. X              XtParseTranslationTable(trans));
  345. X
  346. X  XawDialogAddButton(getname,"Ok",Ok,NULL);
  347. X  XawDialogAddButton(getname,"Cancel",Cancel,NULL);
  348. X
  349. X/* set things up so that if we change the info in a widget, the dialog
  350. X   widget will allow it's children to resize */
  351. X
  352. X/* create the delete query */
  353. X delete_q = XtVaCreatePopupShell("DeleteQuery",transientShellWidgetClass,mainpw,
  354. X                       XtNx,(XtArgVal)x,XtNy,(XtArgVal)y, NULL);
  355. X
  356. X  delete =  XtVaCreateManagedWidget("DelYesNo",dialogWidgetClass,delete_q,
  357. X                       XtNlabel,(XtArgVal)"",NULL);
  358. X  XawDialogAddButton(delete,"Yes",Del,NULL);
  359. X  XawDialogAddButton(delete,"No",Cancel_del,NULL);
  360. X
  361. X}
  362. X
  363. X
  364. X/*
  365. X** sets up the rename requester 
  366. X*/
  367. Xvoid rename_bitmap(w,client_data,call_data )
  368. XWidget w;
  369. XXtPointer client_data,call_data;
  370. X{
  371. X  Position    x, y;
  372. X  Dimension   height,width;
  373. X  Widget a;
  374. X
  375. X/* check if the dialogs are made yet.. */
  376. Xif(!dialogs_made) setup_dialog();
  377. X
  378. X/* set the global so the system call will be 'mv' */
  379. X  mv = TRUE;
  380. X
  381. X/* create a dialog widget with the an 'ok' button */
  382. X  XtVaSetValues(getname,XtNlabel,(XtArgVal)"Rename to:",NULL);
  383. X  XtVaSetValues(getname,XtNvalue,(XtArgVal)bname,NULL); 
  384. X
  385. X  XtPopup(query,XtGrabExclusive);
  386. X}
  387. X
  388. X/*
  389. X** sets up the delete requester
  390. X*/
  391. Xvoid delete_bitmap(w,client_data,call_data )
  392. XWidget w;
  393. XXtPointer client_data,call_data;
  394. X{
  395. X  Position    x, y;
  396. X  Dimension   height,width;
  397. X  Widget a;
  398. X  char str[255];
  399. X
  400. X/* check if the dialogs are made yet.. */
  401. Xif(!dialogs_made) setup_dialog();
  402. X
  403. X  sprintf(str,"Do You Realy wish to delete:\n%s",bname);
  404. X  XtVaSetValues(delete,XtNlabel,(XtArgVal)str,NULL); 
  405. X  XtPopup(delete_q,XtGrabExclusive); 
  406. X
  407. X}
  408. X
  409. X/*
  410. X** sets up the copy requester
  411. X*/
  412. Xvoid copy_bitmap(w,client_data,call_data )
  413. XWidget w;
  414. XXtPointer client_data,call_data;
  415. X{
  416. X  Position    x, y;
  417. X  Dimension   height,width;
  418. X  Widget a;
  419. X
  420. X/* check if the dialogs are made yet.. */
  421. Xif(!dialogs_made) setup_dialog();
  422. X
  423. X/* set the global so that the system call will use 'cp' */
  424. X  mv = FALSE;
  425. X
  426. X/* create a dialog widget with the an 'ok' button */
  427. X
  428. X  XtVaSetValues(getname,XtNlabel,(XtArgVal)"Copy to:",NULL);
  429. X  XtVaSetValues(getname,XtNvalue,(XtArgVal)bname,NULL);
  430. X
  431. X  XtPopup(query,XtGrabExclusive); 
  432. X
  433. X}
  434. X
  435. X/*
  436. X** this function is added to the notify callback on all the 
  437. X** menuButtons so that the global 'bname' contains the most 
  438. X** reciently selected bitmap name
  439. X*/
  440. Xvoid set_name(widget,event)
  441. XWidget widget;
  442. XXButtonEvent *event;
  443. X{
  444. Xchar str[255],*t;
  445. XDimension iw,ih,w,h;
  446. X  bname = XtName(widget);
  447. X  XtVaGetValues(widget,
  448. X                XtNinternalHeight,&ih,
  449. X                XtNinternalWidth,&iw,
  450. X                XtNheight,&h,
  451. X                XtNwidth,&w,
  452. X                NULL);
  453. X  w -= 2 * iw;
  454. X  h -= 2 * ih;
  455. X
  456. X  if ((t = strrchr(bname,'/')) == NULL)
  457. X    t = bname;
  458. X  else
  459. X    t++;
  460. X  sprintf(str,"%s (%dx%d)",t,(int)w,(int)h);
  461. X  XtVaSetValues(lw,XtNlabel,(XtArgVal)str,NULL);
  462. X}
  463. X
  464. X/*
  465. X** this function runs (with a system() call) the editor
  466. X** with arguments to edit the file in bname
  467. X*/
  468. Xvoid edit_bitmap(w,client_data,call_data )
  469. XWidget w;
  470. XXtPointer client_data,call_data;
  471. X{
  472. Xchar command[255],tmp[255];
  473. X
  474. XXtPopdown(menu);
  475. X  if(bname[0] != '\0') {
  476. X    sprintf(command,"%s %s &",EDITOR,bname);
  477. X    system(command);
  478. X  }
  479. X}
  480. X
  481. X/*
  482. X** this function runs (with a system() call) the program specified in
  483. X** SETROOT with arguments of the file in bname
  484. X*/
  485. Xvoid set_root(w,client_data,call_data )
  486. XWidget w;
  487. XXtPointer client_data,call_data;
  488. X{
  489. Xchar command[255],tmp[255];
  490. X
  491. XXtPopdown(menu);
  492. X  if(bname[0] != '\0') {
  493. X    sprintf(command,"%s \"%s\" &",SETROOT,bname);
  494. X    system(command);
  495. X  }
  496. X}
  497. X
  498. X/*
  499. X** this function runs (with a system() call) the program specified in
  500. X** SETROOTINV with arguments of the file in bname
  501. X*/
  502. Xvoid set_root_inv(w,client_data,call_data )
  503. XWidget w;
  504. XXtPointer client_data,call_data;
  505. X{
  506. Xchar command[255],tmp[255];
  507. X
  508. XXtPopdown(menu);
  509. X  if(bname[0] != '\0') {
  510. X    sprintf(command,"%s \"%s\" &",SETROOTINV,bname);
  511. X    system(command);
  512. X  }
  513. X}
  514. X
  515. X/*
  516. X** this is used as a destroyCallback in all the menuButtons
  517. X** it destroys the Pixmap that they used. This is done so that we
  518. X** don't fill the Xterm memory with unused bitmaps!!
  519. X*/
  520. Xvoid destroy_Callback(w,client_data,call_data )
  521. XWidget w;
  522. XXtPointer client_data,call_data;
  523. X{
  524. XXFreePixmap(XtDisplay(toplevel),(Pixmap)client_data);
  525. X}
  526. X
  527. X/*
  528. X** this is the callback for the Rescan button
  529. X** it just calls setup()
  530. X*/
  531. Xvoid rescan(w,client_data,call_data )
  532. XWidget w;
  533. XXtPointer client_data,call_data;
  534. X{
  535. Xsetup();
  536. X}
  537. X
  538. X/*
  539. X** this is the callback for the directory name asciiTextWidget
  540. X*/
  541. Xvoid change_dir(w,client_data,call_data )
  542. XWidget w;
  543. XXtPointer client_data,call_data;
  544. X{
  545. XWidget t;
  546. Xchar *text;
  547. X
  548. X/* get the new directory from the widget and only continue if it is 
  549. X   not the same and is a VALID directory. */
  550. X
  551. X  text = XawDialogGetValueString(atw);
  552. X  if(strcmp(dname,text) == 0) return; /* nothing to do */ 
  553. X
  554. X/* check if it contains a '~' as the first char and substute the correct dir */ 
  555. X   if (text[0] == '~') expand_twiddle(text);
  556. X
  557. X
  558. X/* change the current directory to the new directory */
  559. X  if(chdir(text) != 0) {
  560. X    XtVaSetValues(atw,XtNvalue,(XtArgVal)dname,NULL);
  561. X    return;
  562. X  } 
  563. X    (void) getcwd(dname,253);
  564. X    XtVaSetValues(atw,XtNvalue,(XtArgVal)dname,NULL);
  565. X    XtVaSetValues(lw,XtNlabel,(XtArgVal)"No Bitmap Selected",NULL);
  566. X
  567. X/* reset the bitmaps */
  568. Xsetup();
  569. X}
  570. X
  571. END_OF_FILE
  572. if test 9410 -ne `wc -c <'callbacks.c'`; then
  573.     echo shar: \"'callbacks.c'\" unpacked with wrong size!
  574. fi
  575. # end of 'callbacks.c'
  576. fi
  577. if test -f 'icon.xbm' -a "${1}" != "-c" ; then 
  578.   echo shar: Will not clobber existing file \"'icon.xbm'\"
  579. else
  580. echo shar: Extracting \"'icon.xbm'\" \(2774 characters\)
  581. sed "s/^X//" >'icon.xbm' <<'END_OF_FILE'
  582. X#define icon_width 64
  583. X#define icon_height 54
  584. Xstatic char icon_bits[] = {
  585. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  586. X   0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xcf, 0x7f, 0x9e, 0xcf, 0xff,
  587. X   0x34, 0x06, 0x00, 0x48, 0x49, 0x92, 0x48, 0x92, 0x0c, 0x08, 0x4e, 0xc8,
  588. X   0x7f, 0x9e, 0xca, 0xa4, 0x0c, 0x78, 0x31, 0x08, 0x00, 0x80, 0x48, 0xc9,
  589. X   0x04, 0xd8, 0x20, 0x0a, 0x00, 0x80, 0x4f, 0x92, 0xc4, 0xbb, 0x63, 0x0a,
  590. X   0x00, 0x00, 0xc0, 0xa4, 0x04, 0x9c, 0x24, 0x0a, 0x00, 0x00, 0x40, 0xc9,
  591. X   0x0c, 0xfc, 0xbd, 0x09, 0x00, 0x00, 0xc0, 0xff, 0x0c, 0xdf, 0xcf, 0x09,
  592. X   0x00, 0x00, 0x00, 0x00, 0x34, 0xdf, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00,
  593. X   0xc4, 0xcd, 0x87, 0x08, 0x00, 0x00, 0x00, 0x00, 0xc4, 0xdb, 0x87, 0x08,
  594. X   0x00, 0x00, 0x00, 0x00, 0x04, 0xfb, 0x47, 0x08, 0x00, 0x00, 0x00, 0x00,
  595. X   0xc4, 0xfe, 0x3b, 0x09, 0x00, 0x00, 0x00, 0x00, 0xc4, 0x47, 0x00, 0x08,
  596. X   0x00, 0x00, 0x00, 0x00, 0x84, 0x03, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
  597. X   0xfc, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  598. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  599. X   0xfc, 0xf3, 0xff, 0xff, 0xf9, 0xf9, 0xff, 0x1f, 0xac, 0x12, 0x00, 0x00,
  600. X   0x09, 0xf9, 0xff, 0x1f, 0x54, 0x13, 0x00, 0x00, 0x69, 0xf9, 0xff, 0x1f,
  601. X   0xac, 0x12, 0xc0, 0x01, 0x69, 0xf9, 0xff, 0x1f, 0x54, 0x13, 0x60, 0x02,
  602. X   0x69, 0xf9, 0xff, 0x1f, 0xac, 0xd2, 0x9f, 0x04, 0x69, 0xf9, 0xff, 0x1f,
  603. X   0xfc, 0x13, 0x90, 0x04, 0x69, 0xf9, 0xff, 0x1f, 0x00, 0x10, 0x92, 0x04,
  604. X   0x69, 0xf9, 0xff, 0x1f, 0x00, 0xd0, 0xa3, 0x02, 0x69, 0x01, 0x00, 0x00,
  605. X   0x00, 0x10, 0xc8, 0x07, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10, 0x25, 0x0c,
  606. X   0x69, 0x01, 0x00, 0x00, 0x00, 0x50, 0x22, 0x18, 0x69, 0x01, 0x00, 0x00,
  607. X   0x00, 0x10, 0x20, 0x10, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
  608. X   0x69, 0x01, 0x00, 0x00, 0x00, 0xf0, 0xff, 0xff, 0x09, 0x01, 0x00, 0x00,
  609. X   0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  610. X   0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00,
  611. X   0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xa4, 0xbb, 0x24, 0x75,
  612. X   0x91, 0xee, 0x08, 0x00, 0xa4, 0xa8, 0x25, 0x35, 0x99, 0x26, 0x09, 0x00,
  613. X   0xa4, 0xa8, 0xc6, 0x14, 0x66, 0xe2, 0x08, 0x00, 0xa4, 0xbb, 0x44, 0x74,
  614. X   0x22, 0x2e, 0x09, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
  615. X   0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
  616. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  617. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  618. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  619. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  620. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  621. END_OF_FILE
  622. if test 2774 -ne `wc -c <'icon.xbm'`; then
  623.     echo shar: \"'icon.xbm'\" unpacked with wrong size!
  624. fi
  625. # end of 'icon.xbm'
  626. fi
  627. if test -f 'misc.c' -a "${1}" != "-c" ; then 
  628.   echo shar: Will not clobber existing file \"'misc.c'\"
  629. else
  630. echo shar: Extracting \"'misc.c'\" \(4951 characters\)
  631. sed "s/^X//" >'misc.c' <<'END_OF_FILE'
  632. X/*
  633. X*****************************************************************************
  634. X** xbmbrowser version 1.0  (c) Copyright Ashley Roll, 1992.
  635. X** FILE: misc.c
  636. X**
  637. X** xbmbrowser is Public Domain. However it, and all the code still belong to me.
  638. X** I do, however grant permission for you to freely copy and distribute it on 
  639. X** the condition that this and all other copyright notices remain unchanged in 
  640. X** all distributions.
  641. X**
  642. X** This software comes with NO warranty whatsoever. I therefore take no
  643. X** responsibility for any damages, losses or problems that the program may 
  644. X** cause.
  645. X*****************************************************************************
  646. X*/
  647. X
  648. X#include "xbmbrowser.h"
  649. X
  650. X
  651. X/* 
  652. X** This function is called by the widgets and Windowmanager to quit the 
  653. X** program
  654. X*/
  655. Xvoid DoQuit(w, event, params, num_params)
  656. XWidget w;
  657. XXEvent *event;
  658. XString *params;
  659. XCardinal *num_params;
  660. X{
  661. X  exit(0);
  662. X}
  663. X
  664. X/*
  665. X** Create a new menu - and put a line under the lable
  666. X*/
  667. XWidget MakeMenu(parent,name,label)
  668. XWidget parent;
  669. Xchar *name,*label;
  670. X{
  671. XWidget w;
  672. X
  673. X
  674. X   w = XtVaCreatePopupShell(name,simpleMenuWidgetClass,parent,
  675. X                     XtNlabel,(XtArgVal)label,NULL);
  676. X
  677. X   if (label != NULL)
  678. X   (void) XtVaCreateManagedWidget("line",smeLineObjectClass,w,NULL);
  679. X
  680. Xreturn(w);
  681. X}
  682. X
  683. X
  684. X/* 
  685. X** add an smeBSBObjectClass object to a menu (widget)
  686. X** callback is the procedure that it calls or NULL
  687. X*/
  688. XWidget AddMenuItem(menu,label,callback,cbdata,sensitive)
  689. XWidget menu;
  690. Xchar *label;
  691. XXtCallbackProc callback;
  692. XXtPointer cbdata;
  693. Xint sensitive;
  694. X{
  695. XWidget w;
  696. X
  697. X  w = XtVaCreateManagedWidget(
  698. X             label,smeBSBObjectClass,menu,
  699. X             XtNlabel,(XtArgVal)label,XtNjustify,XtJustifyCenter,NULL);
  700. X
  701. X  if(!sensitive)
  702. X    XtVaSetValues(w,XtNsensitive,(XtArgVal)False,NULL);
  703. X
  704. X  if(callback != NULL)
  705. X  XtAddCallback( w, "callback",callback, cbdata);
  706. X
  707. Xreturn (w);
  708. X}
  709. X
  710. X/*
  711. X** these two procedures handle the help window 
  712. X**
  713. X** the first is the callback for the 'Done' button the other created the 
  714. X** window and puts the stuff in it.
  715. X*/
  716. XWidget h_shell;
  717. X
  718. Xvoid Quit_Help(w,client_data,call_data )
  719. XWidget w;
  720. XXtPointer client_data,call_data;
  721. X{
  722. X  XtDestroyWidget(h_shell);
  723. X}
  724. X
  725. Xvoid Show_Help(w,client_data,call_data )
  726. XWidget w;
  727. XXtPointer client_data,call_data;
  728. X{
  729. XWidget button,about,form;
  730. X
  731. X   /* create the popup shell to put the about into */
  732. X   h_shell = XtVaCreatePopupShell("Help_Window",shellWidgetClass,bfw,NULL);
  733. X
  734. X   form = XtVaCreateManagedWidget("Help_fw",formWidgetClass,h_shell,NULL);
  735. X
  736. X  /* create the widget to put the about into */
  737. X  about = XtVaCreateManagedWidget("text",asciiTextWidgetClass,form,
  738. X          XtNdisplayCaret,(XtArgVal)False,
  739. X          XtNscrollVertical,(XtArgVal)XawtextScrollWhenNeeded,
  740. X          XtNscrollHorizontal,(XtArgVal)XawtextScrollWhenNeeded,
  741. X          XtNwidth,(XtArgVal)575,
  742. X          XtNheight,(XtArgVal)200,
  743. X          XtNtype,(XtArgVal)XawAsciiFile,
  744. X          XtNstring,(XtArgVal)HELPFILE,NULL);
  745. X
  746. X
  747. X button =  XtVaCreateManagedWidget(
  748. X           "Done",commandWidgetClass,form,XtNlabel,(XtArgVal)"Done",
  749. X           XtNfromVert,(XtArgVal)about,NULL);
  750. X XtAddCallback(button,"callback",Quit_Help,NULL);
  751. X
  752. X XtPopup(h_shell,XtGrabNone);
  753. X XStoreName(XtDisplay(h_shell),XtWindow(h_shell),"xbmbrowser Help");
  754. X XSetIconName(XtDisplay(h_shell),XtWindow(h_shell),"xbmbrowser Help");
  755. X}
  756. X
  757. X/* 
  758. X** sort a linked list 
  759. X*/
  760. XFileList *r; /* global - pointer to the first element in the list 2 b sorted */
  761. X
  762. XFileList *merge(a,b)
  763. XFileList *a,*b;
  764. X{
  765. XFileList *temp;
  766. XFileList aux;
  767. X
  768. X  temp = &aux;
  769. X  while(b != NULL)
  770. X    if(a == NULL) { 
  771. X      a = b; 
  772. X      break;
  773. X    }
  774. X    else if(strcmp(b->fname,a->fname) > 0) {
  775. X      temp = temp->next = a; 
  776. X      a = a->next;
  777. X    } else {
  778. X      temp = temp->next = b;
  779. X      b = b->next;
  780. X    }
  781. X
  782. X  temp->next = a;
  783. Xreturn(aux.next);
  784. X}
  785. X
  786. XFileList *sort(n)
  787. Xint n;
  788. X{
  789. XFileList *fi,*la,*temp;
  790. X
  791. X  if(r == NULL) return(NULL);
  792. X  else if(n > 1)
  793. X    return(merge(sort(n/2),sort((n+1)/2)));
  794. X  else {
  795. X    fi = r;
  796. X    la = r;
  797. X    /* build list as long as possible */
  798. X    for(r = r->next; r != NULL;)
  799. X      if(strcmp(r->fname,la->fname) >= 0) {
  800. X        la->next = r;
  801. X        la = r;
  802. X        r = r->next;
  803. X      }
  804. X      else if(strcmp(r->fname,fi->fname) <= 0) {
  805. X        temp = r;
  806. X        r = r->next;
  807. X        temp->next = fi;
  808. X        fi = temp;
  809. X      }
  810. X      else break;
  811. X    
  812. X  la->next = NULL;
  813. X  return(fi);
  814. X  }
  815. X}
  816. X
  817. X
  818. X/*
  819. X** gets all the file names from the directory 'dir'
  820. X** and puts then into a FileList linked list.
  821. X*/
  822. XFileList *get_files(dir)
  823. Xchar *dir;
  824. X{
  825. XDIR *dirp;
  826. Xstruct dirent *dp;
  827. XFileList *start=NULL,*t;
  828. Xint count;
  829. X
  830. X  dirp = opendir(dir);
  831. X  for(dp = readdir(dirp),count = 1; dp != NULL; dp = readdir(dirp),count++) {
  832. X    if(start == NULL) {
  833. X      start = (FileList *) malloc(sizeof(FileList));
  834. X      t = start; t->next = NULL;
  835. X    } else {
  836. X      t->next = (FileList *) malloc(sizeof(FileList));
  837. X      t = t->next;
  838. X      t->next = NULL;
  839. X    }
  840. X    strcpy(t->fname,dp->d_name);
  841. X  }
  842. X  closedir(dirp);
  843. X  r = start;
  844. Xreturn(sort(count));
  845. X}
  846. X
  847. X
  848. END_OF_FILE
  849. if test 4951 -ne `wc -c <'misc.c'`; then
  850.     echo shar: \"'misc.c'\" unpacked with wrong size!
  851. fi
  852. # end of 'misc.c'
  853. fi
  854. if test -f 'patchlevel.h' -a "${1}" != "-c" ; then 
  855.   echo shar: Will not clobber existing file \"'patchlevel.h'\"
  856. else
  857. echo shar: Extracting \"'patchlevel.h'\" \(263 characters\)
  858. sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
  859. X/*
  860. X** this is reserved for official patches released by me (the author - 
  861. X** Ashley Roll). If you have a patch then please release it via me - you 
  862. X** will be credited with creating it. You can E-Mail me at:
  863. X** aroll@gucis.cit.gu.edu.au
  864. X*/
  865. X#define PATCHLEVEL ""
  866. X
  867. END_OF_FILE
  868. if test 263 -ne `wc -c <'patchlevel.h'`; then
  869.     echo shar: \"'patchlevel.h'\" unpacked with wrong size!
  870. fi
  871. # end of 'patchlevel.h'
  872. fi
  873. if test -f 'xbmbrowser.c' -a "${1}" != "-c" ; then 
  874.   echo shar: Will not clobber existing file \"'xbmbrowser.c'\"
  875. else
  876. echo shar: Extracting \"'xbmbrowser.c'\" \(9101 characters\)
  877. sed "s/^X//" >'xbmbrowser.c' <<'END_OF_FILE'
  878. Xchar copyright[]="xbmbrowser Version 1.0  (c) Copyright Ashley Roll, 1992.";
  879. X/*
  880. X*****************************************************************************
  881. X** xbmbrowser version 1.0  (c) Copyright Ashley Roll, 1992.
  882. X** FILE: xbmbrowser.c
  883. X**
  884. X** xbmbrowser is Public Domain. However it, and all the code still belong to me.
  885. X** I do, however grant permission for you to freely copy and distribute it on 
  886. X** the condition that this and all other copyright notices remain unchanged in 
  887. X** all distributions.
  888. X**
  889. X** This software comes with NO warranty whatsoever. I therefore take no
  890. X** responsibility for any damages, losses or problems that the program may 
  891. X** cause.
  892. X*****************************************************************************
  893. X*/
  894. X
  895. X#define MAIN
  896. X#include "xbmbrowser.h"
  897. X#include "patchlevel.h"
  898. X#include "icon.xbm"
  899. X
  900. X
  901. Xextern void DoQuit();
  902. Xextern void Ok();
  903. Xextern Widget MakeMenu();
  904. Xextern Widget AddMenuItem();
  905. Xextern void Show_Help();
  906. Xextern void Inform_User();
  907. Xextern void SetWindowIcon();
  908. Xextern void rename_bitmap();
  909. Xextern void move_bitmap();
  910. Xextern void copy_bitmap();
  911. Xextern void delete_bitmap();
  912. Xextern void edit_bitmap();
  913. Xextern void set_root();
  914. Xextern void set_root_inv();
  915. Xextern void set_name();
  916. Xextern void destroy_Callback();
  917. Xextern void rescan();
  918. Xextern FileList *get_files();
  919. Xextern void change_dir();
  920. Xextern void setup_dialog();
  921. X
  922. X/* -------------------------- */
  923. Xstatic Atom  wm_delete_window;      /* insure that delete window works */
  924. X
  925. Xstatic XtActionsRec  actions[] = {  /* declare possible actions */
  926. X/* action_name, routine */
  927. X  { "quit",   DoQuit  },
  928. X  { "CD", change_dir },
  929. X  { "Set_Name", set_name },
  930. X  { "Ok", Ok },
  931. X};
  932. X
  933. X/* translation table for label widgets for the bitmaps */
  934. Xstatic char Translations[] = 
  935. X  "<EnterWindow>:      Set_Name() \n\
  936. X   <BtnDown>:    XawPositionSimpleMenu(bitmapMenu) MenuPopup(bitmapMenu) \n\
  937. X   <BtnUp>:      MenuPopdown(bitmapMenu)";
  938. X
  939. X/* translation table for the dialogWidget (directory name) */
  940. Xstatic char text_trans[] = 
  941. X  "<Key>Return:  CD() \n\
  942. X   Ctrl<Key>M:   CD() ";
  943. X
  944. X/* fallback resources  */
  945. Xstatic char *fall_back[] = {
  946. X   ".xbmbrowser.width: 450", 
  947. X   ".xbmbrowser.height: 500", 
  948. X   ".xbmbrowser.iconName: browser",
  949. X   ".xbmbrowser.?.TransientShell.width: 350",
  950. X   ".xbmbrowser.main.buttons.Command.width: 70",
  951. X   NULL
  952. X}; 
  953. X
  954. X/* -------------------------- */
  955. X
  956. X/*
  957. X** this creates all the menubuttons that contain the bitmaps
  958. X*/
  959. Xvoid fill_bw()
  960. X{
  961. XFileList *x;
  962. XWidget w;
  963. Xchar b_name[255];
  964. XPixmap bitmap = NULL;
  965. Xint show = TRUE;
  966. X
  967. X    /* create a menu */
  968. X    menu = MakeMenu(bw,"bitmapMenu",NULL);
  969. X
  970. X    /* fill the menu */
  971. X  (void) AddMenuItem(menu,"Rename",rename_bitmap,NULL,show);
  972. X  (void) AddMenuItem(menu,"Copy",copy_bitmap,NULL,show);
  973. X  (void) AddMenuItem(menu,"Delete",delete_bitmap,NULL,show);
  974. X  if(EDITOR[0] == '\0')
  975. X    show = FALSE;
  976. X  (void) AddMenuItem(menu,"Edit",edit_bitmap,NULL,show);
  977. X
  978. X  show = TRUE;
  979. X  if(SETROOT[0] == '\0')
  980. X    show = FALSE;
  981. X  (void) AddMenuItem(menu,"SetRoot",set_root,NULL,show);
  982. X  show = TRUE;
  983. X  if(SETROOTINV[0] == '\0')
  984. X    show = FALSE;
  985. X  (void) AddMenuItem(menu,"SetRoot Inv",set_root_inv,NULL,show);
  986. X
  987. X
  988. X  for(x = file_list; x != NULL; x = x->next)
  989. X  {
  990. X  int t;  
  991. X  char *name;
  992. X
  993. X    name = x->fname; 
  994. X    if(XReadBitmapFile(XtDisplay(toplevel),
  995. X       DefaultRootWindow(XtDisplay(toplevel)),name,
  996. X       &t,&t,&bitmap,&t,&t) == BitmapSuccess) {
  997. X
  998. X
  999. X      /* create the menuButton for it */
  1000. X      w = XtVaCreateManagedWidget(name,labelWidgetClass,bw,
  1001. X             XtNbitmap,(XtArgVal)bitmap,
  1002. X             NULL);
  1003. X
  1004. X      XtOverrideTranslations(w,XtParseTranslationTable(Translations));
  1005. X      XtAddCallback(w,"destroyCallback",destroy_Callback,(XtPointer)bitmap);
  1006. X    }
  1007. X  }
  1008. X}
  1009. X
  1010. Xmain(argc, argv)
  1011. X  int argc;
  1012. X  char **argv;
  1013. X{
  1014. XXtAppContext appcon;
  1015. Xchar wname[100];
  1016. X
  1017. Xac = argc;
  1018. Xav = argv;
  1019. Xbw = NULL;
  1020. Xbname = NULL;
  1021. Xdialogs_made = FALSE;
  1022. Xfile_list = NULL;
  1023. X
  1024. X
  1025. X  sprintf(wname,"XbmBrowser Version 1.0 %s",PATCHLEVEL);
  1026. X  toplevel = XtVaAppInitialize(
  1027. X                 &appcon, "XbmBrowser",    /* app context, ClassName */
  1028. X                 NULL, 0,                  /* app command line options */
  1029. X                 &argc, argv,              /* command line */
  1030. X                 fall_back,                /* Fall back resources */
  1031. X                 XtNtitle,(XtArgVal)wname,
  1032. X                 NULL);                    /* End Va resource list */
  1033. X  XtAppAddActions(appcon, actions, XtNumber(actions));
  1034. X
  1035. X  if( argc > 2 )  useage();
  1036. X  if(argc == 2) {
  1037. X    if(chdir(argv[1]) != 0) {
  1038. X      fprintf(stderr,"xbmbrowser: couldn't chdir to '%s'\n",argv[1]);
  1039. X      exit(0);
  1040. X    }
  1041. X  }
  1042. X
  1043. X  (void) getcwd(dname,253);
  1044. X/* create a paned widget to put everything into */
  1045. X  mainpw  = XtVaCreateManagedWidget("main",panedWidgetClass,toplevel,
  1046. X            NULL);
  1047. X
  1048. X/* create the form widget to put the buttons in */
  1049. X  bfw = XtVaCreateManagedWidget("buttons",formWidgetClass,mainpw,
  1050. X              XtNshowGrip,(XtArgVal)False,
  1051. X              XtNskipAdjust,(XtArgVal)True,NULL);
  1052. X
  1053. X{
  1054. XWidget button;
  1055. X/* create the Buttons */
  1056. X  button = XtVaCreateManagedWidget("quit",commandWidgetClass,bfw,
  1057. X                  XtNlabel,(XtArgVal)"Quit",NULL);
  1058. X  XtAddCallback(button,"callback",DoQuit,NULL);
  1059. X  button = XtVaCreateManagedWidget("help",commandWidgetClass,bfw,
  1060. X                  XtNfromHoriz,(XtArgVal)button,
  1061. X                  XtNlabel,(XtArgVal)"Help",NULL);
  1062. X  XtAddCallback(button,"callback",Show_Help,NULL);
  1063. X  button = XtVaCreateManagedWidget("rescan",commandWidgetClass,bfw,
  1064. X                  XtNfromHoriz,(XtArgVal)button,
  1065. X                  XtNlabel,(XtArgVal)"Rescan",NULL);
  1066. X  XtAddCallback(button,"callback",rescan,NULL);
  1067. X}
  1068. X/* dialogWidget to hold and get the directory to read from */
  1069. X
  1070. X  atw = XtVaCreateManagedWidget("directory", dialogWidgetClass, mainpw,
  1071. X           XtNlabel,(XtArgVal)"Current Directory",
  1072. X           XtNvalue,(XtArgVal)dname,
  1073. X           XtNshowGrip,(XtArgVal)False,
  1074. X           XtNskipAdjust,(XtArgVal)True,
  1075. X           NULL);
  1076. X
  1077. X  XtOverrideTranslations(XtNameToWidget(atw,"value"),
  1078. X                         XtParseTranslationTable(text_trans));
  1079. X
  1080. X/* label widget to hold the name of the current bitmap */
  1081. X  lw = XtVaCreateManagedWidget("label",labelWidgetClass,mainpw,
  1082. X                  XtNlabel,(XtArgVal)"No Bitmap Selected",
  1083. X                  XtNshowGrip,(XtArgVal)False,
  1084. X                  XtNskipAdjust,(XtArgVal)True,NULL);
  1085. X
  1086. X/* create a viewport widget to stick the bitmaps in */
  1087. X{
  1088. Xint width;
  1089. X
  1090. X  XtVaGetValues(toplevel,XtNwidth,&width,NULL);
  1091. X
  1092. X  phw = XtVaCreateManagedWidget("viewport",viewportWidgetClass,mainpw,
  1093. X                  XtNwidth,(XtArgVal)width,
  1094. X                  XtNallowHoriz,(XtArgVal)False,
  1095. X                  XtNallowVert,(XtArgVal)True,
  1096. X                  XtNshowGrip,(XtArgVal)False,
  1097. X                  XtNskipAdjust,(XtArgVal)True,NULL);
  1098. X}
  1099. X setup();
  1100. X XtRealizeWidget(toplevel);
  1101. X
  1102. X/* set up the icon */
  1103. X{
  1104. XPixmap  icon;
  1105. XXWMHints *wmhints;
  1106. XDisplay *display;
  1107. XWindow  window;
  1108. X
  1109. X   display = XtDisplay(toplevel);
  1110. X   window = XtWindow(toplevel);
  1111. X
  1112. X   wmhints = XGetWMHints( display, window );
  1113. X
  1114. X   if ( wmhints == (XWMHints *) NULL )
  1115. X   {
  1116. X      wmhints = (XWMHints *) malloc( sizeof(XWMHints) );
  1117. X      if ( wmhints == (XWMHints *) NULL )
  1118. X
  1119. X      wmhints->flags = 0;
  1120. X   }
  1121. X
  1122. X   icon = XCreateBitmapFromData(display,DefaultRootWindow(display),
  1123. X               icon_bits, icon_width, icon_height);
  1124. X
  1125. X   wmhints->flags |= IconPixmapHint;
  1126. X
  1127. X   wmhints->icon_pixmap = icon;
  1128. X
  1129. X   XSetWMHints( display, window, wmhints );
  1130. X
  1131. X   XFree( wmhints );
  1132. X}
  1133. X
  1134. X
  1135. X  /* Set the window to call quit() action if `deleted' */
  1136. X  XtOverrideTranslations(toplevel,     
  1137. X          XtParseTranslationTable("<Message>WM_PROTOCOLS:quit()") );
  1138. X  wm_delete_window = XInternAtom(XtDisplay(toplevel),"WM_DELETE_WINDOW",False);
  1139. X  (void) XSetWMProtocols(XtDisplay(toplevel), XtWindow(toplevel),
  1140. X                                                 &wm_delete_window, 1);
  1141. X  XtAppMainLoop(appcon);
  1142. Xexit(0);
  1143. X}
  1144. X
  1145. X/*
  1146. X** this (re)initializes the boxWidget that contains the menubuttons
  1147. X** by calling the fillbw() function
  1148. X*/
  1149. Xsetup()
  1150. X{
  1151. Xint width,fore,back,depth;
  1152. X
  1153. X  if(bw != NULL)
  1154. X    XtDestroyWidget(bw);
  1155. X
  1156. X  XtVaGetValues(toplevel,XtNwidth,&width,NULL);
  1157. X  XtVaSetValues(lw,XtNlabel,(XtArgVal)"No Bitmap Selected",NULL);
  1158. X/* create the box widget to put all the bitmaps in */
  1159. X  bw = XtVaCreateManagedWidget("bitmaps",boxWidgetClass,phw,
  1160. X                  XtNwidth,width,
  1161. X                  XtNorientation,(XtArgVal)XtorientVertical,
  1162. X                  XtNfromVert,(XtArgVal)lw,
  1163. X                  NULL);
  1164. X
  1165. X  XtVaGetValues(bw, XtNborderColor, &fore,
  1166. X                    XtNbackground,  &back,
  1167. X                    XtNdepth,       &depth, NULL);
  1168. X
  1169. X  XtVaSetValues(bw, XtNbackgroundPixmap,
  1170. X        (XtArgVal)XmuCreateStippledPixmap(XtScreen(phw), fore, back, depth),
  1171. X                  NULL);
  1172. X
  1173. X/* create all the bitmaps (each in a menubutton) */
  1174. X  while(file_list != NULL) {
  1175. X    FileList *t;
  1176. X    t = file_list->next;
  1177. X    free(file_list);
  1178. X    file_list = t;
  1179. X  }
  1180. X  file_list = get_files(".");
  1181. X  fill_bw();
  1182. X}
  1183. X
  1184. X
  1185. Xuseage()
  1186. X{
  1187. Xfprintf(stderr,"\nxbmbrowser: Useage: \nxbmbrowser [toolkit options] [<Dir>]\n");
  1188. Xfprintf(stderr,"\nWhere <Dir> is a directory name. \n");
  1189. Xexit(1);
  1190. X}
  1191. X
  1192. END_OF_FILE
  1193. if test 9101 -ne `wc -c <'xbmbrowser.c'`; then
  1194.     echo shar: \"'xbmbrowser.c'\" unpacked with wrong size!
  1195. fi
  1196. # end of 'xbmbrowser.c'
  1197. fi
  1198. if test -f 'xbmbrowser.h' -a "${1}" != "-c" ; then 
  1199.   echo shar: Will not clobber existing file \"'xbmbrowser.h'\"
  1200. else
  1201. echo shar: Extracting \"'xbmbrowser.h'\" \(2579 characters\)
  1202. sed "s/^X//" >'xbmbrowser.h' <<'END_OF_FILE'
  1203. X/*
  1204. X*****************************************************************************
  1205. X** xbmbrowser version 1.0  (c) Copyright Ashley Roll, 1992.
  1206. X** FILE: xbmbrowser.h 
  1207. X**
  1208. X** xbmbrowser is Public Domain. However it, and all the code still belong to me.
  1209. X** I do, however grant permission for you to freely copy and distribute it on 
  1210. X** the condition that this and all other copyright notices remain unchanged in 
  1211. X** all distributions.
  1212. X**
  1213. X** This software comes with NO warranty whatsoever. I therefore take no
  1214. X** responsibility for any damages, losses or problems that the program may 
  1215. X** cause.
  1216. X*****************************************************************************
  1217. X*/
  1218. X
  1219. X#include <X11/Xlib.h>  /* Xt programming includes */
  1220. X#include <X11/Xutil.h>
  1221. X#include <X11/Xatom.h>
  1222. X
  1223. X#include <stdio.h>
  1224. X#include <strings.h>
  1225. X#include <dirent.h> 
  1226. X#include <X11/cursorfont.h>
  1227. X#include <X11/Intrinsic.h>      
  1228. X#include <X11/StringDefs.h>
  1229. X
  1230. X#include <X11/Xaw/Form.h>      /* widget includes */
  1231. X#include <X11/Xaw/Box.h>
  1232. X#include <X11/Xaw/Dialog.h> 
  1233. X#include <X11/Xaw/MenuButton.h>
  1234. X#include <X11/Xaw/SimpleMenu.h>
  1235. X#include <X11/Xaw/SmeBSB.h>
  1236. X#include <X11/Xaw/SmeLine.h>
  1237. X#include <X11/Xaw/AsciiText.h>
  1238. X#include <X11/Xaw/Paned.h>
  1239. X#include <X11/Xaw/Viewport.h>
  1240. X
  1241. X
  1242. X/***************************************************************************
  1243. X    SITE SPECIFIC STUFF - EDIT TO MATCH YOUR SETUP
  1244. X ***************************************************************************/
  1245. X/*
  1246. X** The full path to the Help file.
  1247. X*/
  1248. X#ifndef HELPFILE
  1249. X#define HELPFILE "/usr/lib/X11/xbmbrowser.help"
  1250. X#endif
  1251. X
  1252. X/*
  1253. X** the editor that will be called from the Edit selection of the 
  1254. X** Menu. If this is NULL ("") then the selection will not be selectable.
  1255. X** A system() call will be made with this string with the filename of the 
  1256. X** selected bitmap, and an & appended to it.
  1257. X*/
  1258. X#define EDITOR "bitmap"
  1259. X
  1260. X/*
  1261. X** This is the program that can be used to set the bitmap as the root
  1262. X** window decoration. the same things apply as above in EDITOR.
  1263. X*/
  1264. X#define SETROOT "xsetroot -bitmap"
  1265. X#define SETROOTINV "xsetroot -rv -bitmap"
  1266. X
  1267. X
  1268. X
  1269. X/***************************************************************************
  1270. X    PROGRAM STUFF - CHANGE IT AT YOUR OWN RISK
  1271. X ***************************************************************************/
  1272. X
  1273. Xtypedef struct _file_lst {
  1274. X  char fname[255];
  1275. X  struct _file_lst *next;
  1276. X} FileList;
  1277. X
  1278. X#ifdef MAIN
  1279. X#define ext
  1280. X#else
  1281. X#define ext extern
  1282. X#endif
  1283. X
  1284. Xext char *bname;
  1285. Xext char dname[255];
  1286. Xext FileList *file_list;
  1287. Xext Widget toplevel,mainpw,bfw,bw,lw,phw,atw,menu;
  1288. Xext int ac;
  1289. Xext char **av;
  1290. Xext int dialogs_made;
  1291. END_OF_FILE
  1292. if test 2579 -ne `wc -c <'xbmbrowser.h'`; then
  1293.     echo shar: \"'xbmbrowser.h'\" unpacked with wrong size!
  1294. fi
  1295. # end of 'xbmbrowser.h'
  1296. fi
  1297. if test -f 'xbmbrowser.help' -a "${1}" != "-c" ; then 
  1298.   echo shar: Will not clobber existing file \"'xbmbrowser.help'\"
  1299. else
  1300. echo shar: Extracting \"'xbmbrowser.help'\" \(4063 characters\)
  1301. sed "s/^X//" >'xbmbrowser.help' <<'END_OF_FILE'
  1302. XHelp For xbmbrowser, By Ashley Roll                                 Version 1.0
  1303. X
  1304. Xxbmbrowser is a program to let you easily manipulate Bitmap files.
  1305. X
  1306. XAs you can see (on the window that you called this from), the window is 
  1307. Xdivided into four areas, one with the three buttons, the next contains a text
  1308. Xbox that contains the current directory, you can use this to change the
  1309. Xdirectory that is searched for bitmaps. The next one down contains the
  1310. Xname of the last selected Bitmap, and the last contains any Bitmap files
  1311. Xthat the program found from the command line arguments. 
  1312. X
  1313. XThe fourth section is the most important. If you press and hold mouse button
  1314. Xthree down over one of the Bitmap images, then a small menu will popup with
  1315. Xthe following items:
  1316. X
  1317. X Rename -  Use this to rename / move a Bitmap, you will get a requester asking
  1318. X           for the new name, once you have typed the new name click on the 
  1319. X           [Ok] button, or [Cancel] to cancel the rename.
  1320. X
  1321. X Copy -    Use this to copy a Bitmap, you will get a requester asking for the
  1322. X           name to copy to, once you have typed the new name click on the
  1323. X           [Ok] button, or [Cancel] to cancel the copy.
  1324. X
  1325. X Delete -  Use this to Delete a Bitmap, USE WITH CAUTION!!!, you will get a 
  1326. X           requester asking if you wish to delete the Bitmap or not, click on
  1327. X           the [Ok] button and the Bitmap will be removed, or [Cancel] to 
  1328. X           cancel the Delete.
  1329. X
  1330. X Edit -    This will fire up a copy of your local Bitmap editor to edit the
  1331. X           selected Bitmap. (If this is not selectable, then you can not 
  1332. X           do this - ask your system admin to fix it if you REALY want to use
  1333. X           this feature).
  1334. X
  1335. X SetRoot - This will fire up a copy of the program to set the bitmap as the
  1336. X           root window decoration.
  1337. X
  1338. X SetRoot Inv - Same as SetRoot, except that the bitmap is inverted (black = 
  1339. X               white, etc).
  1340. X
  1341. XIf all the Bitmaps cannot fit into the bottom window, or you resize the 
  1342. Xwindow, a scroll bar will appear vertically on the left side of this section
  1343. Xand you can use this to see the hidden Bitmaps.
  1344. X
  1345. XYou can (of course) quit the program by pressing the [Quit] button. The 
  1346. X[Rescan] button will rescan all the bitmaps in the current directory (as 
  1347. Xindicated by the text box), redrawing them, this can be used after you have
  1348. Xedited a bitmap to show what it now looks like.
  1349. X
  1350. XChanging Directories:
  1351. X
  1352. XAll that you have to do to change the current directory that the program 
  1353. Xsearches, so to type the name of the new directory in the text box, and then 
  1354. Xpress <Return>. If the directory doesn't exist or you can't access it, then 
  1355. Xthe directory will remain unchanged. 
  1356. X
  1357. XNOTE: you can use '.' and '..' and '~' in your path as the program changes 
  1358. Xdirectory relative to the current directory, also note that the window will 
  1359. Xalways contain the FULL path of the current directory.
  1360. X
  1361. XCommand line arguments:
  1362. X
  1363. Xxbmbrowser [Toolkit Options] [Directory]
  1364. X
  1365. XToolkit Options are normal Athena Widget set options like '-geometry'.
  1366. X
  1367. XDirectory is a directory that you wish to look at. If it doesn't exit or
  1368. Xyou can't access it, then the program will default to the current directory.
  1369. X
  1370. X******************************************************************************
  1371. X** (c) Copyright Ashley Roll, 1992.
  1372. X** xbmbrowser is Public Domain. However it, and all the code still belong to me.
  1373. X** I do, however grant permission for you to freely copy and distribute it on 
  1374. X** the condition that this and all other copyright notices remain unchanged in 
  1375. X** all distributions.
  1376. X**
  1377. X** This software comes with NO warranty whatsoever. I therefore take no
  1378. X** responsibility for any damages, losses or problems that the program may
  1379. X** cause.
  1380. X******************************************************************************
  1381. X
  1382. XI must thank Anthony Thyssen for beta testing XbmBrowser and comming up with
  1383. Xthe original idea for it.
  1384. X
  1385. XI must also thank Chris McDonald of the University of Western Australia's 
  1386. XDepartment of Computer Science, who provided me with a procedure to expand
  1387. X~'s in a directory name.
  1388. END_OF_FILE
  1389. if test 4063 -ne `wc -c <'xbmbrowser.help'`; then
  1390.     echo shar: \"'xbmbrowser.help'\" unpacked with wrong size!
  1391. fi
  1392. # end of 'xbmbrowser.help'
  1393. fi
  1394. if test -f 'xbmbrowser.man' -a "${1}" != "-c" ; then 
  1395.   echo shar: Will not clobber existing file \"'xbmbrowser.man'\"
  1396. else
  1397. echo shar: Extracting \"'xbmbrowser.man'\" \(890 characters\)
  1398. sed "s/^X//" >'xbmbrowser.man' <<'END_OF_FILE'
  1399. X.TH XBMBROWSER 1 "23 July 1992"
  1400. X.SH NAME
  1401. Xxbmbrowser \- view and manage bitmap files.
  1402. X.SH SYNOPSIS
  1403. X.B xbmbrowser
  1404. X[
  1405. X.I toolkit options
  1406. X]
  1407. X[
  1408. X.I directory
  1409. X]
  1410. X.SH DESCRIPTION
  1411. X.LP
  1412. X.B xbmbrowser 
  1413. Xwill show you all the bitmaps in the 
  1414. X.I directory
  1415. Xif it is specified otherwise it will look in the current directory.
  1416. XNote that if the program can not change directory to the 
  1417. X.I directory
  1418. Xin the command line it will exit and print an error message.
  1419. X
  1420. XYou can then select any bitmap that is displayed and you will be able to 
  1421. XRename, Copy, Delete, Edit and Set it as the root window bitmap. (Edit and SetRoot may not work on your installation \- you will have to try it to find out).
  1422. X
  1423. X.B xbmbrowser
  1424. Xwill take all the normal Athena Widget 
  1425. X.I toolkit options
  1426. Xit is given. 
  1427. X
  1428. XFor instructions on how to use it, start it and press the
  1429. X.I Help
  1430. XButton.
  1431. X.SH AUTHOR
  1432. X.B Ashley Roll
  1433. X-- aroll@gucis.cit.gu.edu.au
  1434. X
  1435. END_OF_FILE
  1436. if test 890 -ne `wc -c <'xbmbrowser.man'`; then
  1437.     echo shar: \"'xbmbrowser.man'\" unpacked with wrong size!
  1438. fi
  1439. # end of 'xbmbrowser.man'
  1440. fi
  1441. echo shar: End of shell archive.
  1442. exit 0
  1443. -----------8<-----------8<-----------8<-----------8<-----------8<-----------
  1444.  
  1445.  
  1446. -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  1447.   Ashley Roll - aroll@gucis.cit.gu.edu.au   Griffith University, Australia
  1448. -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  1449.      Kernal PANIC: Unable to mount /dev/coffie.machine -- Operator Halted.
  1450.  
  1451.                         - - - - - - - - - - - - - -
  1452.   The thoughts, ideas and opinions expressed herein are my own and as such  
  1453.     are completly correct, I will however respect your right to be wrong. 
  1454. -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  1455. exit 0 # Just in case...
  1456. -- 
  1457.   // chris@IMD.Sterling.COM            | Send comp.sources.x submissions to:
  1458. \X/  Amiga - The only way to fly!      |
  1459.  "It's intuitively obvious to the most |    sources-x@imd.sterling.com
  1460.   casual observer..."                  |
  1461.