From 937e0010227a9eccbcc14d0ddde8e1e814c50bbd Mon Sep 17 00:00:00 2001 From: Jaime Thomas Date: Tue, 17 Feb 2009 19:16:38 +0000 Subject: [PATCH] Some random fixes here and there. There is no more name_find or name_set use. --- experimental/ecdb/trunk/TODO | 2 +- .../data/themes/default/groups/erase_disc.edc | 8 +- experimental/ecdb/trunk/src/ecdb_burn.c | 69 ++++++++++---- experimental/ecdb/trunk/src/ecdb_burn.h | 3 +- .../ecdb/trunk/src/ecdb_burn_data_gui.c | 93 +++++++++---------- .../ecdb/trunk/src/ecdb_burn_image_gui.c | 50 ++++++---- .../ecdb/trunk/src/ecdb_burn_image_gui.h | 2 +- experimental/ecdb/trunk/src/ecdb_erase.c | 74 +++++++++++---- experimental/ecdb/trunk/src/ecdb_erase_gui.c | 43 +++++---- 9 files changed, 219 insertions(+), 125 deletions(-) diff --git a/experimental/ecdb/trunk/TODO b/experimental/ecdb/trunk/TODO index 67e71d95..35b97366 100644 --- a/experimental/ecdb/trunk/TODO +++ b/experimental/ecdb/trunk/TODO @@ -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 diff --git a/experimental/ecdb/trunk/data/themes/default/groups/erase_disc.edc b/experimental/ecdb/trunk/data/themes/default/groups/erase_disc.edc index d2a12ef1..579848c8 100644 --- a/experimental/ecdb/trunk/data/themes/default/groups/erase_disc.edc +++ b/experimental/ecdb/trunk/data/themes/default/groups/erase_disc.edc @@ -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)] - */ } } } @@ -42,7 +38,7 @@ group { description { state: "before_show" 0.0; color: 0 0 0 0; - + rel1 { relative: 0.0 0.0; offset: -33 0; @@ -75,7 +71,7 @@ group { type: SWALLOW; repeat_events: 1; scale: 1; - + description { state: "default" 0.0; min: 100 26; diff --git a/experimental/ecdb/trunk/src/ecdb_burn.c b/experimental/ecdb/trunk/src/ecdb_burn.c index f305f580..e2533135 100644 --- a/experimental/ecdb/trunk/src/ecdb_burn.c +++ b/experimental/ecdb/trunk/src/ecdb_burn.c @@ -8,7 +8,8 @@ struct Burn_Data BurnSession *session; Eina_List *sources; Eina_List *tracks; - Ecdb_Project *proj; + 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; @@ -36,7 +37,8 @@ ecdb_burn_project(Ecdb_Burn_Project *proj) printf("Error: Cannot create burn data structure!\n"); return FALSE; } - data->proj = ECDB_PROJECT(proj); + 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 @@ -156,7 +158,8 @@ static void ecdb_burn_progress_handler(void *data, void *buffer, unsigned int nbyte) { BurnProgress *p; - Evas_Object *swallow; + Evas_Object *swallow; + Burn_Data *bdata; static int last_sector = 0; int percent; Edje_Message_Int_Set *progress_msg; @@ -186,11 +189,40 @@ ecdb_burn_progress_handler(void *data, void *buffer, unsigned int nbyte) else { last_sector = p->sectors; + } + + 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; } - swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee), - "burn_image_page"); - percent = (int)((double)(last_sector + 1) / (double)p->sectors * 100.0); if (percent >= 100) { @@ -230,23 +262,28 @@ ecdb_burn_finished(void *data, int type, void *event) burn_drive_info_free(proj->proj->drive->tangible); printf("Burn Complete\n"); - ecore_event_handler_del(proj->proj->ev_handler); - ecore_pipe_del(proj->proj->pipe); + 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)); + case ECDB_AUDIO_PROJECT: + 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); diff --git a/experimental/ecdb/trunk/src/ecdb_burn.h b/experimental/ecdb/trunk/src/ecdb_burn.h index 46800f86..f79ba567 100644 --- a/experimental/ecdb/trunk/src/ecdb_burn.h +++ b/experimental/ecdb/trunk/src/ecdb_burn.h @@ -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 diff --git a/experimental/ecdb/trunk/src/ecdb_burn_data_gui.c b/experimental/ecdb/trunk/src/ecdb_burn_data_gui.c index 42dbfe95..3f43bebc 100644 --- a/experimental/ecdb/trunk/src/ecdb_burn_data_gui.c +++ b/experimental/ecdb/trunk/src/ecdb_burn_data_gui.c @@ -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; @@ -197,8 +197,8 @@ _button_cb_begin(void *data, Evas_Object *obj __UNUSED__, default: snprintf(buf, sizeof(buf), "Unknown error :-("); - } - + } + edje_object_part_text_set(page->data, "progress_text", buf); burn_drive_release(ECDB_PROJECT(proj)->drive->tangible[0].drive, 1); burn_drive_info_free(ECDB_PROJECT(proj)->drive->tangible); @@ -271,14 +271,14 @@ _joliet_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, proj = data; proj->use_joliet = !proj->use_joliet; - + state = ecdb_check_checked_get(obj); if (state != proj->use_joliet) ecdb_check_checked_set(obj, proj->use_joliet); } static void -_joliet_config(void *data, Evas_Object *obj, void *event_info __UNUSED__) +_joliet_config(void *data, Evas_Object *obj, void *event_info __UNUSED__) { Ecdb_Data_Project *proj; @@ -296,7 +296,7 @@ _rockridge_clicked(void *data, Evas_Object *obj, proj = data; proj->use_rockridge = !proj->use_rockridge; - + state = ecdb_check_checked_get(obj); if (state != proj->use_rockridge) ecdb_check_checked_set(obj, proj->use_rockridge); @@ -320,7 +320,7 @@ _symlinks_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, proj = data; proj->follow_symlinks = !proj->follow_symlinks; - + state = ecdb_check_checked_get(obj); if (state != proj->follow_symlinks) ecdb_check_checked_set(obj, proj->follow_symlinks); @@ -344,7 +344,7 @@ _hidden_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, proj = data; proj->ignore_hidden = !proj->ignore_hidden; - + state = ecdb_check_checked_get(obj); if (state != proj->ignore_hidden) ecdb_check_checked_set(obj, proj->ignore_hidden); @@ -368,7 +368,7 @@ _multi_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, proj = data; proj->multi = !proj->multi; - + state = ecdb_check_checked_get(obj); if (state != proj->multi) ecdb_check_checked_set(obj, proj->multi); @@ -392,7 +392,7 @@ _sim_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, proj = data; proj->simulate = !proj->simulate; - + state = ecdb_check_checked_get(obj); if (state != proj->simulate) ecdb_check_checked_set(obj, proj->simulate); @@ -416,7 +416,7 @@ _underrun_clicked(void *data, Evas_Object *obj, const char *emission __UNUSED__, proj = data; proj->underrun_proof = !proj->underrun_proof; - + state = ecdb_check_checked_get(obj); if (state != proj->underrun_proof) ecdb_check_checked_set(obj, proj->underrun_proof); @@ -476,7 +476,7 @@ _settings_clicked(void *data, Evas_Object *obj __UNUSED__, table = edje_object_part_object_get(data, "ecdb.table"); it = evas_object_table_iterator_new(table); - + if (!it) { printf("_settings_clicked: NULL iterator!\n"); @@ -515,7 +515,7 @@ ecdb_burn_data_page_show(Ecdb_Page *page) "burn_data_page", _page_hide_finished, page->gui); evas_object_show(page->data); - + proj = ecdb_data_project_new(); bp = ECDB_PROJECT(proj); bup = ECDB_BURN(proj); @@ -580,7 +580,7 @@ ecdb_burn_data_page_show(Ecdb_Page *page) &x, &y, &w, &h); evas_object_move(proj->filelist_swallow, x, y); evas_object_resize(proj->filelist_swallow, w, h); - edje_object_part_swallow(page->data, "ecdb/burn_data/filelist", + edje_object_part_swallow(page->data, "ecdb/burn_data/filelist", proj->filelist_swallow); ecdb_widget_focus_callback_add(proj->filelist_swallow, "ecdb/burn_data/filelist"); @@ -594,14 +594,13 @@ ecdb_burn_data_page_show(Ecdb_Page *page) t = ecdb_config_inwin_add(bp->ret, NULL); ecdb_config_inwin_follow_set(t, page->data); - + b = ecdb_check_add(t, NULL); ecdb_check_label_set(b, "Use Joliet"); edje_object_signal_callback_add(b, "ecdb,check,*checked", "ecdb", _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,9 +664,8 @@ 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 b = ecdb_button_add(page->data, "ecdb/burn_data/settings"); ecdb_button_label_set(b, "Settings"); @@ -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; - 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"}; + Ecdb_Source *src; + Ecdb_Burn_Data_Project *proj; + int i; + + if (!page) + { + printf("ecdb_burn_data_cleanup: NULL page!\n"); + return; + } + + proj = evas_object_data_get(page->data, "proj"); + if (!proj) + { + printf("ecdb_burn_data_cleanup: NULL proj!\n"); + return; + } + + 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"); - if (!proj) - { - printf("ecdb_burn_data_cleanup: NULL project!\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"); - - filelist = ewl_widget_name_find("ecdb/burn_data/filelist"); + 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); - */ } diff --git a/experimental/ecdb/trunk/src/ecdb_burn_image_gui.c b/experimental/ecdb/trunk/src/ecdb_burn_image_gui.c index 17a7dbbf..9efdab2c 100644 --- a/experimental/ecdb/trunk/src/ecdb_burn_image_gui.c +++ b/experimental/ecdb/trunk/src/ecdb_burn_image_gui.c @@ -1,7 +1,7 @@ /* vim: set sw=3 ts=3 sts=3 expandtab: */ #include "ecdb.h" -static void _button_cb_return(void *data, Evas_Object *obj, +static void _button_cb_return(void *data, Evas_Object *obj, const char *emission, const char *source); static void _button_cb_begin(void *data, Evas_Object *obj, @@ -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; @@ -135,8 +135,8 @@ _button_cb_begin(void *data, Evas_Object *obj __UNUSED__, default: snprintf(buf, sizeof(buf), "Unknown error :-("); - } - + } + edje_object_part_text_set(page->image, "progress_text", buf); burn_drive_release(ECDB_PROJECT(proj)->drive->tangible[0].drive, 1); burn_drive_info_free(ECDB_PROJECT(proj)->drive->tangible); @@ -279,18 +279,34 @@ ecdb_burn_image_page_show(Ecdb_Page *page) } void -ecdb_burn_image_cleanup(void) -{ - /* - 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_cleanup(Ecdb_Page *page) +{ + 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); } diff --git a/experimental/ecdb/trunk/src/ecdb_burn_image_gui.h b/experimental/ecdb/trunk/src/ecdb_burn_image_gui.h index 822858c7..45f4fe4b 100644 --- a/experimental/ecdb/trunk/src/ecdb_burn_image_gui.h +++ b/experimental/ecdb/trunk/src/ecdb_burn_image_gui.h @@ -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 diff --git a/experimental/ecdb/trunk/src/ecdb_erase.c b/experimental/ecdb/trunk/src/ecdb_erase.c index 350a1f9f..dfa607bc 100644 --- a/experimental/ecdb/trunk/src/ecdb_erase.c +++ b/experimental/ecdb/trunk/src/ecdb_erase.c @@ -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; + 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 @@ -54,7 +71,8 @@ static void ecdb_erase_progress_handler(void *data, void *buffer, unsigned int nbyte) { BurnProgress *p; - Evas_Object *swallow; + Evas_Object *swallow; + Erase_Data *edata; static int last_sector = 0; Edje_Message_Int_Set *progress_msg; @@ -83,35 +101,55 @@ ecdb_erase_progress_handler(void *data, void *buffer, unsigned int nbyte) else { last_sector = p->sectors; + } + + edata = data; + if (!edata) + { + printf("ecdb_erase_progress_handler: NULL edata!\n"); + return; + } + + 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; } - swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee), - "erase_page"); - - progress_msg = alloca(sizeof(Edje_Message_Int_Set) + (4 * sizeof(int))); - progress_msg->count = 5; + 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; } diff --git a/experimental/ecdb/trunk/src/ecdb_erase_gui.c b/experimental/ecdb/trunk/src/ecdb_erase_gui.c index 7f0bf2b8..42de9dfe 100644 --- a/experimental/ecdb/trunk/src/ecdb_erase_gui.c +++ b/experimental/ecdb/trunk/src/ecdb_erase_gui.c @@ -56,7 +56,7 @@ _button_cb_begin(void *data, Evas_Object *o __UNUSED__, Ecdb_Page *page; char buf[1024]; int idx; - + page = data; proj = evas_object_data_get(page->erase, "proj"); snprintf(buf, sizeof(buf), "Commencing..."); @@ -79,7 +79,8 @@ _button_cb_begin(void *data, Evas_Object *o __UNUSED__, return; } - proj->quick = ecdb_check_checked_get(proj->speed); + 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) -{ - /* XXX - Evas_Object *swallow; - const char *ids[] = {"ecdb/erase/return", "ecdb/erase/begin", - "ecdb/erase/speed", "ecdb/erase/drive"}; +ecdb_erase_cleanup(Ecdb_Page *page) +{ + Ecdb_Erase_Project *proj; + + if (!page) + { + printf("ecdb_erase_cleanup: NULL page!\n"); + return; + } + + proj = evas_object_data_get(proj->erase, "proj"); + if (!proj) + { + printf("ecdb_erase_cleanup: NULL proj!\n"); + return; + } - 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"); - - swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee), - "ecdb/erase/drive"); - ecdb_check_checked_set(swallow, 0); - */ + 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; }