Made 'Erase' button and dialog optional to make email client compatible with non-windows CTK.

This commit is contained in:
oliverschmidt 2010-01-31 21:13:38 +00:00
parent c0932be656
commit de3142c0d4

View file

@ -29,7 +29,7 @@
*
* This file is part of the Contiki desktop environment for the C64.
*
* $Id: email.c,v 1.5 2008/02/08 22:49:54 oliverschmidt Exp $
* $Id: email.c,v 1.6 2010/01/31 21:13:38 oliverschmidt Exp $
*
*/
@ -56,6 +56,12 @@
#define MAIL_HEIGHT 17
#endif
#ifdef EMAIL_CONF_ERASE
#define MAIL_ERASE EMAIL_CONF_ERASE
#else
#define MAIL_ERASE 1
#endif
#if (MAIL_WIDTH - 9) < 39
#define TEXTENTRY_WIDTH (MAIL_WIDTH - 9)
#else
@ -97,9 +103,10 @@ struct ctk_textentry mailtextentry =
{CTK_TEXTENTRY_INPUT(0, 3, MAIL_WIDTH - 1, MAIL_HEIGHT, mail, MAIL_WIDTH - 1, \
ctk_textentry_multiline_input)};
static struct ctk_button sendbutton =
{CTK_BUTTON(0, MAIL_HEIGHT + 4, 4, "Send")};
#if MAIL_ERASE
static struct ctk_button erasebutton =
{CTK_BUTTON(MAIL_WIDTH - 6, MAIL_HEIGHT + 4, 5, "Erase")};
@ -113,6 +120,7 @@ static struct ctk_button eraseyesbutton =
{CTK_BUTTON(4, 4, 3, "Yes")};
static struct ctk_button erasenobutton =
{CTK_BUTTON(18, 4, 2, "No")};
#endif /* MAIL_ERASE */
/* The setup window. */
static struct ctk_window setupwindow;
@ -220,6 +228,7 @@ PROCESS_THREAD(email_process, ev, data)
PROCESS_BEGIN();
#if MAIL_ERASE
/* Create the "Really erase message?" dialog. */
ctk_dialog_new(&erasedialog, 26, 6);
CTK_WIDGET_ADD(&erasedialog, &erasedialoglabel1);
@ -227,6 +236,7 @@ PROCESS_THREAD(email_process, ev, data)
CTK_WIDGET_ADD(&erasedialog, &eraseyesbutton);
CTK_WIDGET_ADD(&erasedialog, &erasenobutton);
CTK_WIDGET_FOCUS(&erasedialog, &erasenobutton);
#endif /* MAIL_ERASE */
/* Create setup window. */
ctk_window_new(&setupwindow, 28, 16, "E-mail setup");
@ -247,7 +257,6 @@ PROCESS_THREAD(email_process, ev, data)
/* Create compose window. */
ctk_window_new(&composewindow, MAIL_WIDTH + 1, MAIL_HEIGHT + 5, "Compose e-mail");
CTK_WIDGET_ADD(&composewindow, &tolabel);
@ -265,7 +274,9 @@ PROCESS_THREAD(email_process, ev, data)
CTK_WIDGET_ADD(&composewindow, &statuslabel);
CTK_WIDGET_ADD(&composewindow, &sendbutton);
#if MAIL_ERASE
CTK_WIDGET_ADD(&composewindow, &erasebutton);
#endif /* MAIL_ERASE */
erase_message();
@ -292,6 +303,7 @@ PROCESS_THREAD(email_process, ev, data)
smtp_send(to, cc, fromaddress, subject, mail, MAIL_WIDTH, MAIL_HEIGHT);
ctk_label_set_text(&statuslabel, "Sending message...");
CTK_WIDGET_REDRAW(&statuslabel);
#if MAIL_ERASE
} else if(w == (struct ctk_widget *)&erasebutton) {
ctk_dialog_open(&erasedialog);
} else if(w == (struct ctk_widget *)&eraseyesbutton) {
@ -299,6 +311,7 @@ PROCESS_THREAD(email_process, ev, data)
ctk_dialog_close();
} else if(w == (struct ctk_widget *)&erasenobutton) {
ctk_dialog_close();
#endif /* MAIL_ERASE */
} else if(w == (struct ctk_widget *)&setupokbutton) {
applyconfig();
ctk_window_close(&setupwindow);