Debian Codegraph @

testsuite/reftests/frame-inhibitor.c

raw
1 /*
2 * Copyright (C) 2014 Red Hat Inc.
3 *
4 * Author:
5 * Matthias Clasen <[email protected]>
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
27 static gboolean
28 tick_callback_for_1_frame (GtkWidget *widget,
29 GdkFrameClock *frame_clock,
30 gpointer unused)
31 {
32 reftest_uninhibit_snapshot ();
33
34 return G_SOURCE_REMOVE;
35 }
36
37 G_MODULE_EXPORT gboolean
38 inhibit_for_1_frame (GtkWidget *widget)
39 {
40 reftest_inhibit_snapshot ();
41 gtk_widget_add_tick_callback (widget,
42 tick_callback_for_1_frame,
43 NULL, NULL);
44
45 return FALSE;
46 }
47
48 static gboolean
49 tick_callback_for_2_frames (GtkWidget *widget,
50 GdkFrameClock *frame_clock,
51 gpointer unused)
52 {
53 inhibit_for_1_frame (widget);
54 reftest_uninhibit_snapshot ();
55
56 return G_SOURCE_REMOVE;
57 }
58
59 G_MODULE_EXPORT gboolean
60 inhibit_for_2_frames (GtkWidget *widget)
61 {
62 reftest_inhibit_snapshot ();
63 gtk_widget_add_tick_callback (widget,
64 tick_callback_for_2_frames,
65 NULL, NULL);
66
67 return FALSE;
68 }
69
70 static gboolean
71 tick_callback_for_3_frames (GtkWidget *widget,
72 GdkFrameClock *frame_clock,
73 gpointer unused)
74 {
75 inhibit_for_2_frames (widget);
76 reftest_uninhibit_snapshot ();
77
78 return G_SOURCE_REMOVE;
79 }
80
81 G_MODULE_EXPORT gboolean
82 inhibit_for_3_frames (GtkWidget *widget)
83 {
84 reftest_inhibit_snapshot ();
85 gtk_widget_add_tick_callback (widget,
86 tick_callback_for_3_frames,
87 NULL, NULL);
88
89 return FALSE;
90 }
91
92 G_MODULE_EXPORT gboolean
93 add_reference_class_if_no_animation (GtkWidget *widget)
94 {
95 gboolean enabled;
96 GtkStyleContext *context;
97
98 g_object_get (gtk_widget_get_settings (widget), "gtk-enable-animations", &enabled, NULL);
99 if (enabled)
100 return FALSE;
101
102 g_message ("Adding reference class because animation is disabled");
103
104 context = gtk_widget_get_style_context (widget);
105 gtk_style_context_add_class (context, "reference");
106
107 return FALSE;
108 }