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
17 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
20 * Author: Cosimo Cecchi <cosimoc@gnome.org>
27 dark_button_toggled_cb (GtkToggleButton *button,
30 gboolean active = gtk_toggle_button_get_active (button);
31 GtkSettings *settings = gtk_settings_get_default ();
33 g_object_set (settings,
34 "gtk-application-prefer-dark-theme", active,
39 create_dark_popup (GtkWidget *parent)
41 GtkWidget *popup = gtk_window_new (GTK_WINDOW_TOPLEVEL);
42 GtkWidget *button = gtk_toggle_button_new_with_label ("Dark");
44 gtk_window_set_decorated (GTK_WINDOW (popup), FALSE);
45 gtk_widget_set_size_request (popup, 100, 100);
46 gtk_window_set_resizable (GTK_WINDOW (popup), FALSE);
48 g_signal_connect (popup, "delete-event",
49 G_CALLBACK (gtk_true), NULL);
51 gtk_container_add (GTK_CONTAINER (popup), button);
52 g_signal_connect (button, "toggled",
53 G_CALLBACK (dark_button_toggled_cb), NULL);
55 gtk_window_set_transient_for (GTK_WINDOW (popup), GTK_WINDOW (parent));
57 gtk_widget_show_all (popup);
61 main (int argc, char *argv[])
65 const gchar *filename;
67 gtk_init (&argc, &argv);
73 builder = gtk_builder_new ();
74 gtk_builder_add_from_file (builder, filename, NULL);
76 window = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
77 g_object_unref (G_OBJECT (builder));
78 g_signal_connect (window, "destroy",
79 G_CALLBACK (gtk_main_quit), NULL);
80 gtk_widget_show_all (window);
82 create_dark_popup (window);