2008-12-21 01:48:31 +00:00
|
|
|
/* vim: set sw=3 ts=3 sts=3 expandtab: */
|
|
|
|
#include "ecdb.h"
|
|
|
|
|
2009-01-30 03:59:48 +00:00
|
|
|
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);
|
2009-02-05 04:11:22 +00:00
|
|
|
static void _page_hide_finished(void *data, Evas_Object *o,
|
|
|
|
const char *emission,
|
|
|
|
const char *source);
|
2009-02-06 04:03:13 +00:00
|
|
|
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);
|
|
|
|
}
|
2009-02-05 04:11:22 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2008-12-21 01:48:31 +00:00
|
|
|
|
|
|
|
static void
|
2009-01-30 03:59:48 +00:00
|
|
|
_button_cb_return(void *data, Evas_Object *o __UNUSED__,
|
|
|
|
const char *emission __UNUSED__,
|
|
|
|
const char *source __UNUSED__)
|
2008-12-21 01:48:31 +00:00
|
|
|
{
|
2009-02-05 04:11:22 +00:00
|
|
|
Ecdb_Page *page;
|
|
|
|
page = data;
|
2009-01-27 04:00:34 +00:00
|
|
|
|
2009-02-05 04:11:22 +00:00
|
|
|
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);
|
2008-12-21 01:48:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-01-30 03:59:48 +00:00
|
|
|
_button_cb_begin(void *data, Evas_Object *o __UNUSED__,
|
|
|
|
const char *emission __UNUSED__,
|
|
|
|
const char *source __UNUSED__)
|
2008-12-21 01:48:31 +00:00
|
|
|
{
|
|
|
|
Ecdb_Erase_Project *proj;
|
2009-02-05 04:11:22 +00:00
|
|
|
Ecdb_Page *page;
|
2008-12-21 01:48:31 +00:00
|
|
|
char buf[1024];
|
2009-02-05 04:11:22 +00:00
|
|
|
int idx;
|
2008-12-21 01:48:31 +00:00
|
|
|
|
2009-02-05 04:11:22 +00:00
|
|
|
page = data;
|
|
|
|
proj = evas_object_data_get(page->erase, "proj");
|
2008-12-21 01:48:31 +00:00
|
|
|
snprintf(buf, sizeof(buf), "Commencing...");
|
2009-02-05 04:11:22 +00:00
|
|
|
edje_object_part_text_set(page->erase, "progress_text", buf);
|
2008-12-21 01:48:31 +00:00
|
|
|
|
2009-02-05 04:11:22 +00:00
|
|
|
idx = ecdb_combo_selected_get(ECDB_PROJECT(proj)->drive_combo);
|
|
|
|
if (idx < 0)
|
2008-12-21 04:37:50 +00:00
|
|
|
{
|
|
|
|
printf("Choose a drive!\n");
|
2009-02-05 04:11:22 +00:00
|
|
|
edje_object_part_text_set(page->erase, "progress_text",
|
|
|
|
"Choose a Drive!");
|
2008-12-21 04:37:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-02-05 04:11:22 +00:00
|
|
|
if (!ecdb_aquire_drive(ECDB_PROJECT(proj), idx))
|
2008-12-21 01:48:31 +00:00
|
|
|
{
|
|
|
|
printf("Couldn't grab drive!\n");
|
2009-02-05 04:11:22 +00:00
|
|
|
edje_object_part_text_set(page->erase, "progress_text",
|
2008-12-21 01:48:31 +00:00
|
|
|
"Couldn't grab the drive!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-02-05 04:11:22 +00:00
|
|
|
proj->quick = ecdb_check_checked_get(proj->speed);
|
2008-12-21 01:48:31 +00:00
|
|
|
if (!ecdb_erase_disc(proj))
|
|
|
|
{
|
|
|
|
printf("Disc not erasable!\n");
|
|
|
|
snprintf(buf, sizeof(buf), "Disc not erasable!");
|
2009-02-05 04:11:22 +00:00
|
|
|
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);
|
2008-12-21 01:48:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-02-05 04:11:22 +00:00
|
|
|
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");
|
2008-12-21 01:48:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-02-05 04:11:22 +00:00
|
|
|
ecdb_erase_page_show(Ecdb_Page *page)
|
2008-12-21 01:48:31 +00:00
|
|
|
{
|
|
|
|
/* Hide the filelist as it isn't needed to erase a disc */
|
2009-02-05 04:11:22 +00:00
|
|
|
edje_object_signal_emit(page->gui, "ecdb,filelist,hide", "ecdb");
|
2008-12-21 01:48:31 +00:00
|
|
|
|
2009-02-05 04:11:22 +00:00
|
|
|
if (!page->erase)
|
2008-12-21 01:48:31 +00:00
|
|
|
{
|
2009-02-05 04:11:22 +00:00
|
|
|
Evas_Object *d;
|
2008-12-21 01:48:31 +00:00
|
|
|
Evas_Coord x, y, w, h;
|
|
|
|
Eina_List *l;
|
|
|
|
Ecdb_Drive_Info *drive;
|
2009-02-05 04:11:22 +00:00
|
|
|
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);
|
2009-02-06 04:03:13 +00:00
|
|
|
evas_object_event_callback_add(page->erase, EVAS_CALLBACK_DEL, _page_del,
|
|
|
|
page);
|
2009-02-05 04:11:22 +00:00
|
|
|
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);
|
2008-12-21 01:48:31 +00:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH(em->drives, l, drive)
|
|
|
|
{
|
2009-02-05 04:11:22 +00:00
|
|
|
d = ecdb_combo_item_add(bp->drive_combo, NULL);
|
2008-12-24 18:59:22 +00:00
|
|
|
ecdb_combo_item_label_set(d, drive->product);
|
2009-02-05 04:11:22 +00:00
|
|
|
ecdb_combo_append(bp->drive_combo, d);
|
2008-12-21 01:48:31 +00:00
|
|
|
evas_object_show(d);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-05 04:11:22 +00:00
|
|
|
else if (edje_object_part_swallow_get(page->gui, "action_area") !=
|
|
|
|
page->erase)
|
2008-12-21 01:48:31 +00:00
|
|
|
{
|
2009-02-05 04:11:22 +00:00
|
|
|
edje_object_part_swallow(page->gui, "action_area", page->erase);
|
|
|
|
evas_object_show(page->erase);
|
2008-12-21 01:48:31 +00:00
|
|
|
}
|
|
|
|
|
2009-02-05 04:11:22 +00:00
|
|
|
edje_object_signal_emit(page->gui, "ecdb,erase_page,visible", "ecdb");
|
|
|
|
edje_object_signal_emit(page->erase, "ecdb,erase_page,visible", "ecdb");
|
2008-12-21 01:48:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-12-21 03:52:57 +00:00
|
|
|
ecdb_erase_cleanup(void)
|
2008-12-21 01:48:31 +00:00
|
|
|
{
|
2009-02-05 04:11:22 +00:00
|
|
|
/* XXX
|
2008-12-21 01:48:31 +00:00
|
|
|
Evas_Object *swallow;
|
2009-01-27 04:00:34 +00:00
|
|
|
const char *ids[] = {"ecdb/erase/return", "ecdb/erase/begin",
|
|
|
|
"ecdb/erase/speed", "ecdb/erase/drive"};
|
2008-12-21 01:48:31 +00:00
|
|
|
|
|
|
|
swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee),
|
|
|
|
"erase_page");
|
|
|
|
edje_object_part_text_set(swallow, "progress_text", "Erase Complete!");
|
2009-01-27 04:00:34 +00:00
|
|
|
ecdb_gui_controls_enable(ids, 4);
|
2008-12-21 01:48:31 +00:00
|
|
|
edje_object_signal_emit(swallow, "ecdb,erase,done", "ecdb");
|
2009-01-27 04:00:34 +00:00
|
|
|
|
|
|
|
swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee),
|
|
|
|
"ecdb/erase/drive");
|
|
|
|
ecdb_check_checked_set(swallow, 0);
|
2009-02-05 04:11:22 +00:00
|
|
|
*/
|
2008-12-21 01:48:31 +00:00
|
|
|
}
|
|
|
|
|