summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/apoint.c26
-rwxr-xr-xsrc/custom.c31
-rwxr-xr-xsrc/day.c20
-rwxr-xr-xsrc/io.c22
-rwxr-xr-xsrc/notify.c297
-rwxr-xr-xsrc/notify.h4
-rwxr-xr-xsrc/utils.c7
-rwxr-xr-xsrc/vars.c17
-rwxr-xr-xsrc/vars.h9
-rwxr-xr-xsrc/wins.c8
10 files changed, 206 insertions, 235 deletions
diff --git a/src/apoint.c b/src/apoint.c
index eee97de..81941ac 100755
--- a/src/apoint.c
+++ b/src/apoint.c
@@ -1,4 +1,4 @@
-/* $calcurse: apoint.c,v 1.31 2009/01/02 19:52:32 culot Exp $ */
+/* $calcurse: apoint.c,v 1.32 2009/01/02 22:28:54 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -324,8 +324,8 @@ apoint_delete (conf_t *conf, unsigned *nb_events, unsigned *nb_apoints)
if (hilt > 1)
hilt--;
- if (apad->first_onscreen >= to_be_removed)
- apad->first_onscreen = apad->first_onscreen - to_be_removed;
+ if (apad.first_onscreen >= to_be_removed)
+ apad.first_onscreen = apad.first_onscreen - to_be_removed;
if (nb_items == 1)
hilt = 0;
}
@@ -362,8 +362,8 @@ apoint_cut (unsigned *nb_events, unsigned *nb_apoints)
if (hilt > 1)
hilt--;
- if (apad->first_onscreen >= to_be_removed)
- apad->first_onscreen = apad->first_onscreen - to_be_removed;
+ if (apad.first_onscreen >= to_be_removed)
+ apad.first_onscreen = apad.first_onscreen - to_be_removed;
if (NBITEMS == 1)
hilt = 0;
}
@@ -592,9 +592,9 @@ apoint_scroll_pad_down (int nb_events_inday, int win_length)
item_last_line = item_first_line;
else
item_last_line = item_first_line + 1;
- pad_last_line = apad->first_onscreen + awin_length;
+ pad_last_line = apad.first_onscreen + awin_length;
if (item_last_line >= pad_last_line)
- apad->first_onscreen = item_last_line - awin_length;
+ apad.first_onscreen = item_last_line - awin_length;
}
/*
@@ -607,8 +607,8 @@ apoint_scroll_pad_up (int nb_events_inday)
int item_first_line = 0;
item_first_line = get_item_line (hilt, nb_events_inday);
- if (item_first_line < apad->first_onscreen)
- apad->first_onscreen = item_first_line;
+ if (item_first_line < apad.first_onscreen)
+ apad.first_onscreen = item_first_line;
}
/*
@@ -745,11 +745,11 @@ apoint_update_panel (int which_pan)
custom_remove_attr (win[APP].p, ATTR_HIGHEST);
/* Draw the scrollbar if necessary. */
- if ((apad->length >= app_length) || (apad->first_onscreen > 0))
+ if ((apad.length >= app_length) || (apad.first_onscreen > 0))
{
- float ratio = ((float) app_length) / ((float) apad->length);
+ float ratio = ((float) app_length) / ((float) apad.length);
int sbar_length = (int) (ratio * app_length);
- int highend = (int) (ratio * apad->first_onscreen);
+ int highend = (int) (ratio * apad.first_onscreen);
bool hilt_bar = (which_pan == APP) ? true : false;
int sbar_top = highend + title_lines + 1;
@@ -760,7 +760,7 @@ apoint_update_panel (int which_pan)
}
wnoutrefresh (win[APP].p);
- pnoutrefresh (apad->ptrwin, apad->first_onscreen, 0,
+ pnoutrefresh (apad.ptrwin, apad.first_onscreen, 0,
win[APP].y + title_lines + 1, win[APP].x + bordr,
win[APP].y + win[APP].h - 2 * bordr,
win[APP].x + win[APP].w - 3 * bordr);
diff --git a/src/custom.c b/src/custom.c
index 71002ed..038e252 100755
--- a/src/custom.c
+++ b/src/custom.c
@@ -1,8 +1,8 @@
-/* $calcurse: custom.c,v 1.33 2008/12/28 19:41:45 culot Exp $ */
+/* $calcurse: custom.c,v 1.34 2009/01/02 22:28:54 culot Exp $ */
/*
* Calcurse - text-based organizer
- * Copyright (c) 2004-2008 Frederic Culot
+ * Copyright (c) 2004-2009 Frederic Culot
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -222,7 +222,7 @@ custom_load_conf (conf_t *conf, int background)
(void)keys_getch (win[STA].p);
}
var = CUSTOM_CONF_NOVARIABLE;
- pthread_mutex_lock (&nbar->mutex);
+ pthread_mutex_lock (&nbar.mutex);
for (;;)
{
if (fgets (buf, 99, data_file) == NULL)
@@ -277,23 +277,23 @@ custom_load_conf (conf_t *conf, int background)
var = 0;
break;
case CUSTOM_CONF_NOTIFYBARSHOW:
- nbar->show = fill_config_var (e_conf);
+ nbar.show = fill_config_var (e_conf);
var = 0;
break;
case CUSTOM_CONF_NOTIFYBARDATE:
- (void)strncpy (nbar->datefmt, e_conf, strlen (e_conf) + 1);
+ (void)strncpy (nbar.datefmt, e_conf, strlen (e_conf) + 1);
var = 0;
break;
case CUSTOM_CONF_NOTIFYBARCLOCK:
- (void)strncpy (nbar->timefmt, e_conf, strlen (e_conf) + 1);
+ (void)strncpy (nbar.timefmt, e_conf, strlen (e_conf) + 1);
var = 0;
break;
case CUSTOM_CONF_NOTIFYBARWARNING:
- nbar->cntdwn = atoi (e_conf);
+ nbar.cntdwn = atoi (e_conf);
var = 0;
break;
case CUSTOM_CONF_NOTIFYBARCOMMAND:
- (void)strncpy (nbar->cmd, e_conf, strlen (e_conf) + 1);
+ (void)strncpy (nbar.cmd, e_conf, strlen (e_conf) + 1);
var = 0;
break;
case CUSTOM_CONF_OUTPUTDATEFMT:
@@ -346,7 +346,7 @@ custom_load_conf (conf_t *conf, int background)
var = CUSTOM_CONF_INPUTDATEFMT;
}
file_close (data_file, __FILE_POS__);
- pthread_mutex_unlock (&nbar->mutex);
+ pthread_mutex_unlock (&nbar.mutex);
}
/* Draws the configuration bar */
@@ -436,8 +436,6 @@ display_layout_config (window_t *lwin, int mark, int cursor, int need_reset)
{
char label[BUFSIZ];
- if (lwin->p != NULL)
- delwin (lwin->p);
(void)snprintf (label, BUFSIZ, _("CalCurse %s | layout configuration"),
VERSION);
custom_confwin_init (lwin, label);
@@ -551,6 +549,13 @@ custom_layout_config (void)
void
custom_confwin_init (window_t *confwin, char *label)
{
+ if (confwin->p)
+ {
+ erase_window_part (confwin->p, confwin->x, confwin->y,
+ confwin->x + confwin->w, confwin->y + confwin->h);
+ (void)delwin (confwin->p);
+ }
+
wins_get_config ();
confwin->h = (notify_bar ())? row - 3 : row - 2;
confwin->p = newwin (confwin->h, col, 0, 0);
@@ -636,8 +641,6 @@ display_color_config (window_t *cwin, int *mark_fore, int *mark_back,
if (need_reset)
{
- if (cwin->p != NULL)
- delwin (cwin->p);
(void)snprintf (label, BUFSIZ, _("CalCurse %s | color theme"), VERSION);
custom_confwin_init (cwin, label);
}
@@ -731,7 +734,7 @@ custom_color_config (void)
cursor = 0;
need_reset = 1;
theme_changed = 0;
- conf_win.p = NULL;
+ conf_win.p = 0;
display_color_config (&conf_win, &mark_fore, &mark_back, cursor,
need_reset, theme_changed);
diff --git a/src/day.c b/src/day.c
index 6df66e4..1b602dd 100755
--- a/src/day.c
+++ b/src/day.c
@@ -1,4 +1,4 @@
-/* $calcurse: day.c,v 1.46 2009/01/02 19:52:32 culot Exp $ */
+/* $calcurse: day.c,v 1.47 2009/01/02 22:28:54 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -309,16 +309,16 @@ day_process_storage (date_t *slctd_date, bool day_changed,
date = date2sec (day, 0, 0);
/* Inits */
- if (apad->length != 0)
- delwin (apad->ptrwin);
+ if (apad.length != 0)
+ delwin (apad.ptrwin);
/* Store the events and appointments (recursive and normal items). */
- apad->length = day_store_items (date, &inday->nb_events, &inday->nb_apoints);
+ apad.length = day_store_items (date, &inday->nb_events, &inday->nb_apoints);
/* Create the new pad with its new length. */
if (day_changed)
- apad->first_onscreen = 0;
- apad->ptrwin = newpad (apad->length, apad->width);
+ apad.first_onscreen = 0;
+ apad.ptrwin = newpad (apad.length, apad.width);
return (inday);
}
@@ -347,7 +347,7 @@ display_item_date (int incolor, apoint_llist_node_t *i, int type, long date,
char a_st[100], a_end[100];
int recur = 0;
- win = apad->ptrwin;
+ win = apad.ptrwin;
apoint_sec2str (i, type, date, a_st, a_end);
if (type == RECUR_EVNT || type == RECUR_APPT)
recur = 1;
@@ -377,7 +377,7 @@ display_item (int incolor, char *msg, int recur, int note, int len, int y,
int ch_recur, ch_note;
char buf[len];
- win = apad->ptrwin;
+ win = apad.ptrwin;
ch_recur = (recur) ? '*' : ' ';
ch_note = (note) ? '>' : ' ';
if (incolor == 0)
@@ -442,8 +442,8 @@ day_write_pad (long date, int width, int length, int incolor)
/* Draw a line between events and appointments. */
if (line > 0 && draw_line)
{
- wmove (apad->ptrwin, line, 0);
- whline (apad->ptrwin, 0, width);
+ wmove (apad.ptrwin, line, 0);
+ whline (apad.ptrwin, 0, width);
draw_line = false;
}
/* Last print the appointments for current day. */
diff --git a/src/io.c b/src/io.c
index 86503e7..3926f7a 100755
--- a/src/io.c
+++ b/src/io.c
@@ -1,4 +1,4 @@
-/* $calcurse: io.c,v 1.53 2009/01/02 19:52:32 culot Exp $ */
+/* $calcurse: io.c,v 1.54 2009/01/02 22:28:54 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -298,9 +298,9 @@ static void
ical_export_valarm (FILE *stream)
{
(void)fprintf (stream, "BEGIN:VALARM\n");
- pthread_mutex_lock (&nbar->mutex);
- (void)fprintf (stream, "TRIGGER:-P%dS\n", nbar->cntdwn);
- pthread_mutex_unlock (&nbar->mutex);
+ pthread_mutex_lock (&nbar.mutex);
+ (void)fprintf (stream, "TRIGGER:-P%dS\n", nbar.cntdwn);
+ pthread_mutex_unlock (&nbar.mutex);
(void)fprintf (stream, "ACTION:DISPLAY\n");
(void)fprintf (stream, "END:VALARM\n");
}
@@ -871,34 +871,34 @@ io_save_cal (conf_t *conf, io_save_display_t display)
(void)fprintf (data_file, "%d\n", wins_layout ());
if (ui_mode == UI_CURSES)
- pthread_mutex_lock (&nbar->mutex);
+ pthread_mutex_lock (&nbar.mutex);
(void)fprintf (data_file,
"\n# If this option is set to yes, "
"notify-bar will be displayed :\n");
(void)fprintf (data_file, "notify-bar_show=\n");
- (void)fprintf (data_file, "%s\n", (nbar->show) ? "yes" : "no");
+ (void)fprintf (data_file, "%s\n", (nbar.show) ? "yes" : "no");
(void)fprintf (data_file,
"\n# Format of the date to be displayed inside notify-bar :\n");
(void)fprintf (data_file, "notify-bar_date=\n");
- (void)fprintf (data_file, "%s\n", nbar->datefmt);
+ (void)fprintf (data_file, "%s\n", nbar.datefmt);
(void)fprintf (data_file,
"\n# Format of the time to be displayed inside notify-bar :\n");
(void)fprintf (data_file, "notify-bar_clock=\n");
- (void)fprintf (data_file, "%s\n", nbar->timefmt);
+ (void)fprintf (data_file, "%s\n", nbar.timefmt);
(void)fprintf (data_file,
"\n# Warn user if he has an appointment within next "
"'notify-bar_warning' seconds :\n");
(void)fprintf (data_file, "notify-bar_warning=\n");
- (void)fprintf (data_file, "%d\n", nbar->cntdwn);
+ (void)fprintf (data_file, "%d\n", nbar.cntdwn);
(void)fprintf (data_file,
"\n# Command used to notify user of "
"an upcoming appointment :\n");
(void)fprintf (data_file, "notify-bar_command=\n");
- (void)fprintf (data_file, "%s\n", nbar->cmd);
+ (void)fprintf (data_file, "%s\n", nbar.cmd);
(void)fprintf (data_file,
"\n# Format of the date to be displayed "
@@ -913,7 +913,7 @@ io_save_cal (conf_t *conf, io_save_display_t display)
(void)fprintf (data_file, "%d\n", conf->input_datefmt);
if (ui_mode == UI_CURSES)
- pthread_mutex_unlock (&nbar->mutex);
+ pthread_mutex_unlock (&nbar.mutex);
file_close (data_file, __FILE_POS__);
}
diff --git a/src/notify.c b/src/notify.c
index 5f03a6d..df42edc 100755
--- a/src/notify.c
+++ b/src/notify.c
@@ -1,8 +1,8 @@
-/* $calcurse: notify.c,v 1.33 2008/12/28 13:13:59 culot Exp $ */
+/* $calcurse: notify.c,v 1.34 2009/01/02 22:28:54 culot Exp $ */
/*
* Calcurse - text-based organizer
- * Copyright (c) 2004-2008 Frederic Culot
+ * Copyright (c) 2004-2009 Frederic Culot
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -40,10 +40,10 @@
#include "mem.h"
#include "notify.h"
-static struct notify_vars_s *notify = NULL;
-static struct notify_app_s *notify_app = NULL;
-static pthread_attr_t detached_thread_attr;
-static pthread_t notify_t_main;
+static struct notify_vars_s notify;
+static struct notify_app_s notify_app;
+static pthread_attr_t detached_thread_attr;
+static pthread_t notify_t_main;
/* Return 1 if we need to display the notify-bar, else 0. */
int
@@ -51,9 +51,9 @@ notify_bar (void)
{
int display_bar = 0;
- pthread_mutex_lock (&nbar->mutex);
- display_bar = (nbar->show) ? 1 : 0;
- pthread_mutex_unlock (&nbar->mutex);
+ pthread_mutex_lock (&nbar.mutex);
+ display_bar = (nbar.show) ? 1 : 0;
+ pthread_mutex_unlock (&nbar.mutex);
return (display_bar);
}
@@ -66,28 +66,21 @@ notify_init_vars (void)
char *date_format = "%a %F";
char *cmd = "printf '\\a'";
- nbar = (struct nbar_s *) mem_malloc (sizeof (struct nbar_s));
- pthread_mutex_init (&nbar->mutex, NULL);
- nbar->show = 1;
- nbar->cntdwn = 300;
- (void)strncpy (nbar->datefmt, date_format, strlen (date_format) + 1);
- (void)strncpy (nbar->timefmt, time_format, strlen (time_format) + 1);
- (void)strncpy (nbar->cmd, cmd, strlen (cmd) + 1);
+ pthread_mutex_init (&nbar.mutex, NULL);
+ nbar.show = 1;
+ nbar.cntdwn = 300;
+ (void)strncpy (nbar.datefmt, date_format, strlen (date_format) + 1);
+ (void)strncpy (nbar.timefmt, time_format, strlen (time_format) + 1);
+ (void)strncpy (nbar.cmd, cmd, strlen (cmd) + 1);
- if ((nbar->shell = getenv ("SHELL")) == NULL)
- nbar->shell = "/bin/sh";
+ if ((nbar.shell = getenv ("SHELL")) == NULL)
+ nbar.shell = "/bin/sh";
(void)pthread_attr_init (&detached_thread_attr);
(void)pthread_attr_setdetachstate (&detached_thread_attr,
PTHREAD_CREATE_DETACHED);
}
-void
-notify_free_vars (void)
-{
- mem_free (nbar);
-}
-
/* Extract the appointment file name from the complete file path. */
static void
extract_aptsfile (void)
@@ -96,11 +89,11 @@ extract_aptsfile (void)
file = strrchr (path_apts, '/');
if (!file)
- notify->apts_file = path_apts;
+ notify.apts_file = path_apts;
else
{
- notify->apts_file = file;
- notify->apts_file++;
+ notify.apts_file = file;
+ notify.apts_file++;
}
}
@@ -112,28 +105,18 @@ extract_aptsfile (void)
void
notify_init_bar (void)
{
- notify = (struct notify_vars_s *) mem_malloc (sizeof (struct notify_vars_s));
- notify_app = (struct notify_app_s *) mem_malloc (sizeof (struct notify_app_s));
- pthread_mutex_init (&notify->mutex, NULL);
- pthread_mutex_init (&notify_app->mutex, NULL);
- notify_app->got_app = 0;
- notify->win = newwin (win[NOT].h, win[NOT].w, win[NOT].y, win[NOT].x);
+ pthread_mutex_init (&notify.mutex, NULL);
+ pthread_mutex_init (&notify_app.mutex, NULL);
+ notify_app.got_app = 0;
+ notify.win = newwin (win[NOT].h, win[NOT].w, win[NOT].y, win[NOT].x);
extract_aptsfile ();
}
-void
-notify_free_bar (void)
-{
- mem_free (notify_app);
- mem_free (notify);
-}
-
/* Stop the notify-bar main thread. */
void
notify_stop_main_thread (void)
{
pthread_cancel (notify_t_main);
- return;
}
/*
@@ -143,8 +126,8 @@ notify_stop_main_thread (void)
void
notify_reinit_bar (void)
{
- delwin (notify->win);
- notify->win = newwin (win[NOT].h, win[NOT].w, win[NOT].y, win[NOT].x);
+ delwin (notify.win);
+ notify.win = newwin (win[NOT].h, win[NOT].w, win[NOT].y, win[NOT].x);
}
/* Launch user defined command as a notification. */
@@ -176,74 +159,74 @@ notify_update_bar (void)
char buf[BUFSIZ];
date_pos = space;
- pthread_mutex_lock (&notify->mutex);
+ pthread_mutex_lock (&notify.mutex);
- file_pos = strlen (notify->date) + strlen (notify->time) + 7 + 2 * space;
- app_pos = file_pos + strlen (notify->apts_file) + 2 + space;
+ file_pos = strlen (notify.date) + strlen (notify.time) + 7 + 2 * space;
+ app_pos = file_pos + strlen (notify.apts_file) + 2 + space;
txt_max_len = col - (app_pos + 12 + space);
- custom_apply_attr (notify->win, ATTR_HIGHEST);
- wattron (notify->win, A_UNDERLINE | A_REVERSE);
- mvwhline (notify->win, 0, 0, ACS_HLINE, col);
- mvwprintw (notify->win, 0, date_pos, "[ %s | %s ]",
- notify->date, notify->time);
- mvwprintw (notify->win, 0, file_pos, "(%s)", notify->apts_file);
+ custom_apply_attr (notify.win, ATTR_HIGHEST);
+ wattron (notify.win, A_UNDERLINE | A_REVERSE);
+ mvwhline (notify.win, 0, 0, ACS_HLINE, col);
+ mvwprintw (notify.win, 0, date_pos, "[ %s | %s ]",
+ notify.date, notify.time);
+ mvwprintw (notify.win, 0, file_pos, "(%s)", notify.apts_file);
- pthread_mutex_lock (&notify_app->mutex);
- if (notify_app->got_app)
+ pthread_mutex_lock (&notify_app.mutex);
+ if (notify_app.got_app)
{
- if (strlen (notify_app->txt) > txt_max_len)
+ if (strlen (notify_app.txt) > txt_max_len)
{
too_long = 1;
- (void)strncpy (buf, notify_app->txt, txt_max_len - 3);
+ (void)strncpy (buf, notify_app.txt, txt_max_len - 3);
buf[txt_max_len - 3] = '\0';
}
- time_left = notify_app->time - notify->time_in_sec;
+ time_left = notify_app.time - notify.time_in_sec;
if (time_left > 0)
{
hours_left = (time_left / HOURINSEC);
minutes_left = (time_left - hours_left * HOURINSEC) / MININSEC;
- pthread_mutex_lock (&nbar->mutex);
+ pthread_mutex_lock (&nbar.mutex);
- if (time_left < nbar->cntdwn && (notify_app->state & APOINT_NOTIFY))
+ if (time_left < nbar.cntdwn && (notify_app.state & APOINT_NOTIFY))
blinking = 1;
else
blinking = 0;
if (blinking)
- wattron (notify->win, A_BLINK);
+ wattron (notify.win, A_BLINK);
if (too_long)
- mvwprintw (notify->win, 0, app_pos, "> %02d:%02d :: %s.. <",
+ mvwprintw (notify.win, 0, app_pos, "> %02d:%02d :: %s.. <",
hours_left, minutes_left, buf);
else
- mvwprintw (notify->win, 0, app_pos, "> %02d:%02d :: %s <",
- hours_left, minutes_left, notify_app->txt);
+ mvwprintw (notify.win, 0, app_pos, "> %02d:%02d :: %s <",
+ hours_left, minutes_left, notify_app.txt);
if (blinking)
- wattroff (notify->win, A_BLINK);
+ wattroff (notify.win, A_BLINK);
- if (blinking && !(notify_app->state & APOINT_NOTIFIED))
+ if (blinking && !(notify_app.state & APOINT_NOTIFIED))
{
- notify_app->state |= APOINT_NOTIFIED;
- launch_cmd (nbar->cmd, nbar->shell);
+ notify_app.state |= APOINT_NOTIFIED;
+ launch_cmd (nbar.cmd, nbar.shell);
}
- pthread_mutex_unlock (&nbar->mutex);
+ pthread_mutex_unlock (&nbar.mutex);
}
else
{
- notify_app->got_app = 0;
- pthread_mutex_unlock (&notify_app->mutex);
- pthread_mutex_unlock (&notify->mutex);
+ notify_app.got_app = 0;
+ pthread_mutex_unlock (&notify_app.mutex);
+ pthread_mutex_unlock (&notify.mutex);
notify_check_next_app ();
return;
}
}
- pthread_mutex_unlock (&notify_app->mutex);
+ pthread_mutex_unlock (&notify_app.mutex);
- wattroff (notify->win, A_UNDERLINE | A_REVERSE);
- custom_remove_attr (notify->win, ATTR_HIGHEST);
- wrefresh (notify->win);
+ wattroff (notify.win, A_UNDERLINE | A_REVERSE);
+ custom_remove_attr (notify.win, ATTR_HIGHEST);
+ wrefresh (notify.win);
- pthread_mutex_unlock (&notify->mutex);
+ pthread_mutex_unlock (&notify.mutex);
}
/* Update the notication bar content */
@@ -264,22 +247,22 @@ notify_main_thread (void *arg)
{
ntimer = time (NULL);
ntime = localtime (&ntimer);
- pthread_mutex_lock (&notify->mutex);
- notify->time_in_sec = ntimer;
- pthread_mutex_lock (&nbar->mutex);
- strftime (notify->time, NOTIFY_FIELD_LENGTH, nbar->timefmt, ntime);
- strftime (notify->date, NOTIFY_FIELD_LENGTH, nbar->datefmt, ntime);
- pthread_mutex_unlock (&nbar->mutex);
- pthread_mutex_unlock (&notify->mutex);
+ pthread_mutex_lock (&notify.mutex);
+ notify.time_in_sec = ntimer;
+ pthread_mutex_lock (&nbar.mutex);
+ strftime (notify.time, NOTIFY_FIELD_LENGTH, nbar.timefmt, ntime);
+ strftime (notify.date, NOTIFY_FIELD_LENGTH, nbar.datefmt, ntime);
+ pthread_mutex_unlock (&nbar.mutex);
+ pthread_mutex_unlock (&notify.mutex);
notify_update_bar ();
(void)sleep (thread_sleep);
elapse += thread_sleep;
if (elapse >= check_app)
{
elapse = 0;
- pthread_mutex_lock (&notify_app->mutex);
- got_app = notify_app->got_app;
- pthread_mutex_unlock (&notify_app->mutex);
+ pthread_mutex_lock (&notify_app.mutex);
+ got_app = notify_app.got_app;
+ pthread_mutex_unlock (&notify_app.mutex);
if (!got_app)
notify_check_next_app ();
}
@@ -305,19 +288,19 @@ notify_thread_app (void *arg)
tmp_app = *recur_apoint_check_next (&tmp_app, current_time, get_today ());
tmp_app = *apoint_check_next (&tmp_app, current_time);
- pthread_mutex_lock (&notify_app->mutex);
+ pthread_mutex_lock (&notify_app.mutex);
if (tmp_app.got_app)
{
- notify_app->got_app = 1;
- notify_app->time = tmp_app.time;
- notify_app->txt = strdup (tmp_app.txt);
- notify_app->state = tmp_app.state;
+ notify_app.got_app = 1;
+ notify_app.time = tmp_app.time;
+ notify_app.txt = strdup (tmp_app.txt);
+ notify_app.state = tmp_app.state;
}
else
{
- notify_app->got_app = 0;
+ notify_app.got_app = 0;
}
- pthread_mutex_unlock (&notify_app->mutex);
+ pthread_mutex_unlock (&notify_app.mutex);
if (tmp_app.txt != NULL)
mem_free (tmp_app.txt);
@@ -346,28 +329,28 @@ notify_check_added (char *mesg, long start, char state)
long gap;
current_time = time (NULL);
- pthread_mutex_lock (&notify_app->mutex);
- if (!notify_app->got_app)
+ pthread_mutex_lock (&notify_app.mutex);
+ if (!notify_app.got_app)
{
gap = start - current_time;
if (gap >= 0 && gap <= DAYINSEC)
update_notify = 1;
}
- else if (start < notify_app->time && start >= current_time)
+ else if (start < notify_app.time && start >= current_time)
{
update_notify = 1;
}
- else if (start == notify_app->time && state != notify_app->state)
+ else if (start == notify_app.time && state != notify_app.state)
update_notify = 1;
if (update_notify)
{
- notify_app->got_app = 1;
- notify_app->time = start;
- notify_app->txt = strdup (mesg);
- notify_app->state = state;
+ notify_app.got_app = 1;
+ notify_app.time = start;
+ notify_app.txt = strdup (mesg);
+ notify_app.state = state;
}
- pthread_mutex_unlock (&notify_app->mutex);
+ pthread_mutex_unlock (&notify_app.mutex);
notify_update_bar ();
}
@@ -380,33 +363,33 @@ notify_check_repeated (recur_apoint_llist_node_t *i)
time_t current_time;
current_time = time (NULL);
- pthread_mutex_lock (&notify_app->mutex);
+ pthread_mutex_lock (&notify_app.mutex);
if ((real_app_time = recur_item_inday (i->start, i->exc, i->rpt->type,
i->rpt->freq, i->rpt->until,
get_today ()) > current_time))
{
- if (!notify_app->got_app)
+ if (!notify_app.got_app)
{
if (real_app_time - current_time <= DAYINSEC)
update_notify = 1;
}
- else if (real_app_time < notify_app->time &&
+ else if (real_app_time < notify_app.time &&
real_app_time >= current_time)
{
update_notify = 1;
}
- else if (real_app_time == notify_app->time &&
- i->state != notify_app->state)
+ else if (real_app_time == notify_app.time &&
+ i->state != notify_app.state)
update_notify = 1;
}
if (update_notify)
{
- notify_app->got_app = 1;
- notify_app->time = real_app_time;
- notify_app->txt = strdup (i->mesg);
- notify_app->state = i->state;
+ notify_app.got_app = 1;
+ notify_app.time = real_app_time;
+ notify_app.txt = strdup (i->mesg);
+ notify_app.state = i->state;
}
- pthread_mutex_unlock (&notify_app->mutex);
+ pthread_mutex_unlock (&notify_app.mutex);
notify_update_bar ();
}
@@ -415,12 +398,12 @@ notify_same_item (long time)
{
int same = 0;
- pthread_mutex_lock (&(notify_app->mutex));
- if (notify_app->got_app && notify_app->time == time)
+ pthread_mutex_lock (&(notify_app.mutex));
+ if (notify_app.got_app && notify_app.time == time)
same = 1;
- pthread_mutex_unlock (&(notify_app->mutex));
+ pthread_mutex_unlock (&(notify_app.mutex));
- return (same);
+ return same;
}
int
@@ -431,12 +414,12 @@ notify_same_recur_item (recur_apoint_llist_node_t *i)
item_start = recur_item_inday (i->start, i->exc, i->rpt->type,
i->rpt->freq, i->rpt->until, get_today ());
- pthread_mutex_lock (&notify_app->mutex);
- if (notify_app->got_app && item_start == notify_app->time)
+ pthread_mutex_lock (&notify_app.mutex);
+ if (notify_app.got_app && item_start == notify_app.time)
same = 1;
- pthread_mutex_unlock (&(notify_app->mutex));
+ pthread_mutex_unlock (&(notify_app.mutex));
- return (same);
+ return same;
}
/* Launch the notify-bar main thread. */
@@ -445,7 +428,6 @@ notify_start_main_thread (void)
{
pthread_create (&notify_t_main, NULL, notify_main_thread, NULL);
notify_check_next_app ();
- return;
}
/* Print options related to the notify-bar. */
@@ -493,18 +475,18 @@ notify_print_options (WINDOW *optwin, int col)
_("(Command used to notify user of an upcoming appointment)"),
BUFSIZ);
- pthread_mutex_lock (&nbar->mutex);
+ pthread_mutex_lock (&nbar.mutex);
- (void)strncpy (opt[DATE].value, nbar->datefmt, BUFSIZ);
- (void)strncpy (opt[CLOCK].value, nbar->timefmt, BUFSIZ);
- (void)snprintf (opt[WARN].value, BUFSIZ, "%d", nbar->cntdwn);
- (void)strncpy (opt[CMD].value, nbar->cmd, BUFSIZ);
+ (void)strncpy (opt[DATE].value, nbar.datefmt, BUFSIZ);
+ (void)strncpy (opt[CLOCK].value, nbar.timefmt, BUFSIZ);
+ (void)snprintf (opt[WARN].value, BUFSIZ, "%d", nbar.cntdwn);
+ (void)strncpy (opt[CMD].value, nbar.cmd, BUFSIZ);
l = strlen (opt[SHOW].name);
x = x_pos + x_offset + l;
mvwprintw (optwin, y_pos, x_pos, "[1] %s", opt[SHOW].name);
erase_window_part (optwin, x, y_pos, maxcol, y_pos);
- print_bool_option_incolor (optwin, nbar->show, y_pos, x);
+ print_bool_option_incolor (optwin, nbar.show, y_pos, x);
mvwprintw (optwin, y_pos + 1, x_pos, opt[SHOW].desc);
for (i = 1; i < NB_OPT; i++)
@@ -529,7 +511,7 @@ notify_print_options (WINDOW *optwin, int col)
mvwprintw (optwin, y + 1, x_pos, opt[i].desc);
}
- pthread_mutex_unlock (&nbar->mutex);
+ pthread_mutex_unlock (&nbar.mutex);
wmove (win[STA].p, 1, 0);
wnoutrefresh (optwin);
doupdate ();
@@ -553,9 +535,11 @@ notify_config_bar (void)
char *cmd_str = _("Enter the notification command ");
int ch = 0, change_win = 1;
- buf = (char *) mem_malloc (BUFSIZ);
+ buf = mem_malloc (BUFSIZ);
(void)snprintf (label, BUFSIZ, _("CalCurse %s | notify-bar options"),
VERSION);
+
+ conf_win.p = 0;
custom_confwin_init (&conf_win, label);
while (ch != 'q')
@@ -577,66 +561,65 @@ notify_config_bar (void)
custom_confwin_init (&conf_win, label);
break;
case '1':
- pthread_mutex_lock (&nbar->mutex);
- nbar->show = !nbar->show;
- pthread_mutex_unlock (&nbar->mutex);
+ pthread_mutex_lock (&nbar.mutex);
+ nbar.show = !nbar.show;
+ pthread_mutex_unlock (&nbar.mutex);
if (notify_bar ())
notify_start_main_thread ();
else
notify_stop_main_thread ();
- delwin (conf_win.p);
change_win = 1;
break;
case '2':
status_mesg (date_str, "");
- pthread_mutex_lock (&nbar->mutex);
- (void)strncpy (buf, nbar->datefmt, strlen (nbar->datefmt) + 1);
- pthread_mutex_unlock (&nbar->mutex);
+ pthread_mutex_lock (&nbar.mutex);
+ (void)strncpy (buf, nbar.datefmt, strlen (nbar.datefmt) + 1);
+ pthread_mutex_unlock (&nbar.mutex);
if (updatestring (win[STA].p, &buf, 0, 1) == 0)
{
- pthread_mutex_lock (&nbar->mutex);
- (void)strncpy (nbar->datefmt, buf, strlen (buf) + 1);
- pthread_mutex_unlock (&nbar->mutex);
+ pthread_mutex_lock (&nbar.mutex);
+ (void)strncpy (nbar.datefmt, buf, strlen (buf) + 1);
+ pthread_mutex_unlock (&nbar.mutex);
}
change_win = 0;
break;
case '3':
status_mesg (time_str, "");
- pthread_mutex_lock (&nbar->mutex);
- (void)strncpy (buf, nbar->timefmt, strlen (nbar->timefmt) + 1);
- pthread_mutex_unlock (&nbar->mutex);
+ pthread_mutex_lock (&nbar.mutex);
+ (void)strncpy (buf, nbar.timefmt, strlen (nbar.timefmt) + 1);
+ pthread_mutex_unlock (&nbar.mutex);
if (updatestring (win[STA].p, &buf, 0, 1) == 0)
{
- pthread_mutex_lock (&nbar->mutex);
- (void)strncpy (nbar->timefmt, buf, strlen (buf) + 1);
- pthread_mutex_unlock (&nbar->mutex);
+ pthread_mutex_lock (&nbar.mutex);
+ (void)strncpy (nbar.timefmt, buf, strlen (buf) + 1);
+ pthread_mutex_unlock (&nbar.mutex);
}
change_win = 0;
break;
case '4':
status_mesg (count_str, "");
- pthread_mutex_lock (&nbar->mutex);
- printf (buf, "%d", nbar->cntdwn);
- pthread_mutex_unlock (&nbar->mutex);
+ pthread_mutex_lock (&nbar.mutex);
+ printf (buf, "%d", nbar.cntdwn);
+ pthread_mutex_unlock (&nbar.mutex);
if (updatestring (win[STA].p, &buf, 0, 1) == 0 &&
is_all_digit (buf) && atoi (buf) >= 0 && atoi (buf) <= DAYINSEC)
{
- pthread_mutex_lock (&nbar->mutex);
- nbar->cntdwn = atoi (buf);
- pthread_mutex_unlock (&nbar->mutex);
+ pthread_mutex_lock (&nbar.mutex);
+ nbar.cntdwn = atoi (buf);
+ pthread_mutex_unlock (&nbar.mutex);
}
change_win = 0;
break;
case '5':
status_mesg (cmd_str, "");
- pthread_mutex_lock (&nbar->mutex);
- (void)strncpy (buf, nbar->cmd, strlen (nbar->cmd) + 1);
- pthread_mutex_unlock (&nbar->mutex);
+ pthread_mutex_lock (&nbar.mutex);
+ (void)strncpy (buf, nbar.cmd, strlen (nbar.cmd) + 1);
+ pthread_mutex_unlock (&nbar.mutex);
if (updatestring (win[STA].p, &buf, 0, 1) == 0)
{
- pthread_mutex_lock (&nbar->mutex);
- (void)strncpy (nbar->cmd, buf, strlen (buf) + 1);
- pthread_mutex_unlock (&nbar->mutex);
+ pthread_mutex_lock (&nbar.mutex);
+ (void)strncpy (nbar.cmd, buf, strlen (buf) + 1);
+ pthread_mutex_unlock (&nbar.mutex);
}
change_win = 0;
break;
diff --git a/src/notify.h b/src/notify.h
index 957ec36..8823bb8 100755
--- a/src/notify.h
+++ b/src/notify.h
@@ -1,4 +1,4 @@
-/* $calcurse: notify.h,v 1.15 2008/12/28 13:13:59 culot Exp $ */
+/* $calcurse: notify.h,v 1.16 2009/01/02 22:28:54 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -54,9 +54,7 @@ struct notify_app_s
int notify_bar (void);
void notify_init_vars (void);
-void notify_free_vars (void);
void notify_init_bar (void);
-void notify_free_bar (void);
void notify_start_main_thread (void);
void notify_stop_main_thread (void);
void notify_reinit_bar (void);
diff --git a/src/utils.c b/src/utils.c
index 87f2a16..517da04 100755
--- a/src/utils.c
+++ b/src/utils.c
@@ -1,4 +1,4 @@
-/* $calcurse: utils.c,v 1.64 2009/01/01 17:50:41 culot Exp $ */
+/* $calcurse: utils.c,v 1.65 2009/01/02 22:28:54 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -36,7 +36,6 @@
#include "utils.h"
#include "i18n.h"
-#include "notify.h"
#include "wins.h"
#include "custom.h"
#include "keys.h"
@@ -47,7 +46,6 @@
#include "todo.h"
#include "day.h"
#include "keys.h"
-#include "vars.h"
#include "mem.h"
#define NB_CAL_CMDS 24 /* number of commands while in cal view */
@@ -71,9 +69,6 @@ exit_calcurse (int status)
}
calendar_stop_date_thread ();
io_stop_psave_thread ();
- vars_free ();
- notify_free_vars ();
- notify_free_bar ();
day_saved_item_free ();
day_free_list ();
event_llist_free ();
diff --git a/src/vars.c b/src/vars.c
index 2283067..9e7e529 100755
--- a/src/vars.c
+++ b/src/vars.c
@@ -1,4 +1,4 @@
-/* $calcurse: vars.c,v 1.13 2008/12/28 19:41:45 culot Exp $ */
+/* $calcurse: vars.c,v 1.14 2009/01/02 22:28:54 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -92,10 +92,10 @@ char path_notes[] = "";
char path_keys[] = "";
/* Variable to handle pads. */
-struct pad_s *apad;
+struct pad_s apad;
/* Variable to store notify-bar settings. */
-struct nbar_s *nbar;
+struct nbar_s nbar;
/*
* Variables init
@@ -135,9 +135,8 @@ vars_init (conf_t *conf)
calendar_set_first_day_of_week (MONDAY);
/* Pad structure to scroll text inside the appointment panel */
- apad = (struct pad_s *) mem_malloc (sizeof (struct pad_s));
- apad->length = 1;
- apad->first_onscreen = 0;
+ apad.length = 1;
+ apad.first_onscreen = 0;
/* Attribute definitions for color and non-color terminals */
custom_init_attr ();
@@ -145,9 +144,3 @@ vars_init (conf_t *conf)
/* Start at the current date */
calendar_init_slctd_day ();
}
-
-void
-vars_free (void)
-{
- mem_free (apad);
-}
diff --git a/src/vars.h b/src/vars.h
index b8961cd..8f282e1 100755
--- a/src/vars.h
+++ b/src/vars.h
@@ -1,8 +1,8 @@
-/* $calcurse: vars.h,v 1.28 2008/12/28 19:41:45 culot Exp $ */
+/* $calcurse: vars.h,v 1.29 2009/01/02 22:28:54 culot Exp $ */
/*
* Calcurse - text-based organizer
- * Copyright (c) 2004-2008 Frederic Culot
+ * Copyright (c) 2004-2009 Frederic Culot
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -119,10 +119,9 @@ extern char path_apts[BUFSIZ];
extern char path_conf[BUFSIZ];
extern char path_keys[BUFSIZ];
extern char path_notes[BUFSIZ];
-extern struct pad_s *apad;
-extern struct nbar_s *nbar;
+extern struct pad_s apad;
+extern struct nbar_s nbar;
void vars_init (conf_t *conf);
-void vars_free (void);
#endif /* CALCURSE_VARS_H */
diff --git a/src/wins.c b/src/wins.c
index 36655a5..2de2a18 100755
--- a/src/wins.c
+++ b/src/wins.c
@@ -1,4 +1,4 @@
-/* $calcurse: wins.c,v 1.21 2008/12/28 19:41:45 culot Exp $ */
+/* $calcurse: wins.c,v 1.22 2009/01/02 22:28:54 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -103,8 +103,8 @@ wins_init (void)
win[APP].p = newwin (win[APP].h, win[APP].w, win[APP].y, win[APP].x);
(void)snprintf (label, BUFSIZ, _("Appointments"));
wins_show (win[APP].p, label);
- apad->width = win[APP].w - 3;
- apad->ptrwin = newpad (apad->length, apad->width);
+ apad.width = win[APP].w - 3;
+ apad.ptrwin = newpad (apad.length, apad.width);
win[TOD].p = newwin (win[TOD].h, win[TOD].w, win[TOD].y, win[TOD].x);
(void)snprintf (label, BUFSIZ, _("ToDo"));
@@ -195,7 +195,7 @@ wins_reinit (void)
delwin (win[STA].p);
delwin (win[CAL].p);
delwin (win[APP].p);
- delwin (apad->ptrwin);
+ delwin (apad.ptrwin);
delwin (win[TOD].p);
wins_get_config ();
wins_init ();