]> Pileus Git - ~andy/gtk/blob - tests/testfontchooser.c
Test non-xml-clean preview text
[~andy/gtk] / tests / testfontchooser.c
1 /* testfontchooser.c
2  * Copyright (C) 2011 Alberto Ruiz <aruiz@gnome.org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include <gtk/gtk.h>
21
22 static void
23 notify_font_name_cb (GObject *fontchooser, GParamSpec *pspec, gpointer data)
24 {
25   g_debug ("Changed font name %s", gtk_font_chooser_get_font_name (GTK_FONT_CHOOSER (fontchooser)));
26 }
27
28 static void
29 notify_preview_text_cb (GObject *fontchooser, GParamSpec *pspec, gpointer data)
30 {
31   g_debug ("Changed preview text %s", gtk_font_chooser_get_preview_text (GTK_FONT_CHOOSER (fontchooser)));
32 }
33
34 int
35 main (int argc, char *argv[])
36 {
37   GtkWidget *window;
38   GtkWidget *box;
39   GtkWidget *fontchooser;
40
41   gtk_init (NULL, NULL);
42
43   fontchooser = gtk_font_chooser_new ();
44
45   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
46   gtk_widget_set_size_request (window, 600, 600);
47   box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
48   gtk_container_add (GTK_CONTAINER (window), box);
49   gtk_container_add (GTK_CONTAINER (box), fontchooser);
50
51   gtk_widget_show_all (window);
52
53   g_signal_connect (window, "delete-event",
54                     G_CALLBACK (gtk_main_quit), NULL);
55   g_signal_connect (fontchooser, "notify::font-name",
56                     G_CALLBACK (notify_font_name_cb), NULL);
57   g_signal_connect (fontchooser, "notify::preview-text",
58                     G_CALLBACK (notify_preview_text_cb), NULL);
59
60   gtk_font_chooser_set_font_name (GTK_FONT_CHOOSER (fontchooser), "Bitstream Vera Sans 45");
61   gtk_font_chooser_set_preview_text (GTK_FONT_CHOOSER (fontchooser), "[user@host ~]$ &>>");
62   gtk_font_chooser_set_show_preview_entry (GTK_FONT_CHOOSER (fontchooser), FALSE);
63
64   gtk_main ();
65
66   return 0;
67 }