forked from enlightenment/efl
elementary: make it possible to actually free string returned by value to string callback.
NOTE: this introduce an API/ABI incompatibility. You need to think if you need to free the data you allocated in the callback, if yes, then you need to provide a function to free that data, if not, you could just set NULL as the third parameter. SVN revision: 61019
This commit is contained in:
parent
2866ad9a72
commit
9a0a1410aa
|
@ -4155,7 +4155,8 @@ extern "C" {
|
|||
EAPI const char *elm_slider_unit_format_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
|
||||
EAPI void elm_slider_indicator_format_set(Evas_Object *obj, const char *indicator) EINA_ARG_NONNULL(1);
|
||||
EAPI const char *elm_slider_indicator_format_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
|
||||
EAPI void elm_slider_indicator_format_function_set(Evas_Object *obj, const char *(*func)(double val)) EINA_ARG_NONNULL(1);
|
||||
EAPI void elm_slider_indicator_format_function_set(Evas_Object *obj, const char *(*func)(double val), void (*free_func)(const char *str)) EINA_ARG_NONNULL(1);
|
||||
EAPI void elm_slider_units_format_function_set(Evas_Object *obj, const char *(*func)(double val), void (*free_func)(const char *str)) EINA_ARG_NONNULL(1);
|
||||
EAPI void elm_slider_horizontal_set(Evas_Object *obj, Eina_Bool horizontal) EINA_ARG_NONNULL(1);
|
||||
EAPI Eina_Bool elm_slider_horizontal_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
|
||||
EAPI void elm_slider_min_max_set(Evas_Object *obj, double min, double max) EINA_ARG_NONNULL(1);
|
||||
|
|
|
@ -46,16 +46,25 @@ struct _Widget_Data
|
|||
Evas_Object *icon;
|
||||
Evas_Object *end;
|
||||
Evas_Object *spacer;
|
||||
|
||||
Ecore_Timer *delay;
|
||||
|
||||
const char *label;
|
||||
const char *units;
|
||||
const char *indicator;
|
||||
|
||||
const char *(*indicator_format_func)(double val);
|
||||
void (*indicator_format_free)(const char *str);
|
||||
|
||||
const char *(*units_format_func)(double val);
|
||||
void (*units_format_free)(const char *str);
|
||||
|
||||
double val, val_min, val_max;
|
||||
Evas_Coord size;
|
||||
|
||||
Eina_Bool horizontal : 1;
|
||||
Eina_Bool inverted : 1;
|
||||
Eina_Bool indicator_show : 1;
|
||||
double val, val_min, val_max;
|
||||
Ecore_Timer *delay;
|
||||
Evas_Coord size;
|
||||
};
|
||||
|
||||
#define ELM_SLIDER_INVERTED_FACTOR (-1.0)
|
||||
|
@ -359,7 +368,14 @@ _units_set(Evas_Object *obj)
|
|||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (!wd) return;
|
||||
if (wd->units)
|
||||
if (wd->units_format_func)
|
||||
{
|
||||
const char *buf;
|
||||
buf = wd->units_format_func(wd->val);
|
||||
edje_object_part_text_set(wd->slider, "elm.units", buf);
|
||||
if (wd->units_format_free) wd->units_format_free(buf);
|
||||
}
|
||||
else if (wd->units)
|
||||
{
|
||||
char buf[1024];
|
||||
|
||||
|
@ -380,6 +396,7 @@ _indicator_set(Evas_Object *obj)
|
|||
const char *buf;
|
||||
buf = wd->indicator_format_func(wd->val);
|
||||
edje_object_part_text_set(wd->slider, "elm.dragable.slider:elm.indicator", buf);
|
||||
if (wd->indicator_format_free) wd->indicator_format_free(buf);
|
||||
}
|
||||
else if (wd->indicator)
|
||||
{
|
||||
|
@ -1021,7 +1038,7 @@ elm_slider_inverted_get(const Evas_Object *obj)
|
|||
}
|
||||
|
||||
/**
|
||||
* Set the format function pointer for the inducator area
|
||||
* Set the format function pointer for the indicator area
|
||||
*
|
||||
* Set the callback function to format the indicator string.
|
||||
* See elm_slider_indicator_format_set() for more info on how this works.
|
||||
|
@ -1029,16 +1046,42 @@ elm_slider_inverted_get(const Evas_Object *obj)
|
|||
* @param obj The slider object
|
||||
* @param indicator The format string for the indicator display
|
||||
* @param func The indicator format function
|
||||
* @param free_func The freeing function for the format string
|
||||
*
|
||||
* @ingroup Slider
|
||||
*/
|
||||
EAPI void
|
||||
elm_slider_indicator_format_function_set(Evas_Object *obj, const char *(*func)(double val))
|
||||
elm_slider_indicator_format_function_set(Evas_Object *obj, const char *(*func)(double val), void (*free_func)(const char *str))
|
||||
{
|
||||
ELM_CHECK_WIDTYPE(obj, widtype);
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (!wd) return;
|
||||
wd->indicator_format_func = func;
|
||||
wd->indicator_format_free = free_func;
|
||||
_indicator_set(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the format function pointer for the units area
|
||||
*
|
||||
* Set the callback function to format the indicator string.
|
||||
* See elm_slider_units_format_set() for more info on how this works.
|
||||
*
|
||||
* @param obj The slider object
|
||||
* @param indicator The format string for the units display
|
||||
* @param func The units format function
|
||||
* @param free_func The freeing function for the format string
|
||||
*
|
||||
* @ingroup Slider
|
||||
*/
|
||||
EAPI void
|
||||
elm_slider_units_format_function_set(Evas_Object *obj, const char *(*func)(double val), void (*free_func)(const char *str))
|
||||
{
|
||||
ELM_CHECK_WIDTYPE(obj, widtype);
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (!wd) return;
|
||||
wd->units_format_func = func;
|
||||
wd->units_format_free = free_func;
|
||||
_indicator_set(obj);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue