1 /* visuals: UI runner for visual GtkBuilder files
3 * Copyright (C) 2012 Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser 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.
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 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free
18 * Author: Cosimo Cecchi <cosimoc@gnome.org>
25 dark_button_toggled_cb (GtkToggleButton *button,
28 gboolean active = gtk_toggle_button_get_active (button);
29 GtkSettings *settings = gtk_settings_get_default ();
31 g_object_set (settings,
32 "gtk-application-prefer-dark-theme", active,
37 create_dark_popup (GtkWidget *parent)
39 GtkWidget *popup = gtk_window_new (GTK_WINDOW_TOPLEVEL);
40 GtkWidget *button = gtk_toggle_button_new_with_label ("Dark");
42 gtk_window_set_decorated (GTK_WINDOW (popup), FALSE);
43 gtk_widget_set_size_request (popup, 100, 100);
44 gtk_window_set_resizable (GTK_WINDOW (popup), FALSE);
46 g_signal_connect (popup, "delete-event",
47 G_CALLBACK (gtk_true), NULL);
49 gtk_container_add (GTK_CONTAINER (popup), button);
50 g_signal_connect (button, "toggled",
51 G_CALLBACK (dark_button_toggled_cb), NULL);
53 gtk_window_set_transient_for (GTK_WINDOW (popup), GTK_WINDOW (parent));
55 gtk_widget_show_all (popup);
59 main (int argc, char *argv[])
63 const gchar *filename;
65 gtk_init (&argc, &argv);
71 builder = gtk_builder_new ();
72 gtk_builder_add_from_file (builder, filename, NULL);
74 window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
75 g_object_unref (G_OBJECT (builder));
76 g_signal_connect (window, "destroy",
77 G_CALLBACK (gtk_main_quit), NULL);
78 gtk_widget_show_all (window);
80 create_dark_popup (window);