yakov pushed a commit to branch master.

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

commit 81fa947a38a46395176188fc4c9a55b16c75c373
Author: Yakov Goldberg <yako...@samsung.com>
Date:   Tue May 5 09:18:33 2015 +0300

    Add theme support for separate widgets
    
    - theme can be added as a project resource...
    - ...and apply theme to separate widget
    - add popup error messages when adding resource
---
 data/config/black_list.json       |   2 +-
 src/bin/egui_gui/CMakeLists.txt   |   4 +-
 src/bin/egui_gui/editor.c         |  19 +++
 src/bin/egui_gui/egui_layout.json |  49 +++++-
 src/bin/egui_gui/props_helper.c   |  61 +++++++-
 src/bin/egui_gui/rmview.c         | 303 ++++++++++++++++++++++++--------------
 src/bin/egui_gui/rmview.h         |   1 +
 src/bin/main.c                    |  11 +-
 src/lib/database.c                |   2 +
 src/lib/database.h                |   1 +
 src/lib/ffi_abstraction.c         |  39 +++++
 src/lib/generator.c               |  84 ++++++++++-
 src/lib/gui_parser.c              |  46 ++++--
 src/lib/gui_widget.c              |  40 ++++-
 src/lib/gui_widget.h              |   7 +-
 src/lib/json_generator.c          |   2 +
 src/lib/simulator.c               |  19 ++-
 17 files changed, 531 insertions(+), 159 deletions(-)

diff --git a/data/config/black_list.json b/data/config/black_list.json
index 7238272..27a3440 100644
--- a/data/config/black_list.json
+++ b/data/config/black_list.json
@@ -25,7 +25,7 @@
    "Evas.Object":["size_hint_display_mode", "map", "render_op", 
"pointer_mode", "key_grab", "key_ungrab"],
    "Elm.Hoversel":["item_add"],
    "Evas.Image":["orient", "filter_source", "scene", "data_copy", "mmap", 
"pixels_get_callback", "colorspace", "scale_hint", "native_surface", 
"border_center_fill", "fill_spread", "video_surface_caps", "video_surface", 
"content_hint", "pixels_import", "data_convert", "data_set"],
-   
"Elm.Widget":["newest_focus_order_get","cursor_add","focus_next_object_get", 
"focus_next_object_set", 
"focus_highlight_geometry_get","activate","event","event_callback_add","cursor_del","event_callback_del","focus_cycle","focus_direction","event_propagate","signal_callback_add","focus_list_direction_get","tooltip_del","focus_next_get","focus_next","focus_list_next_get","focus_direction_get","signal_callback_del","tooltip_add","theme","focus_custom_chain","display_mode","on_show_region
 [...]
+   
"Elm.Widget":["newest_focus_order_get","cursor_add","focus_next_object_get", 
"focus_next_object_set", 
"focus_highlight_geometry_get","activate","event","event_callback_add","cursor_del","event_callback_del","focus_cycle","focus_direction","event_propagate","signal_callback_add","focus_list_direction_get","tooltip_del","focus_next_get","focus_next","focus_list_next_get","focus_direction_get","signal_callback_del","tooltip_add","focus_custom_chain","display_mode","on_show_region_hook","
 [...]
    "Elm.Entry": 
["context_menu_item_add","markup_filter_prepend","cnp_mode","input_panel_language","autocapital_type","file","input_hint","input_panel_layout","input_panel_return_key_type","line_wrap","input_panel_imdata_get","markup_filter_remove","item_provider_append","markup_filter_append","markup_filter_remove","markup_filter_append","item_provider_append","item_provider_prepend","item_provider_remove"],
    "Elm.Image":["orient","mmap","memfile"],
    "Elm.Label":["slide_mode", "line_wrap"],
diff --git a/src/bin/egui_gui/CMakeLists.txt b/src/bin/egui_gui/CMakeLists.txt
index 83035ad..3a6e6d8 100644
--- a/src/bin/egui_gui/CMakeLists.txt
+++ b/src/bin/egui_gui/CMakeLists.txt
@@ -20,10 +20,12 @@ if (${EGUI_IS_RELEASE})
    set(PACKAGE_DATA_DIR_DEFINITION 
PACKAGE_DATA_DIR="${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME_LOWER}")
    set(PACKAGE_IMAGES_DIR_DEFINITION 
EGUI_LAYOUT_IMAGES_PATH="${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME_LOWER}/images")
    set(PACKAGE_EDJE_DIR_DEFINITION 
EGUI_LAYOUT_EDJE_PATH="${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME_LOWER}/layouts")
+   set(PACKAGE_THEME_DIR_DEFINITION 
EGUI_LAYOUT_THEME_PATH="${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME_LOWER}/themes")
 elseif (NOT ${EGUI_IS_RELEASE})
    set(PACKAGE_DATA_DIR_DEFINITION PACKAGE_DATA_DIR="${CMAKE_BINARY_DIR}/data")
    set(PACKAGE_IMAGES_DIR_DEFINITION 
EGUI_LAYOUT_IMAGES_PATH="${CMAKE_BINARY_DIR}/data/images")
    set(PACKAGE_EDJE_DIR_DEFINITION 
EGUI_LAYOUT_EDJE_PATH="${CMAKE_BINARY_DIR}/data/layouts")
+   set(PACKAGE_THEME_DIR_DEFINITION 
EGUI_LAYOUT_THEME_PATH="${CMAKE_BINARY_DIR}/data/themes")
 endif(${EGUI_IS_RELEASE})
 
 #add -DGUI_MODE to build gui executable
@@ -78,7 +80,7 @@ add_executable(${TARGET}
 add_dependencies(${TARGET} erigo_cmd)
 
 set_property(TARGET ${TARGET}
-   PROPERTY COMPILE_DEFINITIONS ${PACKAGE_DATA_DIR_DEFINITION} 
${PACKAGE_IMAGES_DIR_DEFINITION} ${PACKAGE_EDJE_DIR_DEFINITION})
+   PROPERTY COMPILE_DEFINITIONS ${PACKAGE_DATA_DIR_DEFINITION} 
${PACKAGE_IMAGES_DIR_DEFINITION} ${PACKAGE_EDJE_DIR_DEFINITION} 
${PACKAGE_THEME_DIR_DEFINITION})
 
 target_link_libraries (${TARGET}
    guiparser
diff --git a/src/bin/egui_gui/editor.c b/src/bin/egui_gui/editor.c
index b0085b6..2a64cfe 100644
--- a/src/bin/egui_gui/editor.c
+++ b/src/bin/egui_gui/editor.c
@@ -3445,6 +3445,25 @@ _prop_update_from_propview(void *data EINA_UNUSED, Eo 
*obj, const Eo_Event_Descr
                }
              reload_win = EINA_TRUE;
           }
+        else if (type == GUI_TYPE_THEME)
+          {
+             Eid *old_eid = EID_ID_GET(val);
+             if (old_eid) observer_del(old_eid, _wdg_update, (void *)wdg);
+             if (!strcmp(new_enum_value, PROP_HOVERSEL_NONE_VALUE))
+               {
+                  gui_value_name_id_set(val, type, 0);
+               }
+             else
+               {
+                  /* Look for new value in system themes, and after it in 
resources. */
+                  Eid *new_id = 
gui_context_eid_get_by_name(global_context_get(), new_enum_value);
+                  if (!new_id)
+                    new_id = gui_context_eid_get_by_name(ctx, new_enum_value);
+                  observer_add(new_id, _wdg_update, (void *)wdg);
+                  gui_value_name_id_set(val, type, new_id);
+               }
+             reload_win = EINA_TRUE;
+          }
         else
           {
              ERR("Type '%s' is not handled in HOVERSEL", 
db_gui_type_name_get(type));
diff --git a/src/bin/egui_gui/egui_layout.json 
b/src/bin/egui_gui/egui_layout.json
index b718460..7755f14 100644
--- a/src/bin/egui_gui/egui_layout.json
+++ b/src/bin/egui_gui/egui_layout.json
@@ -3,8 +3,7 @@
   "Settings":
   {
     "project":"egui_layout",
-    "start_points":["main_win"],
-    "edit_theme":"detourious-elm"
+    "start_points":["main_win"]
   },
   "Resources":
   {
@@ -40,7 +39,8 @@
       "_settingsview_toolbar_clicked":"_settingsview_toolbar_clicked",
       "_custom_theme_add_button_clicked":"_custom_theme_add_button_clicked",
       "_custom_theme_del_button_clicked":"_custom_theme_del_button_clicked",
-      "_theme_selector_hover_selected_cb":"_theme_selector_hover_selected_cb"
+      "_theme_selector_hover_selected_cb":"_theme_selector_hover_selected_cb",
+      "_rmview_toolbar_clicked":"_rmview_toolbar_clicked"
     },
     "Edjes":
     {
@@ -439,6 +439,49 @@
         "Evas.Object.size_hint_weight":[1, 0],
         "Evas.Object.size_hint_align":[-1, 0],
         "Efl.Gfx.Base.visible":[true]
+      },
+      "Items":
+      {
+        "rm_toolbar_it0":
+        {
+          "type":"regular",
+          "public":true,
+          "icon":"emblem-photos",
+          "label":"Images",
+          "callback":"_rmview_toolbar_clicked"
+        },
+        "rm_toolbar_it1":
+        {
+          "type":"regular",
+          "public":true,
+          "icon":"emblem-photos",
+          "label":"Edjes",
+          "callback":"_rmview_toolbar_clicked"
+        },
+        "rm_toolbar_it2":
+        {
+          "type":"regular",
+          "public":true,
+          "icon":"emblem-photos",
+          "label":"Themes",
+          "callback":"_rmview_toolbar_clicked"
+        },
+        "rm_toolbar_it3":
+        {
+          "type":"regular",
+          "public":true,
+          "icon":"call-start",
+          "label":"Callbacks",
+          "callback":"_rmview_toolbar_clicked"
+        },
+        "rm_toolbar_it4":
+        {
+          "type":"regular",
+          "public":true,
+          "icon":"format-text-bold",
+          "label":"Strings",
+          "callback":"_rmview_toolbar_clicked"
+        }
       }
     },
     "rm_sc":
diff --git a/src/bin/egui_gui/props_helper.c b/src/bin/egui_gui/props_helper.c
index 53a6f7f..f69b6ca 100644
--- a/src/bin/egui_gui/props_helper.c
+++ b/src/bin/egui_gui/props_helper.c
@@ -115,6 +115,26 @@ _prop_field_update(const Gui_Widget_Property *prop, Eo 
*item_box, It_Data *it_da
                    eo_do(o, elm_obj_widget_part_text_set(NULL, default_str));
                    break;
                 }
+           case GUI_TYPE_THEME:
+                {
+                   eo_do(o, elm_obj_hoversel_clear());
+                   props_hoversel_resources_add(NULL, o, NULL, NULL, 
wdg_context_get(it_data->wdg), RESOURCE_THEME);
+
+                   Eid *eid = EID_ID_GET(prop_value_nth_get(prop, i));
+                   const char *default_str = PROP_HOVERSEL_NONE_VALUE;
+                   if (IS_ID_VALID(eid))
+                     {
+                        default_str = eid_name_get(eid);
+                     }
+                   /* Eid == DUMMY_ID, means that value was fetched by 
eo_do(_get()),
+                    * so set DEFAULT str. */
+                   else if (eid == DUMMY_ID)
+                     {
+                        default_str = DEFAULT_RESOURCE;
+                     }
+                   eo_do(o, elm_obj_widget_part_text_set(NULL, default_str));
+                   break;
+                }
            case GUI_TYPE_OBJECT:
                 {
                    eo_do(o, elm_obj_hoversel_clear());
@@ -408,10 +428,9 @@ 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);
+   const Eina_List *res_lst = gui_context_resource_list_get(ctx, type), *itr, 
*items;
 
    if (!hoversel)
      {
@@ -434,7 +453,7 @@ props_hoversel_resources_add(Eo *box, Eo *hoversel, Eo 
*hover_parent, const char
 
    /* 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);
+     eo_do(hoversel, elm_obj_hoversel_item_add(PROP_HOVERSEL_NONE_VALUE, NULL, 
ELM_ICON_NONE, NULL, NULL));
 
    if (!default_val)
      {
@@ -443,10 +462,21 @@ props_hoversel_resources_add(Eo *box, Eo *hoversel, Eo 
*hover_parent, const char
    elm_object_text_set(hoversel, default_val);
 
    Eid *res_id;
+   if (type == RESOURCE_THEME)
+     {
+        /* Add system themes which are in global context. */
+        const Eina_List *th_lst = 
gui_context_resource_list_get(global_context_get(), type);
+        EINA_LIST_FOREACH(th_lst, itr, res_id)
+          {
+             const Gui_Resource *res = resource_get_from_id(res_id);
+             eo_do(hoversel, elm_obj_hoversel_item_add(resource_name_get(res), 
NULL, ELM_ICON_NONE, NULL, NULL));
+          }
+     }
+
    EINA_LIST_FOREACH(res_lst, itr, res_id)
      {
         const Gui_Resource *res = resource_get_from_id(res_id);
-        elm_hoversel_item_add(hoversel, resource_name_get(res), NULL, 
ELM_ICON_NONE, NULL, NULL);
+        eo_do(hoversel, elm_obj_hoversel_item_add(resource_name_get(res), 
NULL, ELM_ICON_NONE, NULL, NULL));
      }
 
    eo_do(hoversel, evas_obj_size_hint_weight_set(0.0, 0.0));
@@ -560,6 +590,29 @@ props_value_add(Eo *box, const Gui_Widget *wdg, const 
Gui_Value *value, const Op
               props_hoversel_resources_add(NULL, new_obj, NULL, default_str, 
wdg_context_get(wdg), RESOURCE_EDJE);
               break;
            }
+      case GUI_TYPE_THEME:
+           {
+              const char *default_str = PROP_HOVERSEL_NONE_VALUE;
+              if (value)
+                {
+                   Eid *eid = EID_ID_GET(value);
+                   if (IS_ID_VALID(eid))
+                     {
+                        default_str = eid_name_get(eid);
+                        if (!default_str)
+                          ERR("Looks like resource image was deleted. Handle 
this.");
+                     }
+                   /* Eid == DUMMY_ID, means that value was fetched by 
eo_do(_get()),
+                    * so set DEFAULT str. */
+                   else if (eid == DUMMY_ID)
+                     {
+                        default_str = DEFAULT_RESOURCE;
+                     }
+                }
+
+              new_obj = props_hoversel_resources_add(box, NULL, 
elm_widget_top_get(box), default_str, wdg_context_get(wdg), RESOURCE_THEME);
+              break;
+           }
       case GUI_TYPE_OBJECT_ITEM:
          /* FIXME: add handler for calback's data if needed*/
       case GUI_TYPE_VOID:
diff --git a/src/bin/egui_gui/rmview.c b/src/bin/egui_gui/rmview.c
index f34de00..e12a175 100644
--- a/src/bin/egui_gui/rmview.c
+++ b/src/bin/egui_gui/rmview.c
@@ -4,6 +4,7 @@
 #include "gui_widget.h"
 #include "egui_logic_private.h"
 #include "rmview.h"
+#include "popup.h"
 #include "prop_layout.h"
 
 #include "elm_widget.h"
@@ -174,35 +175,45 @@ _res_changed(void *data EINA_UNUSED, Eo *obj, const 
Eo_Event_Description *desc E
       case 1:
            {
               Gui_Resource_Type res_type = 
resource_type_get(f_data->it_data->res);
-              if (res_type == RESOURCE_IMAGE || res_type == RESOURCE_EDJE)
+              switch (res_type)
                 {
-                   entry_field = f_data->it_data->en2;
-                   eo_do(entry_field, str = 
elm_interface_fileselector_path_get());
-                   res_str = resource_value_get(f_data->it_data->res);
-                   /* Set bit, in order to know if change needed */
-                   if (strcmp(str, res_str))
-                     {
-                        f_data->it_data->changed |= (1 << 1);
-                     }
-                   else
-                     {
-                        f_data->it_data->changed &= ~(1 << 1);
-                     }
-                }
-              else
-                {
-                   entry_field = f_data->it_data->en2;
-                   eo_do(entry_field, str = 
elm_obj_widget_part_text_get(NULL));
-                   res_str = resource_value_get(f_data->it_data->res);
-                   /* Set bit, in order to know if change needed */
-                   if (strcmp(str, res_str))
-                     {
-                        f_data->it_data->changed |= (1 << 1);
-                     }
-                   else
-                     {
-                        f_data->it_data->changed &= ~(1 << 1);
-                     }
+                 case RESOURCE_IMAGE:
+                 case RESOURCE_THEME:
+                 case RESOURCE_EDJE:
+                      {
+                         entry_field = f_data->it_data->en2;
+                         eo_do(entry_field, str = 
elm_interface_fileselector_path_get());
+                         res_str = resource_value_get(f_data->it_data->res);
+                         /* Set bit, in order to know if change needed */
+                         if (strcmp(str, res_str))
+                           {
+                              f_data->it_data->changed |= (1 << 1);
+                           }
+                         else
+                           {
+                              f_data->it_data->changed &= ~(1 << 1);
+                           }
+                         break;
+                      }
+                 case RESOURCE_EO_CALLBACK:
+                 case RESOURCE_STRING:
+                      {
+                         entry_field = f_data->it_data->en2;
+                         eo_do(entry_field, str = 
elm_obj_widget_part_text_get(NULL));
+                         res_str = resource_value_get(f_data->it_data->res);
+                         /* Set bit, in order to know if change needed */
+                         if (strcmp(str, res_str))
+                           {
+                              f_data->it_data->changed |= (1 << 1);
+                           }
+                         else
+                           {
+                              f_data->it_data->changed &= ~(1 << 1);
+                           }
+                         break;
+                      }
+                 default:
+                    ERR("switch - default: %d", res_type);
                 }
               break;
            }
@@ -290,47 +301,56 @@ _bt_save_clicked(void *data EINA_UNUSED, Eo *obj, const 
Eo_Event_Description *de
           }
      }
 
-   /* For IMAGE take data from fileselector. */
-   if (res_type == RESOURCE_IMAGE)
+   switch (res_type)
      {
-        eo_do(f_data->it_data->en2, str = 
elm_interface_fileselector_path_get());
-        if (strlen(str))
-          {
-             resource_value_set(res, str);
-          }
-        else
-          {
-             eo_do(f_data->it_data->en2, 
elm_interface_fileselector_path_set(resource_value_get(res)));
-          }
-        const Gui_Widget *wdg  = gui_context_data_get(ctx, SELECTED_WDG);
-        proplayout_build(wdg);
-     }
+        /* For IMAGE and THEME take data from fileselector. */
+      case RESOURCE_IMAGE:
+      case RESOURCE_THEME:
+           {
+              eo_do(f_data->it_data->en2, str = 
elm_interface_fileselector_path_get());
+              if (strlen(str))
+                {
+                   resource_value_set(res, str);
+                }
+              else
+                {
+                   eo_do(f_data->it_data->en2, 
elm_interface_fileselector_path_set(resource_value_get(res)));
+                }
+              const Gui_Widget *wdg  = gui_context_data_get(ctx, SELECTED_WDG);
+              proplayout_build(wdg);
+              break;
+           }
    /* For EDJE take data from fileselector. */
-   else if (res_type == RESOURCE_EDJE)
-     {
-        eo_do(f_data->it_data->en2, str = 
elm_interface_fileselector_path_get());
-        if (strlen(str))
-          {
-             resource_edj_path_set(res, str);
-          }
-        else
-          {
-             eo_do(f_data->it_data->en2, 
elm_interface_fileselector_path_set(resource_edj_path_get(res)));
-          }
-        eo_do(f_data->it_data->en3, str = 
elm_interface_fileselector_path_get());
-        resource_edc_path_set(res, str);
-        const Gui_Widget *wdg  = gui_context_data_get(ctx, SELECTED_WDG);
-        proplayout_build(wdg);
-        observers_invoke(resource_eid_get(res));
-     }
-   /* For CALLBACKS and STRINGS. */
-   else
-     {
-        eo_do(f_data->it_data->en2, str = elm_obj_widget_part_text_get(NULL));
-        if (strlen(str))
-          {
-             resource_value_set(res, str);
-          }
+      case RESOURCE_EDJE:
+           {
+              eo_do(f_data->it_data->en2, str = 
elm_interface_fileselector_path_get());
+              if (strlen(str))
+                {
+                   resource_edj_path_set(res, str);
+                }
+              else
+                {
+                   eo_do(f_data->it_data->en2, 
elm_interface_fileselector_path_set(resource_edj_path_get(res)));
+                }
+              eo_do(f_data->it_data->en3, str = 
elm_interface_fileselector_path_get());
+              resource_edc_path_set(res, str);
+              const Gui_Widget *wdg  = gui_context_data_get(ctx, SELECTED_WDG);
+              proplayout_build(wdg);
+              observers_invoke(resource_eid_get(res));
+              break;
+           }
+      case RESOURCE_EO_CALLBACK:
+      case RESOURCE_STRING:
+           {
+              eo_do(f_data->it_data->en2, str = 
elm_obj_widget_part_text_get(NULL));
+              if (strlen(str))
+                {
+                   resource_value_set(res, str);
+                }
+              break;
+           }
+      default:
+         ERR("switch - default: %d", res_type);
      }
 
    if (status)
@@ -384,6 +404,14 @@ _rmview_build(Rmview_Resource_Type type)
               type_end = RESOURCE_EDJE + 1;
               break;
            }
+      case RMVIEW_THEME:
+           {
+              header1 = "Alias";
+              header2 = "Theme path";
+              type_start = RESOURCE_THEME;
+              type_end = RESOURCE_THEME + 1;
+              break;
+           }
       case RMVIEW_CALLBACK:
            {
               header1 = "Alias";
@@ -435,7 +463,7 @@ _rmview_build(Rmview_Resource_Type type)
              Rmview_Item_Data *it_data = calloc(1, sizeof(Rmview_Item_Data));
              it_data->res = (Gui_Resource *)res;
 
-             en = _rmview_entry_add(g_rm_win->rm_table,res_name);
+             en = _rmview_entry_add(g_rm_win->rm_table, res_name);
              elm_object_tooltip_text_set(en, "Alias name");
              it_data->en1 = en;
              eo_do(g_rm_win->rm_table, elm_obj_table_pack(en, table_col++, 
table_line, 1, 1));
@@ -472,6 +500,20 @@ _rmview_build(Rmview_Resource_Type type)
                         eo_do(en, 
eo_event_callback_add(ELM_FILESELECTOR_ENTRY_EVENT_CHANGED, _res_changed, 
NULL));
                         break;
                      }
+                  /* Add field (fileselector entry) specific to THEME */
+                case RESOURCE_THEME:
+                     {
+                        en = _rmview_fs_entry_add(g_rm_win->rm_table, "...");
+                        elm_object_tooltip_text_set(en, "Theme path");
+                        eo_do(en, elm_interface_fileselector_path_set(value));
+
+                        it_data->en2 = en;
+                        eo_do(g_rm_win->rm_table, elm_obj_table_pack(en, 
table_col++, table_line, 1, 1));
+                        data = RMVIEW_FIELD_DATA_BUILD(1, it_data);
+                        eo_do(en, eo_key_data_set(_STR_RMVIEW, data, 
_field_data_free));
+                        eo_do(en, 
eo_event_callback_add(ELM_FILESELECTOR_ENTRY_EVENT_CHANGED, _res_changed, 
NULL));
+                        break;
+                     }
                   /* Add field (double entry) specific to EDJE */
                 case RESOURCE_EDJE:
                      {
@@ -575,6 +617,7 @@ _rmview_build(Rmview_Resource_Type type)
         switch (_rmview_toolbar_selected_type )
           {
            case RMVIEW_IMAGE:
+           case RMVIEW_THEME:
                 {
                    eo_do(g_rm_win->rm_image_fileselector, 
efl_gfx_visible_set(EINA_TRUE));
                    eo_do(g_rm_win->rm_buttons_box, 
elm_obj_box_pack_end(g_rm_win->rm_image_fileselector));
@@ -619,7 +662,7 @@ _rm_win_request_delete(void *data EINA_UNUSED, Eo *obj 
EINA_UNUSED, const Eo_Eve
 }
 
 /* Callback called, when toolbar item is clicked */
-static void
+void
 _rmview_toolbar_clicked(void *data, Evas_Object *obj EINA_UNUSED, void 
*event_info EINA_UNUSED)
 {
    Rmview_Resource_Type type = (int) (intptr_t) data;
@@ -643,9 +686,19 @@ _rm_add_button_clicked(void *data EINA_UNUSED, Eo *obj 
EINA_UNUSED, const Eo_Eve
    if (!strlen(alias_str))
      return EO_CALLBACK_CONTINUE;
 
+   char _error_message[200] = {'\0'};
    if (gui_context_eid_get_by_name(ctx, alias_str))
      {
-        ERR("Resource \"%s\" already exists", alias_str);
+        sprintf(_error_message, "Resource \"%s\" already exists", alias_str);
+     }
+   else if (gui_context_eid_get_by_name(global_context_get(), alias_str))
+     {
+        sprintf(_error_message, "Resource \"%s\" matches system resource's 
name", alias_str);
+     }
+
+   if (_error_message[0])
+     {
+        popup_show(g_rm_win->rm_win, "Resource adding error", _error_message, 
POPUP_OK_BUTTON, NULL, NULL);
         return EO_CALLBACK_CONTINUE;
      }
 
@@ -656,6 +709,11 @@ _rm_add_button_clicked(void *data EINA_UNUSED, Eo *obj 
EINA_UNUSED, const Eo_Eve
               res_type = RESOURCE_IMAGE;
               break;
            }
+      case RMVIEW_THEME:
+           {
+              res_type = RESOURCE_THEME;
+              break;
+           }
       case RMVIEW_STRING:
            {
               res_type = RESOURCE_STRING;
@@ -677,26 +735,35 @@ _rm_add_button_clicked(void *data EINA_UNUSED, Eo *obj 
EINA_UNUSED, const Eo_Eve
            }
      }
 
-   /* For CALLBACKS and STRINGS: check that value str is not empty. */
-   if ((res_type != RESOURCE_IMAGE) && (res_type != RESOURCE_EDJE))
-     {
-        eo_do(g_rm_win->rm_value_entry, value_str = 
elm_obj_widget_part_text_get(NULL));
-        if (!strlen(value_str))
-          return EO_CALLBACK_CONTINUE;
-     }
-   /* For IMAGES: check that path is not empty. */
-   else if (res_type == RESOURCE_IMAGE)
+   switch (res_type)
      {
-        eo_do(g_rm_win->rm_image_fileselector, value_str = 
elm_interface_fileselector_path_get());
-        if (!strlen(value_str))
-          return EO_CALLBACK_CONTINUE;
-     }
-   /* For EDJES: check that edj path is not empty. */
-   else if (res_type == RESOURCE_EDJE)
-     {
-        eo_do(g_rm_win->rm_edje_fs_edj, value_str = 
elm_interface_fileselector_path_get());
-        if (!strlen(value_str))
-          return EO_CALLBACK_CONTINUE;
+        /* For IMAGES and THEMES: check that path is not empty. */
+      case RESOURCE_IMAGE:
+      case RESOURCE_THEME:
+           {
+              eo_do(g_rm_win->rm_image_fileselector, value_str = 
elm_interface_fileselector_path_get());
+              if (!strlen(value_str))
+                return EO_CALLBACK_CONTINUE;
+              break;
+           }
+      case RESOURCE_EDJE:
+           {
+              eo_do(g_rm_win->rm_edje_fs_edj, value_str = 
elm_interface_fileselector_path_get());
+              if (!strlen(value_str))
+                return EO_CALLBACK_CONTINUE;
+              break;
+           }
+   /* For CALLBACKS and STRINGS: check that value str is not empty. */
+      case RESOURCE_EO_CALLBACK:
+      case RESOURCE_STRING:
+           {
+              eo_do(g_rm_win->rm_value_entry, value_str = 
elm_obj_widget_part_text_get(NULL));
+              if (!strlen(value_str))
+                return EO_CALLBACK_CONTINUE;
+              break;
+           }
+      default:
+         ERR("switch - default: %d", res_type);
      }
 
    Gui_Resource *gui_res = gui_res = gui_context_resource_new((Gui_Context *) 
ctx, res_type, alias_str);
@@ -706,23 +773,35 @@ _rm_add_button_clicked(void *data EINA_UNUSED, Eo *obj 
EINA_UNUSED, const Eo_Eve
         return EO_CALLBACK_CONTINUE;
      }
 
-   if (res_type == RESOURCE_IMAGE || res_type == RESOURCE_EDJE)
+   switch (res_type)
      {
-        resource_value_set(gui_res, value_str);
-        if (res_type == RESOURCE_EDJE)
-          {
-             const char *edc_path = eo_do_ret(g_rm_win->rm_edje_fs_edc, 
edc_path, elm_interface_fileselector_path_get());
-             resource_edc_path_set(gui_res, edc_path);
-             resource_edj_path_set(gui_res, value_str);
-             eo_do(g_rm_win->rm_edje_fs_edc, 
elm_interface_fileselector_path_set(""));
-             eo_do(g_rm_win->rm_edje_fs_edj, 
elm_interface_fileselector_path_set(""));
-          }
-        const Gui_Widget *wdg  = gui_context_data_get(ctx, SELECTED_WDG);
-        proplayout_build(wdg);
-     }
-   else
-     {
-        resource_value_set(gui_res, value_str);
+        /* For IMAGES and THEMES: check that path is not empty. */
+      case RESOURCE_IMAGE:
+      case RESOURCE_THEME:
+      case RESOURCE_EDJE:
+           {
+              resource_value_set(gui_res, value_str);
+              if (res_type == RESOURCE_EDJE)
+                {
+                   const char *edc_path = eo_do_ret(g_rm_win->rm_edje_fs_edc, 
edc_path, elm_interface_fileselector_path_get());
+                   resource_edc_path_set(gui_res, edc_path);
+                   resource_edj_path_set(gui_res, value_str);
+                   eo_do(g_rm_win->rm_edje_fs_edc, 
elm_interface_fileselector_path_set(""));
+                   eo_do(g_rm_win->rm_edje_fs_edj, 
elm_interface_fileselector_path_set(""));
+                }
+              const Gui_Widget *wdg  = gui_context_data_get(ctx, SELECTED_WDG);
+              proplayout_build(wdg);
+              break;
+           }
+         /* For CALLBACKS and STRINGS: check that value str is not empty. */
+      case RESOURCE_EO_CALLBACK:
+      case RESOURCE_STRING:
+           {
+              resource_value_set(gui_res, value_str);
+              break;
+           }
+      default:
+         ERR("switch - default: %d", res_type);
      }
 
    _rmview_build(_rmview_toolbar_selected_type);
@@ -736,18 +815,16 @@ _rm_add_button_clicked(void *data EINA_UNUSED, Eo *obj 
EINA_UNUSED, const Eo_Eve
 void
 rm_win_post_configure()
 {
-   eo_do(g_rm_win->rm_toolbar, elm_obj_toolbar_item_append("emblem-photos", 
"Images",
-                                                    _rmview_toolbar_clicked, 
(void *) (intptr_t) RMVIEW_IMAGE));
-   eo_do(g_rm_win->rm_toolbar, elm_obj_toolbar_item_append("emblem-photos", 
"Edjes",
-                                                    _rmview_toolbar_clicked, 
(void *) (intptr_t) RMVIEW_EDJE));
-   eo_do(g_rm_win->rm_toolbar, elm_obj_toolbar_item_append("call-start", 
"Callbacks",
-                                                    _rmview_toolbar_clicked, 
(void *) (intptr_t) RMVIEW_CALLBACK));
-   eo_do(g_rm_win->rm_toolbar, elm_obj_toolbar_item_append("format-text-bold", 
"Strings",
-                                                    _rmview_toolbar_clicked, 
(void *) (intptr_t) RMVIEW_STRING));
+   elm_object_item_data_set(g_rm_win->rm_toolbar_it0, (void *) (intptr_t) 
RMVIEW_IMAGE);
+   elm_object_item_data_set(g_rm_win->rm_toolbar_it1, (void *) (intptr_t) 
RMVIEW_EDJE);
+   elm_object_item_data_set(g_rm_win->rm_toolbar_it2, (void *) (intptr_t) 
RMVIEW_THEME);
+   elm_object_item_data_set(g_rm_win->rm_toolbar_it3, (void *) (intptr_t) 
RMVIEW_CALLBACK);
+   elm_object_item_data_set(g_rm_win->rm_toolbar_it4, (void *) (intptr_t) 
RMVIEW_STRING);
    elm_object_tooltip_text_set(g_rm_win->rm_alias_entry, "Alias name");
    elm_object_tooltip_text_set(g_rm_win->rm_value_entry, "Value");
    elm_object_tooltip_text_set(g_rm_win->rm_edje_fs_edj, "Edj file name");
    elm_object_tooltip_text_set(g_rm_win->rm_edje_fs_edc, "Edc file name");
    elm_object_tooltip_text_set(g_rm_win->rm_image_fileselector, "Image path");
+   _rmview_toolbar_clicked((void *) RMVIEW_IMAGE, NULL, NULL);
 }
 
diff --git a/src/bin/egui_gui/rmview.h b/src/bin/egui_gui/rmview.h
index aef8b12..c7b9a6d 100644
--- a/src/bin/egui_gui/rmview.h
+++ b/src/bin/egui_gui/rmview.h
@@ -11,6 +11,7 @@ typedef enum
    RMVIEW_NOT_SELECTED,
    RMVIEW_IMAGE,
    RMVIEW_EDJE,
+   RMVIEW_THEME,
    RMVIEW_STRING,
    RMVIEW_CALLBACK
 } Rmview_Resource_Type;
diff --git a/src/bin/main.c b/src/bin/main.c
index f94afd3..b63c6db 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -241,25 +241,23 @@ main(int argc, char **argv)
         goto end;
      }
 
+   elm_init(argc, argv);
    if (!egui_init(PACKAGE_DATA_DIR"/config/func_names.json", 
PACKAGE_DATA_DIR"/config/egui_all.eo",
                   PACKAGE_DATA_DIR"/config/black_list.json"))
      {
         EINA_LOG_ERR("Could not start Erigo");
-        egui_shutdown();
-        return 1;
+        goto error_end;
      }
    _manager_init_check();
 
    if (mode == MODE_GUI)
      {
 #ifdef GUI_MODE
-        elm_init(argc, argv);
         egui_start();
         egui_project_open(filename);
         elm_run();
         egui_project_close();
         egui_stop();
-        elm_shutdown();
 #else
         printf("You are trying to use \"erigo_cmd\" in graphic mode. Nothing 
is going to happen :)\n");
 #endif
@@ -274,9 +272,10 @@ main(int argc, char **argv)
      {
         _generate(filename, output_filename, export_format);
      }
-   if (mode == MODE_SIMULATE)
-     elm_shutdown();
+
+error_end:
    egui_shutdown();
+   elm_shutdown();
 
 end:
    if (filename) free(filename);
diff --git a/src/lib/database.c b/src/lib/database.c
index a25ceb9..c646d3a 100644
--- a/src/lib/database.c
+++ b/src/lib/database.c
@@ -124,6 +124,7 @@ static char *gui_type_names[] =
   "GUI_TYPE_BOOL",
   "GUI_TYPE_ENUM",
   "GUI_TYPE_FILE",
+  "GUI_TYPE_THEME",
   "GUI_TYPE_VOID",
   "GUI_TYPE_NONE"
 };
@@ -1003,6 +1004,7 @@ db_init(const char *db_path, const char *all_eo_path, 
const char *black_list)
    eina_hash_add(typedef_table, "Evas_Smart_Cb", (void *) (uintptr_t) 
GUI_TYPE_CB);
    eina_hash_add(typedef_table, "Elm_Interface_Scrollable_Min_Limit_Cb", (void 
*) (uintptr_t) GUI_TYPE_CB);
    eina_hash_add(typedef_table, "Elm_Object_Item *", (void *) (uintptr_t) 
GUI_TYPE_OBJECT_ITEM);
+   eina_hash_add(typedef_table, "Elm_Theme *", (void *) (uintptr_t) 
GUI_TYPE_THEME);
 
    eina_hash_add(typedef_table, "GUI_TYPE_FILE", (void *) (uintptr_t) 
GUI_TYPE_FILE);
 
diff --git a/src/lib/database.h b/src/lib/database.h
index 89f6657..de06702 100644
--- a/src/lib/database.h
+++ b/src/lib/database.h
@@ -39,6 +39,7 @@ typedef enum _Gui_Type
    GUI_TYPE_BOOL,
    GUI_TYPE_ENUM,
    GUI_TYPE_FILE,
+   GUI_TYPE_THEME,
    GUI_TYPE_VOID,
    GUI_TYPE_NONE
 } Gui_Type;
diff --git a/src/lib/ffi_abstraction.c b/src/lib/ffi_abstraction.c
index 6c80afa..011fe87 100644
--- a/src/lib/ffi_abstraction.c
+++ b/src/lib/ffi_abstraction.c
@@ -20,6 +20,7 @@ static Gui_Par_Type _gui_types[] =
      {&ffi_type_uint}, /*GUI_TYPE_BOOL*/
      {&ffi_type_sint}, /*GUI_TYPE_ENUM*/
      {&ffi_type_pointer}, /*GUI_TYPE_FILE*/
+     {&ffi_type_pointer}, /*GUI_TYPE_THEME*/
      {&ffi_type_pointer}, /*GUI_TYPE_VOID*/
      {NULL}
 };
@@ -55,6 +56,7 @@ _ffi_eo_do(const Gui_Session *session, const Gui_Widget *wdg, 
const Gui_Widget_P
    void **values = NULL;
    Eo **objects = NULL;
    int *enums = NULL;
+   Elm_Theme **themes = NULL;
    Eo *eo_cur;
    int arg_num = 0;
    Eina_Stringshare *prop_name = prop_name_get(prop);
@@ -86,6 +88,7 @@ _ffi_eo_do(const Gui_Session *session, const Gui_Widget *wdg, 
const Gui_Widget_P
    values = (void **) calloc(arg_num, sizeof(void *));
    objects = (Eo **) calloc(arg_num, sizeof(Eo *));
    enums = (int *) calloc(arg_num, sizeof(int));
+   themes = (Elm_Theme **) calloc(arg_num, sizeof(Elm_Theme *));
 
    Gui_Value *gui_value;
    Eina_List *values_lst = NULL, *lst;
@@ -124,6 +127,34 @@ _ffi_eo_do(const Gui_Session *session, const Gui_Widget 
*wdg, const Gui_Widget_P
                          }
                     }
                }
+             else if (gv_type == GUI_TYPE_THEME)
+               {
+                  Eid *eid = EID_ID_GET(gui_value);
+                  if (eid == 0)
+                    {
+                       p = gui_value_pointer_get(gui_value);
+                    }
+                  else
+                    {
+                       const Gui_Resource *res = resource_get_from_id(eid);
+                       if (res)
+                         {
+
+                            themes[i] = elm_theme_new();
+                            p = &themes[i];
+
+                            const char *theme_name = resource_value_get(res);
+                            char *str = malloc(strlen(theme_name) + 9);
+                            sprintf(str, "%s:default", theme_name);
+                            elm_theme_set(themes[i], str);
+                            free(str);
+                         }
+                       else
+                         {
+                            ERR("Resource doesn't exist.");
+                         }
+                    }
+               }
              else if (gv_type == GUI_TYPE_ENUM)
                {
                   const char *enum_str = STRING_GET(gui_value);
@@ -161,6 +192,14 @@ end:
    if (objects) free(objects);
    if (enums) free(enums);
 
+   int j = 0;
+   while (j < arg_num)
+     {
+        if (themes[j]) elm_theme_free(themes[j]);
+        j++;
+     }
+   if (themes) free(themes);
+
    types = NULL;
    values = NULL;
    return ret;
diff --git a/src/lib/generator.c b/src/lib/generator.c
index 3259266..38550fb 100644
--- a/src/lib/generator.c
+++ b/src/lib/generator.c
@@ -121,6 +121,28 @@ _format_string_add(Gui_Value *gui_value, Eina_Strbuf *p)
                 }
               break;
            }
+      case GUI_TYPE_THEME:
+           {
+              Eid *eid = EID_ID_GET(gui_value);
+              if (!eid)
+                {
+                   eina_strbuf_append_printf(p, "NULL");
+                }
+              else
+                {
+                   const Gui_Resource *res = resource_get_from_id(eid);
+                   if (!res)
+                     {
+                        ERR("RESOURCE_THEME not found.");
+                        return EINA_FALSE;
+                     }
+                   else
+                     {
+                        eina_strbuf_append_printf(p, "%s", 
resource_name_get(res));
+                     }
+                }
+              break;
+           }
       case GUI_TYPE_OBJECT:
            {
               Eid *eid = EID_ID_GET(gui_value);
@@ -240,6 +262,15 @@ _wdg_prop_add_generate(Gui_Session *session EINA_UNUSED, 
const Gui_Widget *wdg,
           {
              ADD_TO_LIST(gl_ctx->global_entities, EID_ID_GET(gui_value));
           }
+        /* Generate theme creation code. */
+        if (vtype == GUI_TYPE_THEME)
+          {
+              Eid *eid = EID_ID_GET(gui_value);
+              if (eid)
+                {
+                   wdg_ctx->declarations = 
eina_list_append(wdg_ctx->declarations, eid);
+                }
+          }
         if (!_format_string_add(gui_value, buf))
           {
              eina_strbuf_free(buf);
@@ -535,6 +566,8 @@ _wdg_creation_function_generate(Gui_Session *session, 
Gui_Widget *wdg, Widget_Co
    eina_iterator_free(iter);
    eina_hash_free(wdg_ctx->cbs_bufs_hash);
 
+   Eina_Strbuf *head_inits = eina_strbuf_new();
+   Eina_Strbuf *tail = eina_strbuf_new();
    /* Add definitions of variables */
    Eid *eid;
    EINA_LIST_FREE(wdg_ctx->declarations, eid)
@@ -555,16 +588,47 @@ _wdg_creation_function_generate(Gui_Session *session, 
Gui_Widget *wdg, Widget_Co
                          eid_name_get(eid));
                    break;
                 }
+           case EID_TYPE_RESOURCE:
+                {
+                   const Gui_Resource *res = resource_get_from_id(eid);
+                   if (res && (resource_type_get(res) == RESOURCE_THEME))
+                     {
+                        const char *var_name = resource_name_get(res);
+                        const char *theme_name = resource_value_get(res);
+                        eina_strbuf_append_printf(head, "   Elm_Theme *%s;\n", 
var_name);
+
+                        eina_strbuf_append_printf(head_inits, "\n   %s = 
elm_theme_new();\n", var_name);
+                        /* If global context == eid's contextm this is system 
theme, which can be found by path.
+                         * If not: need to add path*/
+                        char theme_path[PATH_MAX] = {0};
+                        if (global_context_get() != 
gui_context_get_by_eid(eid))
+                          {
+                             sprintf(theme_path, "%s_THEME_PATH\"/%s\"", 
gl_ctx->FORMATTED_PROJECT_NAME, ecore_file_file_get(theme_name));
+                          }
+                        else
+                          {
+                             sprintf(theme_path, "\"%s\"", theme_name);
+                          }
+                        eina_strbuf_append_printf(head_inits, "   
elm_theme_set(%s, %s\":default\");", var_name, theme_path[0] ? theme_path : 
theme_name);
+                        eina_strbuf_append_printf(tail, "   
elm_theme_free(%s);", var_name);
+                     }
+                   break;
+                }
            default:
               break;
           }
      }
+   eina_strbuf_append_printf(head, "%s\n", eina_strbuf_string_get(head_inits));
+
    eina_strbuf_prepend_printf(wdg_ctx->buf, "%s\n", 
eina_strbuf_string_get(head));
    eina_strbuf_append_printf(wdg_ctx->pub_widgets_buf, "} %s_Widgets;\n\n", 
eina_strbuf_string_get(wdg_ctx->Full_Function_Name));
+   eina_strbuf_append_printf(wdg_ctx->buf, "%s\n", 
eina_strbuf_string_get(tail));
    eina_strbuf_append_printf(wdg_ctx->buf, "\n   return pub_widgets;\n");
    eina_strbuf_append_printf(wdg_ctx->buf, "}\n\n");
 
+   eina_strbuf_free(head_inits);
    eina_strbuf_free(head);
+   eina_strbuf_free(tail);
 }
 
 /* Generate string for given callback. */
@@ -734,12 +798,13 @@ _ctx_generate(Global_Gen_Context *gl_ctx)
         Gui_Resource_Type type = i;
         const Eina_List *res_lst = gui_context_resource_list_get(ctx, type);
         if (!res_lst) continue;
+        const char *path_var = NULL;
+        if (type == RESOURCE_IMAGE) path_var = "IMAGES_PATH";
+        if (type == RESOURCE_EDJE) path_var = "EDJE_PATH";
+        if (type == RESOURCE_THEME) path_var = "THEME_PATH";
+
         if (type == RESOURCE_IMAGE || type == RESOURCE_EDJE)
           {
-             const char *path_var = NULL;
-             if (type == RESOURCE_IMAGE) path_var = "IMAGES_PATH";
-             if (type == RESOURCE_EDJE) path_var = "EDJE_PATH";
-
              Eina_Bool first_res = EINA_TRUE;
              Eina_Strbuf *if_buf = eina_strbuf_new();
              EINA_LIST_FOREACH(res_lst, itr, eid)
@@ -763,6 +828,17 @@ _ctx_generate(Global_Gen_Context *gl_ctx)
                }
              eina_strbuf_free(if_buf);
           }
+        if (type == RESOURCE_THEME)
+          {
+             Eina_Strbuf *if_buf = eina_strbuf_new();
+
+             eina_strbuf_append_printf(if_buf, "#ifndef %s_%s\n", 
gl_ctx->FORMATTED_PROJECT_NAME, path_var);
+             eina_strbuf_append_printf(if_buf, "   #error \"Please define 
%s_%s\"\n", gl_ctx->FORMATTED_PROJECT_NAME, path_var);
+             eina_strbuf_append_printf(if_buf, "#endif\n");
+
+             eina_strbuf_append_printf(resources_buf, "%s", 
eina_strbuf_string_get(if_buf));
+             eina_strbuf_free(if_buf);
+          }
         if (type == RESOURCE_EO_CALLBACK)
           {
              EINA_LIST_FOREACH(res_lst, itr, eid)
diff --git a/src/lib/gui_parser.c b/src/lib/gui_parser.c
index 09676ad..b7cca5c 100644
--- a/src/lib/gui_parser.c
+++ b/src/lib/gui_parser.c
@@ -196,20 +196,38 @@ _json_arr_to_prop_values(const Gui_Context *gui_ctx, 
Eina_Json_Value *jv, Gui_Wi
            case EINA_JSON_TYPE_STRING:
                 {
                    const char *str = eina_json_string_get(v);
-                   if (g_type == GUI_TYPE_STRING)
+                   switch (g_type)
                      {
-                        gui_value_string_set(g_val, str);
-                     }
-                   else if (g_type == GUI_TYPE_ENUM)
-                     {
-                        gui_value_enum_set(g_val, str);
-                     }
-                   else if ((g_type == GUI_TYPE_FILE) ||
-                            (g_type == GUI_TYPE_CB) ||
-                            (g_type == GUI_TYPE_OBJECT))
-                     {
-                        Eid *name_id = gui_context_eid_get_by_name(gui_ctx, 
str);
-                        gui_value_name_id_set(g_val, g_type, name_id);
+                      case GUI_TYPE_STRING:
+                           {
+                              gui_value_string_set(g_val, str);
+                              break;
+                           }
+                      case GUI_TYPE_ENUM:
+                           {
+                              gui_value_enum_set(g_val, str);
+                              break;
+                           }
+                      case GUI_TYPE_FILE:
+                      case GUI_TYPE_CB:
+                      case GUI_TYPE_OBJECT:
+                           {
+                              Eid *name_id = 
gui_context_eid_get_by_name(gui_ctx, str);
+                              gui_value_name_id_set(g_val, g_type, name_id);
+                              break;
+                           }
+                      case GUI_TYPE_THEME:
+                           {
+                              Eid *name_id = 
gui_context_eid_get_by_name(global_context_get(), str);
+                              if (!name_id)
+                                name_id = gui_context_eid_get_by_name(gui_ctx, 
str);
+                              gui_value_name_id_set(g_val, g_type, name_id);
+                              break;
+                           }
+                      default:
+                           {
+                              ERR("default case");
+                           }
                      }
                    break;
                 }
@@ -872,7 +890,7 @@ _resource_parse(Gui_Context *gui_ctx, Eina_Json_Value 
*res_js)
                             resource_edj_path_set(gui_res, val);
                          }
                     }
-                  else if (res_type == RESOURCE_IMAGE)
+                  else if ((res_type == RESOURCE_IMAGE) || (res_type == 
RESOURCE_THEME))
                     {
                        if (eina_json_type_get(cur) != EINA_JSON_TYPE_STRING)
                          {
diff --git a/src/lib/gui_widget.c b/src/lib/gui_widget.c
index 1e77cd4..a39cdb0 100644
--- a/src/lib/gui_widget.c
+++ b/src/lib/gui_widget.c
@@ -16,6 +16,12 @@ static Eina_Bool _egui_init_count = 0;
 
 static Gui_Context *context_array[1 << BITS_PER_CONTEXT];
 
+const Gui_Context *
+global_context_get()
+{
+   return context_array[0];
+}
+
 /* Invoked when a memento is appended */
 static New_Memento_Cb _new_memento_cb = NULL;
 static void *_new_memento_data = NULL;
@@ -234,6 +240,7 @@ struct _Gui_Resource
    Gui_Context *ctx;
    Eid *eid;
    char *value; /* In case of a Edje file, contains the real edj path or the 
temp one */
+   Eina_Bool system_theme;
    char *edc_path; /* Used when the resource is a Edje file */
    char *edj_path; /* Used when the resource is a Edje file. Stores the path 
that will be generated */
    Ecore_File_Monitor *edc_monitor;
@@ -250,6 +257,7 @@ resource_section_name_get(Gui_Resource_Type type)
       case  RESOURCE_STRING: return "Strings";
       case  RESOURCE_IMAGE: return "Images";
       case  RESOURCE_EDJE: return "Edjes";
+      case  RESOURCE_THEME: return "Themes";
       case  RESOURCE_EO_CALLBACK: return "Eo_Callbacks";
       case  RESOURCE_SENTINEL: return NULL;
      }
@@ -875,6 +883,16 @@ egui_init(const char *db_path, const char *all_eo_path, 
const char *black_list)
 
    if (!db_init(db_path, all_eo_path, black_list))
      return EINA_FALSE;
+   Gui_Context *ctx = gui_context_new();
+
+   const char *theme_name;
+   Eina_List *lst = elm_theme_name_available_list_new(), *l;
+   EINA_LIST_FOREACH(lst, l, theme_name)
+     {
+        Gui_Resource *gui_res = gui_context_resource_new(ctx, RESOURCE_THEME, 
theme_name);
+        resource_value_set(gui_res, theme_name);
+     }
+   elm_theme_name_available_list_free(lst);
 
    return EINA_TRUE;
 }
@@ -884,6 +902,7 @@ egui_shutdown()
 {
    if (--_egui_init_count > 0)
      return EINA_TRUE;
+   gui_context_del(context_array[0]);
    db_shutdown();
    eolian_shutdown();
    eina_log_domain_unregister(_egui_log_dom);
@@ -2350,6 +2369,7 @@ prop_create_for_op(const Op_Desc *op)
                    break;
                 }
            case GUI_TYPE_FILE:
+           case GUI_TYPE_THEME:
            case GUI_TYPE_OBJECT:
            case GUI_TYPE_CB:
            case GUI_TYPE_OBJECT_ITEM:
@@ -2596,9 +2616,10 @@ gui_value_name_id_set(Gui_Value *val, Gui_Type type, Eid 
*id)
    if ((type != GUI_TYPE_OBJECT) &&
        (type != GUI_TYPE_OBJECT_ITEM) &&
        (type != GUI_TYPE_CB) &&
-       (type != GUI_TYPE_FILE))
+       (type != GUI_TYPE_FILE) &&
+       (type != GUI_TYPE_THEME))
      {
-        ERR("Type: \"%s\". Only OBJECT, OBJECT_ITEM, IMAGE or CB type can be 
used here.", db_gui_type_name_get(type));
+        ERR("Type: \"%s\". Only OBJECT, OBJECT_ITEM, IMAGE, THEME or CB type 
can be used here.", db_gui_type_name_get(type));
         return;
      }
    val->type = type;
@@ -2659,6 +2680,7 @@ gui_value_del(Gui_Value *val)
       case GUI_TYPE_DOUBLE:
       case GUI_TYPE_OBJECT:
       case GUI_TYPE_FILE:
+      case GUI_TYPE_THEME:
       case GUI_TYPE_BOOL:
       case GUI_TYPE_CB:
       case GUI_TYPE_OBJECT_ITEM:
@@ -2711,6 +2733,7 @@ gui_value_pointer_get(const Gui_Value *_gui_value)
               break;
            }
       case GUI_TYPE_FILE:
+      case GUI_TYPE_THEME:
       case GUI_TYPE_OBJECT:
       case GUI_TYPE_CB:
            {
@@ -3316,10 +3339,18 @@ session_add_for_free(Gui_Session *session, void *data)
 }
 
 Gui_Resource *
-gui_context_resource_new(Gui_Context *ctx, Gui_Resource_Type type, const char 
*name)
+gui_context_resource_new(Gui_Context *ctx, Gui_Resource_Type type, const char 
*_name)
 {
    EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, NULL);
-   EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(_name, NULL);
+   char *name = strdup(_name);
+   char *p = name;
+   while (*p)
+     {
+        if (*p == '-')
+          *p = '_';
+        p++;
+     }
 
    /* if resource with id exists, need to return*/
    if (gui_context_eid_get_by_name(ctx, name))
@@ -3344,6 +3375,7 @@ gui_context_resource_new(Gui_Context *ctx, 
Gui_Resource_Type type, const char *n
      {
         eid_data->res = res;
      }
+   free(name);
    return res;
 }
 
diff --git a/src/lib/gui_widget.h b/src/lib/gui_widget.h
index 10efb58..9e4fa9a 100644
--- a/src/lib/gui_widget.h
+++ b/src/lib/gui_widget.h
@@ -91,7 +91,8 @@ typedef enum
    RESOURCE_IMAGE = 1 << 1,
    RESOURCE_EO_CALLBACK = 1 << 2,
    RESOURCE_EDJE = 1 << 3,
-   RESOURCE_SENTINEL = 1 << 4
+   RESOURCE_THEME = 1 << 4,
+   RESOURCE_SENTINEL = 1 << 5
 } Gui_Resource_Type;
 
 #define ITEM_REGULAR_STR "regular"
@@ -113,6 +114,10 @@ egui_shutdown();
 
/******************************************************************************/
 /* Context functions */
 
+/* Get global context, which keeps: e.g. System Themes */
+const Gui_Context *
+global_context_get();
+
 /* Create new context / project.
  * New context added to the list of contexts. */
 Gui_Context *
diff --git a/src/lib/json_generator.c b/src/lib/json_generator.c
index f560632..a64cd18 100644
--- a/src/lib/json_generator.c
+++ b/src/lib/json_generator.c
@@ -59,6 +59,7 @@ _gui_value_json_get(const Gui_Value *gui_value)
            }
       case GUI_TYPE_FILE:
       case GUI_TYPE_CB:
+      case GUI_TYPE_THEME:
            {
               Eid *eid = EID_ID_GET(gui_value);
 
@@ -162,6 +163,7 @@ _resources_json_generate(const Gui_Context *ctx)
                        break;
                     }
                 case RESOURCE_IMAGE:
+                case RESOURCE_THEME:
                     {
                        /* If path is in PROJECT folder, save only relative 
path. */
                        if (strstr(value, gui_context_project_path_get(ctx)))
diff --git a/src/lib/simulator.c b/src/lib/simulator.c
index 9f4c661..3d04af2 100644
--- a/src/lib/simulator.c
+++ b/src/lib/simulator.c
@@ -192,14 +192,17 @@ _widget_add(Gui_Session *session, const Gui_Widget *wdg, 
void *data)
    session_eo_set(session, wdg, o);
 
    /* Apply theme to simulated project. */
-   Elm_Theme *theme = elm_theme_new();
-   const char *theme_name = 
gui_context_edit_theme_name_get(wdg_context_get(wdg));
-   char *str = malloc(strlen(theme_name) + 9);
-   sprintf(str, "%s:default", theme_name);
-   elm_theme_set(theme, str);
-   elm_object_theme_set(o, theme);
-   free(str);
-   elm_theme_free(theme);
+   if (IS_WIN(wdg))
+     {
+        Elm_Theme *theme = elm_theme_new();
+        const char *theme_name = 
gui_context_edit_theme_name_get(wdg_context_get(wdg));
+        char *str = malloc(strlen(theme_name) + 9);
+        sprintf(str, "%s:default", theme_name);
+        elm_theme_set(theme, str);
+        elm_object_theme_set(o, theme);
+        free(str);
+        elm_theme_free(theme);
+     }
 
    /* Add callback on Eo deletion, in order to set wdg as non-existent.
     * T.e. when, during simulation, object will be deleted, Eo for this widget 
will

-- 


Reply via email to