aboutsummaryrefslogblamecommitdiffstats
path: root/src/lib/elementary/efl_ui_layout.c
blob: b3aaa083e941a9b58f100a717525f76daebe1e98 (plain) (tree)
1
2
3
4
5
6
7
8
9



                               
                                   
                            
                                       
                          
 
                       
 
                     
                              
                            
                         
 

                                    
 
                                     
 
                                                                                             
                                                                        
                                                                                                 
 
                                                        

                                                
 

                                       


                                                             

                              
                                                               
                                                                 

               
 


                                                           





                                                                





                                                                   
                                                         





                            







                                                     








                                                                              
 

                                                                      


                                                                                
 
                                  


                                
                         
  
 
                                     
 
                     
                    



















                                                   
       

  
                                       
 
                    




                                

  


                                         
                                                  



                                                                
           
                                           


                                                             
 
                                           
                                
 
 
           
                                                      







                                    
           
                                                      
 
                                   
                                     

                                              

                                   






                                                                     
                                                  

                                                              



                                                            









                                                           
                                                


       
                                                           
                                        
                                                
      


                  
                                         
                                                       
                                    
 
                    
            
         
 


                                                

                                                 
                                      
                                     
      

                         







                                                                                   


                                                                               
      
 






                                                                          
       





                                                          
 
                                         
 
                                                
                                                  


                  
                                         
                                                       

                                    

                    
 

                                                  













                                                       
 
                                              
 






                                                                    
       





                                                          
 
                                         

                                                                             
 





                                                                               
 
                                                
                                                  


           
                                           

                      
                                        
 
                                        



                                                


           
                                                                  
 

                                                   
                                                                         


           
                                            
 

                            
                                       
                                              
 
                                                       
 
                                              
      





                                                        




















                                                                             

 
           
                                                   




















                                                               
                                  
                                        
 
                              
 
                                                      
 
                           

                            
                           
                                                


                        
                                                             
 
                                          
 
                                                                             
 
                               

              

 
                       
                                                                                                                 
 
                                                      
 

                                                                  








                                                           
       







                                                           
 
                    

 
                                
                                                              
 
                                                                  
 
                                                                          

                                                       


                                         
                                     
                                                

                                                  
      
 
           
                                                                                  
 
                                  
                                          
 


              
                                       
                                                                         
 
                                                                              
 

                                                                         
 

                                                             
 
 
                       
                                                                                                
 
                                                      
 
                                                         
 
                                          
      



                                                                 
                                                         


       



                                                                   
                                                          
      
 
                                                                 
 
                                                        
                                                        
 
                    

 
                       
                                                                                                                   
 
                                  
 
                                                                         
 
                                                                       
                                   
 


                                                 
 
                    

 
                       
                                                                                                      

                
                                        
 

                                  
                                                      
 



                                             
                                                                       
                                   
                                           
 
                                        










                                                      
      
 


                                                 
 
                    

 
           
                                 
                                                   

                                           
 
                                
 
                                                    

 

                                                      


                                                 
                                                           
 











                                              
               
                                                
       
                                                    
 
                                                          













                                                           
                                          







                                                      
           

                                          
                                       
      
                                                            



           
                              


                                                
 
                                               

                                 
 

                                 
                                       
                                                     

                                                        
                                                                                    
 



                                                     
 
                                                    

                                          
 
                                   
                                                           
      

                                                                  

      

                
 
                
                                                       

                       
      







                             
      
 
 

                                   
                                         
                                                       

                      
                                                    
 
                                                                                         
 

                                          
 

                                   
                                                           



                                                                  
 
                

 
           
                                    


                                                          
 
                                
 
 
                  
                                                                                       

                     
 
                                         
 

                                                      
                                           
 
                                                  


                                             





                                                                  
 
                               

 
                  
                                                                          
 

                                        

                         
                
 
                                          
 
                          
 




                                          
 

                                        
 

                                        


                                                       


                                            

      
                        
      



                                                                                      
      
 





                                          
 










                                                                     
 

                                 
                                                  

 

                                                                   
                  
                                                                                
 
                           
      

                                         
      

 
                                        
                                           
                                     
 
                      
                                       
 
                                              
      


                                    
 

               
 

                                                                   
 
                       
                                                                                                      
 
                                  
 
                                                      
 

                                                       
 




                                  




                                                         
 
                  
 
 
                  
                                                                                                                          




                                                     

                       
                                                                                                           






















                                                           
                                                                                                                               




                                                  
                                       
                                                                                                                  
 
                                  
 
                                                            
      
                                                                    
                                              

      
                                               
 





                                                       
                                            

 
                  
                                                                                                                                    
 
                                                   
                                                        
                                          
                                                            
 
 
                       
                                                                                                                                                                            
 

                                                      
                                                                                       

 
                       
                                                                                                                                                                             
 

                                                      
                                                                                       
 
 




                                                                     
              
                                                                                   
 
                                       

                
                                                              

                                        


                                                                       
                                                           

 
                
                                                                                                   
 
                                        
                
 
                                                      
 
                                        
      




                                                      
                                                       






                                                                 




                                                                
                                                                       


                        

      
               
      
                                                     
                            
 



                                                                       
                                                                  
                               
           
                                                       


                                               
                                                                 
                                                                  

                               




                                                     
                                     

                                                
 
                               
 
    
                    

 
                  
                                                                   
 
                                 

                                                                      

                
                                                              

                                  

                                                                       
 
                                                  

 
                   
                                                                             
 
                      
                                        
 
                                        
      



                                                                
           
      
 
                                                
                                                          
 
 
                  
                                                               
 
                                 

                
                                                              




                                                                       
                                                    

 
                   
                                                                               
 
                                        
                
 
                                                
 
                                        
      
                                                                     
           
                                  
 
                                          
 
                                                       
                                                                                   
 
                                                                       

                                                                              
                              



                                         










                                                                     
                                               
                            

           

               

 
                       
                                                                                        
                                                                 


                                                      
                                                             






                                                                    
                    

 
                                  


                                                           
                                 
                         
                                               
                                                              



                                        
                                   
                                                  
      
 
              

 
                
                                                               
 
                                      







                                                             
                      
                                                           




                     
                                                  





                                         
                                                        
 
                                  







                                                        
                                                              

                                                                                         
                       




                             
                                                                                            
 
                                           

 
                 
                                                                                          
 
                                    

 
                
                                                                                                                         
 
                                                      
 
                                               
                
 
                                        
      
                                                                  
           

                       
                                                           
                                                    



                                                                
                                              
                                   


                     

           
 

                               
                                 

                                              
                                      

                             



                                                                  

       
                                                           
      
 
              
      
                                                       
                                      


                                                     
      
 
                                           
 
                               
 
                                                        
                                       


                                                              
                                                  
      


                                                                             
           





                                                                     


           
                    
 
 
                
                                                                                            



                                                                           
                  
                                                                                      
 
                                                
 



                                                               



                                                       
                                                                                             






                                                              
                                                                                                   

                                                                          

 
           
                                                                                                                           



                                                
                                  

 
         
                                                                                                
 
                                        
 
                                                      
 



                                                                            
                          
      
 



                                              
                          
      
 
                                                  


                                          
                                                           


                                                                 
                            
                                                   
 
                               
 
                    
 
 
         
                                                                                                 
 
                                        
 
                                                      
 



                                                                             
                          
      
 



                                              
                          

      
                                                  


                                          
                                                           


                                                                 
                             
                                                   
 
                               
 
                    

 
         
                                                                                                                                     
 
                                        
 
                                                      





                                                                         
                          





                                              
                          

      
                                                  


                                          
                                                           


                                                                 
                                   
                                      
                                                   


                                                                              
 
                               
 
                    
 
 
         
                                                                                                                     
 
                                        
                                                      





                                                                    
                          





                                              
                          

      
                                                  


                                          
                                                           


                                                                 
                               
                          
                                                   
 
                               
 
                    
 
 
             
                                                                                                

 

                                               
 

                      
                                        




                                                                  
                                                  
      
 
               
 
 
         
                                                                                                 
 
                                                    
 
                                                      
 
                                        


















                                                                        
                    

 
         
                                                                                                                                                                                        
 
                                        
 
                                                      




                                           
                                                                                 

                                                                        
                          





                                              
                          

      
                                                  


                                          
                                                           


                                                                   







                                                
                              
 
                               
 
                    

 
             
                                                                                                  

 

                                               

                      
                                        





                                                                  
                                                      

           
 
               

 
         
                                                                                              
 
                                                    
 
                                                      
 
                                        

















                                                                        
                    

 

                                  
 
                                                                 
                                                
 
                         
 
 
                          
                                                                                                                   
 

                                                
                                                         

 
                         
                                                                                                      
 
                                                             
 
                                                        

 
                         
                                                                                                      
 
                                                             
 
                                                        
 
 
                       
                                                                                                                    





                                                                


                                                                    
                                        
           
                                                        
 
                                       
                          





                                   

                                                                    
 
                                                                   

                   





                                  
                 
                                                                           
 
                                             
 
                                              
 
                                      
 
            

 
                 
                                                                         
 
                                             
 
                                              
 
                                    
 
                               
 
            

 
                
                                                                                                 
 
                         
                                       

                     

                                                         
 
                                                                       
 
                                      
                                                        
                                   

                                    


                                 
 
                                                            
                                                                              
                                            
                          



                                             
 
                                                            
                                                                        

                                            
                          

      
                                           



                                                         




                                               

                                                   
                                                    
                                                                    



                                                        
 
                    

 
                   
                                                                             
 
                                                   
 
                                                                            

                                                 
 
                                         

 
                
                                                                               
 
                                                         
 
                
                                       
 
                                              
      
                                         


                                                           
                                                                             
                              

           
 
                     

 
                
                                                                                                      
 
                                                         
 
                                                                            

                                                       


                                                   
 
                    

 
                  
                                                                                   
 
                                                   
 
                                                                            

                                                 
 
                                               

 
                
                                                                                                                
 
                                                         
 
                                                                            

                                                       

                                   
                                                                         
 
                    

 
                
                                                                                         
 
                                                         
 
                                                                            

                                                       
 
                                                               
 
 

                                                                    
 
                                                                   
                                                  
                                 
                    

 

                                                    
 
                                                                   
                                                  
                         

 
                  
                                                                                                           
 
                                                       
                                             
 
                                                                          
      
                                                                            
                                      
                                               
                              
 
                                                   

                                                                                
 
                                                     

                                          
                                                                        
                                                            



           
           
                                                                                                      
 
                        
                      

                                                        



                                                       






                                                                                                  


           
                                                                                                      
 
                        
                    


                                  

                                                        
                  
 








                                                                                  

                                                              
      
                                      
      
                                   
 
                           
                                                              



































                                                                                                                                      

                                                                         
 
         
                         

                      

 



                                                                            





                           
                                                             







                                                 
                                                            


                                                                          
                                                       



                
           
                                                                                           
 
















                                                                                                                            
 

                                              


                                                 
                                                                                            




                                                              


           
                                                        
 

                          
 
                                   
 











                                                                            




                                                                          
                          




                                                                    
                                               
                                 



                          
                                         
 

                                                             


                                                             
                                                










                                                                                  
      

 
           








                                                                     
                                                   
 
                                       
 

                                                                                                                
                                                                                                                                                   
 
 
                  
                                                                                       




                          





                                                                                  

             
                                                                                  
                                                                     
 
                                   
 






                                                           
 

                                                            
      
                                                
                                
 

                              
 




                                                                       
                                                


                                                          
      



                                        


                         
                                                                                       
 
                            


                  
                                                                                                                                

                                    


                           
 
                                                              

            


                                          
 

                                                                    
      

                                                        


       

                                      

      
              
      
                                                  
      
       
      
                                         
      

                                           






                                                                     
 

                

 
                  
                                                                                        


                                                          
                                            
                             
 
                                                              

            


                                                                                                   

                                        









                                                                
 

                                                                         
 



                                              
      





                                                                      

      



                                                                   

 
                  
                                                                      
 
                 
                                                   
                                                                       
                                                           

              
 
 
                         
                                                                               








                                               
                  
                                                                                                                        

                                          
                                                           


                  
                                                                                                               

                                          
                                                      
 
 


                             
                                                                                                     








                                                                          
                                  
      
                                           
           


                                                                                                  
                








                                                                                  
                
 



                                                                               
      



                                                              
                                                  

























                                                                               
                                                                                          







                                                               
                                                                                       






                                                              
                                 




                                                                                                
                                                                  



                                                               
                                                                                  

                                                                         
                                                                  






                                                                                                     
                                                                  



                                                                    
                                                                                        

                                                                         
                                                                  






                                                                                                                  
                                                                  



                                                                           
                                                                                                       

                                                                         
                                                                  


                                                                    














                                                                                                                       

                                                                                          
 


                                                                                      

                          
                                                                                                             





                                                                           
                                                                                                                         




                                                                           



                                                                                         

                          
                                                                                                               





                                                                           
                                                                                                                           




                                                                           
                                    



                                                                          
                          








                                                                   
                                                                      







                                                                       
                                     

















                                                                                                    
                                 







                                                                               
                             


                                    







                                                                           
 





                                                             
 


                                                                 
                                                

 


                                                                   
                                         

 
              











                                                                        
                                                                    
 
                                               


              
                                                                     
 
                                                     


              
                                                                                                         
 
                                                                 


              
                                                                                         
 
                                                       


                  
                                                                    
 
                                                    




                 
                                                                     
 
             
                                                
       
                                                     


              
                                                                                                                                                            
 
                                                                                 


                  
                                                                      
 


                                                    


              
                                                                  
 
             
                                                
       
                                                     

 
              
                                                                
 

             
                                                        

                                     


                                                                   
                                           



                    
                                                    
 
             
      
                                                        
                               
      


                                                                   
                                            

 
              
                                                                                        




                                                                                    
                                                                       




                                                                       
                                                                         




                                                         
                                                           




                                                 
                                                                              




                                                              
                                                                 




                                                       
                                                       


                                                       



                                   
                                      




                                 
                                    
 

















                                                                                     
                                                         



                                                                     
                                                                                                                  
 
                          


































                                                                                                 
                                                                   














                                                                               
                                                                                                      
 
                          














                                                                                        
                                                                         
 
                                                 
 



                                                            
                                              
 
 


                                                                                               
                                             
 

                                                                       

 
                                    
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif

#define EFL_ACCESS_OBJECT_PROTECTED
#define ELM_LAYOUT_PROTECTED
#define EFL_UI_WIDGET_PART_BG_PROTECTED
#define EFL_PART_PROTECTED

#include <Elementary.h>

#include "elm_priv.h"
#include "elm_widget_layout.h"
#include "elm_part_helper.h"
#include "elm_entry.eo.h"

#define MY_CLASS EFL_UI_LAYOUT_CLASS
#define MY_CLASS_PFX efl_ui_layout

#define MY_CLASS_NAME "Efl.Ui.Layout"

Eo *_efl_ui_layout_pack_proxy_get(Efl_Ui_Layout *obj, Edje_Part_Type type, const char *part);
static void _efl_model_properties_changed_cb(void *, const Efl_Event *);
static Eina_Bool _efl_ui_layout_part_cursor_unset(Efl_Ui_Layout_Data *sd, const char *part_name);

static const char SIG_THEME_CHANGED[] = "theme,changed";
const char SIG_LAYOUT_FOCUSED[] = "focused";
const char SIG_LAYOUT_UNFOCUSED[] = "unfocused";

const char SIGNAL_PREFIX[] = "signal/";

/* smart callbacks coming from elm layout objects: */
static const Evas_Smart_Cb_Description _smart_callbacks[] = {
   {SIG_THEME_CHANGED, ""},
   {SIG_LAYOUT_FOCUSED, ""},
   {SIG_LAYOUT_UNFOCUSED, ""},
   {SIG_WIDGET_LANG_CHANGED, ""}, /**< handled by elm_widget */
   {SIG_WIDGET_ACCESS_CHANGED, ""}, /**< handled by elm_widget */
   {NULL, NULL}
};

static const char efl_ui_default_text[] = "efl.text";
static const char efl_ui_default_content[] = "efl.content";

static const Elm_Layout_Part_Alias_Description _text_aliases[] =
{
   {"default", "elm.text"},
   {NULL, NULL}
};

static const Elm_Layout_Part_Alias_Description _content_aliases[] =
{
   {"default", "elm.swallow.content"},
   {NULL, NULL}
};

static const char *_elm_legacy_layout_swallow_parts[] = {
   "elm.swallow.icon",
   "elm.swallow.end",
   "elm.swallow.background",
   NULL
};

static const char *_efl_ui_layout_swallow_parts[] = {
   "efl.content",
   "efl.icon",
   "efl.end",
   "efl.background",
   NULL
};

typedef struct _Efl_Ui_Layout_Factory_Tracking Efl_Ui_Layout_Factory_Tracking;

struct _Efl_Ui_Layout_Factory_Tracking
{
   Efl_Ui_Factory *factory;
   Eina_Future *in_flight;
   Eina_Stringshare *name;
};


/* these are data operated by layout's class functions internally, and
 * should not be messed up by inhering classes */
typedef struct _Efl_Ui_Layout_Sub_Object_Data   Efl_Ui_Layout_Sub_Object_Data;
typedef struct _Efl_Ui_Layout_Sub_Object_Cursor Efl_Ui_Layout_Sub_Object_Cursor;
typedef struct _Efl_Ui_Layout_Sub_Iterator      Efl_Ui_Layout_Sub_Iterator;

struct _Efl_Ui_Layout_Sub_Iterator
{
   Eina_Iterator  iterator;
   Eina_Iterator *real_iterator;
   Efl_Ui_Layout *object;
};

struct _Efl_Ui_Layout_Sub_Object_Data
{
   const char  *part;
   Evas_Object *obj;

   enum {
      SWALLOW,
      BOX_APPEND,
      BOX_PREPEND,
      BOX_INSERT_BEFORE,
      BOX_INSERT_AT,
      TABLE_PACK,
      TEXT
   } type;

   union {
      union {
         const Evas_Object *reference;
         unsigned int       pos;
      } box;
      struct
      {
         unsigned short col, row, colspan, rowspan;
      } table;
   } p;
};

struct _Efl_Ui_Layout_Sub_Object_Cursor
{
   Evas_Object *obj;
   const char  *part;
   const char  *cursor;
   const char  *style;

   Eina_Bool    engine_only : 1;
};

#define MY_CLASS_NAME_LEGACY "elm_layout"

static void
_efl_ui_layout_class_constructor(Efl_Class *klass)
{
   evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
}

static void
_on_sub_object_size_hint_change(void *data,
                                Evas *e EINA_UNUSED,
                                Evas_Object *obj EINA_UNUSED,
                                void *event_info EINA_UNUSED)
{
   ELM_WIDGET_DATA_GET_OR_RETURN(data, wd);
   elm_layout_sizing_eval(data);
}

static void
_part_cursor_free(Efl_Ui_Layout_Sub_Object_Cursor *pc)
{
   eina_stringshare_del(pc->part);
   eina_stringshare_del(pc->style);
   eina_stringshare_del(pc->cursor);

   free(pc);
}

static void
_sizing_eval(Evas_Object *obj, Efl_Ui_Layout_Data *sd)
{
   Evas_Coord minh = -1, minw = -1;
   Evas_Coord rest_w = 0, rest_h = 0;
   ELM_WIDGET_DATA_GET_OR_RETURN(sd->obj, wd);

   if (!efl_alive_get(obj)) return;

   if (sd->restricted_calc_w)
     rest_w = wd->w;
   if (sd->restricted_calc_h)
     rest_h = wd->h;

   edje_object_size_min_restricted_calc(wd->resize_obj, &minw, &minh,
                                        rest_w, rest_h);
   evas_object_size_hint_min_set(obj, minw, minh);

   sd->restricted_calc_w = sd->restricted_calc_h = EINA_FALSE;
}

/* common content cases for layout objects: icon and text */
static inline void
_signals_emit(Eo *obj,
              const char *type,
              Eina_Bool set)
{
   char buf[1024];

   if (elm_widget_is_legacy(obj))
     {
        snprintf(buf, sizeof(buf), "elm,state,%s,%s", type,
                 set ? "visible" : "hidden");
        efl_layout_signal_emit(obj, buf, "elm");
     }
   else
     {
        snprintf(buf, sizeof(buf), "efl,state,%s,%s", type,
                 set ? "set" : "unset");
        efl_layout_signal_emit(obj, buf, "efl");
     }
}

static inline void
_icon_signal_emit(Efl_Ui_Layout_Data *sd,
                  Efl_Ui_Layout_Sub_Object_Data *sub_d,
                  Eina_Bool visible)
{
   const char *type;
   Eo *edje;
   int i;

   edje = elm_widget_resize_object_get(sd->obj);
   if (!edje) return;

   //FIXME: Don't limit to the icon and end here.
   // send signals for all contents after elm 2.0
   if (sub_d->type != SWALLOW) return;
   if (elm_widget_is_legacy(sd->obj))
     {
        for (i = 0;; i++)
          {
              if (!_elm_legacy_layout_swallow_parts[i]) return;
              if (!strcmp(sub_d->part, _elm_legacy_layout_swallow_parts[i])) break;
          }
     }
   else
     {
        for (i = 0;; i++)
          {
              if (!_efl_ui_layout_swallow_parts[i]) return;
              if (!strcmp(sub_d->part, _efl_ui_layout_swallow_parts[i])) break;
          }
     }

   if (elm_widget_is_legacy(sd->obj))
     {
        if (!strncmp(sub_d->part, "elm.swallow.", strlen("elm.swallow.")))
          type = sub_d->part + strlen("elm.swallow.");
        else
          type = sub_d->part;
     }
   else
     {
        if (!strncmp(sub_d->part, "efl.", strlen("efl.")))
          type = sub_d->part + strlen("efl.");
        else
          type = sub_d->part;
     }

   _signals_emit(sd->obj, type, visible);

   /* themes might need immediate action here */
   efl_layout_signal_process(sd->obj, EINA_FALSE);
}

static inline void
_text_signal_emit(Efl_Ui_Layout_Data *sd,
                  Efl_Ui_Layout_Sub_Object_Data *sub_d,
                  Eina_Bool visible)
{
   char buf[1024];
   const char *type;

   //FIXME: Don't limit to "elm.text" prefix.
   //Send signals for all text parts after elm 2.0
   if (sub_d->type != TEXT) return;

   if (elm_widget_is_legacy(sd->obj))
     {
        if (!((!strcmp("elm.text", sub_d->part)) ||
              (!strncmp("elm.text.", sub_d->part, 9))))
          return;
     }
   else
     {
        if (!((!strcmp("efl.text", sub_d->part)) ||
              (!strncmp("efl.text.", sub_d->part, 9))))
          return;
     }

   ELM_WIDGET_DATA_GET_OR_RETURN(sd->obj, wd);

   if (elm_widget_is_legacy(sd->obj))
     {
        if (!strncmp(sub_d->part, "elm.text.", strlen("elm.text.")))
          type = sub_d->part + strlen("elm.text.");
        else
          type = sub_d->part;
     }
   else
     {
        if (!strncmp(sub_d->part, "efl.", strlen("efl.")))
          type = sub_d->part + strlen("efl.");
        else
          type = sub_d->part;
     }

   _signals_emit(sd->obj, type, visible);

   /* TODO: is this right? It was like that, but IMO it should be removed: */

   if (elm_widget_is_legacy(sd->obj))
     {
        snprintf(buf, sizeof(buf),
                 visible ? "elm,state,text,visible" : "elm,state,text,hidden");
        efl_layout_signal_emit(sd->obj, buf, "elm");
     }

   /* themes might need immediate action here */
   efl_layout_signal_process(sd->obj, EINA_FALSE);
}

static void
_parts_signals_emit(Efl_Ui_Layout_Data *sd)
{
   const Eina_List *l;
   Efl_Ui_Layout_Sub_Object_Data *sub_d;

   EINA_LIST_FOREACH(sd->subs, l, sub_d)
     {
        _icon_signal_emit(sd, sub_d, EINA_TRUE);
        _text_signal_emit(sd, sub_d, EINA_TRUE);
     }
}

static void
_part_cursor_part_apply(const Efl_Ui_Layout_Sub_Object_Cursor *pc)
{
   elm_object_cursor_set(pc->obj, pc->cursor);
   elm_object_cursor_style_set(pc->obj, pc->style);
   elm_object_cursor_theme_search_enabled_set(pc->obj, !pc->engine_only);
}

static void
_parts_cursors_apply(Efl_Ui_Layout_Data *sd)
{
   const Eina_List *l;
   const char *file, *group;
   Efl_Ui_Layout_Sub_Object_Cursor *pc;
   ELM_WIDGET_DATA_GET_OR_RETURN(sd->obj, wd);

   edje_object_file_get(wd->resize_obj, &file, &group);

   EINA_LIST_FOREACH(sd->parts_cursors, l, pc)
     {
        Evas_Object *obj;

        edje_object_freeze(wd->resize_obj);
        obj = (Evas_Object *)edje_object_part_object_get
          (wd->resize_obj, pc->part);
        edje_object_thaw(wd->resize_obj);

        if (!obj)
          {
             pc->obj = NULL;
             WRN("no part '%s' in group '%s' of file '%s'. "
                 "Cannot set cursor '%s'",
                 pc->part, group, file, pc->cursor);
             continue;
          }
        else if (evas_object_pass_events_get(obj))
          {
             pc->obj = NULL;
             WRN("part '%s' in group '%s' of file '%s' has mouse_events: 0. "
                 "Cannot set cursor '%s'",
                 pc->part, group, file, pc->cursor);
             continue;
          }

        pc->obj = obj;
        _part_cursor_part_apply(pc);
     }
}

static void
_efl_ui_layout_highlight_in_theme(Evas_Object *obj)
{
   const char *fh;

   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);

   fh = edje_object_data_get
       (wd->resize_obj, "focus_highlight");
   if ((fh) && (!strcmp(fh, "on")))
     elm_widget_highlight_in_theme_set(obj, EINA_TRUE);
   else
     elm_widget_highlight_in_theme_set(obj, EINA_FALSE);

   fh = edje_object_data_get
       (wd->resize_obj, "access_highlight");
   if ((fh) && (!strcmp(fh, "on")))
     elm_widget_access_highlight_in_theme_set(obj, EINA_TRUE);
   else
     elm_widget_access_highlight_in_theme_set(obj, EINA_FALSE);
}

static Eina_Bool
_visuals_refresh(Evas_Object *obj,
                 Efl_Ui_Layout_Data *sd)
{
   Eina_Bool ret = EINA_FALSE;

   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);

   _parts_signals_emit(sd);
   _parts_cursors_apply(sd);

   edje_object_mirrored_set
     (wd->resize_obj, efl_ui_mirrored_get(obj));

   edje_object_scale_set
     (wd->resize_obj,
     efl_gfx_entity_scale_get(obj) * elm_config_scale_get());

   _efl_ui_layout_highlight_in_theme(obj);

   ret = efl_ui_widget_on_disabled_update(obj, elm_widget_disabled_get(obj));

   elm_layout_sizing_eval(obj);

   return ret;
}

EOLIAN static Eina_Bool
_efl_ui_layout_efl_ui_widget_on_disabled_update(Eo *obj, Efl_Ui_Layout_Data *_pd EINA_UNUSED, Eina_Bool disabled)
{
   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);

   // Not calling efl_super here: Elm.Widget simply returns false.

   if (elm_widget_is_legacy(obj))
     {
        if (disabled)
          edje_object_signal_emit
             (wd->resize_obj, "elm,state,disabled", "elm");
        else
          edje_object_signal_emit
             (wd->resize_obj, "elm,state,enabled", "elm");
     }
   else
     {
        if (disabled)
          edje_object_signal_emit
             (wd->resize_obj, "efl,state,disabled", "efl");
        else
          edje_object_signal_emit
             (wd->resize_obj, "efl,state,enabled", "efl");
     }

   return EINA_TRUE;
}

static Efl_Ui_Theme_Apply_Result
_efl_ui_layout_theme_internal(Eo *obj, Efl_Ui_Layout_Data *sd)
{
   Efl_Ui_Theme_Apply_Result ret = EFL_UI_THEME_APPLY_RESULT_FAIL;

   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EFL_UI_THEME_APPLY_RESULT_FAIL);

   /* function already prints error messages, if any */
   if (!sd->file_set)
     {
        ret = elm_widget_theme_object_set
                (obj, wd->resize_obj,
                elm_widget_theme_klass_get(obj),
                elm_widget_theme_element_get(obj),
                elm_widget_theme_style_get(obj));
     }

   if (ret)
     efl_event_callback_legacy_call(obj, EFL_UI_LAYOUT_EVENT_THEME_CHANGED, NULL);

   if (!_visuals_refresh(obj, sd))
     ret = EFL_UI_THEME_APPLY_RESULT_FAIL;

   return ret;
}

EOLIAN static Efl_Ui_Theme_Apply_Result
_efl_ui_layout_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Layout_Data *sd)
{
   Efl_Ui_Theme_Apply_Result theme_apply_ret = EFL_UI_THEME_APPLY_RESULT_FAIL;

   theme_apply_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS));
   if (!theme_apply_ret) return EFL_UI_THEME_APPLY_RESULT_FAIL;

   theme_apply_ret &= _efl_ui_layout_theme_internal(obj, sd);
   return theme_apply_ret;
}

EOLIAN static Eina_Bool
_efl_ui_layout_efl_ui_focus_object_on_focus_update(Eo *obj, Efl_Ui_Layout_Data *_pd EINA_UNUSED)
{
   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);

   if (!elm_widget_can_focus_get(obj)) return EINA_FALSE;

   if (efl_ui_focus_object_focus_get(obj))
     {
        if (elm_widget_is_legacy(obj))
          elm_layout_signal_emit(obj, "elm,action,focus", "elm");
        else
          elm_layout_signal_emit(obj, "efl,action,focus", "efl");
        evas_object_focus_set(wd->resize_obj, EINA_TRUE);
     }
   else
     {
        if (elm_widget_is_legacy(obj))
          elm_layout_signal_emit(obj, "elm,action,unfocus", "elm");
        else
          elm_layout_signal_emit(obj, "efl,action,unfocus", "efl");
        evas_object_focus_set(wd->resize_obj, EINA_FALSE);
     }

   efl_ui_focus_object_on_focus_update(efl_super(obj, MY_CLASS));

   if (efl_isa(wd->resize_obj, EFL_CANVAS_LAYOUT_CLASS))
     edje_object_message_signal_process(wd->resize_obj);

   return EINA_TRUE;
}

EOLIAN static Eina_Bool
_efl_ui_layout_efl_ui_widget_widget_sub_object_add(Eo *obj, Efl_Ui_Layout_Data *_pd EINA_UNUSED, Evas_Object *sobj)
{
   Eina_Bool int_ret = EINA_FALSE;

   if (evas_object_data_get(sobj, "elm-parent") == obj) return EINA_TRUE;

   int_ret = elm_widget_sub_object_add(efl_super(obj, MY_CLASS), sobj);
   if (!int_ret) return EINA_FALSE;

   evas_object_event_callback_add
         (sobj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
          _on_sub_object_size_hint_change, obj);

   return EINA_TRUE;
}

EOLIAN static Eina_Bool
_efl_ui_layout_efl_ui_widget_widget_sub_object_del(Eo *obj, Efl_Ui_Layout_Data *sd, Evas_Object *sobj)
{
   Eina_List *l;
   Efl_Ui_Layout_Sub_Object_Data *sub_d;

   Eina_Bool int_ret = EINA_FALSE;

   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);

   evas_object_event_callback_del_full
     (sobj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
     _on_sub_object_size_hint_change, obj);

   int_ret = elm_widget_sub_object_del(efl_super(obj, MY_CLASS), sobj);
   if (!int_ret) return EINA_FALSE;
   if (sd->destructed_is) return EINA_TRUE;

   EINA_LIST_FOREACH(sd->subs, l, sub_d)
     {
        if (sub_d->obj != sobj) continue;

        sd->subs = eina_list_remove_list(sd->subs, l);

        _icon_signal_emit(sd, sub_d, EINA_FALSE);

        eina_stringshare_del(sub_d->part);
        free(sub_d);

        break;
     }

   // No need to resize object during destruction
   if (!efl_invalidated_get(obj))
     elm_layout_sizing_eval(obj);

   return EINA_TRUE;
}

static void
_edje_signal_callback(void *data,
                      Evas_Object *obj EINA_UNUSED,
                      const char *emission,
                      const char *source)
{
   Edje_Signal_Data *esd = data;

   esd->func(esd->data, esd->obj, emission, source);
}

EAPI Eina_Bool
_elm_layout_part_aliasing_eval(const Evas_Object *obj,
                               const char **part,
                               Eina_Bool is_text)
{
   const Elm_Layout_Part_Alias_Description *aliases = NULL;

   if (!elm_widget_is_legacy(obj))
     {
        if (!*part)
          {
             if (is_text)
               *part = efl_ui_default_text;
             else
               *part = efl_ui_default_content;
          }
        return EINA_TRUE;
     }

   if (is_text)
     aliases = elm_layout_text_aliases_get(obj);
   else
     aliases =  elm_layout_content_aliases_get(obj);

   while (aliases && aliases->alias && aliases->real_part)
     {
        /* NULL matches the 1st */
        if ((!*part) || (!strcmp(*part, aliases->alias)))
          {
             *part = aliases->real_part;
             break;
          }

        aliases++;
     }

   if (!*part)
     {
        ERR("no default content part set for object %p -- "
            "part must not be NULL", obj);
        return EINA_FALSE;
     }

   /* if no match, part goes on with the same value */

   return EINA_TRUE;
}

static void
_eo_unparent_helper(Eo *child, Eo *parent)
{
   if (efl_parent_get(child) == parent)
     {
        efl_parent_set(child, evas_object_evas_get(parent));
     }
}

static void
_box_reference_del(void *data,
                   Evas *e EINA_UNUSED,
                   Evas_Object *obj EINA_UNUSED,
                   void *event_info EINA_UNUSED)
{
   Efl_Ui_Layout_Sub_Object_Data *sub_d = data;
   sub_d->p.box.reference = NULL;
}

static Evas_Object *
_sub_box_remove(Evas_Object *obj,
                Efl_Ui_Layout_Data *sd,
                Efl_Ui_Layout_Sub_Object_Data *sub_d)
{
   Evas_Object *child = sub_d->obj; /* sub_d will die in
                                     * _efl_ui_layout_smart_widget_sub_object_del */

   if (sub_d->type == BOX_INSERT_BEFORE)
     evas_object_event_callback_del_full
       ((Evas_Object *)sub_d->p.box.reference,
       EVAS_CALLBACK_DEL, _box_reference_del, sub_d);

   ELM_WIDGET_DATA_GET_OR_RETURN(sd->obj, wd, NULL);
   edje_object_part_box_remove
     (wd->resize_obj, sub_d->part, child);

   _eo_unparent_helper(child, obj);
   if (!_elm_widget_sub_object_redirect_to_top(obj, child))
     {
        ERR("could not remove sub object %p from %p", child, obj);
        return NULL;
     }

   return child;
}

static Eina_Bool
_sub_box_is(const Efl_Ui_Layout_Sub_Object_Data *sub_d)
{
   switch (sub_d->type)
     {
      case BOX_APPEND:
      case BOX_PREPEND:
      case BOX_INSERT_BEFORE:
      case BOX_INSERT_AT:
        return EINA_TRUE;

      default:
        return EINA_FALSE;
     }
}

static Evas_Object *
_sub_table_remove(Evas_Object *obj,
                  Efl_Ui_Layout_Data *sd,
                  Efl_Ui_Layout_Sub_Object_Data *sub_d)
{
   Evas_Object *child;
   ELM_WIDGET_DATA_GET_OR_RETURN(sd->obj, wd, NULL);

   child = sub_d->obj; /* sub_d will die in _efl_ui_layout_smart_widget_sub_object_del */

   edje_object_part_table_unpack
     (wd->resize_obj, sub_d->part, child);

   _eo_unparent_helper(child, obj);

   if (!_elm_widget_sub_object_redirect_to_top(obj, child))
     {
        ERR("could not remove sub object %p from %p", child, obj);
        return NULL;
     }

   return child;
}

static void
_on_size_evaluate_signal(void *data,
                         Evas_Object *obj EINA_UNUSED,
                         const char *emission EINA_UNUSED,
                         const char *source EINA_UNUSED)
{
   elm_layout_sizing_eval(data);
}

EOLIAN static void
_efl_ui_layout_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Layout_Data *_pd EINA_UNUSED)
{
   Evas_Object *edje;

   elm_widget_sub_object_parent_add(obj);

   /* has to be there *before* parent's smart_add() */
   edje = edje_object_add(evas_object_evas_get(obj));
   elm_widget_resize_object_set(obj, edje);

   efl_canvas_group_add(efl_super(obj, MY_CLASS));

   elm_widget_can_focus_set(obj, EINA_FALSE);

   if (elm_widget_is_legacy(obj))
     edje_object_signal_callback_add
        (edje, "size,eval", "elm", _on_size_evaluate_signal, obj);
   else
     edje_object_signal_callback_add
        (edje, "size,eval", "efl", _on_size_evaluate_signal, obj);

   elm_layout_sizing_eval(obj);
}

EOLIAN static void
_efl_ui_layout_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Layout_Data *sd)
{
   Efl_Ui_Layout_Sub_Object_Data *sub_d;
   Efl_Ui_Layout_Sub_Object_Cursor *pc;
   Edje_Signal_Data *esd;
   Evas_Object *child;
   Eina_List *l;

   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);

   elm_layout_freeze(obj);

   EINA_LIST_FREE(sd->subs, sub_d)
     {
        eina_stringshare_del(sub_d->part);
        free(sub_d);
     }

   EINA_LIST_FREE(sd->parts_cursors, pc)
     _part_cursor_free(pc);

   EINA_LIST_FREE(sd->edje_signals, esd)
     {
        edje_object_signal_callback_del_full
           (wd->resize_obj, esd->emission, esd->source,
            _edje_signal_callback, esd);
        eina_stringshare_del(esd->emission);
        eina_stringshare_del(esd->source);
        free(esd);
     }

   if(sd->connect.model)
     {
         efl_event_callback_del(sd->connect.model, EFL_MODEL_EVENT_PROPERTIES_CHANGED,
                                _efl_model_properties_changed_cb, sd);
         efl_unref(sd->connect.model);
         sd->connect.model = NULL;
     }

   eina_hash_free(sd->connect.properties);
   sd->connect.properties = NULL;
   eina_hash_free(sd->connect.signals);
   sd->connect.signals = NULL;
   eina_hash_free(sd->connect.factories);
   sd->connect.factories = NULL;

   /* let's make our Edje object the *last* to be processed, since it
    * may (smart) parent other sub objects here */
   EINA_LIST_FOREACH(wd->subobjs, l, child)
     {
        if (child == wd->resize_obj)
          {
             wd->subobjs =
               eina_list_demote_list(wd->subobjs, l);
             break;
          }
     }

   sd->destructed_is = EINA_TRUE;

   efl_canvas_group_del(efl_super(obj, MY_CLASS));
}

/* rewrite or extend this one on your derived class as to suit your
 * needs */
EOLIAN static void
_efl_ui_layout_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Layout_Data *sd)
{
   if (sd->needs_size_calc)
     {
        _sizing_eval(obj, sd);
        sd->needs_size_calc = EINA_FALSE;
     }
}

static Efl_Ui_Layout_Sub_Object_Cursor *
_parts_cursors_find(Efl_Ui_Layout_Data *sd,
                    const char *part)
{
   const Eina_List *l;
   Efl_Ui_Layout_Sub_Object_Cursor *pc;

   EINA_LIST_FOREACH(sd->parts_cursors, l, pc)
     {
        if (!strcmp(pc->part, part))
          return pc;
     }

   return NULL;
}

/* The public functions down here are meant to operate on whichever
 * widget inheriting from elm_layout */

EOLIAN static Eina_Bool
_efl_ui_layout_efl_file_file_set(Eo *obj, Efl_Ui_Layout_Data *sd, const char *file, const char *group)
{
   Eina_Bool int_ret = EINA_FALSE;

   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);

   int_ret =
     edje_object_file_set(wd->resize_obj, file, group);

   if (int_ret)
     {
        sd->file_set = EINA_TRUE;
        _visuals_refresh(obj, sd);
     }
   else
     ERR("failed to set edje file '%s', group '%s': %s",
         file, group,
         edje_load_error_str
           (edje_object_load_error_get(wd->resize_obj)));

   return int_ret;
}

EOLIAN static void
_efl_ui_layout_efl_file_file_get(const Eo *obj, Efl_Ui_Layout_Data *sd EINA_UNUSED, const char **file, const char **group)
{
   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
   edje_object_file_get(wd->resize_obj, file, group);
}


EOLIAN static Eina_Bool
_efl_ui_layout_efl_file_mmap_set(Eo *obj, Efl_Ui_Layout_Data *sd, const Eina_File *file, const char *group)
{
   Eina_Bool int_ret = EINA_FALSE;

   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);

   int_ret =
     edje_object_mmap_set(wd->resize_obj, file, group);

   if (int_ret)
     {
        sd->file_set = EINA_TRUE;
        _visuals_refresh(obj, sd);
     }
   else
     ERR("failed to set edje mmap file %p, group '%s': %s",
         file, group,
         edje_load_error_str
           (edje_object_load_error_get(wd->resize_obj)));

   return int_ret;
}

EOLIAN static void
_efl_ui_layout_efl_file_mmap_get(const Eo *obj, Efl_Ui_Layout_Data *sd EINA_UNUSED, const Eina_File **file, const char **group)
{
   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
   efl_file_mmap_get(wd->resize_obj, file, group);
}

EOLIAN static Efl_Ui_Theme_Apply_Result
_efl_ui_layout_theme_set(Eo *obj, Efl_Ui_Layout_Data *sd, const char *klass, const char *group, const char *style)
{
   Eina_Bool changed = EINA_FALSE;

   if (!elm_widget_is_legacy(obj) && efl_finalized_get(obj))
     {
        ERR("Efl.Ui.Layout_theme can only be set before finalize!");
        return EFL_UI_THEME_APPLY_RESULT_FAIL;
     }

   if (sd->file_set) sd->file_set = EINA_FALSE;

   changed |= elm_widget_theme_klass_set(obj, klass);
   changed |= elm_widget_theme_element_set(obj, group);
   changed |= elm_widget_theme_style_set(obj, style);

   if (changed)
     return efl_ui_widget_theme_apply(obj);
   return EFL_UI_THEME_APPLY_RESULT_SUCCESS;
}

EOLIAN static void
_efl_ui_layout_efl_layout_signal_signal_emit(Eo *obj, Efl_Ui_Layout_Data *_pd EINA_UNUSED, const char *emission, const char *source)
{
   // Don't do anything else than call forward here
   EINA_SAFETY_ON_TRUE_RETURN(efl_invalidated_get(obj));
   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
   efl_layout_signal_emit(wd->resize_obj, emission, source);
}

EOLIAN static Eina_Bool
_efl_ui_layout_efl_layout_signal_signal_callback_add(Eo *obj, Efl_Ui_Layout_Data *_pd EINA_UNUSED, const char *emission, const char *source, Efl_Signal_Cb func, void *data)
{
   // Don't do anything else than call forward here
   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
   return efl_layout_signal_callback_add(wd->resize_obj, emission, source, func, data);
}

EOLIAN static Eina_Bool
_efl_ui_layout_efl_layout_signal_signal_callback_del(Eo *obj, Efl_Ui_Layout_Data *_pd EINA_UNUSED, const char *emission, const char *source, Edje_Signal_Cb func, void *data)
{
   // Don't do anything else than call forward here
   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
   return efl_layout_signal_callback_del(wd->resize_obj, emission, source, func, data);
}

// TODO:
// - message_send
// - message_signal_process
// and also message handler (not implemented yet as an EO interface!)

EAPI Eina_Bool
elm_layout_content_set(Evas_Object *obj, const char *swallow, Evas_Object *content)
{
   EFL_UI_LAYOUT_CHECK(obj) EINA_FALSE;
   if (!swallow)
     {
        swallow = efl_ui_widget_default_content_part_get(obj);
        if (!swallow) return EINA_FALSE;
     }
   else if (!_elm_layout_part_aliasing_eval(obj, &swallow, EINA_FALSE))
     return EINA_FALSE;

   return efl_content_set(efl_part(obj, swallow), content);
}

static Eina_Bool
_efl_ui_layout_content_set(Eo *obj, Efl_Ui_Layout_Data *sd, const char *part, Evas_Object *content)
{
   Efl_Ui_Layout_Sub_Object_Data *sub_d;
   Eina_List *l;

   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);

   EINA_LIST_FOREACH(sd->subs, l, sub_d)
     {
        if (sub_d->type == SWALLOW)
          {
             if (!strcmp(part, sub_d->part))
               {
                  if (content == sub_d->obj) goto end;
                  _eo_unparent_helper(sub_d->obj, obj);
                  evas_object_del(sub_d->obj);
                  break;
               }
             /* was previously swallowed at another part -- mimic
              * edje_object_part_swallow()'s behavior, then */
             else if (content == sub_d->obj)
               {
                  sd->subs = eina_list_remove_list(sd->subs, l);
                  _icon_signal_emit(sd, sub_d, EINA_FALSE);
                  eina_stringshare_del(sub_d->part);
                  free(sub_d);

                  _elm_widget_sub_object_redirect_to_top(obj, content);
                  break;
               }
          }
     }

   if (content)
     {
        if (!elm_widget_sub_object_add(obj, content))
          return EINA_FALSE;

        if (!edje_object_part_swallow
              (wd->resize_obj, part, content))
          {
             ERR("could not swallow %p into part '%s'", content, part);
             _elm_widget_sub_object_redirect_to_top(obj, content);
             return EINA_FALSE;
          }
        sub_d = ELM_NEW(Efl_Ui_Layout_Sub_Object_Data);
        if (!sub_d)
          {
             ERR("failed to allocate memory!");
             edje_object_part_unswallow(wd->resize_obj, content);
             _elm_widget_sub_object_redirect_to_top(obj, content);
             return EINA_FALSE;
          }
        sub_d->type = SWALLOW;
        sub_d->part = eina_stringshare_add(part);
        sub_d->obj = content;
        sd->subs = eina_list_append(sd->subs, sub_d);

        efl_parent_set(content, obj);
        _icon_signal_emit(sd, sub_d, EINA_TRUE);
     }

   elm_layout_sizing_eval(obj);

end:
   return EINA_TRUE;
}

EAPI Evas_Object *
elm_layout_content_get(const Evas_Object *obj, const char *swallow)
{
   EFL_UI_LAYOUT_CHECK(obj) NULL;
   // If the object is already dead, their shouldn't be any part in it
   if (efl_invalidated_get(obj)) return NULL;
   if (!swallow)
     {
        swallow = efl_ui_widget_default_content_part_get(obj);
        if (!swallow) return NULL;
     }
   else if (!_elm_layout_part_aliasing_eval(obj, &swallow, EINA_FALSE))
     return NULL;

   return efl_content_get(efl_part(obj, swallow));
}

static Evas_Object*
_efl_ui_layout_content_get(Eo *obj, Efl_Ui_Layout_Data *sd, const char *part)
{
   const Eina_List *l;
   Efl_Ui_Layout_Sub_Object_Data *sub_d;

   EINA_LIST_FOREACH(sd->subs, l, sub_d)
     {
        if ((sub_d->type != TEXT) && !strcmp(part, sub_d->part))
          {
             if (sub_d->type == SWALLOW)
               return sub_d->obj;
          }
     }

   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
   return efl_content_get(efl_part(wd->resize_obj, part));
}

EAPI Evas_Object *
elm_layout_content_unset(Evas_Object *obj, const char *swallow)
{
   EFL_UI_LAYOUT_CHECK(obj) NULL;
   if (!swallow)
     {
        swallow = efl_ui_widget_default_content_part_get(obj);
        if (!swallow) return NULL;
     }
   else if (!_elm_layout_part_aliasing_eval(obj, &swallow, EINA_FALSE))
     return NULL;

   return efl_content_unset(efl_part(obj, swallow));
}

static Evas_Object*
_efl_ui_layout_content_unset(Eo *obj, Efl_Ui_Layout_Data *sd, const char *part)
{
   Efl_Ui_Layout_Sub_Object_Data *sub_d;
   Eina_List *l;

   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);

   EINA_LIST_FOREACH(sd->subs, l, sub_d)
     {
        if ((sub_d->type == SWALLOW) && (!strcmp(part, sub_d->part)))
          {
             Evas_Object *content;

             if (!sub_d->obj) return NULL;

             content = sub_d->obj; /* sub_d will die in
                                    * _efl_ui_layout_smart_widget_sub_object_del */

             if (!_elm_widget_sub_object_redirect_to_top(obj, content))
               {
                  ERR("could not remove sub object %p from %p", content, obj);
                  return NULL;
               }

             edje_object_part_unswallow
               (wd->resize_obj, content);
             EINA_LIST_FOREACH(sd->subs, l, sub_d)
               {
                  if (sub_d->obj == content)
                    {
                       sd->subs = eina_list_remove_list(sd->subs, l);
                       _icon_signal_emit(sd, sub_d, EINA_FALSE);
                       eina_stringshare_del(sub_d->part);
                       free(sub_d);
                       break;
                    }
               }
             _eo_unparent_helper(content, obj);
             return content;
          }
     }

   return NULL;
}

EOLIAN static Eina_Bool
_efl_ui_layout_efl_container_content_remove(Eo *obj, Efl_Ui_Layout_Data *sd EINA_UNUSED,
                                         Efl_Gfx_Entity *content)
{
   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);

   if (!_elm_widget_sub_object_redirect_to_top(obj, content))
     {
        ERR("could not remove sub object %p from %p", content, obj);
        return EINA_FALSE;
     }
   edje_object_part_unswallow(wd->resize_obj, content);
   _eo_unparent_helper(content, obj);

   return EINA_TRUE;
}

/* legacy only - eo is iterator */
EAPI Eina_List *
elm_layout_content_swallow_list_get(const Evas_Object *obj)
{
   EFL_UI_LAYOUT_CHECK(obj) NULL;
   Eina_List *ret = NULL;
   Efl_Ui_Layout_Sub_Object_Data *sub_d = NULL;
   Efl_Ui_Layout_Data *sd = efl_data_scope_get(obj, MY_CLASS);
   Eina_List *l = NULL;

   EINA_LIST_FOREACH(sd->subs, l, sub_d)
     {
        if (sub_d->type == SWALLOW)
          ret = eina_list_append(ret, sub_d->obj);
     }

   return ret;
}

static Eina_Bool
_sub_iterator_next(Efl_Ui_Layout_Sub_Iterator *it, void **data)
{
   Efl_Ui_Layout_Sub_Object_Data *sub;

   if (!eina_iterator_next(it->real_iterator, (void **)&sub))
     return EINA_FALSE;

   if (data) *data = sub->obj;
   return EINA_TRUE;
}

static Efl_Ui_Layout *
_sub_iterator_get_container(Efl_Ui_Layout_Sub_Iterator *it)
{
   return it->object;
}

static void
_sub_iterator_free(Efl_Ui_Layout_Sub_Iterator *it)
{
   eina_iterator_free(it->real_iterator);
   free(it);
}

static Eina_Iterator *
_sub_iterator_create(Eo *eo_obj, Efl_Ui_Layout_Data *sd)
{
   Efl_Ui_Layout_Sub_Iterator *it;

   it = calloc(1, sizeof(*it));
   if (!it) return NULL;

   EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);

   it->real_iterator = eina_list_iterator_new(sd->subs);
   it->iterator.version = EINA_ITERATOR_VERSION;
   it->iterator.next = FUNC_ITERATOR_NEXT(_sub_iterator_next);
   it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_sub_iterator_get_container);
   it->iterator.free = FUNC_ITERATOR_FREE(_sub_iterator_free);
   it->object = eo_obj;

   return &it->iterator;
}

EOLIAN static Eina_Iterator *
_efl_ui_layout_efl_container_content_iterate(Eo *eo_obj EINA_UNUSED, Efl_Ui_Layout_Data *sd)
{
   return _sub_iterator_create(eo_obj, sd);
}

EOLIAN static int
_efl_ui_layout_efl_container_content_count(Eo *eo_obj EINA_UNUSED, Efl_Ui_Layout_Data *sd)
{
   return eina_list_count(sd->subs);
}

static Eina_Bool
_efl_ui_layout_text_generic_set(Eo *obj, Efl_Ui_Layout_Data *sd, const char *part, const char *text, Eina_Bool is_markup)
{
   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);

   Efl_Ui_Layout_Sub_Object_Data *sub_d = NULL;
   Eina_List *l;

   EINA_LIST_FOREACH(sd->subs, l, sub_d)
     {
        if ((sub_d->type == TEXT) && (!strcmp(part, sub_d->part)))
          {
             if