Notification configuration menu rewritten to handle scrolling.
This commit is contained in:
parent
d6b7f83e58
commit
a0117296b4
@ -4,6 +4,11 @@
|
|||||||
|
|
||||||
* src/calcurse.1: manpage updated with the '--status' flag and the
|
* src/calcurse.1: manpage updated with the '--status' flag and the
|
||||||
new daemon.log file in calcurse data directory
|
new daemon.log file in calcurse data directory
|
||||||
|
|
||||||
|
* src/notify.c (notify_config_bar): rewritten to handle scrolling
|
||||||
|
|
||||||
|
* src/custom.c: conf_set_scrsize not static anymore (changed to
|
||||||
|
custom_set_swsiz)
|
||||||
|
|
||||||
2009-08-01 Frederic Culot <frederic@culot.org>
|
2009-08-01 Frederic Culot <frederic@culot.org>
|
||||||
|
|
||||||
|
102
src/notify.c
102
src/notify.c
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: notify.c,v 1.43 2009/08/01 20:29:49 culot Exp $ */
|
/* $calcurse: notify.c,v 1.44 2009/08/02 09:30:01 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -572,7 +572,7 @@ print_option (WINDOW *win, unsigned x, unsigned y, char *name,
|
|||||||
char *valstr, unsigned valbool, char *desc, unsigned num)
|
char *valstr, unsigned valbool, char *desc, unsigned num)
|
||||||
{
|
{
|
||||||
const int XOFF = 4;
|
const int XOFF = 4;
|
||||||
const int MAXCOL = col - 2;
|
const int MAXCOL = col - 3;
|
||||||
int x_opt, len;
|
int x_opt, len;
|
||||||
|
|
||||||
x_opt = x + XOFF + strlen (name);
|
x_opt = x + XOFF + strlen (name);
|
||||||
@ -602,11 +602,11 @@ print_option (WINDOW *win, unsigned x, unsigned y, char *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Print options related to the notify-bar. */
|
/* Print options related to the notify-bar. */
|
||||||
static void
|
static unsigned
|
||||||
notify_print_options (WINDOW *optwin, int col)
|
print_config_options (WINDOW *optwin)
|
||||||
{
|
{
|
||||||
const int XORIG = 3;
|
const int XORIG = 3;
|
||||||
const int YORIG = 4;
|
const int YORIG = 0;
|
||||||
const int YOFF = 3;
|
const int YOFF = 3;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -670,20 +670,32 @@ notify_print_options (WINDOW *optwin, int col)
|
|||||||
opt[i].valnum, opt[i].desc, i + 1);
|
opt[i].valnum, opt[i].desc, i + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
wmove (win[STA].p, 1, 0);
|
return YORIG + NB_OPT * YOFF;
|
||||||
wnoutrefresh (optwin);
|
}
|
||||||
doupdate ();
|
|
||||||
|
static void
|
||||||
|
reinit_conf_win (scrollwin_t *win)
|
||||||
|
{
|
||||||
|
unsigned first_line;
|
||||||
|
|
||||||
|
first_line = win->first_visible_line;
|
||||||
|
wins_scrollwin_delete (win);
|
||||||
|
custom_set_swsiz (win);
|
||||||
|
wins_scrollwin_init (win);
|
||||||
|
wins_show (win->win.p, win->label);
|
||||||
|
win->first_visible_line = first_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Notify-bar configuration. */
|
/* Notify-bar configuration. */
|
||||||
void
|
void
|
||||||
notify_config_bar (void)
|
notify_config_bar (void)
|
||||||
{
|
{
|
||||||
window_t conf_win;
|
scrollwin_t cwin;
|
||||||
char label[BUFSIZ];
|
|
||||||
char *buf;
|
char *buf;
|
||||||
char *number_str =
|
char *number_str =
|
||||||
_("Enter an option number to change its value [Q to quit] ");
|
_("Enter an option number to change its value");
|
||||||
|
char *keys =
|
||||||
|
_("(Press '^P' or '^N' to move up or down, 'Q' to quit)");
|
||||||
char *date_str =
|
char *date_str =
|
||||||
_("Enter the date format (see 'man 3 strftime' for possible formats) ");
|
_("Enter the date format (see 'man 3 strftime' for possible formats) ");
|
||||||
char *time_str =
|
char *time_str =
|
||||||
@ -691,31 +703,43 @@ notify_config_bar (void)
|
|||||||
char *count_str =
|
char *count_str =
|
||||||
_("Enter the number of seconds (0 not to be warned before an appointment)");
|
_("Enter the number of seconds (0 not to be warned before an appointment)");
|
||||||
char *cmd_str = _("Enter the notification command ");
|
char *cmd_str = _("Enter the notification command ");
|
||||||
int ch = 0, change_win = 1;
|
int ch;
|
||||||
|
|
||||||
buf = mem_malloc (BUFSIZ);
|
clear ();
|
||||||
(void)snprintf (label, BUFSIZ, _("notify-bar options"));
|
custom_set_swsiz (&cwin);
|
||||||
|
(void)snprintf (cwin.label, BUFSIZ, _("notification options"));
|
||||||
conf_win.p = 0;
|
wins_scrollwin_init (&cwin);
|
||||||
custom_confwin_init (&conf_win, label);
|
wins_show (cwin.win.p, cwin.label);
|
||||||
|
status_mesg (number_str, keys);
|
||||||
|
cwin.total_lines = print_config_options (cwin.pad.p);
|
||||||
|
wins_scrollwin_display (&cwin);
|
||||||
|
|
||||||
while (ch != 'q')
|
buf = mem_malloc (BUFSIZ);
|
||||||
|
while ((ch = wgetch (win[STA].p)) != 'q')
|
||||||
{
|
{
|
||||||
if (change_win)
|
buf[0] = '\0';
|
||||||
custom_confwin_init (&conf_win, label);
|
|
||||||
status_mesg (number_str, "");
|
|
||||||
notify_print_options (conf_win.p, col);
|
|
||||||
*buf = '\0';
|
|
||||||
ch = wgetch (win[STA].p);
|
|
||||||
|
|
||||||
switch (ch)
|
switch (ch)
|
||||||
{
|
{
|
||||||
case KEY_RESIZE:
|
case KEY_RESIZE:
|
||||||
endwin ();
|
wins_get_config ();
|
||||||
refresh ();
|
wins_reset ();
|
||||||
curs_set (0);
|
reinit_conf_win (&cwin);
|
||||||
delwin (conf_win.p);
|
delwin (win[STA].p);
|
||||||
custom_confwin_init (&conf_win, label);
|
win[STA].p = newwin (win[STA].h, win[STA].w, win[STA].y,
|
||||||
|
win[STA].x);
|
||||||
|
keypad (win[STA].p, TRUE);
|
||||||
|
if (notify_bar ())
|
||||||
|
{
|
||||||
|
notify_reinit_bar ();
|
||||||
|
notify_update_bar ();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CTRL ('N'):
|
||||||
|
wins_scrollwin_down (&cwin, 1);
|
||||||
|
break;
|
||||||
|
case CTRL ('P'):
|
||||||
|
wins_scrollwin_up (&cwin, 1);
|
||||||
break;
|
break;
|
||||||
case '1':
|
case '1':
|
||||||
pthread_mutex_lock (&nbar.mutex);
|
pthread_mutex_lock (&nbar.mutex);
|
||||||
@ -725,7 +749,8 @@ notify_config_bar (void)
|
|||||||
notify_start_main_thread ();
|
notify_start_main_thread ();
|
||||||
else
|
else
|
||||||
notify_stop_main_thread ();
|
notify_stop_main_thread ();
|
||||||
change_win = 1;
|
wins_scrollwin_delete (&cwin);
|
||||||
|
reinit_conf_win (&cwin);
|
||||||
break;
|
break;
|
||||||
case '2':
|
case '2':
|
||||||
status_mesg (date_str, "");
|
status_mesg (date_str, "");
|
||||||
@ -738,7 +763,6 @@ notify_config_bar (void)
|
|||||||
(void)strncpy (nbar.datefmt, buf, strlen (buf) + 1);
|
(void)strncpy (nbar.datefmt, buf, strlen (buf) + 1);
|
||||||
pthread_mutex_unlock (&nbar.mutex);
|
pthread_mutex_unlock (&nbar.mutex);
|
||||||
}
|
}
|
||||||
change_win = 0;
|
|
||||||
break;
|
break;
|
||||||
case '3':
|
case '3':
|
||||||
status_mesg (time_str, "");
|
status_mesg (time_str, "");
|
||||||
@ -751,7 +775,6 @@ notify_config_bar (void)
|
|||||||
(void)strncpy (nbar.timefmt, buf, strlen (buf) + 1);
|
(void)strncpy (nbar.timefmt, buf, strlen (buf) + 1);
|
||||||
pthread_mutex_unlock (&nbar.mutex);
|
pthread_mutex_unlock (&nbar.mutex);
|
||||||
}
|
}
|
||||||
change_win = 0;
|
|
||||||
break;
|
break;
|
||||||
case '4':
|
case '4':
|
||||||
status_mesg (count_str, "");
|
status_mesg (count_str, "");
|
||||||
@ -765,7 +788,6 @@ notify_config_bar (void)
|
|||||||
nbar.cntdwn = atoi (buf);
|
nbar.cntdwn = atoi (buf);
|
||||||
pthread_mutex_unlock (&nbar.mutex);
|
pthread_mutex_unlock (&nbar.mutex);
|
||||||
}
|
}
|
||||||
change_win = 0;
|
|
||||||
break;
|
break;
|
||||||
case '5':
|
case '5':
|
||||||
status_mesg (cmd_str, "");
|
status_mesg (cmd_str, "");
|
||||||
@ -778,18 +800,18 @@ notify_config_bar (void)
|
|||||||
(void)strncpy (nbar.cmd, buf, strlen (buf) + 1);
|
(void)strncpy (nbar.cmd, buf, strlen (buf) + 1);
|
||||||
pthread_mutex_unlock (&nbar.mutex);
|
pthread_mutex_unlock (&nbar.mutex);
|
||||||
}
|
}
|
||||||
change_win = 0;
|
|
||||||
break;
|
break;
|
||||||
case '6':
|
case '6':
|
||||||
dmon.enable = !dmon.enable;
|
dmon.enable = !dmon.enable;
|
||||||
change_win = 1;
|
|
||||||
break;
|
break;
|
||||||
case '7':
|
case '7':
|
||||||
dmon.log = !dmon.log;
|
dmon.log = !dmon.log;
|
||||||
change_win = 1;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
status_mesg (number_str, keys);
|
||||||
|
cwin.total_lines = print_config_options (cwin.pad.p);
|
||||||
|
wins_scrollwin_display (&cwin);
|
||||||
}
|
}
|
||||||
mem_free (buf);
|
mem_free (buf);
|
||||||
delwin (conf_win.p);
|
wins_scrollwin_delete (&cwin);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user