Combo works now, added a label widget, and use stringshare for the constant drive info stuff.

This commit is contained in:
Jaime Thomas 2008-12-20 21:08:50 +00:00
parent 7a6f108ed6
commit acce34c9dc
8 changed files with 204 additions and 15 deletions

View File

@ -15,4 +15,5 @@ collections {
#include "groups/burn_image.edc"
#include "groups/entry.edc"
#include "groups/combo.edc"
#include "groups/label.edc"
}

View File

@ -234,7 +234,43 @@ group {
align: 0.0 0.5;
}
}
description {
state: "deactivate" 0.0;
inherit: "default" 0.0;
color: 60 60 60 0;
}
}
part {
name: "ecdb.header.swallow";
type: SWALLOW;
description {
state: "default" 0.0;
align: 0.0 0.5;
color: 255 255 255 0;
rel1 {
to: "combo_button";
relative: 0.0 0.0;
offset: 9 0;
}
rel2 {
to: "combo_button";
relative: 1.0 1.0;
offset: -1 -1;
}
}
description {
state: "active" 0.0;
inherit: "default" 0.0;
color: 255 255 255 255;
}
}
}
programs {
@ -319,6 +355,24 @@ group {
source: "ecdb";
target: "combo_button";
}
program {
name: "header_hide";
signal: "ecdb,combo,header,swallow";
source: "ecdb";
action: STATE_SET "deactivate" 0.0;
target: "ecdb.header";
transition: DECELERATE 0.5;
}
program {
name: "swallow_show";
signal: "ecdb,combo,header,swallow";
source: "ecdb";
action: STATE_SET "active" 0.0;
target: "ecdb.header.swallow";
transition: DECELERATE 0.5;
}
}
}

View File

@ -0,0 +1,35 @@
/* vim: set sw=3 ts=3 sts=3 expandtab: */
group {
name: "ecdb/label";
parts {
part {
name: "ecdb.label";
type: TEXT;
description {
state: "default" 0.0;
color: 60 60 60 255;
fixed: 1 1;
rel1 {
relative: 0.0 0.0;
offset: 0 0;
}
rel2 {
relative: 1.0 1.0;
offset: -1 -1;
}
text {
text: "";
font: "ecdb/default";
min: 1 1;
size: 11;
align: 0.0 0.5;
}
}
}
}
}

View File

@ -51,13 +51,13 @@ struct _Ecdb_Drive_Info
int *write_speeds;
/* Profiles */
char *profile_name;
const char *profile_name;
int profile_loaded;
/* Drive info */
char *vendor;
char *product;
char *revision;
const char *vendor;
const char *product;
const char *revision;
char *location;
unsigned char read_dvdram:1;

View File

@ -31,10 +31,9 @@ ecdb_aquire_drive_info(void)
return FALSE;
}
/* It would be nice if there was an easier way to do this */
drive->product = strdup(drives_current[i].product);
drive->vendor = strdup(drives_current[i].vendor);
drive->revision = strdup(drives_current[i].revision);
drive->product = eina_stringshare_add(drives_current[i].product);
drive->vendor = eina_stringshare_add(drives_current[i].vendor);
drive->revision = eina_stringshare_add(drives_current[i].revision);
drive->location = strdup(drives_current[i].location);
drive->read_dvdram = drives_current[i].read_dvdram;
drive->read_dvdr = drives_current[i].read_dvdr;
@ -48,7 +47,7 @@ ecdb_aquire_drive_info(void)
burn_drive_get_speedlist(drives_current[i].drive, &speeds);
drive->profile_name = strdup(speeds->profile_name);
drive->profile_name = eina_stringshare_add(speeds->profile_name);
drive->profile_loaded = speeds->profile_loaded;
while (speeds->next)
@ -89,11 +88,11 @@ ecdb_drive_info_list_free(Eina_List *list)
{
FREE(info->read_speeds);
FREE(info->write_speeds);
FREE(info->vendor);
FREE(info->product);
FREE(info->revision);
FREE(info->location);
FREE(info->profile_name);
eina_stringshare_del(info->vendor);
eina_stringshare_del(info->product);
eina_stringshare_del(info->revision);
eina_stringshare_del(info->profile_name);
FREE(info);
}

View File

@ -20,6 +20,8 @@ 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 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
ecdb_cb_enter(Ecore_Evas *ee)
@ -772,6 +774,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);
EINA_LIST_FOREACH(em->drives, l, drive)
{
@ -912,3 +915,16 @@ ecdb_gui_burn_image_cleanup(void)
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

@ -59,6 +59,12 @@ ecdb_button_icon_set(Evas_Object *b, const char *group)
evas_object_show(icon);
}
const char *
ecdb_button_label_get(Evas_Object *b)
{
return edje_object_part_text_get(b, "ecdb.label");
}
/************************* CHECK *********************************************/
Evas_Object *
@ -290,7 +296,11 @@ struct _Combo_Data
Evas_Object *popup;
unsigned int expanded;
unsigned int count;
int selected;
const char *name;
const char *header;
Evas_Object * (*create_header)(Evas_Object *, const char *name,
Evas_Object *, int);
};
static void
@ -348,6 +358,7 @@ _combo_del(void *data, Evas *e, Evas_Object *obj, void *event_info)
cd = evas_object_data_get(data, "cd");
eina_stringshare_del(cd->name);
eina_stringshare_del(cd->header);
FREE(cd);
}
@ -375,7 +386,31 @@ _combo_hide(void *data, Evas *e, Evas_Object *obj, void *event_info)
static void
_combo_clicked(void *data, Evas_Object *obj, void *event_info)
{
printf("object clicked...\n");
Combo_Data *cd;
Evas_Object *swallow, *header;
Eina_Iterator *it;
int i = 0;
cd = evas_object_data_get(data, "cd");
swallow = edje_object_part_swallow_get(data, "ecdb.header.swallow");
if (swallow)
evas_object_del(swallow);
it = evas_object_box_iterator_new(edje_object_part_object_get(cd->popup,
"ecdb.box"));
while (eina_iterator_next(it, (void **)&swallow))
{
if (swallow == obj)
break;
i++;
}
// Should I send the part name? The the normal widget_add would handle
// the swallowing
cd->selected = i;
header = cd->create_header(data, "ecdb.header.swallow", swallow, i);
edje_object_signal_emit(data, "ecdb,combo,header,swallow", "ecdb");
ecdb_combo_collapse(data);
}
static void
@ -441,6 +476,7 @@ ecdb_combo_add(Evas_Object *parent, const char *name)
cd->parent = parent;
cd->name = eina_stringshare_add(name);
cd->selected = -1;
evas_object_data_set(c, "cd", cd);
return c;
@ -449,7 +485,12 @@ ecdb_combo_add(Evas_Object *parent, const char *name)
void
ecdb_combo_header_set(Evas_Object *c, const char *text)
{
Combo_Data *cd;
cd = evas_object_data_get(c, "cd");
edje_object_part_text_set(c, "ecdb.header", text);
eina_stringshare_del(cd->header);
cd->header = eina_stringshare_add(text);
}
void
@ -527,3 +568,33 @@ ecdb_combo_collapse(Evas_Object *c)
cd->expanded = 0;
}
void
ecdb_combo_header_create_set(Evas_Object *c, Evas_Object * (*func)
(Evas_Object *c, const char *name,
Evas_Object *clicked, int idx))
{
Combo_Data *cd;
cd = evas_object_data_get(c, "cd");
cd->create_header = func;
}
/******************************* Label ***************************************/
Evas_Object *
ecdb_label_add(Evas_Object *parent, const char *name)
{
Evas_Object *l;
l = ecdb_widget_add(parent, name);
edje_object_file_set(l, em->theme_path, "ecdb/label");
return l;
}
void
ecdb_label_text_set(Evas_Object *l, const char *text)
{
edje_object_part_text_set(l, "ecdb.label", text);
}

View File

@ -5,6 +5,7 @@
Evas_Object *ecdb_button_add(Evas_Object *parent, const char *name);
void ecdb_button_label_set(Evas_Object *b, const char *label);
void ecdb_button_icon_set(Evas_Object *b, const char *group);
const char *ecdb_button_label_get(Evas_Object *b);
Evas_Object *ecdb_check_add(Evas_Object *parent, const char *name);
void ecdb_check_label_set(Evas_Object *c, const char *label);
@ -16,12 +17,24 @@ Evas_Object *ecdb_entry_add(Evas_Object *parent, const char *name);
void ecdb_entry_text_set(Evas_Object *e, const char *text);
char *ecdb_entry_text_get(Evas_Object *e);
// I am unsure about whether to use elementary here or not... It would be nice
/* Combo todo list:
* separate hover from combo
* able to set whether combo collapses on child click
* better theme
*/
Evas_Object *ecdb_combo_add(Evas_Object *parent, const char *name);
void ecdb_combo_header_set(Evas_Object *c, const char *text);
void ecdb_combo_append(Evas_Object *c, Evas_Object *o);
void ecdb_combo_expand(Evas_Object *c);
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,
Evas_Object *clicked,
int idx));
Evas_Object *ecdb_label_add(Evas_Object *parent, const char *name);
void ecdb_label_text_set(Evas_Object *l, const char *text);
#endif