Clean ups, abstract the widgets a bit, and don't segfault when not finding an unsuitable write mode.

This commit is contained in:
Jaime Thomas
2008-12-18 22:16:55 +00:00
parent 6a512c1163
commit 8815f3c6f6
11 changed files with 358 additions and 112 deletions

View File

@@ -506,41 +506,29 @@ ecdb_cb_burn_image_page_buttons_clicked(void *data, Evas_Object *o,
Ecdb_Burn_Project *proj;
Evas_Object *entry;
Ecdb_Source *iso_file;
const char *file;
char *sanitized_file;
char *file;
char buf[1024];
Ecdb_Burn_Result burn_result;
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
if (!strcmp(&file[strlen(file) - 4], "<br>"))
{
sanitized_file = alloca(sizeof(char) * (strlen(file) - 3));
sanitized_file[0] = '\0';
ecore_strlcpy(sanitized_file, file, strlen(file) - 3);
printf("Sanitized_file: %s\n", sanitized_file);
}
else
{
// We aren't altering sanitized_file after this
sanitized_file = (char *)file;
}
file = ecdb_entry_text_get(entry);
printf("file: '%s'\n", file);
// Make sure that file actually exists
if (!ecore_file_exists(sanitized_file))
if (!ecore_file_exists(file))
{
edje_object_part_text_set(swallow, "progress_text", "File doesn't "
"exists!");
FREE(file);
return;
}
proj = ecdb_burn_project_new();
ecdb_project_type_set(ECDB_PROJECT(proj), ECDB_IMAGE_PROJECT);
iso_file = ecdb_source_new();
ecdb_source_data_set(iso_file, sanitized_file);
ecdb_source_data_set(iso_file, file);
FREE(file);
ecdb_source_child_append(proj->files, iso_file);
snprintf(buf, sizeof(buf), "Commencing...");
@@ -610,6 +598,8 @@ ecdb_welcome_page_show(void)
if (!swallow)
{
Evas_Object *b;
Evas_Coord x, y, w, h;
swallow = edje_object_add(ecore_evas_get(em->main_win_ee));
@@ -627,7 +617,6 @@ ecdb_welcome_page_show(void)
ecdb_cb_page_hide_finished, NULL);
evas_object_show(swallow);
Evas_Object *b;
int i;
char *labels[] = {"Burn Data CD", "Burn Audio CD", "Burn Image",
"Erase Re-writable Disc"};
@@ -635,18 +624,10 @@ ecdb_welcome_page_show(void)
"ecdb/erase"};
for (i = 0; i < 4; i++)
{
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, "ecdb/button");
edje_object_part_geometry_get(swallow, ids[i], &x, &y, &w, &h);
edje_object_part_text_set(b, "label", labels[i]);
evas_object_move(b, x, y);
evas_object_resize(b, w, h);
edje_object_part_swallow(swallow, ids[i], b);
b = ecdb_button_add(swallow, ids[i]);
ecdb_button_label_set(b, labels[i]);
evas_object_show(b);
/* Place this after */
ecdb_button_icon_swallow(ecore_evas_get(em->main_win_ee), b, ids[i]);
ecdb_button_icon_set(b, ids[i]);
}
}
@@ -752,6 +733,7 @@ ecdb_erase_page_show(void)
if (!swallow)
{
Evas_Object *b;
Evas_Coord x, y, w, h;
swallow = edje_object_add(ecore_evas_get(em->main_win_ee));
@@ -772,32 +754,19 @@ ecdb_erase_page_show(void)
ecdb_cb_page_hide_finished, NULL);
evas_object_show(swallow);
int i;
char *labels[] = {"Return to Main Page", "Start Erase",
"Quick Erase"};
char *ids[] = {"ecdb/erase/return", "ecdb/erase/begin",
"ecdb/erase/speed"};
char *wtype[] = {"ecdb/button", "ecdb/button", "ecdb/check"};
b = ecdb_button_add(swallow, "ecdb/erase/return");
ecdb_button_label_set(b, "Return to Main Page");
evas_object_show(b);
ecdb_button_icon_set(b, "ecdb/erase/return");
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);
b = ecdb_button_add(swallow, "ecdb/erase/begin");
ecdb_button_label_set(b, "Start Erase");
evas_object_show(b);
ecdb_button_icon_set(b, "ecdb/erase/begin");
if (!strcmp("ecdb/button", wtype[i]))
{
ecdb_button_icon_swallow(ecore_evas_get(em->main_win_ee), b,
ids[i]);
}
}
b = ecdb_check_add(swallow, "ecdb/erase/speed");
ecdb_check_label_set(b, "Quick Erase");
evas_object_show(b);
}
else if (edje_object_part_swallow_get(gui, "action_area") != swallow)
@@ -821,6 +790,7 @@ ecdb_burn_image_page_show(void)
if (!swallow)
{
Evas_Object *b;
Evas_Coord x, y, w, h;
swallow = edje_object_add(ecore_evas_get(em->main_win_ee));
@@ -843,36 +813,19 @@ ecdb_burn_image_page_show(void)
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"};
b = ecdb_button_add(swallow, "ecdb/burn_image/return");
ecdb_button_label_set(b, "Return to Main Page");
evas_object_show(b);
ecdb_button_icon_set(b, "ecdb/burn_image/return");
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);
b = ecdb_button_add(swallow, "ecdb/burn_image/begin");
ecdb_button_label_set(b, "Start Burn");
evas_object_show(b);
ecdb_button_icon_set(b, "ecdb/burn_image/begin");
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]))
{
em->dnd_candidates = eina_list_append(em->dnd_candidates, b);
evas_object_data_set(b, "dnd_call_func", ecdb_dnd_entry_dnd_set);
}
}
b = ecdb_entry_add(swallow, "ecdb/burn_image/file");
ecdb_entry_text_set(b, "Burn File");
evas_object_show(b);
}
else if (edje_object_part_swallow_get(gui, "action_area") != swallow)