Add evas_object_hide support for popup.
authorsanjeev <sanjeev@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 9 Apr 2012 04:48:09 +0000 (04:48 +0000)
committersanjeev <sanjeev@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 9 Apr 2012 04:48:09 +0000 (04:48 +0000)
Author : cnook kimcinoo@gmail.com

The evas_object_hide(popup) could not hide the popup.
So, I added callback to hide the popup, with the test
code.

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@69960 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/bin/test_popup.c
src/lib/elc_popup.c

index 54ee314..723b3f0 100644 (file)
@@ -4,6 +4,9 @@
 #include <Elementary.h>
 #ifndef ELM_LIB_QUICKLAUNCH
 
+static Evas_Object *g_popup = NULL;
+static int times = 0;
+
 static void
 _response_cb(void *data, Evas_Object *obj __UNUSED__,
              void *event_info __UNUSED__)
@@ -15,6 +18,13 @@ _response_cb(void *data, Evas_Object *obj __UNUSED__,
 }
 
 static void
+_g_popup_response_cb(void *data, Evas_Object *obj __UNUSED__,
+             void *event_info __UNUSED__)
+{
+   evas_object_hide(data);
+}
+
+static void
 _block_clicked_cb(void *data __UNUSED__, Evas_Object *obj,
                   void *event_info __UNUSED__)
 {
@@ -267,6 +277,34 @@ _popup_center_title_text_2button_restack_cb(void *data, Evas_Object *obj __UNUSE
    evas_object_show(popup);
 }
 
+static void
+_popup_center_text_1button_hide_show_cb(void *data, Evas_Object *obj __UNUSED__,
+                              void *event_info __UNUSED__)
+{
+   Evas_Object *btn;
+   char str[128];
+
+   times++;
+   if (g_popup)
+     {
+        sprintf(str, "You have checked this popup %d times.", times);
+        elm_object_text_set(g_popup, str);
+        evas_object_show(g_popup);
+        return;
+     }
+
+   g_popup = elm_popup_add(data);
+   evas_object_size_hint_weight_set(g_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   elm_object_text_set(g_popup, "Hide this popup by using the button."
+                       "When you click list item again, you can see this popup.");
+   btn = elm_button_add(g_popup);
+   elm_object_text_set(btn, "Hide");
+   elm_object_part_content_set(g_popup, "button1", btn);
+   evas_object_smart_callback_add(btn, "clicked", _g_popup_response_cb, g_popup);
+
+   evas_object_show(g_popup);
+}
+
 void
 test_popup(void *data __UNUSED__, Evas_Object *obj __UNUSED__,
            void *event_info __UNUSED__)
@@ -301,6 +339,8 @@ test_popup(void *data __UNUSED__, Evas_Object *obj __UNUSED__,
                         NULL, _popup_center_title_item_3button_cb, win);
    elm_list_item_append(list, "popup-center-title + text + 2 buttons (check restacking)", NULL, NULL,
                         _popup_center_title_text_2button_restack_cb, win);
+   elm_list_item_append(list, "popup-center-text + 1 button (check hide, show)", NULL, NULL,
+                        _popup_center_text_1button_hide_show_cb, win);
    elm_list_go(list);
    evas_object_show(list);
    evas_object_show(win);
index 74aada0..fd5c8b0 100644 (file)
@@ -100,6 +100,8 @@ static void _button_remove(Evas_Object *obj, Evas_Object *content,
                            Eina_Bool delete);
 static void _popup_show(void *data, Evas *e, Evas_Object *obj,
                         void *event_info);
+static void _popup_hide(void *data, Evas *e, Evas_Object *obj,
+                        void *event_info);
 static const char SIG_BLOCK_CLICKED[] = "block,clicked";
 static const char SIG_TIMEOUT[] = "timeout";
 static const Evas_Smart_Cb_Description _signals[] = {
@@ -1218,6 +1220,18 @@ _popup_show(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj,
    evas_object_show(wd->notify);
 }
 
+static void
+_popup_hide(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj,
+               void *event_info __UNUSED__)
+{
+   Widget_Data *wd;
+
+   wd = elm_widget_data_get(obj);
+   if (!wd) return;
+
+   evas_object_hide(wd->notify);
+}
+
 EAPI Evas_Object *
 elm_popup_add(Evas_Object *parent)
 {
@@ -1256,6 +1270,8 @@ elm_popup_add(Evas_Object *parent)
                                   _notify_resize, obj);
    evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _popup_show,
                                   NULL);
+   evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _popup_hide,
+                                  NULL);
    evas_object_event_callback_add(obj, EVAS_CALLBACK_RESTACK, _restack, NULL);
    wd->base = elm_layout_add(obj);
    evas_object_size_hint_weight_set(wd->base, EVAS_HINT_EXPAND,