]> Pileus Git - ~andy/gtk/blob - tests/testfullscreen.c
stylecontext: Do invalidation on first resize container
[~andy/gtk] / tests / testfullscreen.c
1 /* testfullscreen.c
2  * Copyright (C) 2013 Red Hat
3  * Author: Olivier Fourdan <ofourdan@redhat.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library 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.
9  *
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  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 #include "config.h"
20 #include <gtk/gtk.h>
21
22 static void
23 set_fullscreen_monitor_cb (GtkWidget *widget, gpointer user_data)
24 {
25   GdkFullscreenMode mode = (GdkFullscreenMode) GPOINTER_TO_INT (user_data);
26   GdkWindow  *window;
27
28   window = gtk_widget_get_parent_window (widget);
29   gdk_window_set_fullscreen_mode (window, mode);
30   gdk_window_fullscreen (window);
31 }
32
33 static void
34 remove_fullscreen_cb (GtkWidget *widget, gpointer user_data)
35 {
36   GdkWindow  *window;
37
38   window = gtk_widget_get_parent_window (widget);
39   gdk_window_unfullscreen (window);
40 }
41
42 int
43 main (int argc, char *argv[])
44 {
45   GtkWidget *window, *vbox, *button;
46
47   gtk_init (&argc, &argv);
48
49   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
50
51   vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
52   gtk_widget_set_valign (vbox, GTK_ALIGN_CENTER);
53   gtk_widget_set_halign (vbox, GTK_ALIGN_CENTER);
54   gtk_box_set_homogeneous (GTK_BOX (vbox), TRUE);
55   gtk_container_add (GTK_CONTAINER (window), vbox);
56
57   button = gtk_button_new_with_label ("Fullscreen on current monitor");
58   g_signal_connect (button, "clicked", G_CALLBACK (set_fullscreen_monitor_cb), GINT_TO_POINTER (GDK_FULLSCREEN_ON_CURRENT_MONITOR));
59   gtk_container_add (GTK_CONTAINER (vbox), button);
60
61   button = gtk_button_new_with_label ("Fullscreen on all monitors");
62   g_signal_connect (button, "clicked", G_CALLBACK (set_fullscreen_monitor_cb), GINT_TO_POINTER (GDK_FULLSCREEN_ON_ALL_MONITORS));
63   gtk_container_add (GTK_CONTAINER (vbox), button);
64
65   button = gtk_button_new_with_label ("Un-fullscreen");
66   g_signal_connect (button, "clicked", G_CALLBACK (remove_fullscreen_cb), NULL);
67   gtk_container_add (GTK_CONTAINER (vbox), button);
68
69   gtk_widget_show_all (window);
70
71   gtk_main ();
72
73   return 0;
74 }