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

@ -106,6 +106,13 @@ group {
after: "focus_set";
}
program {
name: "signal_emit";
signal: "mouse,clicked,1";
action: SIGNAL_EMIT "clicked" "ecdb";
source: "*";
}
program {
name: "focus_in,ecdb";
action: STATE_SET "focused" 0.0;

View File

@ -1,7 +1,7 @@
/* vim: set sw=3 ts=3 sts=3 expandtab: */
group {
name: "ecdb/window";
min: 640 350;
min: 640 360;
parts {
part {
@ -10,7 +10,7 @@ group {
description {
state: "default" 0.0;
min: 640 350;
min: 640 360;
max: 999999 999999;
rel1 {

View File

@ -13,6 +13,7 @@ ecdb_SOURCES = \
ecdb_erase.c ecdb_erase.h \
ecdb_widgets.c ecdb_widgets.h \
ecdb_erase_gui.c ecdb_erase_gui.h \
ecdb_burn_image_gui.c ecdb_burn_image_gui.h \
ecdb_common.h
ecdb_CFLAGS = @ECDB_CFLAGS@

View File

@ -56,6 +56,7 @@ extern int ECDB_DRIVE_ACTION_UPDATE;
#include "ecdb_gui.h"
#include "ecdb_widgets.h"
#include "ecdb_erase_gui.h"
#include "ecdb_burn_image_gui.h"
#endif

View File

@ -292,7 +292,7 @@ ecdb_burn_finished(void *data, int type, void *event)
}
FREE(proj);
ecdb_gui_burn_image_cleanup();
ecdb_burn_image_cleanup();
return TRUE;
}

View File

@ -147,7 +147,7 @@ ecdb_erase_finished(void *data, int type, void *event)
burn_drive_info_free(ECDB_PROJECT(proj)->drive->tangible);
ecore_event_handler_del(ECDB_PROJECT(proj)->ev_handler);
ecdb_erase_project_destroy(proj);
ecdb_gui_erase_cleanup();
ecdb_erase_cleanup();
return TRUE;
}

View File

@ -1,8 +1,6 @@
/* vim: set sw=3 ts=3 sts=3 expandtab: */
#include "ecdb.h"
static Evas_Object *combo_header_create(Evas_Object *c, const char *name,
Evas_Object *obj, int sel);
static void _button_cb_return(void *data, Evas_Object *obj, void *event_info);
static void _button_cb_begin(void *data, Evas_Object *obj, void *event_info);
@ -100,9 +98,6 @@ ecdb_erase_page_show(void)
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, "hide,finished", "erase_page",
ecdb_page_hide_finished, NULL);
evas_object_show(swallow);
@ -125,7 +120,7 @@ ecdb_erase_page_show(void)
b = ecdb_combo_add(swallow, "ecdb/erase/drive");
ecdb_combo_header_set(b, "Drive");
ecdb_combo_header_create_set(b, combo_header_create);
ecdb_combo_header_create_set(b, ecdb_gui_combo_header_from_drive);
EINA_LIST_FOREACH(em->drives, l, drive)
{
@ -147,30 +142,20 @@ ecdb_erase_page_show(void)
}
void
ecdb_gui_erase_cleanup(void)
ecdb_erase_cleanup(void)
{
Evas_Object *swallow;
const char *ids[] = {"ecdb/erase/return", "ecdb/erase/begin",
"ecdb/erase/speed"};
"ecdb/erase/speed", "ecdb/erase/drive"};
swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee),
"erase_page");
edje_object_part_text_set(swallow, "progress_text", "Erase Complete!");
ecdb_gui_controls_enable(ids, 3);
ecdb_gui_controls_enable(ids, 4);
edje_object_signal_emit(swallow, "ecdb,erase,done", "ecdb");
}
static Evas_Object *
combo_header_create(Evas_Object *c, const char *name, Evas_Object *obj, int sel)
{
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;
swallow = evas_object_name_find(ecore_evas_get(em->main_win_ee),
"ecdb/erase/drive");
ecdb_check_checked_set(swallow, 0);
}

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

View File

@ -4,13 +4,17 @@
int ecdb_create_main_gui(void);
void ecdb_set_main_theme(const char *theme_name);
void ecdb_gui_erase_cleanup(void);
void ecdb_gui_burn_image_cleanup(void);
void ecdb_welcome_page_show(void);
void ecdb_page_hide_finished(void *data, Evas_Object *o,
const char *emission,
const char *source);
void ecdb_gui_controls_disable(const char ** ids, int n);
void ecdb_gui_controls_enable(const char **ids, int n);
Evas_Object *ecdb_gui_combo_header_from_drive(Evas_Object *c, const char *name,
void *data, Evas_Object *obj,
int sel);
Evas_Object *ecdb_gui_combo_header_from_speeds(Evas_Object *c, const char *name,
void *data, Evas_Object *obj,
int sel);
#endif

View File

@ -1,6 +1,36 @@
/* vim: set sw=3 ts=3 sts=3 expandtab: */
#include "ecdb.h"
static void
_widget_focus_handle(void *data, Evas_Object *o, const char *emission,
const char *source)
{
static char *old_source;
const char *name;
Evas_Object *eo;
name = data;
// Some widgets aren't named (such as when in combo), so check
if (!name)
return;
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(name);
}
else if (!old_source)
{
old_source = strdup(name);
}
// Send focus to the freshly clicked widget
eo = evas_object_name_find(ecore_evas_get(em->main_win_ee), name);
evas_object_focus_set(eo, 1);
}
Evas_Object *
ecdb_widget_add(Evas_Object *parent, const char *name)
{
@ -8,6 +38,9 @@ ecdb_widget_add(Evas_Object *parent, const char *name)
int x, y, w, h;
o = edje_object_add(evas_object_evas_get(parent));
edje_object_signal_callback_add(o, "mouse,down,*", "*",
_widget_focus_handle,
(void *)name);
if (name)
{
@ -123,7 +156,7 @@ ecdb_check_states_set(Evas_Object *c, const char *ystate, const char *nstate)
}
void
ecdb_check_state_set(Evas_Object *c, int state)
ecdb_check_checked_set(Evas_Object *c, int state)
{
Check_Data *cd;
@ -307,6 +340,14 @@ _entry_markup_to_text(const char *mkup)
return str;
}
static void
_entry_click_cb_call(void *data, Evas_Object *obj, const char *emission,
const char *source)
{
evas_object_focus_set(obj, 1);
evas_object_smart_callback_call(obj, "clicked", NULL);
}
Evas_Object *
ecdb_entry_add(Evas_Object *parent, const char *name)
{
@ -316,6 +357,8 @@ ecdb_entry_add(Evas_Object *parent, const char *name)
edje_object_file_set(e, em->theme_path, "ecdb/entry");
em->dnd_candidates = eina_list_append(em->dnd_candidates, e);
evas_object_data_set(e, "dnd_call_func", ecdb_dnd_entry_dnd_set);
edje_object_signal_callback_add(e, "clicked", "ecdb", _entry_click_cb_call,
e);
return e;
}
@ -345,7 +388,8 @@ struct _Combo_Data
int selected;
const char *name;
const char *header;
Evas_Object * (*create_header)(Evas_Object *, const char *name,
void *data;
Evas_Object * (*create_header)(Evas_Object *, const char *name, void *data,
Evas_Object *, int);
};
@ -387,7 +431,7 @@ _combo_best_location(Evas_Object *c)
ecore_evas_geometry_get(em->main_win_ee, NULL, NULL, &ww, &wh);
evas_object_geometry_get(c, &x, &y, &w, &h);
if ((h) > (wh - y - h))
if ((y + h) > (wh - y - h))
{
return "top";
}
@ -455,7 +499,8 @@ _combo_clicked(void *data, Evas_Object *obj, void *event_info)
cd->selected = i;
if (cd->create_header)
header = cd->create_header(data, "ecdb.header.swallow", swallow, i);
header = cd->create_header(data, "ecdb.header.swallow", cd->data,
swallow, i);
edje_object_signal_emit(data, "ecdb,combo,header,swallow", "ecdb");
ecdb_combo_collapse(data);
}
@ -563,6 +608,9 @@ ecdb_combo_expand(Evas_Object *c)
cd = evas_object_data_get(c, "cd");
if (cd->count == 0)
return;
edje_object_signal_emit(c, "ecdb,combo,active", "ecdb");
evas_object_move(cd->back, 0, 0);
@ -635,7 +683,7 @@ ecdb_combo_collapse(Evas_Object *c)
void
ecdb_combo_header_create_set(Evas_Object *c, Evas_Object * (*func)
(Evas_Object *c, const char *name,
Evas_Object *clicked, int idx))
void *data, Evas_Object *clicked, int idx))
{
Combo_Data *cd;
@ -653,6 +701,15 @@ ecdb_combo_selected_get(Evas_Object *c)
return cd->selected;
}
void
ecdb_combo_data_set(Evas_Object *c, void *data)
{
Combo_Data *cd;
cd = evas_object_data_get(c, "cd");
cd->data = data;
}
/******************************* Label ***************************************/
Evas_Object *

View File

@ -11,7 +11,7 @@ Evas_Object *ecdb_check_add(Evas_Object *parent, const char *name);
void ecdb_check_label_set(Evas_Object *c, const char *label);
void ecdb_check_states_set(Evas_Object *c, const char *ystate,
const char *nstate);
void ecdb_check_state_set(Evas_Object *c, int state);
void ecdb_check_checked_set(Evas_Object *c, int state);
int ecdb_check_checked_get(Evas_Object *c);
Evas_Object *ecdb_entry_add(Evas_Object *parent, const char *name);
@ -31,9 +31,11 @@ void ecdb_combo_collapse(Evas_Object *c);
void ecdb_combo_header_create_set(Evas_Object *c, Evas_Object *
(*func)(Evas_Object *c,
const char *name,
void *data,
Evas_Object *clicked,
int idx));
int ecdb_combo_selected_get(Evas_Object *c);
void ecdb_combo_data_set(Evas_Object *c, void *data);
Evas_Object *ecdb_label_add(Evas_Object *parent, const char *name);
void ecdb_label_text_set(Evas_Object *l, const char *text);