efl_ui_popup: replace title_set to efl_text_set with efl_part
authorJinYong Park <j4939.park@samsung.com>
Tue, 24 Oct 2017 11:13:04 +0000 (20:13 +0900)
committerJaehyun Cho <jae_hyun.cho@samsung.com>
Tue, 28 Nov 2017 08:15:42 +0000 (17:15 +0900)
Summary: Replace Efl.Ui.Popup.Alert's title set method to using efl_text_set with efl_part

Test Plan: elementary_test -to efluipopupalert

Reviewers: jpeg, Jaehyun_Cho, woohyun, herb

Reviewed By: Jaehyun_Cho

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D5359

src/Makefile_Elementary.am
src/bin/elementary/test_popup.c
src/lib/elementary/efl_ui_popup_alert.c
src/lib/elementary/efl_ui_popup_alert.eo
src/lib/elementary/efl_ui_popup_alert_part.eo [new file with mode: 0644]

index f62e9f2..b660255 100644 (file)
@@ -35,6 +35,7 @@ elm_public_eolian_files = \
        lib/elementary/efl_ui_text.eo \
        lib/elementary/efl_ui_popup.eo \
        lib/elementary/efl_ui_popup_alert.eo \
+       lib/elementary/efl_ui_popup_alert_part.eo \
        lib/elementary/efl_ui_popup_alert_scroll.eo \
        lib/elementary/efl_ui_popup_alert_scroll_part.eo \
        lib/elementary/efl_ui_popup_alert_text.eo \
index 1f85961..4975a0f 100644 (file)
@@ -1136,7 +1136,7 @@ test_efl_ui_popup_alert(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, vo
 
    Evas_Object *efl_ui_popup= efl_add(EFL_UI_POPUP_ALERT_CLASS, win);
 
-   efl_ui_popup_alert_title_set(efl_ui_popup, "title");
+   efl_text_set(efl_part(efl_ui_popup, "title"), "title");
 
    evas_object_resize(efl_ui_popup, 160, 160);
    evas_object_show(efl_ui_popup);
@@ -1168,7 +1168,7 @@ test_efl_ui_popup_alert_scroll(void *data EINA_UNUSED, Evas_Object *obj EINA_UNU
 
    Evas_Object *efl_ui_popup= efl_add(EFL_UI_POPUP_ALERT_SCROLL_CLASS, win);
 
-   efl_ui_popup_alert_title_set(efl_ui_popup, "title");
+   efl_text_set(efl_part(efl_ui_popup, "title"), "title");
 
    evas_object_resize(efl_ui_popup, 160, 160);
    evas_object_show(efl_ui_popup);
@@ -1203,7 +1203,7 @@ test_efl_ui_popup_alert_text(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSE
 
    Evas_Object *efl_ui_popup= efl_add(EFL_UI_POPUP_ALERT_TEXT_CLASS, win);
 
-   efl_ui_popup_alert_title_set(efl_ui_popup, "title");
+   efl_text_set(efl_part(efl_ui_popup, "title"), "title");
 
    evas_object_resize(efl_ui_popup, 160, 160);
    evas_object_show(efl_ui_popup);
index 6c7a9a5..2b38d34 100644 (file)
@@ -6,6 +6,8 @@
 
 #include "elm_priv.h"
 #include "efl_ui_popup_alert_private.h"
+#include "efl_ui_popup_alert_part.eo.h"
+#include "elm_part_helper.h"
 
 #define MY_CLASS EFL_UI_POPUP_ALERT_CLASS
 #define MY_CLASS_NAME "Efl.Ui.Popup.Alert"
@@ -27,30 +29,61 @@ _efl_ui_popup_alert_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Popup_Alert_Data *pd
    evas_object_geometry_get(obj, NULL, NULL, &w, &h);
 }
 
-EOLIAN static void
-_efl_ui_popup_alert_title_set(Eo *obj, Efl_Ui_Popup_Alert_Data *pd, const char *text)
+static Eina_Bool
+_efl_ui_popup_alert_text_set(Eo *obj, Efl_Ui_Popup_Alert_Data *pd, const char *part, const char *label)
 {
-   if (pd->title_text)
+   if (part && !strcmp(part, "title"))
      {
-        eina_stringshare_del(pd->title_text);
-        pd->title_text = NULL;
+        if (pd->title_text)
+          {
+             eina_stringshare_del(pd->title_text);
+             pd->title_text = NULL;
+          }
+
+        pd->title_text = eina_stringshare_add(label);
+        elm_object_part_text_set(obj, "elm.text.title", label);
+        elm_layout_signal_emit(obj, "elm,title,show", "elm");
+
+        ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
+        edje_object_message_signal_process(wd->resize_obj);
+        elm_layout_sizing_eval(obj);
      }
+   else
+     efl_text_set(efl_part(efl_super(obj, MY_CLASS), part), label);
 
-   pd->title_text = eina_stringshare_add(text);
-   elm_object_part_text_set(obj, "elm.text.title", text);
-   elm_layout_signal_emit(obj, "elm,title,show", "elm");
+   return EINA_TRUE;
+}
 
-   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
-   edje_object_message_signal_process(wd->resize_obj);
-   elm_layout_sizing_eval(obj);
+const char *
+_efl_ui_popup_alert_text_get(Eo *obj EINA_UNUSED, Efl_Ui_Popup_Alert_Data *pd, const char *part)
+{
+   if (part && !strcmp(part, "title"))
+     {
+        if (pd->title_text)
+          return pd->title_text;
+
+        return NULL;
+     }
+
+   return efl_text_get(efl_part(efl_super(obj, MY_CLASS), part));
 }
 
-EOLIAN static const char *
-_efl_ui_popup_alert_title_get(Eo *obj EINA_UNUSED, Efl_Ui_Popup_Alert_Data *pd)
+static Eina_Bool
+_efl_ui_popup_alert_content_set(Eo *obj, Efl_Ui_Popup_Alert_Data *pd EINA_UNUSED, const char *part, Evas_Object *content)
 {
-   if (pd->title_text)
-    return pd->title_text;
-   return NULL;
+   return efl_content_set(efl_part(efl_super(obj, MY_CLASS), part), content);
+}
+
+Evas_Object *
+_efl_ui_popup_alert_content_get(Eo *obj, Efl_Ui_Popup_Alert_Data *pd EINA_UNUSED, const char *part)
+{
+   return efl_content_get(efl_part(efl_super(obj, MY_CLASS), part));
+}
+
+static Evas_Object *
+_efl_ui_popup_alert_content_unset(Eo *obj, Efl_Ui_Popup_Alert_Data *pd EINA_UNUSED, const char *part)
+{
+   return efl_content_unset(efl_part(efl_super(obj, MY_CLASS), part));
 }
 
 static void
@@ -211,6 +244,18 @@ _efl_ui_popup_alert_class_constructor(Efl_Class *klass)
    evas_smart_legacy_type_register(MY_CLASS_NAME, klass);
 }
 
+/* Efl.Part begin */
+
+ELM_PART_OVERRIDE(efl_ui_popup_alert, EFL_UI_POPUP_ALERT, Efl_Ui_Popup_Alert_Data)
+ELM_PART_OVERRIDE_CONTENT_SET(efl_ui_popup_alert, EFL_UI_POPUP_ALERT, Efl_Ui_Popup_Alert_Data)
+ELM_PART_OVERRIDE_CONTENT_GET(efl_ui_popup_alert, EFL_UI_POPUP_ALERT, Efl_Ui_Popup_Alert_Data)
+ELM_PART_OVERRIDE_CONTENT_UNSET(efl_ui_popup_alert, EFL_UI_POPUP_ALERT, Efl_Ui_Popup_Alert_Data)
+ELM_PART_OVERRIDE_TEXT_SET(efl_ui_popup_alert, EFL_UI_POPUP_ALERT, Efl_Ui_Popup_Alert_Data)
+ELM_PART_OVERRIDE_TEXT_GET(efl_ui_popup_alert, EFL_UI_POPUP_ALERT, Efl_Ui_Popup_Alert_Data)
+#include "efl_ui_popup_alert_part.eo.c"
+
+/* Efl.Part end */
+
 #define EFL_UI_POPUP_ALERT_EXTRA_OPS \
    EFL_CANVAS_GROUP_ADD_DEL_OPS(efl_ui_popup_alert), \
    ELM_LAYOUT_SIZING_EVAL_OPS(efl_ui_popup_alert)
index 8ac3799..27c9cc3 100644 (file)
@@ -8,17 +8,6 @@ enum Efl.Ui.Popup.Alert.Button {
 class Efl.Ui.Popup.Alert(Efl.Ui.Popup)
 {
    methods {
-      @property title {
-         set {
-            [[Set the title of popup.]]
-         }
-         get {
-            [[Get the title of popup.]]
-         }
-         values {
-            text: string;
-         }
-      }
       @property button {
          set {
             [[Set popup buttons.]]
@@ -33,6 +22,7 @@ class Efl.Ui.Popup.Alert(Efl.Ui.Popup)
    }
    implements {
       class.constructor;
+      Efl.Part.part;
    }
    events {
       clicked;
diff --git a/src/lib/elementary/efl_ui_popup_alert_part.eo b/src/lib/elementary/efl_ui_popup_alert_part.eo
new file mode 100644 (file)
index 0000000..3fc255d
--- /dev/null
@@ -0,0 +1,10 @@
+class Efl.Ui.Popup.Alert.Part (Efl.Ui.Layout.Part_Content, Efl.Ui.Layout.Part_Text)
+{
+   [[Efl UI Popup Alert internal part class]]
+   data: null;
+   implements {
+      Efl.Container.content { get; set; }
+      Efl.Container.content_unset;
+      Efl.Text.text { get; set; }
+   }
+}