gui: Use genlist instead of list for the widget styles list.

Now I can show the full group name of a style as well as a simple style
name.
This commit is contained in:
Daniel Juyung Seo 2014-03-20 04:19:49 +09:00
parent de406e5b38
commit 1ab464812f
2 changed files with 36 additions and 5 deletions

View File

@ -596,6 +596,27 @@ _gui_widget_style_exclude_check(Widget_Type type, const char *style)
}
}
static char *
_gl_text_get_cb(void *data, Evas_Object *obj EINA_UNUSED, const char *part)
{
Style_Data *sd = data;
Widget_Data_Style *wds = sd->wds;
if (!strcmp(part, "elm.text"))
return strdup(wds->simple);
else
return strdup(wds->group);
}
static void
_gl_del_cb(void *data, Evas_Object *obj EINA_UNUSED)
{
Style_Data *sd = data;
// do not need to free the internals of Style_Data
free(sd);
}
static Evas_Object *
_gui_widget_style_load(Evas_Object *parent, Widget_Type type)
{
@ -603,10 +624,18 @@ _gui_widget_style_load(Evas_Object *parent, Widget_Type type)
Eina_List *styles = NULL, *l = NULL;
Widget_Data_Style *wds = NULL;
Style_Data *sd = NULL;
Elm_Genlist_Item_Class *itc = NULL;
itc = elm_genlist_item_class_new();
itc->item_style = "double_label";
itc->func.text_get = _gl_text_get_cb;
itc->func.content_get = NULL;
itc->func.state_get = NULL;
itc->func.del = _gl_del_cb;
// widget styles list
o = elm_list_add(parent);
elm_list_select_mode_set(o, ELM_OBJECT_SELECT_MODE_ALWAYS);
gd->left_menu_style_genlist = o = elm_genlist_add(parent);
elm_genlist_select_mode_set(o, ELM_OBJECT_SELECT_MODE_ALWAYS);
styles = theme_widget_styles_get(type);
EINA_LIST_FOREACH(styles, l, wds)
{
@ -617,14 +646,15 @@ _gui_widget_style_load(Evas_Object *parent, Widget_Type type)
sd = (Style_Data *)calloc(1, sizeof(Style_Data));
sd->widget_type = type;
sd->wds = wds;
elm_list_item_append(o, wds->style, NULL, NULL, _style_list_sel_cb, sd);
elm_genlist_item_append(o, itc, sd, NULL, ELM_GENLIST_ITEM_NONE,
_style_list_sel_cb, sd);
}
// add additional hacky custom styles for special reasons
//_custom_styles_add(o, type);
elm_list_item_selected_set(elm_list_first_item_get(o), EINA_TRUE);
elm_list_go(o);
elm_genlist_item_selected_set(elm_genlist_first_item_get(o), EINA_TRUE);
elm_genlist_item_class_free(itc);
return o;
}

View File

@ -12,6 +12,7 @@ struct _Gui_Data
Evas_Object *left_menu_box;
Eina_Bool left_menu_widget_desc; // true if widget desc is created
Evas_Object *left_menu_style_genlist; // genlist for the widget styles on the left menu
Evas_Object *preview_bg;
Evas_Object *preview_box;