* @skipline _del_cb
* @until }
*
- * To delete an item we simple need to call elm_diskselector_item_del() with
+ * To delete an item we simple need to call elm_object_item_del() with
* a pointer for such item.
*
* If you need, you can get selected item with
if (!it_next)
{
iit = elm_index_item_find(gui->id, it);
- if (iit) elm_index_item_del(gui->id, iit);
+ if (iit) elm_object_item_del(iit);
elm_list_item_del(it);
return;
}
if (label[0] == label_next[0])
elm_object_item_data_set(iit, it_next);
else
- elm_index_item_del(gui->id, iit);
+ elm_object_item_del(iit);
elm_list_item_del(it);
}
void
_navi_it_del(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
- elm_naviframe_item_del(data);
+ elm_object_item_del(data);
}
void
Evas_Object *ds = data;
selected_ds_it = elm_diskselector_selected_item_get(ds);
- elm_diskselector_item_del(selected_ds_it);
+ elm_object_item_del(selected_ds_it);
}
static void
Evas_Object *fp = data;
it = elm_flipselector_selected_item_get(fp);
- if (it) elm_flipselector_item_del(it);
+ if (it) elm_object_item_del(it);
}
void /* underflow callback */
_sel(void *data, Evas_Object *obj, void *event_info)
{
if(!elm_hoversel_expanded_get(obj) && event_info != data)
- elm_hoversel_item_del(event_info);
+ elm_object_item_del(event_info);
}
static void
" %s (pointing to %s)\n", elm_index_item_letter_get(iit),
elm_object_item_text_get(lit));
- elm_index_item_del(d.index, lit);
+ elm_object_item_del(lit);
}
static void
Elm_Object_Item *menu_it = elm_menu_first_item_get(data);
menu_it = elm_menu_item_next_get(menu_it);
l = elm_menu_item_subitems_get(menu_it);
- elm_menu_item_del(eina_list_data_get(l));
+ elm_object_item_del(eina_list_data_get(l));
}
static void
elm_segment_control_item_insert_at(sc, NULL, "Inserted at", count - 1);
seg_it = elm_segment_control_item_insert_at(sc, NULL, "To be deleted", 2);
- elm_segment_control_item_del(seg_it);
+ elm_object_item_del(seg_it);
elm_segment_control_item_insert_at(sc, NULL, "To be deleted", 2);
elm_segment_control_item_del_at(sc, 2);
Tab_Data *td = data;
if (td->tab)
- elm_toolbar_item_del(td->tab);
+ elm_object_item_del(td->tab);
free(td);
}
if (item->icon)
evas_object_del(item->icon);
wd->items = eina_list_remove(wd->items, item);
- free(item);
+ elm_widget_item_free(item);
}
wd->items = NULL;
}
+static void
+_item_del_pre_hook(Elm_Object_Item *it)
+{
+ ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
+
+ Widget_Data *wd;
+ Elm_Ctxpopup_Item *ctxpopup_it = (Elm_Ctxpopup_Item *) it;
+
+ wd = elm_widget_data_get(WIDGET(ctxpopup_it));
+ if (!wd) return;
+
+ if (ctxpopup_it->icon)
+ evas_object_del(ctxpopup_it->icon);
+ if (VIEW(ctxpopup_it))
+ evas_object_del(VIEW(ctxpopup_it));
+
+ eina_stringshare_del(ctxpopup_it->label);
+
+ wd->items = eina_list_remove(wd->items, ctxpopup_it);
+
+ wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
+
+ if (eina_list_count(wd->items) < 1)
+ {
+ evas_object_hide(WIDGET(ctxpopup_it));
+ return;
+ }
+
+ if (wd->visible)
+ _sizing_eval(WIDGET(ctxpopup_it));
+}
+
EAPI Evas_Object *
elm_ctxpopup_add(Evas_Object *parent)
{
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);
EAPI void
elm_ctxpopup_item_del(Elm_Object_Item *it)
{
- ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
-
- Widget_Data *wd;
- Elm_Ctxpopup_Item *ctxpopup_it = (Elm_Ctxpopup_Item *) it;
-
- wd = elm_widget_data_get(WIDGET(ctxpopup_it));
- if (!wd) return;
-
- if (ctxpopup_it->icon)
- evas_object_del(ctxpopup_it->icon);
- if (VIEW(ctxpopup_it))
- evas_object_del(VIEW(ctxpopup_it));
-
- eina_stringshare_del(ctxpopup_it->label);
-
- wd->items = eina_list_remove(wd->items, ctxpopup_it);
-
- wd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
-
- elm_widget_item_del(ctxpopup_it);
-
- if (eina_list_count(wd->items) < 1)
- {
- evas_object_hide(WIDGET(ctxpopup_it));
- return;
- }
-
- if (wd->visible)
- _sizing_eval(WIDGET(ctxpopup_it));
-
+ elm_object_item_del(it);
}
EAPI void
EAPI Elm_Object_Item *elm_ctxpopup_item_append(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data);
/**
- * @brief Delete the given item in a ctxpopup object.
- *
- * @param it Ctxpopup item to be deleted
- *
- * @see elm_ctxpopup_item_append()
- *
- * @ingroup Ctxpopup
- */
-EAPI void elm_ctxpopup_item_del(Elm_Object_Item *it);
-
-/**
* @brief Set the direction priority of a ctxpopup.
*
* @param obj Ctxpopup object
elm_hoversel_hover_parent_set(obj, NULL);
EINA_LIST_FREE(wd->items, item)
{
- elm_widget_item_pre_notify_del(item);
eina_stringshare_del(item->label);
eina_stringshare_del(item->icon_file);
eina_stringshare_del(item->icon_group);
- elm_widget_item_del(item);
+ elm_widget_item_free(item);
}
}
return ((Elm_Hoversel_Item *) it)->label;
}
+static void
+_item_del_pre_hook(Elm_Object_Item *it)
+{
+ ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
+ Widget_Data *wd;
+ Elm_Hoversel_Item *item = (Elm_Hoversel_Item *) it;
+ wd = elm_widget_data_get(WIDGET(item));
+ if (!wd) return;
+ elm_hoversel_hover_end(WIDGET(item));
+ wd->items = eina_list_remove(wd->items, item);
+ eina_stringshare_del(item->label);
+ eina_stringshare_del(item->icon_file);
+ eina_stringshare_del(item->icon_group);
+}
+
EAPI Evas_Object *
elm_hoversel_add(Evas_Object *parent)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
- EINA_LIST_FOREACH_SAFE(wd->items, l, ll, it) elm_hoversel_item_del(it);
+ EINA_LIST_FOREACH_SAFE(wd->items, l, ll, it)
+ {
+ _item_del_pre_hook(it);
+ elm_widget_item_free(it);
+ }
}
EAPI const Eina_List *
if (!wd) return NULL;
Elm_Hoversel_Item *item = elm_widget_item_new(obj, Elm_Hoversel_Item);
if (!item) return NULL;
+ elm_widget_item_del_pre_hook_set(item, _item_del_pre_hook);
elm_widget_item_text_get_hook_set(item, _item_text_get_hook);
wd->items = eina_list_append(wd->items, item);
item->label = eina_stringshare_add(label);
EAPI void
elm_hoversel_item_del(Elm_Object_Item *it)
{
- ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
- Widget_Data *wd;
- Elm_Hoversel_Item *item = (Elm_Hoversel_Item *) it;
- wd = elm_widget_data_get(WIDGET(item));
- if (!wd) return;
- elm_hoversel_hover_end(WIDGET(item));
- wd->items = eina_list_remove(wd->items, item);
- elm_widget_item_pre_notify_del(item);
- eina_stringshare_del(item->label);
- eina_stringshare_del(item->icon_file);
- eina_stringshare_del(item->icon_group);
- elm_widget_item_del(item);
+ elm_object_item_del(it);
}
EAPI void
* @warning Should @b not be called while the hoversel is active; use
* elm_hoversel_expanded_get() to check first.
*
- * @see elm_hoversel_item_del()
+ * @see elm_object_item_del()
*/
EAPI void elm_hoversel_clear(Evas_Object *obj);
EAPI Elm_Object_Item *elm_hoversel_item_add(Evas_Object *obj, const char *label, const char *icon_file, Elm_Icon_Type icon_type, Evas_Smart_Cb func, const void *data);
/**
- * @brief Delete an item from the hoversel
- *
- * @param it The item to delete
- *
- * This deletes the item from the hoversel (should not be called while the
- * hoversel is active; use elm_hoversel_expanded_get() to check first).
- *
- * @see elm_hoversel_item_add()
- */
-EAPI void elm_hoversel_item_del(Elm_Object_Item *it);
-
-/**
* @brief This sets the icon for the given hoversel item.
*
* @param it The item to set the icon
_del_button_obj(obj, _item->button);
- free(_item);
if (wd->current == l)
wd->current = NULL;
break;
if (vieww) *vieww = vw;
}
+static void
+_item_del_pre_hook(Elm_Object_Item *it)
+{
+ ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
+ _del_button_item((Elm_Multibuttonentry_Item *) it);
+}
+
static Elm_Multibuttonentry_Item*
_add_button_item(Evas_Object *obj, const char *str, Multibuttonentry_Pos pos, const Elm_Multibuttonentry_Item *reference, void *data)
{
item = elm_widget_item_new(obj, Elm_Multibuttonentry_Item);
if (item)
{
+ elm_widget_item_del_pre_hook_set(item, _item_del_pre_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_data_set(item, data);
if (item)
{
_del_button_item(item);
+ elm_widget_item_free(item);
elm_object_focus_set(wd->entry, EINA_TRUE);
}
}
EAPI void
elm_multibuttonentry_item_del(Elm_Object_Item *it)
{
- ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
- _del_button_item((Elm_Multibuttonentry_Item *) it);
+ elm_object_item_del(it);
}
EAPI const char *
EAPI void elm_multibuttonentry_item_unselect_all(Evas_Object *obj);
/**
- * Delete a given item
- *
- * @param it The item
- *
- */
-EAPI void elm_multibuttonentry_item_del(Elm_Object_Item *it);
-
-/**
* Remove all items in the multibuttonentry.
*
* @param obj The multibuttonentry object
static Evas_Object * _title_content_unset(Elm_Naviframe_Item *it,
const char *part);
static void _item_del(Elm_Naviframe_Item *it);
+static void _item_del_pre_hook(Elm_Object_Item *it);
static void _pushed_finished(void *data,
Evas_Object *obj,
const char *emission,
Elm_Naviframe_Item);
wd->stack = eina_inlist_remove(wd->stack, wd->stack->last);
_item_del(it);
+ elm_widget_item_free(it);
if (!wd->stack) break;
}
}
}
eina_stringshare_del(it->style);
+}
+
+static void
+_item_del_pre_hook(Elm_Object_Item *it)
+{
+ ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
+ Elm_Naviframe_Item *navi_it;
+ Widget_Data *wd;
- elm_widget_item_del(it);
+ navi_it =(Elm_Naviframe_Item *) it;
+ wd = elm_widget_data_get(WIDGET(navi_it));
+ if (!wd) return;
+
+ if (it == elm_naviframe_top_item_get(WIDGET(navi_it)))
+ {
+ wd->stack = eina_inlist_remove(wd->stack, EINA_INLIST_GET(navi_it));
+ _item_del(navi_it);
+ elm_widget_item_free(navi_it);
+ //If the item is only one, the stack will be empty
+ if (!wd->stack) return;
+ navi_it = EINA_INLIST_CONTAINER_GET(wd->stack->last,
+ Elm_Naviframe_Item);
+ evas_object_show(VIEW(navi_it));
+ evas_object_raise(VIEW(navi_it));
+ edje_object_signal_emit(VIEW(navi_it), "elm,state,visible", "elm");
+ }
+ else
+ {
+ wd->stack = eina_inlist_remove(wd->stack, EINA_INLIST_GET(navi_it));
+ _item_del(navi_it);
+ elm_widget_item_free(navi_it);
+ }
}
static void
SIG_POP_FINISHED,
data);
_item_del(data);
+ elm_widget_item_free(data);
}
static void
return NULL;
}
+ elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
elm_widget_item_text_set_hook_set(it, _item_text_set_hook);
elm_widget_item_text_get_hook_set(it, _item_text_get_hook);
elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
edje_object_message_signal_process(VIEW(prev_it));
}
else
- _item_del(it);
+ {
+ _item_del(it);
+ elm_widget_item_free(it);
+ }
return content;
}
prev_l = l->prev;
wd->stack = eina_inlist_remove(wd->stack, l);
_item_del(EINA_INLIST_CONTAINER_GET(l, Elm_Naviframe_Item));
+ elm_widget_item_free(EINA_INLIST_CONTAINER_GET(l,
+ Elm_Naviframe_Item));
l = prev_l;
}
elm_naviframe_item_pop(WIDGET(navi_it));
EAPI void
elm_naviframe_item_del(Elm_Object_Item *it)
{
- ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
- Elm_Naviframe_Item *navi_it;
- Widget_Data *wd;
-
- navi_it =(Elm_Naviframe_Item *) it;
- wd = elm_widget_data_get(WIDGET(navi_it));
- if (!wd) return;
-
- if (it == elm_naviframe_top_item_get(WIDGET(navi_it)))
- {
- wd->stack = eina_inlist_remove(wd->stack, EINA_INLIST_GET(navi_it));
- _item_del(navi_it);
- //If the item is only one, the stack will be empty
- if (!wd->stack) return;
- navi_it = EINA_INLIST_CONTAINER_GET(wd->stack->last,
- Elm_Naviframe_Item);
- evas_object_show(VIEW(navi_it));
- evas_object_raise(VIEW(navi_it));
- edje_object_signal_emit(VIEW(navi_it), "elm,state,visible", "elm");
- }
- else
- {
- wd->stack = eina_inlist_remove(wd->stack, EINA_INLIST_GET(navi_it));
- _item_del(navi_it);
- }
+ elm_object_item_del(it);
}
EAPI void
EAPI void elm_naviframe_item_promote(Elm_Object_Item *it);
/**
- * @brief Delete the given item instantly.
- *
- * @param it The naviframe item
- *
- * This just deletes the given item from the naviframe item list instantly.
- * So this would not emit any signals for view transitions but just change
- * the current view if the given item is a top one.
- *
- * @ingroup Naviframe
- */
-EAPI void elm_naviframe_item_del(Elm_Object_Item *it);
-
-/**
* @brief preserve the content objects when items are popped.
*
* @param obj The naviframe object
EINA_DEPRECATED EAPI Evas_Object *elm_ctxpopup_content_unset(Evas_Object *obj);
/**
+ * @brief Delete the given item in a ctxpopup object.
+ *
+ * @param it Ctxpopup item to be deleted
+ *
+ * @deprecated Use elm_object_item_del() instead
+ * @see elm_ctxpopup_item_append()
+ *
+ * @ingroup Ctxpopup
+ */
+EINA_DEPRECATED EAPI void elm_ctxpopup_item_del(Elm_Object_Item *it);
+
+/**
* Set the label for a given file selector button widget
*
* @param obj The file selector button widget
EINA_DEPRECATED EAPI void elm_hoversel_item_del_cb_set(Elm_Object_Item *it, Evas_Smart_Cb func);
/**
+ * @brief Delete an item from the hoversel
+ *
+ * @param it The item to delete
+ *
+ * This deletes the item from the hoversel (should not be called while the
+ * hoversel is active; use elm_hoversel_expanded_get() to check first).
+ *
+ * @deprecated Use elm_object_item_del() instead
+ * @see elm_hoversel_item_add()
+ */
+EINA_DEPRECATED EAPI void elm_hoversel_item_del(Elm_Object_Item *it);
+
+/**
* Set actionslider labels.
*
* @param obj The actionslider object
*/
EINA_DEPRECATED EAPI void elm_diskselector_item_del_cb_set(Elm_Object_Item *it, Evas_Smart_Cb func);
+/**
+ * Delete them item from the diskselector.
+ *
+ * @param it The item of diskselector to be deleted.
+ *
+ * If deleting all diskselector items is required, elm_diskselector_clear()
+ * should be used instead of getting items list and deleting each one.
+ *
+ * @deprecated Use elm_object_item_del() instead
+ * @see elm_diskselector_clear()
+ * @see elm_diskselector_item_append()
+ *
+ * @ingroup Diskselector
+ */
+EINA_DEPRECATED EAPI void elm_diskselector_item_del(Elm_Object_Item *it);
+
EINA_DEPRECATED EAPI void elm_factory_content_set(Evas_Object *obj, Evas_Object *content);
EINA_DEPRECATED EAPI Evas_Object *elm_factory_content_get(const Evas_Object *obj);
EINA_DEPRECATED EAPI void elm_flipselector_item_label_set(Elm_Object_Item *it, const char *label);
/**
+ * Delete a given item from a flip selector widget.
+ *
+ * @param it The item to delete
+ *
+ * @deprecated Use elm_object_item_del() instead
+ * @ingroup Flipselector
+ */
+EINA_DEPRECATED EAPI void elm_flipselector_item_del(Elm_Object_Item *it);
+
+/**
* Make a given Elementary object the focused one.
*
* @param obj The Elementary object to make focused.
EINA_DEPRECATED EAPI void elm_index_item_del_cb_set(Elm_Object_Item *it, Evas_Smart_Cb func);
/**
+ * Remove an item from a given index widget, <b>to be referenced by
+ * it's data value</b>.
+ *
+ * @param obj The index object
+ * @param item The item to be removed from @p obj
+ *
+ * If a deletion callback is set, via elm_object_item_del_cb_set(),
+ * that callback function will be called by this one.
+ *
+ * @deprecated Use elm_object_item_del() instead
+ * @ingroup Index
+ */
+EINA_DEPRECATED EAPI void elm_index_item_del(Evas_Object *obj, Elm_Object_Item *item);
+
+/**
* @brief Set the label on the label object
*
* @param obj The label object
EINA_DEPRECATED EAPI void elm_menu_item_data_set(Elm_Object_Item *it, const void *data);
/**
+ * @brief Deletes an item from the menu.
+ *
+ * @param it The item to delete.
+ *
+ * @deprecated Use elm_object_item_del() instead
+ * @see elm_menu_item_add()
+ */
+EINA_DEPRECATED EAPI void elm_menu_item_del(Elm_Object_Item *it);
+
+/**
* @brief Set the content of the notify widget
*
* @param obj The notify object
EINA_DEPRECATED EAPI void *elm_slideshow_item_data_get(const Elm_Object_Item *it);
/**
+ * Delete a given item from a slideshow widget.
+ *
+ * @param it The slideshow item
+ *
+ * @deprecated Use elm_object_item_de() instead
+ * @ingroup Slideshow
+ */
+EINA_DEPRECATED EAPI void elm_slideshow_item_del(Elm_Object_Item *it);
+
+/**
* Get the toolbar object from an item.
*
* @param it The item.
EINA_DEPRECATED EAPI void elm_toolbar_item_del_cb_set(Elm_Object_Item *it, Evas_Smart_Cb func);
/**
+ * Delete them item from the toolbar.
+ *
+ * @param it The item of toolbar to be deleted.
+ *
+ * @deprecated Use elm_object_item_del() instead
+ * @see elm_toolbar_item_append()
+ *
+ * @ingroup Toolbar
+ */
+EINA_DEPRECATED EAPI void elm_toolbar_item_del(Elm_Object_Item *it);
+
+/**
* @brief Link a Elm_Payer with an Elm_Video object.
*
* @param player the Elm_Player object.
EINA_DEPRECATED EAPI void elm_segment_control_item_icon_set(Elm_Object_Item *it, Evas_Object *icon);
/**
+ * Remove a segment control item from its parent, deleting it.
+ *
+ * @param it The item to be removed.
+ *
+ * Items can be added with elm_segment_control_item_add() or
+ * elm_segment_control_item_insert_at().
+ *
+ * @deprecated Use elm_object_item_del() instead
+ * @ingroup SegmentControl
+ */
+EINA_DEPRECATED EAPI void elm_segment_control_item_del(Elm_Object_Item *it);
+
+/**
* Get the label
*
* @param obj The multibuttonentry object
EINA_DEPRECATED EAPI void elm_multibuttonentry_item_label_set(Elm_Object_Item *it, const char *str);
/**
+ * Delete a given item
+ *
+ * @param it The item
+ *
+ * @deprecated Use elm_object_item_del() instead
+ *
+ */
+EINA_DEPRECATED EAPI void elm_multibuttonentry_item_del(Elm_Object_Item *it);
+
+/**
+ * @brief Delete the given item instantly.
+ *
+ * @param it The naviframe item
+ *
+ * This just deletes the given item from the naviframe item list instantly.
+ * So this would not emit any signals for view transitions but just change
+ * the current view if the given item is a top one.
+ *
+ * @deprecated Use elm_object_item_del() instead
+ * @ingroup Naviframe
+ */
+EINA_DEPRECATED EAPI void elm_naviframe_item_del(Elm_Object_Item *it);
+
+
+
+/**
* Sets the disabled/enabled state of a list item.
*
* @param it The item.
wd->idler = ecore_idle_enterer_before_add(_move_scroller, data);
}
+static void
+_item_del(Elm_Diskselector_Item *item)
+{
+ if (!item) return;
+ eina_stringshare_del(item->label);
+ if (item->icon)
+ evas_object_del(item->icon);
+}
+
+static int
+_count_letter(const char *str)
+{
+ int pos = 0;
+ int code = 0, chnum;
+
+ for (chnum = 0; ; chnum++)
+ {
+ pos = evas_string_char_next_get(str, pos, &code);
+ if (code == 0) break;
+ }
+ return chnum;
+}
+
+static int
+_check_letter(const char *str, int length)
+{
+ int pos = 0;
+ int code = 0, chnum;
+
+ for (chnum = 0; ; chnum++)
+ {
+ if (chnum == length) break;
+ pos = evas_string_char_next_get(str, pos, &code);
+ if (code == 0) break;
+ }
+ return pos;
+}
+
+static Eina_Bool
+_check_string(void *data)
+{
+ int mid, steps, length, diff;
+ Elm_Diskselector_Item *it;
+ Eina_List *list, *l;
+ Evas_Coord ox, ow;
+ char buf[1024];
+ Widget_Data *wd = data;
+
+ evas_object_geometry_get(wd->scroller, &ox, NULL, &ow, NULL);
+ if (ow <= 0)
+ return EINA_FALSE;
+ if (!wd->init)
+ return EINA_FALSE;
+ if (!wd->round)
+ list = wd->items;
+ else
+ list = wd->r_items;
+
+ EINA_LIST_FOREACH(list, l, it)
+ {
+ Evas_Coord x, w;
+ int len;
+ evas_object_geometry_get(VIEW(it), &x, NULL, &w, NULL);
+ /* item not visible */
+ if ((x + w <= ox) || (x >= ox + ow))
+ continue;
+
+ len = _count_letter(it->label);
+// // FIXME: len should be # of ut8f letters. ie count using utf8 string walk, not stringshare len
+// len = eina_stringshare_strlen(it->label);
+
+ if (x <= ox + 5)
+ edje_object_signal_emit(VIEW(it), "elm,state,left_side",
+ "elm");
+ else if (x + w >= ox + ow - 5)
+ edje_object_signal_emit(VIEW(it), "elm,state,right_side",
+ "elm");
+ else
+ {
+ if ((wd->len_threshold) && (len > wd->len_threshold))
+ edje_object_signal_emit(VIEW(it), "elm,state,center_small",
+ "elm");
+ else
+ edje_object_signal_emit(VIEW(it), "elm,state,center",
+ "elm");
+ }
+
+ // if len is les that the limit len, skip anyway
+ if (len <= wd->len_side)
+ continue;
+
+ steps = len - wd->len_side + 1;
+ mid = x + w / 2;
+ if (mid <= ox + ow / 2)
+ diff = (ox + ow / 2) - mid;
+ else
+ diff = mid - (ox + ow / 2);
+
+ length = len - (int)(diff * steps / (ow / 3));
+ length = MAX(length, wd->len_side);
+ // limit string len to "length" ut8f chars
+ length = _check_letter(it->label, length);
+ // cut it off at byte mark returned form _check_letter
+ strncpy(buf, it->label, length);
+ buf[length] = '\0';
+ edje_object_part_text_set(VIEW(it), "elm.text", buf);
+ }
+
+ if (wd->check_idler)
+ ecore_idle_enterer_del(wd->check_idler);
+ wd->check_idler = NULL;
+ return EINA_FALSE;
+}
+
+static void
+_item_del_pre_hook(Elm_Object_Item *it)
+{
+ ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
+ Elm_Diskselector_Item *item, *item2, *dit;
+ Eina_List *l;
+ int i = 0;
+ Widget_Data *wd;
+ item = (Elm_Diskselector_Item *) it;
+ wd = elm_widget_data_get(WIDGET(item));
+ if (!wd) return;
+
+ elm_box_unpack(wd->main_box, VIEW(item));
+
+ if (wd->round)
+ wd->r_items = eina_list_remove(wd->r_items, item);
+
+ wd->items = eina_list_remove(wd->items, item);
+
+ if (wd->selected_item == item)
+ {
+ dit = (Elm_Diskselector_Item *) eina_list_nth(wd->items, 0);
+ if (dit != item)
+ wd->selected_item = dit;
+ else
+ wd->selected_item = eina_list_nth(wd->items, 1);
+
+ _selected_item_indicate(wd->selected_item);
+ }
+
+ _item_del(item);
+ wd->item_count -= 1;
+
+ if (wd->round)
+ {
+ if (!wd->item_count)
+ {
+ evas_object_hide(wd->VIEW(first));
+ evas_object_hide(wd->VIEW(second));
+ evas_object_hide(wd->VIEW(last));
+ evas_object_hide(wd->VIEW(s_last));
+
+ EINA_LIST_FOREACH(wd->under_items, l, item2)
+ evas_object_hide(VIEW(item2));
+
+ EINA_LIST_FOREACH(wd->over_items, l, item2)
+ evas_object_hide(VIEW(item2));
+ }
+ else
+ {
+ dit = eina_list_nth(wd->items, 0);
+ if (dit)
+ {
+ eina_stringshare_replace(&wd->first->label, dit->label);
+ edje_object_part_text_set(wd->VIEW(first), "elm.text",
+ wd->first->label);
+ }
+ dit = eina_list_nth(wd->items, 1);
+ if (dit)
+ {
+ eina_stringshare_replace(&wd->second->label, dit->label);
+ edje_object_part_text_set(wd->VIEW(second), "elm.text",
+ wd->second->label);
+ }
+ // if more than 3 itmes should be displayed
+ for (i = 2; i < CEIL(wd->display_item_num); i++)
+ {
+ dit = eina_list_nth(wd->items, i);
+ item2 = eina_list_nth(wd->over_items, i - 2);
+ eina_stringshare_replace(&item2->label, dit->label);
+ edje_object_part_text_set(VIEW(item2), "elm.text", item2->label);
+ }
+
+ dit = eina_list_nth(wd->items, eina_list_count(wd->items) - 1);
+ if (dit)
+ {
+ eina_stringshare_replace(&wd->last->label, dit->label);
+ edje_object_part_text_set(wd->VIEW(last), "elm.text",
+ wd->last->label);
+ }
+ dit = eina_list_nth(wd->items, eina_list_count(wd->items) - 2);
+ if (dit)
+ {
+ eina_stringshare_replace(&wd->s_last->label, dit->label);
+ edje_object_part_text_set(wd->VIEW(s_last), "elm.text",
+ wd->s_last->label);
+ }
+ // if more than 3 itmes should be displayed
+ for (i = 3; i <= CEIL(wd->display_item_num); i++)
+ {
+ dit = eina_list_nth(wd->items, wd->item_count - i);
+ item2 = eina_list_nth(wd->under_items, i - 3);
+ eina_stringshare_replace(&item2->label, dit->label);
+ edje_object_part_text_set(VIEW(item2), "elm.text",
+ item2->label);
+ }
+ }
+ }
+ wd->check_idler = ecore_idle_enterer_before_add(_check_string, wd);
+ _sizing_eval(wd->self);
+
+}
+
static Elm_Diskselector_Item *
_item_new(Evas_Object *obj, Evas_Object *icon, const char *label, Evas_Smart_Cb func, const void *data)
{
it = elm_widget_item_new(obj, Elm_Diskselector_Item);
if (!it) return NULL;
+ elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
elm_widget_item_text_set_hook_set(it, _item_text_set_hook);
elm_widget_item_text_get_hook_set(it, _item_text_get_hook);
elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
}
static void
-_item_del(Elm_Diskselector_Item *item)
-{
- if (!item) return;
- eina_stringshare_del(item->label);
- if (item->icon)
- evas_object_del(item->icon);
- elm_widget_item_del(item);
-}
-
-static void
_theme_data_get(Widget_Data *wd)
{
const char* str;
}
}
- EINA_LIST_FREE(wd->items, it) _item_del(it);
+ EINA_LIST_FREE(wd->items, it)
+ {
+ _item_del(it);
+ elm_widget_item_free(it);
+ }
eina_list_free(wd->r_items);
}
return EINA_TRUE;
}
-static int
-_count_letter(const char *str)
-{
- int pos = 0;
- int code = 0, chnum;
-
- for (chnum = 0; ; chnum++)
- {
- pos = evas_string_char_next_get(str, pos, &code);
- if (code == 0) break;
- }
- return chnum;
-}
-
-static int
-_check_letter(const char *str, int length)
-{
- int pos = 0;
- int code = 0, chnum;
-
- for (chnum = 0; ; chnum++)
- {
- if (chnum == length) break;
- pos = evas_string_char_next_get(str, pos, &code);
- if (code == 0) break;
- }
- return pos;
-}
-
-static Eina_Bool
-_check_string(void *data)
-{
- int mid, steps, length, diff;
- Elm_Diskselector_Item *it;
- Eina_List *list, *l;
- Evas_Coord ox, ow;
- char buf[1024];
- Widget_Data *wd = data;
-
- evas_object_geometry_get(wd->scroller, &ox, NULL, &ow, NULL);
- if (ow <= 0)
- return EINA_FALSE;
- if (!wd->init)
- return EINA_FALSE;
- if (!wd->round)
- list = wd->items;
- else
- list = wd->r_items;
-
- EINA_LIST_FOREACH(list, l, it)
- {
- Evas_Coord x, w;
- int len;
- evas_object_geometry_get(VIEW(it), &x, NULL, &w, NULL);
- /* item not visible */
- if ((x + w <= ox) || (x >= ox + ow))
- continue;
-
- len = _count_letter(it->label);
-// // FIXME: len should be # of ut8f letters. ie count using utf8 string walk, not stringshare len
-// len = eina_stringshare_strlen(it->label);
-
- if (x <= ox + 5)
- edje_object_signal_emit(VIEW(it), "elm,state,left_side",
- "elm");
- else if (x + w >= ox + ow - 5)
- edje_object_signal_emit(VIEW(it), "elm,state,right_side",
- "elm");
- else
- {
- if ((wd->len_threshold) && (len > wd->len_threshold))
- edje_object_signal_emit(VIEW(it), "elm,state,center_small",
- "elm");
- else
- edje_object_signal_emit(VIEW(it), "elm,state,center",
- "elm");
- }
-
- // if len is les that the limit len, skip anyway
- if (len <= wd->len_side)
- continue;
-
- steps = len - wd->len_side + 1;
- mid = x + w / 2;
- if (mid <= ox + ow / 2)
- diff = (ox + ow / 2) - mid;
- else
- diff = mid - (ox + ow / 2);
-
- length = len - (int)(diff * steps / (ow / 3));
- length = MAX(length, wd->len_side);
- // limit string len to "length" ut8f chars
- length = _check_letter(it->label, length);
- // cut it off at byte mark returned form _check_letter
- strncpy(buf, it->label, length);
- buf[length] = '\0';
- edje_object_part_text_set(VIEW(it), "elm.text", buf);
- }
-
- if (wd->check_idler)
- ecore_idle_enterer_del(wd->check_idler);
- wd->check_idler = NULL;
- return EINA_FALSE;
-}
-
static void
_selected_item_indicate(Elm_Diskselector_Item *it)
{
elm_box_unpack(wd->main_box, VIEW(it));
wd->r_items = eina_list_remove(wd->r_items, it);
eina_stringshare_del(it->label);
- evas_object_del(VIEW(it));
- free(it);
+ elm_widget_item_free(it);
}
static void
return ((Elm_Diskselector_Item *) it)->icon;
}
+
EAPI Evas_Object *
elm_diskselector_add(Evas_Object *parent)
{
if (!wd->items) return;
wd->selected_item = NULL;
- EINA_LIST_FREE(wd->items, it) _item_del(it);
+ EINA_LIST_FREE(wd->items, it)
+ {
+ _item_del(it);
+ elm_widget_item_free(it);
+ }
_round_items_del(wd);
_sizing_eval(obj);
}
EAPI void
elm_diskselector_item_del(Elm_Object_Item * it)
{
- ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
- Elm_Diskselector_Item *item, *item2, *dit;
- Eina_List *l;
- int i = 0;
- Widget_Data *wd;
- item = (Elm_Diskselector_Item *) it;
- wd = elm_widget_data_get(WIDGET(item));
- if (!wd) return;
-
- elm_box_unpack(wd->main_box, VIEW(item));
-
- if (wd->round)
- wd->r_items = eina_list_remove(wd->r_items, item);
-
- wd->items = eina_list_remove(wd->items, item);
-
- if (wd->selected_item == item)
- {
- dit = (Elm_Diskselector_Item *) eina_list_nth(wd->items, 0);
- if (dit != item)
- wd->selected_item = dit;
- else
- wd->selected_item = eina_list_nth(wd->items, 1);
-
- _selected_item_indicate(wd->selected_item);
- }
-
- _item_del(item);
- wd->item_count -= 1;
-
- if (wd->round)
- {
- if (!wd->item_count)
- {
- evas_object_hide(wd->VIEW(first));
- evas_object_hide(wd->VIEW(second));
- evas_object_hide(wd->VIEW(last));
- evas_object_hide(wd->VIEW(s_last));
-
- EINA_LIST_FOREACH(wd->under_items, l, item2)
- evas_object_hide(VIEW(item2));
-
- EINA_LIST_FOREACH(wd->over_items, l, item2)
- evas_object_hide(VIEW(item2));
- }
- else
- {
- dit = eina_list_nth(wd->items, 0);
- if (dit)
- {
- eina_stringshare_replace(&wd->first->label, dit->label);
- edje_object_part_text_set(wd->VIEW(first), "elm.text",
- wd->first->label);
- }
- dit = eina_list_nth(wd->items, 1);
- if (dit)
- {
- eina_stringshare_replace(&wd->second->label, dit->label);
- edje_object_part_text_set(wd->VIEW(second), "elm.text",
- wd->second->label);
- }
- // if more than 3 itmes should be displayed
- for (i = 2; i < CEIL(wd->display_item_num); i++)
- {
- dit = eina_list_nth(wd->items, i);
- item2 = eina_list_nth(wd->over_items, i - 2);
- eina_stringshare_replace(&item2->label, dit->label);
- edje_object_part_text_set(VIEW(item2), "elm.text", item2->label);
- }
-
- dit = eina_list_nth(wd->items, eina_list_count(wd->items) - 1);
- if (dit)
- {
- eina_stringshare_replace(&wd->last->label, dit->label);
- edje_object_part_text_set(wd->VIEW(last), "elm.text",
- wd->last->label);
- }
- dit = eina_list_nth(wd->items, eina_list_count(wd->items) - 2);
- if (dit)
- {
- eina_stringshare_replace(&wd->s_last->label, dit->label);
- edje_object_part_text_set(wd->VIEW(s_last), "elm.text",
- wd->s_last->label);
- }
- // if more than 3 itmes should be displayed
- for (i = 3; i <= CEIL(wd->display_item_num); i++)
- {
- dit = eina_list_nth(wd->items, wd->item_count - i);
- item2 = eina_list_nth(wd->under_items, i - 3);
- eina_stringshare_replace(&item2->label, dit->label);
- edje_object_part_text_set(VIEW(item2), "elm.text",
- item2->label);
- }
- }
- }
- wd->check_idler = ecore_idle_enterer_before_add(_check_string, wd);
- _sizing_eval(wd->self);
+ elm_object_item_del(it);
}
EAPI const char *
*
* @param obj The diskselector object.
*
- * @see elm_diskselector_item_del()
+ * @see elm_object_item_del()
* @see elm_diskselector_item_append()
*
* @ingroup Diskselector
* or @c NULL on failure.
*
* @see elm_diskselector_item_append()
- * @see elm_diskselector_item_del()
+ * @see elm_object_item_del()
* @see elm_diskselector_clear()
*
* @ingroup Diskselector
* to the right.
*
* Items created with this method can be deleted with
- * elm_diskselector_item_del().
+ * elm_object_item_del().
*
* Associated @p data can be properly freed when item is deleted if a
* callback function is set with elm_object_item_del_cb_set().
* elm_diskselector_item_append(disk, "label", ic, NULL, NULL);
* @endcode
*
- * @see elm_diskselector_item_del()
+ * @see elm_object_item_del()
* @see elm_diskselector_clear()
* @see elm_icon_add()
*
*/
EAPI Elm_Object_Item *elm_diskselector_item_append(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Smart_Cb func, const void *data);
-
-/**
- * Delete them item from the diskselector.
- *
- * @param it The item of diskselector to be deleted.
- *
- * If deleting all diskselector items is required, elm_diskselector_clear()
- * should be used instead of getting items list and deleting each one.
- *
- * @see elm_diskselector_clear()
- * @see elm_diskselector_item_append()
- *
- * @ingroup Diskselector
- */
-EAPI void elm_diskselector_item_del(Elm_Object_Item *it);
-
/**
* Get the selected item.
*
static void _callbacks_set(Evas_Object *obj);
static void _flip_up(Widget_Data *wd);
static void _flip_down(Widget_Data *wd);
+static void _item_del_pre_hook(Elm_Object_Item *it);
static const char SIG_SELECTED[] = "selected";
static const char SIG_UNDERFLOWED[] = "underflowed";
it = elm_widget_item_new(obj, Elm_Flipselector_Item);
if (!it) return NULL;
+ elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
elm_widget_item_text_set_hook_set(it, _item_text_set_hook);
elm_widget_item_text_get_hook_set(it, _item_text_get_hook);
elm_widget_item_signal_emit_hook_set(it, _item_signal_emit_hook);
_item_free(Elm_Flipselector_Item *it)
{
eina_stringshare_del(it->label);
- elm_widget_item_del(it);
+ elm_widget_item_free(it);
}
static void
"", _signal_val_change_stop, obj);
}
+static void
+_item_del_pre_hook(Elm_Object_Item *it)
+{
+ ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
+ Widget_Data *wd;
+ Elm_Flipselector_Item *item, *item2;
+ Eina_List *l;
+
+ item = (Elm_Flipselector_Item *) it;
+ wd = elm_widget_data_get(WIDGET(item));
+ if (!wd) return;
+
+ if (wd->walking > 0)
+ {
+ item->deleted = EINA_TRUE;
+ return;
+ }
+
+ _flipselector_walk(wd);
+
+ EINA_LIST_FOREACH(wd->items, l, item2)
+ {
+ if (item2 == item)
+ {
+ wd->items = eina_list_remove_list(wd->items, l);
+ if (wd->current == l)
+ {
+ wd->current = l->prev;
+ if (!wd->current) wd->current = l->next;
+ if (wd->current)
+ {
+ item2 = wd->current->data;
+ _send_msg(wd, MSG_FLIP_DOWN, (char *)item2->label);
+ }
+ else
+ _send_msg(wd, MSG_FLIP_DOWN, "");
+ }
+ break;
+ }
+ }
+ eina_stringshare_del(item->label);
+ _sentinel_eval(wd);
+ _flipselector_unwalk(wd);
+}
+
EAPI Evas_Object *
elm_flipselector_add(Evas_Object *parent)
{
EAPI void
elm_flipselector_item_del(Elm_Object_Item *it)
{
- ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
- Widget_Data *wd;
- Elm_Flipselector_Item *item, *item2;
- Eina_List *l;
-
- item = (Elm_Flipselector_Item *) it;
- wd = elm_widget_data_get(WIDGET(item));
- if (!wd) return;
-
- if (wd->walking > 0)
- {
- item->deleted = EINA_TRUE;
- return;
- }
-
- _flipselector_walk(wd);
-
- EINA_LIST_FOREACH(wd->items, l, item2)
- {
- if (item2 == item)
- {
- wd->items = eina_list_remove_list(wd->items, l);
- if (wd->current == l)
- {
- wd->current = l->prev;
- if (!wd->current) wd->current = l->next;
- if (wd->current)
- {
- item2 = wd->current->data;
- _send_msg(wd, MSG_FLIP_DOWN, (char *)item2->label);
- }
- else
- _send_msg(wd, MSG_FLIP_DOWN, "");
- }
- break;
- }
- }
- _item_free(item);
- _sentinel_eval(wd);
- _flipselector_unwalk(wd);
+ elm_object_item_del(it);
}
EAPI const char *
* freed. Use the list members with functions like
* elm_object_item_text_set(),
* elm_object_item_text_get(),
- * elm_flipselector_item_del(),
+ * elm_object_item_del(),
* elm_flipselector_item_selected_get(),
* elm_flipselector_item_selected_set().
*
EAPI Eina_Bool elm_flipselector_item_selected_get(const Elm_Object_Item *it);
/**
- * Delete a given item from a flip selector widget.
- *
- * @param it The item to delete
- *
- * @ingroup Flipselector
- */
-EAPI void elm_flipselector_item_del(Elm_Object_Item *it);
-
-/**
* Gets the item before @p item in a flip selector widget's
* internal list of items.
*
_del_pre_hook(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
+ Elm_Index_Item *it;
if (!wd) return;
_index_box_clear(obj, wd->bx[wd->level], wd->level);
_index_box_clear(obj, wd->bx[0], 0);
- while (wd->items) _item_free(wd->items->data);
+ while (wd->items)
+ {
+ it = wd->items->data;
+ _item_free(it);
+ elm_widget_item_free(it);
+ }
if (wd->delay) ecore_timer_del(wd->delay);
}
evas_object_size_hint_max_set(obj, maxw, maxh);
}
+static void
+_item_del_pre_hook(Elm_Object_Item *it)
+{
+ ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
+ Widget_Data *wd = elm_widget_data_get(WIDGET(it));
+ if (!wd) return;
+ _item_free((Elm_Index_Item *) it);
+ _index_box_clear(WIDGET(it), wd->bx[wd->level], wd->level);
+}
+
static Elm_Index_Item *
_item_new(Evas_Object *obj, const char *letter, const void *item)
{
if (!wd) return NULL;
it = elm_widget_item_new(obj, Elm_Index_Item);
if (!it) return NULL;
+ elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
it->letter = eina_stringshare_add(letter);
it->base.data = item;
it->level = wd->level;
Widget_Data *wd = elm_widget_data_get(WIDGET(it));
if (!wd) return;
wd->items = eina_list_remove(wd->items, it);
- elm_widget_item_pre_notify_del(it);
eina_stringshare_del(it->letter);
- elm_widget_item_del(it);
}
// FIXME: always have index filled
if (cmp_data_func(p_it->base.data, it->base.data) >= 0)
p_it->base.data = it->base.data;
_item_free(it);
+ elm_widget_item_free(it);
}
}
}
EAPI void
-elm_index_item_del(Evas_Object *obj, Elm_Object_Item *it)
+elm_index_item_del(Evas_Object *obj __UNUSED__, Elm_Object_Item *it)
{
- ELM_CHECK_WIDTYPE(obj, widtype);
- ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
- _item_free((Elm_Index_Item *) it);
- _index_box_clear(obj, wd->bx[wd->level], wd->level);
+ elm_object_item_del(it);
}
EAPI Elm_Object_Item *
if (it->level != wd->level) continue;
clear = eina_list_append(clear, it);
}
- EINA_LIST_FREE(clear, it) _item_free(it);
+ EINA_LIST_FREE(clear, it)
+ {
+ _item_free(it);
+ elm_widget_item_free(it);
+ }
}
EAPI void
EAPI void elm_index_item_sorted_insert(Evas_Object *obj, const char *letter, const void *item, Eina_Compare_Cb cmp_func, Eina_Compare_Cb cmp_data_func);
/**
- * Remove an item from a given index widget, <b>to be referenced by
- * it's data value</b>.
- *
- * @param obj The index object
- * @param item The item to be removed from @p obj
- *
- * If a deletion callback is set, via elm_object_item_del_cb_set(),
- * that callback function will be called by this one.
- *
- * @ingroup Index
- */
-EAPI void elm_index_item_del(Evas_Object *obj, Elm_Object_Item *item);
-
-/**
* Find a given index widget's item, <b>using item data</b>.
*
* @param obj The index object
{
Elm_Menu_Item *child;
- elm_widget_item_pre_notify_del(item);
-
EINA_LIST_FREE(item->submenu.items, child)
_del_item(child);
if (item->submenu.hv) evas_object_del(item->submenu.hv);
if (item->submenu.location) evas_object_del(item->submenu.location);
if (item->icon_str) eina_stringshare_del(item->icon_str);
- elm_widget_item_del(item);
+ elm_widget_item_free(item);
}
static void
evas_object_event_callback_del_full(wd->parent, EVAS_CALLBACK_DEL, _parent_del, wd);
EINA_LIST_FREE(wd->items, item)
- _del_item(item);
+ _del_item(item);
if (wd->hv) evas_object_del(wd->hv);
if (wd->location) evas_object_del(wd->location);
_sizing_eval(obj);
}
+static void
+_item_del_pre_hook(Elm_Object_Item *it)
+{
+ ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
+ Elm_Menu_Item *item = (Elm_Menu_Item *) it;
+ Elm_Object_Item *_item;
+
+ EINA_LIST_FREE(item->submenu.items, _item) elm_object_item_del(_item);
+ if (item->label) eina_stringshare_del(item->label);
+ if (item->content) evas_object_del(item->content);
+ if (item->submenu.hv) evas_object_del(item->submenu.hv);
+ if (item->submenu.location) evas_object_del(item->submenu.location);
+
+ if (item->parent)
+ item->parent->submenu.items = eina_list_remove(item->parent->submenu.items, item);
+ else
+ {
+ Widget_Data *wd = elm_widget_data_get(WIDGET(item));
+ wd->items = eina_list_remove(wd->items, item);
+ }
+}
+
EAPI Elm_Object_Item *
elm_menu_item_add(Evas_Object *obj, Elm_Object_Item *parent, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
{
return NULL;
}
+ elm_widget_item_del_pre_hook_set(subitem, _item_del_pre_hook);
elm_widget_item_disable_hook_set(subitem, _item_disable_hook);
elm_widget_item_text_set_hook_set(subitem, _item_text_set_hook);
elm_widget_item_text_get_hook_set(subitem, _item_text_get_hook);
subitem = elm_widget_item_new(obj, Elm_Menu_Item);
if (!subitem) return NULL;
+ elm_widget_item_del_pre_hook_set(subitem, _item_del_pre_hook);
elm_widget_item_disable_hook_set(subitem, _item_disable_hook);
elm_widget_item_text_set_hook_set(subitem, _item_text_set_hook);
elm_widget_item_text_get_hook_set(subitem, _item_text_get_hook);
subitem = elm_widget_item_new(obj, Elm_Menu_Item);
if (!subitem) return NULL;
+ elm_widget_item_del_pre_hook_set(subitem, _item_del_pre_hook);
elm_widget_item_disable_hook_set(subitem, _item_disable_hook);
elm_widget_item_text_set_hook_set(subitem, _item_text_set_hook);
elm_widget_item_text_get_hook_set(subitem, _item_text_get_hook);
EAPI void
elm_menu_item_del(Elm_Object_Item *it)
{
- ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
- Elm_Menu_Item *item = (Elm_Menu_Item *) it;
- Elm_Object_Item *_item;
-
- elm_widget_item_pre_notify_del(item);
-
- EINA_LIST_FREE(item->submenu.items, _item) elm_menu_item_del(_item);
- if (item->label) eina_stringshare_del(item->label);
- if (item->content) evas_object_del(item->content);
- if (item->submenu.hv) evas_object_del(item->submenu.hv);
- if (item->submenu.location) evas_object_del(item->submenu.location);
-
- if (item->parent)
- item->parent->submenu.items = eina_list_remove(item->parent->submenu.items, item);
- else
- {
- Widget_Data *wd = elm_widget_data_get(WIDGET(item));
- wd->items = eina_list_remove(wd->items, item);
- }
-
- elm_widget_item_del(item);
+ elm_object_item_del(it);
}
EAPI void
EAPI Eina_Bool elm_menu_item_is_separator(Elm_Object_Item *it);
/**
- * @brief Deletes an item from the menu.
- *
- * @param it The item to delete.
- *
- * @see elm_menu_item_add()
- */
-EAPI void elm_menu_item_del(Elm_Object_Item *it);
-
-/**
* @brief Returns a list of @p item's subitems.
*
* @param it The item
wd = elm_widget_data_get(obj);
if (!wd) return;
- EINA_LIST_FREE(wd->seg_items, it) _item_free(it);
+ EINA_LIST_FREE(wd->seg_items, it)
+ {
+ _item_free(it);
+ elm_widget_item_free(it);
+ }
free(wd);
}
if (wd->selected_item == it) wd->selected_item = NULL;
if (wd->seg_items) wd->seg_items = eina_list_remove(wd->seg_items, it);
- elm_widget_item_pre_notify_del(it);
-
if (it->icon) evas_object_del(it->icon);
if (it->label) eina_stringshare_del(it->label);
-
- elm_widget_item_del(it);
}
static void
return ((Elm_Segment_Item *) it)->icon;
}
+static void
+_item_del_pre_hook(Elm_Object_Item *it)
+{
+ ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
+ Widget_Data *wd;
+ Elm_Segment_Item *item = (Elm_Segment_Item *) it;
+
+ wd = elm_widget_item_data_get(item);
+ if (!wd) return;
+
+ _item_free(item);
+ _update_list(wd);
+}
+
static Elm_Segment_Item*
_item_new(Evas_Object *obj, Evas_Object *icon, const char *label)
{
it = elm_widget_item_new(obj, Elm_Segment_Item);
if (!it) return NULL;
elm_widget_item_data_set(it, wd);
+ elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
elm_widget_item_text_set_hook_set(it, _item_text_set_hook);
elm_widget_item_text_get_hook_set(it, _item_text_get_hook);
elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
EAPI void
elm_segment_control_item_del(Elm_Object_Item *it)
{
- ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
- Widget_Data *wd;
- Elm_Segment_Item *item = (Elm_Segment_Item *) it;
-
- wd = elm_widget_item_data_get(item);
- if (!wd) return;
-
- _item_free(item);
- _update_list(wd);
+ elm_object_item_del(it);
}
EAPI void
it = _item_find(obj, idx);
if (!it) return;
- _item_free(it);
- _update_list(wd);
+ elm_object_item_del((Elm_Object_Item *) it);
}
EAPI const char*
* elm_segment_control_item_insert_at() should be used instead.
*
* Items created with this function can be deleted with function
- * elm_segment_control_item_del() or elm_segment_control_item_del_at().
+ * elm_object_item_del() or elm_segment_control_item_del_at().
*
* @note @p label set to @c NULL is different from empty string "".
* If an item
* @endcode
*
* @see elm_segment_control_item_insert_at()
- * @see elm_segment_control_item_del()
+ * @see elm_object_item_del()
*
* @ingroup SegmentControl
*/
* to segment control, just like elm_segment_control_item_add().
*
* Items created with this function can be deleted with function
- * elm_segment_control_item_del() or elm_segment_control_item_del_at().
+ * elm_object_item_del() or elm_segment_control_item_del_at().
*
* @note @p label set to @c NULL is different from empty string "".
* If an item
*
* @see elm_segment_control_item_add()
* @see elm_segment_control_item_count_get()
- * @see elm_segment_control_item_del()
+ * @see elm_object_item_del()
*
* @ingroup SegmentControl
*/
EAPI Elm_Object_Item *elm_segment_control_item_insert_at(Evas_Object *obj, Evas_Object *icon, const char *label, int index);
/**
- * Remove a segment control item from its parent, deleting it.
- *
- * @param it The item to be removed.
- *
- * Items can be added with elm_segment_control_item_add() or
- * elm_segment_control_item_insert_at().
- *
- * @ingroup SegmentControl
- */
-EAPI void elm_segment_control_item_del(Elm_Object_Item *it);
-
-/**
* Remove a segment control item at given index from its parent,
* deleting it.
*
return ECORE_CALLBACK_CANCEL;
}
+static void
+_item_del_pre_hook(Elm_Object_Item *it)
+{
+ ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
+
+ Elm_Slideshow_Item *item = (Elm_Slideshow_Item *) it;
+ Widget_Data *wd = elm_widget_data_get(WIDGET(item));
+ if (!wd) return;
+ if (wd->previous == item) wd->previous = NULL;
+ if (wd->current == item)
+ {
+ Eina_List *l = eina_list_data_find_list(wd->items, item);
+ Eina_List *l2 = eina_list_next(l);
+ wd->current = NULL;
+ if (!l2)
+ {
+ l2 = eina_list_prev(l);
+ if (l2)
+ elm_slideshow_show(eina_list_data_get(l2));
+
+ }
+ else
+ elm_slideshow_show(eina_list_data_get(l2));
+ }
+
+ wd->items = eina_list_remove_list(wd->items, item->l);
+ wd->items_built = eina_list_remove_list(wd->items_built, item->l_built);
+
+ if ((VIEW(item)) && (item->itc->func.del))
+ item->itc->func.del(elm_widget_item_data_get(item), VIEW(item));
+}
+
EAPI Evas_Object *
elm_slideshow_add(Evas_Object *parent)
{
if (!wd) return NULL;
item = elm_widget_item_new(obj, Elm_Slideshow_Item);
if (!item) return NULL;
-
+ elm_widget_item_del_pre_hook_set(item, _item_del_pre_hook);
item->itc = itc;
item->l = eina_list_append(item->l, item);
elm_widget_item_data_set(item, data);
item = elm_widget_item_new(obj, Elm_Slideshow_Item);
if (!item) return NULL;
-
+ elm_widget_item_del_pre_hook_set(item, _item_del_pre_hook);
item->itc = itc;
item->l = eina_list_append(item->l, item);
elm_widget_item_data_set(item, data);
{
if (item->itc->func.del)
item->itc->func.del(elm_widget_item_data_get(item), VIEW(item));
- evas_object_del(VIEW(item));
- VIEW(item) = NULL;
}
EINA_LIST_FREE(wd->items, item)
- {
- elm_widget_item_del(item);
- }
+ elm_widget_item_free(item);
}
EAPI void
elm_slideshow_item_del(Elm_Object_Item *it)
{
- ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
-
- Elm_Slideshow_Item *item = (Elm_Slideshow_Item *) it;
- Widget_Data *wd = elm_widget_data_get(WIDGET(item));
- if (!wd) return;
- if (wd->previous == item) wd->previous = NULL;
- if (wd->current == item)
- {
- Eina_List *l = eina_list_data_find_list(wd->items, item);
- Eina_List *l2 = eina_list_next(l);
- wd->current = NULL;
- if (!l2)
- {
- l2 = eina_list_prev(l);
- if (l2)
- elm_slideshow_show(eina_list_data_get(l2));
-
- }
- else
- elm_slideshow_show(eina_list_data_get(l2));
- }
-
- wd->items = eina_list_remove_list(wd->items, item->l);
- wd->items_built = eina_list_remove_list(wd->items_built, item->l_built);
-
- if ((VIEW(item)) && (item->itc->func.del))
- item->itc->func.del(elm_widget_item_data_get(item), VIEW(item));
- if (VIEW(item))
- evas_object_del(VIEW(item));
- free(item);
+ elm_object_item_del(it);
}
EAPI const Eina_List *
* This removes (and deletes) all items in @p obj, leaving it
* empty.
*
- * @see elm_slideshow_item_del(), to remove just one item.
+ * @see elm_object_item_del(), to remove just one item.
*
* @ingroup Slideshow
*/
*
* This list is @b not to be modified in any way and must not be
* freed. Use the list members with functions like
- * elm_slideshow_item_del(), elm_slideshow_item_data_get().
+ * elm_object_item_del(), elm_slideshow_item_data_get().
*
* @warning This list is only valid until @p obj object's internal
* items list is changed. It should be fetched again with another
EAPI const Eina_List *elm_slideshow_items_get(const Evas_Object *obj);
/**
- * Delete a given item from a slideshow widget.
- *
- * @param it The slideshow item
- *
- * @ingroup Slideshow
- */
-EAPI void elm_slideshow_item_del(Elm_Object_Item *it);
-
-/**
* Returns the currently displayed item, in a given slideshow widget
*
* @param obj The slideshow object
{
Elm_Toolbar_Item_State *it_state;
_item_unselect(it);
- elm_widget_item_pre_notify_del(it);
EINA_LIST_FREE(it->states, it_state)
{
if (it->icon == it_state->icon)
if (it->icon) evas_object_del(it->icon);
//TODO: See if checking for wd->menu_parent is necessary before deleting menu
if (it->o_menu) evas_object_del(it->o_menu);
- elm_widget_item_del(it);
}
static void
{
next = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
_item_del(it);
+ elm_widget_item_free(it);
it = next;
}
if (wd->more_item)
- _item_del(wd->more_item);
+ {
+ _item_del(wd->more_item);
+ elm_widget_item_free(wd->more_item);
+ }
if (wd->long_timer)
{
ecore_timer_del(wd->long_timer);
return NULL;
}
+static void
+_item_del_pre_hook(Elm_Object_Item *it)
+{
+ ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
+
+ Widget_Data *wd;
+ Evas_Object *obj2;
+ Elm_Toolbar_Item *item, *next;
+ item = (Elm_Toolbar_Item *) it;
+
+ wd = elm_widget_data_get(WIDGET(item));
+ if (!wd) return;
+ obj2 = WIDGET(item);
+ next = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
+ wd->items = eina_inlist_remove(wd->items, EINA_INLIST_GET(item));
+ wd->item_count--;
+ if (!next) next = ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items);
+ if (wd->always_select && item->selected && next) _item_select(next);
+ _item_del(item);
+ _theme_hook(obj2);
+}
+
static Elm_Toolbar_Item *
_item_new(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
{
return NULL;
}
+ elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
elm_widget_item_disable_hook_set(it, _item_disable_hook);
elm_widget_item_text_set_hook_set(it, _item_text_set_hook);
elm_widget_item_text_get_hook_set(it, _item_text_get_hook);
EAPI void
elm_toolbar_item_del(Elm_Object_Item *it)
{
- ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
-
- Widget_Data *wd;
- Evas_Object *obj2;
- Elm_Toolbar_Item *item, *next;
- item = (Elm_Toolbar_Item *) it;
-
- wd = elm_widget_data_get(WIDGET(item));
- if (!wd) return;
- obj2 = WIDGET(item);
- next = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
- wd->items = eina_inlist_remove(wd->items, EINA_INLIST_GET(item));
- wd->item_count--;
- if (!next) next = ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items);
- if (wd->always_select && item->selected && next) _item_select(next);
- _item_del(item);
- _theme_hook(obj2);
+ elm_object_item_del(it);
}
EAPI void
if (wd->more_item)
{
_item_del(wd->more_item);
+ elm_widget_item_free(wd->more_item);
wd->more_item = NULL;
}
* be set as @b last item.
*
* Items created with this method can be deleted with
- * elm_toolbar_item_del().
+ * elm_object_item_del().
*
* Associated @p data can be properly freed when item is deleted if a
* callback function is set with elm_object_item_del_cb_set().
* If an absolute path is provided it will load it direct from a file.
*
* @see elm_toolbar_item_icon_set()
- * @see elm_toolbar_item_del()
+ * @see elm_object_item_del()
*
* @ingroup Toolbar
*/
* be set as @b first item.
*
* Items created with this method can be deleted with
- * elm_toolbar_item_del().
+ * elm_object_item_del().
*
* Associated @p data can be properly freed when item is deleted if a
* callback function is set with elm_object_item_del_cb_set().
* If an absolute path is provided it will load it direct from a file.
*
* @see elm_toolbar_item_icon_set()
- * @see elm_toolbar_item_del()
+ * @see elm_object_item_del()
*
* @ingroup Toolbar
*/
* this toolbar will be just before item @p before.
*
* Items created with this method can be deleted with
- * elm_toolbar_item_del().
+ * elm_object_item_del().
*
* Associated @p data can be properly freed when item is deleted if a
* callback function is set with elm_object_item_del_cb_set().
* If an absolute path is provided it will load it direct from a file.
*
* @see elm_toolbar_item_icon_set()
- * @see elm_toolbar_item_del()
+ * @see elm_object_item_del()
*
* @ingroup Toolbar
*/
* this toolbar will be just after item @p after.
*
* Items created with this method can be deleted with
- * elm_toolbar_item_del().
+ * elm_object_item_del().
*
* Associated @p data can be properly freed when item is deleted if a
* callback function is set with elm_object_item_del_cb_set().
* If an absolute path is provided it will load it direct from a file.
*
* @see elm_toolbar_item_icon_set()
- * @see elm_toolbar_item_del()
+ * @see elm_object_item_del()
*
* @ingroup Toolbar
*/
EAPI Eina_Bool elm_toolbar_item_icon_file_set(Elm_Object_Item *it, const char *file, const char *key);
/**
- * Delete them item from the toolbar.
- *
- * @param it The item of toolbar to be deleted.
- *
- * @see elm_toolbar_item_append()
- *
- * @ingroup Toolbar
- */
-EAPI void elm_toolbar_item_del(Elm_Object_Item *it);
-
-
-/**
* Set or unset item as a separator.
*
* @param it The toolbar item.
return item;
}
+void
+_elm_widget_item_free(Elm_Widget_Item *item)
+{
+ ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
+
+ if (item->del_func)
+ item->del_func((void *)item->data, item->widget, item);
+
+ if (item->view)
+ evas_object_del(item->view);
+
+ if (item->access)
+ {
+ _elm_access_clear(item->access);
+ free(item->access);
+ item->access = NULL;
+ }
+ if (item->access_info)
+ {
+ eina_stringshare_del(item->access_info);
+ item->access_info = NULL;
+ }
+
+ EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
+ free(item);
+}
+
/**
* @internal
*
{
ELM_WIDGET_ITEM_CHECK_OR_RETURN(item);
- if (item->del_func)
- item->del_func((void *)item->data, item->widget, item);
-
+ //Widget delete callback
if (item->del_pre_func)
item->del_pre_func((Elm_Object_Item *) item);
- if (item->view)
- evas_object_del(item->view);
-
- if (item->access)
- {
- _elm_access_clear(item->access);
- free(item->access);
- item->access = NULL;
- }
- if (item->access_info)
- {
- eina_stringshare_del(item->access_info);
- item->access_info = NULL;
- }
-
- EINA_MAGIC_SET(item, EINA_MAGIC_NONE);
- free(item);
+ _elm_widget_item_free(item);
}
/**
Evas_Object *widget;
/**< the base view object */
Evas_Object *view;
- /**< item specific data. used for del callback*/
+ /**< item specific data. used for del callback */
const void *data;
+ /**< user delete callback function */
Evas_Smart_Cb del_func;
- /**< don't expose this callback call */
+ /**< widget delete callback function. don't expose this callback call */
Elm_Widget_Del_Pre_Cb del_pre_func;
Elm_Widget_Content_Set_Cb content_set_func;
EAPI void elm_widget_access_info_set(Evas_Object *obj, const char *txt);
EAPI const char *elm_widget_access_info_get(Evas_Object *obj);
EAPI Elm_Widget_Item *_elm_widget_item_new(Evas_Object *parent, size_t alloc_size);
+EAPI void _elm_widget_item_free(Elm_Widget_Item *item);
EAPI void _elm_widget_item_del(Elm_Widget_Item *item);
EAPI void _elm_widget_item_pre_notify_del(Elm_Widget_Item *item);
EAPI void _elm_widget_item_del_cb_set(Elm_Widget_Item *item, Evas_Smart_Cb del_cb);
#define elm_widget_item_new(parent, type) \
(type *)_elm_widget_item_new((parent), sizeof(type))
/**
+ * Convenience macro to free widget item, doing casts for you.
+ * @see _elm_widget_item_free()
+ * @param item a valid item.
+ */
+#define elm_widget_item_free(item) \
+ _elm_widget_item_free((Elm_Widget_Item *)item)
+
+/**
* Convenience macro to delete widget item, doing casts for you.
* @see _elm_widget_item_del()
* @param item a valid item.