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 "oxygenarrowstatedata.h" 22 #include "../config.h" 23 24 #include <iostream> 25 26 namespace Oxygen 27 { 28 29 //_____________________________________________ connect(GtkWidget * widget)30 void ArrowStateData::connect( GtkWidget* widget ) 31 { 32 33 #if OXYGEN_DEBUG 34 std::cerr << "Oxygen::ArrowStateData::connect - " << widget << " (" << G_OBJECT_TYPE_NAME( widget ) << ")" << std::endl; 35 #endif 36 37 _target = widget; 38 _upArrowData._timeLine.connect( (GSourceFunc)delayedUpdate, this ); 39 _downArrowData._timeLine.connect( (GSourceFunc)delayedUpdate, this ); 40 } 41 42 //_____________________________________________ disconnect(GtkWidget * widget)43 void ArrowStateData::disconnect( GtkWidget* widget ) 44 { 45 #if OXYGEN_DEBUG 46 std::cerr << "Oxygen::ArrowStateData::disconnect - " << widget << " (" << G_OBJECT_TYPE_NAME( widget ) << ")" << std::endl; 47 #endif 48 49 _upArrowData._timeLine.disconnect(); 50 _upArrowData._state = false; 51 52 _downArrowData._timeLine.disconnect(); 53 _downArrowData._state = false; 54 55 _target = 0L; 56 57 } 58 59 //_____________________________________________ updateState(bool state)60 bool ArrowStateData::Data::updateState( bool state ) 61 { 62 if( state == _state ) return false; 63 64 #if OXYGEN_DEBUG 65 std::cerr 66 << "Oxygen::ArrowStateData::Data::updateState - " 67 << " state: " << state 68 << std::endl; 69 #endif 70 71 _state = state; 72 73 // change direction 74 _timeLine.setDirection( state ? TimeLine::Forward:TimeLine::Backward ); 75 76 // restart timeLine if needed 77 if( _timeLine.isConnected() && !_timeLine.isRunning() ) _timeLine.start(); 78 79 return true; 80 } 81 82 //_____________________________________________ delayedUpdate(gpointer pointer)83 gboolean ArrowStateData::delayedUpdate( gpointer pointer ) 84 { 85 86 ArrowStateData& data( *static_cast<ArrowStateData*>( pointer ) ); 87 88 if( data._target ) 89 { gtk_widget_queue_draw( data._target ); } 90 91 return FALSE; 92 93 } 94 95 } 96