Enlightenment CVS committal Author : dj2 Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: ewl_icon.c ewl_icon.h Log Message: - allow the setting of alternate text on an icon. if the icon is missing this text will be shown =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_icon.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -3 -r1.18 -r1.19 --- ewl_icon.c 6 Sep 2006 16:38:03 -0000 1.18 +++ ewl_icon.c 8 Oct 2006 01:46:59 -0000 1.19 @@ -131,7 +131,8 @@ if (icon->preview) { - constrain = ewl_icon_constrain_get(icon); + if (ewl_widget_type_is(icon->preview, EWL_IMAGE_TYPE)) + constrain = ewl_icon_constrain_get(icon); ewl_widget_destroy(icon->preview); } @@ -390,7 +391,8 @@ DCHECK_PARAM_PTR("icon", icon); DCHECK_TYPE("icon", icon, EWL_ICON_TYPE); - ewl_image_constrain_set(EWL_IMAGE(icon->preview), val); + if (icon->preview) + ewl_image_constrain_set(EWL_IMAGE(icon->preview), val); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -403,12 +405,15 @@ unsigned int ewl_icon_constrain_get(Ewl_Icon *icon) { - unsigned int constrain; + unsigned int constrain = 0; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET("icon", icon, 0); DCHECK_TYPE_RET("icon", icon, EWL_ICON_TYPE, 0); + if (!ewl_widget_type_is(icon->preview, EWL_IMAGE_TYPE)) + DRETURN_INT(constrain, DLEVEL_STABLE); + constrain = ewl_image_constrain_get(EWL_IMAGE(icon->preview)); DRETURN_INT(constrain, DLEVEL_STABLE); @@ -450,6 +455,58 @@ DCHECK_TYPE_RET("icon", icon, EWL_ICON_TYPE, FALSE); DRETURN_INT(icon->compress_label, DLEVEL_STABLE); +} + +/** + * @param icon: The icon to work with + * @param txt: The text to set as the alternate text + * @return Returns no value + * @brief Sets the given text as the alternate text for the icon + */ +void +ewl_icon_alt_text_set(Ewl_Icon *icon, const char *txt) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("icon", icon); + DCHECK_TYPE("icon", icon, EWL_ICON_TYPE); + + IF_FREE(icon->alt_text); + if (!txt && icon->preview && + ewl_widget_type_is(icon->preview, EWL_LABEL_TYPE)) + { + ewl_widget_destroy(icon->preview); + icon->preview = NULL; + + DRETURN(DLEVEL_STABLE); + } + + icon->alt_text = strdup(txt); + if (!icon->preview) + { + icon->preview = ewl_label_new(); + ewl_label_text_set(EWL_LABEL(icon->preview), icon->alt_text); + ewl_container_child_prepend(EWL_CONTAINER(icon), icon->preview); + ewl_widget_show(icon->preview); + } + else if (ewl_widget_type_is(icon->preview, EWL_LABEL_TYPE)) + ewl_label_text_set(EWL_LABEL(icon->preview), icon->alt_text); + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @param icon: The icon to work with + * @return Returns the alternate text set on the icon + * @brief Retrieves the alternate text set on the icon + */ +const char * +ewl_icon_alt_text_get(Ewl_Icon *icon) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR_RET("icon", icon, NULL); + DCHECK_TYPE_RET("icon", icon, EWL_ICON_TYPE, NULL); + + DRETURN_PTR(icon->alt_text, DLEVEL_STABLE); } /** =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_icon.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- ewl_icon.h 21 May 2006 07:22:44 -0000 1.6 +++ ewl_icon.h 8 Oct 2006 01:46:59 -0000 1.7 @@ -37,6 +37,7 @@ Ewl_Widget *extended; /**< The icons extended information */ char *label_text; /**< The label text */ + char *alt_text; /**< The alternate text */ Ewl_Icon_Type type; /**< The icons type */ unsigned char editable:1; /**< Is the icon editable? */ @@ -71,6 +72,9 @@ void ewl_icon_label_compressed_set(Ewl_Icon *icon, unsigned int compress); unsigned int ewl_icon_label_compressed_get(Ewl_Icon *icon); + +void ewl_icon_alt_text_set(Ewl_Icon *icon, const char *txt); +const char *ewl_icon_alt_text_get(Ewl_Icon *icon); /* * Internal stuff ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs