1 /*
2 * this file is part of the oxygen gtk engine
3 * Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
4 *
5 * This  library is free  software; you can  redistribute it and/or
6 * modify it  under  the terms  of the  GNU Lesser  General  Public
7 * License  as published  by the Free  Software  Foundation; either
8 * version 2 of the License, or(at your option ) any later version.
9 *
10 * This library is distributed  in the hope that it will be useful,
11 * but  WITHOUT ANY WARRANTY; without even  the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License  along  with  this library;  if not,  write to  the Free
17 * Software Foundation, Inc., 51  Franklin St, Fifth Floor, Boston,
18 * MA 02110-1301, USA.
19 */
20 
21 #include "oxygenwidgetstateengine.h"
22 
23 namespace Oxygen
24 {
25 
26     //________________________________________________________
registerWidget(GtkWidget * widget,AnimationModes modes,const StyleOptions & options)27     bool WidgetStateEngine::registerWidget( GtkWidget* widget, AnimationModes modes, const StyleOptions& options )
28     {
29 
30         #if OXYGEN_DEBUG
31         std::cerr
32             << "Oxygen::WidgetStateEngine::registerWidget - "
33             << widget << " (" << G_OBJECT_TYPE_NAME( widget ) << ")"
34             << " mode: " << modes
35             << std::endl;
36         #endif
37 
38         bool registered( false );
39         if( (modes&AnimationHover) && registerWidget( widget, _hoverData, (options&Hover)&&!(options&Disabled) ) ) registered = true;
40         if( (modes&AnimationFocus) && registerWidget( widget, _focusData, (options&Focus)&&!(options&Disabled) ) ) registered = true;
41 
42         if( registered )
43         { BaseEngine::registerWidget( widget ); }
44 
45         return registered;
46 
47     }
48 
49     //________________________________________________________
registerWidget(GtkWidget * widget,DataMap<WidgetStateData> & dataMap,const bool & state) const50     bool WidgetStateEngine::registerWidget( GtkWidget* widget, DataMap<WidgetStateData>& dataMap, const bool& state ) const
51     {
52 
53         if( dataMap.contains( widget ) ) return false;
54 
55         WidgetStateData& data( dataMap.registerWidget( widget ) );
56         data.setEnabled( enabled() );
57         data.updateState( state );
58         data.setDuration( duration() );
59 
60         /*
61         blacklist some applications based on name and widget
62         the widget is effectively registered, but not connected
63         */
64         if( widgetIsBlackListed( widget ) ) return true;
65 
66         // connect
67         if( enabled() ) data.connect( widget );
68 
69         return true;
70 
71     }
72 
73 }
74