2 * Copyright (C) 2011 Alberto Ruiz <aruiz@gnome.org>
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.
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.
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.
21 #include "prop-editor.h"
24 notify_font_cb (GtkFontChooser *fontchooser, GParamSpec *pspec, gpointer data)
26 PangoFontFamily *family;
29 g_debug ("Changed font name %s", gtk_font_chooser_get_font (fontchooser));
31 family = gtk_font_chooser_get_family (fontchooser);
32 face = gtk_font_chooser_get_face (fontchooser);
35 g_debug (" Family: %s is-monospace:%s",
36 pango_font_family_get_name (family),
37 pango_font_family_is_monospace (family) ? "true" : "false");
40 g_debug (" No font family!");
43 g_debug (" Face description: %s", pango_font_face_get_face_name (face));
45 g_debug (" No font face!");
49 notify_preview_text_cb (GObject *fontchooser, GParamSpec *pspec, gpointer data)
51 g_debug ("Changed preview text %s", gtk_font_chooser_get_preview_text (GTK_FONT_CHOOSER (fontchooser)));
55 font_activated_cb (GtkFontChooser *chooser, const gchar *font_name, gpointer data)
57 g_debug ("font-activated: %s", font_name);
61 main (int argc, char *argv[])
65 GtkWidget *fontchooser;
67 gtk_init (NULL, NULL);
69 fontchooser = gtk_font_chooser_widget_new ();
71 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
72 gtk_widget_set_size_request (window, 600, 600);
73 box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
74 gtk_container_add (GTK_CONTAINER (window), box);
75 gtk_container_add (GTK_CONTAINER (box), fontchooser);
77 gtk_widget_show_all (window);
79 g_signal_connect (window, "delete-event",
80 G_CALLBACK (gtk_main_quit), NULL);
81 g_signal_connect (fontchooser, "notify::font",
82 G_CALLBACK (notify_font_cb), NULL);
83 g_signal_connect (fontchooser, "notify::preview-text",
84 G_CALLBACK (notify_preview_text_cb), NULL);
85 g_signal_connect (fontchooser, "font-activated",
86 G_CALLBACK (font_activated_cb), NULL);
88 gtk_font_chooser_set_font (GTK_FONT_CHOOSER (fontchooser), "Bitstream Vera Sans 45");
89 gtk_font_chooser_set_preview_text (GTK_FONT_CHOOSER (fontchooser), "[user@host ~]$ &>>");
90 gtk_font_chooser_set_show_preview_entry (GTK_FONT_CHOOSER (fontchooser), FALSE);
92 create_prop_editor (G_OBJECT (fontchooser), GTK_TYPE_FONT_CHOOSER);