1 /* widget-factory: a collection of widgets in a single page, for easy
4 * Copyright (C) 2011 Canonical Ltd
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
21 * Authored by Andrea Cimitan <andrea.cimitan@canonical.com>
28 dark_toggled (GtkCheckMenuItem *item, gpointer data)
32 dark = gtk_check_menu_item_get_active (item);
33 g_object_set (gtk_settings_get_default (),
34 "gtk-application-prefer-dark-theme", dark,
39 main (int argc, char *argv[])
44 gboolean dark = FALSE;
46 gtk_init (&argc, &argv);
48 if (argc > 1 && (g_strcmp0 (argv[1], "--dark") == 0))
51 builder = gtk_builder_new ();
52 gtk_builder_add_from_file (builder, "./widget-factory.ui", NULL);
54 window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
55 gtk_builder_connect_signals (builder, NULL);
57 widget = (GtkWidget*) gtk_builder_get_object (builder, "darkmenuitem");
58 g_signal_connect (widget, "toggled", G_CALLBACK (dark_toggled), NULL);
59 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (widget), dark);
61 g_object_unref (G_OBJECT (builder));
63 gtk_widget_show (window);