Use status_ask_choice() for the export dialog
Remove the export bar and use a simple status_ask_choice() dialog instead. This reduces code complexity and replaces another unnecessary menu by the well-tested dialog feature that is used everywhere else. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
parent
ad78a69192
commit
7733d52f32
@ -289,24 +289,23 @@ static inline void key_generic_import(void)
|
|||||||
|
|
||||||
static inline void key_generic_export()
|
static inline void key_generic_export()
|
||||||
{
|
{
|
||||||
int key;
|
const char *export_msg = _("Export to (i)cal or (p)cal format?");
|
||||||
|
const char *export_choices = _("[ip]");
|
||||||
|
const int nb_export_choices = 2;
|
||||||
|
|
||||||
wins_erase_status_bar();
|
wins_erase_status_bar();
|
||||||
io_export_bar();
|
|
||||||
while ((key = wgetch(win[STA].p)) != 'q') {
|
switch (status_ask_choice(export_msg, export_choices, nb_export_choices)) {
|
||||||
switch (key) {
|
case 1:
|
||||||
case 'I':
|
io_export_data(IO_EXPORT_ICAL);
|
||||||
case 'i':
|
break;
|
||||||
io_export_data(IO_EXPORT_ICAL);
|
case 2:
|
||||||
case 'p':
|
io_export_data(IO_EXPORT_PCAL);
|
||||||
io_export_data(IO_EXPORT_PCAL);
|
break;
|
||||||
break;
|
default: /* User escaped */
|
||||||
}
|
break;
|
||||||
wins_reset();
|
|
||||||
wins_update(FLAG_ALL);
|
|
||||||
wins_erase_status_bar();
|
|
||||||
io_export_bar();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inday = do_storage(0);
|
inday = do_storage(0);
|
||||||
wins_update(FLAG_ALL);
|
wins_update(FLAG_ALL);
|
||||||
}
|
}
|
||||||
|
@ -743,7 +743,6 @@ void io_check_file(char *, int *);
|
|||||||
int io_check_data_files(void);
|
int io_check_data_files(void);
|
||||||
void io_startup_screen(int);
|
void io_startup_screen(int);
|
||||||
void io_export_data(enum export_type);
|
void io_export_data(enum export_type);
|
||||||
void io_export_bar(void);
|
|
||||||
void io_import_data(enum import_type, const char *);
|
void io_import_data(enum import_type, const char *);
|
||||||
struct io_file *io_log_init(void);
|
struct io_file *io_log_init(void);
|
||||||
void io_log_print(struct io_file *, int, const char *);
|
void io_log_print(struct io_file *, int, const char *);
|
||||||
|
23
src/io.c
23
src/io.c
@ -937,29 +937,6 @@ void io_export_data(enum export_type type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draws the export format selection bar */
|
|
||||||
void io_export_bar(void)
|
|
||||||
{
|
|
||||||
int smlspc, spc;
|
|
||||||
|
|
||||||
smlspc = 2;
|
|
||||||
spc = 15;
|
|
||||||
|
|
||||||
custom_apply_attr(win[STA].p, ATTR_HIGHEST);
|
|
||||||
mvwaddstr(win[STA].p, 0, 2, "Q");
|
|
||||||
mvwaddstr(win[STA].p, 1, 2, "I");
|
|
||||||
mvwaddstr(win[STA].p, 0, 2 + spc, "P");
|
|
||||||
custom_remove_attr(win[STA].p, ATTR_HIGHEST);
|
|
||||||
|
|
||||||
mvwaddstr(win[STA].p, 0, 2 + smlspc, _("Exit"));
|
|
||||||
mvwaddstr(win[STA].p, 1, 2 + smlspc, _("Ical"));
|
|
||||||
mvwaddstr(win[STA].p, 0, 2 + spc + smlspc, _("Pcal"));
|
|
||||||
|
|
||||||
wnoutrefresh(win[STA].p);
|
|
||||||
wmove(win[STA].p, 0, 0);
|
|
||||||
wins_doupdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
static FILE *get_import_stream(enum export_type type)
|
static FILE *get_import_stream(enum export_type type)
|
||||||
{
|
{
|
||||||
FILE *stream;
|
FILE *stream;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user