Enlightenment CVS committal Author : kiwi Project : e_modules Module : eveil
Dir : e_modules/eveil Modified Files: Makefile.am TODO e_mod_config.c e_mod_config_alarm.c e_mod_main.c e_mod_main.h eveil.edc Removed Files: module_icon.png Log Message: * snooze * more explicit error messages * menu icons * better vertical orientation support * Add some TODO items :) * Module API update =================================================================== RCS file: /cvs/e/e_modules/eveil/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- Makefile.am 29 May 2006 08:42:20 -0000 1.1 +++ Makefile.am 1 Jun 2006 12:55:25 -0000 1.2 @@ -6,8 +6,7 @@ EDJE_FLAGS = -id . -fd $(srcdir)/fonts filesdir = $(datadir) -files_DATA = module_icon.png \ - module.eap \ +files_DATA = module.eap \ $(wildcard eveil.ed?) \ $(wildcard fonts/*.ttf) =================================================================== RCS file: /cvs/e/e_modules/eveil/TODO,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- TODO 30 May 2006 11:48:16 -0000 1.3 +++ TODO 1 Jun 2006 12:55:25 -0000 1.4 @@ -28,11 +28,15 @@ * memo description * button to set date today and tomorow * set initial size larger (see also inset mode) + * snooze + * more explicit error messages + * menu icons + * better vertical orientation support - - popups - - snooze + - full size popup like exebuf + - eveil logo like an e, instead of alarm clock image, a bit like on e_module + - ? keep alarms on config change ? - exact alarm time ring - - show week days in alarms list - pill mode - handle alarms wich happend when no E on come back - 12h time format =================================================================== RCS file: /cvs/e/e_modules/eveil/e_mod_config.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- e_mod_config.c 30 May 2006 11:48:16 -0000 1.2 +++ e_mod_config.c 1 Jun 2006 12:55:25 -0000 1.3 @@ -85,11 +85,20 @@ for(l=eveil_config->alarms; l; l=evas_list_next(l)) { + Evas_Object *ic; Alarm *al; char buf[1024], bufdate[15]; al = evas_list_data(l); + if (al->state == ALARM_STATE_OFF) + ic = NULL; + else + { + ic = e_icon_add(evas_object_evas_get(cfdata->alarms_ilist)); + if (!eveil_config->theme) e_util_edje_icon_set(ic, THEME_ICON_ALARM_ON); + else e_icon_file_edje_set(ic, eveil_config->theme, THEME_ICON_ALARM_ON); + } if (al->sched.type == ALARM_SCHED_TYPE_DAY) { struct tm *st; @@ -105,8 +114,7 @@ // TODO: show the days of the week snprintf(buf, sizeof(buf), "%s (Weekly %.2d:%.2d)", al->name, al->sched.hour, al->sched.minute); } - - e_widget_ilist_append(cfdata->alarms_ilist, NULL, buf, _cb_alarms_list, cfdata, NULL); + e_widget_ilist_append(cfdata->alarms_ilist, ic, buf, _cb_alarms_list, cfdata, NULL); } e_widget_min_size_get(cfdata->alarms_ilist, &wmw, &wmh); @@ -180,7 +188,7 @@ ob = e_widget_check_add(evas, _("Active"), &(cfdata->alarms_active)); e_widget_frametable_object_append(of, ob, 0, 0, 2, 1, 1, 1, 1, 10); - ob = e_widget_ilist_add(evas, 80, 60, NULL); + ob = e_widget_ilist_add(evas, 16, 16, NULL); e_widget_ilist_selector_set(ob, 1); cfdata->alarms_ilist = ob; eveil_config_refresh_alarms_ilist(cfdata); @@ -254,7 +262,7 @@ { eveil_config->alarms_state = cfdata->alarms_active; eveil_edje_message_send(EDJE_MSG_SEND_ALARM_STATE, - cfdata->alarms_active); + cfdata->alarms_active, NULL); } return 1; @@ -389,13 +397,13 @@ { eveil_config->timer_icon_mode = cfdata->timer_icon_mode; eveil_edje_message_send(EDJE_MSG_SEND_TIMER_ICON_MODE, - cfdata->timer_icon_mode); + cfdata->timer_icon_mode, NULL); } if (eveil_config->timer_detail_mode != cfdata->timer_detail_mode) { eveil_config->timer_detail_mode = cfdata->timer_detail_mode; eveil_edje_message_send(EDJE_MSG_SEND_TIMER_DETAIL_MODE, - cfdata->timer_detail_mode); + cfdata->timer_detail_mode, NULL); } eveil_config->timer_open_popup_default = cfdata->timer_open_popup_default; eveil_config->timer_run_program_default = cfdata->timer_run_program_default; @@ -408,13 +416,13 @@ { eveil_config->alarms_icon_mode = cfdata->alarms_icon_mode; eveil_edje_message_send(EDJE_MSG_SEND_ALARM_ICON_MODE, - cfdata->alarms_icon_mode); + cfdata->alarms_icon_mode, NULL); } if (eveil_config->alarms_detail_mode != cfdata->alarms_detail_mode) { eveil_config->alarms_detail_mode = cfdata->alarms_detail_mode; eveil_edje_message_send(EDJE_MSG_SEND_ALARM_DETAIL_MODE, - cfdata->alarms_detail_mode); + cfdata->alarms_detail_mode, NULL); } eveil_config->alarms_open_popup_default = cfdata->alarms_open_popup_default; eveil_config->alarms_run_program_default = cfdata->alarms_run_program_default; =================================================================== RCS file: /cvs/e/e_modules/eveil/e_mod_config_alarm.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- e_mod_config_alarm.c 30 May 2006 11:48:16 -0000 1.2 +++ e_mod_config_alarm.c 1 Jun 2006 12:55:25 -0000 1.3 @@ -220,7 +220,7 @@ e_widget_frametable_object_append(of, cfdata->sched_gui.date, 3, 5, 1, 1, 1, 1, 1, 1); ob = e_widget_button_add(evas, _("Today"), NULL, _cb_alarm_today, cfdata, NULL); e_widget_frametable_object_append(of, ob, 3, 6, 1, 1, 1, 1, 1, 1); - ob = e_widget_button_add(evas, _("Tomorow"), NULL, _cb_alarm_tomorrow, cfdata, NULL); + ob = e_widget_button_add(evas, _("Tomorrow"), NULL, _cb_alarm_tomorrow, cfdata, NULL); e_widget_frametable_object_append(of, ob, 3, 7, 1, 1, 1, 1, 1, 1); e_widget_list_object_append(o, of, 1, 1, 0.5); @@ -230,6 +230,7 @@ _common_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) { Alarm *al; + int error; al = eveil_alarm_add(cfdata->state, cfdata->name, cfdata->sched.type, @@ -246,14 +247,44 @@ cfdata->description, cfdata->open_popup, cfdata->run_program, - cfdata->program); + cfdata->program, &error); if (!al) { char buf[4096]; - snprintf(buf, sizeof(buf), - "<hilight>Alarm not added !</hilight><br>" - "information / schedule you gave are not correct"); + switch (error) + { + case ALARM_ADD_ERROR_UNKNOWN: + snprintf(buf, sizeof(buf), + "<hilight>Error, The alarm was not added !</hilight><br><br>" + "There is an error in the informations / schedule of your alarm"); + break; + case ALARM_ADD_ERROR_NAME: + snprintf(buf, sizeof(buf), + "<hilight>Error, The alarm was not added !</hilight><br><br>" + "You have to enter a name for the alarm"); + break; + case ALARM_ADD_ERROR_SCHED_WEEK: + snprintf(buf, sizeof(buf), + "<hilight>Error, The alarm was not added !</hilight><br><br>" + "You have to select at least one day in the week"); + break; + case ALARM_ADD_ERROR_SCHED_DAY: + snprintf(buf, sizeof(buf), + "<hilight>Error, The alarm was not added !</hilight><br><br>" + "The date you entered for the alarm has incorrect syntax<br><br>" + "You have to respect this format :<br>" + " YYYY/MM/DD<br>" + "YYYY is the year on 4 numbers<br>" + "MM is the month on 2 numbers<br>" + "DD is the day on 2 numbers<br>"); + break; + case ALARM_ADD_ERROR_SCHED_BEFORE: + snprintf(buf, sizeof(buf), + "<hilight>Error, The alarm was not added !</hilight><br><br>" + "The date you entered is before now"); + break; + } e_module_dialog_show(_("Eveil Module Error"), buf); return 0; } @@ -383,6 +414,7 @@ { E_Config_Dialog *cfd; E_Config_Dialog_Data *cfdata; + char buf[4096]; cfd = data; cfdata = data2; @@ -390,7 +422,17 @@ if(!_basic_apply_data(cfd, cfdata)) return; - eveil_alarm_test(cfdata->al); + if (eveil_alarm_ring(cfdata->al, 1)) + { + snprintf(buf, sizeof(buf), + "<hilight>Alarm test SUCCEED !</hilight>"); + } + else + { + snprintf(buf, sizeof(buf), + "<hilight>Alarm test FAILED !</hilight>"); + } + e_module_dialog_show(_("Eveil Module Test Report"), buf); } static void _cb_alarm_today(void *data, void *data2) =================================================================== RCS file: /cvs/e/e_modules/eveil/e_mod_main.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- e_mod_main.c 30 May 2006 11:48:16 -0000 1.4 +++ e_mod_main.c 1 Jun 2006 12:55:25 -0000 1.5 @@ -5,7 +5,7 @@ #include "e_mod_main.h" #include <config.h> -#define ALARM_ADD_FAIL { eveil_alarm_del(al); return NULL; } +#define ALARM_ADD_FAIL(errcode) if (al) eveil_alarm_del(al); if (error) *error = errcode; return NULL; /* module requirements */ EAPI E_Module_Api e_modapi = @@ -37,17 +37,26 @@ Evas_Object *obj; }; +static void _alarm_check_state(void); static int _alarm_check_date(Alarm *al, int strict); +static void _alarm_snooze(Alarm *al); +static void _alarm_cb_dialog_snooze_ok(void *data, E_Dialog *dia); +static void _alarm_cb_dialog_snooze_cancel(void *data, E_Dialog *dia); +static void _alarm_dialog_snooze_delete(E_Dialog *dia, Alarm *al); static double _epoch_find_date(char *date, int hour, int minute); static double _epoch_find_next(int day_monday, int day_tuesday, int day_wenesday, int day_thursday, int day_friday, int day_saturday, int day_sunday, int hour, int minute); static void _button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info); static void _menu_cb_deactivate_post(void *data, E_Menu *m); +static void _menu_cb_alarm_snooze(void *data, E_Menu *m, E_Menu_Item *mi); static void _menu_cb_alarm_add(void *data, E_Menu *m, E_Menu_Item *mi); +static void _menu_cb_timer_start(void *data, E_Menu *mn, E_Menu_Item *mi); +static void _menu_cb_timer_stop(void *data, E_Menu *mn, E_Menu_Item *mi); static void _menu_cb_configure(void *data, E_Menu *m, E_Menu_Item *mi); static void _cb_edje_messages(void *data, Evas_Object *obj, Edje_Message_Type type, int id, void *msg); static int _cb_timer_etimer(void *data); static int _cb_timer_s_etimer(void *data); static int _cb_alarms_ring_etimer(void *data); +static int _cb_alarm_snooze_time(void *data); static E_Config_DD *_conf_edd = NULL; static E_Config_DD *_alarms_edd = NULL; @@ -70,9 +79,19 @@ o = edje_object_add(gc->evas); + /* FIXME: should be tested in modapi_init */ snprintf(buf, sizeof(buf), "%s/eveil.edj", e_module_dir_get(eveil_config->module)); - if (!e_theme_edje_object_set(o, "base/theme/modules/eveil", "modules/eveil/main")) - edje_object_file_set(o, buf, "modules/eveil/main"); + if (e_theme_edje_object_set(o, THEME_IN_E, THEME_MAIN)) + { + if (eveil_config->theme) + E_FREE(eveil_config->theme); + } + else + { + edje_object_file_set(o, buf, THEME_MAIN); + if (!eveil_config->theme) + eveil_config->theme = strdup(buf); + } edje_object_message_handler_set(o, _cb_edje_messages, inst); @@ -89,19 +108,19 @@ if (eveil_config->timer_icon_mode) eveil_edje_message_send(EDJE_MSG_SEND_TIMER_ICON_MODE, - eveil_config->timer_icon_mode); + eveil_config->timer_icon_mode, NULL); if (eveil_config->timer_detail_mode) eveil_edje_message_send(EDJE_MSG_SEND_TIMER_DETAIL_MODE, - eveil_config->timer_detail_mode); + eveil_config->timer_detail_mode, NULL); if (eveil_config->alarms_icon_mode) eveil_edje_message_send(EDJE_MSG_SEND_ALARM_ICON_MODE, - eveil_config->alarms_icon_mode); + eveil_config->alarms_icon_mode, NULL); if (eveil_config->alarms_detail_mode) eveil_edje_message_send(EDJE_MSG_SEND_ALARM_DETAIL_MODE, - eveil_config->alarms_detail_mode); + eveil_config->alarms_detail_mode, NULL); if (eveil_config->alarms_state) eveil_edje_message_send(EDJE_MSG_SEND_ALARM_STATE, - eveil_config->alarms_state); + eveil_config->alarms_state, NULL); eveil_edje_refresh_alarm(); @@ -123,20 +142,39 @@ _gc_orient(E_Gadcon_Client *gcc) { Instance *inst; + int w, h; + w = 40; + h = 16; + inst = gcc->data; - if (eveil_config->alarms_icon_mode || - eveil_config->timer_icon_mode) + /* vertical */ + switch (gcc->gadcon->orient) { - e_gadcon_client_aspect_set(gcc, 40, 16); - e_gadcon_client_min_size_set(gcc, 40, 16); - } - else + case E_GADCON_ORIENT_VERT: + case E_GADCON_ORIENT_LEFT: + case E_GADCON_ORIENT_RIGHT: + case E_GADCON_ORIENT_CORNER_LT: + case E_GADCON_ORIENT_CORNER_RT: + case E_GADCON_ORIENT_CORNER_LB: + case E_GADCON_ORIENT_CORNER_RB: + w = 16; + h = 16; + default: + break; + } + + /* no icon */ + if ( !eveil_config->alarms_detail_mode && + !eveil_config->timer_detail_mode ) { - e_gadcon_client_aspect_set(gcc, 16, 16); - e_gadcon_client_min_size_set(gcc, 16, 16); + w = 16; + h = 16; } + + e_gadcon_client_aspect_set(gcc, w, h); + e_gadcon_client_min_size_set(gcc, w, h); } static char * @@ -163,14 +201,18 @@ * Eveil functions */ -Alarm *eveil_alarm_add(int state, char *name, int type, char *date, int day_monday, int day_tuesday, int day_wenesday, int day_thursday, int day_friday, int day_saturday, int day_sunday, int hour, int minute, int autoremove, char *description, int open_popup, int run_program, char *program) +Alarm *eveil_alarm_add(int state, char *name, int type, char *date, int day_monday, int day_tuesday, int day_wenesday, int day_thursday, int day_friday, int day_saturday, int day_sunday, int hour, int minute, int autoremove, char *description, int open_popup, int run_program, char *program, int *error) { - Alarm *al; + Alarm *al = NULL; if (!name) - return NULL; + { + ALARM_ADD_FAIL(ALARM_ADD_ERROR_NAME); + } if (!strlen(name)) - return NULL; + { + ALARM_ADD_FAIL(ALARM_ADD_ERROR_NAME); + } al = E_NEW(Alarm, 1); @@ -181,10 +223,14 @@ { case ALARM_SCHED_TYPE_DAY: if ( !(al->sched.date_epoch = _epoch_find_date(date, hour, minute)) ) - ALARM_ADD_FAIL - if (al->sched.date_epoch <= ecore_time_get()) - ALARM_ADD_FAIL - break; + { + ALARM_ADD_FAIL(ALARM_ADD_ERROR_SCHED_DAY); + } + if (al->sched.date_epoch <= ecore_time_get()) + { + ALARM_ADD_FAIL(ALARM_ADD_ERROR_SCHED_BEFORE); + } + break; case ALARM_SCHED_TYPE_WEEK: al->sched.day_monday = day_monday; @@ -202,10 +248,15 @@ day_saturday, day_sunday, hour, minute)) ) - ALARM_ADD_FAIL - } + { + ALARM_ADD_FAIL(ALARM_ADD_ERROR_SCHED_WEEK); + } + break; + } al->sched.hour = hour; al->sched.minute = minute; + al->snooze.minute = ALARM_SNOOZE_MINUTE_DEFAULT; + al->snooze.hour = ALARM_SNOOZE_HOUR_DEFAULT; al->autoremove = autoremove; if (description) al->description = evas_stringshare_add(description); @@ -216,7 +267,9 @@ al->program = evas_stringshare_add(program); if (!_alarm_check_date(al, 1)) - ALARM_ADD_FAIL + { + ALARM_ADD_FAIL(ALARM_ADD_ERROR_UNKNOWN); + } if (!eveil_config->alarms_ring_etimer) eveil_config->alarms_ring_etimer = ecore_timer_add(ALARMS_RING_TIME, @@ -234,6 +287,10 @@ evas_stringshare_del(al->description); if (al->program) evas_stringshare_del(al->program); + if (al->snooze.dia) + e_object_del(E_OBJECT(al->snooze.dia)); + if (al->snooze.etimer) + ecore_timer_del(al->snooze.etimer); eveil_config->alarms = evas_list_remove(eveil_config->alarms, al); free(al); @@ -241,26 +298,27 @@ ecore_timer_del(eveil_config->alarms_ring_etimer); } -int eveil_alarm_test(Alarm *al) +int eveil_alarm_ring(Alarm *al, int test) { char buf[4096]; + int ret = 1; eveil_config->alarms_state = ALARMS_STATE_RINGING; + if (!test) + al->state = ALARM_STATE_RINGING; eveil_edje_message_send(EDJE_MSG_SEND_ALARM_STATE, - ALARMS_STATE_RINGING); + ALARMS_STATE_RINGING, NULL); // TODO: real popups if ((al->open_popup == ALARM_OPEN_POPUP_YES) || (al->open_popup == ALARM_OPEN_POPUP_PARENT && eveil_config->alarms_open_popup_default)) { - char buf[4096]; - snprintf(buf, sizeof(buf), - "<hilight>(Test) %s !</hilight>" - "<br><br>", - al->name); - e_module_dialog_show(_("Eveil Module Popup (Test)"), buf); + "<hilight>Alarm : %s</hilight><br><br>" + "%s", + al->name, (al->description) ? al->description : "" ); + e_module_dialog_show(_("Eveil Module Popup"), buf); } if ((al->run_program == ALARM_RUN_PROGRAM_OWN) || @@ -280,28 +338,21 @@ ECORE_EXE_USE_SH, NULL); } if (exe > 0) - { - ecore_exe_free(exe); - snprintf(buf, sizeof(buf), - "<hilight>Success !</hilight><br>" - "Youre program has been launch :)"); - } + ecore_exe_free(exe); else { snprintf(buf, sizeof(buf), - "<hilight>Failed !</hilight><br>" + "<hilight>Failed !</hilight><br><br>" "Eveil couln't launch the program you specified"); + e_module_dialog_show(_("Eveil Module Error"), buf); + ret = 0; } } - else - { - snprintf(buf, sizeof(buf), - "<hilight>Success !</hilight>"); - } - - e_module_dialog_show(_("Eveil Module Test Report"), buf); - return 1; + _alarm_check_date(al, 0); + eveil_edje_refresh_alarm(); + + return ret; } void eveil_timer_start(void) @@ -318,32 +369,34 @@ eveil_config->timer_state = TIMER_STATE_ON; eveil_edje_message_send(EDJE_MSG_SEND_TIMER_STATE, - eveil_config->timer_state); + eveil_config->timer_state, NULL); } void eveil_timer_stop(void) { - if (eveil_config->timer_state == TIMER_STATE_OFF) - return; - eveil_config->timer_state = TIMER_STATE_OFF; - eveil_edje_message_send(EDJE_MSG_SEND_TIMER_STATE, - TIMER_STATE_OFF); ecore_timer_del(eveil_config->timer_etimer); ecore_timer_del(eveil_config->timer_s_etimer); - eveil_config->timer_etimer = NULL; + eveil_config->timer_s_etimer = NULL; + + eveil_edje_message_send(EDJE_MSG_SEND_TIMER_STATE, + TIMER_STATE_OFF, NULL); } -void eveil_edje_message_send(int id, int message) +void eveil_edje_message_send(int id, int message, void *data) { Evas_List *l; + Instance *dont; + dont = data; for (l=eveil_config->instances; l; l=evas_list_next(l)) { Instance *inst; inst = evas_list_data(l); + if (inst == dont) + continue; edje_object_message_send(inst->obj, EDJE_MESSAGE_INT, id, &message); } @@ -437,14 +490,15 @@ return 0; else { - if ((al->autoremove == ALARM_AUTOREMOVE_YES) || - (al->autoremove == ALARM_AUTOREMOVE_PARENT && - eveil_config->alarms_date_autoremove_default == 1)) - eveil_alarm_del(al); - else - al->state = ALARM_STATE_OFF; - if (eveil_config->config_dialog) - eveil_config_refresh_alarms_ilist(eveil_config->config_dialog->cfdata); + int delete = ((al->autoremove == ALARM_AUTOREMOVE_YES) || + (al->autoremove == ALARM_AUTOREMOVE_PARENT && + eveil_config->alarms_date_autoremove_default == 1)); + if ((al->state == ALARM_STATE_ON) || + (al->state == ALARM_STATE_OFF)) + { + if (delete) eveil_alarm_del(al); + else al->state = ALARM_STATE_OFF; + } } } break; @@ -475,9 +529,107 @@ break; } + if (eveil_config->config_dialog) + eveil_config_refresh_alarms_ilist(eveil_config->config_dialog->cfdata); + return 1; } +static void +_alarm_check_state(void) +{ + Evas_List *l; + Alarm *al; + + for(l=eveil_config->alarms; l; l=evas_list_next(l)) + { + al = evas_list_data(l); + if ((al->state >= ALARM_STATE_RINGING) && + (al->sched.type == ALARM_SCHED_TYPE_DAY)) + { + if ( ((al->autoremove == ALARM_AUTOREMOVE_YES) || + (al->autoremove == ALARM_AUTOREMOVE_PARENT && + eveil_config->alarms_date_autoremove_default == 1)) ) + eveil_alarm_del(al); + else + al->state = ALARM_STATE_OFF; + } + } +} + +static void +_alarm_snooze(Alarm *al) +{ + E_Dialog *dia; + Evas_Object *o, *ob; + Evas *evas; + char buf[4096]; + int w, h; + + if (al->snooze.dia) + return; + + dia = e_dialog_new(e_container_current_get(e_manager_current_get())); + if (!dia) + return; + evas = e_win_evas_get(dia->win); + + snprintf(buf, sizeof(buf), "Snooze %s", al->name); + e_dialog_title_set(dia, buf); + + o = e_widget_list_add(evas, 0, 0); + ob = e_widget_slider_add(evas, 1, 0, _("%1.0f hours"), 0.0, 24.0, 1.0, 0, + NULL, &(al->snooze.hour), 100); + e_widget_list_object_append(o, ob, 0, 0, 1.0); + ob = e_widget_slider_add(evas, 1, 0, _("%1.0f minutes"), 0.0, 60.0, 1.0, 0, + NULL, &(al->snooze.minute), 100); + e_widget_list_object_append(o, ob, 0, 0, 1.0); + + e_widget_min_size_get(o, &w, &h); + e_dialog_content_set(dia, o, w, h); + + e_dialog_button_add(dia, _("Ok"), NULL, _alarm_cb_dialog_snooze_ok, al); + e_dialog_button_add(dia, _("Close"), NULL, _alarm_cb_dialog_snooze_cancel, al); + + al->snooze.dia = dia; + e_win_centered_set(dia->win, 1); + e_dialog_show(dia); +} + +static void +_alarm_cb_dialog_snooze_ok(void *data, E_Dialog *dia) +{ + Alarm *al; + int time; + + al = data; + time = al->snooze.hour*3600 + al->snooze.minute*60; + if (!time) + return; + if (al->snooze.etimer) + ecore_timer_del(al->snooze.etimer); + al->state = ALARM_STATE_SNOOZED; + al->snooze.remember = 1; + al->snooze.etimer = ecore_timer_add(time, _cb_alarm_snooze_time, al); + _alarm_dialog_snooze_delete(dia, al); +} + +static void +_alarm_cb_dialog_snooze_cancel(void *data, E_Dialog *dia) +{ + Alarm *al; + + al = data; + _alarm_dialog_snooze_delete(dia, al); +} + +static void +_alarm_dialog_snooze_delete(E_Dialog *dia, Alarm *al) +{ + e_object_del(E_OBJECT(dia)); + al->snooze.dia = NULL; +} + static double _epoch_find_date(char *date, int hour, int minute) { @@ -527,6 +679,9 @@ day_week[4] = day_thursday; day_week[5] = day_friday; day_week[6] = day_saturday; + if (!(day_week[0] || day_week[1] || day_week[2] || day_week[3] || + day_week[4] || day_week[5] || day_week[6])) + return 0; t = time(NULL); ts_today = localtime(&t); @@ -577,14 +732,74 @@ E_Menu *mn; E_Menu_Item *mi; int cx, cy, cw, ch; + int nb_snoozed = 0; mn = e_menu_new(); e_menu_post_deactivate_callback_set(mn, _menu_cb_deactivate_post, inst); eveil_config->menu = mn; + /* snooze menu */ + if (eveil_config->alarms_state == ALARMS_STATE_RINGING) + { + Evas_List *l; + + for (l=eveil_config->alarms; l; l=evas_list_next(l)) + { + Alarm *al; + al = evas_list_data(l); + if (al->state == ALARM_STATE_RINGING) + { + char buf[30]; + snprintf(buf, sizeof(buf), "Snooze %s", al->name); + mi = e_menu_item_new(mn); + e_menu_item_label_set(mi, buf); + e_menu_item_callback_set(mi, _menu_cb_alarm_snooze, al); + if (!eveil_config->theme) e_util_menu_item_edje_icon_set(mi, THEME_ICON_SNOOZE); + else e_menu_item_icon_edje_set(mi, eveil_config->theme, THEME_ICON_SNOOZE); + if (al->snooze.remember) + { + snprintf(buf, sizeof(buf), "Snooze %.14s of %.2d:%.2d", + al->name, al->snooze.hour, al->snooze.minute); + mi = e_menu_item_new(mn); + e_menu_item_label_set(mi, buf); + e_menu_item_callback_set(mi, _menu_cb_alarm_snooze, al); + } + nb_snoozed = 1; + } + } + } + + if (!nb_snoozed) + { + mi = e_menu_item_new(mn); + e_menu_item_label_set(mi, _("Snooze (No alarm to delay)")); + if (!eveil_config->theme) e_util_menu_item_edje_icon_set(mi, THEME_ICON_SNOOZE); + else e_menu_item_icon_edje_set(mi, eveil_config->theme, THEME_ICON_SNOOZE); + } + mi = e_menu_item_new(mn); + e_menu_item_separator_set(mi, 1); mi = e_menu_item_new(mn); e_menu_item_label_set(mi, _("Add an alarm")); e_menu_item_callback_set(mi, _menu_cb_alarm_add, NULL); + if (!eveil_config->theme) e_util_menu_item_edje_icon_set(mi, THEME_ICON_ALARM_ON); + else e_menu_item_icon_edje_set(mi, eveil_config->theme, THEME_ICON_ALARM_ON); + mi = e_menu_item_new(mn); + e_menu_item_separator_set(mi, 1); + mi = e_menu_item_new(mn); + if (eveil_config->timer_state == TIMER_STATE_OFF) + { + e_menu_item_label_set(mi, _("Start the timer")); + e_menu_item_callback_set(mi, _menu_cb_timer_start, NULL); + if (!eveil_config->theme) e_util_menu_item_edje_icon_set(mi, THEME_ICON_TIMER_ON); + else e_menu_item_icon_edje_set(mi, eveil_config->theme, THEME_ICON_TIMER_ON); + } + else + { + e_menu_item_label_set(mi, _("Stop the timer")); + e_menu_item_callback_set(mi, _menu_cb_timer_stop, NULL); + if (!eveil_config->theme) e_util_menu_item_edje_icon_set(mi, THEME_ICON_TIMER_OFF); + else e_menu_item_icon_edje_set(mi, eveil_config->theme, THEME_ICON_TIMER_OFF); + } mi = e_menu_item_new(mn); e_menu_item_separator_set(mi, 1); mi = e_menu_item_new(mn); @@ -614,12 +829,33 @@ } static void +_menu_cb_alarm_snooze(void *data, E_Menu *m, E_Menu_Item *mi) +{ + Alarm *al; + + al = data; + _alarm_snooze(al); +} + +static void _menu_cb_alarm_add(void *data, E_Menu *m, E_Menu_Item *mi) { eveil_config_alarm(NULL); } static void +_menu_cb_timer_start(void *data, E_Menu *mn, E_Menu_Item *mi) +{ + eveil_timer_start(); +} + +static void +_menu_cb_timer_stop(void *data, E_Menu *mn, E_Menu_Item *mi) +{ + eveil_timer_stop(); +} + +static void _menu_cb_configure(void *data, E_Menu *m, E_Menu_Item *mi) { if (!eveil_config) return; @@ -627,6 +863,7 @@ eveil_config_module(); } + static void _cb_edje_messages(void *data, Evas_Object *obj, Edje_Message_Type type, int id, void *msg) { @@ -649,7 +886,8 @@ ecore_timer_add(ALARMS_RING_TIME, _cb_alarms_ring_etimer, NULL); - + + _alarm_check_state(); } else { @@ -660,7 +898,8 @@ } } eveil_edje_message_send(EDJE_MSG_SEND_ALARM_STATE, - eveil_config->alarms_state); + eveil_config->alarms_state, + inst); } break; @@ -674,7 +913,8 @@ else eveil_timer_stop(); eveil_edje_message_send(EDJE_MSG_SEND_TIMER_STATE, - eveil_config->timer_state); + eveil_config->timer_state, + inst); } break; } @@ -685,7 +925,7 @@ { eveil_config->timer_state = TIMER_STATE_RINGING; eveil_edje_message_send(EDJE_MSG_SEND_TIMER_STATE, - TIMER_STATE_RINGING); + TIMER_STATE_RINGING, NULL); eveil_config->timer_s_time = eveil_config->timer_time; eveil_edje_refresh_timer(); @@ -695,9 +935,8 @@ char buf[4096]; snprintf(buf, sizeof(buf), - "<hilight>Timer elapsed !</hilight>" - "Time for pastas :D<br><br>" - "Real popups like in dEvian comming soon"); + "<hilight>Timer elapsed !</hilight><br><br>" + "Time for pastas :D"); e_module_dialog_show(_("Eveil Module Popup"), buf); } @@ -746,63 +985,34 @@ Alarm *al; al = evas_list_data(l); - if (al->state == ALARM_STATE_OFF) + if (!(al->state == ALARM_STATE_ON)) continue; if (al->sched.type == ALARM_SCHED_TYPE_DAY) t = al->sched.date_epoch; else t = al->sched.day_next_epoch; - if (t <= tt) - { - eveil_config->alarms_state = ALARMS_STATE_RINGING; - eveil_edje_message_send(EDJE_MSG_SEND_ALARM_STATE, - ALARMS_STATE_RINGING); - - // TODO: real popups - if ((al->open_popup == ALARM_OPEN_POPUP_YES) || - (al->open_popup == ALARM_OPEN_POPUP_PARENT && - eveil_config->alarms_open_popup_default)) - { - char buf[4096]; - - snprintf(buf, sizeof(buf), - "<hilight>%s !</hilight>" - "<br><br>" - "Real popups like in dEvian comming soon", - al->name); - e_module_dialog_show(_("Eveil Module Popup"), buf); - } - - if ((al->run_program == ALARM_RUN_PROGRAM_OWN) || - (al->run_program == ALARM_RUN_PROGRAM_PARENT && - eveil_config->alarms_run_program_default)) - { - Ecore_Exe *exe; - - if (al->run_program == ALARM_RUN_PROGRAM_PARENT) - { - exe = ecore_exe_pipe_run(eveil_config->alarms_program_default, - ECORE_EXE_USE_SH, NULL); - } - else - { - exe = ecore_exe_pipe_run(al->program, - ECORE_EXE_USE_SH, NULL); - } - if (exe > 0) - ecore_exe_free(exe); - } - - _alarm_check_date(al, 0); - eveil_edje_refresh_alarm(); - } + eveil_alarm_ring(al, 0); } return 1; } +static int +_cb_alarm_snooze_time(void *data) +{ + Alarm *al; + + al = data; + al->snooze.etimer = NULL; + + eveil_alarm_ring(al, 0); + + return 0; +} + + /* * Module functions */ @@ -810,6 +1020,8 @@ EAPI void * e_modapi_init(E_Module *m) { + char buf[4096]; + _alarms_edd = E_CONFIG_DD_NEW("Eveil_Alarm", Alarm); #undef T #undef D @@ -829,6 +1041,9 @@ E_CONFIG_VAL(D, T, sched.hour, SHORT); E_CONFIG_VAL(D, T, sched.minute, SHORT); E_CONFIG_VAL(D, T, sched.day_next_epoch, DOUBLE); + E_CONFIG_VAL(D, T, snooze.hour, SHORT); + E_CONFIG_VAL(D, T, snooze.minute, SHORT); + E_CONFIG_VAL(D, T, snooze.remember, SHORT); E_CONFIG_VAL(D, T, autoremove, SHORT); E_CONFIG_VAL(D, T, description, STR); E_CONFIG_VAL(D, T, open_popup, SHORT); @@ -860,10 +1075,8 @@ { if (eveil_config->config_version < CONFIG_VERSION) { - char buf[4096]; - snprintf(buf, sizeof(buf), - _("<hilight>Configuration Upgraded</hilight><br><br>" + _("<hilight>Eveil module : Configuration Upgraded</hilight><br><br>" "Your configuration of eveil module<br>" "has been upgraded<br>" "Your settings were removed<br>" @@ -876,10 +1089,8 @@ { if (eveil_config->config_version > CONFIG_VERSION) { - char buf[4096]; - snprintf(buf, sizeof(buf), - _("<hilight>Configuration Downgraded</hilight><br><br>" + _("<hilight>Eveil module : Configuration Downgraded</hilight><br><br>" "Your configuration of Eveil module<br>" "has been downgraded<br>" "Your settings were removed<br>" @@ -968,6 +1179,8 @@ if (eveil_config->alarms_program_default) evas_stringshare_del(eveil_config->alarms_program_default); + if (eveil_config->theme) + free(eveil_config->theme); if (eveil_config->config_dialog) e_object_del(E_OBJECT(eveil_config->config_dialog)); if (eveil_config->menu) @@ -988,16 +1201,6 @@ e_modapi_save(E_Module *m) { e_config_domain_save("module.eveil", _conf_edd, eveil_config); - return 1; -} - -EAPI int -e_modapi_info(E_Module *m) -{ - char buf[4096]; - - snprintf(buf, sizeof(buf), "%s/module_icon.png", e_module_dir_get(m)); - m->icon_file = strdup(buf); return 1; } =================================================================== RCS file: /cvs/e/e_modules/eveil/e_mod_main.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- e_mod_main.h 30 May 2006 11:48:16 -0000 1.2 +++ e_mod_main.h 1 Jun 2006 12:55:25 -0000 1.3 @@ -4,7 +4,7 @@ #ifndef E_MOD_MAIN_H #define E_MOD_MAIN_H -#define CONFIG_VERSION 6 +#define CONFIG_VERSION 7 #define TIME_FORMAT_12 0 #define TIME_FORMAT_24 1 @@ -15,7 +15,7 @@ #define TIMER_STATE_RINGING 2 #define TIMER_TIME_MIN 1 #define TIMER_TIME_MAX (3600*24) -#define TIMER_TIME_DEFAULT (60*11) +#define TIMER_TIME_DEFAULT (60*9) #define TIMER_ICON_MODE_OFF 0 #define TIMER_ICON_MODE_ON 1 #define TIMER_ICON_MODE_ONGO 2 @@ -45,6 +45,8 @@ #define ALARM_STATE_OFF 0 #define ALARM_STATE_ON 1 +#define ALARM_STATE_RINGING 2 +#define ALARM_STATE_SNOOZED 3 #define ALARM_SCHED_TYPE_DAY 0 #define ALARM_SCHED_TYPE_WEEK 1 #define ALARM_SCHED_TYPE_DEFAULT 1 @@ -58,10 +60,25 @@ #define ALARM_RUN_PROGRAM_PARENT 1 #define ALARM_RUN_PROGRAM_OWN 2 #define ALARM_RUN_PROGRAM_DEFAULT 1 +#define ALARM_SNOOZE_HOUR_DEFAULT 0 +#define ALARM_SNOOZE_MINUTE_DEFAULT 15 +#define ALARM_ADD_ERROR_UNKNOWN 0 +#define ALARM_ADD_ERROR_NAME 1 +#define ALARM_ADD_ERROR_SCHED_WEEK 2 +#define ALARM_ADD_ERROR_SCHED_DAY 3 +#define ALARM_ADD_ERROR_SCHED_BEFORE 4 #define RING_TEST_ALARM 0 #define RING_TEST_TIMER 1 +#define THEME_IN_E "base/theme/modules/eveil" +#define THEME_MAIN "modules/eveil/main" +#define THEME_ICON_SNOOZE "modules/eveil/icon/alarm/snooze" +#define THEME_ICON_ALARM_ON "modules/eveil/icon/alarm/on" +#define THEME_ICON_ALARM_OFF "modules/eveil/icon/alarm/off" +#define THEME_ICON_TIMER_ON "modules/eveil/icon/timer/on" +#define THEME_ICON_TIMER_OFF "modules/eveil/icon/timer/off" + #define EDJE_MSG_RECV_ALARM_STATE 0 #define EDJE_MSG_RECV_TIMER_STATE 1 @@ -103,6 +120,15 @@ } sched; int autoremove; + struct + { + int hour; + int minute; + int remember; + E_Dialog *dia; + Ecore_Timer *etimer; + } snooze; + const char *description; int open_popup; int run_program; @@ -135,6 +161,7 @@ const char *alarms_program_default; int config_version; + char *theme; E_Module *module; E_Config_Dialog *config_dialog; Evas_List *instances; @@ -142,21 +169,20 @@ }; EAPI extern E_Module_Api e_modapi; - +extern Config *eveil_config; EAPI void *e_modapi_init (E_Module *m); EAPI int e_modapi_shutdown (E_Module *m); EAPI int e_modapi_save (E_Module *m); -EAPI int e_modapi_info (E_Module *m); EAPI int e_modapi_about (E_Module *m); EAPI int e_modapi_config (E_Module *m); -Alarm *eveil_alarm_add(int state, char *name, int type, char *date, int day_monday, int day_tuesday, int day_wenesday, int day_thursday, int day_friday, int day_saturday, int day_sunday, int hour, int minute, int autoremove, char *description, int open_popup, int run_program, char *program); +Alarm *eveil_alarm_add(int state, char *name, int type, char *date, int day_monday, int day_tuesday, int day_wenesday, int day_thursday, int day_friday, int day_saturday, int day_sunday, int hour, int minute, int autoremove, char *description, int open_popup, int run_program, char *program, int *error); void eveil_alarm_del(Alarm *al); -int eveil_alarm_test(Alarm *al); +int eveil_alarm_ring(Alarm *al, int test); void eveil_timer_start(void); void eveil_timer_stop(void); -void eveil_edje_message_send(int id, int message); +void eveil_edje_message_send(int id, int message, void *data); void eveil_edje_text_set(char *part, char *text); void eveil_edje_refresh_alarm(void); void eveil_edje_refresh_timer(void); @@ -164,8 +190,5 @@ void eveil_config_module(void); void eveil_config_refresh_alarms_ilist(E_Config_Dialog_Data *cfdata); void eveil_config_alarm(Alarm *al); - -extern Config *eveil_config; - #endif =================================================================== RCS file: /cvs/e/e_modules/eveil/eveil.edc,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- eveil.edc 30 May 2006 11:48:16 -0000 1.2 +++ eveil.edc 1 Jun 2006 12:55:25 -0000 1.3 @@ -1,6 +1,6 @@ /* Enlightenment Eveil Module theme */ -#define BASE_BORDER 4 +#define BASE_BORDER 2 #define SPLIT_OFFSET 0 #define ALARM_STATE_OFF 0 @@ -91,6 +91,7 @@ { image: "images/alarm_enabled.png" COMP; image: "images/alarm_disabled.png" COMP; + image: "images/alarm_snooze.png" COMP; image: "images/timer_enabled.png" COMP; image: "images/timer_disabled.png" COMP; } @@ -392,51 +393,49 @@ visible: 0; rel1 { - relative: 0.0 1.0; + relative: 0.0 0.0; to: "base"; } rel2 { - relative: 1.0 1.0; + relative: 0.0 1.0; to: "base"; } color: 255 255 255 0; } description { - state: "mid" 0.0; + state: "down" 0.0; inherit: default 0.0; - visible: 1; + visible: 0; rel1 { - relative: 0.0 0.45; - offset: 0 -SPLIT_OFFSET; + relative: 0.0 1.0; } rel2 { - relative: 1.0 0.55; - offset: 0 SPLIT_OFFSET; + relative: 1.0 1.0; } - color: 255 255 255 0; } description { - state: "up" 0.0; + state: "mid" 0.0; inherit: default 0.0; visible: 0; rel1 { - relative: 0.0 0.0; + relative: 0.0 0.45; + offset: 0 -SPLIT_OFFSET; } rel2 { - relative: 1.0 0.0; + relative: 1.0 0.55; + offset: 0 SPLIT_OFFSET; } - color: 255 255 255 0; } description { - state: "nothing" 0.0; + state: "up" 0.0; inherit: default 0.0; visible: 0; rel1 @@ -445,9 +444,8 @@ } rel2 { - relative: 0.0 1.0; + relative: 1.0 0.0; } - color: 255 255 255 0; } } part @@ -702,7 +700,7 @@ program { name: "split_down"; - action: STATE_SET "default" 0.0; + action: STATE_SET "down" 0.0; transition: SINUSOIDAL 1; target: "split"; } @@ -723,7 +721,7 @@ program { name: "split_nothing"; - action: STATE_SET "nothing" 0.0; + action: STATE_SET "default" 0.0; transition: SINUSOIDAL 1; target: "split"; } @@ -868,6 +866,188 @@ group { - name: "modules/eveil/popup"; + name: "modules/eveil/icon/alarm/snooze"; + parts + { + part + { + name: "icon"; + type: IMAGE; + mouse_events: 1; + description + { + state: "default" 0.0; + aspect: 1 1; + align: 0.0 0.0; + color: 255 255 255 200; + rel1 + { + relative: 0.0 0.0; + offset: 2 2; + } + rel2 + { + relative: 1.0 1.0; + offset: -2 -2; + } + image + { + normal: "images/alarm_snooze.png"; + } + fill + { + smooth: 1; + } + } + } + } + } + + group + { + name: "modules/eveil/icon/alarm/on"; + parts + { + part + { + name: "icon"; + type: IMAGE; + mouse_events: 1; + description + { + state: "default" 0.0; + aspect: 1 1; + align: 0.0 0.0; + color: 255 255 255 200; + rel1 + { + relative: 0.0 0.0; + } + rel2 + { + relative: 1.0 1.0; + } + image + { + normal: "images/alarm_enabled.png"; + } + fill + { + smooth: 1; + } + } + } + } + } + + group + { + name: "modules/eveil/icon/alarm/off"; + parts + { + part + { + name: "icon"; + type: IMAGE; + mouse_events: 1; + description + { + state: "default" 0.0; + aspect: 1 1; + align: 0.0 0.0; + color: 255 255 255 200; + rel1 + { + relative: 0.0 0.0; + } + rel2 + { + relative: 1.0 1.0; + } + image + { + normal: "images/alarm_disabled.png"; + } + fill + { + smooth: 1; + } + } + } + } + } + + group + { + name: "modules/eveil/icon/timer/on"; + parts + { + part + { + name: "icon"; + type: IMAGE; + mouse_events: 1; + description + { + state: "default" 0.0; + aspect: 1 1; + align: 0.0 0.0; + color: 255 255 255 200; + rel1 + { + relative: 0.0 0.0; + } + rel2 + { + relative: 1.0 1.0; + } + image + { + normal: "images/timer_enabled.png"; + } + fill + { + smooth: 1; + } + } + } + } + } + + group + { + name: "modules/eveil/icon/timer/off"; + parts + { + part + { + name: "icon"; + type: IMAGE; + mouse_events: 1; + description + { + state: "default" 0.0; + aspect: 1 1; + align: 0.0 0.0; + color: 255 255 255 200; + rel1 + { + relative: 0.0 0.0; + } + rel2 + { + relative: 1.0 1.0; + } + image + { + normal: "images/timer_disabled.png"; + } + fill + { + smooth: 1; + } + } + } + } } } _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs