/* vim: set sw=3 ts=3 sts=3 expandtab: */ #include "ecdb.h" static void _button_cb_return(void *data, Evas_Object *o, const char *emission, const char *source); static void _button_cb_begin(void *data, Evas_Object *o, const char *emission, const char *source); static void _page_hide_finished(void *data, Evas_Object *o, const char *emission, const char *source); static void _page_del(void *data, Evas *e, Evas_Object *obj, void *ev); static void _page_del(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *ev __UNUSED__) { Ecdb_Erase_Project *proj; proj = evas_object_data_get(obj, "proj"); if (proj) ecdb_erase_project_destroy(proj); } static void _page_hide_finished(void *data, Evas_Object *o, const char *emission __UNUSED__, const char *source __UNUSED__) { Evas_Object *gui; gui = data; edje_object_part_unswallow(gui, o); evas_object_hide(o); } static void _button_cb_return(void *data, Evas_Object *o __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) { Ecdb_Page *page; page = data; edje_object_part_text_set(page->erase, "progress_text", "Begin Erase"); edje_object_part_text_set(page->erase, "progress_percent", "0%"); edje_object_signal_emit(page->erase, "ecdb,erase_page,hide", "ecdb"); ecdb_welcome_page_show(page); } static void _button_cb_begin(void *data, Evas_Object *o __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) { Ecdb_Erase_Project *proj; Ecdb_Page *page; char buf[1024]; int idx; page = data; proj = evas_object_data_get(page->erase, "proj"); snprintf(buf, sizeof(buf), "Commencing..."); edje_object_part_text_set(page->erase, "progress_text", buf); idx = ecdb_combo_selected_get(ECDB_PROJECT(proj)->drive_combo); if (idx < 0) { printf("Choose a drive!\n"); edje_object_part_text_set(page->erase, "progress_text", "Choose a Drive!"); return; } if (!ecdb_aquire_drive(ECDB_PROJECT(proj), idx)) { printf("Couldn't grab drive!\n"); edje_object_part_text_set(page->erase, "progress_text", "Couldn't grab the drive!"); return; } proj->quick = ecdb_check_checked_get(proj->speed); // TODO: Error Messages here if (!ecdb_erase_disc(proj)) { printf("Disc not erasable!\n"); snprintf(buf, sizeof(buf), "Disc not erasable!"); edje_object_part_text_set(page->erase, "progress_text", buf); burn_drive_release(ECDB_PROJECT(proj)->drive->tangible[0].drive, 0); burn_drive_info_free(ECDB_PROJECT(proj)->drive->tangible); return; } edje_object_signal_emit(page->erase, "ecdb,erase,start", "ecdb"); Evas_Object *objs[] = {proj->speed, ECDB_PROJECT(proj)->ret, ECDB_PROJECT(proj)->begin, ECDB_PROJECT(proj)->drive_combo, NULL}; for (idx = 0; objs[idx] != NULL; idx++) edje_object_signal_emit(objs[idx], "ecdb,disable", "ecdb"); } void ecdb_erase_page_show(Ecdb_Page *page) { /* Hide the filelist as it isn't needed to erase a disc */ edje_object_signal_emit(page->gui, "ecdb,filelist,hide", "ecdb"); if (!page->erase) { Evas_Object *d; Evas_Coord x, y, w, h; Eina_List *l; Ecdb_Drive_Info *drive; Ecdb_Erase_Project *proj; Ecdb_Project *bp; page->erase = edje_object_add(ecore_evas_get(em->main_win_ee)); edje_object_file_set(page->erase, em->theme_path, "ecdb/erase_page"); edje_object_part_geometry_get(page->gui, "active_area", &x, &y, &w, &h); evas_object_move(page->erase, x, y); evas_object_resize(page->erase, w, h); edje_object_part_swallow(page->gui, "action_area", page->erase); evas_object_event_callback_add(page->erase, EVAS_CALLBACK_DEL, _page_del, page); evas_object_show(page->erase); proj = ecdb_erase_project_new(); bp = ECDB_PROJECT(proj); evas_object_data_set(page->erase, "proj", proj); edje_object_signal_callback_add(page->erase, "hide,finished", "erase_page", _page_hide_finished, page->gui); bp->ret = ecdb_button_add(page->erase, "ecdb/erase/return"); ecdb_button_label_set(bp->ret, "Return to Main Page"); edje_object_signal_callback_add(page->erase, "mouse,clicked,1", "ecdb/erase/return", _button_cb_return, page); evas_object_show(bp->ret); ecdb_button_icon_set(bp->ret, "ecdb/erase/return"); bp->begin = ecdb_button_add(page->erase, "ecdb/erase/begin"); ecdb_button_label_set(bp->begin, "Start Erase"); edje_object_signal_callback_add(page->erase, "mouse,clicked,1", "ecdb/erase/begin", _button_cb_begin, page); evas_object_show(bp->begin); ecdb_button_icon_set(bp->begin, "ecdb/erase/begin"); proj->speed = ecdb_check_add(page->erase, "ecdb/erase/speed"); ecdb_check_label_set(proj->speed, "Quick Erase"); evas_object_show(proj->speed); bp->drive_combo = ecdb_combo_add(page->erase, "ecdb/erase/drive"); ecdb_combo_header_set(bp->drive_combo, "Drive"); ecdb_combo_header_create_set(bp->drive_combo, ecdb_gui_combo_header_from_drive); EINA_LIST_FOREACH(em->drives, l, drive) { d = ecdb_combo_item_add(bp->drive_combo, NULL); ecdb_combo_item_label_set(d, drive->product); ecdb_combo_append(bp->drive_combo, d); evas_object_show(d); } } else if (edje_object_part_swallow_get(page->gui, "action_area") != page->erase) { edje_object_part_swallow(page->gui, "action_area", page->erase); evas_object_show(page->erase); } edje_object_signal_emit(page->gui, "ecdb,erase_page,visible", "ecdb"); edje_object_signal_emit(page->erase, "ecdb,erase_page,visible", "ecdb"); } void ecdb_erase_cleanup(Ecdb_Page *page) { Ecdb_Erase_Project *proj; int idx; if (!page) { printf("ecdb_erase_cleanup: NULL page!\n"); return; } proj = evas_object_data_get(proj->erase, "proj"); if (!proj) { printf("ecdb_erase_cleanup: NULL proj!\n"); return; } Evas_Object *objs[] = {proj->speed, ECDB_PROJECT(proj)->ret, ECDB_PROJECT(proj)->begin, ECDB_PROJECT(proj)->drive_combo, NULL}; for (idx = 0; objs[idx] != NULL; idx++) edje_object_signal_emit(objs[idx], "ecdb,disable", "ecdb"); edje_object_part_text_set(page->erase, "progress_text", "Erase Complete!"); edje_object_signal_emit(page->erase, "ecdb,erase,done", "ecdb"); // Set attributes back to normal ecdb_check_checked_set(proj->speed, 0); proj->speed = 0; }