[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bubblemon-list] Bottle patch
From: |
Joshua Crawford |
Subject: |
[Bubblemon-list] Bottle patch |
Date: |
Sat, 15 Jan 2005 22:39:12 +1100 |
User-agent: |
Mutt/1.5.6i |
G'day,
The patch below (for 2.0.3) modifies the behaviour of the message bottle:
o When fresh new mail arrives, or the applet is started while mail is
already present (new or not), drop a bottle.
o An unopened (mtime > atime) mailbox keeps the bottle floating, as before.
o An opened mailbox (atime >= mtime) makes the bottle sink to the bottom (and
stay there).
o Only when the mailbox is actually empty (size == 0) or unreadable is no
bottle shown.
I just started using bubblemon after the Freshmeat announcement a few days
ago and I think it's great (it even got a "Wow, that's cool!" from my
non-geek girlfriend). There's just a couple of things I'd like to see added,
which are a little beyond my knowledge: play a sound (plop) when new email
arrives, and run an application when the applet is clicked. If bubblemon did
these, I could remove Inbox Monitor from my panel.
diff -upPr bubblemon-2.0.3.old/src/bubblemon.c bubblemon-2.0.3/src/bubblemon.c
--- bubblemon-2.0.3.old/src/bubblemon.c 2005-01-09 20:58:06.000000000 +1100
+++ bubblemon-2.0.3/src/bubblemon.c 2005-01-15 18:10:20.000000000 +1100
@@ -456,17 +456,20 @@ static void bubblemon_updateBottle(int m
physics.bottle_y < MIN(physics.waterLevels[bubblePic.width / 2].y,
bubblePic.height - msgInBottle.height / 2);
- if (youveGotMail) {
- if (physics.bottle_state == GONE) {
- // Drop a new bottle
- physics.bottle_y = bubblePic.height + msgInBottle.height;
- physics.bottle_dy = 0.0;
- physics.bottle_state = FALLING;
- } else if (physics.bottle_state == SINKING) {
- physics.bottle_state = FLOATING;
- }
+ if ((physics.bottle_state == GONE) && (youveGotMail != 0)) {
+ /* Either the applet's just been started and mail is already present
+ or new mail has arrived. Drop a new bottle */
+ physics.bottle_y = bubblePic.height + msgInBottle.height;
+ physics.bottle_dy = 0.0;
+ physics.bottle_state = FALLING;
+ } else if (youveGotMail == 2) {
+ /* Keep the bottle floating until the mailbox is opened */
+ physics.bottle_state = FLOATING;
+ } else if ((youveGotMail == 0) && (physics.bottle_state == SUNK)) {
+ /* Mail has been deleted. Remove the bottle */
+ physics.bottle_state = SINKING;
} else {
- /* No unread mail */
+ /* No new mail */
if ((physics.bottle_state == FALLING) ||
(physics.bottle_state == FLOATING))
{
@@ -479,7 +482,9 @@ static void bubblemon_updateBottle(int m
}
/* Accelerate the bottle */
- if ((physics.bottle_state == FALLING) ||
+ if (physics.bottle_state == SUNK) {
+ gravityDdy = 0;
+ } else if ((physics.bottle_state == FALLING) ||
(physics.bottle_state == SINKING) ||
!isInWater)
{
@@ -514,9 +519,17 @@ static void bubblemon_updateBottle(int m
physics.bottle_state = FLOATING;
}
- /* Did we lose it? */
- if ((physics.bottle_state == SINKING) && (physics.bottle_y +
msgInBottle.height < 0.0)) {
- physics.bottle_state = GONE;
+ /* Did it hit bottom? */
+ if (physics.bottle_state == SINKING) {
+ if ((youveGotMail != 0) && (physics.bottle_y <= msgInBottle.height / 4.0))
{
+ /* Keep it there */
+ physics.bottle_y = msgInBottle.height / 4.0;
+ physics.bottle_state = SUNK;
+ physics.bottle_dy = 0.0;
+ } else if (physics.bottle_y + (msgInBottle.height / 2.0) < 0.0) {
+ /* Remove it */
+ physics.bottle_state = GONE;
+ }
}
}
diff -upPr bubblemon-2.0.3.old/src/bubblemon.h bubblemon-2.0.3/src/bubblemon.h
--- bubblemon-2.0.3.old/src/bubblemon.h 2005-01-09 20:59:08.000000000 +1100
+++ bubblemon-2.0.3/src/bubblemon.h 2005-01-15 17:55:07.000000000 +1100
@@ -85,7 +85,7 @@ static const unsigned int WEEDCOLOR1
typedef enum { WATER, ANTIALIAS, AIR } bubblemon_colorcode_t;
/* Bottle behaviour */
-typedef enum { GONE, FLOATING, SINKING, FALLING } bubblemon_bottlestate_t;
+typedef enum { GONE, FLOATING, SINKING, FALLING, SUNK }
bubblemon_bottlestate_t;
/* Bubble layers */
typedef enum { BACKGROUND, FOREGROUND } bubblemon_layer_t;
diff -upPr bubblemon-2.0.3.old/src/unix-mail.c bubblemon-2.0.3/src/unix-mail.c
--- bubblemon-2.0.3.old/src/unix-mail.c 2004-08-21 04:27:35.000000000 +1000
+++ bubblemon-2.0.3/src/unix-mail.c 2005-01-15 18:09:50.000000000 +1100
@@ -29,6 +29,7 @@
/* Check $MAIL for new mail on every N calls to mail_hasUnreadMail. */
static const int CHECKEVERYNTH = 100;
+/* Returns 2 if new (unseen) mail is present, 1 if any other mail, 0
otherwise. */
int mail_hasUnreadMail(void)
{
static int countdown = 0;
@@ -60,10 +61,15 @@ int mail_hasUnreadMail(void)
// Checking the file dates on the spool file failed
return 0;
}
-
- // New mail has arrived if the mail file has been updated after it
- // was last read from
- cachedMailState = mailStat.st_mtime > mailStat.st_atime;
+
+ if (mailStat.st_size == 0) {
+ /* No mail */
+ cachedMailState = 0;
+ } else {
+ /* New mail has arrived if the mail file has been updated after it
+ was last read from */
+ cachedMailState = ((mailStat.st_mtime > mailStat.st_atime) ? 2 : 1);
+ }
return cachedMailState;
}
--
Joshua 'bruce' Crawford ... http://www.geocities.com/mortarn
A seminar on Time Travel will be held two weeks ago.
pgp3xWbkqGmhl.pgp
Description: PGP signature