Make the erase have a percentage complete.

This commit is contained in:
Jaime Thomas
2008-11-17 21:31:23 +00:00
parent 7b12247d36
commit ae9c73f2b4
4 changed files with 56 additions and 8 deletions

View File

@@ -95,24 +95,36 @@ ecdb_erase_progress_handler(void *data, void *buffer, unsigned int nbyte)
BurnProgress *p;
Evas_Object *swallow;
char buf[1024];
char *text = buffer;
static int last_sector = 0;
if ((nbyte != sizeof(BurnProgress)) || (!strcmp(text, "AC")))
if ((nbyte != sizeof(BurnProgress)) || (!strcmp((char *)buffer, "AC")))
{
ecore_event_add(ECDB_DRIVE_ACTION_FINISHED, NULL, NULL, NULL);
last_sector = 0;
return;
}
else
{
p = buffer;
text = NULL;
}
/* Libburn reports p->sector as being 0 right at the end of the job,
* so store the last sector and use that to determine the proper
* percentage/sector to set
*/
if (last_sector <= p->sector)
last_sector = p->sector;
else
last_sector = p->sectors;
swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee),
"erase_page");
snprintf(buf, sizeof(buf), "%d/%d", p->sector, p->sectors);
printf("buf: %s\n", buf);
snprintf(buf, sizeof(buf), "%d/%d", last_sector, p->sectors);
edje_object_part_text_set(swallow, "progress_text", buf);
snprintf(buf, sizeof(buf), "%d%%", (int)((double)(last_sector + 1) /
(double)p->sectors * 100.0));
edje_object_part_text_set(swallow, "progress_percent", buf);
}
int