More work on burn data.
This commit is contained in:
parent
21d6c80f55
commit
6bf1aeb2d6
@ -51,7 +51,6 @@ ecdb_burn_project_init(Ecdb_Burn_Project *proj)
|
||||
proj->underrun_proof = TRUE;
|
||||
proj->opc = TRUE;
|
||||
proj->multi = TRUE;
|
||||
proj->files = ecdb_source_new();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -59,7 +58,8 @@ ecdb_burn_project_init(Ecdb_Burn_Project *proj)
|
||||
void
|
||||
ecdb_burn_project_destroy(Ecdb_Burn_Project *proj)
|
||||
{
|
||||
ecdb_source_destroy(proj->files);
|
||||
if (proj->files)
|
||||
ecdb_source_destroy(proj->files);
|
||||
FREE(proj->volume_id);
|
||||
FREE(proj->publisher_id);
|
||||
FREE(proj->data_preparer_id);
|
||||
|
@ -1,6 +1,17 @@
|
||||
/* vim: set sw=3 ts=3 sts=3 expandtab: */
|
||||
#include "ecdb.h"
|
||||
|
||||
typedef struct _Burn_Data_Data Burn_Data_Data;
|
||||
struct _Burn_Data_Data
|
||||
{
|
||||
Ecdb_Burn_Project *proj;
|
||||
Evas_Object *entry;
|
||||
Evas_Object *capacity;
|
||||
Evas_Object *swallow;
|
||||
Evas_Object *sc;
|
||||
Evas_Object *dc;
|
||||
};
|
||||
|
||||
static void _button_cb_return(void *data, Evas_Object *obj, void *event_info);
|
||||
static void _button_cb_begin(void *data, Evas_Object *obj, void *event_info);
|
||||
static void _combo_cb_clicked(void *data, Evas_Object *obj, void *event_info);
|
||||
@ -10,22 +21,32 @@ static int
|
||||
_update_capacity(void *data, int type, void *ev_data)
|
||||
{
|
||||
Ecdb_Source *src;
|
||||
Evas_Object *o;
|
||||
Edje_Message_Float msg;
|
||||
Burn_Data_Data *bdd;
|
||||
Ecdb_Project *proj;
|
||||
|
||||
o = data;
|
||||
src = evas_object_data_get(o, "source");
|
||||
// FIXME use actual disc capacity here
|
||||
msg.val = (float)src->size / 1048576.0 / 700.0;
|
||||
if (msg.val > 1.0)
|
||||
bdd = data;
|
||||
if ((!bdd) || (!bdd->proj))
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
|
||||
proj = ECDB_PROJECT(bdd->proj);
|
||||
src = evas_object_data_get(bdd->capacity, "source");
|
||||
if ((proj->drive) && (proj->drive->capacity > 0))
|
||||
{
|
||||
printf("OVER SIZE LIMIT!\n");
|
||||
msg.val = (float)src->size / (float)proj->drive->capacity;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("size: %lld, calced size: %f\n", src->size, msg.val);
|
||||
// Default to a nice, small size
|
||||
msg.val = (float)src->size / 1048576.0 / 700.0;
|
||||
}
|
||||
edje_object_message_send(o, EDJE_MESSAGE_FLOAT, 1, &msg);
|
||||
if (msg.val > 1.0)
|
||||
{
|
||||
printf("OVER SIZE LIMIT!\n");
|
||||
edje_object_signal_emit(bdd->capacity, "ecdb,capacity,exceeded", "ecdb");
|
||||
edje_object_signal_emit(bdd->swallow, "ecdb,capacity, exceeded", "ecdb");
|
||||
}
|
||||
edje_object_message_send(bdd->capacity, EDJE_MESSAGE_FLOAT, 1, &msg);
|
||||
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
@ -33,15 +54,18 @@ _update_capacity(void *data, int type, void *ev_data)
|
||||
static void
|
||||
_button_cb_return(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Evas_Object *swallow, *gui;
|
||||
Evas_Object *gui;
|
||||
Burn_Data_Data *bdd;
|
||||
char *signal;
|
||||
|
||||
gui = evas_object_name_find(ecore_evas_get(em->main_win_ee), "gui");
|
||||
swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee),
|
||||
"burn_data_page");
|
||||
bdd = data;
|
||||
if (!bdd)
|
||||
return;
|
||||
|
||||
signal = evas_object_data_get(swallow, "hide_signal");
|
||||
edje_object_signal_emit(swallow, signal, "ecdb");
|
||||
gui = evas_object_name_find(ecore_evas_get(em->main_win_ee), "gui");
|
||||
|
||||
signal = evas_object_data_get(bdd->swallow, "hide_signal");
|
||||
edje_object_signal_emit(bdd->swallow, signal, "ecdb");
|
||||
ecdb_welcome_page_show();
|
||||
|
||||
/* Hide the filelist to be nice */
|
||||
@ -51,63 +75,57 @@ _button_cb_return(void *data, Evas_Object *obj, void *event_info)
|
||||
static void
|
||||
_button_cb_begin(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Evas_Object *swallow, *gui, *o;
|
||||
Ecdb_Burn_Project *proj;
|
||||
Evas_Object *gui;
|
||||
Ecdb_Project *base_proj;
|
||||
Burn_Data_Data *bdd;
|
||||
Ewl_Widget *filelist;
|
||||
char buf[1024];
|
||||
Ecdb_Burn_Result burn_result;
|
||||
int drive, speed;
|
||||
|
||||
bdd = data;
|
||||
if ((!bdd) || (!bdd->proj))
|
||||
return;
|
||||
|
||||
gui = evas_object_name_find(ecore_evas_get(em->main_win_ee), "gui");
|
||||
swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee),
|
||||
"burn_data_page");
|
||||
filelist = ewl_widget_name_find("ecdb/burn_data/filelist");
|
||||
|
||||
proj = ecdb_burn_project_new();
|
||||
ecdb_source_destroy(proj->files);
|
||||
ecdb_project_type_set(ECDB_PROJECT(proj), ECDB_BURN_PROJECT);
|
||||
|
||||
o = evas_object_name_find(evas_object_evas_get(obj),
|
||||
"ecdb/burn_data/drive");
|
||||
drive = ecdb_combo_selected_get(o);
|
||||
if (drive < 0)
|
||||
base_proj = ECDB_PROJECT(bdd->proj);
|
||||
if (!base_proj->drive)
|
||||
{
|
||||
printf("Choose a drive!\n");
|
||||
ecdb_burn_project_destroy(proj);
|
||||
edje_object_part_text_set(swallow, "progress_text", "Choose a Drive!");
|
||||
edje_object_part_text_set(bdd->swallow, "progress_text",
|
||||
"Choose a Drive!");
|
||||
return;
|
||||
}
|
||||
|
||||
o = evas_object_name_find(evas_object_evas_get(obj),
|
||||
"ecdb/burn_data/speed");
|
||||
drive = ecdb_combo_selected_get(bdd->dc);
|
||||
speed = ecdb_speed_convert(eina_list_nth(em->drives, drive),
|
||||
ecdb_combo_selected_get(o));
|
||||
ecdb_combo_selected_get(bdd->sc));
|
||||
if (speed < 0)
|
||||
proj->speed = 0;
|
||||
bdd->proj->speed = 0;
|
||||
else
|
||||
proj->speed = speed;
|
||||
bdd->proj->speed = speed;
|
||||
|
||||
proj->files = ewl_widget_data_get(filelist, "source");
|
||||
while (proj->files->parent)
|
||||
proj->files = proj->files->parent;
|
||||
bdd->proj->files = ewl_widget_data_get(filelist, "source");
|
||||
while (bdd->proj->files->parent)
|
||||
bdd->proj->files = bdd->proj->files->parent;
|
||||
|
||||
snprintf(buf, sizeof(buf), "Commencing...");
|
||||
edje_object_part_text_set(swallow, "progress_text", buf);
|
||||
if (!ecdb_aquire_drive(ECDB_PROJECT(proj), drive))
|
||||
edje_object_part_text_set(bdd->swallow, "progress_text", buf);
|
||||
if (!ecdb_aquire_drive(ECDB_PROJECT(bdd->proj), drive))
|
||||
{
|
||||
printf("Couldn't grab drive!\n");
|
||||
ecdb_burn_project_destroy(proj);
|
||||
edje_object_part_text_set(swallow, "progress_text",
|
||||
edje_object_part_text_set(bdd->swallow, "progress_text",
|
||||
"Couldn't grab the drive!");
|
||||
return;
|
||||
}
|
||||
|
||||
burn_result = ecdb_burn_project(proj);
|
||||
burn_result = ecdb_burn_project(bdd->proj);
|
||||
switch (burn_result)
|
||||
{
|
||||
case ECDB_ERROR_NONE:
|
||||
edje_object_signal_emit(gui, "ecdb,filelist,hide", "ecdb");
|
||||
edje_object_signal_emit(swallow, "ecdb,burn_data,start", "ecdb");
|
||||
edje_object_signal_emit(bdd->swallow, "ecdb,burn_data,start", "ecdb");
|
||||
const char *ids[] = {"ecdb/burn_data/return", "ecdb/burn_data/begin",
|
||||
"ecdb/burn_data/file", "ecdb/burn_data/drive",
|
||||
"ecdb/burn_data/speed"};
|
||||
@ -130,55 +148,62 @@ _button_cb_begin(void *data, Evas_Object *obj, void *event_info)
|
||||
snprintf(buf, sizeof(buf), "Unknown error :-(");
|
||||
}
|
||||
|
||||
edje_object_part_text_set(swallow, "progress_text", buf);
|
||||
Ecdb_Project *p = ECDB_PROJECT(proj);
|
||||
burn_drive_release(p->drive->tangible[0].drive, 1);
|
||||
burn_drive_info_free(p->drive->tangible);
|
||||
ecdb_burn_project_destroy(proj);
|
||||
edje_object_part_text_set(bdd->swallow, "progress_text", buf);
|
||||
burn_drive_release(base_proj->drive->tangible[0].drive, 1);
|
||||
burn_drive_info_free(base_proj->drive->tangible);
|
||||
ecdb_burn_project_destroy(bdd->proj);
|
||||
bdd->proj = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_combo_cb_clicked(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
Evas_Object *c1, *c2, *b;
|
||||
Ecdb_Drive_Info *drive;
|
||||
Evas_Object *b;
|
||||
Burn_Data_Data *bdd;
|
||||
Ecdb_Project *proj;
|
||||
int sel, i, num_speeds, speed;
|
||||
char buf[1024];
|
||||
|
||||
c2 = data;
|
||||
c1 = evas_object_name_find(evas_object_evas_get(obj),
|
||||
"ecdb/burn_data/drive");
|
||||
sel = ecdb_combo_selected_get(c1);
|
||||
bdd = data;
|
||||
if ((!bdd) || (!bdd->proj))
|
||||
return;
|
||||
|
||||
proj = ECDB_PROJECT(bdd->proj);
|
||||
sel = ecdb_combo_selected_get(bdd->dc);
|
||||
if (sel < 0)
|
||||
return;
|
||||
|
||||
drive = eina_list_nth(em->drives, sel);
|
||||
num_speeds = drive->write_speeds[0];
|
||||
ecdb_combo_data_set(c2, drive);
|
||||
proj->drive = eina_list_nth(em->drives, sel);
|
||||
// Update the capacity here, as our capacity could change with the drive
|
||||
ecore_event_add(ECDB_FILELIST_SIZE_CHANGED, NULL, NULL, NULL);
|
||||
num_speeds = proj->drive->write_speeds[0];
|
||||
ecdb_combo_data_set(bdd->sc, proj->drive);
|
||||
for (i = 1; i < num_speeds; i++)
|
||||
{
|
||||
if ((drive->write_speeds[i]) <= 0)
|
||||
if ((proj->drive->write_speeds[i]) <= 0)
|
||||
continue;
|
||||
|
||||
b = ecdb_combo_item_add(c2, NULL);
|
||||
b = ecdb_combo_item_add(bdd->sc, NULL);
|
||||
|
||||
if ((drive->profile_name) && (drive->profile_name[0] != '\0'))
|
||||
if ((proj->drive->profile_name) &&
|
||||
(proj->drive->profile_name[0] != '\0'))
|
||||
{
|
||||
if (drive->profile_name[0] == 'C')
|
||||
speed = drive->write_speeds[i] / 150;
|
||||
else if (drive->profile_name[0] == 'D')
|
||||
speed = drive->write_speeds[i] / 1352;
|
||||
if (proj->drive->profile_name[0] == 'C')
|
||||
speed = proj->drive->write_speeds[i] / 150;
|
||||
else if (proj->drive->profile_name[0] == 'D')
|
||||
speed = proj->drive->write_speeds[i] / 1352;
|
||||
else
|
||||
speed = drive->write_speeds[i] / 4500;
|
||||
speed = proj->drive->write_speeds[i] / 4500;
|
||||
}
|
||||
else
|
||||
{
|
||||
speed = 0;
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof(buf), "%dX (%dkb/s)", speed, drive->write_speeds[i]);
|
||||
snprintf(buf, sizeof(buf), "%dX (%dkb/s)", speed,
|
||||
proj->drive->write_speeds[i]);
|
||||
ecdb_combo_item_label_set(b, buf);
|
||||
ecdb_combo_append(c2, b);
|
||||
ecdb_combo_append(bdd->sc, b);
|
||||
evas_object_show(b);
|
||||
}
|
||||
}
|
||||
@ -187,6 +212,7 @@ void
|
||||
ecdb_burn_data_page_show(void)
|
||||
{
|
||||
Evas_Object *swallow, *gui;
|
||||
Burn_Data_Data *bdd;
|
||||
|
||||
gui = evas_object_name_find(ecore_evas_get(em->main_win_ee), "gui");
|
||||
swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee),
|
||||
@ -201,6 +227,9 @@ ecdb_burn_data_page_show(void)
|
||||
Ewl_Widget *embed, *filelist;
|
||||
Ecdb_Source *src;
|
||||
|
||||
bdd = calloc(1, sizeof(Burn_Data_Data));
|
||||
bdd->proj = ecdb_burn_project_new();
|
||||
|
||||
swallow = edje_object_add(ecore_evas_get(em->main_win_ee));
|
||||
edje_object_file_set(swallow, em->theme_path, "ecdb/burn_data_page");
|
||||
evas_object_name_set(swallow, "burn_data_page");
|
||||
@ -213,17 +242,19 @@ ecdb_burn_data_page_show(void)
|
||||
edje_object_signal_callback_add(swallow, "hide,finished",
|
||||
"burn_data_page",
|
||||
ecdb_page_hide_finished, NULL);
|
||||
evas_object_data_set(swallow, "bdd", bdd);
|
||||
evas_object_show(swallow);
|
||||
bdd->swallow = swallow;
|
||||
|
||||
b = ecdb_button_add(swallow, "ecdb/burn_data/return");
|
||||
ecdb_button_label_set(b, "Return to Main Page");
|
||||
evas_object_smart_callback_add(b, "clicked", _button_cb_return, NULL);
|
||||
evas_object_smart_callback_add(b, "clicked", _button_cb_return, bdd);
|
||||
evas_object_show(b);
|
||||
ecdb_button_icon_set(b, "ecdb/burn_data/return");
|
||||
|
||||
b = ecdb_button_add(swallow, "ecdb/burn_data/begin");
|
||||
ecdb_button_label_set(b, "Start Burn");
|
||||
evas_object_smart_callback_add(b, "clicked", _button_cb_begin, NULL);
|
||||
evas_object_smart_callback_add(b, "clicked", _button_cb_begin, bdd);
|
||||
evas_object_show(b);
|
||||
ecdb_button_icon_set(b, "ecdb/burn_data/begin");
|
||||
|
||||
@ -231,17 +262,19 @@ ecdb_burn_data_page_show(void)
|
||||
ecdb_combo_header_set(c1, "Drive");
|
||||
ecdb_combo_header_create_set(c1, ecdb_gui_combo_header_from_drive);
|
||||
evas_object_show(c1);
|
||||
bdd->dc = c1;
|
||||
|
||||
c2 = ecdb_combo_add(swallow, "ecdb/burn_data/speed");
|
||||
ecdb_combo_header_create_set(c2, ecdb_gui_combo_header_from_speeds);
|
||||
ecdb_combo_header_set(c2, "Max Speed");
|
||||
evas_object_show(c2);
|
||||
bdd->sc = c2;
|
||||
|
||||
EINA_LIST_FOREACH(em->drives, l, drive)
|
||||
{
|
||||
b = ecdb_combo_item_add(c1, NULL);
|
||||
ecdb_combo_item_label_set(b, drive->product);
|
||||
evas_object_smart_callback_add(b, "clicked", _combo_cb_clicked, c2);
|
||||
evas_object_smart_callback_add(b, "clicked", _combo_cb_clicked, bdd);
|
||||
ecdb_combo_append(c1, b);
|
||||
evas_object_show(b);
|
||||
}
|
||||
@ -274,21 +307,34 @@ ecdb_burn_data_page_show(void)
|
||||
b = ecdb_entry_add(swallow, "ecdb/burn_data/vol_name");
|
||||
ecdb_entry_text_set(b, "Volume Name");
|
||||
evas_object_show(b);
|
||||
bdd->entry = b;
|
||||
|
||||
// FIXME Turn this into a normal widget
|
||||
b = ecdb_widget_add(swallow, "ecdb/burn_data/capacity");
|
||||
edje_object_file_set(b, em->theme_path, "ecdb/capacity");
|
||||
evas_object_data_set(b, "source", src);
|
||||
ecore_event_handler_add(ECDB_FILELIST_SIZE_CHANGED, _update_capacity, b);
|
||||
ecore_event_handler_add(ECDB_FILELIST_SIZE_CHANGED, _update_capacity,
|
||||
bdd);
|
||||
evas_object_show(b);
|
||||
bdd->capacity = b;
|
||||
}
|
||||
|
||||
else if (edje_object_part_swallow_get(gui, "action_area") != swallow)
|
||||
{
|
||||
edje_object_part_swallow(gui, "action_area", swallow);
|
||||
evas_object_show(swallow);
|
||||
}
|
||||
|
||||
bdd = evas_object_data_get(swallow, "bdd");
|
||||
if (!bdd)
|
||||
{
|
||||
printf("No data for burn data page! This should never happen!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!bdd->proj)
|
||||
bdd->proj = ecdb_burn_project_new();
|
||||
}
|
||||
|
||||
edje_object_signal_emit(gui, "ecdb,burn_data_page,visible", "ecdb");
|
||||
edje_object_signal_emit(swallow, "ecdb,burn_data_page,visible", "ecdb");
|
||||
}
|
||||
@ -299,6 +345,7 @@ ecdb_burn_data_cleanup(void)
|
||||
Evas_Object *swallow;
|
||||
Ewl_Widget *filelist;
|
||||
Ecdb_Source *src;
|
||||
Burn_Data_Data *bdd;
|
||||
int i;
|
||||
|
||||
const char *ids[] = {"ecdb/burn_data/return", "ecdb/burn_data/begin",
|
||||
@ -306,6 +353,7 @@ ecdb_burn_data_cleanup(void)
|
||||
"ecdb/burn_data/speed"};
|
||||
swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee),
|
||||
"burn_data_page");
|
||||
bdd = evas_object_data_get(swallow, "bdd");
|
||||
edje_object_part_text_set(swallow, "progress_text", "Burn Complete!");
|
||||
ecdb_gui_controls_enable(ids, 5);
|
||||
edje_object_signal_emit(swallow, "ecdb,burn_data,done", "ecdb");
|
||||
@ -320,5 +368,6 @@ ecdb_burn_data_cleanup(void)
|
||||
ecdb_source_child_remove(src, src->children[i]);
|
||||
ecdb_source_destroy(src->children[i]);
|
||||
}
|
||||
bdd->proj = NULL;
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,7 @@ _button_cb_begin(void *data, Evas_Object *obj, void *event_info)
|
||||
proj = ecdb_burn_project_new();
|
||||
ecdb_project_type_set(ECDB_PROJECT(proj), ECDB_IMAGE_PROJECT);
|
||||
iso_file = ecdb_source_new();
|
||||
proj->files = ecdb_source_new();
|
||||
ecdb_source_data_set(iso_file, file);
|
||||
FREE(file);
|
||||
ecdb_source_child_append(proj->files, iso_file);
|
||||
|
@ -70,6 +70,9 @@ struct _Ecdb_Drive_Info
|
||||
unsigned char write_cdr:1;
|
||||
unsigned char write_simulate:1;
|
||||
|
||||
/* Capacity */
|
||||
long long capacity;
|
||||
|
||||
BurnDriveInfo *tangible;
|
||||
};
|
||||
|
||||
|
@ -49,6 +49,7 @@ ecdb_aquire_drive_info(void)
|
||||
|
||||
drive->profile_name = eina_stringshare_add(speeds->profile_name);
|
||||
drive->profile_loaded = speeds->profile_loaded;
|
||||
drive->capacity = speeds->end_lba * 2048;
|
||||
|
||||
while (speeds->next)
|
||||
{
|
||||
|
@ -44,6 +44,9 @@ ecdb_source_destroy(Ecdb_Source *src)
|
||||
int i;
|
||||
Ecdb_Source *child;
|
||||
|
||||
if (!src)
|
||||
return;
|
||||
|
||||
/* free the non-recursive stuff */
|
||||
if (src->dst) eina_stringshare_del(src->dst);
|
||||
if (src->node) iso_node_unref(src->node);
|
||||
@ -100,12 +103,16 @@ ecdb_source_add_directory_recursive(Ecdb_Source *parent)
|
||||
void
|
||||
ecdb_source_child_append(Ecdb_Source *src, Ecdb_Source *child)
|
||||
{
|
||||
long long orig, diff;
|
||||
Ecdb_Source *p;
|
||||
|
||||
if (src == child)
|
||||
{
|
||||
printf("Trying to make a parent of itself!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
orig = src->size;
|
||||
src->num_children++;
|
||||
src->children = realloc(src->children, sizeof(Ecdb_Source) *
|
||||
(src->num_children + 1));
|
||||
@ -113,6 +120,14 @@ ecdb_source_child_append(Ecdb_Source *src, Ecdb_Source *child)
|
||||
src->children[src->num_children] = NULL;
|
||||
src->size += child->size;
|
||||
child->parent = src;
|
||||
|
||||
diff = src->size - orig;
|
||||
p = src;
|
||||
while (p->parent)
|
||||
{
|
||||
p = p->parent;
|
||||
p->size += diff;
|
||||
}
|
||||
}
|
||||
|
||||
/* Basically here we can remove all occurences (who knows why we'd get
|
||||
|
Loading…
Reference in New Issue
Block a user