rimmed pushed a commit to branch master.

http://git.enlightenment.org/tools/eflete.git/commit/?id=103d613181cf8eb06f82f81a8dc0b279853d2dbf

commit 103d613181cf8eb06f82f81a8dc0b279853d2dbf
Author: Mykyta Biliavskyi <m.biliavs...@samsung.com>
Date:   Mon Jun 27 17:21:55 2016 +0300

    Popup: make unified interface for all popup windows,
    
    Change signature of function popup_want_action. Replace
    Evas_Object *content, with pointer to the function, that
    return pointer to the content object. This was necessary
    for resolve issue with elementary combobox widget usage.
    
    Rework popup window usage for new part create dialog.
    
    This is first commit, in next will be replaced popup
    usage to unified interface at other places inside Eflete.
---
 src/bin/ui/main_window.h               | 16 +++++++--
 src/bin/ui/popup.c                     | 11 ++++---
 src/bin/ui/workspace/group_navigator.c | 59 ++++++++++++++++++----------------
 3 files changed, 52 insertions(+), 34 deletions(-)

diff --git a/src/bin/ui/main_window.h b/src/bin/ui/main_window.h
index 257f571..e2fd922 100644
--- a/src/bin/ui/main_window.h
+++ b/src/bin/ui/main_window.h
@@ -112,6 +112,16 @@ typedef enum
 typedef Eina_Bool(* Popup_Validator_Func)(void *data);
 
 /**
+ * Function that return object, which is used as content
+ * inside popup window.
+ *
+ * @param data The user data
+ *
+ * @ingroup Window
+ */
+typedef Evas_Object *(* Popup_Content_Get_Func)(void *data);
+
+/**
  * The fileselector helper callback.
  *
  * @param data The user data;
@@ -308,18 +318,18 @@ project_close(void);
  *
  * @param title The Popup title;
  * @param msg The Popup message, formated text;
- * @param content The user Evas_Object seted as content to popup;
+ * @param content_get The func, that return content Evas_Object to popup;
  * @param to_focus The object what be focused after popup show;
  * @param p_btns The flags for set the popup buttons;
  * @param func The validation func, if returned EINA_FALSE popup not be closed;
- * @param data The user data for validation func.
+ * @param data The user data for validation and content_get funcutions.
  *
  * @ingroup Window
  */
 Popup_Button
 popup_want_action(const char *title,
                   const char *msg,
-                  Evas_Object *content,
+                  Popup_Content_Get_Func content_get,
                   Evas_Object *to_focus,
                   Popup_Button p_btns,
                   Popup_Validator_Func func,
diff --git a/src/bin/ui/popup.c b/src/bin/ui/popup.c
index aaad3a5..efab951 100644
--- a/src/bin/ui/popup.c
+++ b/src/bin/ui/popup.c
@@ -87,7 +87,7 @@ _btn_cb(void *data,
 Popup_Button
 popup_want_action(const char *title,
                   const char *msg,
-                  Evas_Object *content,
+                  Popup_Content_Get_Func content_get,
                   Evas_Object *to_focus,
                   Popup_Button popup_btns,
                   Popup_Validator_Func func,
@@ -97,7 +97,7 @@ popup_want_action(const char *title,
    Evas_Object *btn;
 
    /* only one content will be setted to ap.popup: or message, or used content 
*/
-   assert((msg != NULL) != (content != NULL));
+   assert((msg != NULL) != (content_get != NULL));
    validator = func;
    user_data = data;
 
@@ -108,7 +108,11 @@ popup_want_action(const char *title,
    elm_object_part_text_set(ap.popup, "title,text", title);
    elm_popup_content_text_wrap_type_set(ap.popup, ELM_WRAP_WORD);
    if (msg) elm_object_text_set(ap.popup, msg);
-   if (content) elm_object_content_set(ap.popup, content);
+   if (content_get)
+     {
+        Evas_Object *content = content_get(data);
+        elm_object_content_set(ap.popup, content);
+     }
 
    if (popup_btns & BTN_OK)
      BTN_ADD(_("Ok"), "button1", &_btn_ok)
@@ -870,7 +874,6 @@ popup_colorselector_helper(Evas_Object *follow_up,
    if (follow_up)
      {
         _helper_property_color_follow(NULL, NULL, follow_up, NULL);
-        evas_object_event_callback_add(follow_up, EVAS_CALLBACK_RESIZE, 
_helper_property_color_follow, NULL);
         evas_object_event_callback_add(follow_up, EVAS_CALLBACK_MOVE, 
_helper_property_color_follow, NULL);
      }
    else
diff --git a/src/bin/ui/workspace/group_navigator.c 
b/src/bin/ui/workspace/group_navigator.c
index 5d13f45..c5697cc 100644
--- a/src/bin/ui/workspace/group_navigator.c
+++ b/src/bin/ui/workspace/group_navigator.c
@@ -73,6 +73,7 @@ typedef struct
 
    struct {
         int copy_part, part_type;
+        Evas_Object *box;
         Evas_Object *entry_name;
         Evas_Object *spinner_value;
         Evas_Object *combobox;
@@ -917,6 +918,14 @@ _popup_add_part_ok_clicked(void *data,
    ecore_job_add(_job_popup_del, pl);
 }
 
+Eina_Bool
+_popup_add_part_validator(void *data)
+{
+   _popup_add_part_ok_clicked(data, NULL, NULL);
+   return true;
+}
+
+
 void
 group_navigator_part_add(Evas_Object *obj, Part *part)
 {
@@ -1007,29 +1016,18 @@ _combobox_item_pressed_cb(void *data __UNUSED__, 
Evas_Object *obj,
    elm_entry_cursor_end_set(obj);
 }
 
-static void
-_on_menu_add_part_clicked(void *data __UNUSED__,
-                          Evas_Object *obj,
-                          void *ei __UNUSED__)
+Evas_Object *
+_add_part_content_get(void *data)
 {
    Combobox_Item *combobox_item;
    unsigned int i = 0;
-   Part_List *pl = evas_object_data_get(obj, GROUP_NAVIGATOR_DATA);
    Eina_List *l;
    Part *part;
 
-   Eina_Stringshare *title;
+   Part_List *pl = (Part_List *)data;
    Evas_Object *box, *item;
 
-   assert(pl != NULL);
-
-   ap.popup = elm_popup_add(ap.win);
-   elm_popup_orient_set(ap.popup, ELM_POPUP_ORIENT_CENTER);
-   title = eina_stringshare_printf(_("Add New Part to Group \"%s\""), 
pl->group->name);
-   elm_object_part_text_set(ap.popup, "title,text", title);
-   eina_stringshare_del(title);
-
-   BOX_ADD(ap.popup, box, false, false);
+   BOX_ADD(ap.win, box, false, false);
    elm_box_padding_set(box, 0, 10);
 
    LAYOUT_PROP_ADD(box, _("Part name"), "popup", "1swallow")
@@ -1087,20 +1085,27 @@ _on_menu_add_part_clicked(void *data __UNUSED__,
    evas_object_smart_callback_add(pl->popup.combobox_copy, "item,selected", 
_part_selected_cb, pl);
    elm_box_pack_end(box, item);
 
-   elm_object_content_set(ap.popup, box);
-   BUTTON_ADD(box, pl->popup.btn_add, _("Add"));
-   evas_object_smart_callback_add(pl->popup.btn_add, "clicked", 
_popup_add_part_ok_clicked, pl);
-   elm_object_part_content_set(ap.popup, "button1", pl->popup.btn_add);
-   elm_object_disabled_set(pl->popup.btn_add, true);
+   pl->popup.box = box;
+   return box;
+}
 
-   BUTTON_ADD(box, pl->popup.btn_cancel, _("Cancel"));
-   evas_object_smart_callback_add(pl->popup.btn_cancel, "clicked", 
_popup_cancel_clicked, pl);
-   elm_object_part_content_set(ap.popup, "button2", pl->popup.btn_cancel);
+static void
+_on_menu_add_part_clicked(void *data __UNUSED__,
+                          Evas_Object *obj,
+                          void *ei __UNUSED__)
+{
+  Part_List *pl = evas_object_data_get(obj, GROUP_NAVIGATOR_DATA);
+   Eina_Stringshare *title;
 
-   ui_menu_items_list_disable_set(ap.menu, MENU_ITEMS_LIST_MAIN, true);
+   assert(pl != NULL);
 
-   elm_object_focus_set(pl->popup.entry_name, true);
-   evas_object_show(ap.popup);
+   title = eina_stringshare_printf(_("Add New Part to Group \"%s\""), 
pl->group->name);
+   Popup_Button button = popup_want_action(title, NULL, _add_part_content_get,
+                                           NULL, BTN_OK | BTN_CANCEL,
+                                           _popup_add_part_validator, pl);
+   if (BTN_CANCEL == button)
+     evas_object_del(pl->popup.box);
+   eina_stringshare_del(title);
 }
 
 static void
@@ -1344,7 +1349,7 @@ _on_menu_add_state_clicked(void *data __UNUSED__,
    BUTTON_ADD(ap.popup, pl->popup.btn_cancel, _("Cancel"));
    evas_object_smart_callback_add(pl->popup.btn_cancel, "clicked", 
_popup_cancel_clicked, pl);
    elm_object_part_content_set(ap.popup, "button2", pl->popup.btn_cancel);
-
+   ui_menu_items_list_disable_set(ap.menu, MENU_ITEMS_LIST_MAIN, true);
    ui_menu_items_list_disable_set(ap.menu, MENU_ITEMS_LIST_MAIN, true);
    elm_object_focus_set(pl->popup.entry_name, true);
    evas_object_show(ap.popup);

-- 


Reply via email to