Enlightenment CVS committal Author : dj2 Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/bin/tests Modified Files: Makefile.am ewl_combo.c ewl_theme.c Log Message: - remove the dirty flag from the models, makes it impossible to share them - start moving combo over to use the model/view setup, working not half bad, there appears to be something wrong with the button appearance change [This is API breakage.] - need to add doxy - need to redo the theme tests as I've just removed the combo for now until it can be ported to model/view =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/bin/tests/Makefile.am,v retrieving revision 1.23 retrieving revision 1.24 diff -u -3 -r1.23 -r1.24 --- Makefile.am 10 Mar 2006 18:36:44 -0000 1.23 +++ Makefile.am 13 Mar 2006 00:19:27 -0000 1.24 @@ -26,7 +26,7 @@ ewl_table.la ewl_notebook.la ewl_scrollpane.la \ ewl_spinner.la ewl_progressbar.la ewl_theme.la \ ewl_media.la ewl_menu.la ewl_imenu.la \ - ewl_widget.la + ewl_widget.la ewl_border_la_SOURCES = ewl_border.c ewl_border_la_LIBADD = $(top_builddir)/src/lib/libewl.la =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/bin/tests/ewl_combo.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- ewl_combo.c 10 Mar 2006 04:05:42 -0000 1.3 +++ ewl_combo.c 13 Mar 2006 00:19:27 -0000 1.4 @@ -1,9 +1,24 @@ #include "Ewl_Test.h" #include <stdio.h> #include <string.h> +#include <stdlib.h> +typedef struct Combo_Test_Data Combo_Test_Data; +struct Combo_Test_Data +{ + unsigned int count; + char ** data; +}; + +static void *combo_test_data_setup(void); static int create_test(Ewl_Container *win); static void combo_value_changed(Ewl_Widget *w, void *ev, void *data); +static Ewl_Widget *combo_test_data_header_fetch(void *data, + unsigned int col); +static void *combo_test_data_fetch(void *data, unsigned int row, + unsigned int col); +static int combo_test_data_count_get(void *data); +static void combo_cb_add(Ewl_Widget *w, void *ev, void *data); void test_info(Ewl_Test *test) @@ -20,57 +35,150 @@ static int create_test(Ewl_Container *box) { - Ewl_Widget *combo1, *item; - - combo1 = ewl_combo_new("test menu"); - ewl_container_child_append(EWL_CONTAINER(box), combo1); - ewl_callback_append(combo1, EWL_CALLBACK_VALUE_CHANGED, + Ewl_Widget *combo, *hbox, *o; + Ewl_Model *model; + Ewl_View *view; + void *data; + + hbox = ewl_hbox_new(); + ewl_container_child_append(EWL_CONTAINER(box), hbox); + ewl_widget_show(hbox); + + data = combo_test_data_setup(); + + /* create the model */ + model = ewl_model_new(); + ewl_model_fetch_set(model, combo_test_data_fetch); + ewl_model_count_set(model, combo_test_data_count_get); + ewl_model_header_fetch_set(model, combo_test_data_header_fetch); + + /* create the view for ewl_label widgets */ + view = ewl_view_new(); + ewl_view_constructor_set(view, ewl_label_new); + ewl_view_assign_set(view, EWL_VIEW_ASSIGN(ewl_label_text_set)); + + combo = ewl_combo_new(); + ewl_widget_name_set(combo, "combo_label"); + ewl_container_child_append(EWL_CONTAINER(hbox), combo); + ewl_callback_append(combo, EWL_CALLBACK_VALUE_CHANGED, combo_value_changed, NULL); - ewl_widget_show(combo1); - - item = ewl_menu_item_new(); - ewl_button_label_set(EWL_BUTTON(item), "dia"); - ewl_button_image_set(EWL_BUTTON(item), - PACKAGE_DATA_DIR "/images/Draw.png", NULL); - ewl_container_child_append(EWL_CONTAINER(combo1), item); - ewl_widget_show(item); - - item = EWL_WIDGET(ewl_separator_new()); - ewl_container_child_append(EWL_CONTAINER(combo1), item); - ewl_widget_show(item); - - item = ewl_menu_item_new(); - ewl_button_label_set(EWL_BUTTON(item), "gimp"); - ewl_button_image_set(EWL_BUTTON(item), - PACKAGE_DATA_DIR "/images/World.png", NULL); - ewl_container_child_append(EWL_CONTAINER(combo1), item); - ewl_widget_show(item); - - item = ewl_menu_item_new(); - ewl_button_label_set(EWL_BUTTON(item), "button"); - ewl_widget_data_set(item, "dummy", "data"); - ewl_container_child_append(EWL_CONTAINER(combo1), item); - ewl_widget_show(item); + ewl_combo_model_set(EWL_COMBO(combo), model); + ewl_combo_view_set(EWL_COMBO(combo), view); + ewl_combo_data_set(EWL_COMBO(combo), data); + ewl_widget_show(combo); + + /* create the view for ewl_image widgets */ + view = ewl_view_new(); + ewl_view_constructor_set(view, ewl_image_new); + ewl_view_assign_set(view, EWL_VIEW_ASSIGN(ewl_image_file_path_set)); + + combo = ewl_combo_new(); + ewl_widget_name_set(combo, "combo_image"); + ewl_container_child_append(EWL_CONTAINER(hbox), combo); + ewl_callback_append(combo, EWL_CALLBACK_VALUE_CHANGED, + combo_value_changed, NULL); + ewl_combo_model_set(EWL_COMBO(combo), model); + ewl_combo_view_set(EWL_COMBO(combo), view); + ewl_combo_data_set(EWL_COMBO(combo), data); + ewl_widget_show(combo); + + o = ewl_button_new(); + ewl_button_label_set(EWL_BUTTON(o), "Add items"); + ewl_container_child_append(EWL_CONTAINER(box), o); + ewl_callback_append(o, EWL_CALLBACK_CLICKED, combo_cb_add, NULL); + ewl_widget_show(o); return 1; } +static void * +combo_test_data_setup(void) +{ + Combo_Test_Data *data; + + data = calloc(1, sizeof(Combo_Test_Data)); + data->count = 3; + + data->data = calloc(3, sizeof(char *)); + data->data[0] = strdup(PACKAGE_DATA_DIR "/images/Draw.png"); + data->data[1] = strdup(PACKAGE_DATA_DIR "/images/End.png"); + data->data[2] = strdup(PACKAGE_DATA_DIR "/images/World.png"); + + return data; +} + +static Ewl_Widget * +combo_test_data_header_fetch(void *data __UNUSED__, + unsigned int col __UNUSED__) +{ + Ewl_Widget *header; + + header = ewl_label_new(); + ewl_label_text_set(EWL_LABEL(header), "Select Image"); + ewl_widget_show(header); + + return header; +} + +static void * +combo_test_data_fetch(void *data, unsigned int row, + unsigned int col __UNUSED__) +{ + Combo_Test_Data *d; + + d = data; + if (row < d->count) + return d->data[row]; + else + return NULL; +} + +static int +combo_test_data_count_get(void *data) +{ + Combo_Test_Data *d; + + d = data; + return d->count; +} + static void -combo_value_changed(Ewl_Widget *w __UNUSED__, void *ev, +combo_value_changed(Ewl_Widget *w, void *ev __UNUSED__, + void *data __UNUSED__) +{ + Combo_Test_Data *d; + int idx; + + d = ewl_combo_data_get(EWL_COMBO(w)); + idx = ewl_combo_selected_get(EWL_COMBO(w)); + if (idx > -1) + printf("value changed to %d (%s)\n", idx, d->data[idx]); + else + printf("Nothing selected.\n"); +} + +static void +combo_cb_add(Ewl_Widget *w __UNUSED__, void *ev __UNUSED__, void *data __UNUSED__) { - Ewl_Widget *entry; - const char *text; + Ewl_Widget *c; + Combo_Test_Data *d; + int s; - entry = EWL_WIDGET(ev); - text = ewl_button_label_get(EWL_BUTTON(entry)); + c = ewl_widget_name_find("combo_label"); + d = ewl_combo_data_get(EWL_COMBO(c)); - printf("value changed to %s\n", text); - if (!strcmp(text, "button")) - { - char *t2; - t2 = ewl_widget_data_get(entry, "dummy"); - printf("with data: %s\n", t2); - } + s = d->count; + d->count += 2; + d->data = realloc(d->data, sizeof(char *) * d->count); + + d->data[s] = strdup(PACKAGE_DATA_DIR "/images/Package.png"); + d->data[s + 1] = strdup(PACKAGE_DATA_DIR "/images/Open.png"); + + ewl_combo_dirty_set(EWL_COMBO(c), 1); + + c = ewl_widget_name_find("combo_image"); + ewl_combo_dirty_set(EWL_COMBO(c), 1); } + =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/bin/tests/ewl_theme.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- ewl_theme.c 10 Mar 2006 04:05:42 -0000 1.1 +++ ewl_theme.c 13 Mar 2006 00:19:27 -0000 1.2 @@ -236,7 +236,8 @@ misc = ewl_hseparator_new(); ewl_container_child_append(EWL_CONTAINER(vbox), misc); ewl_widget_show(misc); - +#if 0 +XXX Port this to use the model/view system misc = ewl_combo_new("Combo entry"); ewl_container_child_append(EWL_CONTAINER(vbox), misc); ewl_widget_show(misc); @@ -255,7 +256,8 @@ ewl_container_child_append(EWL_CONTAINER(misc), item); ewl_widget_show(item); } - +#endif + /* List/tree */ vbox = ewl_vbox_new(); ewl_container_child_append(EWL_CONTAINER(notebook), vbox); ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs