item);
}
-static void
-_item_icon_set(Elm_Ctxpopup_Item_Data *item,
- Evas_Object *icon)
-{
- if (item->icon)
- evas_object_del(item->icon);
-
- item->icon = icon;
- if (!icon) return;
-
- edje_object_part_swallow(VIEW(item), "elm.swallow.icon", item->icon);
-}
-
-static void
-_item_label_set(Elm_Ctxpopup_Item_Data *item,
- const char *label)
-{
- if (!eina_stringshare_replace(&item->label, label))
- return;
-
- ELM_CTXPOPUP_DATA_GET(WIDGET(item), sd);
-
- edje_object_part_text_set(VIEW(item), "elm.text", label);
- if (sd->visible) _item_sizing_eval(item);
-}
-
static Evas_Object *
_item_in_focusable_button(Elm_Ctxpopup_Item_Data *item)
{
const char *part,
const char *label)
{
+ if (!ctxpopup_it) return;
+ if (ctxpopup_it->label == label) return;
if ((part) && (strcmp(part, "default"))) return;
- _item_label_set(ctxpopup_it, label);
+ ELM_CTXPOPUP_DATA_GET(WIDGET(ctxpopup_it), sd);
+
+ if (ctxpopup_it->label && !label)
+ {
+ if (!sd->horizontal)
+ _elm_theme_object_set(WIDGET(ctxpopup_it), VIEW(ctxpopup_it), "ctxpopup",
+ "icon_style_item",
+ elm_widget_style_get(WIDGET(ctxpopup_it)));
+ else
+ _elm_theme_object_set(WIDGET(ctxpopup_it), VIEW(ctxpopup_it), "ctxpopup",
+ "icon_style_item_horizontal",
+ elm_widget_style_get(WIDGET(ctxpopup_it)));
+ }
+ else if (!ctxpopup_it->label && label)
+ {
+ if (!ctxpopup_it->icon)
+ {
+ if (!sd->horizontal)
+ _elm_theme_object_set(WIDGET(ctxpopup_it), VIEW(ctxpopup_it), "ctxpopup",
+ "text_style_item",
+ elm_widget_style_get(WIDGET(ctxpopup_it)));
+ else
+ _elm_theme_object_set(WIDGET(ctxpopup_it), VIEW(ctxpopup_it), "ctxpopup",
+ "text_style_item_horizontal",
+ elm_widget_style_get(WIDGET(ctxpopup_it)));
+ }
+ else
+ {
+ if (!sd->horizontal)
+ _elm_theme_object_set(WIDGET(ctxpopup_it), VIEW(ctxpopup_it), "ctxpopup",
+ "icon_text_style_item",
+ elm_widget_style_get(WIDGET(ctxpopup_it)));
+ else
+ _elm_theme_object_set(WIDGET(ctxpopup_it), VIEW(ctxpopup_it), "ctxpopup",
+ "icon_text_style_item_horizontal",
+ elm_widget_style_get(WIDGET(ctxpopup_it)));
+ }
+ }
+
+ eina_stringshare_replace(&ctxpopup_it->label, label);
+ if (ctxpopup_it->label)
+ edje_object_part_text_set(VIEW(ctxpopup_it), "elm.text", label);
+
+ sd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
+
+ if (sd->visible)
+ elm_layout_sizing_eval(WIDGET(ctxpopup_it));
}
EOLIAN static const char *
const char *part,
Evas_Object *content)
{
+ if (!ctxpopup_it) return;
+ if (ctxpopup_it->icon == content) return;
if ((part) && (strcmp(part, "icon"))) return;
ELM_CTXPOPUP_DATA_GET(WIDGET(ctxpopup_it), sd);
- _item_icon_set(ctxpopup_it, content);
+ if (ctxpopup_it->icon)
+ evas_object_del(ctxpopup_it->icon);
+
+ if (ctxpopup_it->label)
+ {
+ if (!ctxpopup_it->icon && content)
+ {
+ if (!sd->horizontal)
+ _elm_theme_object_set(WIDGET(ctxpopup_it), VIEW(ctxpopup_it), "ctxpopup",
+ "icon_text_style_item",
+ elm_widget_style_get(WIDGET(ctxpopup_it)));
+ else
+ _elm_theme_object_set(WIDGET(ctxpopup_it), VIEW(ctxpopup_it), "ctxpopup",
+ "icon_text_style_item_horizontal",
+ elm_widget_style_get(WIDGET(ctxpopup_it)));
+ }
+ else if (ctxpopup_it->icon && !content)
+ {
+ if (!sd->horizontal)
+ _elm_theme_object_set(WIDGET(ctxpopup_it), VIEW(ctxpopup_it), "ctxpopup",
+ "text_style_item",
+ elm_widget_style_get(WIDGET(ctxpopup_it)));
+ else
+ _elm_theme_object_set(WIDGET(ctxpopup_it), VIEW(ctxpopup_it), "ctxpopup",
+ "text_style_item_horizontal",
+ elm_widget_style_get(WIDGET(ctxpopup_it)));
+ }
+ }
+
+ ctxpopup_it->icon = content;
+ if (ctxpopup_it->icon)
+ edje_object_part_swallow(VIEW(ctxpopup_it), "elm.swallow.icon", ctxpopup_it->icon);
+
sd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
if (sd->visible)
_item_theme_set(item, "icon_style_item_horizontal");
}
- _item_icon_set(item, icon);
- _item_label_set(item, label);
+ if (label)
+ {
+ edje_object_part_text_set(VIEW(item), "elm.text", label);
+ item->label = eina_stringshare_add(label);
+ }
+
+ if (icon)
+ {
+ edje_object_part_swallow(VIEW(item), "elm.swallow.icon", icon);
+ item->icon = icon;
+ }
+
focus_bt = _item_in_focusable_button(item);
item->btn = focus_bt;
_elm_widget_color_class_parent_set(VIEW(item), obj);