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 cefb0a7a76
commit 32640312d9
19 changed files with 913 additions and 45 deletions

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);
static void ecdb_cb_erase_page_buttons_clicked(void *data, Evas_Object *o,
const char *emission, const char *source);
static void ecdb_cb_burn_image_page_buttons_clicked(void *data, Evas_Object *o,
const char *emission, const char *source);
static void ecdb_cb_page_hide_finished(void *data, Evas_Object *o,
const char *emission, const char *source);
static void ecdb_gui_controls_disable(const char **ids, int n);
@@ -14,6 +16,7 @@ static void ecdb_gui_controls_enable(const char **ids, int n);
static void ecdb_filelist_show(void);
static void ecdb_welcome_page_show(void);
static void ecdb_erase_page_show(void);
static void ecdb_burn_image_page_show(void);
static void ecdb_page_hide(const char *pname);
static void
@@ -160,6 +163,11 @@ ecdb_create_main_gui(void)
ecore_evas_title_set(em->main_win_ee, "ECDB");
ecore_evas_name_class_set(em->main_win_ee, "ECDB", "ECDB");
ecore_evas_avoid_damage_set(em->main_win_ee, 1);
ecore_x_dnd_aware_set(ecore_evas_software_x11_window_get
(em->main_win_ee), 1);
ecore_x_dnd_type_set(ecore_evas_software_x11_window_get
(em->main_win_ee), "*", 1);
ecore_evas_callback_delete_request_set(em->main_win_ee, ecdb_shutdown);
ecore_evas_callback_destroy_set(em->main_win_ee, ecdb_shutdown);
@@ -336,6 +344,15 @@ ecdb_cb_welcome_page_buttons_clicked(void *data, Evas_Object *o,
"ecdb");
ecdb_erase_page_show();
}
else if (!strcmp(source, "ecdb/burn_image"))
{
ecdb_filelist_show();
swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee),
"welcome_page");
edje_object_signal_emit(swallow, "ecdb,welcome_page,hide",
"ecdb");
ecdb_burn_image_page_show();
}
else if (swallow)
edje_object_signal_emit(gui, "ecdb,filelist,hide", "ecdb");
@@ -380,11 +397,12 @@ ecdb_cb_erase_page_buttons_clicked(void *data, Evas_Object *o,
return;
}
proj->quick = speed;
if (!ecdb_erase_disc(proj))
{
Ecdb_Project *p = ECDB_PROJECT(proj);
printf("Couldn't begin burn!\n");
printf("Disc not erasable!\n");
snprintf(buf, sizeof(buf), "Disc not erasable!");
edje_object_part_text_set(swallow, "progress_text", buf);
burn_drive_release(p->drive->tangible[0].drive, 0);
@@ -393,7 +411,7 @@ ecdb_cb_erase_page_buttons_clicked(void *data, Evas_Object *o,
return;
}
proj->quick = speed;
speed = 0;
edje_object_signal_emit(swallow, "ecdb,erase,start", "ecdb");
const char *ids[] = {"ecdb/erase/return", "ecdb/erase/begin",
@@ -407,6 +425,115 @@ ecdb_cb_erase_page_buttons_clicked(void *data, Evas_Object *o,
}
}
static void
ecdb_cb_burn_image_page_buttons_clicked(void *data, Evas_Object *o,
const char *emission, const char *source)
{
Evas_Object *swallow, *gui;
gui = evas_object_name_find(ecore_evas_get(em->main_win_ee), "gui");
swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee),
"burn_image_page");
if (!strcmp(source, "ecdb/burn_image/return"))
{
char *signal;
edje_object_part_text_set(swallow, "progress_text",
"Begin Burn");
edje_object_part_text_set(swallow, "progress_percent", "0%");
signal = evas_object_data_get(swallow, "hide_signal");
edje_object_signal_emit(swallow, signal, "ecdb");
ecdb_welcome_page_show();
/* Hide the filelist to be nice */
edje_object_signal_emit(gui, "ecdb,filelist,hide", "ecdb");
}
else if (!strcmp(source, "ecdb/burn_image/begin"))
{
Ecdb_Burn_Project *proj;
Evas_Object *entry;
Ecdb_Source *iso_file;
Efreet_Uri *uri;
const char *file;
char *sanitized_file;
char buf[1024];
Ecdb_Burn_Result burn_result;
proj = ecdb_burn_project_new();
ecdb_project_type_set(ECDB_PROJECT(proj), ECDB_IMAGE_PROJECT);
entry = evas_object_name_find(ecore_evas_get(em->main_win_ee),
"ecdb/burn_image/file");
file = edje_object_part_text_get(entry, "label");
//Textblock returns a <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
ecdb_welcome_page_show(void)
{
@@ -629,6 +756,87 @@ ecdb_erase_page_show(void)
edje_object_signal_emit(swallow, "ecdb,erase_page,visible", "ecdb");
}
static void
ecdb_burn_image_page_show(void)
{
Evas_Object *swallow, *gui;
gui = evas_object_name_find(ecore_evas_get(em->main_win_ee), "gui");
swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee),
"burn_image_page");
if (!swallow)
{
Evas_Coord x, y, w, h;
swallow = edje_object_add(ecore_evas_get(em->main_win_ee));
edje_object_file_set(swallow, em->theme_path,
"ecdb/burn_image_page");
evas_object_name_set(swallow, "burn_image_page");
evas_object_data_set(swallow, "hide_signal",
"ecdb,burn_image_page,hide");
edje_object_part_geometry_get(gui, "active_area",
&x, &y, &w, &h);
evas_object_move(swallow, x, y);
evas_object_resize(swallow, w, h);
edje_object_part_swallow(gui, "action_area", swallow);
evas_object_show(swallow);
edje_object_signal_callback_add(swallow, "mouse,down,1",
"ecdb/*", ecdb_cb_controls_focused,
NULL);
edje_object_signal_callback_add(swallow, "mouse,clicked,1",
"ecdb/burn_image/*",
ecdb_cb_burn_image_page_buttons_clicked, NULL);
edje_object_signal_callback_add(swallow, "hide,finished",
"burn_image_page", ecdb_cb_page_hide_finished,
NULL);
evas_object_show(swallow);
int i;
char *labels[] = {"Return to Main Page", "Start Burn",
"Burn File"};
char *ids[] = {"ecdb/burn_image/return",
"ecdb/burn_image/begin",
"ecdb/burn_image/file"};
char *wtype[] = {"ecdb/button", "ecdb/button", "ecdb/entry"};
for (i = 0; i < 3; i++)
{
Evas_Object *b;
b = edje_object_add(ecore_evas_get(em->main_win_ee));
evas_object_name_set(b, ids[i]);
edje_object_file_set(b, em->theme_path, wtype[i]);
edje_object_part_geometry_get(swallow, ids[i], &x,
&y, &w, &h);
evas_object_move(b, x, y);
evas_object_resize(b, w, h);
edje_object_part_text_set(b, "label", labels[i]);
edje_object_part_swallow(swallow, ids[i], b);
evas_object_show(b);
if (!strcmp("ecdb/button", wtype[i]))
ecdb_button_icon_swallow(ecore_evas_get(
em->main_win_ee), b, ids[i]);
else if (!strcmp("ecdb/entry", wtype[i]))
{
ecore_list_append(em->dnd_candidates, b);
evas_object_data_set(b, "dnd_call_func",
ecdb_dnd_entry_dnd_set);
}
}
}
else if (edje_object_part_swallow_get(gui, "action_area") != swallow)
{
edje_object_part_swallow(gui, "action_area", swallow);
evas_object_show(swallow);
}
edje_object_signal_emit(gui, "ecdb,burn_image_page,visible", "ecdb");
edje_object_signal_emit(swallow, "ecdb,burn_image_page,visible",
"ecdb");
}
/* Hurrah! Fancyness */
static void
ecdb_cb_page_hide_finished(void *data, Evas_Object *o, const char *emission,
@@ -679,3 +887,16 @@ ecdb_gui_erase_cleanup(void)
edje_object_signal_emit(swallow, "ecdb,erase,done", "ecdb");
}
void
ecdb_gui_burn_image_cleanup(void)
{
Evas_Object *swallow;
const char *ids[] = {"ecdb/burn_image/return", "ecdb/burn_image/begin",
"ecdb/burn_image/file"};
swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee),
"burn_image_page");
edje_object_part_text_set(swallow, "progress_text", "Burn Complete!");
ecdb_gui_controls_enable(ids, 3);
edje_object_signal_emit(swallow, "ecdb,burn_image,done", "ecdb");
}