seoz pushed a commit to branch master.

commit 9754dd3dff33979302753c94618c0ab532ec2101
Author: Daniel Juyung Seo <[email protected]>
Date:   Wed Jun 26 16:23:48 2013 +0900

    hoversel_example_01.c: refactoring example.
    
    Make the button text description clear. It was ambigous what will happen if 
we press the buttons and hoversel items.
    This fixes T181 issue. https://phab.enlightenment.org/T181
---
 src/examples/hoversel_example_01.c | 36 +++++++++++++++---------------------
 1 file changed, 15 insertions(+), 21 deletions(-)

diff --git a/src/examples/hoversel_example_01.c 
b/src/examples/hoversel_example_01.c
index c05d717..b990fba 100644
--- a/src/examples/hoversel_example_01.c
+++ b/src/examples/hoversel_example_01.c
@@ -4,16 +4,20 @@
 #include <Elementary.h>
 
 static void _print_items(void *data, Evas_Object *obj, void *event_info);
-static void _rm_items(void *data, Evas_Object *obj, void *event_info);
-static void _sel(void *data, Evas_Object *obj, void *event_info);
 static void _free(void *data, Evas_Object *obj, void *event_info);
 static void _add_item(void *data, Evas_Object *obj, void *event_info);
 
+static void
+_clear_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+   if (!data) return;
+   elm_hoversel_clear((Evas_Object *)data);
+}
+
 EAPI_MAIN int
 elm_main(int argc, char **argv)
 {
-   Evas_Object *win, *rect, *hoversel;
-   Elm_Object_Item *hoversel_it;
+   Evas_Object *win, *rect, *hoversel, *btn = NULL;
 
    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
 
@@ -29,21 +33,24 @@ elm_main(int argc, char **argv)
    hoversel = elm_hoversel_add(win);
    elm_hoversel_hover_parent_set(hoversel, win);
    elm_hoversel_horizontal_set(hoversel, EINA_FALSE);
-   elm_object_text_set(hoversel, "Hoversel");
+   elm_object_text_set(hoversel, "Add an item to Hoversel");
    elm_object_part_content_set(hoversel, "icon", rect);
    elm_hoversel_item_add(hoversel, "Print items", NULL, ELM_ICON_NONE,
                          _print_items, NULL);
    elm_hoversel_item_add(hoversel, "Option 2", "home", ELM_ICON_STANDARD, NULL,
                          NULL);
-   hoversel_it = elm_hoversel_item_add(hoversel, "Clear all items", "close",
-                                       ELM_ICON_STANDARD, _rm_items, NULL);
-   evas_object_smart_callback_add(hoversel, "selected", _sel, hoversel_it);
    evas_object_smart_callback_add(hoversel, "clicked", _add_item, NULL);
 
    evas_object_resize(hoversel, 180, 30);
    evas_object_move(hoversel, 10, 10);
    evas_object_show(hoversel);
 
+   btn = elm_button_add(win);
+   elm_object_text_set(btn, "Clear all Items");
+   evas_object_smart_callback_add(btn, "clicked", _clear_btn_clicked_cb, 
hoversel);
+   evas_object_resize(btn, 180, 30);
+   evas_object_move(btn, 10, 50);
+   evas_object_show(btn);
 
    elm_run();
    elm_shutdown();
@@ -64,19 +71,6 @@ _print_items(void *data, Evas_Object *obj, void *event_info)
 }
 
 static void
-_rm_items(void *data, Evas_Object *obj, void *event_info)
-{
-   elm_hoversel_clear(obj);
-}
-
-static void
-_sel(void *data, Evas_Object *obj, void *event_info)
-{
-   if (event_info != data)
-     elm_object_item_del(event_info);
-}
-
-static void
 _add_item(void *data, Evas_Object *obj, void *event_info)
 {
    static int num = 0;

-- 

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev

Reply via email to