elm_genlist_item_update(tit->item);
}
+static void
+my_gl_labels_update(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ Testitem *tit = data;
+ tit->mode++;
+ elm_genlist_item_fields_update(tit->item, "*", ELM_GENLIST_ITEM_FIELD_LABEL);
+}
+
+static void
+my_gl_contents_update(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+ Testitem *tit = data;
+ tit->mode++;
+ elm_genlist_item_fields_update(tit->item, "*", ELM_GENLIST_ITEM_FIELD_CONTENT);
+}
+
void
test_genlist3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
evas_object_show(bt);
bt = elm_button_add(win);
- elm_object_text_set(bt, "[2]");
- evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[1]));
+ elm_object_text_set(bt, "labels");
+ evas_object_smart_callback_add(bt, "clicked", my_gl_labels_update, &(tit[1]));
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
elm_box_pack_end(bx2, bt);
evas_object_show(bt);
bt = elm_button_add(win);
- elm_object_text_set(bt, "[3]");
- evas_object_smart_callback_add(bt, "clicked", my_gl_update, &(tit[2]));
+ elm_object_text_set(bt, "contents");
+ evas_object_smart_callback_add(bt, "clicked", my_gl_contents_update, &(tit[2]));
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
elm_box_pack_end(bx2, bt);
ELM_GENLIST_ITEM_SUBITEMS = (1 << 0), /**< may expand and have child items */
ELM_GENLIST_ITEM_GROUP = (1 << 1) /**< index of a group of items */
} Elm_Genlist_Item_Flags;
+ typedef enum _Elm_Genlist_Item_Field_Flags
+ {
+ ELM_GENLIST_ITEM_FIELD_ALL = 0,
+ ELM_GENLIST_ITEM_FIELD_LABEL = (1 << 0),
+ ELM_GENLIST_ITEM_FIELD_CONTENT = (1 << 1),
+ ELM_GENLIST_ITEM_FIELD_STATE = (1 << 2)
+ } Elm_Genlist_Item_Field_Flags;
typedef struct _Elm_Genlist_Item_Class Elm_Genlist_Item_Class; /**< Genlist item class definition structs */
#define Elm_Genlist_Item_Class Elm_Gen_Item_Class
typedef struct _Elm_Genlist_Item Elm_Genlist_Item; /**< Item of Elm_Genlist. Sub-type of Elm_Widget_Item */
*/
EAPI void elm_genlist_item_demote(Elm_Gen_Item *it) EINA_ARG_NONNULL(1);
/**
+ * Update the part of an item
+ *
+ * @param it The item
+ * @param parts The name of item's part
+ * @param itf The flags of item's part type
+ *
+ * This updates an item's part by calling item's fetching functions again
+ * to get the icons, labels and states. Use this when the original
+ * item data has changed and the changes are desired to be reflected.
+ * Second parts argument is used for globbing to match '*', '?', and '.'
+ * It can be used at updating multi fields.
+ *
+ * Use elm_genlist_realized_items_update() to update an item's all
+ * property.
+ *
+ * @see elm_genlist_item_update()
+ *
+ * @ingroup Genlist
+ */
+ EAPI void elm_genlist_item_fields_update(Elm_Genlist_Item *it, const char *parts, Elm_Genlist_Item_Field_Flags itf) EINA_ARG_NONNULL(1);
+ /**
* Update the item class of an item
*
* @param it The item
#include <assert.h>
-
+#include <fnmatch.h>
#include <Elementary.h>
#include <Elementary_Cursor.h>
#include "elm_priv.h"
static void
_item_label_realize(Elm_Gen_Item *it,
Evas_Object *target,
- Eina_List **source)
+ Eina_List **source,
+ const char *parts)
{
if (it->itc->func.label_get)
{
*source = elm_widget_stringlist_get(edje_object_data_get(target, "labels"));
EINA_LIST_FOREACH(*source, l, key)
{
+ if (parts && fnmatch(parts, key, FNM_PERIOD))
+ continue;
+
char *s = it->itc->func.label_get
((void *)it->base.data, WIDGET(it), key);
}
static Eina_List *
+_item_content_unrealize(Elm_Gen_Item *it,
+ Evas_Object *target,
+ Eina_List **source,
+ const char *parts)
+{
+ Eina_List *res = it->content_objs;
+
+ if (it->itc->func.content_get)
+ {
+ const Eina_List *l;
+ const char *key;
+ Evas_Object *ic = NULL;
+
+ EINA_LIST_FOREACH(*source, l, key)
+ {
+ if (parts && fnmatch(parts, key, FNM_PERIOD))
+ continue;
+
+ ic = edje_object_part_swallow_get(target, key);
+ if (ic)
+ {
+ res = eina_list_remove(res, ic);
+ edje_object_part_unswallow(target, ic);
+ evas_object_del(ic);
+ }
+ }
+ }
+
+ return res;
+}
+
+static Eina_List *
_item_content_realize(Elm_Gen_Item *it,
Evas_Object *target,
- Eina_List **source)
+ Eina_List **source,
+ const char *parts)
{
Eina_List *res = NULL;
Evas_Object *ic = NULL;
*source = elm_widget_stringlist_get(edje_object_data_get(target, "contents"));
+
+ if (parts && (eina_list_count(*source) != eina_list_count(it->content_objs)))
+ res = it->content_objs;
+
EINA_LIST_FOREACH(*source, l, key)
{
+ if (parts && fnmatch(parts, key, FNM_PERIOD))
+ continue;
+
if (it->itc->func.content_get)
ic = it->itc->func.content_get
((void *)it->base.data, WIDGET(it), key);
static void
_item_state_realize(Elm_Gen_Item *it,
Evas_Object *target,
- Eina_List **source)
+ Eina_List **source,
+ const char *parts)
{
if (it->itc->func.state_get)
{
*source = elm_widget_stringlist_get(edje_object_data_get(target, "states"));
EINA_LIST_FOREACH(*source, l, key)
{
+ if (parts && fnmatch(parts, key, FNM_PERIOD))
+ continue;
+
Eina_Bool on = it->itc->func.state_get
((void *)it->base.data, WIDGET(it), key);
will clean our mess */
assert(eina_list_count(it->content_objs) == 0);
- _item_label_realize(it, VIEW(it), &it->labels);
- it->content_objs = _item_content_realize(it, VIEW(it), &it->contents);
- _item_state_realize(it, VIEW(it), &it->states);
+ _item_label_realize(it, VIEW(it), &it->labels, NULL);
+ it->content_objs = _item_content_realize(it, VIEW(it), &it->contents, NULL);
+ _item_state_realize(it, VIEW(it), &it->states, NULL);
if (!it->item->mincalcd)
{
will clean our mess */
assert(eina_list_count(it->item->mode_content_objs) == 0);
- _item_label_realize(it, it->item->mode_view, &it->item->mode_labels);
- it->item->mode_content_objs = _item_content_realize(it,
- it->item->mode_view,
- &it->item->mode_contents);
- _item_state_realize(it, it->item->mode_view, &it->item->mode_states);
+ _item_label_realize(it, it->item->mode_view, &it->item->mode_labels, NULL);
+ it->item->mode_content_objs =
+ _item_content_realize(it, it->item->mode_view,
+ &it->item->mode_contents, NULL);
+ _item_state_realize(it, it->item->mode_view, &it->item->mode_states, NULL);
edje_object_part_swallow(it->item->mode_view,
edje_object_data_get(it->item->mode_view, "mode_part"),
}
EAPI void
+elm_genlist_item_fields_update(Elm_Genlist_Item *it,
+ const char *parts,
+ Elm_Genlist_Item_Field_Flags itf)
+{
+ ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
+ if (!it->item->block) return;
+ if (it->delete_me) return;
+
+ if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_LABEL))
+ _item_label_realize(it, it->base.view, &it->labels, parts);
+ if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_CONTENT))
+ {
+ it->content_objs = _item_content_unrealize(it, it->base.view,
+ &it->contents, parts);
+ it->content_objs = _item_content_realize(it, it->base.view,
+ &it->contents, parts);
+ }
+ if ((!itf) || (itf & ELM_GENLIST_ITEM_FIELD_STATE))
+ _item_state_realize(it, it->base.view, &it->states, parts);
+}
+
+EAPI void
elm_genlist_item_item_class_update(Elm_Gen_Item *it,
const Elm_Genlist_Item_Class *itc)
{