Combos work now, fix popup placement, move burn image gui stuff into its own file.

This commit is contained in:
Jaime Thomas
2008-12-21 03:52:57 +00:00
parent 9db32952a6
commit 6101e38169
11 changed files with 138 additions and 277 deletions

View File

@@ -2,14 +2,9 @@
#include "ecdb.h"
static void ecdb_handle_typebuf(Evas_Object *gui);
static void ecdb_cb_controls_focused(void *data, Evas_Object *o,
const char *emission, const char *source);
static void ecdb_cb_welcome_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_filelist_show(void);
static void ecdb_burn_image_page_show(void);
static void ecdb_page_hide(const char *pname);
static void ecdb_filelist_focus_handle(int action, Evas_Object *fl);
@@ -342,30 +337,6 @@ ecdb_handle_typebuf(Evas_Object *gui)
}
static void
ecdb_cb_controls_focused(void *data, Evas_Object *o, const char *emission,
const char *source)
{
static char *old_source;
Evas_Object *eo;
if ((old_source) && (strcmp(old_source, source)))
{
eo = evas_object_name_find(ecore_evas_get(em->main_win_ee), old_source);
edje_object_signal_emit(eo, "ecdb,focus,out", "ecdb");
FREE(old_source);
old_source = strdup(source);
}
else if (!old_source)
{
old_source = strdup(source);
}
// Send focus to the freshly clicked widget
eo = evas_object_name_find(ecore_evas_get(em->main_win_ee), source);
evas_object_focus_set(eo, 1);
}
static void
ecdb_cb_welcome_page_buttons_clicked(void *data, Evas_Object *o,
const char *emission, const char *source)
@@ -406,113 +377,6 @@ ecdb_cb_welcome_page_buttons_clicked(void *data, Evas_Object *o,
printf("Action: %s\n", source);
}
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;
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 = ecdb_entry_text_get(entry);
printf("file: '%s'\n", file);
// Make sure that file actually exists
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, file);
FREE(file);
ecdb_source_child_append(proj->files, iso_file);
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"))
{
// o is not the entry, it is the burn_image_page!
swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee),
"ecdb/burn_image/file");
evas_object_focus_set(swallow, 1);
}
}
void
ecdb_welcome_page_show(void)
{
@@ -535,8 +399,6 @@ ecdb_welcome_page_show(void)
evas_object_move(swallow, x, y);
evas_object_resize(swallow, w, h);
edje_object_part_swallow(gui, "action_area", 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/*",
ecdb_cb_welcome_page_buttons_clicked, NULL);
edje_object_signal_callback_add(swallow, "hide,finished", "welcome_page",
@@ -645,100 +507,6 @@ ecdb_page_hide(const char *pname)
}
}
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_Object *b, *c1, *c2;
Eina_List *l;
Ecdb_Drive_Info *drive;
Evas_Coord x, y, w, h;
char buf[1024];
int i, write_speed_count;
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_page_hide_finished, NULL);
evas_object_show(swallow);
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");
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");
b = ecdb_entry_add(swallow, "ecdb/burn_image/file");
ecdb_entry_text_set(b, "Burn File");
evas_object_show(b);
c1 = ecdb_combo_add(swallow, "ecdb/burn_image/drive");
ecdb_combo_header_set(c1, "Drive");
evas_object_show(c1);
c2 = ecdb_combo_add(swallow, "ecdb/burn_image/speed");
ecdb_combo_header_set(c2, "Speed");
evas_object_show(c2);
EINA_LIST_FOREACH(em->drives, l, drive)
{
b = ecdb_button_add(c1, NULL);
ecdb_button_label_set(b, drive->product);
ecdb_combo_append(c1, b);
evas_object_show(b);
// Need to set this
write_speed_count = drive->write_speeds[0];
for (i = 1; i < write_speed_count; i++)
{
if (drive->write_speeds[i] <= 0)
break;
b = ecdb_button_add(c2, NULL);
snprintf(buf, sizeof(buf), "%d", drive->write_speeds[i]);
printf("speed: %d\n", drive->write_speeds[i]);
ecdb_button_label_set(b, buf);
ecdb_combo_append(c2, b);
evas_object_show(b);
}
}
}
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 */
void
ecdb_page_hide_finished(void *data, Evas_Object *o, const char *emission,
@@ -773,16 +541,52 @@ ecdb_gui_controls_enable(const char **ids, int n)
}
}
void
ecdb_gui_burn_image_cleanup(void)
Evas_Object *
ecdb_gui_combo_header_from_drive(Evas_Object *c, const char *name, void *data,
Evas_Object *obj, int sel)
{
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");
Evas_Object *ret;
Ecdb_Drive_Info *drive;
ret = ecdb_label_add(c, name);
drive = eina_list_nth(em->drives, sel);
ecdb_label_text_set(ret, drive->product);
evas_object_show(ret);
return ret;
}
Evas_Object *
ecdb_gui_combo_header_from_speeds(Evas_Object *c, const char *name, void *data,
Evas_Object *obj, int sel)
{
Evas_Object *ret;
Ecdb_Drive_Info *drive;
char buf[1024];
int i, num_speeds, count;
drive = data;
if (!drive)
return NULL;
num_speeds = drive->write_speeds[0];
count = 1;
sel++;
for (i = 1; i < num_speeds; i++)
{
if ((drive->write_speeds[i]) <= 0)
continue;
if (count == sel)
break;
count++;
}
ret = ecdb_label_add(c, name);
snprintf(buf, sizeof(buf), "%d", drive->write_speeds[count]);
ecdb_label_text_set(ret, buf);
evas_object_show(ret);
return ret;
}