Make the Edje Smart inheritable.
authorsachiel <sachiel@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 8 Apr 2010 19:21:54 +0000 (19:21 +0000)
committersachiel <sachiel@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 8 Apr 2010 19:21:54 +0000 (19:21 +0000)
Pretty much moving some things around and extending the smart class
to allow overloading some common functions. Edje_Edit will make use
of this.

git-svn-id: http://svn.enlightenment.org/svn/e/trunk/edje@47841 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/edje_edit.c
src/lib/edje_load.c
src/lib/edje_main.c
src/lib/edje_private.h
src/lib/edje_smart.c
src/lib/edje_util.c

index edee6c6..02b49a8 100644 (file)
@@ -3642,7 +3642,7 @@ edje_edit_state_external_param_bool_get(Evas_Object *obj, const char *part, cons
    EINA_LIST_FOREACH(pd->external_params, l, p)
       if (!strcmp(p->name, param))
        {
-          if (p->type != EDJE_EXTERNAL_PARAM_TYPE_INT)
+          if (p->type != EDJE_EXTERNAL_PARAM_TYPE_BOOL)
             return EINA_FALSE;
           if (val)
             *val = p->i;
index 69e711f..00177bc 100644 (file)
@@ -10,7 +10,6 @@ static Eina_Bool _edje_file_collection_hash_foreach(const Eina_Hash *hash, const
 #ifdef EDJE_PROGRAM_CACHE
 static Eina_Bool  _edje_collection_free_prog_cache_matches_free_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata);
 #endif
-static int _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *group, Eina_List *group_path);
 static void _edje_object_pack_item_hints_set(Evas_Object *obj, Edje_Pack_Element *it);
 static void _cb_signal_repeat(void *data, Evas_Object *obj, const char *signal, const char *source);
 
@@ -33,7 +32,12 @@ static Eina_List *_edje_swallows_collect(Edje *ed);
 EAPI Eina_Bool
 edje_object_file_set(Evas_Object *obj, const char *file, const char *group)
 {
-   return _edje_object_file_set_internal(obj, file, group, NULL);
+   Edje *ed;
+
+   ed = _edje_fetch(obj);
+   if (!ed)
+     return EINA_FALSE;
+   return ed->api->file_set(obj, file, group);
 }
 
 /* FIXDOC: Verify/expand doc. */
@@ -272,7 +276,7 @@ _edje_programs_patterns_init(Edje *ed)
    ssp->sources_patterns = edje_match_programs_source_init(ssp->globing);
 }
 
-static int
+int
 _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *group, Eina_List *group_path)
 {
    Edje *ed;
index ea7e2cf..dbbeb0d 100644 (file)
@@ -200,25 +200,6 @@ edje_shutdown(void)
 
 /* Private Routines */
 
-Edje *
-_edje_add(Evas_Object *obj)
-{
-   Edje *ed;
-
-   ed = calloc(1, sizeof(Edje));
-   if (!ed) return NULL;
-   ed->evas = evas_object_evas_get(obj);
-   ed->clipper = evas_object_rectangle_add(ed->evas);
-   evas_object_smart_member_add(ed->clipper, obj);
-   evas_object_color_set(ed->clipper, 255, 255, 255, 255);
-   evas_object_move(ed->clipper, -10000, -10000);
-   evas_object_resize(ed->clipper, 20000, 20000);
-   evas_object_pass_events_set(ed->clipper, 1);
-   ed->have_objects = 1;
-   ed->references = 1;
-   return ed;
-}
-
 void
 _edje_del(Edje *ed)
 {
index e4c1794..3d1d3f2 100644 (file)
@@ -111,6 +111,26 @@ EAPI extern int _edje_default_log_dom ;
 
 #endif
 
+/* Inheritable Edje Smart API. For now private so only Edje Edit makes
+ * use of this, but who knows what will be possible in the future */
+#define EDJE_SMART_API_VERSION 1
+
+typedef struct _Edje_Smart_Api Edje_Smart_Api;
+
+struct _Edje_Smart_Api
+{
+   Evas_Smart_Class base;
+   int version;
+   Eina_Bool (*file_set)(Evas_Object *obj, const char *file, const char *group);
+};
+
+/* Basic macro to init the Edje Smart API */
+#define EDJE_SMART_API_INIT(smart_class_init) {smart_class_init, EDJE_SMART_API_VERSION, NULL}
+
+#define EDJE_SMART_API_INIT_NULL EDJE_SMART_API_INIT(EVAS_SMART_CLASS_INIT_NULL)
+#define EDJE_SMART_API_INIT_VERSION EDJE_SMART_API_INIT(EVAS_SMART_CLASS_INIT_VERSION)
+#define EDJE_SMART_API_INIT_NAME_VERSION(name) EDJE_SMART_API_INIT(EVAS_SMART_CLASS_INIT_NAME_VERSION(name))
+
 /* increment this when the EET data descriptors have changed and old
  * EETs cannot be loaded/used correctly anymore.
  */
@@ -766,6 +786,7 @@ typedef struct _Edje_Signals_Sources_Patterns Edje_Signals_Sources_Patterns;
 
 struct _Edje
 {
+   const Edje_Smart_Api *api;
    const char           *path;
    const char           *group;
    const char           *parent;
@@ -1247,6 +1268,8 @@ void  _edje_callbacks_focus_del(Evas_Object *obj, Edje *ed);
 void  _edje_edd_init(void);
 void  _edje_edd_shutdown(void);
 
+int _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *group, Eina_List *group_path);
+
 void  _edje_file_add(Edje *ed);
 void  _edje_file_del(Edje *ed);
 void  _edje_file_free(Edje_File *edf);
@@ -1254,8 +1277,9 @@ void  _edje_file_cache_shutdown(void);
 void  _edje_collection_free(Edje_File *edf, Edje_Part_Collection *ec);
 void  _edje_collection_free_part_description_free(Edje_Part_Description *desc, Eina_Bool free_strings);
 
+void  _edje_object_smart_set(Edje_Smart_Api *sc);
+const Edje_Smart_Api * _edje_object_smart_class_get(void);
 
-Edje *_edje_add(Evas_Object *obj);
 void  _edje_del(Edje *ed);
 void  _edje_ref(Edje *ed);
 void  _edje_unref(Edje *ed);
index 2429b04..ba6f1b8 100644 (file)
@@ -15,6 +15,9 @@ static void _edje_smart_clip_set(Evas_Object * obj, Evas_Object * clip);
 static void _edje_smart_clip_unset(Evas_Object * obj);
 static void _edje_smart_calculate(Evas_Object * obj);
 
+static Eina_Bool _edje_smart_file_set(Evas_Object *obj, const char *file, const char *group);
+
+static Edje_Smart_Api _edje_smart_class = EDJE_SMART_API_INIT_NAME_VERSION("edje");
 static Evas_Smart *_edje_smart = NULL;
 
 Eina_List *_edje_edjes = NULL;
@@ -33,38 +36,79 @@ edje_object_add(Evas *evas)
 {
    if (!_edje_smart)
      {
-        static const Evas_Smart_Class sc =
-         {
-            "edje",
-              EVAS_SMART_CLASS_VERSION,
-              _edje_smart_add,
-              _edje_smart_del,
-              _edje_smart_move,
-              _edje_smart_resize,
-              _edje_smart_show,
-              _edje_smart_hide,
-              _edje_smart_color_set,
-              _edje_smart_clip_set,
-              _edje_smart_clip_unset,
-              _edje_smart_calculate,
-              NULL,
-              NULL,
-              NULL
-         };
-       _edje_smart = evas_smart_class_new(&sc);
+       _edje_object_smart_set(&_edje_smart_class);
+       _edje_smart = evas_smart_class_new((Evas_Smart_Class *)&_edje_smart_class);
      }
    return evas_object_smart_add(evas, _edje_smart);
 }
 
+void
+_edje_object_smart_set(Edje_Smart_Api *sc)
+{
+   if (!sc)
+     return;
+
+   sc->base.add = _edje_smart_add;
+   sc->base.del = _edje_smart_del;
+   sc->base.move = _edje_smart_move;
+   sc->base.resize = _edje_smart_resize;
+   sc->base.show = _edje_smart_show;
+   sc->base.hide = _edje_smart_hide;
+   sc->base.color_set = _edje_smart_color_set;
+   sc->base.clip_set = _edje_smart_clip_set;
+   sc->base.clip_unset = _edje_smart_clip_unset;
+   sc->base.calculate = _edje_smart_calculate;
+   sc->base.member_add = NULL;
+   sc->base.member_del = NULL;
+   sc->file_set = _edje_smart_file_set;
+}
+
+const Edje_Smart_Api *
+_edje_object_smart_class_get(void)
+{
+   static const Edje_Smart_Api *class = NULL;
+
+   if (class)
+     return class;
+
+   _edje_object_smart_set(&_edje_smart_class);
+   class = &_edje_smart_class;
+
+   return class;
+}
+
 /* Private Routines */
 static void
 _edje_smart_add(Evas_Object *obj)
 {
    Edje *ed;
 
-   ed = _edje_add(obj);
-   if (!ed) return;
-   evas_object_smart_data_set(obj, ed);
+   ed = evas_object_smart_data_get(obj);
+   if (!ed)
+     {
+       const Evas_Smart *smart;
+       const Evas_Smart_Class *sc;
+
+       ed = calloc(1, sizeof(Edje));
+       if (!ed) return;
+
+       smart = evas_object_smart_smart_get(obj);
+       sc = evas_smart_class_get(smart);
+       ed->api = (const Edje_Smart_Api *)sc;
+
+       evas_object_smart_data_set(obj, ed);
+     }
+
+   ed->evas = evas_object_evas_get(obj);
+   ed->clipper = evas_object_rectangle_add(ed->evas);
+   evas_object_smart_member_add(ed->clipper, obj);
+   evas_object_color_set(ed->clipper, 255, 255, 255, 255);
+   evas_object_move(ed->clipper, -10000, -10000);
+   evas_object_resize(ed->clipper, 20000, 20000);
+   evas_object_pass_events_set(ed->clipper, 1);
+   ed->have_objects = 1;
+   ed->references = 1;
+
    evas_object_geometry_get(obj, &(ed->x), &(ed->y), &(ed->w), &(ed->h));
    ed->obj = obj;
    _edje_edjes = eina_list_append(_edje_edjes, obj);
@@ -273,3 +317,9 @@ _edje_smart_calculate(Evas_Object *obj)
    if (!ed) return;
    _edje_recalc_do(ed);
 }
+
+static Eina_Bool
+_edje_smart_file_set(Evas_Object *obj, const char *file, const char *group)
+{
+   return _edje_object_file_set_internal(obj, file, group, NULL);
+}
index d958777..1e5ea92 100644 (file)
@@ -4337,11 +4337,9 @@ Edje *
 _edje_fetch(const Evas_Object *obj)
 {
    Edje *ed;
-   char *type;
 
-   type = (char *)evas_object_type_get(obj);
-   if (!type) return NULL;
-   if (strcmp(type, "edje")) return NULL;
+   if (!evas_object_smart_type_check(obj, "edje"))
+     return NULL;
    ed = evas_object_smart_data_get(obj);
    if ((ed) && (ed->delete_me)) return NULL;
    return ed;