2
* this file is part of the oxygen gtk engine
3
* Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
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.
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.
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,
21
#include "oxygenscrollbardata.h"
22
#include "../oxygengtkutils.h"
29
//________________________________________________________________________________
30
void ScrollBarData::connect( GtkWidget* widget )
34
_valueChangedId.connect( G_OBJECT(widget), "value-changed", G_CALLBACK( valueChanged ), this );
37
//________________________________________________________________________________
38
void ScrollBarData::disconnect( GtkWidget* )
42
// reset timeout and locked flag
46
_valueChangedId.disconnect();
49
//________________________________________________________________________________
50
void ScrollBarData::valueChanged( GtkRange* widget, gpointer pointer )
53
ScrollBarData& data( *static_cast<ScrollBarData*>( pointer ) );
54
if( data._updatesDelayed )
57
// schedule delayed timeOut
58
if( !data._timer.isRunning() )
61
data._timer.start( data._delay, (GSourceFunc)delayedUpdate, &data );
64
} else data._locked = true;
67
} else if( GtkWidget* parent = Gtk::gtk_parent_scrolled_window( GTK_WIDGET( widget ) ) ) {
69
gtk_widget_queue_draw( parent );
76
//________________________________________________________________________________
77
gboolean ScrollBarData::delayedUpdate( gpointer pointer )
80
ScrollBarData& data( *static_cast<ScrollBarData*>(pointer) );
85
// if target is invalid, reset timeout and return
89
} else if( data._locked ) {
91
// if locked, reset the flag and re-run timer
95
} else if( GtkWidget* parent = Gtk::gtk_parent_scrolled_window( GTK_WIDGET( data._target ) ) ) {
97
// otherwise, trigger update
98
gtk_widget_queue_draw( parent );
103
// if everything fails, unlock and do nothing
104
data._locked = false;