summaryrefslogtreecommitdiff
path: root/src/fe-text/statusbar-items.c
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2000-06-14 17:48:13 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2000-06-14 17:48:13 +0000
commitdb8918ae61e25d05e6f25e601314ace2c02a9ea1 (patch)
treed17d30e0dde04fe1395f3b13e2220556f4fe516a /src/fe-text/statusbar-items.c
parentc5d1dab0bce51757cd0bf90afe4a2c638e2be947 (diff)
downloadirssi-db8918ae61e25d05e6f25e601314ace2c02a9ea1.zip
/SET mail_counter on|off. Also, it doesn't anymore read through the file
if it's modification time hasn't changed. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@337 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-text/statusbar-items.c')
-rw-r--r--src/fe-text/statusbar-items.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/fe-text/statusbar-items.c b/src/fe-text/statusbar-items.c
index a8c01ddc..5c4f062a 100644
--- a/src/fe-text/statusbar-items.c
+++ b/src/fe-text/statusbar-items.c
@@ -77,7 +77,8 @@ static time_t lag_last_draw;
/* mbox counter */
static SBAR_ITEM_REC *mail_item;
-static int mail_timetag;
+static int mail_timetag, mail_last_count;
+static time_t mail_last_mtime;
/* topic */
static SBAR_ITEM_REC *topic_item;
@@ -584,11 +585,20 @@ static int statusbar_lag_timeout(void)
wouldn't need to.. */
static int get_mail_count(void)
{
+ struct stat statbuf;
FILE *f;
- char str[512];
+ char str[512], *fname;
int count;
- f = fopen(g_getenv("MAIL"), "r");
+ fname = g_getenv("MAIL");
+ if (stat(fname, &statbuf) != 0)
+ return 0;
+
+ if (statbuf.st_mtime == mail_last_mtime)
+ return mail_last_count;
+ mail_last_mtime = statbuf.st_mtime;
+
+ f = fopen(fname, "r");
if (f == NULL) return 0;
count = 0;
@@ -598,6 +608,7 @@ static int get_mail_count(void)
}
fclose(f);
+ mail_last_count = count;
return count;
}
@@ -606,9 +617,9 @@ static void statusbar_mail(SBAR_ITEM_REC *item, int ypos)
char str[MAX_INT_STRLEN];
int size_needed, mail_count;
- mail_count = get_mail_count();
- ltoa(str, mail_count);
+ mail_count = settings_get_bool("mail_counter") ? get_mail_count() : 0;
+ ltoa(str, mail_count);
if (*str == '\0' || mail_count <= 0)
size_needed = 0;
else
@@ -812,6 +823,7 @@ void statusbar_items_init(void)
settings_add_int("misc", "lag_min_show", 100);
settings_add_bool("lookandfeel", "topicbar", TRUE);
settings_add_bool("lookandfeel", "actlist_moves", FALSE);
+ settings_add_bool("misc", "mail_counter", TRUE);
/* clock */
clock_timetag = g_timeout_add(1000, (GSourceFunc) statusbar_clock_timeout, NULL);