Lots of work... Add an entry widget (semi-broken), image burning now works, xdnd stuff.

This commit is contained in:
Jaime Thomas 2008-12-09 01:12:16 +00:00
parent 531c69a9d3
commit 99f68b251e
19 changed files with 913 additions and 45 deletions

View File

@ -4,3 +4,5 @@
-> ffmpeg instead of gstreamer -> ffmpeg instead of gstreamer
-> finish interface -> finish interface
-> more flexible typebuf -> more flexible typebuf
-> allow user to choose which drive to use
-> remove the image creation from ecdb_burn_project

View File

@ -12,4 +12,6 @@ collections {
#include "groups/icons.edc" #include "groups/icons.edc"
#include "groups/erase_disc.edc" #include "groups/erase_disc.edc"
#include "groups/check.edc" #include "groups/check.edc"
#include "groups/burn_image.edc"
#include "groups/entry.edc"
} }

View File

@ -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";
}
}
}

View File

@ -12,16 +12,6 @@ group {
min: 0 26; min: 0 26;
color: 255 255 255 178; color: 255 255 255 178;
rel1 {
relative: 0.0 0.0;
offset: 3 4;
}
rel2 {
relative: 1.0 1.0;
offset: -4 -5;
}
image { image {
normal: "button_base.png"; normal: "button_base.png";
border: 7 7 7 7; border: 7 7 7 7;

View File

@ -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;
}
}
}
}

View File

@ -64,13 +64,13 @@ group {
rel1 { rel1 {
to: "bg"; to: "bg";
relative: 0.5 0.0; relative: 0.5 0.0;
offset: 10 10; offset: 10 5;
} }
rel2 { rel2 {
to: "bg"; to: "bg";
relative: 1.0 0.3; relative: 1.0 0.0;
offset: -11 -11; offset: -11 50;
} }
} }
} }
@ -84,15 +84,15 @@ group {
state: "default" 0.0; state: "default" 0.0;
rel1 { rel1 {
to: "bg"; to: "ecdb/erase/return";
relative: 0.5 0.3; relative: 0.0 1.0;
offset: 10 10; offset: 0 5;
} }
rel2 { rel2 {
to: "bg"; to: "ecdb/erase/return";
relative: 1.0 0.6; relative: 1.0 1.0;
offset: -11 -11; offset: 0 50;
} }
} }
} }
@ -106,15 +106,15 @@ group {
state: "default" 0.0; state: "default" 0.0;
rel1 { rel1 {
to: "bg"; to: "ecdb/erase/begin";
relative: 0.5 0.6; relative: 0.0 1.0;
offset: 10 10; offset: 0 5;
} }
rel2 { rel2 {
to: "bg"; to: "ecdb/erase/begin";
relative: 1.0 0.9; relative: 1.0 1.0;
offset: -11 -11; offset: 0 30;
} }
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 620 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 936 B

View File

@ -18,4 +18,6 @@ images {
image: "check_focus.png" COMP; image: "check_focus.png" COMP;
image: "check_shadow.png" COMP; image: "check_shadow.png" COMP;
image: "button_disabled.png" COMP; image: "button_disabled.png" COMP;
image: "entry.png" COMP;
image: "entry_focus.png" COMP;
} }

View File

@ -48,6 +48,13 @@ main(int argc, char **argv)
goto SHUTDOWN; goto SHUTDOWN;
} }
if (!efreet_init())
{
printf("Cannot initialize Efreet!\n");
ret = 1;
goto SHUTDOWN;
}
if (!ewl_init(&argc, argv)) if (!ewl_init(&argc, argv))
{ {
printf("Connot initialize Ewl!\n"); printf("Connot initialize Ewl!\n");
@ -141,6 +148,7 @@ SHUTDOWN:
ecore_evas_shutdown(); ecore_evas_shutdown();
ecore_shutdown(); ecore_shutdown();
edje_shutdown(); edje_shutdown();
efreet_shutdown();
printf("Program Done\n"); printf("Program Done\n");
return ret; return ret;
@ -152,6 +160,8 @@ ecdb_setup(void)
em = NULL; em = NULL;
em = calloc(1, sizeof(Ecdb_Main)); em = calloc(1, sizeof(Ecdb_Main));
em->drives = NULL; em->drives = NULL;
em->drop_object = NULL;
em->dnd_candidates = ecore_list_new();
if (!ecore_file_mkdir("/tmp/ecdb")) if (!ecore_file_mkdir("/tmp/ecdb"))
printf("Creation of temporary directory failed!\n"); printf("Creation of temporary directory failed!\n");
@ -162,6 +172,11 @@ ecdb_setup(void)
ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, ecdb_shutdown, ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, ecdb_shutdown,
NULL); 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()) if (!ecdb_aquire_drive_info())
{ {

View File

@ -6,10 +6,11 @@
#include <Edje.h> #include <Edje.h>
#include <Ecore.h> #include <Ecore.h>
#include <Ecore_Data.h> #include <Ecore_Data.h>
#include <Eina.h>
#include <Ecore_File.h> #include <Ecore_File.h>
#include <Ecore_Evas.h> #include <Ecore_Evas.h>
#include <Ecore_Str.h> #include <Ecore_Str.h>
#include <Ecore_X.h>
#include <Eina.h>
#include <Efreet_Mime.h> #include <Efreet_Mime.h>
#include <Efreet.h> #include <Efreet.h>
#include <Ewl.h> #include <Ewl.h>
@ -42,6 +43,8 @@ struct _Ecdb_Main
char theme_path[PATH_MAX]; char theme_path[PATH_MAX];
Ecore_Evas *main_win_ee; Ecore_Evas *main_win_ee;
Ecore_List *drives; Ecore_List *drives;
Ecore_List *dnd_candidates;
Evas_Object *drop_object;
}; };
extern Ecdb_Main *em; extern Ecdb_Main *em;

View File

@ -65,7 +65,7 @@ ecdb_burn_project_destroy(Ecdb_Burn_Project *proj)
FREE(proj->abstract_id); FREE(proj->abstract_id);
FREE(proj->biblio_id); FREE(proj->biblio_id);
ecdb_project_destroy(ECDB_PROJECT(proj)); ecdb_project_destroy(ECDB_PROJECT(proj));
free(proj); FREE(proj);
} }
int int
@ -87,6 +87,8 @@ ecdb_burn_project(Ecdb_Burn_Project *proj)
return FALSE; return FALSE;
} }
data->proj = ECDB_PROJECT(proj); data->proj = ECDB_PROJECT(proj);
data->sources = ecore_list_new();
data->tracks = ecore_list_new();
if (proj->burn_mode != BURN_AUDIO) if (proj->burn_mode != BURN_AUDIO)
padding = 300*1024; padding = 300*1024;
@ -102,14 +104,14 @@ ecdb_burn_project(Ecdb_Burn_Project *proj)
if (!source) if (!source)
{ {
printf("Failed to add any files to burn disc!\n"); 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) if (burn_track_set_source(track, source) != BURN_SOURCE_OK)
{ {
printf("Error: Cannot attach source object to track " printf("Error: Cannot attach source object to track "
"object!\n"); "object!\n");
return FALSE; return ECDB_ERROR_SOURCE_ATTACH;
} }
burn_session_add_track(data->session, track, BURN_POS_END); 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 " printf("Error: Failed to find a suitable write mode for "
"disc!\n"); "disc!\n");
return FALSE; return ECDB_ERROR_WRITE_MODE;
} }
burn_disc_write(opts, data->disc); burn_disc_write(opts, data->disc);
@ -149,7 +151,7 @@ ecdb_burn_project(Ecdb_Burn_Project *proj)
(ECDB_DRIVE_ACTION_FINISHED, ecdb_burn_finished, (ECDB_DRIVE_ACTION_FINISHED, ecdb_burn_finished,
data); data);
return TRUE; return ECDB_ERROR_NONE;
} }
/* This function is pretty naive... Should probably update it at some time */ /* This function is pretty naive... Should probably update it at some time */
@ -191,9 +193,39 @@ ecdb_drive_progress_update(void *data)
static void static void
ecdb_burn_progress_handler(void *data, void *buffer, unsigned int nbyte) 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 int
@ -227,14 +259,18 @@ ecdb_burn_finished(void *data, int type, void *event)
burn_drive_info_free(proj->proj->drive->tangible); burn_drive_info_free(proj->proj->drive->tangible);
printf("Burn Complete\n"); 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 */ /* 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; return TRUE;
} }

View File

@ -17,7 +17,17 @@ enum _Ecdb_Project_Type
ECDB_BURN_PROJECT, ECDB_BURN_PROJECT,
ECDB_AUDIO_PROJECT, ECDB_AUDIO_PROJECT,
ECDB_ERASE_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; typedef struct _Ecdb_Drive_Info Ecdb_Drive_Info;

View File

@ -40,8 +40,10 @@ void
ecdb_erase_project_destroy(Ecdb_Erase_Project *proj) ecdb_erase_project_destroy(Ecdb_Erase_Project *proj)
{ {
ecdb_project_destroy(ECDB_PROJECT(proj)); ecdb_project_destroy(ECDB_PROJECT(proj));
FREE(proj);
} }
// FIXME Make this return an error code
int int
ecdb_erase_disc(Ecdb_Erase_Project *proj) ecdb_erase_disc(Ecdb_Erase_Project *proj)
{ {

View File

@ -7,6 +7,8 @@ static void ecdb_cb_welcome_page_buttons_clicked(void *data, Evas_Object *o,
const char *emission, const char *source); const char *emission, const char *source);
static void ecdb_cb_erase_page_buttons_clicked(void *data, Evas_Object *o, static void ecdb_cb_erase_page_buttons_clicked(void *data, Evas_Object *o,
const char *emission, const char *source); 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, static void ecdb_cb_page_hide_finished(void *data, Evas_Object *o,
const char *emission, const char *source); const char *emission, const char *source);
static void ecdb_gui_controls_disable(const char **ids, int n); 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_filelist_show(void);
static void ecdb_welcome_page_show(void); static void ecdb_welcome_page_show(void);
static void ecdb_erase_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 ecdb_page_hide(const char *pname);
static void static void
@ -160,6 +163,11 @@ ecdb_create_main_gui(void)
ecore_evas_title_set(em->main_win_ee, "ECDB"); ecore_evas_title_set(em->main_win_ee, "ECDB");
ecore_evas_name_class_set(em->main_win_ee, "ECDB", "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_delete_request_set(em->main_win_ee, ecdb_shutdown);
ecore_evas_callback_destroy_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");
ecdb_erase_page_show(); 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) else if (swallow)
edje_object_signal_emit(gui, "ecdb,filelist,hide", "ecdb"); 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; return;
} }
proj->quick = speed;
if (!ecdb_erase_disc(proj)) if (!ecdb_erase_disc(proj))
{ {
Ecdb_Project *p = ECDB_PROJECT(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!"); snprintf(buf, sizeof(buf), "Disc not erasable!");
edje_object_part_text_set(swallow, "progress_text", buf); edje_object_part_text_set(swallow, "progress_text", buf);
burn_drive_release(p->drive->tangible[0].drive, 0); 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; return;
} }
proj->quick = speed; speed = 0;
edje_object_signal_emit(swallow, "ecdb,erase,start", "ecdb"); edje_object_signal_emit(swallow, "ecdb,erase,start", "ecdb");
const char *ids[] = {"ecdb/erase/return", "ecdb/erase/begin", 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 <br> 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 static void
ecdb_welcome_page_show(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"); 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 */ /* Hurrah! Fancyness */
static void static void
ecdb_cb_page_hide_finished(void *data, Evas_Object *o, const char *emission, 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"); 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");
}

View File

@ -4,5 +4,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); void ecdb_gui_erase_cleanup(void);
void ecdb_gui_burn_image_cleanup(void);
#endif #endif

View File

@ -54,7 +54,7 @@ ecdb_source_destroy(Ecdb_Source *src)
void void
ecdb_source_data_set(Ecdb_Source *src, const char *dst) ecdb_source_data_set(Ecdb_Source *src, const char *dst)
{ {
if (!src) if ((!src) || (!ecore_file_exists(dst)))
return; return;
src->dst = eina_stringshare_add(dst); 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); data_src = burn_file_source_new(c->dst, NULL);
goto FIFO_CREATE; 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(); efreet_mime_shutdown();
} }

View File

@ -26,7 +26,7 @@ ecdb_project_init(Ecdb_Project *proj)
void void
ecdb_project_destroy(Ecdb_Project *proj) ecdb_project_destroy(Ecdb_Project *proj)
{ {
free(proj); printf("Destroying base project\n");
} }
void void
@ -155,4 +155,96 @@ ecdb_button_icon_swallow(Evas *e, Evas_Object *b, const char *iname)
evas_object_show(icon); 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]);
}

View File

@ -1,6 +1,8 @@
#ifndef ECDB_MISC_H #ifndef ECDB_MISC_H
#define 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); Ecdb_Project *ecdb_project_new(void);
int ecdb_project_init(Ecdb_Project *proj); int ecdb_project_init(Ecdb_Project *proj);
void ecdb_project_destroy(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); char *ecdb_strip_string(const char *strip);
void ecdb_button_icon_swallow(Evas *e, Evas_Object *b, void ecdb_button_icon_swallow(Evas *e, Evas_Object *b,
const char *iname); 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 #endif