2008-12-21 04:41:31 +00:00
|
|
|
/* vim: set sw=3 ts=3 sts=3 expandtab: */
|
|
|
|
#include "ecdb.h"
|
|
|
|
|
2009-02-17 19:16:38 +00:00
|
|
|
static void _button_cb_return(void *data, Evas_Object *obj,
|
2009-01-25 01:17:06 +00:00
|
|
|
const char *emission,
|
|
|
|
const char *source);
|
|
|
|
static void _button_cb_begin(void *data, Evas_Object *obj,
|
|
|
|
const char *emission,
|
|
|
|
const char *source);
|
2009-04-19 18:31:20 +00:00
|
|
|
static void _combo_cb_clicked(void *data, Evas_Object *obj,
|
|
|
|
const char *emission,
|
|
|
|
const char *source);
|
2009-02-05 04:11:22 +00:00
|
|
|
static void _page_hide_finished(void *data, Evas_Object *o,
|
2009-04-19 18:31:20 +00:00
|
|
|
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_Image_Project *proj;
|
|
|
|
|
|
|
|
proj = evas_object_data_get(obj, "proj");
|
|
|
|
if (proj)
|
|
|
|
ecdb_image_project_destroy(proj);
|
|
|
|
}
|
2008-12-21 04:41:31 +00:00
|
|
|
|
|
|
|
static void
|
2009-02-05 04:11:22 +00:00
|
|
|
_page_hide_finished(void *data, Evas_Object *o, const char *emission __UNUSED__,
|
|
|
|
const char *source __UNUSED__)
|
2008-12-21 04:41:31 +00:00
|
|
|
{
|
2009-01-25 01:17:06 +00:00
|
|
|
Evas_Object *gui;
|
2008-12-21 04:41:31 +00:00
|
|
|
|
2009-01-30 03:59:48 +00:00
|
|
|
gui = data;
|
2009-02-05 04:11:22 +00:00
|
|
|
edje_object_part_unswallow(gui, o);
|
|
|
|
evas_object_hide(o);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_button_cb_return(void *data, Evas_Object *obj,
|
|
|
|
const char *emission __UNUSED__,
|
|
|
|
const char *source __UNUSED__)
|
|
|
|
{
|
|
|
|
Ecdb_Page *page;
|
2008-12-21 04:41:31 +00:00
|
|
|
|
2009-02-05 04:11:22 +00:00
|
|
|
page = data;
|
|
|
|
edje_object_part_text_set(page->image, "progress_text", "Begin Burn");
|
|
|
|
edje_object_part_text_set(page->image, "progress_percent", "0%");
|
|
|
|
edje_object_signal_emit(page->image, "ecdb,burn_image_page,hide", "ecdb");
|
|
|
|
ecdb_welcome_page_show(page);
|
2008-12-21 04:41:31 +00:00
|
|
|
|
|
|
|
/* Hide the filelist to be nice */
|
2009-02-05 04:11:22 +00:00
|
|
|
edje_object_signal_emit(page->gui, "ecdb,filelist,hide", "ecdb");
|
2008-12-21 04:41:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-02-05 04:11:22 +00:00
|
|
|
_button_cb_begin(void *data, Evas_Object *obj __UNUSED__,
|
2009-01-25 01:17:06 +00:00
|
|
|
const char *emission __UNUSED__,
|
|
|
|
const char *source __UNUSED__)
|
2008-12-21 04:41:31 +00:00
|
|
|
{
|
2009-02-05 04:11:22 +00:00
|
|
|
Ecdb_Image_Project *proj;
|
|
|
|
Ecdb_Page *page;
|
2008-12-21 04:41:31 +00:00
|
|
|
Ecdb_Source *iso_file;
|
2009-04-19 23:24:53 +00:00
|
|
|
char *file, *buf;
|
2008-12-21 04:41:31 +00:00
|
|
|
Ecdb_Burn_Result burn_result;
|
2009-02-05 04:11:22 +00:00
|
|
|
int drive, speed, idx;
|
2008-12-21 04:41:31 +00:00
|
|
|
|
2009-02-05 04:11:22 +00:00
|
|
|
page = data;
|
|
|
|
proj = evas_object_data_get(page->image, "proj");
|
|
|
|
file = ecdb_entry_text_get(proj->entry);
|
2008-12-21 04:41:31 +00:00
|
|
|
|
|
|
|
// Make sure that file actually exists
|
|
|
|
if (!ecore_file_exists(file))
|
|
|
|
{
|
2009-02-05 04:11:22 +00:00
|
|
|
edje_object_part_text_set(page->image, "progress_text", "File doesn't "
|
2008-12-21 04:41:31 +00:00
|
|
|
"exists!");
|
|
|
|
FREE(file);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
iso_file = ecdb_source_new();
|
|
|
|
ecdb_source_data_set(iso_file, file);
|
|
|
|
FREE(file);
|
2009-02-05 04:11:22 +00:00
|
|
|
ecdb_source_child_append(ECDB_BURN(proj)->files, iso_file);
|
2008-12-21 04:41:31 +00:00
|
|
|
|
2009-02-05 04:11:22 +00:00
|
|
|
drive = ecdb_combo_selected_get(ECDB_PROJECT(proj)->drive_combo);
|
2008-12-21 04:41:31 +00:00
|
|
|
if (drive < 0)
|
|
|
|
{
|
2009-02-23 01:22:02 +00:00
|
|
|
EINA_ERROR_PDBG("Choose a drive!\n");
|
2009-02-05 04:11:22 +00:00
|
|
|
edje_object_part_text_set(page->image, "progress_text",
|
|
|
|
"Choose a Drive!");
|
2008-12-21 04:41:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
speed = ecdb_speed_convert(eina_list_nth(em->drives, drive),
|
2009-02-05 04:11:22 +00:00
|
|
|
ecdb_combo_selected_get(ECDB_BURN(proj)->speed_combo));
|
2008-12-21 04:41:31 +00:00
|
|
|
if (speed < 0)
|
2009-02-05 04:11:22 +00:00
|
|
|
ECDB_BURN(proj)->speed = 0;
|
2008-12-21 04:41:31 +00:00
|
|
|
else
|
2009-02-05 04:11:22 +00:00
|
|
|
ECDB_BURN(proj)->speed = speed;
|
2008-12-21 04:41:31 +00:00
|
|
|
|
2009-04-19 23:24:53 +00:00
|
|
|
if (!ecdb_set_project_drive(ECDB_PROJECT(proj), drive))
|
|
|
|
{
|
|
|
|
EINA_ERROR_PWARN("Drive index doesn't exist!\n");
|
|
|
|
edje_object_part_text_set(page->image, "progress_text",
|
|
|
|
"Drive index doesn't exist!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ECDB_PROJECT(proj)->drive->fresh_info)
|
|
|
|
{
|
|
|
|
EINA_ERROR_PDBG("Insert a disc into the drive!\n");
|
|
|
|
edje_object_part_text_set(page->image, "progress_text",
|
|
|
|
"Insert a disc into the drive!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(ECDB_PROJECT(proj)->drive->status & ECDB_DISC_BLANK))
|
|
|
|
{
|
|
|
|
EINA_ERROR_PDBG("Insert a blank disc!\n");
|
|
|
|
edje_object_part_text_set(page->image, "progress_text",
|
|
|
|
"Insert a blank disc!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ecdb_aquire_drive(ECDB_PROJECT(proj)))
|
2008-12-21 04:41:31 +00:00
|
|
|
{
|
2009-02-23 01:22:02 +00:00
|
|
|
EINA_ERROR_PWARN("Couldn't grab drive!\n");
|
2009-02-05 04:11:22 +00:00
|
|
|
edje_object_part_text_set(page->image, "progress_text",
|
2008-12-21 04:41:31 +00:00
|
|
|
"Couldn't grab the drive!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-04-19 23:24:53 +00:00
|
|
|
edje_object_part_text_set(page->image, "progress_text", "Commencing...");
|
2009-02-17 22:48:11 +00:00
|
|
|
burn_result = ecdb_burn_project(ECDB_BURN(proj), page);
|
2008-12-21 04:41:31 +00:00
|
|
|
switch (burn_result)
|
|
|
|
{
|
|
|
|
case ECDB_ERROR_NONE:
|
2009-02-05 04:11:22 +00:00
|
|
|
edje_object_signal_emit(page->gui, "ecdb,filelist,hide", "ecdb");
|
|
|
|
edje_object_signal_emit(page->image, "ecdb,burn_image,start", "ecdb");
|
|
|
|
Evas_Object *objs[] = {proj->entry, ECDB_PROJECT(proj)->ret,
|
|
|
|
ECDB_PROJECT(proj)->begin, ECDB_PROJECT(proj)->drive_combo,
|
|
|
|
ECDB_BURN(proj)->speed_combo, NULL};
|
2009-02-17 19:16:38 +00:00
|
|
|
for (idx = 0; objs[idx]; idx++)
|
2009-02-05 04:11:22 +00:00
|
|
|
edje_object_signal_emit(objs[idx], "ecdb,disable", "ecdb");
|
2008-12-21 04:41:31 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case ECDB_ERROR_IMAGE_CREATE:
|
2009-04-19 23:24:53 +00:00
|
|
|
buf = "Invalid file!";
|
2008-12-21 04:41:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ECDB_ERROR_SOURCE_ATTACH:
|
2009-04-19 23:24:53 +00:00
|
|
|
buf = "Couldn't attach source data!";
|
2008-12-21 04:41:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ECDB_ERROR_WRITE_MODE:
|
2009-04-19 23:24:53 +00:00
|
|
|
buf = "No suitable burn mode!";
|
2008-12-21 04:41:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2009-04-19 23:24:53 +00:00
|
|
|
buf = "Unknown error :-(";
|
2009-02-17 19:16:38 +00:00
|
|
|
}
|
|
|
|
|
2009-02-05 04:11:22 +00:00
|
|
|
edje_object_part_text_set(page->image, "progress_text", buf);
|
2009-04-19 23:24:53 +00:00
|
|
|
burn_drive_release(ECDB_PROJECT(proj)->drive->tangible[0].drive, 0);
|
2009-02-05 04:11:22 +00:00
|
|
|
burn_drive_info_free(ECDB_PROJECT(proj)->drive->tangible);
|
2008-12-21 04:41:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-01-30 03:59:48 +00:00
|
|
|
_combo_cb_clicked(void *data, Evas_Object *obj __UNUSED__,
|
2009-04-19 18:31:20 +00:00
|
|
|
const char *emission __UNUSED__,
|
|
|
|
const char *source __UNUSED__)
|
2008-12-21 04:41:31 +00:00
|
|
|
{
|
2009-02-05 04:11:22 +00:00
|
|
|
Evas_Object *b;
|
|
|
|
Ecdb_Burn_Project *bp;
|
2008-12-21 04:41:31 +00:00
|
|
|
Ecdb_Drive_Info *drive;
|
2009-04-18 23:18:17 +00:00
|
|
|
int sel, i, num_speeds;
|
2008-12-21 04:41:31 +00:00
|
|
|
char buf[1024];
|
|
|
|
|
2009-02-05 04:11:22 +00:00
|
|
|
bp = data;
|
|
|
|
sel = ecdb_combo_selected_get(ECDB_PROJECT(bp)->drive_combo);
|
2008-12-21 04:41:31 +00:00
|
|
|
if (sel < 0)
|
|
|
|
return;
|
|
|
|
|
2009-02-06 04:03:13 +00:00
|
|
|
ECDB_PROJECT(bp)->drive = drive = eina_list_nth(em->drives, sel);
|
|
|
|
|
|
|
|
/* Don't keep adding items to the combo if the drive hasn't changed */
|
|
|
|
if (drive == ecdb_combo_data_get(bp->speed_combo))
|
|
|
|
return;
|
|
|
|
|
2008-12-21 04:41:31 +00:00
|
|
|
num_speeds = drive->write_speeds[0];
|
2009-02-05 04:11:22 +00:00
|
|
|
ecdb_combo_data_set(bp->speed_combo, drive);
|
2008-12-21 04:41:31 +00:00
|
|
|
for (i = 1; i < num_speeds; i++)
|
|
|
|
{
|
|
|
|
if ((drive->write_speeds[i]) <= 0)
|
|
|
|
continue;
|
|
|
|
|
2009-02-05 04:11:22 +00:00
|
|
|
b = ecdb_combo_item_add(bp->speed_combo, NULL);
|
2009-04-18 23:18:17 +00:00
|
|
|
snprintf(buf, sizeof(buf), "%dkb/s", drive->write_speeds[i]);
|
2008-12-24 18:59:22 +00:00
|
|
|
ecdb_combo_item_label_set(b, buf);
|
2009-02-05 04:11:22 +00:00
|
|
|
ecdb_combo_append(bp->speed_combo, b);
|
2008-12-21 04:41:31 +00:00
|
|
|
evas_object_show(b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-02-05 04:11:22 +00:00
|
|
|
ecdb_burn_image_page_show(Ecdb_Page *page)
|
2008-12-21 04:41:31 +00:00
|
|
|
{
|
2009-02-05 04:11:22 +00:00
|
|
|
if (!page->image)
|
2008-12-21 04:41:31 +00:00
|
|
|
{
|
2009-02-05 04:11:22 +00:00
|
|
|
Evas_Object *b;
|
2008-12-21 04:41:31 +00:00
|
|
|
Eina_List *l;
|
|
|
|
Ecdb_Drive_Info *drive;
|
|
|
|
Evas_Coord x, y, w, h;
|
2009-02-05 04:11:22 +00:00
|
|
|
Ecdb_Image_Project *proj;
|
|
|
|
Ecdb_Project *bp;
|
|
|
|
Ecdb_Burn_Project *bup;
|
|
|
|
|
|
|
|
/* Create the swallow */
|
|
|
|
page->image = edje_object_add(ecore_evas_get(em->main_win_ee));
|
|
|
|
edje_object_file_set(page->image, em->theme_path, "ecdb/burn_image_page");
|
|
|
|
edje_object_part_geometry_get(page->gui, "active_area", &x, &y, &w, &h);
|
|
|
|
evas_object_move(page->gui, x, y);
|
|
|
|
evas_object_resize(page->image, w, h);
|
|
|
|
edje_object_part_swallow(page->gui, "action_area", page->image);
|
2009-02-06 04:03:13 +00:00
|
|
|
evas_object_event_callback_add(page->image, EVAS_CALLBACK_DEL, _page_del,
|
|
|
|
page);
|
2009-02-05 04:11:22 +00:00
|
|
|
edje_object_signal_callback_add(page->image, "hide,finished",
|
2008-12-21 04:41:31 +00:00
|
|
|
"burn_image_page",
|
2009-02-05 04:11:22 +00:00
|
|
|
_page_hide_finished, page->gui);
|
|
|
|
evas_object_show(page->image);
|
|
|
|
|
|
|
|
/* Make the project */
|
|
|
|
proj = ecdb_image_project_new();
|
|
|
|
bp = ECDB_PROJECT(proj);
|
|
|
|
bup = ECDB_BURN(proj);
|
|
|
|
evas_object_data_set(page->image, "proj", proj);
|
|
|
|
|
|
|
|
/* Make the interface all nice and proper */
|
|
|
|
bp->ret = ecdb_button_add(page->image, "ecdb/burn_image/return");
|
|
|
|
ecdb_button_label_set(bp->ret, "Return to Main Page");
|
2009-04-19 18:31:20 +00:00
|
|
|
edje_object_signal_callback_add(page->image, "ecdb,clicked",
|
2009-02-05 04:11:22 +00:00
|
|
|
"ecdb/burn_image/return", _button_cb_return, page);
|
|
|
|
evas_object_show(bp->ret);
|
|
|
|
ecdb_button_icon_set(bp->ret, "ecdb/burn_image/return");
|
|
|
|
|
|
|
|
bp->begin = ecdb_button_add(page->image, "ecdb/burn_image/begin");
|
|
|
|
ecdb_button_label_set(bp->begin, "Start Burn");
|
2009-04-19 18:31:20 +00:00
|
|
|
edje_object_signal_callback_add(page->image, "ecdb,clicked",
|
2009-02-05 04:11:22 +00:00
|
|
|
"ecdb/burn_image/begin", _button_cb_begin, page);
|
|
|
|
evas_object_show(bp->begin);
|
|
|
|
ecdb_button_icon_set(bp->begin, "ecdb/burn_image/begin");
|
|
|
|
|
|
|
|
proj->entry = ecdb_entry_add(page->image, "ecdb/burn_image/file");
|
|
|
|
ecdb_entry_text_set(proj->entry, "Burn File");
|
|
|
|
evas_object_show(proj->entry);
|
|
|
|
|
|
|
|
bp->drive_combo = ecdb_combo_add(page->image, "ecdb/burn_image/drive");
|
|
|
|
ecdb_combo_header_set(bp->drive_combo, "Drive");
|
|
|
|
ecdb_combo_header_create_set(bp->drive_combo,
|
|
|
|
ecdb_gui_combo_header_from_drive);
|
|
|
|
evas_object_show(bp->drive_combo);
|
|
|
|
|
|
|
|
bup->speed_combo = ecdb_combo_add(page->image, "ecdb/burn_image/speed");
|
|
|
|
ecdb_combo_header_create_set(bup->speed_combo,
|
|
|
|
ecdb_gui_combo_header_from_speeds);
|
|
|
|
ecdb_combo_header_set(bup->speed_combo, "Max Speed");
|
|
|
|
evas_object_show(bup->speed_combo);
|
2008-12-21 04:41:31 +00:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH(em->drives, l, drive)
|
|
|
|
{
|
2009-02-05 04:11:22 +00:00
|
|
|
b = ecdb_combo_item_add(bp->drive_combo, NULL);
|
2008-12-24 18:59:22 +00:00
|
|
|
ecdb_combo_item_label_set(b, drive->product);
|
2009-04-19 18:31:20 +00:00
|
|
|
edje_object_signal_callback_add(b, "ecdb,clicked", "ecdb",
|
|
|
|
_combo_cb_clicked, proj);
|
2009-02-05 04:11:22 +00:00
|
|
|
ecdb_combo_append(bp->drive_combo, b);
|
2008-12-21 04:41:31 +00:00
|
|
|
evas_object_show(b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-05 04:11:22 +00:00
|
|
|
else if (edje_object_part_swallow_get(page->gui, "action_area") !=
|
|
|
|
page->image)
|
2008-12-21 04:41:31 +00:00
|
|
|
{
|
2009-02-05 04:11:22 +00:00
|
|
|
edje_object_part_swallow(page->gui, "action_area", page->image);
|
|
|
|
evas_object_show(page->image);
|
2008-12-21 04:41:31 +00:00
|
|
|
}
|
|
|
|
|
2009-02-05 04:11:22 +00:00
|
|
|
edje_object_signal_emit(page->gui, "ecdb,burn_image_page,visible", "ecdb");
|
|
|
|
edje_object_signal_emit(page->image, "ecdb,burn_image_page,visible", "ecdb");
|
2008-12-21 04:41:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-02-17 19:16:38 +00:00
|
|
|
ecdb_burn_image_cleanup(Ecdb_Page *page)
|
2009-02-17 22:48:11 +00:00
|
|
|
{
|
|
|
|
Ecdb_Image_Project *proj;
|
|
|
|
int idx;
|
|
|
|
|
|
|
|
if (!page)
|
|
|
|
{
|
2009-02-23 01:22:02 +00:00
|
|
|
EINA_ERROR_PWARN("ecdb_burn_image_cleanup: NULL page!\n");
|
2009-02-17 22:48:11 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
proj = evas_object_data_get(page->image, "proj");
|
|
|
|
if (!proj)
|
|
|
|
{
|
2009-02-23 01:22:02 +00:00
|
|
|
EINA_ERROR_PWARN("ecdb_burn_image_cleanup: NULL proj!\n");
|
2009-02-17 22:48:11 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Evas_Object *objs[] = {proj->entry, ECDB_PROJECT(proj)->ret,
|
|
|
|
ECDB_PROJECT(proj)->begin, ECDB_PROJECT(proj)->drive_combo,
|
2009-02-17 19:16:38 +00:00
|
|
|
ECDB_BURN(proj)->speed_combo, NULL};
|
2009-02-17 22:48:11 +00:00
|
|
|
for (idx = 0; objs[idx]; idx++)
|
|
|
|
edje_object_signal_emit(objs[idx], "ecdb,enable", "ecdb");
|
2009-02-17 19:16:38 +00:00
|
|
|
|
|
|
|
edje_object_part_text_set(page->image, "progress_text", "Burn Complete!");
|
2009-02-17 22:48:11 +00:00
|
|
|
edje_object_signal_emit(page->image, "ecdb,burn_image,done", "ecdb");
|
|
|
|
|
|
|
|
// Set project attributes back to normal
|
2009-02-17 19:16:38 +00:00
|
|
|
ecdb_entry_text_set(proj->entry, NULL);
|
2008-12-21 04:41:31 +00:00
|
|
|
}
|
|
|
|
|