Code to save the calendar default view in the configuration file.

This commit is contained in:
Frederic Culot 2009-10-28 15:15:43 +00:00
parent d678eb411a
commit 758d5ff035
6 changed files with 39 additions and 6 deletions

View File

@ -5,6 +5,14 @@
* src/help.c: description of the scroll keys added to the generic * src/help.c: description of the scroll keys added to the generic
keys help screen keys help screen
* src/custom.c (custom_load_conf): new configuration variable
added to define the default calendar view
* src/calendar.c (calendar_set_view, calendar_get_view): new
functions
* src/io.c (io_save_conf): save the calendar default view
2009-10-16 Frederic Culot <frederic@culot.org> 2009-10-16 Frederic Culot <frederic@culot.org>

View File

@ -1,4 +1,4 @@
/* $calcurse: calendar.c,v 1.29 2009/10/16 15:52:00 culot Exp $ */ /* $calcurse: calendar.c,v 1.30 2009/10/28 15:15:43 culot Exp $ */
/* /*
* Calcurse - text-based organizer * Calcurse - text-based organizer
@ -101,6 +101,18 @@ calendar_view_prev (void)
calendar_view--; calendar_view--;
} }
void
calendar_set_view (int view)
{
calendar_view = (view < 0 || view >= CAL_VIEWS) ? CAL_MONTH_VIEW : view;
}
int
calendar_get_view (void)
{
return (int)calendar_view;
}
/* Thread needed to update current date in calendar. */ /* Thread needed to update current date in calendar. */
/* ARGSUSED0 */ /* ARGSUSED0 */
static void * static void *

View File

@ -1,4 +1,4 @@
/* $calcurse: calendar.h,v 1.17 2009/08/25 14:51:42 culot Exp $ */ /* $calcurse: calendar.h,v 1.18 2009/10/28 15:15:43 culot Exp $ */
/* /*
* Calcurse - text-based organizer * Calcurse - text-based organizer
@ -106,6 +106,8 @@ move_t;
void calendar_view_next (void); void calendar_view_next (void);
void calendar_view_prev (void); void calendar_view_prev (void);
void calendar_set_view (int);
int calendar_get_view (void);
void calendar_start_date_thread (void); void calendar_start_date_thread (void);
void calendar_stop_date_thread (void); void calendar_stop_date_thread (void);
void calendar_set_current_date (void); void calendar_set_current_date (void);

View File

@ -1,4 +1,4 @@
/* $calcurse: custom.c,v 1.44 2009/08/02 09:29:24 culot Exp $ */ /* $calcurse: custom.c,v 1.45 2009/10/28 15:15:44 culot Exp $ */
/* /*
* Calcurse - text-based organizer * Calcurse - text-based organizer
@ -273,6 +273,10 @@ custom_load_conf (conf_t *conf, int background)
conf->skip_progress_bar = fill_config_var (e_conf); conf->skip_progress_bar = fill_config_var (e_conf);
var = 0; var = 0;
break; break;
case CUSTOM_CONF_CALENDAR_DEFAULTVIEW:
calendar_set_view (atoi (e_conf));
var = 0;
break;
case CUSTOM_CONF_WEEKBEGINSONMONDAY: case CUSTOM_CONF_WEEKBEGINSONMONDAY:
if (fill_config_var (e_conf)) if (fill_config_var (e_conf))
calendar_set_first_day_of_week (MONDAY); calendar_set_first_day_of_week (MONDAY);
@ -344,7 +348,9 @@ custom_load_conf (conf_t *conf, int background)
var = CUSTOM_CONF_SKIPSYSTEMDIALOGS; var = CUSTOM_CONF_SKIPSYSTEMDIALOGS;
else if (strncmp (e_conf, "skip_progress_bar=", 18) == 0) else if (strncmp (e_conf, "skip_progress_bar=", 18) == 0)
var = CUSTOM_CONF_SKIPPROGRESSBAR; var = CUSTOM_CONF_SKIPPROGRESSBAR;
else if (strncmp (e_conf, "week_begins_on_monday=", 23) == 0) else if (strncmp (e_conf, "calendar_default_view=", 22) == 0)
var = CUSTOM_CONF_CALENDAR_DEFAULTVIEW;
else if (strncmp (e_conf, "week_begins_on_monday=", 22) == 0)
var = CUSTOM_CONF_WEEKBEGINSONMONDAY; var = CUSTOM_CONF_WEEKBEGINSONMONDAY;
else if (strncmp (e_conf, "color-theme=", 12) == 0) else if (strncmp (e_conf, "color-theme=", 12) == 0)
var = CUSTOM_CONF_COLORTHEME; var = CUSTOM_CONF_COLORTHEME;

View File

@ -1,4 +1,4 @@
/* $calcurse: custom.h,v 1.18 2009/08/02 09:29:24 culot Exp $ */ /* $calcurse: custom.h,v 1.19 2009/10/28 15:15:44 culot Exp $ */
/* /*
* Calcurse - text-based organizer * Calcurse - text-based organizer
@ -66,6 +66,7 @@ enum
CUSTOM_CONF_CONFIRMDELETE, CUSTOM_CONF_CONFIRMDELETE,
CUSTOM_CONF_SKIPSYSTEMDIALOGS, CUSTOM_CONF_SKIPSYSTEMDIALOGS,
CUSTOM_CONF_SKIPPROGRESSBAR, CUSTOM_CONF_SKIPPROGRESSBAR,
CUSTOM_CONF_CALENDAR_DEFAULTVIEW,
CUSTOM_CONF_WEEKBEGINSONMONDAY, CUSTOM_CONF_WEEKBEGINSONMONDAY,
CUSTOM_CONF_COLORTHEME, CUSTOM_CONF_COLORTHEME,
CUSTOM_CONF_LAYOUT, CUSTOM_CONF_LAYOUT,

View File

@ -1,4 +1,4 @@
/* $calcurse: io.c,v 1.78 2009/08/09 16:00:02 culot Exp $ */ /* $calcurse: io.c,v 1.79 2009/10/28 15:15:44 culot Exp $ */
/* /*
* Calcurse - text-based organizer * Calcurse - text-based organizer
@ -883,6 +883,10 @@ io_save_conf (conf_t *conf)
"when saving data will not be displayed\n"); "when saving data will not be displayed\n");
(void)fprintf (fp, "skip_progress_bar=\n"); (void)fprintf (fp, "skip_progress_bar=\n");
(void)fprintf (fp, "%s\n", (conf->skip_progress_bar) ? "yes" : "no"); (void)fprintf (fp, "%s\n", (conf->skip_progress_bar) ? "yes" : "no");
(void)fprintf (fp, "\n# Default calendar view (0)monthly (1)weekly:\n");
(void)fprintf (fp, "calendar_default_view=\n");
(void)fprintf (fp, "%d\n", calendar_get_view ());
(void)fprintf (fp, "\n# If this option is set to yes, " (void)fprintf (fp, "\n# If this option is set to yes, "
"monday is the first day of the week, else it is sunday\n"); "monday is the first day of the week, else it is sunday\n");