yakov pushed a commit to branch master.

http://git.enlightenment.org/tools/erigo.git/commit/?id=f7ad42c135c6b1d5ad1cf5854c02cd79ab076570

commit f7ad42c135c6b1d5ad1cf5854c02cd79ab076570
Author: Yakov Goldberg <yako...@samsung.com>
Date:   Sun Apr 12 18:44:27 2015 +0300

    Add "Add resource..." item into hoversel in property view.
    
    If there are no resources, empty hoversel is shown for property that
    requires resource.
    Add "Add resource..." item in such hoversel to open Resource Manager.
---
 NEWS                            |  7 +++++++
 src/bin/egui_gui/props_helper.c | 24 +++++++++++++++---------
 src/bin/egui_gui/props_helper.h |  1 +
 src/bin/egui_gui/propview.c     | 22 +++++++++++++++++++++-
 4 files changed, 44 insertions(+), 10 deletions(-)

diff --git a/NEWS b/NEWS
index 6395761..fe76a34 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,13 @@ Erigo 1.0.0
 Full manuals, examples and video lessons can be found here:
 https://phab.enlightenment.org/w/projects/gui_builder/
 
+
+Changes since 1.0.0
+-------------------
+Fixes:
+  * Don't show empty hoversel in Property view when there is no resources.
+    Add item to open Resource Manager.
+
 Changes since 0.9.1
 -------------------
 Features:
diff --git a/src/bin/egui_gui/props_helper.c b/src/bin/egui_gui/props_helper.c
index 12cdb81..53a6f7f 100644
--- a/src/bin/egui_gui/props_helper.c
+++ b/src/bin/egui_gui/props_helper.c
@@ -408,24 +408,32 @@ props_hoversel_object_ops_add(Eo *box, Eo *hover_parent, 
const char *default_val
 Eo *
 props_hoversel_resources_add(Eo *box, Eo *hoversel, Eo *hover_parent, const 
char *default_val, const Gui_Context *ctx, Gui_Resource_Type type)
 {
+   const Eina_List *itr, *items;
+   Elm_Object_Item *it;
+   Eina_Bool add_empty = EINA_TRUE, add_resource_item = EINA_TRUE;
+   const Eina_List *res_lst = gui_context_resource_list_get(ctx, type);
+
    if (!hoversel)
      {
         hoversel = eo_add(ELM_HOVERSEL_CLASS, box);
         eo_do(hoversel, elm_obj_hoversel_hover_parent_set(hover_parent));
      }
-   /* Check if empty string was added already.
-    * If not - add it. */
-   const Eina_List *itr;
-   Elm_Object_Item *it;
-   Eina_Bool add_empty = EINA_TRUE;
-   const Eina_List *items;
+
+   /* This function is called for each type of resource.
+    * So empty line is added during first call, thus we need to check if they 
were already added. */
    EINA_LIST_FOREACH(eo_do_ret(hoversel, items, elm_obj_hoversel_items_get()), 
itr, it)
      {
         const char *str = elm_object_item_text_get(it);
         if (str && !strcmp(str, PROP_HOVERSEL_NONE_VALUE))
           add_empty = EINA_FALSE;
+        if (str && !strcmp(str, PROP_HOVERSEL_ADD_RESOURCE_VALUE))
+          add_resource_item = EINA_FALSE;
      }
-   if (add_empty)
+   if (add_resource_item)
+     eo_do(hoversel, 
elm_obj_hoversel_item_add(PROP_HOVERSEL_ADD_RESOURCE_VALUE, NULL, 
ELM_ICON_NONE, NULL, NULL));
+
+   /* Don't add empty item if there is no resources */
+   if (res_lst && add_empty)
      elm_hoversel_item_add(hoversel, PROP_HOVERSEL_NONE_VALUE, NULL, 
ELM_ICON_NONE, NULL, NULL);
 
    if (!default_val)
@@ -434,9 +442,7 @@ props_hoversel_resources_add(Eo *box, Eo *hoversel, Eo 
*hover_parent, const char
      }
    elm_object_text_set(hoversel, default_val);
 
-   const Eina_List *res_lst;
    Eid *res_id;
-   res_lst = gui_context_resource_list_get(ctx, type);
    EINA_LIST_FOREACH(res_lst, itr, res_id)
      {
         const Gui_Resource *res = resource_get_from_id(res_id);
diff --git a/src/bin/egui_gui/props_helper.h b/src/bin/egui_gui/props_helper.h
index f3546f1..29b4222 100644
--- a/src/bin/egui_gui/props_helper.h
+++ b/src/bin/egui_gui/props_helper.h
@@ -6,6 +6,7 @@
 #include "egui_layout.h"
 
 #define PROP_HOVERSEL_NONE_VALUE "                           "
+#define PROP_HOVERSEL_ADD_RESOURCE_VALUE "Add resource..."
 #define DEFAULT_RESOURCE "DEFAULT"
 
 /* pass Gui_Widget or Item_Container_Item */
diff --git a/src/bin/egui_gui/propview.c b/src/bin/egui_gui/propview.c
index 943bd14..2edad1f 100644
--- a/src/bin/egui_gui/propview.c
+++ b/src/bin/egui_gui/propview.c
@@ -5,6 +5,7 @@
 #include "props_helper.h"
 #include "egui_logic_private.h"
 #include "propview.h"
+#include "rmview.h"
 
 #include "elm_widget_container.h"
 
@@ -58,6 +59,25 @@ _default_hover_selected_cb(void *data, Eo *obj EINA_UNUSED, 
const Eo_Event_Descr
    return EO_CALLBACK_CONTINUE;
 }
 
+/* This will be called when hoversel item is selected.
+ * If "Add resource..." item was selected, oper Resource Manager*/
+static Eina_Bool
+_hover_selected_cb(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description 
*desc EINA_UNUSED, void *event_info)
+{
+   const char *choosen_value = elm_object_item_part_text_get(event_info, NULL);
+   if (!strcmp(choosen_value, PROP_HOVERSEL_ADD_RESOURCE_VALUE))
+     {
+        const Egui_Layout_Widgets *g_main_wdgs = egui_layout_gui_get();
+        rm_win_set(egui_layout_rm_win_create(g_main_wdgs->main_win->main_win));
+        rm_win_post_configure();
+     }
+   else
+     {
+        _view_cbs->property_update_cb_func(NULL, obj, NULL, event_info);
+     }
+   return EO_CALLBACK_CONTINUE;
+}
+
 static Evas_Object *
 _property_item_content_get(It_Data *it_data)
 {
@@ -102,7 +122,7 @@ _property_item_content_get(It_Data *it_data)
              if (eo_isa(obj, ELM_HOVERSEL_CLASS))
                {
                   /* pass box as a data, in order to change its color then 
value changed from default. */
-                  eo_do(obj, 
eo_event_callback_add(EVAS_SELECTABLE_INTERFACE_EVENT_SELECTED, 
_view_cbs->property_update_cb_func, NULL));
+                  eo_do(obj, 
eo_event_callback_add(EVAS_SELECTABLE_INTERFACE_EVENT_SELECTED, 
_hover_selected_cb, NULL));
                }
              else if (eo_isa(obj, ELM_CHECK_CLASS))
                {

-- 


Reply via email to