Some small fixes, and a little polishing of erase function.

This commit is contained in:
Jaime Thomas 2008-11-12 16:06:29 +00:00
parent 68e7815eb3
commit 1bc97e48f0
5 changed files with 57 additions and 23 deletions

View File

@ -13,7 +13,8 @@ struct Burn_Data
int ecdb_burn_finished(void *data, int type, void *event); int ecdb_burn_finished(void *data, int type, void *event);
int ecdb_burn_project_init(Ecdb_Burn_Project *proj); int ecdb_burn_project_init(Ecdb_Burn_Project *proj);
int ecdb_erase_project_init(Ecdb_Erase_Project *proj); int ecdb_erase_project_init(Ecdb_Erase_Project *proj);
static void ecdb_burn_progress_handler(void *data, void *buffer, int nbyte); static void ecdb_burn_progress_handler(void *data, void *buffer,
unsigned int nbyte);
Ecdb_Burn_Project * Ecdb_Burn_Project *
ecdb_burn_project_new(void) ecdb_burn_project_new(void)
@ -155,9 +156,10 @@ ecdb_burn_project(Ecdb_Burn_Project *proj)
void * void *
ecdb_drive_progress_update(void *data) ecdb_drive_progress_update(void *data)
{ {
Ecdb_Project *proj; const Ecdb_Project *proj;
BurnProgress p; BurnProgress p;
struct burn_drive *drive; struct burn_drive *drive;
BurnDriveStatus stat;
proj = data; proj = data;
@ -173,27 +175,25 @@ ecdb_drive_progress_update(void *data)
printf("Progress update active\n"); printf("Progress update active\n");
while (TRUE) while (TRUE)
{ {
proj->stat = burn_drive_get_status(drive, &p); stat = burn_drive_get_status(drive, &p);
if (proj->stat == BURN_DRIVE_SPAWNING) ecore_pipe_write(proj->pipe, &p, sizeof(&p));
if (stat == BURN_DRIVE_SPAWNING)
{ {
sleep(1); sleep(1);
continue; continue;
} }
else if (proj->stat == BURN_DRIVE_IDLE) else if (stat == BURN_DRIVE_IDLE)
{ {
ecore_pipe_del(proj->pipe); ecore_pipe_del(proj->pipe);
/* Call the finished event handler here */ /* Call the finished event handler here */
pthread_exit(NULL); pthread_exit(NULL);
break; break;
} }
ecore_pipe_write(proj->pipe, &p, sizeof(&p));
sleep(1);
} }
} }
static void static void
ecdb_burn_progress_handler(void *data, void *buffer, int nbyte) ecdb_burn_progress_handler(void *data, void *buffer, unsigned int nbyte)
{ {
BurnProgress *p = buffer; BurnProgress *p = buffer;

View File

@ -55,7 +55,6 @@ struct _Ecdb_Project_Info
{ {
/* The drive reference */ /* The drive reference */
Ecdb_Drive_Info *drive; Ecdb_Drive_Info *drive;
BurnDriveStatus stat;
Ecore_Event_Handler *ev_handler; Ecore_Event_Handler *ev_handler;
Ecore_Pipe *pipe; Ecore_Pipe *pipe;
unsigned int type; unsigned int type;

View File

@ -1,7 +1,9 @@
#include "ecdb.h" #include "ecdb.h"
int ecdb_erase_project_init(Ecdb_Erase_Project *proj); int ecdb_erase_project_init(Ecdb_Erase_Project *proj);
static void ecdb_erase_progress_handler(void *data, void *buffer, int nbyte); static void ecdb_erase_progress_handler(void *data, void *buffer,
unsigned int nbyte);
int ecdb_erase_finished(void *data, int type, void *event);
Ecdb_Erase_Project * Ecdb_Erase_Project *
ecdb_erase_project_new(void) ecdb_erase_project_new(void)
@ -76,6 +78,9 @@ ecdb_erase_disc(Ecdb_Erase_Project *proj)
pthread_create(&progress_update, NULL, pthread_create(&progress_update, NULL,
ecdb_drive_progress_update, proj); ecdb_drive_progress_update, proj);
pthread_detach(progress_update); pthread_detach(progress_update);
ECDB_PROJECT(proj)->ev_handler = ecore_event_handler_add
(ECDB_DRIVE_ACTION_FINISHED,
ecdb_erase_finished, proj);
return TRUE; return TRUE;
} }
else else
@ -86,14 +91,38 @@ ecdb_erase_disc(Ecdb_Erase_Project *proj)
} }
static void static void
ecdb_erase_progress_handler(void *data, void *buffer, int nbyte) ecdb_erase_progress_handler(void *data, void *buffer, unsigned int nbyte)
{ {
BurnProgress *p = buffer; BurnProgress *p = buffer;
Evas_Object *swallow; Evas_Object *swallow;
char buf[1024]; char buf[1024];
// Is this correct?
if (p->sector >= p->sectors)
{
ecore_event_add(ECDB_DRIVE_ACTION_FINISHED, NULL, NULL, NULL);
return;
}
swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee), swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee),
"erase_page"); "erase_page");
snprintf(buf, sizeof(buf), "%d/%d", p->sector, p->sectors); snprintf(buf, sizeof(buf), "%d/%d", p->sector, p->sectors);
edje_object_part_text_set(swallow, "progress_text", buf); edje_object_part_text_set(swallow, "progress_text", buf);
} }
int
ecdb_erase_finished(void *data, int type, void *event)
{
Ecdb_Erase_Project *proj;
proj = data;
burn_drive_release(ECDB_PROJECT(proj)->drive->tangible[0].drive, 0);
burn_drive_info_free(ECDB_PROJECT(proj)->drive->tangible);
ecore_event_handler_del(ECDB_PROJECT(proj)->ev_handler);
ecdb_erase_project_destroy(proj);
ecdb_gui_erase_cleanup();
return TRUE;
}

View File

@ -373,8 +373,8 @@ ecdb_cb_erase_page_buttons_clicked(void *data, Evas_Object *o,
{ {
printf("Couldn't grab drive!\n"); printf("Couldn't grab drive!\n");
ecdb_erase_project_destroy(proj); ecdb_erase_project_destroy(proj);
snprintf(buf, sizeof(buf), "Couldn't grab drive!"); edje_object_part_text_set(swallow, "progress_text",
edje_object_part_text_set(swallow, "progress_text", buf); "Couldn't grab the drive!");
return; return;
} }
@ -397,15 +397,6 @@ ecdb_cb_erase_page_buttons_clicked(void *data, Evas_Object *o,
const char *ids[] = {"ecdb/erase/return", "ecdb/erase/begin", const char *ids[] = {"ecdb/erase/return", "ecdb/erase/begin",
"ecdb/erase/speed"}; "ecdb/erase/speed"};
ecdb_gui_controls_disable(ids, 3); ecdb_gui_controls_disable(ids, 3);
/* 2) Start erase
* 3) Grab a drive
* 4) Start burn
* 5) Set up progress callback
*/
} }
else if (!strcmp(source, "ecdb/erase/speed")) else if (!strcmp(source, "ecdb/erase/speed"))
{ {
@ -674,3 +665,17 @@ ecdb_gui_controls_enable(const char **ids, int n)
} }
} }
void
ecdb_gui_erase_cleanup(void)
{
Evas_Object *swallow;
const char *ids[] = {"ecdb/erase/return", "ecdb/erase/begin",
"ecdb/erase/speed"};
swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee),
"erase_page");
edje_object_part_text_set(swallow, "progress_text", "Erase Complete!");
ecdb_gui_controls_enable(ids, 3);
edje_object_signal_emit(swallow, "ecdb,erase,done", "ecdb");
}

View File

@ -3,5 +3,6 @@
int ecdb_create_main_gui(void); int ecdb_create_main_gui(void);
void ecdb_set_main_theme(const char *theme_name); void ecdb_set_main_theme(const char *theme_name);
void ecdb_gui_erase_cleanup(void);
#endif #endif