Formatting changes.

This commit is contained in:
Jaime Thomas 2008-12-09 05:47:59 +00:00
parent 48f67e3844
commit 7207b1b406
19 changed files with 2112 additions and 2054 deletions

View File

@ -11,179 +11,179 @@ int ecdb_setup();
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
int ret = 0; int ret = 0;
/* Do I really need all of these? */ /* Do I really need all of these? */
if (!ecore_init()) if (!ecore_init())
{ {
printf("Cannot initialize Ecore!\n"); printf("Cannot initialize Ecore!\n");
return 1; return 1;
} }
if (!ecore_string_init()) if (!ecore_string_init())
{ {
printf("Cannot initialize Ecore_String!\n"); printf("Cannot initialize Ecore_String!\n");
ret = 1; ret = 1;
goto SHUTDOWN; goto SHUTDOWN;
} }
if (!ecore_file_init()) if (!ecore_file_init())
{ {
printf("Cannot initialize Ecore_File!\n"); printf("Cannot initialize Ecore_File!\n");
ret = 1; ret = 1;
goto SHUTDOWN; goto SHUTDOWN;
} }
if (!ecore_evas_init()) if (!ecore_evas_init())
{ {
printf("Cannot initialize Ecore_Evas!\n"); printf("Cannot initialize Ecore_Evas!\n");
ret = 1; ret = 1;
goto SHUTDOWN; goto SHUTDOWN;
} }
if (!edje_init()) if (!edje_init())
{ {
printf("Cannot initialize Edje!\n"); printf("Cannot initialize Edje!\n");
ret = 1; ret = 1;
goto SHUTDOWN; goto SHUTDOWN;
} }
if (!efreet_init()) if (!efreet_init())
{ {
printf("Cannot initialize Efreet!\n"); printf("Cannot initialize Efreet!\n");
ret = 1; ret = 1;
goto SHUTDOWN; goto SHUTDOWN;
} }
if (!ewl_init(&argc, argv)) if (!ewl_init(&argc, argv))
{ {
printf("Connot initialize Ewl!\n"); printf("Connot initialize Ewl!\n");
ret = 1; ret = 1;
goto SHUTDOWN; goto SHUTDOWN;
} }
if (!ecdb_image_init()) if (!ecdb_image_init())
{ {
printf("Cannot initialize libisofs!\n"); printf("Cannot initialize libisofs!\n");
ret = 1; ret = 1;
goto SHUTDOWN; goto SHUTDOWN;
} }
if (!ecdb_burn_init()) if (!ecdb_burn_init())
{ {
printf("Cannot initialize libburn!\n"); printf("Cannot initialize libburn!\n");
ret = 1; ret = 1;
goto SHUTDOWN; goto SHUTDOWN;
} }
if (!ecdb_setup()) if (!ecdb_setup())
{ {
printf("Setup failed\n"); printf("Setup failed\n");
ret = 1; ret = 1;
goto SHUTDOWN; goto SHUTDOWN;
} }
ecdb_print_drive_info(); ecdb_print_drive_info();
if (!ecdb_create_main_gui()) if (!ecdb_create_main_gui())
{ {
printf("Cannot create main window\n"); printf("Cannot create main window\n");
ret = 1; ret = 1;
goto SHUTDOWN; goto SHUTDOWN;
} }
/* /*
Ecdb_Audio_Project *proj; Ecdb_Audio_Project *proj;
Ecdb_Source *src; Ecdb_Source *src;
proj = ecdb_audio_project_new(); proj = ecdb_audio_project_new();
i = 1; i = 1;
while ((i < argc) && (argv)) while ((i < argc) && (argv))
{ {
if (ecore_file_exists(argv[i])) if (ecore_file_exists(argv[i]))
{ {
if (!ecore_file_is_dir(argv[i])) if (!ecore_file_is_dir(argv[i]))
{ {
src = ecdb_source_new(); src = ecdb_source_new();
ecdb_source_data_set(src, argv[i], 0); ecdb_source_data_set(src, argv[i], 0);
ecdb_source_child_append(proj->tracks, src); ecdb_source_child_append(proj->tracks, src);
} }
} }
i++; i++;
} }
ecdb_audio_project_start(proj); ecdb_audio_project_start(proj);
proj->publisher_id = proj->data_preparer_id = proj->system_id = proj->publisher_id = proj->data_preparer_id = proj->system_id =
proj->application_id = proj->copywrite_id = proj->application_id = proj->copywrite_id =
proj->abstract_id = proj->biblio_id = strdup("ecdb"); proj->abstract_id = proj->biblio_id = strdup("ecdb");
if (!ecdb_aquire_drive(ECDB_PROJECT(proj), 0)) if (!ecdb_aquire_drive(ECDB_PROJECT(proj), 0))
{ {
printf("Couldn't grab drive!\n"); printf("Couldn't grab drive!\n");
ret = 1; ret = 1;
goto SHUTDOWN; goto SHUTDOWN;
} }
if (!ecdb_burn_project(proj)) if (!ecdb_burn_project(proj))
{ {
printf("Burn was unsuccessful\n"); printf("Burn was unsuccessful\n");
ret = 1; ret = 1;
goto SHUTDOWN; goto SHUTDOWN;
} }
*/ */
ewl_main(); ewl_main();
/* End testing */ /* End testing */
SHUTDOWN: SHUTDOWN:
burn_finish(); burn_finish();
iso_finish(); iso_finish();
ewl_shutdown(); ewl_shutdown();
ecore_file_shutdown(); ecore_file_shutdown();
ecore_string_shutdown(); ecore_string_shutdown();
ecore_evas_shutdown(); ecore_evas_shutdown();
ecore_shutdown(); ecore_shutdown();
edje_shutdown(); edje_shutdown();
efreet_shutdown(); efreet_shutdown();
printf("Program Done\n"); printf("Program Done\n");
return ret; return ret;
}; };
int int
ecdb_setup(void) 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->drop_object = NULL;
em->dnd_candidates = ecore_list_new(); 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");
}
ECDB_DRIVE_ACTION_FINISHED = ecore_event_type_new(); ECDB_DRIVE_ACTION_FINISHED = ecore_event_type_new();
ECDB_DRIVE_ACTION_BEGUN = ecore_event_type_new(); ECDB_DRIVE_ACTION_BEGUN = ecore_event_type_new();
ECDB_DRIVE_ACTION_UPDATE = ecore_event_type_new(); ECDB_DRIVE_ACTION_UPDATE = ecore_event_type_new();
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_POSITION, ecdb_dnd_position, ecore_event_handler_add(ECORE_X_EVENT_XDND_DROP, ecdb_dnd_drop, em);
em); ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY, ecdb_dnd_selection,
ecore_event_handler_add(ECORE_X_EVENT_XDND_DROP, ecdb_dnd_drop, em); em);
ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
ecdb_dnd_selection, em);
if (!ecdb_aquire_drive_info()) if (!ecdb_aquire_drive_info())
{ {
printf("Aquiring drives failed!\n"); printf("Aquiring drives failed!\n");
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }

View File

@ -30,7 +30,7 @@
#undef FREE #undef FREE
#define FREE(dat) \ #define FREE(dat) \
{ \ { \
if (dat) { free(dat); dat = NULL; } \ if (dat) { free(dat); dat = NULL; } \
} }
#undef __UNUSED__ #undef __UNUSED__
@ -40,11 +40,11 @@
typedef struct _Ecdb_Main Ecdb_Main; typedef struct _Ecdb_Main Ecdb_Main;
struct _Ecdb_Main 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; Ecore_List *dnd_candidates;
Evas_Object *drop_object; Evas_Object *drop_object;
}; };
extern Ecdb_Main *em; extern Ecdb_Main *em;

View File

@ -6,94 +6,98 @@ int ecdb_audio_project_init(Ecdb_Audio_Project *proj);
Ecdb_Audio_Project * Ecdb_Audio_Project *
ecdb_audio_project_new(void) ecdb_audio_project_new(void)
{ {
Ecdb_Audio_Project *proj; Ecdb_Audio_Project *proj;
proj = calloc(1, sizeof(Ecdb_Audio_Project)); proj = calloc(1, sizeof(Ecdb_Audio_Project));
if (!proj) if (!proj)
return NULL; {
if (!ecdb_audio_project_init(proj)) return NULL;
{ }
FREE(proj); if (!ecdb_audio_project_init(proj))
return NULL; {
} FREE(proj);
return NULL;
}
return proj; return proj;
} }
int int
ecdb_audio_project_init(Ecdb_Audio_Project *proj) ecdb_audio_project_init(Ecdb_Audio_Project *proj)
{ {
if (!ecdb_project_init(ECDB_PROJECT(proj))) if (!ecdb_project_init(ECDB_PROJECT(proj)))
return FALSE; {
return FALSE;
}
ecdb_project_type_set(ECDB_PROJECT(proj), ECDB_AUDIO_PROJECT); ecdb_project_type_set(ECDB_PROJECT(proj), ECDB_AUDIO_PROJECT);
proj->tracks = ecdb_source_new(); proj->tracks = ecdb_source_new();
proj->num_tracks = 0; proj->num_tracks = 0;
proj->num_transcode_complete = 0; proj->num_transcode_complete = 0;
return TRUE; return TRUE;
} }
void void
ecdb_audio_project_destroy(Ecdb_Audio_Project *proj) ecdb_audio_project_destroy(Ecdb_Audio_Project *proj)
{ {
ecdb_source_destroy(proj->tracks); ecdb_source_destroy(proj->tracks);
ecdb_project_destroy(ECDB_PROJECT(proj)); ecdb_project_destroy(ECDB_PROJECT(proj));
free(proj); free(proj);
} }
void void
ecdb_audio_project_start(Ecdb_Audio_Project *proj) ecdb_audio_project_start(Ecdb_Audio_Project *proj)
{ {
char cmd[PATH_MAX]; //<-- + 20ish? char cmd[PATH_MAX]; //<-- + 20ish?
int i; int i;
/* Fork off the gstreamer program for every file to be added /* Fork off the gstreamer program for every file to be added
* Depending on the number of files, this can be pretty system intensive, so * Depending on the number of files, this can be pretty system intensive, so
* is there a way to reduce/control this ? * is there a way to reduce/control this ?
*/ */
for (i = 0; proj->tracks->children[i]; i++) for (i = 0; proj->tracks->children[i]; i++)
{ {
snprintf(cmd, PATH_MAX, "ecdb_transcode_helper %s", snprintf(cmd, PATH_MAX, "ecdb_transcode_helper %s",
proj->tracks->children[i]->dst); proj->tracks->children[i]->dst);
ecore_exe_pipe_run(cmd, ECORE_EXE_PIPE_READ | ecore_exe_pipe_run(cmd, ECORE_EXE_PIPE_READ |
ECORE_EXE_PIPE_READ_LINE_BUFFERED, NULL); ECORE_EXE_PIPE_READ_LINE_BUFFERED, NULL);
} }
proj->num_tracks = i + 1; proj->num_tracks = i + 1;
ecore_event_handler_add(ECORE_EXE_EVENT_DATA, transcode_data_cb, proj); ecore_event_handler_add(ECORE_EXE_EVENT_DATA, transcode_data_cb, proj);
} }
int int
transcode_data_cb(void *data, int type, void *event) transcode_data_cb(void *data, int type, void *event)
{ {
const char *rec; const char *rec;
Ecore_Exe_Event_Data *ev = event; Ecore_Exe_Event_Data *ev = event;
Ecdb_Audio_Project *proj = data; Ecdb_Audio_Project *proj = data;
rec = ev->data; rec = ev->data;
proj->num_transcode_complete++; proj->num_transcode_complete++;
printf("Message: %s\n", rec); printf("Message: %s\n", rec);
if (!strcmp(rec, "EOS")) if (!strcmp(rec, "EOS"))
{ {
printf("Transcode complete\n"); printf("Transcode complete\n");
proj->num_transcode_complete++; proj->num_transcode_complete++;
} }
else
{
printf("Error!\n"); // How to handle these?
}
/* How to handle errors? */ if (proj->num_tracks == proj->num_transcode_complete)
else {
printf("Error!\n"); printf("Hurrah, transcoding is done!\n");
/* Change to another event later */
ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, NULL, NULL, NULL);
}
if (proj->num_tracks == proj->num_transcode_complete) return 1;
{
printf("Hurrah, transcoding is done!\n");
/* Change to another event later */
ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, NULL, NULL, NULL);
}
return 1;
} }

View File

@ -1,8 +1,8 @@
#ifndef ECDB_AUDIO_H #ifndef ECDB_AUDIO_H
#define ECDB_AUDIO_H #define ECDB_AUDIO_H
Ecdb_Audio_Project *ecdb_audio_project_new(void); Ecdb_Audio_Project *ecdb_audio_project_new(void);
void ecdb_audio_project_start(Ecdb_Audio_Project *proj); void ecdb_audio_project_start(Ecdb_Audio_Project *proj);
void ecdb_audio_project_destroy(Ecdb_Audio_Project *proj); void ecdb_audio_project_destroy(Ecdb_Audio_Project *proj);
#endif #endif

View File

@ -3,18 +3,18 @@
typedef struct Burn_Data Burn_Data; typedef struct Burn_Data Burn_Data;
struct Burn_Data struct Burn_Data
{ {
BurnDisc *disc; BurnDisc *disc;
BurnSession *session; BurnSession *session;
Ecore_List *sources; Ecore_List *sources;
Ecore_List *tracks; Ecore_List *tracks;
Ecdb_Project *proj; Ecdb_Project *proj;
}; };
int ecdb_burn_finished(void *data, int type, void *event); int ecdb_burn_finished(void *data, int type, void *event);
int ecdb_burn_project_init(Ecdb_Burn_Project *proj); int ecdb_burn_project_init(Ecdb_Burn_Project *proj);
int ecdb_erase_project_init(Ecdb_Erase_Project *proj); int ecdb_erase_project_init(Ecdb_Erase_Project *proj);
static void ecdb_burn_progress_handler(void *data, void *buffer, static void ecdb_burn_progress_handler(void *data, void *buffer,
unsigned int nbyte); unsigned int nbyte);
void ecdb_sources_list_free(void *data); void ecdb_sources_list_free(void *data);
void ecdb_tracks_list_free(void *data); void ecdb_tracks_list_free(void *data);
@ -22,278 +22,282 @@ void ecdb_tracks_list_free(void *data);
Ecdb_Burn_Project * Ecdb_Burn_Project *
ecdb_burn_project_new(void) ecdb_burn_project_new(void)
{ {
Ecdb_Burn_Project *proj; Ecdb_Burn_Project *proj;
proj = calloc(1, sizeof(Ecdb_Burn_Project)); proj = calloc(1, sizeof(Ecdb_Burn_Project));
if (!proj) if (!proj)
return NULL; return NULL;
if (!ecdb_burn_project_init(proj)) if (!ecdb_burn_project_init(proj))
{ {
FREE(proj); FREE(proj);
return NULL; return NULL;
} }
return proj; return proj;
} }
int int
ecdb_burn_project_init(Ecdb_Burn_Project *proj) ecdb_burn_project_init(Ecdb_Burn_Project *proj)
{ {
if (!ecdb_project_init(ECDB_PROJECT(proj))) if (!ecdb_project_init(ECDB_PROJECT(proj)))
return FALSE; return FALSE;
/* Create some sane defaults */ /* Create some sane defaults */
ecdb_project_type_set(ECDB_PROJECT(proj), ECDB_BURN_PROJECT); ecdb_project_type_set(ECDB_PROJECT(proj), ECDB_BURN_PROJECT);
proj->burn_mode = BURN_MODE1; proj->burn_mode = BURN_MODE1;
proj->fifo_chunksize = 2048; proj->fifo_chunksize = 2048;
proj->fifo_chunks = 2048; proj->fifo_chunks = 2048;
proj->underrun_proof = TRUE; proj->underrun_proof = TRUE;
proj->opc = TRUE; proj->opc = TRUE;
proj->multi = TRUE; proj->multi = TRUE;
proj->files = ecdb_source_new(); proj->files = ecdb_source_new();
return TRUE; return TRUE;
} }
void void
ecdb_burn_project_destroy(Ecdb_Burn_Project *proj) ecdb_burn_project_destroy(Ecdb_Burn_Project *proj)
{ {
ecdb_source_destroy(proj->files); ecdb_source_destroy(proj->files);
FREE(proj->volume_id); FREE(proj->volume_id);
FREE(proj->publisher_id); FREE(proj->publisher_id);
FREE(proj->data_preparer_id); FREE(proj->data_preparer_id);
FREE(proj->system_id); FREE(proj->system_id);
FREE(proj->application_id); FREE(proj->application_id);
FREE(proj->copywrite_id); FREE(proj->copywrite_id);
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
ecdb_burn_project(Ecdb_Burn_Project *proj) ecdb_burn_project(Ecdb_Burn_Project *proj)
{ {
char reasons[BURN_REASONS_LEN]; char reasons[BURN_REASONS_LEN];
int padding, i; int padding, i;
Burn_Data *data; Burn_Data *data;
BurnTrack *track; BurnTrack *track;
BurnSource *source; BurnSource *source;
BurnWriteOpts *opts; BurnWriteOpts *opts;
pthread_t progress_update; pthread_t progress_update;
i = 0; i = 0;
data = calloc(1, sizeof(Burn_Data)); data = calloc(1, sizeof(Burn_Data));
if (!data) if (!data)
{ {
printf("Error: Cannot create burn data structure!\n"); printf("Error: Cannot create burn data structure!\n");
return FALSE; return FALSE;
} }
data->proj = ECDB_PROJECT(proj); data->proj = ECDB_PROJECT(proj);
data->sources = ecore_list_new(); data->sources = ecore_list_new();
data->tracks = ecore_list_new(); data->tracks = ecore_list_new();
ecore_list_free_cb_set(data->sources, ecdb_sources_list_free); ecore_list_free_cb_set(data->sources, ecdb_sources_list_free);
ecore_list_free_cb_set(data->tracks, ecdb_tracks_list_free); ecore_list_free_cb_set(data->tracks, ecdb_tracks_list_free);
if (proj->burn_mode != BURN_AUDIO) if (proj->burn_mode != BURN_AUDIO)
padding = 300*1024; padding = 300*1024;
data->disc = burn_disc_create(); data->disc = burn_disc_create();
data->session = burn_session_create(); data->session = burn_session_create();
burn_disc_add_session(data->disc, data->session, BURN_POS_END); burn_disc_add_session(data->disc, data->session, BURN_POS_END);
track = burn_track_create(); track = burn_track_create();
burn_track_define_data(track, 0, padding, 1, proj->burn_mode); burn_track_define_data(track, 0, padding, 1, proj->burn_mode);
source = ecdb_image_project(proj); source = ecdb_image_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");
burn_session_free(data->session); burn_session_free(data->session);
burn_disc_free(data->disc); burn_disc_free(data->disc);
ecore_list_destroy(data->sources); ecore_list_destroy(data->sources);
ecore_list_destroy(data->tracks); ecore_list_destroy(data->tracks);
FREE(data); FREE(data);
return ECDB_ERROR_IMAGE_CREATE; 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"); burn_session_free(data->session);
burn_session_free(data->session); burn_disc_free(data->disc);
burn_disc_free(data->disc); ecore_list_destroy(data->sources);
ecore_list_destroy(data->sources); ecore_list_destroy(data->tracks);
ecore_list_destroy(data->tracks); FREE(data);
FREE(data); return ECDB_ERROR_SOURCE_ATTACH;
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);
ecore_list_append(data->sources, source); ecore_list_append(data->sources, source);
ecore_list_append(data->tracks, track); ecore_list_append(data->tracks, track);
opts = burn_write_opts_new(ECDB_PROJECT(proj)->drive-> opts = burn_write_opts_new(ECDB_PROJECT(proj)->drive->tangible[0].drive);
tangible[0].drive); burn_write_opts_set_perform_opc(opts, proj->opc);
burn_write_opts_set_perform_opc(opts, proj->opc); burn_write_opts_set_multi(opts, proj->multi);
burn_write_opts_set_multi(opts, proj->multi); if (proj->simulate)
if (proj->simulate) {
printf("Simulating Burn!\n"); printf("Simulating Burn!\n");
burn_write_opts_set_simulate(opts, proj->simulate); }
burn_drive_set_speed(ECDB_PROJECT(proj)->drive->tangible->drive, 0, burn_write_opts_set_simulate(opts, proj->simulate);
proj->speed); burn_drive_set_speed(ECDB_PROJECT(proj)->drive->tangible->drive, 0,
burn_write_opts_set_underrun_proof(opts, proj->underrun_proof); proj->speed);
burn_write_opts_set_underrun_proof(opts, proj->underrun_proof);
printf("Searching for burn mode\n"); printf("Searching for burn mode\n");
if (burn_write_opts_auto_write_type(opts, data->disc, reasons, 0) if (burn_write_opts_auto_write_type(opts, data->disc, reasons, 0)
== BURN_WRITE_NONE) == BURN_WRITE_NONE)
{ {
printf("Error: Failed to find a suitable write mode for " printf("Error: Failed to find a suitable write mode for disc!\n");
"disc!\n"); burn_session_free(data->session);
burn_session_free(data->session); burn_disc_free(data->disc);
burn_disc_free(data->disc); burn_write_opts_free(opts);
burn_write_opts_free(opts); ecore_list_destroy(data->sources);
ecore_list_destroy(data->sources); ecore_list_destroy(data->tracks);
ecore_list_destroy(data->tracks); FREE(proj);
FREE(proj); return ECDB_ERROR_WRITE_MODE;
return ECDB_ERROR_WRITE_MODE; }
}
burn_disc_write(opts, data->disc); burn_disc_write(opts, data->disc);
burn_write_opts_free(opts); burn_write_opts_free(opts);
printf("Disc now burning\n"); printf("Disc now burning\n");
ECDB_PROJECT(proj)->pipe = ecore_pipe_add(ecdb_burn_progress_handler, ECDB_PROJECT(proj)->pipe = ecore_pipe_add(ecdb_burn_progress_handler, NULL);
NULL); pthread_create(&progress_update, NULL, ecdb_drive_progress_update, proj);
pthread_create(&progress_update, NULL, ecdb_drive_progress_update, pthread_detach(progress_update);
proj); ECDB_PROJECT(proj)->ev_handler = ecore_event_handler_add
pthread_detach(progress_update); (ECDB_DRIVE_ACTION_FINISHED, ecdb_burn_finished, data);
ECDB_PROJECT(proj)->ev_handler = ecore_event_handler_add
(ECDB_DRIVE_ACTION_FINISHED, ecdb_burn_finished,
data);
return ECDB_ERROR_NONE; 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 */
void * void *
ecdb_drive_progress_update(void *data) ecdb_drive_progress_update(void *data)
{ {
const Ecdb_Project *proj; const Ecdb_Project *proj;
BurnProgress p; BurnProgress p;
struct burn_drive *drive; struct burn_drive *drive;
proj = data; proj = data;
if (!proj->drive->tangible) if (!proj->drive->tangible)
{ {
printf("No tangible drive!\n"); printf("No tangible drive!\n");
ecore_pipe_del(proj->pipe); ecore_pipe_del(proj->pipe);
/* Call failure here */ pthread_exit(NULL);
pthread_exit(NULL); }
} drive = proj->drive->tangible[0].drive;
drive = proj->drive->tangible[0].drive;
printf("Progress update active\n"); printf("Progress update active\n");
while (burn_drive_get_status(drive, NULL) == BURN_DRIVE_SPAWNING) while (burn_drive_get_status(drive, NULL) == BURN_DRIVE_SPAWNING)
usleep(100000); {
usleep(100000);
}
while (burn_drive_get_status(drive, &p) != BURN_DRIVE_IDLE) while (burn_drive_get_status(drive, &p) != BURN_DRIVE_IDLE)
{ {
if (p.sectors > 0) if (p.sectors > 0)
ecore_pipe_write(proj->pipe, &p, sizeof(p)); {
usleep(100000); ecore_pipe_write(proj->pipe, &p, sizeof(p));
} }
usleep(100000);
}
ecore_pipe_write(proj->pipe, "AC", sizeof("AC")); ecore_pipe_write(proj->pipe, "AC", sizeof("AC"));
ecore_pipe_del(proj->pipe); ecore_pipe_del(proj->pipe);
/* Call the finished event handler here */ /* Call the finished event handler here */
pthread_exit(NULL); pthread_exit(NULL);
} }
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; BurnProgress *p;
Evas_Object *swallow; Evas_Object *swallow;
char buf[1024]; char buf[1024];
static int last_sector = 0; static int last_sector = 0;
if ((nbyte != sizeof(BurnProgress)) || (!strcmp((char *)buffer, "AC"))) if ((nbyte != sizeof(BurnProgress)) || (!strcmp((char *)buffer, "AC")))
{ {
ecore_event_add(ECDB_DRIVE_ACTION_FINISHED, NULL, NULL, NULL); ecore_event_add(ECDB_DRIVE_ACTION_FINISHED, NULL, NULL, NULL);
last_sector = 0; last_sector = 0;
return; return;
} }
else else
{ {
p = buffer; p = buffer;
} }
/* Libburn reports p->sector as being 0 right at the end of the job, /* 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 * so store the last sector and use that to determine the proper
* percentage/sector to set * percentage/sector to set
*/ */
if (last_sector <= p->sector) if (last_sector <= p->sector)
last_sector = p->sector; {
else last_sector = p->sector;
last_sector = p->sectors; }
else
{
last_sector = p->sectors;
}
swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee), swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee),
"burn_image_page"); "burn_image_page");
snprintf(buf, sizeof(buf), "%d/%d", last_sector, p->sectors); snprintf(buf, sizeof(buf), "%d/%d", last_sector, p->sectors);
edje_object_part_text_set(swallow, "progress_text", buf); edje_object_part_text_set(swallow, "progress_text", buf);
snprintf(buf, sizeof(buf), "%d%%", (int)((double)(last_sector + 1) / snprintf(buf, sizeof(buf), "%d%%", (int)((double)(last_sector + 1) /
(double)p->sectors * 100.0)); (double)p->sectors * 100.0));
edje_object_part_text_set(swallow, "progress_percent", buf); edje_object_part_text_set(swallow, "progress_percent", buf);
} }
int int
ecdb_burn_finished(void *data, int type, void *event) ecdb_burn_finished(void *data, int type, void *event)
{ {
Burn_Data *proj; Burn_Data *proj;
proj = data; proj = data;
printf("Freeing source and tracks\n"); printf("Freeing source and tracks\n");
ecore_list_destroy(proj->sources); ecore_list_destroy(proj->sources);
ecore_list_destroy(proj->tracks); ecore_list_destroy(proj->tracks);
printf("Freeing session and disc\n"); printf("Freeing session and disc\n");
burn_session_free(proj->session); burn_session_free(proj->session);
burn_disc_free(proj->disc); burn_disc_free(proj->disc);
printf("Releasing drive\n"); printf("Releasing drive\n");
burn_drive_release(proj->proj->drive->tangible[0].drive, 1); burn_drive_release(proj->proj->drive->tangible[0].drive, 1);
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(proj->proj->ev_handler); ecore_event_handler_del(proj->proj->ev_handler);
switch (proj->proj->type) switch (proj->proj->type)
{ {
case ECDB_AUDIO_PROJECT: case ECDB_AUDIO_PROJECT:
ecdb_audio_project_destroy(ECDB_AUDIO(proj->proj)); ecdb_audio_project_destroy(ECDB_AUDIO(proj->proj));
break; break;
default:
ecdb_burn_project_destroy(ECDB_BURN(proj->proj));
}
FREE(proj);
ecdb_gui_burn_image_cleanup(); default:
ecdb_burn_project_destroy(ECDB_BURN(proj->proj));
}
FREE(proj);
return TRUE; ecdb_gui_burn_image_cleanup();
return TRUE;
} }
void void
ecdb_sources_list_free(void *data) ecdb_sources_list_free(void *data)
{ {
burn_source_free(data); burn_source_free(data);
} }
void void
ecdb_tracks_list_free(void *data) ecdb_tracks_list_free(void *data)
{ {
burn_track_free(data); burn_track_free(data);
} }

View File

@ -1,9 +1,9 @@
#ifndef ECDB_BURN_H #ifndef ECDB_BURN_H
#define ECDB_BURN_H #define ECDB_BURN_H
int ecdb_burn_project(Ecdb_Burn_Project *proj); int ecdb_burn_project(Ecdb_Burn_Project *proj);
Ecdb_Burn_Project *ecdb_burn_project_new(void); Ecdb_Burn_Project *ecdb_burn_project_new(void);
void ecdb_burn_project_destroy(Ecdb_Burn_Project *proj); void ecdb_burn_project_destroy(Ecdb_Burn_Project *proj);
void *ecdb_drive_progress_update(void *data); void *ecdb_drive_progress_update(void *data);
#endif #endif

View File

@ -14,60 +14,60 @@ typedef enum burn_drive_status BurnDriveStatus;
typedef enum _Ecdb_Project_Type Ecdb_Project_Type; typedef enum _Ecdb_Project_Type Ecdb_Project_Type;
enum _Ecdb_Project_Type 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 ECDB_IMAGE_PROJECT
}; };
typedef enum _Ecdb_Burn_Result Ecdb_Burn_Result; typedef enum _Ecdb_Burn_Result Ecdb_Burn_Result;
enum _Ecdb_Burn_Result enum _Ecdb_Burn_Result
{ {
ECDB_ERROR_IMAGE_CREATE, ECDB_ERROR_IMAGE_CREATE,
ECDB_ERROR_SOURCE_ATTACH, ECDB_ERROR_SOURCE_ATTACH,
ECDB_ERROR_WRITE_MODE, ECDB_ERROR_WRITE_MODE,
ECDB_ERROR_NONE ECDB_ERROR_NONE
}; };
typedef struct _Ecdb_Drive_Info Ecdb_Drive_Info; typedef struct _Ecdb_Drive_Info Ecdb_Drive_Info;
struct _Ecdb_Drive_Info struct _Ecdb_Drive_Info
{ {
/* Speeds */ /* Speeds */
int *read_speeds; int *read_speeds;
int *write_speeds; int *write_speeds;
/* Profiles */ /* Profiles */
char *profile_name; char *profile_name;
int profile_loaded; int profile_loaded;
/* Drive info */ /* Drive info */
char *vendor; char *vendor;
char *product; char *product;
char *revision; char *revision;
char *location; char *location;
unsigned char read_dvdram:1; unsigned char read_dvdram:1;
unsigned char read_dvdr:1; unsigned char read_dvdr:1;
unsigned char read_dvdrom:1; unsigned char read_dvdrom:1;
unsigned char read_cdr:1; unsigned char read_cdr:1;
unsigned char read_cdrw:1; unsigned char read_cdrw:1;
unsigned char write_dvdram:1; unsigned char write_dvdram:1;
unsigned char write_dvdr:1; unsigned char write_dvdr:1;
unsigned char write_cdr:1; unsigned char write_cdr:1;
unsigned char write_simulate:1; unsigned char write_simulate:1;
BurnDriveInfo *tangible; BurnDriveInfo *tangible;
}; };
typedef struct _Ecdb_Project_Info Ecdb_Project; typedef struct _Ecdb_Project_Info Ecdb_Project;
struct _Ecdb_Project_Info struct _Ecdb_Project_Info
{ {
/* The drive reference */ /* The drive reference */
Ecdb_Drive_Info *drive; Ecdb_Drive_Info *drive;
Ecore_Event_Handler *ev_handler; Ecore_Event_Handler *ev_handler;
Ecore_Pipe *pipe; Ecore_Pipe *pipe;
unsigned int type; unsigned int type;
}; };
/* Typecast a pointer to an Ecdb_Source */ /* Typecast a pointer to an Ecdb_Source */
@ -76,12 +76,12 @@ struct _Ecdb_Project_Info
typedef struct _Ecdb_Source Ecdb_Source; typedef struct _Ecdb_Source Ecdb_Source;
struct _Ecdb_Source struct _Ecdb_Source
{ {
const char *dst; const char *dst;
unsigned char dir:1; unsigned char dir:1;
unsigned int num_children; unsigned int num_children;
Ecdb_Source **children; Ecdb_Source **children;
Ecdb_Source *parent; Ecdb_Source *parent;
IsoNode *node; IsoNode *node;
}; };
/* Typecast a pointer to an Ecdb_Project */ /* Typecast a pointer to an Ecdb_Project */
@ -90,42 +90,42 @@ struct _Ecdb_Source
typedef struct _Ecdb_Burn_Project Ecdb_Burn_Project; typedef struct _Ecdb_Burn_Project Ecdb_Burn_Project;
struct _Ecdb_Burn_Project struct _Ecdb_Burn_Project
{ {
/* Inherit from normal project */ /* Inherit from normal project */
Ecdb_Project proj; Ecdb_Project proj;
/* Files are important here */ /* Files are important here */
Ecdb_Source *files; Ecdb_Source *files;
/* Ids */ /* Ids */
char *volume_id; char *volume_id;
char *publisher_id; char *publisher_id;
char *data_preparer_id; char *data_preparer_id;
char *system_id; char *system_id;
char *application_id; char *application_id;
char *copywrite_id; char *copywrite_id;
char *abstract_id; char *abstract_id;
char *biblio_id; char *biblio_id;
/* iso options */ /* iso options */
unsigned char iso_level:1; unsigned char iso_level:1;
unsigned char use_joliet:1; unsigned char use_joliet:1;
unsigned char use_rockridge:1; unsigned char use_rockridge:1;
unsigned char follow_symlinks:1; unsigned char follow_symlinks:1;
unsigned char ignore_hidden:1; unsigned char ignore_hidden:1;
unsigned char ignore_special:1; unsigned char ignore_special:1;
unsigned char iso1990:1; unsigned char iso1990:1;
/* burn options */ /* burn options */
unsigned char opc:1; unsigned char opc:1;
unsigned char multi:1; unsigned char multi:1;
unsigned char simulate:1; unsigned char simulate:1;
unsigned char underrun_proof:1; unsigned char underrun_proof:1;
int speed; int speed;
/* burn stuff */ /* burn stuff */
int fifo_chunksize; int fifo_chunksize;
int fifo_chunks; int fifo_chunks;
int burn_mode; int burn_mode;
}; };
/* Typecast a pointer to an Ecdb_Burn_Project */ /* Typecast a pointer to an Ecdb_Burn_Project */
@ -134,13 +134,13 @@ struct _Ecdb_Burn_Project
typedef struct _Ecdb_Audio_Project Ecdb_Audio_Project; typedef struct _Ecdb_Audio_Project Ecdb_Audio_Project;
struct _Ecdb_Audio_Project struct _Ecdb_Audio_Project
{ {
/* Inherit from normal project */ /* Inherit from normal project */
Ecdb_Project proj; Ecdb_Project proj;
/* Audio tracks */ /* Audio tracks */
Ecdb_Source *tracks; Ecdb_Source *tracks;
int num_tracks; int num_tracks;
int num_transcode_complete; int num_transcode_complete;
}; };
/* Typecast a pointer to an Ecdb_Audio_Project */ /* Typecast a pointer to an Ecdb_Audio_Project */
@ -149,12 +149,12 @@ struct _Ecdb_Audio_Project
typedef struct _Ecdb_Erase_Project Ecdb_Erase_Project; typedef struct _Ecdb_Erase_Project Ecdb_Erase_Project;
struct _Ecdb_Erase_Project struct _Ecdb_Erase_Project
{ {
/* Inherit from normal project */ /* Inherit from normal project */
Ecdb_Project proj; Ecdb_Project proj;
/* Speed */ /* Speed */
unsigned char quick:1; unsigned char quick:1;
unsigned char format:1; unsigned char format:1;
}; };
/* Typecast a pointer to an Ecdb_Erase_Project */ /* Typecast a pointer to an Ecdb_Erase_Project */

View File

@ -5,159 +5,169 @@ void ecdb_drive_info_free_cb(void *data);
int int
ecdb_aquire_drive_info(void) ecdb_aquire_drive_info(void)
{ {
int ret, i; int ret, i;
unsigned int drive_num; unsigned int drive_num;
struct burn_drive_info *drives_current; struct burn_drive_info *drives_current;
struct burn_speed_descriptor *speeds; struct burn_speed_descriptor *speeds;
ret = 0; ret = 0;
if (em->drives) if (em->drives)
ecore_list_destroy(em->drives); {
ecore_list_destroy(em->drives);
}
em->drives = ecore_list_new(); em->drives = ecore_list_new();
ecore_list_free_cb_set(em->drives, ecdb_drive_info_free_cb); ecore_list_free_cb_set(em->drives, ecdb_drive_info_free_cb);
while (!ret) while (!ret)
ret = burn_drive_scan(&drives_current, &drive_num); {
ret = burn_drive_scan(&drives_current, &drive_num);
}
for (i = 0; i < drive_num; i++) for (i = 0; i < drive_num; i++)
{ {
Ecdb_Drive_Info *drive; Ecdb_Drive_Info *drive;
drive = calloc(1, sizeof(Ecdb_Drive_Info)); drive = calloc(1, sizeof(Ecdb_Drive_Info));
if (!drive) if (!drive)
return FALSE; {
return FALSE;
}
/* It would be nice if there was an easier way to do this */ /* It would be nice if there was an easier way to do this */
drive->product = strdup(drives_current[i].product); drive->product = strdup(drives_current[i].product);
drive->vendor = strdup(drives_current[i].vendor); drive->vendor = strdup(drives_current[i].vendor);
drive->revision = strdup(drives_current[i].revision); drive->revision = strdup(drives_current[i].revision);
drive->location = strdup(drives_current[i].location); drive->location = strdup(drives_current[i].location);
drive->read_dvdram = drives_current[i].read_dvdram; drive->read_dvdram = drives_current[i].read_dvdram;
drive->read_dvdr = drives_current[i].read_dvdr; drive->read_dvdr = drives_current[i].read_dvdr;
drive->read_dvdrom = drives_current[i].read_dvdrom; drive->read_dvdrom = drives_current[i].read_dvdrom;
drive->read_cdr = drives_current[i].read_cdr; drive->read_cdr = drives_current[i].read_cdr;
drive->read_cdrw = drives_current[i].read_cdrw; drive->read_cdrw = drives_current[i].read_cdrw;
drive->write_dvdram = drives_current[i].write_dvdram; drive->write_dvdram = drives_current[i].write_dvdram;
drive->write_dvdr = drives_current[i].write_dvdr; drive->write_dvdr = drives_current[i].write_dvdr;
drive->write_cdr = drives_current[i].write_cdr; drive->write_cdr = drives_current[i].write_cdr;
drive->write_simulate = drives_current[i].write_simulate; drive->write_simulate = drives_current[i].write_simulate;
burn_drive_get_speedlist(drives_current[i].drive, &speeds); burn_drive_get_speedlist(drives_current[i].drive, &speeds);
drive->profile_name = strdup(speeds->profile_name); drive->profile_name = strdup(speeds->profile_name);
drive->profile_loaded = speeds->profile_loaded; drive->profile_loaded = speeds->profile_loaded;
while (speeds->next) while (speeds->next)
{ {
i++; i++;
speeds = speeds->next; speeds = speeds->next;
} }
drive->read_speeds = calloc(i + 2, sizeof(int)); drive->read_speeds = calloc(i + 2, sizeof(int));
drive->write_speeds = calloc(i + 2, sizeof(int)); drive->write_speeds = calloc(i + 2, sizeof(int));
drive->read_speeds[0] = i + 1; drive->read_speeds[0] = i + 1;
drive->write_speeds[0] = i + 1; drive->write_speeds[0] = i + 1;
for (ret = 1; ret <= i; ret++) for (ret = 1; ret <= i; ret++)
{ {
drive->write_speeds[ret] = speeds->write_speed; drive->write_speeds[ret] = speeds->write_speed;
drive->read_speeds[ret] = speeds->read_speed; drive->read_speeds[ret] = speeds->read_speed;
speeds = speeds->prev; speeds = speeds->prev;
} }
burn_drive_free_speedlist(&speeds); burn_drive_free_speedlist(&speeds);
ecore_list_append(em->drives, drive); ecore_list_append(em->drives, drive);
} }
burn_drive_info_free(drives_current); burn_drive_info_free(drives_current);
return TRUE; return TRUE;
} }
void void
ecdb_drive_info_free_cb(void *data) ecdb_drive_info_free_cb(void *data)
{ {
Ecdb_Drive_Info *info; Ecdb_Drive_Info *info;
info = data; info = data;
FREE(info->read_speeds); FREE(info->read_speeds);
FREE(info->write_speeds); FREE(info->write_speeds);
FREE(info->vendor); FREE(info->vendor);
FREE(info->product); FREE(info->product);
FREE(info->revision); FREE(info->revision);
FREE(info->location); FREE(info->location);
FREE(info->profile_name); FREE(info->profile_name);
FREE(info); FREE(info);
} }
void void
ecdb_print_drive_info(void) ecdb_print_drive_info(void)
{ {
Ecdb_Drive_Info *drive; Ecdb_Drive_Info *drive;
int j, i, h; int j, i, h;
ecore_list_first_goto(em->drives); ecore_list_first_goto(em->drives);
while ((drive = ecore_list_next(em->drives))) while ((drive = ecore_list_next(em->drives)))
{ {
printf("Vendor: %s, Product: %s, Revision: %s, " printf("Vendor: %s, Product: %s, Revision: %s, "
"Location: %s\n", "Location: %s\n",
drive->vendor, drive->product, drive->vendor, drive->product,
drive->revision, drive->location); drive->revision, drive->location);
printf("Profile name: %s, Loaded: %d\n", printf("Profile name: %s, Loaded: %d\n",
drive->profile_name, drive->profile_name,
drive->profile_loaded); drive->profile_loaded);
printf("Read DVDRAM: %d, Read DVDR: %d, Read DVDROM: %d, " printf("Read DVDRAM: %d, Read DVDR: %d, Read DVDROM: %d, "
"Read CDR: %d, Read CDRW: %d\n", "Read CDR: %d, Read CDRW: %d\n",
drive->read_dvdram, drive->read_dvdram,
drive->read_dvdr, drive->read_dvdr,
drive->read_dvdrom, drive->read_dvdrom,
drive->read_cdr, drive->read_cdr,
drive->read_cdrw); drive->read_cdrw);
printf("Write DVDRAM: %d, Write DVDR: %d, Write CDR: %d, " printf("Write DVDRAM: %d, Write DVDR: %d, Write CDR: %d, "
"Write Simulate: %d\n", "Write Simulate: %d\n",
drive->write_dvdram, drive->write_dvdram,
drive->write_dvdr, drive->write_dvdr,
drive->write_cdr, drive->write_cdr,
drive->write_simulate); drive->write_simulate);
j = drive->read_speeds[0]; j = drive->read_speeds[0];
for (i = 1; i < j; i ++) for (i = 1; i < j; i ++)
{ {
if ((h = drive->write_speeds[i])) if ((h = drive->write_speeds[i]))
printf("Write: %d\n", h); {
if ((h = drive->read_speeds[i])) printf("Write: %d\n", h);
printf("Read: %d\n", h); }
} if ((h = drive->read_speeds[i]))
} {
printf("Read: %d\n", h);
}
}
}
} }
int int
ecdb_aquire_drive(Ecdb_Project *proj, unsigned int idx) ecdb_aquire_drive(Ecdb_Project *proj, unsigned int idx)
{ {
Ecdb_Drive_Info *info; Ecdb_Drive_Info *info;
char adr[BURN_DRIVE_ADR_LEN]; char adr[BURN_DRIVE_ADR_LEN];
info = ecore_list_index_goto(em->drives, idx); info = ecore_list_index_goto(em->drives, idx);
if (burn_drive_convert_fs_adr(info->location, adr) <= 0) if (burn_drive_convert_fs_adr(info->location, adr) <= 0)
{ {
printf("Error: Address doesn't provide cd burner!\n"); printf("Error: Address doesn't provide cd burner!\n");
return FALSE; return FALSE;
} }
if (burn_drive_scan_and_grab(&info->tangible, adr, 1) > 0) if (burn_drive_scan_and_grab(&info->tangible, adr, 1) > 0)
{ {
proj->drive = info; proj->drive = info;
return TRUE; return TRUE;
} }
else else
{ {
info->tangible = NULL; info->tangible = NULL;
return FALSE; return FALSE;
} }
} }

View File

@ -1,8 +1,8 @@
#ifndef ECDB_DRIVES_H #ifndef ECDB_DRIVES_H
#define ECDB_DRIVES_H #define ECDB_DRIVES_H
int ecdb_aquire_drive_info(void); int ecdb_aquire_drive_info(void);
void ecdb_print_drive_info(void); void ecdb_print_drive_info(void);
int ecdb_aquire_drive(Ecdb_Project *proj, unsigned int idx); int ecdb_aquire_drive(Ecdb_Project *proj, unsigned int idx);
#endif #endif

View File

@ -2,146 +2,152 @@
int ecdb_erase_project_init(Ecdb_Erase_Project *proj); int ecdb_erase_project_init(Ecdb_Erase_Project *proj);
static void ecdb_erase_progress_handler(void *data, void *buffer, static void ecdb_erase_progress_handler(void *data, void *buffer,
unsigned int nbyte); unsigned int nbyte);
int ecdb_erase_finished(void *data, int type, void *event); int ecdb_erase_finished(void *data, int type, void *event);
Ecdb_Erase_Project * Ecdb_Erase_Project *
ecdb_erase_project_new(void) ecdb_erase_project_new(void)
{ {
Ecdb_Erase_Project *proj; Ecdb_Erase_Project *proj;
proj = calloc(1, sizeof(Ecdb_Erase_Project)); proj = calloc(1, sizeof(Ecdb_Erase_Project));
if (!proj) if (!proj)
return NULL; {
if (!ecdb_erase_project_init(proj)) return NULL;
{ }
FREE(proj);
return NULL; if (!ecdb_erase_project_init(proj))
} {
FREE(proj);
return NULL;
}
return proj; return proj;
} }
int int
ecdb_erase_project_init(Ecdb_Erase_Project *proj) ecdb_erase_project_init(Ecdb_Erase_Project *proj)
{ {
if (!ecdb_project_init(ECDB_PROJECT(proj))) if (!ecdb_project_init(ECDB_PROJECT(proj)))
return FALSE; {
return FALSE;
}
/* Proper defaults */ /* Proper defaults */
ecdb_project_type_set(ECDB_PROJECT(proj), ECDB_ERASE_PROJECT); ecdb_project_type_set(ECDB_PROJECT(proj), ECDB_ERASE_PROJECT);
proj->quick = TRUE; proj->quick = TRUE;
proj->format = FALSE; proj->format = FALSE;
return TRUE; return TRUE;
} }
void 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); FREE(proj);
} }
// FIXME Make this return an error code // FIXME Make this return an error code
int int
ecdb_erase_disc(Ecdb_Erase_Project *proj) ecdb_erase_disc(Ecdb_Erase_Project *proj)
{ {
BurnDriveStatus disc_state; BurnDriveStatus disc_state;
pthread_t progress_update; pthread_t progress_update;
disc_state = burn_disc_get_status(ECDB_PROJECT(proj)->drive-> disc_state = burn_disc_get_status(ECDB_PROJECT(proj)->drive->
tangible[0].drive); tangible[0].drive);
if (disc_state == BURN_DISC_BLANK) if (disc_state == BURN_DISC_BLANK)
{ {
printf("Disc is already blank!\n"); printf("Disc is already blank!\n");
return FALSE; return FALSE;
} }
else if (disc_state == BURN_DISC_EMPTY) else if (disc_state == BURN_DISC_EMPTY)
{ {
printf("No disc!\n"); printf("No disc!\n");
return FALSE; return FALSE;
} }
else if (!burn_disc_erasable(ECDB_PROJECT(proj)->drive-> else if (!burn_disc_erasable(ECDB_PROJECT(proj)->drive->
tangible[0].drive)) tangible[0].drive))
{ {
printf("Not able to erase!\n"); printf("Not able to erase!\n");
return FALSE; return FALSE;
} }
else if (disc_state == BURN_DISC_FULL || BURN_DISC_APPENDABLE) else if (disc_state == BURN_DISC_FULL || BURN_DISC_APPENDABLE)
{ {
printf("Beginning to erase disc!\n"); printf("Beginning to erase disc!\n");
ECDB_PROJECT(proj)->pipe = ecore_pipe_add ECDB_PROJECT(proj)->pipe = ecore_pipe_add(ecdb_erase_progress_handler,
(ecdb_erase_progress_handler, NULL);
NULL); burn_disc_erase(ECDB_PROJECT(proj)->drive->tangible[0].drive,
burn_disc_erase(ECDB_PROJECT(proj)->drive-> proj->quick);
tangible[0].drive, proj->quick); pthread_create(&progress_update, NULL, ecdb_drive_progress_update, proj);
pthread_create(&progress_update, NULL, pthread_detach(progress_update);
ecdb_drive_progress_update, proj); ECDB_PROJECT(proj)->ev_handler = ecore_event_handler_add
pthread_detach(progress_update); (ECDB_DRIVE_ACTION_FINISHED, ecdb_erase_finished, proj);
ECDB_PROJECT(proj)->ev_handler = ecore_event_handler_add return TRUE;
(ECDB_DRIVE_ACTION_FINISHED, }
ecdb_erase_finished, proj); else
return TRUE; {
} printf("Not of erasable type\n");
else return FALSE;
{ }
printf("Not of erasable type\n");
return FALSE;
}
} }
static void static void
ecdb_erase_progress_handler(void *data, void *buffer, unsigned int nbyte) ecdb_erase_progress_handler(void *data, void *buffer, unsigned int nbyte)
{ {
BurnProgress *p; BurnProgress *p;
Evas_Object *swallow; Evas_Object *swallow;
char buf[1024]; char buf[1024];
static int last_sector = 0; static int last_sector = 0;
if ((nbyte != sizeof(BurnProgress)) || (!strcmp((char *)buffer, "AC"))) if ((nbyte != sizeof(BurnProgress)) || (!strcmp((char *)buffer, "AC")))
{ {
ecore_event_add(ECDB_DRIVE_ACTION_FINISHED, NULL, NULL, NULL); ecore_event_add(ECDB_DRIVE_ACTION_FINISHED, NULL, NULL, NULL);
last_sector = 0; last_sector = 0;
return; return;
} }
else else
{ {
p = buffer; p = buffer;
} }
/* Libburn reports p->sector as being 0 right at the end of the job, /* 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 * so store the last sector and use that to determine the proper
* percentage/sector to set * percentage/sector to set
*/ */
if (last_sector <= p->sector) if (last_sector <= p->sector)
last_sector = p->sector; {
else last_sector = p->sector;
last_sector = p->sectors; }
else
{
last_sector = p->sectors;
}
swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee), swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee),
"erase_page"); "erase_page");
snprintf(buf, sizeof(buf), "%d/%d", last_sector, p->sectors); snprintf(buf, sizeof(buf), "%d/%d", last_sector, p->sectors);
edje_object_part_text_set(swallow, "progress_text", buf); edje_object_part_text_set(swallow, "progress_text", buf);
snprintf(buf, sizeof(buf), "%d%%", (int)((double)(last_sector + 1) / snprintf(buf, sizeof(buf), "%d%%", (int)((double)(last_sector + 1) /
(double)p->sectors * 100.0)); (double)p->sectors * 100.0));
edje_object_part_text_set(swallow, "progress_percent", buf); edje_object_part_text_set(swallow, "progress_percent", buf);
} }
int int
ecdb_erase_finished(void *data, int type, void *event) ecdb_erase_finished(void *data, int type, void *event)
{ {
Ecdb_Erase_Project *proj; Ecdb_Erase_Project *proj;
proj = data; proj = data;
burn_drive_release(ECDB_PROJECT(proj)->drive->tangible[0].drive, 0); burn_drive_release(ECDB_PROJECT(proj)->drive->tangible[0].drive, 0);
burn_drive_info_free(ECDB_PROJECT(proj)->drive->tangible); burn_drive_info_free(ECDB_PROJECT(proj)->drive->tangible);
ecore_event_handler_del(ECDB_PROJECT(proj)->ev_handler); ecore_event_handler_del(ECDB_PROJECT(proj)->ev_handler);
ecdb_erase_project_destroy(proj); ecdb_erase_project_destroy(proj);
ecdb_gui_erase_cleanup(); ecdb_gui_erase_cleanup();
return TRUE; return TRUE;
} }

View File

@ -1,9 +1,9 @@
#ifndef ECDB_ERASE_H #ifndef ECDB_ERASE_H
#define ECDB_ERASE_H #define ECDB_ERASE_H
void ecdb_erase_project_start(Ecdb_Erase_Project *proj); void ecdb_erase_project_start(Ecdb_Erase_Project *proj);
int ecdb_erase_disc(Ecdb_Erase_Project *proj); int ecdb_erase_disc(Ecdb_Erase_Project *proj);
Ecdb_Erase_Project *ecdb_erase_project_new(); Ecdb_Erase_Project *ecdb_erase_project_new();
void ecdb_erase_project_destroy(Ecdb_Erase_Project *proj); void ecdb_erase_project_destroy(Ecdb_Erase_Project *proj);
#endif #endif

View File

@ -2,168 +2,165 @@
static void free_file(Ewl_Filelist_File *file); static void free_file(Ewl_Filelist_File *file);
static void ecdb_custom_filelist_cb_clicked(Ewl_Widget *w, void *ev, static void ecdb_custom_filelist_cb_clicked(Ewl_Widget *w, void *ev,
void *data); void *data);
static Ewl_Widget *ecdb_custom_filelist_view_widget_fetch(void *data, static Ewl_Widget *ecdb_custom_filelist_view_widget_fetch(void *data,
unsigned int row, unsigned int column); unsigned int row, unsigned int column);
static void *ecdb_custom_filelist_model_data_fetch(void *data, unsigned int row, static void *ecdb_custom_filelist_model_data_fetch(void *data, unsigned int row,
unsigned int column); unsigned int column);
static void ecdb_custom_filelist_model_filter(Ewl_Filelist_Directory *dir); static void ecdb_custom_filelist_model_filter(Ewl_Filelist_Directory *dir);
static unsigned int ecdb_custom_filelist_model_data_unref(void *data); static unsigned int ecdb_custom_filelist_model_data_unref(void *data);
static Ewl_Filelist_Directory *ecdb_custom_filelist_directory_new static Ewl_Filelist_Directory *ecdb_custom_filelist_directory_new
(Ecdb_Source *src); (Ecdb_Source *src);
static void ecdb_custom_filelist_dnd_dropped_cb(Ewl_Widget *w, void *ev, static void ecdb_custom_filelist_dnd_dropped_cb(Ewl_Widget *w, void *ev,
void *data); void *data);
Ewl_Widget * Ewl_Widget *
ecdb_custom_filelist_new(void) ecdb_custom_filelist_new(void)
{ {
const char *dnd_types[] = {"text/uri-list", NULL}; const char *dnd_types[] = {"text/uri-list", NULL};
Ewl_Widget *ret; Ewl_Widget *ret;
ret = ewl_filelist_new(); ret = ewl_filelist_new();
ewl_model_data_unref_set(EWL_FILELIST(ret)->model, ewl_model_data_unref_set(EWL_FILELIST(ret)->model,
ecdb_custom_filelist_model_data_unref); ecdb_custom_filelist_model_data_unref);
ewl_model_data_fetch_set(EWL_FILELIST(ret)->model, ewl_model_data_fetch_set(EWL_FILELIST(ret)->model,
ecdb_custom_filelist_model_data_fetch); ecdb_custom_filelist_model_data_fetch);
ewl_view_widget_fetch_set(EWL_FILELIST(ret)->view, ewl_view_widget_fetch_set(EWL_FILELIST(ret)->view,
ecdb_custom_filelist_view_widget_fetch); ecdb_custom_filelist_view_widget_fetch);
ewl_callback_append(ret, EWL_CALLBACK_DND_DATA_RECEIVED, ewl_callback_append(ret, EWL_CALLBACK_DND_DATA_RECEIVED,
ecdb_custom_filelist_dnd_dropped_cb, NULL); ecdb_custom_filelist_dnd_dropped_cb, NULL);
ewl_dnd_accepted_types_set(ret, dnd_types); ewl_dnd_accepted_types_set(ret, dnd_types);
ewl_callback_del_type(EWL_FILELIST(ret)->controller, ewl_callback_del_type(EWL_FILELIST(ret)->controller, EWL_CALLBACK_CLICKED);
EWL_CALLBACK_CLICKED); ewl_callback_prepend(EWL_FILELIST(ret)->controller, EWL_CALLBACK_CLICKED,
ewl_callback_prepend(EWL_FILELIST(ret)->controller, ecdb_custom_filelist_cb_clicked, ret);
EWL_CALLBACK_CLICKED, ecdb_custom_filelist_cb_clicked, return ret;
ret);
return ret;
} }
static void static void
ecdb_custom_filelist_dnd_dropped_cb(Ewl_Widget *w, void *ev, ecdb_custom_filelist_dnd_dropped_cb(Ewl_Widget *w, void *ev,
void *data__UNUSED__) void *data__UNUSED__)
{ {
int i; int i;
Ewl_Event_Dnd_Data_Received *dnd = ev; Ewl_Event_Dnd_Data_Received *dnd = ev;
char **files = dnd->data; char **files = dnd->data;
Ecdb_Source *parent, *child; Ecdb_Source *parent, *child;
Efreet_Uri *uri; Efreet_Uri *uri;
/* Get the parent, find the path of the file(s) dropped /* Get the parent, find the path of the file(s) dropped
* and add them as children to parent */ * and add them as children to parent */
parent = ewl_widget_data_get(w, "source"); parent = ewl_widget_data_get(w, "source");
for (i = 0; i < dnd->len; i++) for (i = 0; i < dnd->len; i++)
{ {
uri = efreet_uri_decode(files[i]); uri = efreet_uri_decode(files[i]);
if (!ecore_file_exists(uri->path)) if (!ecore_file_exists(uri->path))
{ {
efreet_uri_free(uri); efreet_uri_free(uri);
continue; continue;
} }
child = ecdb_source_new(); child = ecdb_source_new();
ecdb_source_data_set(child, uri->path); ecdb_source_data_set(child, uri->path);
ecdb_source_child_append(parent, child); ecdb_source_child_append(parent, child);
efreet_uri_free(uri); efreet_uri_free(uri);
} }
ecdb_custom_filelist_directory_set(EWL_FILELIST(w), parent); ecdb_custom_filelist_directory_set(EWL_FILELIST(w), parent);
/* And filter it here -- a bit of a hack */ /* And filter it here -- a bit of a hack */
ewl_filelist_model_data_sort(ewl_mvc_data_get ewl_filelist_model_data_sort(ewl_mvc_data_get
(EWL_MVC(EWL_FILELIST(w)->controller)), (EWL_MVC(EWL_FILELIST(w)->controller)),
0, EWL_SORT_DIRECTION_ASCENDING); 0, EWL_SORT_DIRECTION_ASCENDING);
ewl_mvc_dirty_set(EWL_MVC(EWL_FILELIST(w)->controller), TRUE); ewl_mvc_dirty_set(EWL_MVC(EWL_FILELIST(w)->controller), TRUE);
} }
void void
ecdb_custom_filelist_directory_set(Ewl_Filelist *fl, Ecdb_Source *src) ecdb_custom_filelist_directory_set(Ewl_Filelist *fl, Ecdb_Source *src)
{ {
if (src) if (src)
{ {
Ewl_Filelist_Directory *data; Ewl_Filelist_Directory *data;
Ewl_Event_Action_Response ev_data; Ewl_Event_Action_Response ev_data;
data = ewl_mvc_data_get(EWL_MVC(fl->controller)); data = ewl_mvc_data_get(EWL_MVC(fl->controller));
if (data) ecdb_custom_filelist_model_data_unref(data); if (data)
{
ecdb_custom_filelist_model_data_unref(data);
}
data = ecdb_custom_filelist_directory_new(src); data = ecdb_custom_filelist_directory_new(src);
ewl_mvc_data_set(EWL_MVC(fl->controller), data); ewl_mvc_data_set(EWL_MVC(fl->controller), data);
ev_data.response = EWL_FILELIST_EVENT_DIR_CHANGE; ev_data.response = EWL_FILELIST_EVENT_DIR_CHANGE;
ewl_callback_call_with_event_data(EWL_WIDGET(fl), ewl_callback_call_with_event_data(EWL_WIDGET(fl),
EWL_CALLBACK_VALUE_CHANGED, &ev_data); EWL_CALLBACK_VALUE_CHANGED, &ev_data);
/* Set the source as needed for file operations */ /* Set the source as needed for file operations */
ewl_widget_data_set(EWL_WIDGET(fl), "source", src); ewl_widget_data_set(EWL_WIDGET(fl), "source", src);
} }
} }
static Ewl_Filelist_Directory * static Ewl_Filelist_Directory *
ecdb_custom_filelist_directory_new(Ecdb_Source *parent) ecdb_custom_filelist_directory_new(Ecdb_Source *parent)
{ {
Ecdb_Source *src; Ecdb_Source *src;
Ewl_Filelist_Directory *dir; Ewl_Filelist_Directory *dir;
Ewl_Filelist_File *file; Ewl_Filelist_File *file;
struct stat st; struct stat st;
int nf = 0, nd = 0, i = 0; int nf = 0, nd = 0, i = 0;
Ecore_List *files, *dirs; Ecore_List *files, *dirs;
files = ecore_list_new(); files = ecore_list_new();
dirs = ecore_list_new(); dirs = ecore_list_new();
ecore_list_free_cb_set(files, ECORE_FREE_CB(free_file)); ecore_list_free_cb_set(files, ECORE_FREE_CB(free_file));
ecore_list_free_cb_set(dirs, ECORE_FREE_CB(free_file)); ecore_list_free_cb_set(dirs, ECORE_FREE_CB(free_file));
if (!parent) if (!parent)
return NULL; {
return NULL;
}
/* No up for now */ while ((src = parent->children[i]))
{
file = calloc(1, sizeof(Ewl_Filelist_File));
file->name = eina_stringshare_add(src->dst);
while ((src = parent->children[i])) stat(src->dst, &st);
{ file->size = st.st_size;
file = calloc(1, sizeof(Ewl_Filelist_File)); file->modtime = st.st_mtime;
file->name = eina_stringshare_add(src->dst); file->mode = st.st_mode;
file->groupname = st.st_gid;
file->username = st.st_uid;
file->is_dir = src->dir;
file->readable = ecore_file_can_read(src->dst);
file->writeable = ecore_file_can_write(src->dst);
stat(src->dst, &st); if (src->dir)
file->size = st.st_size; {
file->modtime = st.st_mtime; ecore_list_append(dirs, file);
file->mode = st.st_mode; nd++;
file->groupname = st.st_gid; }
file->username = st.st_uid;
file->is_dir = src->dir;
file->readable = ecore_file_can_read(src->dst);
file->writeable = ecore_file_can_write(src->dst);
if (src->dir) else
{ {
ecore_list_append(dirs, file); ecore_list_append(files, file);
nd++; nf++;
} }
else i++;
{ }
ecore_list_append(files, file);
nf++;
}
/* Oops */ dir = calloc(1, sizeof(Ewl_Filelist_Directory));
i++; dir->files = ecore_list_new();
} dir->dirs = ecore_list_new();
dir->rfiles = files;
dir->rdirs = dirs;
dir->num_dirs = nd;
dir->num_files = nf;
dir = calloc(1, sizeof(Ewl_Filelist_Directory)); ecdb_custom_filelist_model_filter(dir);
dir->files = ecore_list_new(); return dir;
dir->dirs = ecore_list_new();
dir->rfiles = files;
dir->rdirs = dirs;
dir->num_dirs = nd;
dir->num_files = nf;
ecdb_custom_filelist_model_filter(dir);
return dir;
} }
static void static void
@ -176,208 +173,216 @@ free_file(Ewl_Filelist_File *file)
static void static void
ecdb_custom_filelist_model_filter(Ewl_Filelist_Directory *dir) ecdb_custom_filelist_model_filter(Ewl_Filelist_Directory *dir)
{ {
Ewl_Filelist_File *file; Ewl_Filelist_File *file;
int nd, nf; int nd, nf;
ecore_list_clear(dir->files); ecore_list_clear(dir->files);
ecore_list_clear(dir->dirs); ecore_list_clear(dir->dirs);
nd = nf = 0; nd = nf = 0;
if (!dir->show_dot) if (!dir->show_dot)
{ {
ecore_list_first_goto(dir->rfiles); ecore_list_first_goto(dir->rfiles);
while ((file = ecore_list_next(dir->rfiles))) while ((file = ecore_list_next(dir->rfiles)))
{ {
if (ecore_file_file_get(file->name)[0] != '.') if (ecore_file_file_get(file->name)[0] != '.')
{ {
ecore_list_append(dir->files, file); ecore_list_append(dir->files, file);
nf++; nf++;
} }
} }
ecore_list_first_goto(dir->rdirs); ecore_list_first_goto(dir->rdirs);
while ((file = ecore_list_next(dir->rdirs))) while ((file = ecore_list_next(dir->rdirs)))
{ {
if (ecore_file_file_get(file->name)[0] != '.') if (ecore_file_file_get(file->name)[0] != '.')
{ {
ecore_list_append(dir->dirs, file); ecore_list_append(dir->dirs, file);
nd++; nd++;
} }
} }
} }
else else
{ {
ecore_list_first_goto(dir->rfiles); ecore_list_first_goto(dir->rfiles);
while ((file = ecore_list_next(dir->rfiles))) while ((file = ecore_list_next(dir->rfiles)))
{ {
ecore_list_append(dir->files, file); ecore_list_append(dir->files, file);
nf++; nf++;
} }
ecore_list_first_goto(dir->rdirs); ecore_list_first_goto(dir->rdirs);
while ((file = ecore_list_next(dir->rdirs))) while ((file = ecore_list_next(dir->rdirs)))
{ {
ecore_list_append(dir->dirs, file); ecore_list_append(dir->dirs, file);
nd++; nd++;
} }
} }
dir->num_dirs = nd; dir->num_dirs = nd;
dir->num_files = nf; dir->num_files = nf;
} }
static unsigned int static unsigned int
ecdb_custom_filelist_model_data_unref(void *data) ecdb_custom_filelist_model_data_unref(void *data)
{ {
Ewl_Filelist_Directory *dir; Ewl_Filelist_Directory *dir;
dir = data; dir = data;
ecore_list_destroy(dir->files); ecore_list_destroy(dir->files);
ecore_list_destroy(dir->dirs); ecore_list_destroy(dir->dirs);
ecore_list_destroy(dir->rfiles); ecore_list_destroy(dir->rfiles);
ecore_list_destroy(dir->rdirs); ecore_list_destroy(dir->rdirs);
FREE(dir); FREE(dir);
return TRUE; return TRUE;
} }
static void * static void *
ecdb_custom_filelist_model_data_fetch(void *data, unsigned int row, ecdb_custom_filelist_model_data_fetch(void *data, unsigned int row,
unsigned int column) unsigned int column)
{ {
Ewl_Filelist_Directory *fld; Ewl_Filelist_Directory *fld;
Ewl_Filelist_File *file; Ewl_Filelist_File *file;
int i; int i;
void *ret; void *ret;
fld = data; fld = data;
/* Check if in dirs or files list */ /* Check if in dirs or files list */
if (row < fld->num_dirs) if (row < fld->num_dirs)
file = ecore_list_index_goto(fld->dirs, row); {
else file = ecore_list_index_goto(fld->dirs, row);
{ }
i = (row - fld->num_dirs); else
file = ecore_list_index_goto(fld->files, i); {
} i = (row - fld->num_dirs);
file = ecore_list_index_goto(fld->files, i);
}
if (column == 1) ret = ewl_filelist_size_get(file->size); if (column == 1) ret = ewl_filelist_size_get(file->size);
else if (column == 2) ret = ewl_filelist_perms_get(file->mode); else if (column == 2) ret = ewl_filelist_perms_get(file->mode);
else if (column == 3) ret = ewl_filelist_username_get else if (column == 3) ret = ewl_filelist_username_get(file->username);
(file->username); else if (column == 4) ret = ewl_filelist_groupname_get(file->groupname);
else if (column == 4) ret = ewl_filelist_groupname_get else if (column == 5) ret = ewl_filelist_modtime_get(file->modtime);
(file->groupname); else ret = strdup(file->name);
else if (column == 5) ret = ewl_filelist_modtime_get
(file->modtime);
else ret = strdup(file->name);
/* ret needs to be freed by the view or with model_data_free_set */ /* ret needs to be freed by the view or with model_data_free_set */
return ret; return ret;
} }
static void static void
ecdb_custom_filelist_cb_clicked(Ewl_Widget *w, void *ev, void *data) ecdb_custom_filelist_cb_clicked(Ewl_Widget *w, void *ev, void *data)
{ {
Ewl_Event_Mouse_Down *md; Ewl_Event_Mouse_Down *md;
char *file; char *file;
int i = 0; int i = 0;
Ewl_Widget *c; Ewl_Widget *c;
Ewl_Filelist *fl; Ewl_Filelist *fl;
Ecdb_Source *parent, *child; Ecdb_Source *parent, *child;
md = ev; md = ev;
fl = data; fl = data;
if (!ewl_mvc_selected_count_get(EWL_MVC(fl->controller))) if (!ewl_mvc_selected_count_get(EWL_MVC(fl->controller)))
return; {
return;
}
if (md->clicks != 2) if (md->clicks != 2)
{ {
ewl_filelist_selected_files_change_notify(fl); ewl_filelist_selected_files_change_notify(fl);
return; return;
} }
c = ewl_container_child_at_recursive_get(EWL_CONTAINER(fl), c = ewl_container_child_at_recursive_get(EWL_CONTAINER(fl), md->base.x,
md->base.x, md->base.y); md->base.y);
while (c && c->parent) while (c && c->parent)
{ {
if (!ewl_widget_internal_is(c)) if (!ewl_widget_internal_is(c))
{ {
i = 1; i = 1;
break; break;
} }
c = c->parent; c = c->parent;
} }
if (!i) if (!i)
return; {
return;
}
file = ecdb_custom_filelist_selected_file_get(fl); file = ecdb_custom_filelist_selected_file_get(fl);
parent = ewl_widget_data_get(EWL_WIDGET(fl), "source"); parent = ewl_widget_data_get(EWL_WIDGET(fl), "source");
i = 0; i = 0;
while ((child = parent->children[i])) while ((child = parent->children[i]))
{ {
if ((child->dir) && (!strcmp(child->dst, file))) if ((child->dir) && (!strcmp(child->dst, file)))
{ {
ecdb_custom_filelist_directory_set(fl, child); ecdb_custom_filelist_directory_set(fl, child);
FREE(file); FREE(file);
return; return;
} }
i++; i++;
} }
ewl_filelist_selected_files_change_notify(fl); ewl_filelist_selected_files_change_notify(fl);
FREE(file); FREE(file);
} }
char * char *
ecdb_custom_filelist_selected_file_get(Ewl_Filelist *fl) ecdb_custom_filelist_selected_file_get(Ewl_Filelist *fl)
{ {
Ewl_Filelist_Directory *data; Ewl_Filelist_Directory *data;
Ewl_Filelist_File *file; Ewl_Filelist_File *file;
Ewl_Selection_Idx *idx; Ewl_Selection_Idx *idx;
int i; int i;
idx = ewl_mvc_selected_get(EWL_MVC(fl->controller)); idx = ewl_mvc_selected_get(EWL_MVC(fl->controller));
data = EWL_SELECTION(idx)->data; data = EWL_SELECTION(idx)->data;
if (idx->row < data->num_dirs) if (idx->row < data->num_dirs)
file = ecore_list_index_goto(data->dirs, idx->row); {
else file = ecore_list_index_goto(data->dirs, idx->row);
{ }
i = (idx->row - data->num_dirs); else
file = ecore_list_index_goto(data->files, i); {
} i = (idx->row - data->num_dirs);
FREE(idx); file = ecore_list_index_goto(data->files, i);
return strdup(file->name); }
FREE(idx);
return strdup(file->name);
} }
static Ewl_Widget * static Ewl_Widget *
ecdb_custom_filelist_view_widget_fetch(void *data, unsigned int row __UNUSED__, ecdb_custom_filelist_view_widget_fetch(void *data, unsigned int row __UNUSED__,
unsigned int column) unsigned int column)
{ {
Ewl_Widget *ret; Ewl_Widget *ret;
const char *img = NULL, *stock, *filename; const char *img = NULL, *stock, *filename;
/* Create icon */ /* Create icon */
ret = ewl_icon_simple_new(); ret = ewl_icon_simple_new();
ewl_icon_constrain_set(EWL_ICON(ret), EWL_ICON_SIZE_MEDIUM); ewl_icon_constrain_set(EWL_ICON(ret), EWL_ICON_SIZE_MEDIUM);
ewl_box_orientation_set(EWL_BOX(ret), ewl_box_orientation_set(EWL_BOX(ret), EWL_ORIENTATION_HORIZONTAL);
EWL_ORIENTATION_HORIZONTAL); ewl_object_alignment_set(EWL_OBJECT(ret), EWL_FLAG_ALIGN_LEFT);
ewl_object_alignment_set(EWL_OBJECT(ret), EWL_FLAG_ALIGN_LEFT);
/* Get and set data into icon */ /* Get and set data into icon */
if (column == 0) if (column == 0)
{ {
stock = ewl_filelist_stock_icon_get(data); stock = ewl_filelist_stock_icon_get(data);
img = ewl_icon_theme_icon_path_get(stock, EWL_ICON_SIZE_MEDIUM); img = ewl_icon_theme_icon_path_get(stock, EWL_ICON_SIZE_MEDIUM);
if (img) ewl_icon_image_set(EWL_ICON(ret), img, NULL); if (img)
{
filename = ecore_file_file_get(data); ewl_icon_image_set(EWL_ICON(ret), img, NULL);
ewl_icon_label_set(EWL_ICON(ret), filename); }
} filename = ecore_file_file_get(data);
else ewl_icon_label_set(EWL_ICON(ret), filename);
ewl_icon_label_set(EWL_ICON(ret), data); }
else
FREE(data); {
ewl_icon_label_set(EWL_ICON(ret), data);
return ret; }
FREE(data);
return ret;
} }

View File

@ -1,9 +1,9 @@
#ifndef ECDB_FILELIST_CUSTOM_H #ifndef ECDB_FILELIST_CUSTOM_H
#define ECDB_FILELIST_CUSTOM_H #define ECDB_FILELIST_CUSTOM_H
void ecdb_custom_filelist_directory_set(Ewl_Filelist *fl, void ecdb_custom_filelist_directory_set(Ewl_Filelist *fl,
Ecdb_Source *src); Ecdb_Source *src);
Ewl_Widget *ecdb_custom_filelist_new(void); Ewl_Widget *ecdb_custom_filelist_new(void);
char * ecdb_custom_filelist_selected_file_get(Ewl_Filelist *fl); char * ecdb_custom_filelist_selected_file_get(Ewl_Filelist *fl);
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,9 @@
#ifndef ECDB_GUI_H #ifndef ECDB_GUI_H
#define ECDB_GUI_H #define ECDB_GUI_H
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); void ecdb_gui_burn_image_cleanup(void);
#endif #endif

View File

@ -6,103 +6,109 @@ void ecdb_source_add_directory_recursive(Ecdb_Source *parent);
Ecdb_Source * Ecdb_Source *
ecdb_source_new(void) ecdb_source_new(void)
{ {
Ecdb_Source *src; Ecdb_Source *src;
src = calloc(1, sizeof(Ecdb_Source)); src = calloc(1, sizeof(Ecdb_Source));
if (!src) if (!src)
return NULL; {
if (!ecdb_source_init(src)) return NULL;
{ }
FREE(src); if (!ecdb_source_init(src))
return NULL; {
} FREE(src);
return NULL;
}
return src; return src;
} }
int int
ecdb_source_init(Ecdb_Source *src) ecdb_source_init(Ecdb_Source *src)
{ {
src->dir = FALSE; src->dir = FALSE;
src->num_children = 0; src->num_children = 0;
src->children = calloc(1, sizeof(Ecdb_Source)); src->children = calloc(1, sizeof(Ecdb_Source));
if (!src->children) if (!src->children)
return FALSE; {
src->children[src->num_children] = NULL; return FALSE;
return TRUE; }
src->children[src->num_children] = NULL;
return TRUE;
} }
void void
ecdb_source_destroy(Ecdb_Source *src) ecdb_source_destroy(Ecdb_Source *src)
{ {
int i; int i;
Ecdb_Source *child; Ecdb_Source *child;
/* free the non-recursive stuff */ /* free the non-recursive stuff */
if (src->dst) eina_stringshare_del(src->dst); if (src->dst) eina_stringshare_del(src->dst);
if (src->node) iso_node_unref(src->node); if (src->node) iso_node_unref(src->node);
for (i = 0; src->children[i]; i++) for (i = 0; src->children[i]; i++)
{ {
child = src->children[i]; child = src->children[i];
ecdb_source_destroy(child); ecdb_source_destroy(child);
} }
FREE(src->children); FREE(src->children);
FREE(src); FREE(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) || (!ecore_file_exists(dst))) if ((!src) || (!ecore_file_exists(dst)))
return; {
return;
}
src->dst = eina_stringshare_add(dst); src->dst = eina_stringshare_add(dst);
/* Add the files recursively here */ /* Add the files recursively here */
if (ecore_file_is_dir(src->dst)) if (ecore_file_is_dir(src->dst))
{ {
src->dir = !!TRUE; src->dir = !!TRUE;
ecdb_source_add_directory_recursive(src); ecdb_source_add_directory_recursive(src);
} }
} }
void void
ecdb_source_add_directory_recursive(Ecdb_Source *parent) ecdb_source_add_directory_recursive(Ecdb_Source *parent)
{ {
Ecore_List *files; Ecore_List *files;
Ecdb_Source *child; Ecdb_Source *child;
char path[PATH_MAX]; char path[PATH_MAX];
char *src; char *src;
files = ecore_file_ls(parent->dst); files = ecore_file_ls(parent->dst);
while ((src = ecore_list_first_remove(files))) while ((src = ecore_list_first_remove(files)))
{ {
child = ecdb_source_new(); child = ecdb_source_new();
snprintf(path, PATH_MAX, "%s/%s", parent->dst, src); snprintf(path, PATH_MAX, "%s/%s", parent->dst, src);
ecdb_source_data_set(child, path); ecdb_source_data_set(child, path);
ecdb_source_child_append(parent, child); ecdb_source_child_append(parent, child);
free(src); FREE(src);
} }
ecore_list_destroy(files); ecore_list_destroy(files);
} }
void void
ecdb_source_child_append(Ecdb_Source *src, Ecdb_Source *child) ecdb_source_child_append(Ecdb_Source *src, Ecdb_Source *child)
{ {
if (src == child) if (src == child)
{ {
printf("Trying to make a parent of itself!\n"); printf("Trying to make a parent of itself!\n");
return; return;
} }
src->num_children++; src->num_children++;
src->children = realloc(src->children, sizeof(Ecdb_Source) * src->children = realloc(src->children, sizeof(Ecdb_Source) *
(src->num_children + 1)); (src->num_children + 1));
src->children[src->num_children - 1] = child; src->children[src->num_children - 1] = child;
src->children[src->num_children] = NULL; src->children[src->num_children] = NULL;
child->parent = src; child->parent = src;
} }
/* Basically here we can remove all occurences (who knows why we'd get /* Basically here we can remove all occurences (who knows why we'd get
@ -112,163 +118,176 @@ ecdb_source_child_append(Ecdb_Source *src, Ecdb_Source *child)
void void
ecdb_source_child_remove(Ecdb_Source *src, Ecdb_Source *child) ecdb_source_child_remove(Ecdb_Source *src, Ecdb_Source *child)
{ {
Ecdb_Source **temp; Ecdb_Source **temp;
int i, cidx, f; int i, cidx, f;
if (src == child) if (src == child)
{ {
printf("Trying to remove oneself\n"); printf("Trying to remove oneself\n");
return; return;
} }
temp = calloc(src->num_children, sizeof(Ecdb_Source)); temp = calloc(src->num_children, sizeof(Ecdb_Source));
temp[src->num_children - 1] = NULL; temp[src->num_children - 1] = NULL;
cidx = f = 0; cidx = f = 0;
for (i = 0; src->children[i]; i++) for (i = 0; src->children[i]; i++)
{ {
if ((src->children[i] == child) && (!f)) if ((src->children[i] == child) && (!f))
{ {
f++; f++;
continue; continue;
} }
temp[cidx] = src->children[i]; temp[cidx] = src->children[i];
cidx++; cidx++;
} }
FREE(src->children); FREE(src->children);
src->children = temp; src->children = temp;
src->num_children--; src->num_children--;
child->parent = NULL; child->parent = NULL;
} }
void void
ecdb_source_add_children_rec(Ecdb_Source *parent, IsoImage *image) ecdb_source_add_children_rec(Ecdb_Source *parent, IsoImage *image)
{ {
IsoDir *cd = NULL; IsoDir *cd = NULL;
Ecdb_Source *cs; Ecdb_Source *cs;
int i; int i;
if ((!parent) || (!image)) if ((!parent) || (!image))
return; return;
i = 0; i = 0;
while ((cs = parent->children[i])) while ((cs = parent->children[i]))
{ {
if (cs->dir) if (cs->dir)
{ {
iso_tree_add_new_dir(ISO_DIR(parent->node), iso_tree_add_new_dir(ISO_DIR(parent->node),
ecore_file_file_get(cs->dst), ecore_file_file_get(cs->dst), &cd);
&cd); cs->node = ISO_NODE(cd);
cs->node = ISO_NODE(cd); /* If the source has children, find the node from above
/* If the source has children, find the node from above * (if applicable), and recursively add to it */
* (if applicable), and recursively add to it */ if (cs->num_children > 0)
if (cs->num_children > 0) {
{ ecdb_source_add_children_rec(cs, image);
ecdb_source_add_children_rec(cs, image); }
}
} }
/* file */ /* file */
else else
{ {
iso_tree_add_node(image, ISO_DIR(parent->node), iso_tree_add_node(image, ISO_DIR(parent->node),
cs->dst, NULL); cs->dst, NULL);
} }
i++; i++;
} }
} }
/* proj->files should only have children */ /* proj->files should only have children */
BurnSource * BurnSource *
ecdb_image_project(Ecdb_Burn_Project *proj) ecdb_image_project(Ecdb_Burn_Project *proj)
{ {
IsoImage *image; IsoImage *image;
Ecdb_Source *c; Ecdb_Source *c;
IsoWriteOpts *opts; IsoWriteOpts *opts;
BurnSource *data_src, *fifo_src; BurnSource *data_src, *fifo_src;
if ((!proj->files) || (!proj->files->num_children)) if ((!proj->files) || (!proj->files->num_children))
return NULL; {
return NULL;
}
/* To handle already-suplied image files */ /* To handle already-suplied image files */
if (proj->files->num_children == 1) if (proj->files->num_children == 1)
{ {
efreet_mime_init(); efreet_mime_init();
c = proj->files->children[0]; c = proj->files->children[0];
if ((!ecore_file_is_dir(c->dst)) && if ((!ecore_file_is_dir(c->dst)) &&
(!strcmp(efreet_mime_type_get(c->dst), (!strcmp(efreet_mime_type_get(c->dst), "application/x-cd-image")))
"application/x-cd-image"))) {
{ 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)
else if (ECDB_PROJECT(proj)->type == ECDB_IMAGE_PROJECT) {
{ printf("Supplied file is not an image!\n");
printf("Supplied file is not an image!\n"); efreet_mime_shutdown();
efreet_mime_shutdown(); return NULL;
return NULL; }
} efreet_mime_shutdown();
efreet_mime_shutdown(); }
}
/* Otherwise we have a bunch of files */ /* Otherwise we have a bunch of files */
if (!iso_image_new(proj->volume_id, &image)) if (!iso_image_new(proj->volume_id, &image))
{ {
printf("Failed to create image!\n"); printf("Failed to create image!\n");
return NULL; return NULL;
} }
/* Set all ids */ /* Set all ids */
if (proj->publisher_id) if (proj->publisher_id)
iso_image_set_publisher_id(image, proj->publisher_id); {
if (proj->data_preparer_id) iso_image_set_publisher_id(image, proj->publisher_id);
iso_image_set_data_preparer_id(image, }
proj->data_preparer_id); if (proj->data_preparer_id)
if (proj->system_id) {
iso_image_set_system_id(image, proj->system_id); iso_image_set_data_preparer_id(image, proj->data_preparer_id);
if (proj->application_id) }
iso_image_set_application_id(image, proj->application_id); if (proj->system_id)
if (proj->copywrite_id) {
iso_image_set_copyright_file_id(image, proj->copywrite_id); iso_image_set_system_id(image, proj->system_id);
if (proj->abstract_id) }
iso_image_set_abstract_file_id(image, proj->abstract_id); if (proj->application_id)
if (proj->biblio_id) {
iso_image_set_biblio_file_id(image, proj->biblio_id); iso_image_set_application_id(image, proj->application_id);
}
if (proj->copywrite_id)
{
iso_image_set_copyright_file_id(image, proj->copywrite_id);
}
if (proj->abstract_id)
{
iso_image_set_abstract_file_id(image, proj->abstract_id);
}
if (proj->biblio_id)
{
iso_image_set_biblio_file_id(image, proj->biblio_id);
}
if (!iso_write_opts_new(&opts, 2)) if (!iso_write_opts_new(&opts, 2))
{ {
printf("Failed to create writing options!\n"); printf("Failed to create writing options!\n");
iso_image_unref(image); iso_image_unref(image);
return NULL; return NULL;
} }
/* And some write opts stuff */ /* And some write opts stuff */
iso_write_opts_set_iso_level(opts, proj->iso_level); iso_write_opts_set_iso_level(opts, proj->iso_level);
iso_write_opts_set_joliet(opts, proj->use_joliet); iso_write_opts_set_joliet(opts, proj->use_joliet);
iso_write_opts_set_rockridge(opts, proj->use_rockridge); iso_write_opts_set_rockridge(opts, proj->use_rockridge);
iso_write_opts_set_iso1999(opts, proj->iso1990); iso_write_opts_set_iso1999(opts, proj->iso1990);
iso_write_opts_set_appendable(opts, proj->multi); iso_write_opts_set_appendable(opts, proj->multi);
iso_tree_set_follow_symlinks(image, proj->follow_symlinks); iso_tree_set_follow_symlinks(image, proj->follow_symlinks);
iso_tree_set_ignore_hidden(image, proj->ignore_hidden); iso_tree_set_ignore_hidden(image, proj->ignore_hidden);
iso_tree_set_ignore_special(image, proj->ignore_special); iso_tree_set_ignore_special(image, proj->ignore_special);
/* actually fill image with some files now */ /* actually fill image with some files now */
proj->files->node = ISO_NODE(iso_image_get_root(image)); proj->files->node = ISO_NODE(iso_image_get_root(image));
ecdb_source_add_children_rec(proj->files, image); ecdb_source_add_children_rec(proj->files, image);
/* Make the burn source here */ /* Make the burn source here */
iso_image_create_burn_source(image, opts, &data_src); iso_image_create_burn_source(image, opts, &data_src);
iso_write_opts_free(opts); iso_write_opts_free(opts);
iso_image_unref(image); iso_image_unref(image);
/* And, convert to fifo */ /* And, convert to fifo */
FIFO_CREATE: FIFO_CREATE:
fifo_src = burn_fifo_source_new(data_src, fifo_src = burn_fifo_source_new(data_src, proj->fifo_chunksize,
proj->fifo_chunksize, proj->fifo_chunks, 0); proj->fifo_chunks, 0);
burn_source_free(data_src); burn_source_free(data_src);
return fifo_src; return fifo_src;
} }

View File

@ -1,11 +1,11 @@
#ifndef ECDB_IMAGE_H #ifndef ECDB_IMAGE_H
#define ECDB_IMAGE_H #define ECDB_IMAGE_H
Ecdb_Source *ecdb_source_new(void); Ecdb_Source *ecdb_source_new(void);
void ecdb_source_destroy(Ecdb_Source *src); void ecdb_source_destroy(Ecdb_Source *src);
void ecdb_source_data_set(Ecdb_Source *src, const char *dst); void ecdb_source_data_set(Ecdb_Source *src, const char *dst);
void ecdb_source_child_append(Ecdb_Source *src, Ecdb_Source *child); void ecdb_source_child_append(Ecdb_Source *src, Ecdb_Source *child);
void ecdb_source_child_remove(Ecdb_Source *src, Ecdb_Source *child); void ecdb_source_child_remove(Ecdb_Source *src, Ecdb_Source *child);
BurnSource *ecdb_image_project(Ecdb_Burn_Project *proj); BurnSource *ecdb_image_project(Ecdb_Burn_Project *proj);
#endif #endif

View File

@ -3,241 +3,264 @@
Ecdb_Project * Ecdb_Project *
ecdb_project_new(void) ecdb_project_new(void)
{ {
Ecdb_Project *proj; Ecdb_Project *proj;
proj = calloc(1, sizeof(Ecdb_Project)); proj = calloc(1, sizeof(Ecdb_Project));
if (!proj) if (!proj)
return NULL; {
if (!ecdb_project_init(proj)) return NULL;
{ }
FREE(proj); if (!ecdb_project_init(proj))
return NULL; {
} FREE(proj);
return NULL;
return proj; }
return proj;
} }
int int
ecdb_project_init(Ecdb_Project *proj) ecdb_project_init(Ecdb_Project *proj)
{ {
return TRUE; return TRUE;
} }
void void
ecdb_project_destroy(Ecdb_Project *proj) ecdb_project_destroy(Ecdb_Project *proj)
{ {
printf("Destroying base project\n"); printf("Destroying base project\n");
} }
void void
ecdb_project_type_set(Ecdb_Project *proj, unsigned int t) ecdb_project_type_set(Ecdb_Project *proj, unsigned int t)
{ {
proj->type = t; proj->type = t;
} }
int int
ecdb_shutdown(void *data, int type, void *event) ecdb_shutdown(void *data, int type, void *event)
{ {
if (em->drives) ecore_list_destroy(em->drives); if (em->drives)
if (em->dnd_candidates) ecore_list_destroy(em->dnd_candidates); {
free(em); ecore_list_destroy(em->drives);
}
if (!ecore_file_recursive_rm("/tmp/ecdb")) if (em->dnd_candidates)
printf("Removal of temporary directory failed!\n"); {
ewl_main_quit(); ecore_list_destroy(em->dnd_candidates);
return FALSE; }
FREE(em);
if (!ecore_file_recursive_rm("/tmp/ecdb"))
{
printf("Removal of temporary directory failed!\n");
}
ewl_main_quit();
return FALSE;
} }
int int
ecdb_burn_init(void) ecdb_burn_init(void)
{ {
if (!burn_initialize()) if (!burn_initialize())
return 0; {
return 0;
}
burn_msgs_set_severities("NEVER", "SORRY", "ecdb: "); burn_msgs_set_severities("NEVER", "SORRY", "ecdb: ");
burn_set_signal_handling("ecdb: ", NULL, 0); burn_set_signal_handling("ecdb: ", NULL, 0);
return 1; return 1;
} }
int int
ecdb_image_init(void) ecdb_image_init(void)
{ {
if (!iso_init()) if (!iso_init())
return 0; {
iso_set_msgs_severities("NEVER", "SORRY", "ecdb: "); return 0;
}
iso_set_msgs_severities("NEVER", "SORRY", "ecdb: ");
return 1; return 1;
} }
int int
ecdb_match_keyword(const char *chk, const char *key, int len) ecdb_match_keyword(const char *chk, const char *key, int len)
{ {
int i; int i;
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
if (chk[i] != key[i]) if (chk[i] != key[i])
return TRUE; {
} return TRUE;
}
}
return FALSE; return FALSE;
} }
char * char *
ecdb_strip_string(const char *strip) ecdb_strip_string(const char *strip)
{ {
char *t1 = (char *)strip; char *t1 = (char *)strip;
do do
{ {
if (*t1 == ' ') if (*t1 == ' ')
{ {
t1++; t1++;
return strdup(t1); return strdup(t1);
} }
} while ((t1) && (t1++)); } while ((t1) && (t1++));
return NULL; return NULL;
} }
char * char *
ecdb_strip_next_argument(const char *strip) ecdb_strip_next_argument(const char *strip)
{ {
char *t1 = (char *)strip, *t2; char *t1 = (char *)strip, *t2;
char *ret = NULL; char *ret = NULL;
int len = 0, space = FALSE; int len = 0, space = FALSE;
do do
{ {
if (*t1 == ' ') if (*t1 == ' ')
space = TRUE; {
space = TRUE;
}
if ((*t1 != ' ') && (space == TRUE)) if ((*t1 != ' ') && (space == TRUE))
{ {
t2 = t1; t2 = t1;
/* Find length of string to copy */ /* Find length of string to copy */
while ((*t2) && (*t2 != ' ')) while ((*t2) && (*t2 != ' '))
{ {
len++; len++;
t2++; t2++;
} }
/* Given no more args */ /* Given no more args */
if (!len) if (!len)
return NULL; {
else return NULL;
len++; }
else
{
len++;
}
/* Make a new string and copy everything over */ /* Make a new string and copy everything over */
ret = malloc(sizeof(char) * len); ret = malloc(sizeof(char) * len);
memcpy(ret, t1, len); memcpy(ret, t1, len);
return ret; return ret;
} }
} while (*(t1++)); } while (*(t1++));
return NULL; return NULL;
} }
void void
ecdb_button_icon_swallow(Evas *e, Evas_Object *b, const char *iname) ecdb_button_icon_swallow(Evas *e, Evas_Object *b, const char *iname)
{ {
Evas_Object *icon; Evas_Object *icon;
Evas_Coord x, y, w, h; Evas_Coord x, y, w, h;
icon = edje_object_add(e); icon = edje_object_add(e);
edje_object_file_set(icon, em->theme_path, iname); edje_object_file_set(icon, em->theme_path, iname);
edje_object_part_geometry_get(b, "icon", &x, &y, &w, &h); edje_object_part_geometry_get(b, "icon", &x, &y, &w, &h);
evas_object_move(icon, x, y); evas_object_move(icon, x, y);
evas_object_resize(icon, w, h); evas_object_resize(icon, w, h);
edje_object_part_swallow(b, "icon", icon); edje_object_part_swallow(b, "icon", icon);
evas_object_show(icon); evas_object_show(icon);
} }
int int
ecdb_dnd_position(void *data, int type, void *event) ecdb_dnd_position(void *data, int type, void *event)
{ {
Ecore_X_Event_Xdnd_Position *ev; Ecore_X_Event_Xdnd_Position *ev;
Evas_Object *o; Evas_Object *o;
Ecore_X_Rectangle rect; Ecore_X_Rectangle rect;
Evas_Coord window_x, window_y, window_w, window_h, x, y, w, h; Evas_Coord window_x, window_y, window_w, window_h, x, y, w, h;
ev = event; ev = event;
if (ev->win != ecore_evas_software_x11_window_get(em->main_win_ee)) if (ev->win != ecore_evas_software_x11_window_get(em->main_win_ee))
return 1; {
return 1;
}
ecore_evas_geometry_get(em->main_win_ee, &window_x, ecore_evas_geometry_get(em->main_win_ee, &window_x, &window_y, &window_w,
&window_y, &window_w, &window_h); &window_h);
ecore_list_first_goto(em->dnd_candidates); ecore_list_first_goto(em->dnd_candidates);
while ((o = ecore_list_next(em->dnd_candidates))) while ((o = ecore_list_next(em->dnd_candidates)))
{ {
if (evas_object_visible_get(o)) if (evas_object_visible_get(o))
{ {
evas_object_geometry_get(o, &x, &y, &w, &h); evas_object_geometry_get(o, &x, &y, &w, &h);
x += window_x; x += window_x;
y += window_y; y += window_y;
if ((ev->position.x >= x) && (ev->position.x <= (x+w)) if ((ev->position.x >= x) && (ev->position.x <= (x+w))
&& (ev->position.y >= y) && (ev->position.y >= y) && (ev->position.y <= (y + h)))
&& (ev->position.y <= (y + h))) {
{ rect.x = x;
rect.x = x; rect.y = y;
rect.y = y; rect.width = w;
rect.width = w; rect.height = h;
rect.height = h; em->drop_object = o;
em->drop_object = o; ecore_x_dnd_send_status(1, 1, rect, ECORE_X_DND_ACTION_PRIVATE);
ecore_x_dnd_send_status(1, 1, rect, return 1;
ECORE_X_DND_ACTION_PRIVATE); }
return 1; }
} }
}
}
rect.x = window_x; rect.x = window_x;
rect.y = window_y; rect.y = window_y;
rect.width = window_w; rect.width = window_w;
rect.height = window_h; rect.height = window_h;
ecore_x_dnd_send_status(0, 1, rect, ECORE_X_DND_ACTION_PRIVATE); ecore_x_dnd_send_status(0, 1, rect, ECORE_X_DND_ACTION_PRIVATE);
return 1; return 1;
} }
int int
ecdb_dnd_drop(void *data, int type, void *event) ecdb_dnd_drop(void *data, int type, void *event)
{ {
if (em->drop_object) if (em->drop_object)
{ {
ecore_x_selection_xdnd_request ecore_x_selection_xdnd_request
(ecore_evas_software_x11_window_get(em->main_win_ee), (ecore_evas_software_x11_window_get(em->main_win_ee),
"text/uri-list"); "text/uri-list");
} }
return 1; return 1;
} }
int int
ecdb_dnd_selection(void *data, int type, void *event) ecdb_dnd_selection(void *data, int type, void *event)
{ {
Ecore_X_Event_Selection_Notify *ev; Ecore_X_Event_Selection_Notify *ev;
Ecore_X_Selection_Data_Files *files; Ecore_X_Selection_Data_Files *files;
void (*call_func)(Evas_Object *, Ecore_X_Selection_Data_Files *) = void (*call_func)(Evas_Object *, Ecore_X_Selection_Data_Files *) = NULL;
NULL;
ev = event; ev = event;
if ((!em->drop_object) || (ev->selection != ECORE_X_SELECTION_XDND) if ((!em->drop_object) || (ev->selection != ECORE_X_SELECTION_XDND)
|| (!(files = ev->data)) || (files->num_files <= 0)) || (!(files = ev->data)) || (files->num_files <= 0))
{ {
ecore_x_dnd_send_finished(); ecore_x_dnd_send_finished();
return 1; return 1;
} }
call_func = evas_object_data_get(em->drop_object, "dnd_call_func"); call_func = evas_object_data_get(em->drop_object, "dnd_call_func");
if (call_func != NULL) if (call_func != NULL)
call_func(em->drop_object, files); {
call_func(em->drop_object, files);
}
em->drop_object = NULL; em->drop_object = NULL;
ecore_x_dnd_send_finished(); ecore_x_dnd_send_finished();
return 1; return 1;
} }
@ -246,5 +269,9 @@ ecdb_dnd_selection(void *data, int type, void *event)
void void
ecdb_dnd_entry_dnd_set(Evas_Object *o, Ecore_X_Selection_Data_Files *files) ecdb_dnd_entry_dnd_set(Evas_Object *o, Ecore_X_Selection_Data_Files *files)
{ {
edje_object_part_text_set(o, "label", files->files[0]); Efreet_Uri *uri;
uri = efreet_uri_decode(files->files[0]);
edje_object_part_text_set(o, "label", uri->path);
efreet_uri_free(uri);
} }

View File

@ -3,27 +3,27 @@
// At some point I should move the ecdb_project_* stuff into its own file, // At some point I should move the ecdb_project_* stuff into its own file,
// and the init and shutdown stuff into ecdb.c // 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);
void ecdb_project_type_set(Ecdb_Project *proj, unsigned int t); void ecdb_project_type_set(Ecdb_Project *proj, unsigned int t);
void ecdb_projects_free(void *data); void ecdb_projects_free(void *data);
int ecdb_shutdown(void *data, int type, void *event); int ecdb_shutdown(void *data, int type, void *event);
int ecdb_burn_init(void); int ecdb_burn_init(void);
int ecdb_image_init(void); int ecdb_image_init(void);
/* This is misc after all */ /* This is misc after all */
int ecdb_match_keyword(const char *chk, const char *key, int len); int ecdb_match_keyword(const char *chk, const char *key, int len);
char *ecdb_strip_next_argument(const char *strip); 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 // Also consider moving dnd stuff into its own file
int ecdb_dnd_position(void *data, int type, void *event); int ecdb_dnd_position(void *data, int type, void *event);
int ecdb_dnd_drop(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); int ecdb_dnd_selection(void *data, int type, void *event);
void ecdb_dnd_entry_dnd_set(Evas_Object *o, void ecdb_dnd_entry_dnd_set(Evas_Object *o,
Ecore_X_Selection_Data_Files *files); Ecore_X_Selection_Data_Files *files);
#endif #endif