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;
#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);
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. */
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;
/* 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)
{
#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.
*/
struct _Edje
{
+ const Edje_Smart_Api *api;
const char *path;
const char *group;
const char *parent;
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);
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);
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;
{
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);
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);
+}
_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;