| 317 | } |
| 318 | |
| 319 | bool Engine::SetProperty( sfg::Selector::Ptr selector, const std::string& property, const std::string& value ) { |
| 320 | if( !selector ) { |
| 321 | // Invalid selector string given. |
| 322 | return false; |
| 323 | } |
| 324 | |
| 325 | // If the selector does already exist, we'll remove it to make sure the newly |
| 326 | // added value will get a higher priority than the previous one, because |
| 327 | // that's the expected behaviour (LIFO). |
| 328 | SelectorValueList& list( m_properties[property][selector->GetWidgetName()] ); // Shortcut. |
| 329 | SelectorValueList::iterator list_begin( list.begin() ); |
| 330 | SelectorValueList::iterator list_end( list.end() ); |
| 331 | |
| 332 | for( ; list_begin != list_end; ++list_begin ) { |
| 333 | if( *list_begin->first == *selector ) { |
| 334 | // Equal, remove. |
| 335 | list.erase( list_begin ); |
| 336 | break; |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | // Insert at top to get highest priority. |
| 341 | list.insert( list.begin(), SelectorValuePair( selector, value ) ); |
| 342 | |
| 343 | if( m_auto_refresh ) { |
| 344 | Widget::RefreshAll(); |
| 345 | } |
| 346 | |
| 347 | return true; |
| 348 | } |
| 349 | |
| 350 | bool Engine::SetProperties( const std::string& properties ) { |
| 351 | auto theme = parser::theme::ParseString( properties ); |