elementary: add elm_progressbar_unit_format_function_set

SVN revision: 72197
This commit is contained in:
Michael BOUCHAUD 2012-06-15 16:32:54 +00:00
parent 4d5405a135
commit d24e7b363d
3 changed files with 46 additions and 1 deletions

View File

@ -192,3 +192,7 @@
2012-06-14 Michael Bouchaud
* Add an enum to Elm_Calendar_Mark_Repeat_Type:
ELM_CALENDAR_LAST_DAY_OF_MONTH
2012-06-15 Michael Bouchaud
* elm_progressbar: elm_progressbar_format_function_set to add a callback
function to format the unit string.

View File

@ -23,6 +23,9 @@ struct _Elm_Progressbar_Smart_Data
Eina_Bool inverted : 1;
Eina_Bool pulse : 1;
Eina_Bool pulse_state : 1;
char *(*unit_format_func)(double val);
void (*unit_format_free)(char *str);
};
#define ELM_PROGRESSBAR_DATA_GET(o, sd) \
@ -74,7 +77,15 @@ _units_set(Evas_Object *obj)
{
ELM_PROGRESSBAR_DATA_GET(obj, sd);
if (sd->units)
if (sd->unit_format_func)
{
char *buf;
buf = sd->unit_format_func(sd->val);
elm_layout_text_set(obj, "elm.text.status", buf);
if (sd->unit_format_free) sd->unit_format_free(buf);
}
else if (sd->units)
{
char buf[1024];
@ -428,6 +439,19 @@ elm_progressbar_unit_format_get(const Evas_Object *obj)
return sd->units;
}
EAPI void
elm_progressbar_unit_format_function_set(Evas_Object *obj, char *(func)(double), void (*free_func) (char *))
{
ELM_PROGRESSBAR_CHECK(obj);
ELM_PROGRESSBAR_DATA_GET(obj, sd);
sd->unit_format_func = func;
sd->unit_format_free = free_func;
_units_set(obj);
elm_layout_sizing_eval(obj);
}
EAPI void
elm_progressbar_horizontal_set(Evas_Object *obj,
Eina_Bool horizontal)

View File

@ -228,6 +228,23 @@ EAPI void elm_progressbar_unit_format_set(Evas_Object *o
*/
EAPI const char *elm_progressbar_unit_format_get(const Evas_Object *obj);
/**
* Set the format function pointer for the units label
*
* @param obj The progress bar object
* @param func The unit format function
* @param free_func The freeing function for the format string.
*
* Set the callback function to format the unit string.
*
* @see elm_progressbar_unit_format_set() for more info on how this works.
*
* @since 1.1.0
*
* @ingroup Progressbar
*/
EAPI void elm_progressbar_unit_format_function_set(Evas_Object *obj, char *(func)(double), void (*free_func) (char *));
/**
* Set the orientation of a given progress bar widget
*