Path: utzoo!utgpu!watserv1!watmath!att!emory!wuarchive!julius.cs.uiuc.edu!apple!sun-barr!newstop!exodus!appserv!uunet.UU.NET From: kddlab!isl.yamaha.co.jp!shutoh@uunet.UU.NET (Kazuhiko Shutoh) Newsgroups: comp.sources.x Subject: v10i090: xpbiff -- xbiff with popups, Patch1, Part01/01 Message-ID: <333@appserv.Eng.Sun.COM> Date: 1 Dec 90 08:23:09 GMT References: Sender: news@exodus.Eng.Sun.COM Lines: 685 Approved: argv@sun.com Submitted-by: kddlab!isl.yamaha.co.jp!shutoh@uunet.UU.NET (Kazuhiko Shutoh) Posting-number: Volume 10, Issue 90 Archive-name: xpbiff/patch1 Patch-To: xpbiff: Volume 10, Issue 1 #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'xpbiff.patch1.comp' <<'END_OF_FILE' Xdiff -rc old.comp/README new.comp/README X*** old.comp/README Sat Dec 1 10:33:34 1990 X--- new.comp/README Sat Dec 1 10:43:06 1990 X*************** X*** 3,9 **** X--- 3,11 ---- X X xpbiff X X+ Popup biff for X, including show mail headers. X X+ X * Command line options X X Usage : xpbiff [Toolkit-Options][-nfg noarrive_bitmap_foreground color] X*************** X*** 52,57 **** X--- 54,63 ---- X -patchlevel : X Show current patchlevel and source code version. X X+ * Adding feature: X+ X+ Keep top window stack option added(-keep). X+ Click mailbox window, redisplay mail header popup. X X * Compile X X*************** X*** 75,102 **** X Send any comments, bug reports, etc. to: shutoh@isl.yamaha.co.jp or, X for oversea: shutoh%isl.yamaha.co.jp%kddlab@uunet.uu.net X X! * Special Thanks to: X X! Test : X! X! Shingo Kawasaki(YAMAHA/ISL) X! X! Bug report & fix suggestion : X! X! Hidetsugu Nakashio X! hkato@krc.sony.co.jp (Hiroshi KATO) X! hotta@asimov.soft.flab.fujitsu.co.jp X! ikawa@onion.osaka.jip.co.jp (Ikawa Hiroki) X! makimura@agusa.nuee.nagoya-u.ac.jp (Ken Makimura) X! murase@ctf5.drl.mei.co.jp X! nishida@phantom.src.ricoh.co.jp (Akihiro Nishida) X! X! Thanks a lot!!!!!!! X! X -- X Kazuhiko Shutoh X InSoft System Lab. X YAMAHA Corp. X shutoh@isl.yamama.co.jp X X X--- 81,121 ---- X Send any comments, bug reports, etc. to: shutoh@isl.yamaha.co.jp or, X for oversea: shutoh%isl.yamaha.co.jp%kddlab@uunet.uu.net X X! * Special Thanks to comment, bug fix, testing: X X! Michael Glad X! Andrew Krzywdzinski X! Andy Malis X! Bob Primmer X! Chris Garrigues <7thSon@SLCS.SLB.COM> X! David Asano X! Felix Ingrand X! Hidetsugu Nakashio X! Ken Nelson X! Luis Miguel Silveira X! Peter Jackson X! Robert Lupton (the Good) X! Steven Reiz X! Sting Takubon TAKEUCHI X! chiba@is.s.u-tokyo.ac.jp (Chiba) X! hkato@krc.sony.co.jp (Hiroshi KATO) X! hotta@flab.fujitsu.co.jp (Yuji Hotta) X! imp@Solbourne.COM (Warner Losh) X! jgraf@smdgr1.intel.com (Jim Graf ) X! lindheim@sampson.ccsf.caltech.edu (Jan Lindheim) X! lusk@antares.mcs.anl.gov (Rusty Lusk) X! masuhara@is.s.u-tokyo.ac.jp X! murase@ctf5.drl.mei.co.jp (Kouichi Murase) X! nishida@phantom.src.ricoh.co.jp (Akihiro Nishida) X! rekers@cwi.nl (Jan Rekers) X! remy@cs.uoregon.edu (Remy Evard) X! vita@oxford.dab.ge.com (Mark Vita) X! X -- X Kazuhiko Shutoh X InSoft System Lab. X YAMAHA Corp. X shutoh@isl.yamama.co.jp X+ X X Xdiff -rc old.comp/patchlevel.h new.comp/patchlevel.h X*** old.comp/patchlevel.h Sat Dec 1 10:33:35 1990 X--- new.comp/patchlevel.h Sat Dec 1 10:38:57 1990 X*************** X*** 1,4 **** X X! #define PATCHLEVEL 0 X X X--- 1,5 ---- X X! #define PATCHLEVEL 1 X! X X Xdiff -rc old.comp/xpbiff.c new.comp/xpbiff.c X*** old.comp/xpbiff.c Sat Dec 1 10:33:36 1990 X--- new.comp/xpbiff.c Sat Dec 1 10:38:44 1990 X*************** X*** 1,11 **** X X! static char sccsid[] = "@(#)xpbiff.c 1.15 10/18/90"; X X /* X * xpbiff - popup biff for X X * X * Author: Kazuhiko Shutoh, 1990. X! * X * Permission to use, copy, modify and distribute without charge this software, X * documentation, images, etc. is granted, provided that this comment and the X * author's name is retained. The author assumes no responsibility for lost X--- 1,45 ---- X X! static char sccsid[] = "@(#)xpbiff.c 1.18 12/1/90"; X X /* X * xpbiff - popup biff for X X * X * Author: Kazuhiko Shutoh, 1990. X! * X! * Special thanks for comment, bug fix, testing to: X! * X! * Michael Glad X! * Andrew Krzywdzinski X! * Andy Malis X! * Bob Primmer X! * Chris Garrigues <7thSon@SLCS.SLB.COM> X! * David Asano X! * Felix Ingrand X! * Hidetsugu Nakashio X! * Ken Nelson X! * Luis Miguel Silveira X! * Peter Jackson X! * Robert Lupton (the Good) X! * Steven Reiz X! * Sting Takubon TAKEUCHI X! * chiba@is.s.u-tokyo.ac.jp (Chiba) X! * hkato@krc.sony.co.jp (Hiroshi KATO) X! * hotta@flab.fujitsu.co.jp (Yuji Hotta) X! * imp@Solbourne.COM (Warner Losh) X! * jgraf@smdgr1.intel.com (Jim Graf ) X! * lindheim@sampson.ccsf.caltech.edu (Jan Lindheim) X! * lusk@antares.mcs.anl.gov (Rusty Lusk) X! * masuhara@is.s.u-tokyo.ac.jp X! * murase@ctf5.drl.mei.co.jp (Kouichi Murase) X! * nishida@phantom.src.ricoh.co.jp (Akihiro Nishida) X! * rekers@cwi.nl (Jan Rekers) X! * remy@cs.uoregon.edu (Remy Evard) X! * vita@oxford.dab.ge.com (Mark Vita) X! * X! * X! * THANKS A LOT!!!! X! * X! * X * Permission to use, copy, modify and distribute without charge this software, X * documentation, images, etc. is granted, provided that this comment and the X * author's name is retained. The author assumes no responsibility for lost X*************** X*** 19,29 **** X--- 53,72 ---- X #include X #include X #include X+ #ifndef X11R3 X #include X #include X #include X #include X #include X+ #include X+ #else X+ #include X+ #include X+ #include X+ #include X+ #include X+ #endif X #include X #include X #include X*************** X*** 48,61 **** X X XtCallbackProc redraw_callback(); X XtCallbackProc BreakPopup(); X XtTimerCallbackProc Polling(); X char *GetMailHeader(); X void PopupMailHeader(); X void AnimateBiff(); X X- X Widget toplevel, biff, header, info_base, info, popdown_button; X X /* X * widget tree: X * X--- 91,105 ---- X X XtCallbackProc redraw_callback(); X XtCallbackProc BreakPopup(); X+ XtCallbackProc popup_again(); X XtTimerCallbackProc Polling(); X char *GetMailHeader(); X void PopupMailHeader(); X void AnimateBiff(); X X Widget toplevel, biff, header, info_base, info, popdown_button; X X+ X /* X * widget tree: X * X*************** X*** 68,73 **** X--- 112,120 ---- X Pixmap arrivePixmap, noPixmap, workPixmap; X int width, height; X unsigned char current_status; X+ unsigned char showing_header = 0; X+ long mail_size = 0; X+ XtIntervalId polling_id; X X String colors[4] = {"dummy_colorname", "dummy_colorname", "dummy_colorname", "dummy_colorname"}; X char spool_path[100]; X*************** X*** 74,84 **** X--- 121,134 ---- X unsigned long polling_time = 15000; /* Default 15 second */ X X unsigned char raise = True; X+ unsigned char stay_raised = False; X unsigned char animate = True; X unsigned char popup = True; X unsigned char bell = True; X unsigned char popdown = True; X X+ unsigned int no_bitmap_width, no_bitmap_height; X+ X main(argc, argv) X int argc; X char **argv; X*************** X*** 88,100 **** X XtTranslations newTranslations; X static XtActionsRec redrawActions[] = { X {"expose", (XtCallbackProc) redraw_callback}, X }; X X static char *overrideTranslations = X ": expose() \n\ X! : expose()"; X X XColor backColor, foreColor, dummyColor; X X int i; X int count; X--- 138,153 ---- X XtTranslations newTranslations; X static XtActionsRec redrawActions[] = { X {"expose", (XtCallbackProc) redraw_callback}, X+ {"select", (XtCallbackProc) popup_again}, X }; X X static char *overrideTranslations = X ": expose() \n\ X! : expose() \n\ X! : select()"; X X XColor backColor, foreColor, dummyColor; X+ char *no_arrival_bitmap_file; X X int i; X int count; X*************** X*** 114,119 **** X--- 167,173 ---- X X toplevel = XtInitialize("xpbiff", "XPbiff", NULL, 0, &argc, argv); X X+ no_arrival_bitmap_file = NULL; X for (count = 1; count < argc; count++) { X if ((strcmp("-nfg", argv[count]) == 0) && (count + 1 <= argc)) X strcpy(colors[0], argv[++count]); X*************** X*** 127,132 **** X--- 181,188 ---- X polling_time = (unsigned long) atol(argv[++count]); X else if ((strcmp("-noraise", argv[count]) == 0) && (count + 1 <= argc)) X raise = False; X+ else if ((strcmp("-keepup", argv[count]) == 0) && (count + 1 <= argc)) X+ stay_raised = True; X else if ((strcmp("-nopopup", argv[count]) == 0) && (count + 1 <= argc)) X popup = False; X else if ((strcmp("-noanimate", argv[count]) == 0) && (count + 1 <= argc)) X*************** X*** 142,153 **** X strcpy(colors[3], "black"); X } else if ((strcmp("-patchlevel", argv[count]) == 0) && (count + 1 <= argc)) { X printf("xpbiff - written by Kazuhiko Shutoh\nSCCS ID : %s\nPatchlevel : %d\n", sccsid, PATCHLEVEL); X exit(0); X } else { X fprintf(stderr, "Usage : xpbiff [Toolkit-Options][-nfg noarrive_bitmap_foreground color]\n"); X fprintf(stderr, " [-nbg noarrive_bitmap_background_color][-afg arrive_bitmap_foreground_color]\n"); X fprintf(stderr, " [-abg arrive_bitmap_background_color][-polling_time time(msec)]\n"); X! fprintf(stderr, " [-noraise][-nopopup][-noanimate][-nopopdown][-nobell][-mono][-patchlevel]\n"); X exit(0); X } X } X--- 198,239 ---- X strcpy(colors[3], "black"); X } else if ((strcmp("-patchlevel", argv[count]) == 0) && (count + 1 <= argc)) { X printf("xpbiff - written by Kazuhiko Shutoh\nSCCS ID : %s\nPatchlevel : %d\n", sccsid, PATCHLEVEL); X+ printf("\nSpecial thanks to:\n\ X+ Michael Glad \n\ X+ Andrew Krzywdzinski \n\ X+ Andy Malis \n\ X+ Bob Primmer \n\ X+ Chris Garrigues <7thSon@SLCS.SLB.COM>\n\ X+ David Asano \n\ X+ Felix Ingrand \n\ X+ Hidetsugu Nakashio \n\ X+ Ken Nelson \n\ X+ Luis Miguel Silveira \n\ X+ Peter Jackson \n\ X+ Robert Lupton (the Good) \n\ X+ Steven Reiz \n\ X+ Sting Takubon TAKEUCHI \n\ X+ chiba@is.s.u-tokyo.ac.jp (Chiba)\n\ X+ hkato@krc.sony.co.jp (Hiroshi KATO)\n\ X+ hotta@flab.fujitsu.co.jp (Yuji Hotta)\n\ X+ imp@Solbourne.COM (Warner Losh)\n\ X+ jgraf@smdgr1.intel.com (Jim Graf )\n\ X+ lindheim@sampson.ccsf.caltech.edu (Jan Lindheim)\n\ X+ lusk@antares.mcs.anl.gov (Rusty Lusk)\n\ X+ masuhara@is.s.u-tokyo.ac.jp\n\ X+ murase@ctf5.drl.mei.co.jp (Kouichi Murase)\n\ X+ nishida@phantom.src.ricoh.co.jp (Akihiro Nishida) \n\ X+ rekers@cwi.nl (Jan Rekers)\n\ X+ remy@cs.uoregon.edu (Remy Evard)\n\ X+ vita@oxford.dab.ge.com (Mark Vita)\n"); X exit(0); X+ } else if ((strcmp("-bitmap", argv[count]) == 0) && (count + 1 <= argc)) { X+ no_arrival_bitmap_file = argv[++count]; X } else { X fprintf(stderr, "Usage : xpbiff [Toolkit-Options][-nfg noarrive_bitmap_foreground color]\n"); X fprintf(stderr, " [-nbg noarrive_bitmap_background_color][-afg arrive_bitmap_foreground_color]\n"); X fprintf(stderr, " [-abg arrive_bitmap_background_color][-polling_time time(msec)]\n"); X! fprintf(stderr, " [-noraise][-nopopup][-noanimate][-nopopdown][-keepup][-nobell][-mono][-patchlevel][-bitmap bitmap_file]\n"); X exit(0); X } X } X*************** X*** 169,178 **** X X XAllocNamedColor(XtDisplay(toplevel), DefaultColormapOfScreen(XtScreen(toplevel)), colors[0], &foreColor, &dummyColor); X XAllocNamedColor(XtDisplay(toplevel), DefaultColormapOfScreen(XtScreen(toplevel)), colors[1], &backColor, &dummyColor); X! noPixmap = XCreatePixmapFromBitmapData(XtDisplay(toplevel), XtWindow(biff), X! no_bits, no_width, no_height, foreColor.pixel, X! backColor.pixel, DefaultDepthOfScreen(XtScreen(toplevel))); X X gcBiff = XCreateGC(XtDisplay(toplevel), XtWindow(biff), X (unsigned long) 0, NULL); X XSetGraphicsExposures(XtDisplay(toplevel), gcBiff, False); X--- 255,287 ---- X X XAllocNamedColor(XtDisplay(toplevel), DefaultColormapOfScreen(XtScreen(toplevel)), colors[0], &foreColor, &dummyColor); X XAllocNamedColor(XtDisplay(toplevel), DefaultColormapOfScreen(XtScreen(toplevel)), colors[1], &backColor, &dummyColor); X! if(no_arrival_bitmap_file == NULL) { X! noPixmap = XCreatePixmapFromBitmapData(XtDisplay(toplevel), XtWindow(biff), no_bits, no_width, X! no_height, foreColor.pixel, backColor.pixel, DefaultDepthOfScreen(XtScreen(toplevel))); X! no_bitmap_width = no_width; X! no_bitmap_height = no_height; X! } X! else { X! int usr_bitmap_x, usr_bitmap_y; X! unsigned char *usr_bitmap_data; X X+ if(XmuReadBitmapDataFromFile(no_arrival_bitmap_file, &no_bitmap_width, &no_bitmap_height, X+ &usr_bitmap_data, &usr_bitmap_x, &usr_bitmap_y) != BitmapSuccess) { X+ fprintf(stderr, "cannot make a bitmap '%s'.\n", no_arrival_bitmap_file); X+ exit(1); X+ } X+ X+ noPixmap = XCreatePixmapFromBitmapData(XtDisplay(toplevel), XtWindow(biff), usr_bitmap_data, X+ no_bitmap_width, no_bitmap_height, foreColor.pixel, backColor.pixel, X+ DefaultDepthOfScreen(XtScreen(toplevel))); X+ i = 0; X+ XtSetArg(args[i], XtNwidth, no_bitmap_width); X+ i++; X+ XtSetArg(args[i], XtNheight, no_bitmap_height); X+ i++; X+ XtSetValues(biff, args, i); X+ } X+ X gcBiff = XCreateGC(XtDisplay(toplevel), XtWindow(biff), X (unsigned long) 0, NULL); X XSetGraphicsExposures(XtDisplay(toplevel), gcBiff, False); X*************** X*** 197,203 **** X X X /* Interval timer start */ X! XtAddTimeOut(polling_time, Polling, NULL); X X XtMainLoop(); X } X--- 306,312 ---- X X X /* Interval timer start */ X! polling_id = XtAddTimeOut(polling_time, Polling, NULL); X X XtMainLoop(); X } X*************** X*** 223,229 **** X if (current_status == ARRIVE) { X XCopyArea(XtDisplay(toplevel), arrivePixmap, XtWindow(biff), gcBiff, 0, 0, arrive_width, arrive_height, 0, 0); X } else { X! XCopyArea(XtDisplay(toplevel), noPixmap, XtWindow(biff), gcBiff, 0, 0, arrive_width, arrive_height, 0, 0); X } X } X X--- 332,338 ---- X if (current_status == ARRIVE) { X XCopyArea(XtDisplay(toplevel), arrivePixmap, XtWindow(biff), gcBiff, 0, 0, arrive_width, arrive_height, 0, 0); X } else { X! XCopyArea(XtDisplay(toplevel), noPixmap, XtWindow(biff), gcBiff, 0, 0, no_bitmap_width, no_bitmap_height, 0, 0); X } X } X X*************** X*** 231,240 **** X XtTimerCallbackProc X Polling(client_data, id) X caddr_t client_data; X! XtIntervalId id; X { X X- static long mail_size = 0; X struct stat file_stat; X char *mail_header; X X--- 340,348 ---- X XtTimerCallbackProc X Polling(client_data, id) X caddr_t client_data; X! XtIntervalId *id; X { X X struct stat file_stat; X char *mail_header; X X*************** X*** 279,285 **** X XBell(XtDisplay(toplevel), 0); X } else { X mail_size = file_stat.st_size; X! if (raise == True) X XLowerWindow(XtDisplay(toplevel), XtWindow(toplevel)); X if (popup == True) X BreakPopup(toplevel, (XtPointer) NULL, (XtPointer) NULL); X--- 387,393 ---- X XBell(XtDisplay(toplevel), 0); X } else { X mail_size = file_stat.st_size; X! if (raise == True && stay_raised == False) X XLowerWindow(XtDisplay(toplevel), XtWindow(toplevel)); X if (popup == True) X BreakPopup(toplevel, (XtPointer) NULL, (XtPointer) NULL); X*************** X*** 289,296 **** X if (current_status == ARRIVE) { X current_status = NO; X XCopyArea(XtDisplay(toplevel), noPixmap, XtWindow(biff), gcBiff, 0, 0, X! arrive_width, arrive_height, 0, 0); X! if (raise == True) X XLowerWindow(XtDisplay(toplevel), XtWindow(toplevel)); X if (popup == True) X BreakPopup(toplevel, (XtPointer) NULL, (XtPointer) NULL); X--- 397,404 ---- X if (current_status == ARRIVE) { X current_status = NO; X XCopyArea(XtDisplay(toplevel), noPixmap, XtWindow(biff), gcBiff, 0, 0, X! no_bitmap_width, no_bitmap_height, 0, 0); X! if (raise == True && stay_raised == False) X XLowerWindow(XtDisplay(toplevel), XtWindow(toplevel)); X if (popup == True) X BreakPopup(toplevel, (XtPointer) NULL, (XtPointer) NULL); X*************** X*** 297,303 **** X } X /* No arrive */ X X! XtAddTimeOut(polling_time, Polling, NULL); X X } X X--- 405,411 ---- X } X /* No arrive */ X X! polling_id = XtAddTimeOut(polling_time, Polling, NULL); X X } X X*************** X*** 385,391 **** X X free(head); X X! XtPopup(header, XtGrabExclusive); X } X X X--- 493,502 ---- X X free(head); X X! XtPopup(header, XtGrabNone); X! X! showing_header = 1; X! X } X X X*************** X*** 395,407 **** X X struct stat status; X int fd; X! char *mail_header, *mail_buffer, *head; X X /* get mail headers */ X X fd = open(spool_path, O_RDONLY); X fstat(fd, &status); X! mail_buffer = (char *) malloc((unsigned int) (status.st_size + 1)); X head = mail_header = (char *) malloc((unsigned int) (status.st_size + 1)); X read(fd, mail_buffer, status.st_size); X close(fd); X--- 506,518 ---- X X struct stat status; X int fd; X! char *mail_buffer_saved, *mail_header, *mail_buffer, *head; X X /* get mail headers */ X X fd = open(spool_path, O_RDONLY); X fstat(fd, &status); X! mail_buffer = mail_buffer_saved = (char *) malloc((unsigned int) (status.st_size + 1)); X head = mail_header = (char *) malloc((unsigned int) (status.st_size + 1)); X read(fd, mail_buffer, status.st_size); X close(fd); X*************** X*** 420,426 **** X X } X *mail_header = NULL; X! X free(mail_buffer); X return (head); X X--- 531,538 ---- X X } X *mail_header = NULL; X! X! free(mail_buffer_saved); X free(mail_buffer); X return (head); X X*************** X*** 437,441 **** X--- 549,603 ---- X X XtPopdown(header); X XtDestroyWidget(header); X+ X+ showing_header = 0; X+ } X+ X+ XtCallbackProc X+ popup_again(widget, client_data, call_data) X+ Widget widget; X+ caddr_t client_data; X+ caddr_t call_data; X+ { X+ struct stat file_stat; X+ char *mail_header; X+ X+ if ((stat(spool_path, &file_stat) == 0) && (file_stat.st_size != 0)) { X+ /* There are mail */ X+ if (current_status == NO) { X+ /* the click catchs new mail */ X+ current_status = ARRIVE; X+ mail_size = file_stat.st_size; X+ if (popup == True) X+ mail_header = GetMailHeader(); X+ if (raise == True) X+ XRaiseWindow(XtDisplay(toplevel), XtWindow(toplevel)); X+ if (animate == True) X+ AnimateBiff(); X+ XCopyArea(XtDisplay(toplevel), arrivePixmap, XtWindow(biff), X+ gcBiff, 0, 0, arrive_width, arrive_height, 0, 0); X+ if (popup == True) X+ PopupMailHeader(mail_header); X+ XSync(XtDisplay(toplevel), 0); X+ if (bell == True) X+ XBell(XtDisplay(toplevel), 0); X+ } else { X+ mail_size = file_stat.st_size; X+ if (popup == True) X+ mail_header = GetMailHeader(); X+ if (popup == True && showing_header) X+ BreakPopup(toplevel, (XtPointer) NULL, (XtPointer) NULL); X+ if (raise == True) X+ XRaiseWindow(XtDisplay(toplevel), XtWindow(toplevel)); X+ XCopyArea(XtDisplay(toplevel), arrivePixmap, XtWindow(biff), X+ gcBiff, 0, 0, arrive_width, arrive_height, 0, 0); X+ if (popup == True) X+ PopupMailHeader(mail_header); X+ XSync(XtDisplay(toplevel), 0); X+ } X+ } X+ X+ XtRemoveTimeOut(polling_id); X+ polling_id = XtAddTimeOut(polling_time, Polling, NULL); X X } END_OF_FILE if test 20010 -ne `wc -c <'xpbiff.patch1.comp'`; then echo shar: \"'xpbiff.patch1.comp'\" unpacked with wrong size! fi # end of 'xpbiff.patch1.comp' fi echo shar: End of shell archive. exit 0 dan ---------------------------------------------------- O'Reilly && Associates argv@sun.com / argv@ora.com Opinions expressed reflect those of the author only. -- dan ---------------------------------------------------- O'Reilly && Associates argv@sun.com / argv@ora.com Opinions expressed reflect those of the author only.