2
* This file is part of libslab.
4
* Copyright (c) 2006, 2007 Novell, Inc.
6
* Libslab is free software; you can redistribute it and/or modify it under the
7
* terms of the GNU Lesser General Public License as published by the Free
8
* Software Foundation; either version 2 of the License, or (at your option)
11
* Libslab is distributed in the hope that it will be useful, but WITHOUT ANY
12
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with libslab; if not, write to the Free Software Foundation, Inc., 51
18
* Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
#include "double-click-detector.h"
25
#include "libslab-utils.h"
27
G_DEFINE_TYPE (DoubleClickDetector, double_click_detector, G_TYPE_OBJECT);
30
double_click_detector_class_init (DoubleClickDetectorClass * detector_class)
35
double_click_detector_init (DoubleClickDetector * detector)
37
GtkSettings *settings;
40
settings = gtk_settings_get_default ();
42
g_object_get (G_OBJECT (settings), "gtk-double-click-time", &click_interval, NULL);
44
detector->double_click_time = (guint32) click_interval;
45
detector->last_click_time = 0;
49
double_click_detector_new ()
51
return g_object_new (DOUBLE_CLICK_DETECTOR_TYPE, NULL);
55
double_click_detector_is_double_click (DoubleClickDetector *this, guint32 event_time,
61
event_time = libslab_get_current_time_millis ();
63
if (this->last_click_time <= 0) {
65
double_click_detector_update_click_time (this, event_time);
70
delta = event_time - this->last_click_time;
73
double_click_detector_update_click_time (this, event_time);
75
return delta < this->double_click_time;
79
double_click_detector_update_click_time (DoubleClickDetector *this, guint32 event_time)
82
event_time = libslab_get_current_time_millis ();
84
this->last_click_time = event_time;