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, see <http://www.gnu.org/licenses/>.
19 * Authored by Andrea Cimitan <andrea.cimitan@canonical.com>
27 dark_toggled (GtkCheckMenuItem *item, gpointer data)
31 dark = gtk_check_menu_item_get_active (item);
32 g_object_set (gtk_settings_get_default (),
33 "gtk-application-prefer-dark-theme", dark,
38 show_about (GtkMenuItem *item, GtkWidget *window)
41 const gchar *authors[] = {
47 pixbuf = gdk_pixbuf_new_from_resource ("/logos/gtk-logo-256.png", NULL);
49 gtk_show_about_dialog (GTK_WINDOW (window),
50 "program-name", "GTK+ Widget Factory",
51 "version", g_strdup_printf ("%s,\nRunning against GTK+ %d.%d.%d",
53 gtk_get_major_version (),
54 gtk_get_minor_version (),
55 gtk_get_micro_version ()),
56 "copyright", "(C) 1997-2009 The GTK+ Team",
57 "license-type", GTK_LICENSE_LGPL_2_1,
58 "website", "http://www.gtk.org",
59 "comments", "Program to demonstrate GTK+ themes and widgets",
62 "title", "About GTK+ Widget Factory",
65 g_object_unref (pixbuf);
69 main (int argc, char *argv[])
74 gboolean dark = FALSE;
76 gtk_init (&argc, &argv);
78 if (argc > 1 && (g_strcmp0 (argv[1], "--dark") == 0))
81 builder = gtk_builder_new ();
82 gtk_builder_add_from_resource (builder, "/ui/widget-factory.ui", NULL);
84 window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
85 gtk_builder_connect_signals (builder, NULL);
87 widget = (GtkWidget*) gtk_builder_get_object (builder, "darkmenuitem");
88 g_signal_connect (widget, "toggled", G_CALLBACK (dark_toggled), NULL);
89 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (widget), dark);
91 widget = (GtkWidget*) gtk_builder_get_object (builder, "aboutmenuitem");
92 g_signal_connect (widget, "activate", G_CALLBACK (show_about), window);
94 g_object_unref (G_OBJECT (builder));
96 gtk_widget_show (window);