From 32640312d9f9be989352dfc9c56178a8ef23eaad Mon Sep 17 00:00:00 2001 From: Jaime Thomas Date: Tue, 9 Dec 2008 01:12:16 +0000 Subject: [PATCH] Lots of work... Add an entry widget (semi-broken), image burning now works, xdnd stuff. --- experimental/ecdb/trunk/TODO | 2 + .../trunk/data/themes/default/default.edc | 2 + .../data/themes/default/groups/burn_image.edc | 300 ++++++++++++++++++ .../data/themes/default/groups/button.edc | 10 - .../data/themes/default/groups/entry.edc | 176 ++++++++++ .../data/themes/default/groups/erase_disc.edc | 30 +- .../data/themes/default/images/entry.png | Bin 0 -> 620 bytes .../themes/default/images/entry_focus.png | Bin 0 -> 936 bytes .../data/themes/default/images/images.edc | 2 + experimental/ecdb/trunk/src/ecdb.c | 15 + experimental/ecdb/trunk/src/ecdb.h | 5 +- experimental/ecdb/trunk/src/ecdb_burn.c | 64 +++- experimental/ecdb/trunk/src/ecdb_common.h | 12 +- experimental/ecdb/trunk/src/ecdb_erase.c | 2 + experimental/ecdb/trunk/src/ecdb_gui.c | 225 ++++++++++++- experimental/ecdb/trunk/src/ecdb_gui.h | 1 + experimental/ecdb/trunk/src/ecdb_image.c | 8 +- experimental/ecdb/trunk/src/ecdb_misc.c | 94 +++++- experimental/ecdb/trunk/src/ecdb_misc.h | 10 + 19 files changed, 913 insertions(+), 45 deletions(-) create mode 100644 experimental/ecdb/trunk/data/themes/default/groups/burn_image.edc create mode 100644 experimental/ecdb/trunk/data/themes/default/groups/entry.edc create mode 100644 experimental/ecdb/trunk/data/themes/default/images/entry.png create mode 100644 experimental/ecdb/trunk/data/themes/default/images/entry_focus.png diff --git a/experimental/ecdb/trunk/TODO b/experimental/ecdb/trunk/TODO index 7a9cfacc..ca90e50f 100644 --- a/experimental/ecdb/trunk/TODO +++ b/experimental/ecdb/trunk/TODO @@ -4,3 +4,5 @@ -> ffmpeg instead of gstreamer -> finish interface -> more flexible typebuf +-> allow user to choose which drive to use +-> remove the image creation from ecdb_burn_project diff --git a/experimental/ecdb/trunk/data/themes/default/default.edc b/experimental/ecdb/trunk/data/themes/default/default.edc index 0e98bbf3..ae598867 100644 --- a/experimental/ecdb/trunk/data/themes/default/default.edc +++ b/experimental/ecdb/trunk/data/themes/default/default.edc @@ -12,4 +12,6 @@ collections { #include "groups/icons.edc" #include "groups/erase_disc.edc" #include "groups/check.edc" + #include "groups/burn_image.edc" + #include "groups/entry.edc" } diff --git a/experimental/ecdb/trunk/data/themes/default/groups/burn_image.edc b/experimental/ecdb/trunk/data/themes/default/groups/burn_image.edc new file mode 100644 index 00000000..e966c78a --- /dev/null +++ b/experimental/ecdb/trunk/data/themes/default/groups/burn_image.edc @@ -0,0 +1,300 @@ +group { + name: "ecdb/burn_image_page"; + min: 640 170; + + parts { + part { + name: "bg"; + type: RECT; + + description { + state: "default" 0.0; + color: 0 0 0 0; + + rel1 { + relative: 0.0 0.0; + offset: 0 0; + } + + rel2 { + relative: 1.0 1.0; + offset: -1 -1; + } + } + + description { + state: "before_show" 0.0; + color: 0 0 0 0; + + rel1 { + relative: 0.0 0.0; + offset: -33 0; + } + + rel2 { + relative: 0.0 0.0; + offset: -1 0; + } + } + + description { + state: "hide" 0.0; + color: 0 0 0 0; + + rel1 { + relative: 1.0 1.0; + offset: -1 -1; + } + + rel2 { + relative: 1.0 1.0; + offset: 33 33; + } + } + } + + part { + name: "ecdb/burn_image/return"; + type: SWALLOW; + repeat_events: 1; + + description { + state: "default" 0.0; + + rel1 { + to: "bg"; + relative: 0.5 0.0; + offset: 10 5; + } + + rel2 { + to: "bg"; + relative: 1.0 0.0; + offset: -11 50; + } + } + } + + part { + name: "ecdb/burn_image/begin"; + type: SWALLOW; + repeat_events: 1; + + description { + state: "default" 0.0; + + rel1 { + to: "ecdb/burn_image/return"; + relative: 0.0 1.0; + offset: 0 5; + } + + rel2 { + to: "ecdb/burn_image/return"; + relative: 1.0 1.0; + offset: 0 50; + } + } + } + + part { + name: "ecdb/burn_image/file"; + type: SWALLOW; + repeat_events: 1; + + description { + state: "default" 0.0; + + rel1 { + to: "ecdb/burn_image/begin"; + relative: 0.0 1.0; + offset: 0 5; + } + + rel2 { + to: "ecdb/burn_image/begin"; + relative: 1.0 1.0; + offset: 0 30; + } + } + } + + part { + name: "progress_outline"; + type: IMAGE; + mouse_events: 0; + + description { + state: "default" 0.0; + + rel1 { + to: "bg"; + relative: 0.0 0.0; + offset: 10 13; + } + + rel2 { + to: "bg"; + relative: 0.5 1.0; + offset: -1 -10; + } + + image { + normal: "frame_outline.png"; + border: 9 9 9 9; + } + } + } + + part { + name: "progress_text"; + type: TEXT; + effect: SOFT_SHADOW; + + description { + state: "default" 0.0; + fixed: 1 1; + color: 200 200 200 255; + color3: 20 20 20 255; + + rel1 { + to: "progress_outline"; + relative: 0.0 0.7; + offset: 5 5; + } + + rel2 { + to: "progress_outline"; + relative: 1.0 1.0; + offset: -6 -6; + } + + text { + text: "Begin Burn"; + font: "ecdb/default"; + min: 1 1; + size: 24; + align: 0.5 0.5; + } + } + + description { + state: "fade" 0.0; + inherit: "default" 0.0; + color: 255 255 255 0; + } + } + + part { + name: "progress_percent"; + type: TEXT; + effect: SOFT_SHADOW; + + description { + state: "default" 0.0; + fixed: 1 1; + color: 200 200 200 255; + color3: 20 20 20 255; + + rel1 { + to: "progress_outline"; + relative: 0.0 0.0; + offset: 5 5; + } + + rel2 { + to: "progress_outline"; + relative: 1.0 0.7; + offset: -6 -6; + } + + text { + text: "0%"; + font: "ecdb/default"; + min: 1 1; + size: 72; + align: 0.5 0.5; + } + } + } + + part { + name: "disabled_hack"; + type: RECT; + mouse_events: 1; + + description { + state: "default" 0.0; + visible: 0; + + rel1 { + to: "bg"; + relative: 0.5 0.0; + offset: 0 0; + } + + rel2 { + to: "bg"; + relative: 1.0 1.0; + offset: -1 -1; + } + } + + description { + state: "visible" 0.0; + inherit: "default" 0.0; + color: 255 255 255 0; + visible: 1; + } + } + } + + programs { + program { + name: "burn_image_page,visible1"; + signal: "ecdb,burn_image_page,visible"; + source: "ecdb"; + action: STATE_SET "before_show" 0.0; + target: "bg"; + after: "burn_image_page,visible2"; + } + + program { + name: "burn_image_page,visible2"; + action: STATE_SET "default" 0.0; + target: "bg"; + transition: DECELERATE 0.5; + } + + program { + name: "burn_image_page,hide"; + signal: "ecdb,burn_image_page,hide"; + source: "ecdb"; + action: STATE_SET "hide" 0.0; + target: "bg"; + transition: DECELERATE 0.5; + after: "hide,finished"; + } + + program { + name: "burn_image_page,controls_disable"; + signal: "ecdb,burn_image,start"; + source: "ecdb"; + action: STATE_SET "visible" 0.0; + target: "disabled_hack"; + } + + program { + name: "burn_image_page,controls_enable"; + signal: "ecdb,burn_image,done"; + source: "ecdb"; + action: STATE_SET "default" 0.0; + target: "disabled_hack"; + } + + program { + name: "hide,finished"; + action: SIGNAL_EMIT "hide,finished" "burn_image_page"; + } + } +} diff --git a/experimental/ecdb/trunk/data/themes/default/groups/button.edc b/experimental/ecdb/trunk/data/themes/default/groups/button.edc index a38fffc6..02ea3469 100644 --- a/experimental/ecdb/trunk/data/themes/default/groups/button.edc +++ b/experimental/ecdb/trunk/data/themes/default/groups/button.edc @@ -12,16 +12,6 @@ group { min: 0 26; color: 255 255 255 178; - rel1 { - relative: 0.0 0.0; - offset: 3 4; - } - - rel2 { - relative: 1.0 1.0; - offset: -4 -5; - } - image { normal: "button_base.png"; border: 7 7 7 7; diff --git a/experimental/ecdb/trunk/data/themes/default/groups/entry.edc b/experimental/ecdb/trunk/data/themes/default/groups/entry.edc new file mode 100644 index 00000000..842c82b6 --- /dev/null +++ b/experimental/ecdb/trunk/data/themes/default/groups/entry.edc @@ -0,0 +1,176 @@ +group { + name: "ecdb/entry"; + min: 18 18; + + styles { + style { + name: "entry_default"; + base: "font=ecdb/default font_size=11 align=left color=#000 wrap=none"; + tag: "br" "\n"; + tag: "tab" "\t"; + tag: "hilight" "+ font=Sans:style:Bold"; + // Need any tags? + } + } + + parts { + part { + name: "entry"; + + description { + state: "default" 0.0; + + image { + normal: "entry.png"; + border: 6 6 8 7; + } + } + + description { + state: "disabled" 0.0; + inherit: "default" 0.0; + color: 255 255 255 128; + } + } + + part { + name: "entry_focus"; + + description { + state: "default" 0.0; + color: 255 255 255 0; + + image { + normal: "entry_focus.png"; + border: 7 7 8 7; + middle: 0; + } + + fill { + smooth: 0; + } + } + + description { + state: "focused" 0.0; + inherit: "default" 0.0; + color: 255 255 255 255; + } + } + + part { + name: "label"; + type: TEXTBLOCK; + mouse_events: 1; + entry_mode: EDITABLE; + multiline: 0; + source2: "entry/selection/default"; + source3: "entry/cursor/default"; + + description { + state: "default" 0.0; + text { + style: "entry_default"; + min: 1 1; + } + + rel1 { + to: "entry"; + offset: 5 3; + } + + rel2 { + to: "entry"; + offset: -2 -2; + } + } + } + } + + programs { + program { + name: "focus1"; + action: FOCUS_SET; + signal: "mouse,down,*"; + source: "*"; + target: "label"; + } + + program { + name: "focus2"; + action: STATE_SET "focused" 0.0; + signal: "mouse,down,*"; + source: "*"; + target: "entry_focus"; + transition: DECELERATE 0.5; + } + + program { + name: "focus_out"; + signal: "ecdb,focus,out"; + action: STATE_SET "default" 0.0; + source: "ecdb"; + target: "entry_focus"; + transition: DECELERATE 0.5; + } + + program { + name: "disable"; + signal: "ecdb,disable"; + action: STATE_SET "disabled" 0.0; + source: "ecdb"; + target: "entry"; + } + + program { + name: "enable"; + signal: "ecdb,enable"; + action: STATE_SET "default" 0.0; + source: "ecdb"; + target: "entry"; + } + } +} + +group { + name: "entry/cursor/default"; + + parts { + part { + name: "cursor"; + type: RECT; + mouse_events: 0; + + description { + state: "default" 0.0; + color: 0 0 0 255; + min: 1 1; + rel1 { + relative: 0.0 0.0; + offset: 1 3; + } + + rel2 { + relative: 0.0 1.0; + offset: 0 -2; + } + } + } + } +} + +group { + name: "entry/selection/default"; + parts { + part { + name: "selection"; + type: RECT; + mouse_events: 0; + + description { + state: "default" 0.0; + color: 138 171 225 128; + } + } + } +} 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 bca55a6a..7035ba2d 100644 --- a/experimental/ecdb/trunk/data/themes/default/groups/erase_disc.edc +++ b/experimental/ecdb/trunk/data/themes/default/groups/erase_disc.edc @@ -64,13 +64,13 @@ group { rel1 { to: "bg"; relative: 0.5 0.0; - offset: 10 10; + offset: 10 5; } rel2 { to: "bg"; - relative: 1.0 0.3; - offset: -11 -11; + relative: 1.0 0.0; + offset: -11 50; } } } @@ -84,15 +84,15 @@ group { state: "default" 0.0; rel1 { - to: "bg"; - relative: 0.5 0.3; - offset: 10 10; + to: "ecdb/erase/return"; + relative: 0.0 1.0; + offset: 0 5; } rel2 { - to: "bg"; - relative: 1.0 0.6; - offset: -11 -11; + to: "ecdb/erase/return"; + relative: 1.0 1.0; + offset: 0 50; } } } @@ -106,15 +106,15 @@ group { state: "default" 0.0; rel1 { - to: "bg"; - relative: 0.5 0.6; - offset: 10 10; + to: "ecdb/erase/begin"; + relative: 0.0 1.0; + offset: 0 5; } rel2 { - to: "bg"; - relative: 1.0 0.9; - offset: -11 -11; + to: "ecdb/erase/begin"; + relative: 1.0 1.0; + offset: 0 30; } } } diff --git a/experimental/ecdb/trunk/data/themes/default/images/entry.png b/experimental/ecdb/trunk/data/themes/default/images/entry.png new file mode 100644 index 0000000000000000000000000000000000000000..a52b2caa622075e82083c1e671b2ffdb2d4ee34e GIT binary patch literal 620 zcmV-y0+aoTP)Xh%&o}qq%)lK3AyScOtc;BX7E5WVPhjmng{8H2Hokyc*y<}#QQByX zG3vsy%I>fO3^SXV&q82OScQzIy!YmpbI!f@Bdn?0?Rr{k4FGAHrkzeF#$UwD1OP+4hi-_?QH6EGeS(QWJ~&iO4IygWF#_ht!~0MP68{3r^ao(%hklj+3F=P{TW%!L6W zDr|6Ji9io+)!v^@qeB3%R!|{?9t^%c64EiZZr(tpQbC^QJ2^c&4>3F)ddGwQb7npw zB9_a|I7zDQJ9p7+HsN{Rzhf^_gkcD4t9bw6V`G^^0zj5!sZvU}S}j;>A*I~4Qn;=Q zDJ4FA{wkNnH~`RYw`WFc_`VMz1on|q3N{F!l)`Tp1pp)*7-O)n9LGUmEtJy5TG0`q zjFeWJP$5-0sNCXIsd7-Mw?cI}r`tMJrQ>huR2jGAMH%#Z$Nmb+%)T+@;u~$yXsB!J zPPJ>?^!q48mgRfFa%Rlp1itSkI{5VjR`Kh#VEW@cLU=LR3z{UC7*A%f)yg!`I$i%! zY4dvh_2?{mJQ`0#|1?}1xC9VG>&?y`A}A%`8hKf(`A1sH@t;$t&de{EdBn_f-c1oR ze_`fl%v|4?{0p!LAON5NqyR36D86F!`HOQ5Aie6`f74GZG~kh3N|KKN0000Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iFP{ z4H^(`u^$Tn00SsVL_t(I%dM49XdHDE$3O2kzn$Hkq}eoWwoM>SDXA4bh=)=eK?ILQ zJa|y_W{x>{^U|}PiXzy9f?mXbAXr4b2^A#@jSBvyYFiQ8q$xFN*35Qi=J%e5*=#mp zYZd*%V`hHy=EM8FKfe+Bw6L&HkK;H7$g(V(otr~wQgE4m=sIz~!r&bYM zH!3sji_~GJs0mpRs?{owv|GG>cG8_+)~%d=a;eeYQ%gD6jA;y&z)DmCOYNu>u9uR= zP|S3*&Qj_)^-*E{-Z{X?P>hcZ=lX$zB?8WYk6?5pLHa(}gx<_T)LXg@Z%03tQD+*l zayr?HbmeqXw1Y?00Oj9FQ8n6yXF#%q|03Cz@vf3ez&ROEl-tSSoRCz)c4%`xm1?Bj z;wbhHan{|w2voh%oKIz2q#{CIKrn~u_9+^Cn1E{OpBH62yz%&2(u02cTrD}YCu8}B zk#>|Uhe9EAtq9t)&F4HAS%9>oEUz0gdkd!a`$n(%YZc<7(|Pgk7j3_9SG~+}0g-5L zic}5fq&Ho`O5oLXAM%t5bX9yN8E|mo}kEC(mE_^-62*%-0ru{G(^36=6Up z7g`;mP{BK6SIwwb$|B8-EBDVR58o^Kfqlso2NZNmjkD1v^s(M{jZ>p-PstwZS zJ5_B3)!)qQl$nhU?07S)10z5TWWc(Jv~Te%NxFUpWViDB-}D#tKcYR#rnQ3r0000< KMNUMnLSTZaOucXb literal 0 HcmV?d00001 diff --git a/experimental/ecdb/trunk/data/themes/default/images/images.edc b/experimental/ecdb/trunk/data/themes/default/images/images.edc index 1d09092e..e4abe625 100644 --- a/experimental/ecdb/trunk/data/themes/default/images/images.edc +++ b/experimental/ecdb/trunk/data/themes/default/images/images.edc @@ -18,4 +18,6 @@ images { image: "check_focus.png" COMP; image: "check_shadow.png" COMP; image: "button_disabled.png" COMP; + image: "entry.png" COMP; + image: "entry_focus.png" COMP; } diff --git a/experimental/ecdb/trunk/src/ecdb.c b/experimental/ecdb/trunk/src/ecdb.c index f7b51f28..b48a3aae 100644 --- a/experimental/ecdb/trunk/src/ecdb.c +++ b/experimental/ecdb/trunk/src/ecdb.c @@ -48,6 +48,13 @@ main(int argc, char **argv) goto SHUTDOWN; } + if (!efreet_init()) + { + printf("Cannot initialize Efreet!\n"); + ret = 1; + goto SHUTDOWN; + } + if (!ewl_init(&argc, argv)) { printf("Connot initialize Ewl!\n"); @@ -141,6 +148,7 @@ SHUTDOWN: ecore_evas_shutdown(); ecore_shutdown(); edje_shutdown(); + efreet_shutdown(); printf("Program Done\n"); return ret; @@ -152,6 +160,8 @@ ecdb_setup(void) em = NULL; em = calloc(1, sizeof(Ecdb_Main)); em->drives = NULL; + em->drop_object = NULL; + em->dnd_candidates = ecore_list_new(); if (!ecore_file_mkdir("/tmp/ecdb")) printf("Creation of temporary directory failed!\n"); @@ -162,6 +172,11 @@ ecdb_setup(void) ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, ecdb_shutdown, NULL); + ecore_event_handler_add(ECORE_X_EVENT_XDND_POSITION, ecdb_dnd_position, + em); + ecore_event_handler_add(ECORE_X_EVENT_XDND_DROP, ecdb_dnd_drop, em); + ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY, + ecdb_dnd_selection, em); if (!ecdb_aquire_drive_info()) { diff --git a/experimental/ecdb/trunk/src/ecdb.h b/experimental/ecdb/trunk/src/ecdb.h index 259f71a1..2fc742d7 100644 --- a/experimental/ecdb/trunk/src/ecdb.h +++ b/experimental/ecdb/trunk/src/ecdb.h @@ -6,10 +6,11 @@ #include #include #include -#include #include #include #include +#include +#include #include #include #include @@ -42,6 +43,8 @@ struct _Ecdb_Main char theme_path[PATH_MAX]; Ecore_Evas *main_win_ee; Ecore_List *drives; + Ecore_List *dnd_candidates; + Evas_Object *drop_object; }; extern Ecdb_Main *em; diff --git a/experimental/ecdb/trunk/src/ecdb_burn.c b/experimental/ecdb/trunk/src/ecdb_burn.c index ed3be979..7f0f7fe5 100644 --- a/experimental/ecdb/trunk/src/ecdb_burn.c +++ b/experimental/ecdb/trunk/src/ecdb_burn.c @@ -65,7 +65,7 @@ ecdb_burn_project_destroy(Ecdb_Burn_Project *proj) FREE(proj->abstract_id); FREE(proj->biblio_id); ecdb_project_destroy(ECDB_PROJECT(proj)); - free(proj); + FREE(proj); } int @@ -87,6 +87,8 @@ ecdb_burn_project(Ecdb_Burn_Project *proj) return FALSE; } data->proj = ECDB_PROJECT(proj); + data->sources = ecore_list_new(); + data->tracks = ecore_list_new(); if (proj->burn_mode != BURN_AUDIO) padding = 300*1024; @@ -102,14 +104,14 @@ ecdb_burn_project(Ecdb_Burn_Project *proj) if (!source) { printf("Failed to add any files to burn disc!\n"); - return FALSE; + return ECDB_ERROR_IMAGE_CREATE; } if (burn_track_set_source(track, source) != BURN_SOURCE_OK) { printf("Error: Cannot attach source object to track " "object!\n"); - return FALSE; + return ECDB_ERROR_SOURCE_ATTACH; } burn_session_add_track(data->session, track, BURN_POS_END); @@ -133,7 +135,7 @@ ecdb_burn_project(Ecdb_Burn_Project *proj) { printf("Error: Failed to find a suitable write mode for " "disc!\n"); - return FALSE; + return ECDB_ERROR_WRITE_MODE; } burn_disc_write(opts, data->disc); @@ -149,7 +151,7 @@ ecdb_burn_project(Ecdb_Burn_Project *proj) (ECDB_DRIVE_ACTION_FINISHED, ecdb_burn_finished, data); - return TRUE; + return ECDB_ERROR_NONE; } /* This function is pretty naive... Should probably update it at some time */ @@ -191,9 +193,39 @@ ecdb_drive_progress_update(void *data) static void ecdb_burn_progress_handler(void *data, void *buffer, unsigned int nbyte) { - BurnProgress *p = buffer; + BurnProgress *p; + Evas_Object *swallow; + char buf[1024]; + static int last_sector = 0; - printf("Sector %d of %d\n", p->sector, p->sectors); + 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; + } + + + /* 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), + "burn_image_page"); + 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 @@ -227,14 +259,18 @@ 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(ECDB_PROJECT(proj)->ev_handler); + ecore_event_handler_del(proj->proj->ev_handler); + + switch (proj->proj->type) + { + case ECDB_AUDIO_PROJECT: + ecdb_audio_project_destroy(ECDB_AUDIO(proj->proj)); + break; + default: + ecdb_burn_project_destroy(ECDB_BURN(proj->proj)); + } + FREE(proj); /* To be removed from here at some point */ - Ecdb_Burn_Project *t; - t = ECDB_BURN(proj->proj); - FREE(t->files); - FREE(t); - FREE(proj); - ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, NULL, NULL, NULL); return TRUE; } diff --git a/experimental/ecdb/trunk/src/ecdb_common.h b/experimental/ecdb/trunk/src/ecdb_common.h index 5e3b924a..90002ca2 100644 --- a/experimental/ecdb/trunk/src/ecdb_common.h +++ b/experimental/ecdb/trunk/src/ecdb_common.h @@ -17,7 +17,17 @@ enum _Ecdb_Project_Type ECDB_BURN_PROJECT, ECDB_AUDIO_PROJECT, ECDB_ERASE_PROJECT, - ECDB_COPY_PROJECT + ECDB_COPY_PROJECT, + ECDB_IMAGE_PROJECT +}; + +typedef enum _Ecdb_Burn_Result Ecdb_Burn_Result; +enum _Ecdb_Burn_Result +{ + ECDB_ERROR_IMAGE_CREATE, + ECDB_ERROR_SOURCE_ATTACH, + ECDB_ERROR_WRITE_MODE, + ECDB_ERROR_NONE }; typedef struct _Ecdb_Drive_Info Ecdb_Drive_Info; diff --git a/experimental/ecdb/trunk/src/ecdb_erase.c b/experimental/ecdb/trunk/src/ecdb_erase.c index edff271c..9eb5f899 100644 --- a/experimental/ecdb/trunk/src/ecdb_erase.c +++ b/experimental/ecdb/trunk/src/ecdb_erase.c @@ -40,8 +40,10 @@ void ecdb_erase_project_destroy(Ecdb_Erase_Project *proj) { ecdb_project_destroy(ECDB_PROJECT(proj)); + FREE(proj); } +// FIXME Make this return an error code int ecdb_erase_disc(Ecdb_Erase_Project *proj) { diff --git a/experimental/ecdb/trunk/src/ecdb_gui.c b/experimental/ecdb/trunk/src/ecdb_gui.c index 80531833..142ed800 100644 --- a/experimental/ecdb/trunk/src/ecdb_gui.c +++ b/experimental/ecdb/trunk/src/ecdb_gui.c @@ -7,6 +7,8 @@ static void ecdb_cb_welcome_page_buttons_clicked(void *data, Evas_Object *o, const char *emission, const char *source); static void ecdb_cb_erase_page_buttons_clicked(void *data, Evas_Object *o, const char *emission, const char *source); +static void ecdb_cb_burn_image_page_buttons_clicked(void *data, Evas_Object *o, + const char *emission, const char *source); static void ecdb_cb_page_hide_finished(void *data, Evas_Object *o, const char *emission, const char *source); static void ecdb_gui_controls_disable(const char **ids, int n); @@ -14,6 +16,7 @@ static void ecdb_gui_controls_enable(const char **ids, int n); static void ecdb_filelist_show(void); static void ecdb_welcome_page_show(void); static void ecdb_erase_page_show(void); +static void ecdb_burn_image_page_show(void); static void ecdb_page_hide(const char *pname); static void @@ -160,6 +163,11 @@ ecdb_create_main_gui(void) ecore_evas_title_set(em->main_win_ee, "ECDB"); ecore_evas_name_class_set(em->main_win_ee, "ECDB", "ECDB"); + ecore_evas_avoid_damage_set(em->main_win_ee, 1); + ecore_x_dnd_aware_set(ecore_evas_software_x11_window_get + (em->main_win_ee), 1); + ecore_x_dnd_type_set(ecore_evas_software_x11_window_get + (em->main_win_ee), "*", 1); ecore_evas_callback_delete_request_set(em->main_win_ee, ecdb_shutdown); ecore_evas_callback_destroy_set(em->main_win_ee, ecdb_shutdown); @@ -336,6 +344,15 @@ ecdb_cb_welcome_page_buttons_clicked(void *data, Evas_Object *o, "ecdb"); ecdb_erase_page_show(); } + else if (!strcmp(source, "ecdb/burn_image")) + { + ecdb_filelist_show(); + swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee), + "welcome_page"); + edje_object_signal_emit(swallow, "ecdb,welcome_page,hide", + "ecdb"); + ecdb_burn_image_page_show(); + } else if (swallow) edje_object_signal_emit(gui, "ecdb,filelist,hide", "ecdb"); @@ -380,11 +397,12 @@ ecdb_cb_erase_page_buttons_clicked(void *data, Evas_Object *o, return; } + proj->quick = speed; if (!ecdb_erase_disc(proj)) { Ecdb_Project *p = ECDB_PROJECT(proj); - printf("Couldn't begin burn!\n"); + printf("Disc not erasable!\n"); snprintf(buf, sizeof(buf), "Disc not erasable!"); edje_object_part_text_set(swallow, "progress_text", buf); burn_drive_release(p->drive->tangible[0].drive, 0); @@ -393,7 +411,7 @@ ecdb_cb_erase_page_buttons_clicked(void *data, Evas_Object *o, return; } - proj->quick = speed; + speed = 0; edje_object_signal_emit(swallow, "ecdb,erase,start", "ecdb"); const char *ids[] = {"ecdb/erase/return", "ecdb/erase/begin", @@ -407,6 +425,115 @@ ecdb_cb_erase_page_buttons_clicked(void *data, Evas_Object *o, } } +static void +ecdb_cb_burn_image_page_buttons_clicked(void *data, Evas_Object *o, + const char *emission, const char *source) +{ + Evas_Object *swallow, *gui; + + 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_image_page"); + + if (!strcmp(source, "ecdb/burn_image/return")) + { + char *signal; + + edje_object_part_text_set(swallow, "progress_text", + "Begin Burn"); + edje_object_part_text_set(swallow, "progress_percent", "0%"); + signal = evas_object_data_get(swallow, "hide_signal"); + edje_object_signal_emit(swallow, signal, "ecdb"); + ecdb_welcome_page_show(); + + /* Hide the filelist to be nice */ + edje_object_signal_emit(gui, "ecdb,filelist,hide", "ecdb"); + } + else if (!strcmp(source, "ecdb/burn_image/begin")) + { + Ecdb_Burn_Project *proj; + Evas_Object *entry; + Ecdb_Source *iso_file; + Efreet_Uri *uri; + const char *file; + char *sanitized_file; + char buf[1024]; + Ecdb_Burn_Result burn_result; + + proj = ecdb_burn_project_new(); + ecdb_project_type_set(ECDB_PROJECT(proj), ECDB_IMAGE_PROJECT); + entry = evas_object_name_find(ecore_evas_get(em->main_win_ee), + "ecdb/burn_image/file"); + file = edje_object_part_text_get(entry, "label"); + + //Textblock returns a
at the end, so chop that off + sanitized_file = alloca(sizeof(char) * (strlen(file) - 3)); + sanitized_file[0] = '\0'; + ecore_strlcpy(sanitized_file, file, strlen(file) - 3); + + uri = efreet_uri_decode(sanitized_file); + iso_file = ecdb_source_new(); + ecdb_source_data_set(iso_file, uri->path); + ecdb_source_child_append(proj->files, iso_file); + efreet_uri_free(uri); + + snprintf(buf, sizeof(buf), "Commencing..."); + edje_object_part_text_set(swallow, "progress_text", buf); + if (!ecdb_aquire_drive(ECDB_PROJECT(proj), 0)) + { + printf("Couldn't grab drive!\n"); + ecdb_burn_project_destroy(proj); + edje_object_part_text_set(swallow, "progress_text", + "Couldn't grab the drive!"); + return; + } + + burn_result = ecdb_burn_project(proj); + switch (burn_result) + { + case ECDB_ERROR_NONE: + edje_object_signal_emit(gui, + "ecdb,filelist,hide", "ecdb"); + edje_object_signal_emit(swallow, + "ecdb,burn_image,start", + "ecdb"); + const char *ids[] = {"ecdb/burn_image/return", + "ecdb/burn_image/begin", + "ecdb/burn_image/file"}; + ecdb_gui_controls_disable(ids, 3); + return; + + case ECDB_ERROR_IMAGE_CREATE: + snprintf(buf, sizeof(buf), "Invalid file!"); + break; + + case ECDB_ERROR_SOURCE_ATTACH: + snprintf(buf, sizeof(buf), + "Couldn't attach source data!"); + break; + + case ECDB_ERROR_WRITE_MODE: + snprintf(buf, sizeof(buf), + "No suitable burn mode!"); + break; + + default: + 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); + } + else if (!strcmp(source, "ecdb/burn_image/file")) + { + evas_object_focus_set(o, 1); + } + +} + static void ecdb_welcome_page_show(void) { @@ -629,6 +756,87 @@ ecdb_erase_page_show(void) edje_object_signal_emit(swallow, "ecdb,erase_page,visible", "ecdb"); } +static void +ecdb_burn_image_page_show(void) +{ + Evas_Object *swallow, *gui; + + 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_image_page"); + + if (!swallow) + { + Evas_Coord x, y, w, h; + + swallow = edje_object_add(ecore_evas_get(em->main_win_ee)); + edje_object_file_set(swallow, em->theme_path, + "ecdb/burn_image_page"); + evas_object_name_set(swallow, "burn_image_page"); + evas_object_data_set(swallow, "hide_signal", + "ecdb,burn_image_page,hide"); + edje_object_part_geometry_get(gui, "active_area", + &x, &y, &w, &h); + evas_object_move(swallow, x, y); + evas_object_resize(swallow, w, h); + edje_object_part_swallow(gui, "action_area", swallow); + evas_object_show(swallow); + edje_object_signal_callback_add(swallow, "mouse,down,1", + "ecdb/*", ecdb_cb_controls_focused, + NULL); + edje_object_signal_callback_add(swallow, "mouse,clicked,1", + "ecdb/burn_image/*", + ecdb_cb_burn_image_page_buttons_clicked, NULL); + edje_object_signal_callback_add(swallow, "hide,finished", + "burn_image_page", ecdb_cb_page_hide_finished, + NULL); + evas_object_show(swallow); + + int i; + char *labels[] = {"Return to Main Page", "Start Burn", + "Burn File"}; + char *ids[] = {"ecdb/burn_image/return", + "ecdb/burn_image/begin", + "ecdb/burn_image/file"}; + char *wtype[] = {"ecdb/button", "ecdb/button", "ecdb/entry"}; + + for (i = 0; i < 3; i++) + { + Evas_Object *b; + b = edje_object_add(ecore_evas_get(em->main_win_ee)); + evas_object_name_set(b, ids[i]); + edje_object_file_set(b, em->theme_path, wtype[i]); + edje_object_part_geometry_get(swallow, ids[i], &x, + &y, &w, &h); + evas_object_move(b, x, y); + evas_object_resize(b, w, h); + edje_object_part_text_set(b, "label", labels[i]); + edje_object_part_swallow(swallow, ids[i], b); + evas_object_show(b); + + if (!strcmp("ecdb/button", wtype[i])) + ecdb_button_icon_swallow(ecore_evas_get( + em->main_win_ee), b, ids[i]); + else if (!strcmp("ecdb/entry", wtype[i])) + { + ecore_list_append(em->dnd_candidates, b); + evas_object_data_set(b, "dnd_call_func", + ecdb_dnd_entry_dnd_set); + } + } + } + + else if (edje_object_part_swallow_get(gui, "action_area") != swallow) + { + edje_object_part_swallow(gui, "action_area", swallow); + evas_object_show(swallow); + } + + edje_object_signal_emit(gui, "ecdb,burn_image_page,visible", "ecdb"); + edje_object_signal_emit(swallow, "ecdb,burn_image_page,visible", + "ecdb"); +} + /* Hurrah! Fancyness */ static void ecdb_cb_page_hide_finished(void *data, Evas_Object *o, const char *emission, @@ -679,3 +887,16 @@ ecdb_gui_erase_cleanup(void) edje_object_signal_emit(swallow, "ecdb,erase,done", "ecdb"); } +void +ecdb_gui_burn_image_cleanup(void) +{ + Evas_Object *swallow; + const char *ids[] = {"ecdb/burn_image/return", "ecdb/burn_image/begin", + "ecdb/burn_image/file"}; + 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, 3); + edje_object_signal_emit(swallow, "ecdb,burn_image,done", "ecdb"); +} + diff --git a/experimental/ecdb/trunk/src/ecdb_gui.h b/experimental/ecdb/trunk/src/ecdb_gui.h index ea056670..0415cd1c 100644 --- a/experimental/ecdb/trunk/src/ecdb_gui.h +++ b/experimental/ecdb/trunk/src/ecdb_gui.h @@ -4,5 +4,6 @@ int ecdb_create_main_gui(void); void ecdb_set_main_theme(const char *theme_name); void ecdb_gui_erase_cleanup(void); +void ecdb_gui_burn_image_cleanup(void); #endif diff --git a/experimental/ecdb/trunk/src/ecdb_image.c b/experimental/ecdb/trunk/src/ecdb_image.c index 30e305e7..f9910e98 100644 --- a/experimental/ecdb/trunk/src/ecdb_image.c +++ b/experimental/ecdb/trunk/src/ecdb_image.c @@ -54,7 +54,7 @@ ecdb_source_destroy(Ecdb_Source *src) void ecdb_source_data_set(Ecdb_Source *src, const char *dst) { - if (!src) + if ((!src) || (!ecore_file_exists(dst))) return; src->dst = eina_stringshare_add(dst); @@ -204,6 +204,12 @@ ecdb_image_project(Ecdb_Burn_Project *proj) data_src = burn_file_source_new(c->dst, NULL); goto FIFO_CREATE; } + else if (ECDB_PROJECT(proj)->type == ECDB_IMAGE_PROJECT) + { + printf("Supplied file is not an image!\n"); + efreet_mime_shutdown(); + return NULL; + } efreet_mime_shutdown(); } diff --git a/experimental/ecdb/trunk/src/ecdb_misc.c b/experimental/ecdb/trunk/src/ecdb_misc.c index 1bd572b4..7823dbe8 100644 --- a/experimental/ecdb/trunk/src/ecdb_misc.c +++ b/experimental/ecdb/trunk/src/ecdb_misc.c @@ -26,7 +26,7 @@ ecdb_project_init(Ecdb_Project *proj) void ecdb_project_destroy(Ecdb_Project *proj) { - free(proj); + printf("Destroying base project\n"); } void @@ -155,4 +155,96 @@ ecdb_button_icon_swallow(Evas *e, Evas_Object *b, const char *iname) evas_object_show(icon); } +int +ecdb_dnd_position(void *data, int type, void *event) +{ + Ecore_X_Event_Xdnd_Position *ev; + Evas_Object *o; + Ecore_X_Rectangle rect; + Evas_Coord window_x, window_y, window_w, window_h, x, y, w, h; + ev = event; + if (ev->win != ecore_evas_software_x11_window_get(em->main_win_ee)) + return 1; + + ecore_evas_geometry_get(em->main_win_ee, &window_x, + &window_y, &window_w, &window_h); + ecore_list_first_goto(em->dnd_candidates); + while ((o = ecore_list_next(em->dnd_candidates))) + { + if (evas_object_visible_get(o)) + { + evas_object_geometry_get(o, &x, &y, &w, &h); + x += window_x; + y += window_y; + + if ((ev->position.x >= x) && (ev->position.x <= (x+w)) + && (ev->position.y >= y) + && (ev->position.y <= (y + h))) + { + rect.x = x; + rect.y = y; + rect.width = w; + rect.height = h; + em->drop_object = o; + ecore_x_dnd_send_status(1, 1, rect, + ECORE_X_DND_ACTION_PRIVATE); + return 1; + } + } + } + + rect.x = window_x; + rect.y = window_y; + rect.width = window_w; + rect.height = window_h; + ecore_x_dnd_send_status(0, 1, rect, ECORE_X_DND_ACTION_PRIVATE); + + return 1; +} + +int +ecdb_dnd_drop(void *data, int type, void *event) +{ + if (em->drop_object) + { + ecore_x_selection_xdnd_request + (ecore_evas_software_x11_window_get(em->main_win_ee), + "text/uri-list"); + } + return 1; +} + +int +ecdb_dnd_selection(void *data, int type, void *event) +{ + Ecore_X_Event_Selection_Notify *ev; + Ecore_X_Selection_Data_Files *files; + void (*call_func)(Evas_Object *, Ecore_X_Selection_Data_Files *) = + NULL; + + ev = event; + if ((!em->drop_object) || (ev->selection != ECORE_X_SELECTION_XDND) + || (!(files = ev->data)) || (files->num_files <= 0)) + { + ecore_x_dnd_send_finished(); + return 1; + } + + call_func = evas_object_data_get(em->drop_object, "dnd_call_func"); + if (call_func != NULL) + call_func(em->drop_object, files); + + em->drop_object = NULL; + ecore_x_dnd_send_finished(); + return 1; +} + + +// For use with the entry group, where only one file is valid. We take the +// first one and ignore the rest (if any) +void +ecdb_dnd_entry_dnd_set(Evas_Object *o, Ecore_X_Selection_Data_Files *files) +{ + edje_object_part_text_set(o, "label", files->files[0]); +} diff --git a/experimental/ecdb/trunk/src/ecdb_misc.h b/experimental/ecdb/trunk/src/ecdb_misc.h index fb956bac..a7a1ccaf 100644 --- a/experimental/ecdb/trunk/src/ecdb_misc.h +++ b/experimental/ecdb/trunk/src/ecdb_misc.h @@ -1,6 +1,8 @@ #ifndef ECDB_MISC_H #define ECDB_MISC_H +// At some point I should move the ecdb_project_* stuff into its own file, +// and the init and shutdown stuff into ecdb.c Ecdb_Project *ecdb_project_new(void); int ecdb_project_init(Ecdb_Project *proj); void ecdb_project_destroy(Ecdb_Project *proj); @@ -16,4 +18,12 @@ char *ecdb_strip_next_argument(const char *strip); char *ecdb_strip_string(const char *strip); void ecdb_button_icon_swallow(Evas *e, Evas_Object *b, const char *iname); + +// Also consider moving dnd stuff into its own file +int ecdb_dnd_position(void *data, int type, void *event); +int ecdb_dnd_drop(void *data, int type, void *event); +int ecdb_dnd_selection(void *data, int type, void *event); +void ecdb_dnd_entry_dnd_set(Evas_Object *o, + Ecore_X_Selection_Data_Files *files); + #endif