]> Pileus Git - ~andy/gtk/blob - tests/testspinbutton.c
stylecontext: Do invalidation on first resize container
[~andy/gtk] / tests / testspinbutton.c
1 /* testspinbutton.c
2  * Copyright (C) 2004 Morten Welinder
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 #include "config.h"
19 #include <gtk/gtk.h>
20
21 static gint num_windows = 0;
22
23 static gboolean
24 on_delete_event (GtkWidget *w,
25                  GdkEvent *event,
26                  gpointer user_data)
27 {
28   num_windows--;
29   if (num_windows == 0)
30     gtk_main_quit ();
31
32   return FALSE;
33 }
34
35 static void
36 prepare_window_for_orientation (GtkOrientation orientation)
37 {
38   GtkWidget *window, *mainbox;
39   int max;
40
41   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
42   g_signal_connect (window, "delete_event", G_CALLBACK (on_delete_event), NULL);
43
44   mainbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
45   gtk_container_add (GTK_CONTAINER (window), mainbox);
46
47   for (max = 9; max <= 999999999; max = max * 10 + 9)
48     {
49       GtkAdjustment *adj = gtk_adjustment_new (max,
50                                                1, max,
51                                                1,
52                                                (max + 1) / 10,
53                                                0.0);
54
55       GtkWidget *spin = gtk_spin_button_new (adj, 1.0, 0);
56       gtk_orientable_set_orientation (GTK_ORIENTABLE (spin), orientation);
57       gtk_widget_set_halign (GTK_WIDGET (spin), GTK_ALIGN_CENTER);
58
59       GtkWidget *hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
60       gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, FALSE, 2);
61       gtk_container_add (GTK_CONTAINER (mainbox), hbox);
62     }
63
64   gtk_widget_show_all (window);
65   num_windows++;
66 }
67
68 int
69 main (int argc, char **argv)
70 {
71   gtk_init (&argc, &argv);
72
73   prepare_window_for_orientation (GTK_ORIENTATION_HORIZONTAL);
74   prepare_window_for_orientation (GTK_ORIENTATION_VERTICAL);
75
76   gtk_main ();
77
78   return 0;
79 }