Elm Ctxpopup item: Migrate to Eo

This commit is contained in:
Daniel Zaoui 2014-09-28 08:14:47 +03:00
parent 0308cb0993
commit 1db002db3a
5 changed files with 157 additions and 125 deletions

View File

@ -611,7 +611,8 @@ elm_hoversel_item.eo \
elm_segment_control_item.eo \
elm_slideshow_item.eo \
elm_flipselector_item.eo \
elm_menu_item.eo
elm_menu_item.eo \
elm_ctxpopup_item.eo
elm_eolian_c = $(elm_eolian_files:%.eo=%.eo.c)
elm_eolian_h = $(elm_eolian_files:%.eo=%.eo.h)
@ -730,7 +731,8 @@ elementaryeolianfiles_DATA = \
elm_segment_control_item.eo \
elm_slideshow_item.eo \
elm_flipselector_item.eo \
elm_menu_item.eo
elm_menu_item.eo \
elm_ctxpopup_item.eo
EXTRA_DIST += ${elementaryeolianfiles_DATA}

View File

@ -5,6 +5,7 @@
#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
#define ELM_INTERFACE_ATSPI_WIDGET_ACTION_PROTECTED
#define ELM_WIDGET_ITEM_PROTECTED
#include <Elementary.h>
#include "elm_priv.h"
@ -34,10 +35,6 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
static Eina_Bool _key_action_move(Evas_Object *obj, const char *params);
static Eina_Bool _key_action_escape(Evas_Object *obj, const char *params);
static Elm_Ctxpopup_Item* _item_new(Eo *obj,
Elm_Ctxpopup_Data *sd,
Evas_Smart_Cb func,
const void *data);
static const Elm_Action key_actions[] = {
{"move", _key_action_move},
@ -49,12 +46,12 @@ EOLIAN static Eina_Bool
_elm_ctxpopup_elm_widget_translate(Eo *obj, Elm_Ctxpopup_Data *sd)
{
Eina_List *l;
Elm_Ctxpopup_Item *it;
Elm_Object_Item *it;
if (sd->auto_hide) evas_object_hide(obj);
EINA_LIST_FOREACH(sd->items, l, it)
elm_widget_item_translate(it);
eo_do((Eo *)it, elm_wdg_item_translate());
eo_do_super(obj, MY_CLASS, elm_obj_widget_translate());
@ -849,17 +846,14 @@ _elm_ctxpopup_elm_container_content_unset(Eo *obj, Elm_Ctxpopup_Data *sd, const
return content;
}
static void
_item_text_set_hook(Elm_Object_Item *it,
const char *part,
const char *label)
EOLIAN static void
_elm_ctxpopup_item_elm_widget_item_part_text_set(Eo *eo_ctxpopup_it EINA_UNUSED,
Elm_Ctxpopup_Item_Data *ctxpopup_it,
const char *part,
const char *label)
{
Elm_Ctxpopup_Item *ctxpopup_it;
if ((part) && (strcmp(part, "default"))) return;
ctxpopup_it = (Elm_Ctxpopup_Item *)it;
ELM_CTXPOPUP_DATA_GET(WIDGET(ctxpopup_it), sd);
elm_object_item_part_text_set(ctxpopup_it->list_item, "default", label);
@ -868,31 +862,26 @@ _item_text_set_hook(Elm_Object_Item *it,
if (sd->visible) elm_layout_sizing_eval(WIDGET(ctxpopup_it));
}
static const char *
_item_text_get_hook(const Elm_Object_Item *it,
const char *part)
EOLIAN static const char *
_elm_ctxpopup_item_elm_widget_item_part_text_get(Eo *eo_ctxpopup_it EINA_UNUSED,
Elm_Ctxpopup_Item_Data *ctxpopup_it,
const char *part)
{
Elm_Ctxpopup_Item *ctxpopup_it;
if (part && strcmp(part, "default")) return NULL;
ctxpopup_it = (Elm_Ctxpopup_Item *)it;
return elm_object_item_part_text_get(ctxpopup_it->list_item, "default");
}
static void
_item_content_set_hook(Elm_Object_Item *it,
const char *part,
Evas_Object *content)
EOLIAN static void
_elm_ctxpopup_item_elm_widget_item_part_content_set(Eo *eo_ctxpopup_it EINA_UNUSED,
Elm_Ctxpopup_Item_Data *ctxpopup_it,
const char *part,
Evas_Object *content)
{
Elm_Ctxpopup_Item *ctxpopup_it;
if ((part) && (strcmp(part, "icon"))
&& (strcmp(part, "start"))
&& (strcmp(part, "end"))) return;
ctxpopup_it = (Elm_Ctxpopup_Item *)it;
ELM_CTXPOPUP_DATA_GET(WIDGET(ctxpopup_it), sd);
if ((part) && (!strcmp(part, "end")))
@ -906,39 +895,35 @@ _item_content_set_hook(Elm_Object_Item *it,
if (sd->visible) elm_layout_sizing_eval(WIDGET(ctxpopup_it));
}
static Evas_Object *
_item_content_get_hook(const Elm_Object_Item *it,
const char *part)
EOLIAN static Evas_Object *
_elm_ctxpopup_item_elm_widget_item_part_content_get(Eo *eo_ctxpopup_it EINA_UNUSED,
Elm_Ctxpopup_Item_Data *ctxpopup_it,
const char *part)
{
Elm_Ctxpopup_Item *ctxpopup_it;
if (part && strcmp(part, "icon") && strcmp(part, "start")
&& strcmp(part, "end")) return NULL;
ctxpopup_it = (Elm_Ctxpopup_Item *)it;
if (part && !strcmp(part, "end"))
return elm_object_item_part_content_get(ctxpopup_it->list_item, "end");
else
return elm_object_item_part_content_get(ctxpopup_it->list_item, "start");
}
static void
_item_disable_hook(Elm_Object_Item *it)
EOLIAN static void
_elm_ctxpopup_item_elm_widget_item_disable(Eo *eo_ctxpopup_it,
Elm_Ctxpopup_Item_Data *ctxpopup_it)
{
Elm_Ctxpopup_Item *ctxpopup_it = (Elm_Ctxpopup_Item *)it;
elm_object_item_disabled_set
(ctxpopup_it->list_item, elm_widget_item_disabled_get(ctxpopup_it));
(ctxpopup_it->list_item, eo_do(eo_ctxpopup_it, elm_wdg_item_disabled_get()));
}
static void
_item_signal_emit_hook(Elm_Object_Item *it,
const char *emission,
const char *source)
EOLIAN static void
_elm_ctxpopup_item_elm_widget_item_signal_emit(Eo *eo_ctxpopup_it EINA_UNUSED,
Elm_Ctxpopup_Item_Data *ctxpopup_it,
const char *emission,
const char *source)
{
Elm_Ctxpopup_Item *ctxpopup_it = (Elm_Ctxpopup_Item *)it;
elm_object_item_signal_emit(ctxpopup_it->list_item, emission, source);
}
@ -1045,11 +1030,11 @@ _list_del(Elm_Ctxpopup_Data *sd)
ELM_SAFE_FREE(sd->list, evas_object_del);
}
static Eina_Bool
_item_del_pre_hook(Elm_Object_Item *it)
EOLIAN static Eina_Bool
_elm_ctxpopup_item_elm_widget_item_del_pre(Eo *eo_ctxpopup_it,
Elm_Ctxpopup_Item_Data *ctxpopup_it)
{
Evas_Object *list;
Elm_Ctxpopup_Item *ctxpopup_it = (Elm_Ctxpopup_Item *)it;
ELM_CTXPOPUP_DATA_GET(WIDGET(ctxpopup_it), sd);
@ -1060,16 +1045,16 @@ _item_del_pre_hook(Elm_Object_Item *it)
if (eina_list_count(elm_list_items_get(list)) < 2)
{
if (ctxpopup_it->list_item)
elm_widget_item_del(ctxpopup_it->list_item);
sd->items = eina_list_remove(sd->items, ctxpopup_it);
elm_object_item_del(ctxpopup_it->list_item);
sd->items = eina_list_remove(sd->items, eo_ctxpopup_it);
evas_object_hide(WIDGET(ctxpopup_it));
return EINA_TRUE;
}
if (ctxpopup_it->list_item)
elm_widget_item_del(ctxpopup_it->list_item);
sd->items = eina_list_remove(sd->items, ctxpopup_it);
elm_object_item_del(ctxpopup_it->list_item);
sd->items = eina_list_remove(sd->items, eo_ctxpopup_it);
if (sd->list_visible) elm_layout_sizing_eval(WIDGET(ctxpopup_it));
return EINA_TRUE;
@ -1146,7 +1131,7 @@ _elm_ctxpopup_evas_object_smart_add(Eo *obj, Elm_Ctxpopup_Data *priv)
EOLIAN static void
_elm_ctxpopup_evas_object_smart_del(Eo *obj, Elm_Ctxpopup_Data *sd)
{
Elm_Ctxpopup_Item *it;
Elm_Object_Item *it;
evas_object_event_callback_del_full
(sd->box, EVAS_CALLBACK_RESIZE, _on_content_resized, obj);
@ -1157,7 +1142,7 @@ _elm_ctxpopup_evas_object_smart_del(Eo *obj, Elm_Ctxpopup_Data *sd)
ELM_SAFE_FREE(sd->bg, evas_object_del);
EINA_LIST_FREE(sd->items, it)
elm_widget_item_free(it);
eo_del((Eo *)it);
eo_do_super(obj, MY_CLASS, evas_obj_smart_del());
}
@ -1257,26 +1242,35 @@ _elm_ctxpopup_horizontal_get(Eo *obj EINA_UNUSED, Elm_Ctxpopup_Data *sd)
static void
_item_wrap_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Elm_Ctxpopup_Item *item = data;
Elm_Ctxpopup_Item_Data *item = data;
if (!item->wcb.org_func_cb) return;
item->wcb.org_func_cb((void *)item->wcb.org_data, item->wcb.cobj, item);
item->wcb.org_func_cb((void *)item->wcb.org_data, item->wcb.cobj, EO_OBJ(item));
}
EOLIAN static void
_elm_ctxpopup_item_eo_base_constructor(Eo *obj, Elm_Ctxpopup_Item_Data *it)
{
eo_do_super(obj, ELM_CTXPOPUP_ITEM_CLASS, eo_constructor());
it->base = eo_data_scope_get(obj, ELM_WIDGET_ITEM_CLASS);
}
EOLIAN static Elm_Object_Item*
_elm_ctxpopup_item_append(Eo *obj, Elm_Ctxpopup_Data *sd, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data)
{
Elm_Ctxpopup_Item *item;
Eo *eo_item;
item = _item_new(obj, sd, func, data);
if (!item) return NULL;
eo_item = eo_add(ELM_CTXPOPUP_ITEM_CLASS, obj, elm_obj_ctxpopup_item_init(func, data));
if (!eo_item) return NULL;
ELM_CTXPOPUP_ITEM_DATA_GET(eo_item, item);
item->list_item =
elm_list_item_append(sd->list, label, icon, NULL, _item_wrap_cb, item);
sd->items = eina_list_append(sd->items, item);
sd->items = eina_list_append(sd->items, eo_item);
if (sd->visible) elm_layout_sizing_eval(obj);
return (Elm_Object_Item *)item;
return (Elm_Object_Item *)eo_item;
}
EOLIAN static void
@ -1356,32 +1350,38 @@ _elm_ctxpopup_last_item_get(Eo *obj EINA_UNUSED, Elm_Ctxpopup_Data *sd)
EOLIAN static Elm_Object_Item*
_elm_ctxpopup_item_prepend(Eo *obj, Elm_Ctxpopup_Data *sd, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data)
{
Elm_Ctxpopup_Item *item;
Eo *eo_item;
item = _item_new(obj, sd, func, data);
if (!item) return NULL;
eo_item = eo_add(ELM_CTXPOPUP_ITEM_CLASS, obj, elm_obj_ctxpopup_item_init(func, data));
if (!eo_item) return NULL;
ELM_CTXPOPUP_ITEM_DATA_GET(eo_item, item);
item->list_item =
elm_list_item_prepend(sd->list, label, icon, NULL, _item_wrap_cb, item);
sd->items = eina_list_prepend(sd->items, item);
sd->items = eina_list_prepend(sd->items, eo_item);
if (sd->visible) elm_layout_sizing_eval(obj);
return (Elm_Object_Item *)item;
return (Elm_Object_Item *)eo_item;
}
EAPI Elm_Object_Item *
elm_ctxpopup_item_prev_get(const Elm_Object_Item *it)
{
Eina_List *l;
Elm_Ctxpopup_Item *item = (Elm_Ctxpopup_Item *)it;
return eo_do((Eo *)it, elm_obj_ctxpopup_item_prev_get());
}
EOLIAN static Elm_Object_Item *
_elm_ctxpopup_item_prev_get(Eo *eo_item EINA_UNUSED, Elm_Ctxpopup_Item_Data *item)
{
Eina_List *l;
ELM_CTXPOPUP_ITEM_CHECK_OR_RETURN(it, NULL);
ELM_CTXPOPUP_DATA_GET(WIDGET(item), sd);
if (!sd->items) return NULL;
l = eina_list_data_find_list(sd->items, it);
l = eina_list_data_find_list(sd->items, eo_item);
if (l && l->prev) return eina_list_data_get(l->prev);
return NULL;
@ -1390,39 +1390,32 @@ elm_ctxpopup_item_prev_get(const Elm_Object_Item *it)
EAPI Elm_Object_Item *
elm_ctxpopup_item_next_get(const Elm_Object_Item *it)
{
Eina_List *l;
Elm_Ctxpopup_Item *item = (Elm_Ctxpopup_Item *)it;
return eo_do((Eo *)it, elm_obj_ctxpopup_item_next_get());
}
EOLIAN static Elm_Object_Item *
_elm_ctxpopup_item_next_get(Eo *eo_item EINA_UNUSED, Elm_Ctxpopup_Item_Data *item)
{
Eina_List *l;
ELM_CTXPOPUP_ITEM_CHECK_OR_RETURN(it, NULL);
ELM_CTXPOPUP_DATA_GET(WIDGET(item), sd);
if (!sd->items) return NULL;
l = eina_list_data_find_list(sd->items, it);
l = eina_list_data_find_list(sd->items, eo_item);
if (l && l->next) return eina_list_data_get(l->next);
return NULL;
}
static Elm_Ctxpopup_Item*
_item_new(Eo *obj,
Elm_Ctxpopup_Data *sd,
EOLIAN static void
_elm_ctxpopup_item_init(Eo *eo_item,
Elm_Ctxpopup_Item_Data *item,
Evas_Smart_Cb func,
const void *data)
{
Elm_Ctxpopup_Item *item;
item = elm_widget_item_new(obj, Elm_Ctxpopup_Item);
if (!item) return NULL;
elm_widget_item_del_pre_hook_set(item, _item_del_pre_hook);
elm_widget_item_disable_hook_set(item, _item_disable_hook);
elm_widget_item_text_set_hook_set(item, _item_text_set_hook);
elm_widget_item_text_get_hook_set(item, _item_text_get_hook);
elm_widget_item_content_set_hook_set(item, _item_content_set_hook);
elm_widget_item_content_get_hook_set(item, _item_content_get_hook);
elm_widget_item_signal_emit_hook_set(item, _item_signal_emit_hook);
Eo *obj = eo_do(eo_item, eo_parent_get());
Elm_Ctxpopup_Data *sd = eo_data_scope_get(obj, ELM_CTXPOPUP_CLASS);
if (!sd->list)
{
sd->list = elm_list_add(obj);
@ -1441,8 +1434,6 @@ _item_new(Eo *obj,
item->wcb.cobj = obj;
sd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
return item;
}
EOLIAN static const Elm_Atspi_Action*
@ -1460,4 +1451,5 @@ _elm_ctxpopup_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EINA_UNU
return &atspi_actions[0];
}
#include "elm_ctxpopup_item.eo.c"
#include "elm_ctxpopup.eo.c"

View File

@ -7,33 +7,7 @@ typedef enum
ELM_CTXPOPUP_DIRECTION_UNKNOWN, /**< ctxpopup does not determine it's direction yet*/
} Elm_Ctxpopup_Direction; /**< Direction in which to show the popup */
/**
* Get the item before @p it in a ctxpopup widget's internal list of
* items.
*
* @param it The item to fetch previous from
* @return The item before the @p it in its parent's list. If there is no
* previous item for @p it or there's an error, @c NULL is returned.
*
* @see elm_ctxpopup_item_next_get()
*
* @since 1.11
* @ingroup Ctxpopup
*/
EAPI Elm_Object_Item *elm_ctxpopup_item_prev_get(const Elm_Object_Item *it);
/**
* Get the item after @p it in a ctxpopup widget's
* internal list of items.
*
* @param it The item to fetch next from
* @return The item after the @p it in its parent's list. If there is no next
* item for @p it or there's an error, @c NULL is returned.
*
* @see elm_ctxpopup_item_prev_get()
*
* @since 1.11
* @ingroup Ctxpopup
*/
EAPI Elm_Object_Item *elm_ctxpopup_item_next_get(const Elm_Object_Item *it);

View File

@ -0,0 +1,59 @@
class Elm_Ctxpopup_Item(Elm_Widget_Item)
{
legacy_prefix: null;
eo_prefix: elm_obj_ctxpopup_item;
properties {
prev {
get {
/*@
Get the item before @p it in a ctxpopup widget's internal list of
items.
@see elm_ctxpopup_item_next_get()
@since 1.11
@ingroup Ctxpopup
*/
}
values {
Elm_Object_Item *item; /*@ The item before the object in its parent's list. If there is no
previous item for @p it or there's an error, @c NULL is returned. */
}
}
next {
get {
/*@
Get the item after @p it in a ctxpopup widget's
internal list of items.
@see elm_ctxpopup_item_prev_get()
@since 1.11
@ingroup Ctxpopup
*/
}
values {
Elm_Object_Item *item; /*@ The item after the object in its parent's list. If there is no
previous item for @p it or there's an error, @c NULL is returned. */
}
}
}
methods {
init {
params {
Evas_Smart_Cb func;
const(void) * data;
}
}
}
implements {
Eo.Base.constructor;
Elm_Widget_Item.del_pre;
Elm_Widget_Item.disable;
Elm_Widget_Item.signal_emit;
Elm_Widget_Item.part_text.get;
Elm_Widget_Item.part_text.set;
Elm_Widget_Item.part_content.get;
Elm_Widget_Item.part_content.set;
}
}

View File

@ -2,6 +2,7 @@
#define ELM_WIDGET_CTXPOPUP_H
#include "elm_widget_layout.h"
#include "elm_ctxpopup_item.eo.h"
/* DO NOT USE THIS HEADER UNLESS YOU ARE PREPARED FOR BREAKING OF YOUR
* CODE. THIS IS ELEMENTARY'S INTERNAL WIDGET API (for now) AND IS NOT
@ -9,6 +10,7 @@
* IT AT RUNTIME.
*/
#include "elm_object_item_migration_temp.h"
/**
* @addtogroup Widget
* @{
@ -20,15 +22,15 @@
* widgets which are a ctxpopup with some more logic on top.
*/
typedef struct _Elm_Ctxpopup_Item Elm_Ctxpopup_Item;
typedef struct _Elm_Ctxpopup_Item_Data Elm_Ctxpopup_Item_Data;
/**
* Base widget smart data extended with ctxpopup instance data.
*/
typedef struct _Elm_Ctxpopup_Data Elm_Ctxpopup_Data;
struct _Elm_Ctxpopup_Item
struct _Elm_Ctxpopup_Item_Data
{
ELM_WIDGET_ITEM;
Elm_Widget_Item_Data *base;
Elm_Object_Item *list_item;
@ -92,7 +94,10 @@ struct _Elm_Ctxpopup_Data
return
#define ELM_CTXPOPUP_ITEM_CHECK_OR_RETURN(it, ...) \
ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item_Data *)it, __VA_ARGS__); \
ELM_CTXPOPUP_CHECK(it->base.widget) __VA_ARGS__;
ELM_WIDGET_ITEM_CHECK_OR_RETURN(it->base, __VA_ARGS__); \
ELM_CTXPOPUP_CHECK(it->base->widget) __VA_ARGS__;
#define ELM_CTXPOPUP_ITEM_DATA_GET(o, sd) \
Elm_Ctxpopup_Item_Data *sd = eo_data_scope_get((Eo *)o, ELM_CTXPOPUP_ITEM_CLASS)
#endif