@@ -86,7 +86,9 @@ int Widget_SetAttributeEx(LCUI_Widget w, const char *name, void *value,
8686
8787int Widget_SetAttribute (LCUI_Widget w , const char * name , const char * value )
8888{
89+ int ret ;
8990 char * value_str ;
91+
9092 if (strcmp (name , "disabled" ) == 0 ) {
9193 if (!value || strcmp (value , "false" ) != 0 ) {
9294 Widget_SetDisabled (w , TRUE);
@@ -95,16 +97,21 @@ int Widget_SetAttribute(LCUI_Widget w, const char *name, const char *value)
9597 }
9698 return 0 ;
9799 }
98- if (!value ) {
99- return Widget_SetAttributeEx (w , name , NULL , LCUI_STYPE_NONE ,
100- NULL );
100+ if (value ) {
101+ value_str = strdup2 (value );
102+ if (!value_str ) {
103+ return - ENOMEM ;
104+ }
105+ ret = Widget_SetAttributeEx (w , name , value_str ,
106+ LCUI_STYPE_STRING , free );
107+ } else {
108+ ret = Widget_SetAttributeEx (w , name , NULL , LCUI_STYPE_NONE ,
109+ NULL );
101110 }
102- value_str = strdup2 (value );
103- if (!value_str ) {
104- return - ENOMEM ;
111+ if (w -> proto && w -> proto -> setattr ) {
112+ w -> proto -> setattr (w , name , value );
105113 }
106- return Widget_SetAttributeEx (w , name , value_str , LCUI_STYPE_STRING ,
107- free );
114+ return ret ;
108115}
109116
110117const char * Widget_GetAttribute (LCUI_Widget w , const char * name )
0 commit comments