diff --git a/legacy/elementary/data/edje_externals/Makefile.am b/legacy/elementary/data/edje_externals/Makefile.am index bc54ae27c0..4fd17a84e2 100644 --- a/legacy/elementary/data/edje_externals/Makefile.am +++ b/legacy/elementary/data/edje_externals/Makefile.am @@ -9,6 +9,7 @@ files_DATA = icons.edj EXTRA_DIST = \ icons.edc \ +ico_anchorblock.png \ ico_anchorview.png \ ico_bubble.png \ ico_button.png \ diff --git a/legacy/elementary/data/edje_externals/ico_anchorblock.png b/legacy/elementary/data/edje_externals/ico_anchorblock.png new file mode 100644 index 0000000000..a62138e97a Binary files /dev/null and b/legacy/elementary/data/edje_externals/ico_anchorblock.png differ diff --git a/legacy/elementary/data/edje_externals/ico_anchorview.png b/legacy/elementary/data/edje_externals/ico_anchorview.png index a62138e97a..7615015d53 100644 Binary files a/legacy/elementary/data/edje_externals/ico_anchorview.png and b/legacy/elementary/data/edje_externals/ico_anchorview.png differ diff --git a/legacy/elementary/data/edje_externals/icons.edc b/legacy/elementary/data/edje_externals/icons.edc index fbf1998f06..de19422fd8 100644 --- a/legacy/elementary/data/edje_externals/icons.edc +++ b/legacy/elementary/data/edje_externals/icons.edc @@ -10,6 +10,7 @@ collections { group { name: "ico_"_name; \ image.normal: "ico_"_name".png"; \ }}}}} +ICON("anchorblock") ICON("anchorview") ICON("bubble") ICON("button") diff --git a/legacy/elementary/src/edje_externals/Makefile.am b/legacy/elementary/src/edje_externals/Makefile.am index 979fb0e02b..067ec707b6 100644 --- a/legacy/elementary/src/edje_externals/Makefile.am +++ b/legacy/elementary/src/edje_externals/Makefile.am @@ -26,6 +26,7 @@ pkg_LTLIBRARIES = elm.la elm_la_SOURCES = private.h \ modules.inc \ elm.c \ +elm_anchorblock.c \ elm_anchorview.c \ elm_bubble.c \ elm_button.c \ diff --git a/legacy/elementary/src/edje_externals/elm_anchorblock.c b/legacy/elementary/src/edje_externals/elm_anchorblock.c new file mode 100644 index 0000000000..cb5dc9196a --- /dev/null +++ b/legacy/elementary/src/edje_externals/elm_anchorblock.c @@ -0,0 +1,95 @@ +#include "private.h" + +typedef struct _Elm_Params_Anchorblock +{ + const char *text; +} Elm_Params_Anchorblock; + +static void +external_anchorblock_state_set(void *data __UNUSED__, Evas_Object *obj, const void *from_params, const void *to_params, float pos __UNUSED__) +{ + const Elm_Params_Anchorblock *p; + + if (to_params) p = to_params; + else if (from_params) p = from_params; + else return; + + if (p->text) + { + elm_anchorblock_text_set(obj, p->text); + } +} + +static Eina_Bool +external_anchorblock_param_set(void *data __UNUSED__, Evas_Object *obj, const Edje_External_Param *param) +{ + if (!strcmp(param->name, "text")) + { + if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING) + { + elm_anchorblock_text_set(obj, param->s); + return EINA_TRUE; + } + } + + ERR("unknown parameter '%s' of type '%s'", + param->name, edje_external_param_type_str(param->type)); + + return EINA_FALSE; +} + +static Eina_Bool +external_anchorblock_param_get(void *data __UNUSED__, const Evas_Object *obj, Edje_External_Param *param) +{ + if (!strcmp(param->name, "text")) + { + if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING) + { + param->s = elm_anchorblock_text_get(obj); + return EINA_TRUE; + } + } + + ERR("unknown parameter '%s' of type '%s'", + param->name, edje_external_param_type_str(param->type)); + + return EINA_FALSE; +} + +static void * +external_anchorblock_params_parse(void *data __UNUSED__, Evas_Object *obj __UNUSED__, const Eina_List *params) +{ + Elm_Params_Anchorblock *mem; + Edje_External_Param *param; + const Eina_List *l; + + mem = calloc(1, sizeof(Elm_Params_Anchorblock)); + if (!mem) + return NULL; + + EINA_LIST_FOREACH(params, l, param) + { + if (!strcmp(param->name, "text")) + mem->text = eina_stringshare_add(param->s); + } + + return mem; +} + +static void +external_anchorblock_params_free(void *params) +{ + Elm_Params_Anchorblock *mem = params; + + if (mem->text) + eina_stringshare_del(mem->text); + free(mem); +} + +static Edje_External_Param_Info external_anchorblock_params[] = { + EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT("text", "some text"), + EDJE_EXTERNAL_PARAM_INFO_SENTINEL +}; + +DEFINE_EXTERNAL_ICON_ADD(anchorblock, "anchorblock") +DEFINE_EXTERNAL_TYPE_SIMPLE(anchorblock, "Anchorblock"); diff --git a/legacy/elementary/src/edje_externals/modules.inc b/legacy/elementary/src/edje_externals/modules.inc index 0d304413e8..6517ba10a4 100644 --- a/legacy/elementary/src/edje_externals/modules.inc +++ b/legacy/elementary/src/edje_externals/modules.inc @@ -1,3 +1,4 @@ +DEFINE_TYPE(anchorblock) DEFINE_TYPE(anchorview) DEFINE_TYPE(bubble) DEFINE_TYPE(button) diff --git a/legacy/elementary/src/lib/Elementary.h.in b/legacy/elementary/src/lib/Elementary.h.in index 352c3e2dbe..6d1a602ba9 100644 --- a/legacy/elementary/src/lib/Elementary.h.in +++ b/legacy/elementary/src/lib/Elementary.h.in @@ -658,6 +658,8 @@ extern "C" { }; EAPI Evas_Object *elm_anchorview_add(Evas_Object *parent); EAPI void elm_anchorview_text_set(Evas_Object *obj, const char *text); + EAPI const char *elm_anchorview_text_get(Evas_Object *obj); + EAPI void elm_anchorview_hover_parent_set(Evas_Object *obj, Evas_Object *parent); EAPI void elm_anchorview_hover_style_set(Evas_Object *obj, const char *style); EAPI void elm_anchorview_hover_end(Evas_Object *obj); @@ -683,6 +685,7 @@ extern "C" { }; EAPI Evas_Object *elm_anchorblock_add(Evas_Object *parent); EAPI void elm_anchorblock_text_set(Evas_Object *obj, const char *text); + EAPI const char *elm_anchorblock_text_get(Evas_Object *obj); EAPI void elm_anchorblock_hover_parent_set(Evas_Object *obj, Evas_Object *parent); EAPI void elm_anchorblock_hover_style_set(Evas_Object *obj, const char *style); EAPI void elm_anchorblock_hover_end(Evas_Object *obj); diff --git a/legacy/elementary/src/lib/elc_anchorblock.c b/legacy/elementary/src/lib/elc_anchorblock.c index b25cf7c76e..a2bb10de7b 100644 --- a/legacy/elementary/src/lib/elc_anchorblock.c +++ b/legacy/elementary/src/lib/elc_anchorblock.c @@ -26,6 +26,15 @@ struct _Widget_Data }; static const char *widtype = NULL; + +static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked"; +static const Evas_Smart_Cb_Description _signals[] = { + {SIG_ANCHOR_CLICKED, ""}, /* TODO: declare the type properly, as data is + * being passed + */ + {NULL, NULL} +}; + static void _del_pre_hook(Evas_Object *obj); static void _del_hook(Evas_Object *obj); static void _sizing_eval(Evas_Object *obj); @@ -116,7 +125,7 @@ _anchor_clicked(void *data, Evas_Object *obj, void *event_info) if (py < (y + (h / 3))) ei.hover_top = 0; ei.hover_bottom = 1; if (py > (y + ((h * 2) / 3))) ei.hover_bottom = 0; - evas_object_smart_callback_call(data, "anchor,clicked", &ei); + evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, &ei); evas_object_smart_callback_add(wd->hover, "clicked", _hover_clicked, data); evas_object_show(wd->hover); } @@ -198,6 +207,26 @@ elm_anchorblock_text_set(Evas_Object *obj, const char *text) _sizing_eval(obj); } +/** + * Get the markup text set for the anchorblock + * + * This retrieves back the string set by @c elm_anchorblock_text_set(). + * + * @param obj The anchorblock object + * @return text The markup text set or @c NULL, either if it was not set + * or an error ocurred + * + * @ingroup Anchorblock + */ +EAPI const char* +elm_anchorblock_text_get(Evas_Object *obj) +{ + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return NULL; + return elm_entry_entry_get(wd->entry); +} + /** * Set the parent of the hover popup *