1/*
2 * Copyright (C) 2014 Red Hat Inc.
3 *
4 * Author:
5 * Matthias Clasen <mclasen@redhat.com>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include "config.h"
22
23#include <gtk/gtk.h>
24
25#include "gtk-reftest.h"
26
27static gboolean
28tick_callback_for_1_frame (GtkWidget *widget,
29 GdkFrameClock *frame_clock,
30 gpointer unused)
31{
32 reftest_uninhibit_snapshot ();
33 gtk_widget_queue_draw (widget);
34
35 return G_SOURCE_REMOVE;
36}
37
38G_MODULE_EXPORT gboolean
39inhibit_for_1_frame (GtkWidget *widget)
40{
41 reftest_inhibit_snapshot ();
42 gtk_widget_add_tick_callback (widget,
43 callback: tick_callback_for_1_frame,
44 NULL, NULL);
45
46 return FALSE;
47}
48
49static gboolean
50tick_callback_for_2_frames (GtkWidget *widget,
51 GdkFrameClock *frame_clock,
52 gpointer unused)
53{
54 inhibit_for_1_frame (widget);
55 reftest_uninhibit_snapshot ();
56
57 return G_SOURCE_REMOVE;
58}
59
60G_MODULE_EXPORT gboolean
61inhibit_for_2_frames (GtkWidget *widget)
62{
63 reftest_inhibit_snapshot ();
64 gtk_widget_add_tick_callback (widget,
65 callback: tick_callback_for_2_frames,
66 NULL, NULL);
67
68 return FALSE;
69}
70
71static gboolean
72tick_callback_for_3_frames (GtkWidget *widget,
73 GdkFrameClock *frame_clock,
74 gpointer unused)
75{
76 inhibit_for_2_frames (widget);
77 reftest_uninhibit_snapshot ();
78
79 return G_SOURCE_REMOVE;
80}
81
82G_MODULE_EXPORT gboolean
83inhibit_for_3_frames (GtkWidget *widget)
84{
85 reftest_inhibit_snapshot ();
86 gtk_widget_add_tick_callback (widget,
87 callback: tick_callback_for_3_frames,
88 NULL, NULL);
89
90 return FALSE;
91}
92
93G_MODULE_EXPORT gboolean
94add_reference_class_if_no_animation (GtkWidget *widget)
95{
96 gboolean enabled;
97
98 g_object_get (object: gtk_widget_get_settings (widget), first_property_name: "gtk-enable-animations", &enabled, NULL);
99 if (enabled)
100 return FALSE;
101
102 g_message ("Adding reference class because animation is disabled");
103
104 gtk_widget_add_css_class (widget, css_class: "reference");
105
106 return FALSE;
107}
108

source code of gtk/testsuite/reftests/frame-inhibitor.c