Some random fixes here and there. There is no more name_find or name_set use.

This commit is contained in:
Jaime Thomas 2009-02-17 19:16:38 +00:00
parent 8f4dc5a95e
commit 937e001022
9 changed files with 219 additions and 125 deletions

View File

@ -18,9 +18,9 @@ TODO
-> integrate exchange
-> instead of always swallowing widgets, allow theme to specify on a widget-by-widget basis if it wants to emit signals from internal parts (so, for example, the settings could be triggered by a small + in the corner, and expand from there)
->able to allow entire gui to be handled by theme... so we only interact with signals (no widgets at all)
->get rid of evas_object_name_find/name_set
-> make theme and code use a custom signal, rather than mouse,clicked,1
DONE
//////////////////////////////////////////////////////////////////////////////
-> better way to detect pipe deletion (done? - needs more testing)
->get rid of evas_object_name_find/name_set

View File

@ -11,10 +11,6 @@ group {
set_text(PART:"progress_percent", percent);
snprintf(sectors, 100, "%d/%d", getarg(3), getarg(4));
set_text(PART:"progress_text", sectors);
/* Also sent is the buffer available [getarg(5)] and
* the buffer capacity [getarg(6)]
*/
}
}
}

View File

@ -9,6 +9,7 @@ struct Burn_Data
Eina_List *sources;
Eina_List *tracks;
Ecdb_Project *proj;
Ecdb_Page *page;
};
int ecdb_burn_finished(void *data, int type, void *event);
@ -19,7 +20,7 @@ void ecdb_sources_list_free(Eina_List *list);
void ecdb_tracks_list_free(Eina_List *list);
int
ecdb_burn_project(Ecdb_Burn_Project *proj)
ecdb_burn_project(Ecdb_Burn_Project *proj, Ecdb_Page *page)
{
char reasons[BURN_REASONS_LEN];
int padding, i;
@ -37,6 +38,7 @@ ecdb_burn_project(Ecdb_Burn_Project *proj)
return FALSE;
}
data->proj = ECDB_PROJECT(proj);
data->page = page;
if (proj->burn_mode != BURN_AUDIO)
padding = 300*1024;
@ -105,7 +107,7 @@ ecdb_burn_project(Ecdb_Burn_Project *proj)
burn_write_opts_free(opts);
printf("Disc now burning\n");
ECDB_PROJECT(proj)->pipe = ecore_pipe_add(ecdb_burn_progress_handler, proj);
ECDB_PROJECT(proj)->pipe = ecore_pipe_add(ecdb_burn_progress_handler, data);
pthread_create(&progress_update, NULL, ecdb_drive_progress_update, proj);
pthread_detach(progress_update);
ECDB_PROJECT(proj)->ev_handler = ecore_event_handler_add
@ -157,6 +159,7 @@ ecdb_burn_progress_handler(void *data, void *buffer, unsigned int nbyte)
{
BurnProgress *p;
Evas_Object *swallow;
Burn_Data *bdata;
static int last_sector = 0;
int percent;
Edje_Message_Int_Set *progress_msg;
@ -188,8 +191,37 @@ ecdb_burn_progress_handler(void *data, void *buffer, unsigned int nbyte)
last_sector = p->sectors;
}
swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee),
"burn_image_page");
bdata = data;
if (!bdata)
{
printf("ecdb_burn_progress_handler: NULL bdata!\n");
return;
}
if ((!bdata->page) || (!bdata->proj))
{
printf("ecdb_burn_progress_handler: NULL page or proj!\n");
return;
}
switch (proj->type)
{
case ECDB_AUDIO_PROJECT:
swallow = page->audio;
break;
case: ECDB_DATA_PROJECT:
swallow = page->data;
break;
case: ECDB_IMAGE_PROJECT:
swallow = page->image;
break;
default:
printf("ecdb_burn_progress_handler: Unrecognized project type!\n");
return;
}
percent = (int)((double)(last_sector + 1) / (double)p->sectors * 100.0);
if (percent >= 100)
@ -231,22 +263,27 @@ ecdb_burn_finished(void *data, int type, void *event)
printf("Burn Complete\n");
ecore_event_handler_del(proj->proj->ev_handler);
proj->proj->ev_handler = NULL;
ecore_pipe_del(proj->proj->pipe);
proj->proj->pipe = NULL;
switch (proj->proj->type)
{
case ECDB_AUDIO_PROJECT:
ecdb_audio_project_destroy(ECDB_AUDIO(proj->proj));
print("How in the world did you get here?\n");
//ecdb_burn_audio_cleanup(proj->page);
break;
case ECDB_BURN_PROJECT:
ecdb_burn_data_cleanup(ECDB_BURN(proj->proj));
ecdb_burn_project_destroy(ECDB_BURN(proj->proj));
ecdb_burn_data_cleanup(proj->page);
break;
case ECDB_IMAGE_PROJECT:
ecdb_burn_image_cleanup();
ecdb_burn_project_destroy(ECDB_BURN(proj->proj));
ecdb_burn_image_cleanup(proj->page);
break;
default:
printf("ecdb_burn_finished: unknown project type!\n");
}
FREE(proj);

View File

@ -2,7 +2,8 @@
#ifndef ECDB_BURN_H
#define ECDB_BURN_H
int ecdb_burn_project(Ecdb_Burn_Project *proj);
int ecdb_burn_project(Ecdb_Burn_Project *proj,
Ecdb_Page *page);
void *ecdb_drive_progress_update(void *data);
#endif

View File

@ -169,7 +169,7 @@ _button_cb_begin(void *data, Evas_Object *obj __UNUSED__,
return;
}
burn_result = ecdb_burn_project(ECDB_BURN(proj));
burn_result = ecdb_burn_project(ECDB_BURN(proj), page);
switch (burn_result)
{
case ECDB_ERROR_NONE:
@ -179,7 +179,7 @@ _button_cb_begin(void *data, Evas_Object *obj __UNUSED__,
proj->filelist_swallow, ECDB_BURN(proj)->speed_combo,
ECDB_PROJECT(proj)->ret, ECDB_PROJECT(proj)->begin,
NULL};
for (idx = 0; objs[idx] != NULL; idx++)
for (idx = 0; objs[idx]; idx++)
edje_object_signal_emit(objs[idx], "ecdb,disable", "ecdb");
return;
@ -601,7 +601,6 @@ ecdb_burn_data_page_show(Ecdb_Page *page)
_joliet_clicked, proj);
evas_object_smart_callback_add(b, "proj_config", _joliet_config, proj);
ecdb_config_inwin_child_add(t, b, 0, 0, 1, 1);
evas_object_name_set(b, "ecdb/burn_data/joliet");
evas_object_show(b);
b = ecdb_check_add(t, NULL);
@ -610,7 +609,6 @@ ecdb_burn_data_page_show(Ecdb_Page *page)
_rockridge_clicked, proj);
evas_object_smart_callback_add(b, "proj_config", _rockridge_config, proj);
ecdb_config_inwin_child_add(t, b, 0, 1, 1, 1);
evas_object_name_set(b, "ecdb/burn_data/rockridge");
evas_object_show(b);
b = ecdb_check_add(t, NULL);
@ -619,7 +617,6 @@ ecdb_burn_data_page_show(Ecdb_Page *page)
_symlinks_clicked, proj);
evas_object_smart_callback_add(b, "proj_config", _symlinks_config, proj);
ecdb_config_inwin_child_add(t, b, 0, 2, 1, 1);
evas_object_name_set(b, "ecdb/burn_data/symlinks");
evas_object_show(b);
b = ecdb_check_add(t, NULL);
@ -628,7 +625,6 @@ ecdb_burn_data_page_show(Ecdb_Page *page)
_hidden_clicked, proj);
evas_object_smart_callback_add(b, "proj_config", _hidden_config, proj);
ecdb_config_inwin_child_add(t, b, 0, 3, 1, 1);
evas_object_name_set(b, "ecdb/burn_data/hidden");
evas_object_show(b);
b = ecdb_check_add(t, NULL);
@ -637,7 +633,6 @@ ecdb_burn_data_page_show(Ecdb_Page *page)
_multi_clicked, proj);
evas_object_smart_callback_add(b, "proj_config", _multi_config, proj);
ecdb_config_inwin_child_add(t, b, 1, 0, 1, 1);
evas_object_name_set(b, "ecdb/burn_data/multi");
evas_object_show(b);
b = ecdb_check_add(t, NULL);
@ -646,7 +641,6 @@ ecdb_burn_data_page_show(Ecdb_Page *page)
_sim_clicked, proj);
evas_object_smart_callback_add(b, "proj_config", _sim_config, proj);
ecdb_config_inwin_child_add(t, b, 1, 1, 1, 1);
evas_object_name_set(b, "ecdb/burn_data/sim");
evas_object_show(b);
b = ecdb_check_add(t, NULL);
@ -655,7 +649,6 @@ ecdb_burn_data_page_show(Ecdb_Page *page)
_underrun_clicked, proj);
evas_object_smart_callback_add(b, "proj_config", _underrun_config, proj);
ecdb_config_inwin_child_add(t, b, 1, 2, 1, 1);
evas_object_name_set(b, "ecdb/burn_data/underrun");
evas_object_show(b);
b = ecdb_entry_add(t, NULL);
@ -664,7 +657,6 @@ ecdb_burn_data_page_show(Ecdb_Page *page)
_proj_name, proj);
evas_object_smart_callback_add(b, "proj_config", _proj_config, proj);
ecdb_config_inwin_child_add(t, b, 1, 3, 1, 1);
evas_object_name_set(b, "ecdb/burn_data/name");
evas_object_show(b);
b = ecdb_button_add(t, NULL);
@ -672,7 +664,6 @@ ecdb_burn_data_page_show(Ecdb_Page *page)
edje_object_signal_callback_add(b, "mouse,down,1", "*", _apply_clicked,
t);
ecdb_config_inwin_child_add(t, b, 0, 4, 2, 1);
evas_object_name_set(b, "ecdb/burn_data/apply");
evas_object_show(b);
// At the end so t is a valid pointer
@ -694,27 +685,38 @@ ecdb_burn_data_page_show(Ecdb_Page *page)
}
void
ecdb_burn_data_cleanup(Ecdb_Burn_Project *proj)
ecdb_burn_data_cleanup(Ecdb_Page *page)
{
/*
Ewl_Widget *filelist;
Ecdb_Source *src;
Ecdb_Burn_Data_Project *proj;
int i;
const char *ids[] = {"ecdb/burn_data/return", "ecdb/burn_data/begin",
"ecdb/burn_data/file", "ecdb/burn_data/drive"
"ecdb/burn_data/speed"};
if (!proj)
if (!page)
{
printf("ecdb_burn_data_cleanup: NULL project!\n");
printf("ecdb_burn_data_cleanup: NULL page!\n");
return;
}
edje_object_part_text_set(proj->parent, "progress_text", "Burn Complete!");
ecdb_gui_controls_enable(ids, 5);
edje_object_signal_emit(proj->parent, "ecdb,burn_data,done", "ecdb");
proj = evas_object_data_get(page->data, "proj");
if (!proj)
{
printf("ecdb_burn_data_cleanup: NULL proj!\n");
return;
}
filelist = ewl_widget_name_find("ecdb/burn_data/filelist");
Evas_Object *objs[] = {proj->capacity, proj->settings,
proj->filelist_swallow, ECDB_BURN(proj)->speed_combo,
ECDB_PROJECT(proj)->ret, ECDB_PROJECT(proj)->begin,
NULL};
for (i = 0; objs[i]; i++)
edje_object_signal_emit(objs[idx], "ecdb,disable", "ecdb");
edje_object_signal_emit(page->data, "ecdb,burn_data,start", "ecdb");
edje_object_part_text_set(page->data, "progress_text", "Burn Complete!");
edje_object_signal_emit(page->data, "ecdb,burn_data,done", "ecdb");
filelist = proj->filelist;
src = ewl_widget_data_get(filelist, "source");
while (src->parent)
src = src->parent;
@ -724,8 +726,5 @@ ecdb_burn_data_cleanup(Ecdb_Burn_Project *proj)
ecdb_source_child_remove(src, src->children[i]);
ecdb_source_destroy(src->children[i]);
}
evas_object_data_set(proj->parent, "proj", NULL);
*/
}

View File

@ -117,7 +117,7 @@ _button_cb_begin(void *data, Evas_Object *obj __UNUSED__,
Evas_Object *objs[] = {proj->entry, ECDB_PROJECT(proj)->ret,
ECDB_PROJECT(proj)->begin, ECDB_PROJECT(proj)->drive_combo,
ECDB_BURN(proj)->speed_combo, NULL};
for (idx = 0; objs[idx] != NULL; idx++)
for (idx = 0; objs[idx]; idx++)
edje_object_signal_emit(objs[idx], "ecdb,disable", "ecdb");
return;
@ -279,18 +279,34 @@ ecdb_burn_image_page_show(Ecdb_Page *page)
}
void
ecdb_burn_image_cleanup(void)
ecdb_burn_image_cleanup(Ecdb_Page *page)
{
/*
Evas_Object *swallow;
const char *ids[] = {"ecdb/burn_image/return", "ecdb/burn_image/begin",
"ecdb/burn_image/file", "ecdb/burn_image/drive"
"ecdb/burn_image/speed"};
swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee),
"burn_image_page");
edje_object_part_text_set(swallow, "progress_text", "Burn Complete!");
ecdb_gui_controls_enable(ids, 5);
edje_object_signal_emit(swallow, "ecdb,burn_image,done", "ecdb");
*/
Ecdb_Burn_Image_Project *proj;
int idx;
if (!page)
{
printf("ecdb_burn_image_cleanup: NULL page!\n");
return;
}
proj = evas_object_data_get(page->image, "proj");
if (!proj)
{
printf("ecdb_burn_image_cleanup: NULL proj!\n");
return;
}
Evas_Object *objs[] = {proj->entry, ECDB_PROJECT(proj)->ret,
ECDB_PROJECT(proj)->begin, ECDB_PROJECT(proj)->drive_combo,
ECDB_BURN(proj)->speed_combo, NULL};
for (idx = 0; objs[idx]; idx++)
edje_object_signal_emit(objs[i], "ecdb,enable", "ecdb");
edje_object_part_text_set(page->image, "progress_text", "Burn Complete!");
edje_object_signal_emit(page->image, "ecdb,burn_image,done", "ecdb");
// Set project attributes back to normal
ecdb_entry_text_set(proj->entry, NULL);
}

View File

@ -3,6 +3,6 @@
#define ECDB_BURN_IMAGE_GUI_H
void ecdb_burn_image_page_show(Ecdb_Page *page);
void ecdb_burn_image_cleanup(void);
void ecdb_burn_image_cleanup(Ecdb_Page *page);
#endif

View File

@ -1,16 +1,33 @@
/* vim: set sw=3 ts=3 sts=3 expandtab: */
#include "ecdb.h"
typedef struct Erase_Data Erase_Data;
struct Erase_Data
{
Ecdb_Project *proj;
Ecdb_Page *page;
};
static void ecdb_erase_progress_handler(void *data, void *buffer,
unsigned int nbyte);
int ecdb_erase_finished(void *data, int type, void *event);
// FIXME Make this return an error code
int
ecdb_erase_disc(Ecdb_Erase_Project *proj)
ecdb_erase_disc(Ecdb_Erase_Project *proj, Ecdb_Page *page)
{
BurnDriveStatus disc_state;
pthread_t progress_update;
Erase_Disc *data;
data = calloc(1, sizeof(Erase_Data));
if (!data)
{
printf("ecdb_erase_disc: NULL data!\n");
return FALSE;
}
data->proj = proj;
data->page = page;
disc_state = burn_disc_get_status(ECDB_PROJECT(proj)->drive->
tangible[0].drive);
@ -34,13 +51,13 @@ ecdb_erase_disc(Ecdb_Erase_Project *proj)
{
printf("Beginning to erase disc!\n");
ECDB_PROJECT(proj)->pipe = ecore_pipe_add(ecdb_erase_progress_handler,
proj);
data);
burn_disc_erase(ECDB_PROJECT(proj)->drive->tangible[0].drive,
proj->quick);
pthread_create(&progress_update, NULL, ecdb_drive_progress_update, proj);
pthread_detach(progress_update);
ECDB_PROJECT(proj)->ev_handler = ecore_event_handler_add
(ECDB_DRIVE_ACTION_FINISHED, ecdb_erase_finished, proj);
(ECDB_DRIVE_ACTION_FINISHED, ecdb_erase_finished, data);
return TRUE;
}
else
@ -55,6 +72,7 @@ ecdb_erase_progress_handler(void *data, void *buffer, unsigned int nbyte)
{
BurnProgress *p;
Evas_Object *swallow;
Erase_Data *edata;
static int last_sector = 0;
Edje_Message_Int_Set *progress_msg;
@ -85,33 +103,53 @@ ecdb_erase_progress_handler(void *data, void *buffer, unsigned int nbyte)
last_sector = p->sectors;
}
swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee),
"erase_page");
edata = data;
if (!edata)
{
printf("ecdb_erase_progress_handler: NULL edata!\n");
return;
}
progress_msg = alloca(sizeof(Edje_Message_Int_Set) + (4 * sizeof(int)));
progress_msg->count = 5;
if ((!edata->page) || (!edata->proj))
{
printf("ecdb_erase_progress_handler: NULL page or proj!\n");
return;
}
switch (proj->type)
{
case ECDB_ERASE_PROJECT:
swallow = page->erase;
break;
default:
printf("ecdb_erase_progress_handler: Unrecognized project type!\n")
return;
}
progress_msg = alloca(sizeof(Edje_Message_Int_Set) + (2 * sizeof(int)));
progress_msg->count = 3;
progress_msg->val[0] = (int)((double)(last_sector + 1) /
(double)p->sectors * 100.0);
progress_msg->val[1] = last_sector;
progress_msg->val[2] = p->sectors;
progress_msg->val[3] = (int)p->buffer_available;
progress_msg->val[4] = (int)p->buffer_capacity;
edje_object_message_send(swallow, EDJE_MESSAGE_INT_SET, 0, progress_msg);
}
int
ecdb_erase_finished(void *data, int type, void *event)
{
Erase_Data *ed;
Ecdb_Erase_Project *proj;
proj = data;
ed = data;
proj = ed->proj;
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);
ecore_pipe_del(ECDB_PROJECT(proj)->pipe);
ecdb_erase_project_destroy(proj);
ecdb_erase_cleanup();
ecdb_erase_cleanup(ed->page);
return TRUE;
}

View File

@ -80,6 +80,7 @@ _button_cb_begin(void *data, Evas_Object *o __UNUSED__,
}
proj->quick = ecdb_check_checked_get(proj->speed);
// TODO: Error Messages here
if (!ecdb_erase_disc(proj))
{
printf("Disc not erasable!\n");
@ -174,22 +175,28 @@ ecdb_erase_page_show(Ecdb_Page *page)
}
void
ecdb_erase_cleanup(void)
ecdb_erase_cleanup(Ecdb_Page *page)
{
/* XXX
Evas_Object *swallow;
const char *ids[] = {"ecdb/erase/return", "ecdb/erase/begin",
"ecdb/erase/speed", "ecdb/erase/drive"};
Ecdb_Erase_Project *proj;
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, 4);
edje_object_signal_emit(swallow, "ecdb,erase,done", "ecdb");
if (!page)
{
printf("ecdb_erase_cleanup: NULL page!\n");
return;
}
swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee),
"ecdb/erase/drive");
ecdb_check_checked_set(swallow, 0);
*/
proj = evas_object_data_get(proj->erase, "proj");
if (!proj)
{
printf("ecdb_erase_cleanup: NULL proj!\n");
return;
}
edje_object_part_text_set(page->erase, "progress_text", "Erase Complete!");
edje_object_signal_emit(page->erase, "ecdb,erase,done", "ecdb");
// Set attributes back to normal
ecdb_check_checked_set(proj->speed, 0);
proj->speed = 0;
}