Start splitting up ecdb_gui into more logic files

This commit is contained in:
Jaime Thomas 2008-12-21 01:48:31 +00:00
parent a749296f93
commit 9c0d05f789
9 changed files with 252 additions and 190 deletions

View File

@ -9,13 +9,13 @@ group {
if (get_int(s) == 0) if (get_int(s) == 0)
{ {
set_state(PART:"check", "active", 0.0); set_state(PART:"check", "active", 0.0);
emit("ecdb,check,checked", "ecdb/check"); emit("ecdb,check,checked", "ecdb");
set_int(s, 1); set_int(s, 1);
} }
else else
{ {
set_state(PART:"check", "default", 0.0); set_state(PART:"check", "default", 0.0);
emit("ecdb,check,unchecked", "ecdb/check"); emit("ecdb,check,unchecked", "ecdb");
set_int(s, 0); set_int(s, 0);
} }
} }

View File

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

View File

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

View File

@ -0,0 +1,176 @@
/* 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);
static void
_button_cb_return(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *swallow, *gui;
char *signal;
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),
"erase_page");
edje_object_part_text_set(swallow, "progress_text", "Begin Erase");
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();
}
static void
_button_cb_begin(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *swallow, *gui, *o;
Ecdb_Erase_Project *proj;
char buf[1024];
int drive;
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),
"erase_page");
proj = ecdb_erase_project_new();
snprintf(buf, sizeof(buf), "Commencing...");
edje_object_part_text_set(swallow, "progress_text", buf);
o = evas_object_name_find(evas_object_evas_get(obj), "ecdb/erase/drive");
drive = ecdb_combo_selected_get(o);
if (!ecdb_aquire_drive(ECDB_PROJECT(proj), drive))
{
printf("Couldn't grab drive!\n");
ecdb_erase_project_destroy(proj);
edje_object_part_text_set(swallow, "progress_text",
"Couldn't grab the drive!");
return;
}
o = evas_object_name_find(evas_object_evas_get(obj), "ecdb/erase/speed");
proj->quick = ecdb_check_checked_get(o);
if (!ecdb_erase_disc(proj))
{
Ecdb_Project *p = ECDB_PROJECT(proj);
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);
burn_drive_info_free(p->drive->tangible);
ecdb_erase_project_destroy(proj);
return;
}
edje_object_signal_emit(swallow, "ecdb,erase,start", "ecdb");
const char *ids[] = {"ecdb/erase/return", "ecdb/erase/begin",
"ecdb/erase/speed", "ecdb/erase/drive"};
ecdb_gui_controls_disable(ids, 4);
}
void
ecdb_erase_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),
"erase_page");
/* Hide the filelist as it isn't needed to erase a disc */
edje_object_signal_emit(gui, "ecdb,filelist,hide", "ecdb");
if (!swallow)
{
Evas_Object *b, *d;
Evas_Coord x, y, w, h;
Eina_List *l;
Ecdb_Drive_Info *drive;
swallow = edje_object_add(ecore_evas_get(em->main_win_ee));
edje_object_file_set(swallow, em->theme_path, "ecdb/erase_page");
evas_object_name_set(swallow, "erase_page");
evas_object_data_set(swallow, "hide_signal", "ecdb,erase_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, "hide,finished", "erase_page",
ecdb_page_hide_finished, NULL);
evas_object_show(swallow);
b = ecdb_button_add(swallow, "ecdb/erase/return");
ecdb_button_label_set(b, "Return to Main Page");
evas_object_smart_callback_add(b, "clicked", _button_cb_return, NULL);
evas_object_show(b);
ecdb_button_icon_set(b, "ecdb/erase/return");
b = ecdb_button_add(swallow, "ecdb/erase/begin");
ecdb_button_label_set(b, "Start Erase");
evas_object_smart_callback_add(b, "clicked", _button_cb_begin, NULL);
evas_object_show(b);
ecdb_button_icon_set(b, "ecdb/erase/begin");
b = ecdb_check_add(swallow, "ecdb/erase/speed");
ecdb_check_label_set(b, "Quick Erase");
evas_object_show(b);
b = ecdb_combo_add(swallow, "ecdb/erase/drive");
ecdb_combo_header_set(b, "Drive");
ecdb_combo_header_create_set(b, combo_header_create);
EINA_LIST_FOREACH(em->drives, l, drive)
{
d = ecdb_button_add(b, NULL);
ecdb_button_label_set(d, drive->product);
ecdb_combo_append(b, d);
evas_object_show(d);
}
}
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,erase_page,visible", "ecdb");
edje_object_signal_emit(swallow, "ecdb,erase_page,visible", "ecdb");
}
void
ecdb_gui_erase_cleanup(void)
{
Evas_Object *swallow;
const char *ids[] = {"ecdb/erase/return", "ecdb/erase/begin",
"ecdb/erase/speed"};
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);
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;
}

View File

@ -0,0 +1,8 @@
/* vim: set sw=3 ts=3 sts=3 expandtab: */
#ifndef ECDB_ERASE_GUI_H
#define ECDB_ERASE_GUI_H
void ecdb_erase_page_show(void);
void ecdb_erase_cleanup(void);
#endif

View File

@ -6,22 +6,12 @@ static void ecdb_cb_controls_focused(void *data, Evas_Object *o,
const char *emission, const char *source); const char *emission, const char *source);
static void ecdb_cb_welcome_page_buttons_clicked(void *data, Evas_Object *o, static void ecdb_cb_welcome_page_buttons_clicked(void *data, Evas_Object *o,
const char *emission, const char *source); 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, static void ecdb_cb_burn_image_page_buttons_clicked(void *data, Evas_Object *o,
const char *emission, const char *source); 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);
static void ecdb_gui_controls_enable(const char **ids, int n);
static void ecdb_filelist_show(void); 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_burn_image_page_show(void);
static void ecdb_page_hide(const char *pname); static void ecdb_page_hide(const char *pname);
static void ecdb_filelist_focus_handle(int action, Evas_Object *fl); static void ecdb_filelist_focus_handle(int action, Evas_Object *fl);
Evas_Object *combo_header_create(Evas_Object *c, const char *name,
Evas_Object *obj, int sel);
static void static void
ecdb_cb_enter(Ecore_Evas *ee) ecdb_cb_enter(Ecore_Evas *ee)
@ -416,70 +406,6 @@ ecdb_cb_welcome_page_buttons_clicked(void *data, Evas_Object *o,
printf("Action: %s\n", source); printf("Action: %s\n", source);
} }
static void
ecdb_cb_erase_page_buttons_clicked(void *data, Evas_Object *o,
const char *emission, const char *source)
{
Evas_Object *swallow, *gui;
static int speed = 0;
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),
"erase_page");
if (!strcmp(source, "ecdb/erase/return"))
{
char *signal;
edje_object_part_text_set(swallow, "progress_text", "Begin Erase");
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();
}
else if (!strcmp(source, "ecdb/erase/begin"))
{
Ecdb_Erase_Project *proj;
proj = ecdb_erase_project_new();
char buf[1024];
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_erase_project_destroy(proj);
edje_object_part_text_set(swallow, "progress_text",
"Couldn't grab the drive!");
return;
}
proj->quick = speed;
if (!ecdb_erase_disc(proj))
{
Ecdb_Project *p = ECDB_PROJECT(proj);
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);
burn_drive_info_free(p->drive->tangible);
ecdb_erase_project_destroy(proj);
return;
}
speed = 0;
edje_object_signal_emit(swallow, "ecdb,erase,start", "ecdb");
const char *ids[] = {"ecdb/erase/return", "ecdb/erase/begin",
"ecdb/erase/speed"};
ecdb_gui_controls_disable(ids, 3);
}
else if (!strcmp(source, "ecdb/erase/speed"))
{
speed = !speed;
printf("Burn speed: %d\n", speed);
}
}
static void static void
ecdb_cb_burn_image_page_buttons_clicked(void *data, Evas_Object *o, ecdb_cb_burn_image_page_buttons_clicked(void *data, Evas_Object *o,
const char *emission, const char *source) const char *emission, const char *source)
@ -586,10 +512,8 @@ ecdb_cb_burn_image_page_buttons_clicked(void *data, Evas_Object *o,
"ecdb/burn_image/file"); "ecdb/burn_image/file");
evas_object_focus_set(swallow, 1); evas_object_focus_set(swallow, 1);
} }
} }
void
static void
ecdb_welcome_page_show(void) ecdb_welcome_page_show(void)
{ {
Evas_Object *gui, *swallow; Evas_Object *gui, *swallow;
@ -616,7 +540,7 @@ ecdb_welcome_page_show(void)
edje_object_signal_callback_add(swallow, "mouse,clicked,1", "ecdb/*", edje_object_signal_callback_add(swallow, "mouse,clicked,1", "ecdb/*",
ecdb_cb_welcome_page_buttons_clicked, NULL); ecdb_cb_welcome_page_buttons_clicked, NULL);
edje_object_signal_callback_add(swallow, "hide,finished", "welcome_page", edje_object_signal_callback_add(swallow, "hide,finished", "welcome_page",
ecdb_cb_page_hide_finished, NULL); ecdb_page_hide_finished, NULL);
evas_object_show(swallow); evas_object_show(swallow);
int i; int i;
@ -721,80 +645,6 @@ ecdb_page_hide(const char *pname)
} }
} }
static void
ecdb_erase_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),
"erase_page");
/* Hide the filelist as it isn't needed to erase a disc */
edje_object_signal_emit(gui, "ecdb,filelist,hide", "ecdb");
if (!swallow)
{
Evas_Object *b, *d;
Evas_Coord x, y, w, h;
Eina_List *l;
Ecdb_Drive_Info *drive;
swallow = edje_object_add(ecore_evas_get(em->main_win_ee));
edje_object_file_set(swallow, em->theme_path, "ecdb/erase_page");
evas_object_name_set(swallow, "erase_page");
evas_object_data_set(swallow, "hide_signal", "ecdb,erase_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/erase/*",
ecdb_cb_erase_page_buttons_clicked, NULL);
edje_object_signal_callback_add(swallow, "hide,finished", "erase_page",
ecdb_cb_page_hide_finished, NULL);
evas_object_show(swallow);
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");
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");
b = ecdb_check_add(swallow, "ecdb/erase/speed");
ecdb_check_label_set(b, "Quick Erase");
evas_object_show(b);
b = ecdb_combo_add(swallow, "ecdb/erase/drive");
ecdb_combo_header_set(b, "Drive");
ecdb_combo_header_create_set(b, combo_header_create);
EINA_LIST_FOREACH(em->drives, l, drive)
{
d = ecdb_button_add(b, NULL);
ecdb_button_label_set(d, drive->product);
ecdb_combo_append(b, d);
evas_object_show(d);
}
}
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,erase_page,visible", "ecdb");
edje_object_signal_emit(swallow, "ecdb,erase_page,visible", "ecdb");
}
static void static void
ecdb_burn_image_page_show(void) ecdb_burn_image_page_show(void)
{ {
@ -830,7 +680,7 @@ ecdb_burn_image_page_show(void)
NULL); NULL);
edje_object_signal_callback_add(swallow, "hide,finished", edje_object_signal_callback_add(swallow, "hide,finished",
"burn_image_page", "burn_image_page",
ecdb_cb_page_hide_finished, NULL); ecdb_page_hide_finished, NULL);
evas_object_show(swallow); evas_object_show(swallow);
b = ecdb_button_add(swallow, "ecdb/burn_image/return"); b = ecdb_button_add(swallow, "ecdb/burn_image/return");
@ -890,14 +740,14 @@ ecdb_burn_image_page_show(void)
} }
/* Hurrah! Fancyness */ /* Hurrah! Fancyness */
static void void
ecdb_cb_page_hide_finished(void *data, Evas_Object *o, const char *emission, ecdb_page_hide_finished(void *data, Evas_Object *o, const char *emission,
const char *source) const char *source)
{ {
ecdb_page_hide(source); ecdb_page_hide(source);
} }
static void void
ecdb_gui_controls_disable(const char **ids, int n) ecdb_gui_controls_disable(const char **ids, int n)
{ {
Evas_Object *obj; Evas_Object *obj;
@ -910,7 +760,7 @@ ecdb_gui_controls_disable(const char **ids, int n)
} }
} }
static void void
ecdb_gui_controls_enable(const char **ids, int n) ecdb_gui_controls_enable(const char **ids, int n)
{ {
Evas_Object *obj; Evas_Object *obj;
@ -923,20 +773,6 @@ ecdb_gui_controls_enable(const char **ids, int n)
} }
} }
void
ecdb_gui_erase_cleanup(void)
{
Evas_Object *swallow;
const char *ids[] = {"ecdb/erase/return", "ecdb/erase/begin",
"ecdb/erase/speed"};
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);
edje_object_signal_emit(swallow, "ecdb,erase,done", "ecdb");
}
void void
ecdb_gui_burn_image_cleanup(void) ecdb_gui_burn_image_cleanup(void)
{ {
@ -950,16 +786,3 @@ ecdb_gui_burn_image_cleanup(void)
edje_object_signal_emit(swallow, "ecdb,burn_image,done", "ecdb"); edje_object_signal_emit(swallow, "ecdb,burn_image,done", "ecdb");
} }
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;
}

View File

@ -6,5 +6,11 @@ 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);
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);
#endif #endif

View File

@ -67,13 +67,44 @@ ecdb_button_label_get(Evas_Object *b)
/************************* CHECK *********************************************/ /************************* CHECK *********************************************/
typedef struct _Check_Data Check_Data;
struct _Check_Data
{
unsigned int checked;
};
void
_check_toggle_cb_call(void *data, Evas_Object *obj, const char *emission,
const char *source)
{
Check_Data *cd;
cd = evas_object_data_get(obj, "cd");
if (!strcmp(emission, "ecdb,check,checked"))
{
evas_object_smart_callback_call(obj, "checked", NULL);
cd->checked = 1;
}
else
{
evas_object_smart_callback_call(obj, "unchecked", NULL);
cd->checked = 0;
}
}
Evas_Object * Evas_Object *
ecdb_check_add(Evas_Object *parent, const char *name) ecdb_check_add(Evas_Object *parent, const char *name)
{ {
Evas_Object *c; Evas_Object *c;
Check_Data *cd;
c = ecdb_widget_add(parent, name); c = ecdb_widget_add(parent, name);
edje_object_file_set(c, em->theme_path, "ecdb/check"); edje_object_file_set(c, em->theme_path, "ecdb/check");
edje_object_signal_callback_add(c, "ecdb,check,*", "ecdb",
_check_toggle_cb_call, c);
cd = calloc(1, sizeof(Check_Data));
evas_object_data_set(c, "cd", cd);
return c; return c;
} }
@ -94,16 +125,31 @@ ecdb_check_states_set(Evas_Object *c, const char *ystate, const char *nstate)
void void
ecdb_check_state_set(Evas_Object *c, int state) ecdb_check_state_set(Evas_Object *c, int state)
{ {
Check_Data *cd;
cd = evas_object_data_get(c, "cd");
if (state) if (state)
{ {
cd->checked = 1;
edje_object_signal_emit(c, "ecdb,check,on", "ecdb"); edje_object_signal_emit(c, "ecdb,check,on", "ecdb");
} }
else else
{ {
cd->checked = 0;
edje_object_signal_emit(c, "ecdb,check,off", "ecdb"); edje_object_signal_emit(c, "ecdb,check,off", "ecdb");
} }
} }
int
ecdb_check_checked_get(Evas_Object *c)
{
Check_Data *cd;
cd = evas_object_data_get(c, "cd");
return cd->checked;
}
/************************** ENTRY *******************************************/ /************************** ENTRY *******************************************/
/* Shamelessly stolen from Elementary... */ /* Shamelessly stolen from Elementary... */

View File

@ -12,6 +12,7 @@ void ecdb_check_label_set(Evas_Object *c, const char *label);
void ecdb_check_states_set(Evas_Object *c, const char *ystate, void ecdb_check_states_set(Evas_Object *c, const char *ystate,
const char *nstate); const char *nstate);
void ecdb_check_state_set(Evas_Object *c, int state); void ecdb_check_state_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); Evas_Object *ecdb_entry_add(Evas_Object *parent, const char *name);
void ecdb_entry_text_set(Evas_Object *e, const char *text); void ecdb_entry_text_set(Evas_Object *e, const char *text);