From acce34c9dc81b6215b7a72226480663db9380166 Mon Sep 17 00:00:00 2001 From: Jaime Thomas Date: Sat, 20 Dec 2008 21:08:50 +0000 Subject: [PATCH] Combo works now, added a label widget, and use stringshare for the constant drive info stuff. --- .../trunk/data/themes/default/default.edc | 1 + .../data/themes/default/groups/combo.edc | 54 ++++++++++++++ .../data/themes/default/groups/label.edc | 35 +++++++++ experimental/ecdb/trunk/src/ecdb_common.h | 8 +- experimental/ecdb/trunk/src/ecdb_drives.c | 17 ++--- experimental/ecdb/trunk/src/ecdb_gui.c | 16 ++++ experimental/ecdb/trunk/src/ecdb_widgets.c | 73 ++++++++++++++++++- experimental/ecdb/trunk/src/ecdb_widgets.h | 15 +++- 8 files changed, 204 insertions(+), 15 deletions(-) create mode 100644 experimental/ecdb/trunk/data/themes/default/groups/label.edc diff --git a/experimental/ecdb/trunk/data/themes/default/default.edc b/experimental/ecdb/trunk/data/themes/default/default.edc index 5f034a7c..bda19223 100644 --- a/experimental/ecdb/trunk/data/themes/default/default.edc +++ b/experimental/ecdb/trunk/data/themes/default/default.edc @@ -15,4 +15,5 @@ collections { #include "groups/burn_image.edc" #include "groups/entry.edc" #include "groups/combo.edc" + #include "groups/label.edc" } diff --git a/experimental/ecdb/trunk/data/themes/default/groups/combo.edc b/experimental/ecdb/trunk/data/themes/default/groups/combo.edc index 373aea7f..be6efcbb 100644 --- a/experimental/ecdb/trunk/data/themes/default/groups/combo.edc +++ b/experimental/ecdb/trunk/data/themes/default/groups/combo.edc @@ -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; + } } } diff --git a/experimental/ecdb/trunk/data/themes/default/groups/label.edc b/experimental/ecdb/trunk/data/themes/default/groups/label.edc new file mode 100644 index 00000000..294abf18 --- /dev/null +++ b/experimental/ecdb/trunk/data/themes/default/groups/label.edc @@ -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; + } + } + } + } +} diff --git a/experimental/ecdb/trunk/src/ecdb_common.h b/experimental/ecdb/trunk/src/ecdb_common.h index 71a6346a..1b316e70 100644 --- a/experimental/ecdb/trunk/src/ecdb_common.h +++ b/experimental/ecdb/trunk/src/ecdb_common.h @@ -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; diff --git a/experimental/ecdb/trunk/src/ecdb_drives.c b/experimental/ecdb/trunk/src/ecdb_drives.c index dd1b97db..dde6ba95 100644 --- a/experimental/ecdb/trunk/src/ecdb_drives.c +++ b/experimental/ecdb/trunk/src/ecdb_drives.c @@ -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); } diff --git a/experimental/ecdb/trunk/src/ecdb_gui.c b/experimental/ecdb/trunk/src/ecdb_gui.c index 4a71a50f..2222fb38 100644 --- a/experimental/ecdb/trunk/src/ecdb_gui.c +++ b/experimental/ecdb/trunk/src/ecdb_gui.c @@ -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; +} diff --git a/experimental/ecdb/trunk/src/ecdb_widgets.c b/experimental/ecdb/trunk/src/ecdb_widgets.c index 06fb521a..279e12ec 100644 --- a/experimental/ecdb/trunk/src/ecdb_widgets.c +++ b/experimental/ecdb/trunk/src/ecdb_widgets.c @@ -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); +} diff --git a/experimental/ecdb/trunk/src/ecdb_widgets.h b/experimental/ecdb/trunk/src/ecdb_widgets.h index 081d4998..0779b139 100644 --- a/experimental/ecdb/trunk/src/ecdb_widgets.h +++ b/experimental/ecdb/trunk/src/ecdb_widgets.h @@ -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