diff options
author | Christian Persch <chpe@gnome.org> | 2011-09-12 00:13:26 +0200 |
---|---|---|
committer | Christian Persch <chpe@gnome.org> | 2011-09-13 12:55:33 +0200 |
commit | abd9242f3358aad1de4521bd6787643ac82b69db (patch) | |
tree | 397bee44380f21f3a2df74a43d6c8fccd9f1a707 /tests/testfontchooser.c | |
parent | 1b818f2e461dd85a7feed925334ad7b37498392c (diff) | |
download | gtk+-abd9242f3358aad1de4521bd6787643ac82b69db.tar.gz |
Add GtkFontChooser:font-desc property
Add a way to set/get the font as a PangoFontDescription.
Diffstat (limited to 'tests/testfontchooser.c')
-rw-r--r-- | tests/testfontchooser.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/tests/testfontchooser.c b/tests/testfontchooser.c index 4ff3668b42..be81e1b713 100644 --- a/tests/testfontchooser.c +++ b/tests/testfontchooser.c @@ -21,9 +21,28 @@ #include "prop-editor.h" static void -notify_font_name_cb (GObject *fontchooser, GParamSpec *pspec, gpointer data) +notify_font_cb (GtkFontChooser *fontchooser, GParamSpec *pspec, gpointer data) { - g_debug ("Changed font name %s", gtk_font_chooser_get_font (GTK_FONT_CHOOSER (fontchooser))); + PangoFontFamily *family; + PangoFontFace *face; + + g_debug ("Changed font name %s", gtk_font_chooser_get_font (fontchooser)); + + family = gtk_font_chooser_get_family (fontchooser); + face = gtk_font_chooser_get_face (fontchooser); + if (family) + { + g_debug (" Family: %s is-monospace:%s", + pango_font_family_get_name (family), + pango_font_family_is_monospace (family) ? "true" : "false"); + } + else + g_debug (" No font family!"); + + if (face) + g_debug (" Face description: %s", pango_font_face_get_face_name (face)); + else + g_debug (" No font face!"); } static void @@ -32,6 +51,12 @@ notify_preview_text_cb (GObject *fontchooser, GParamSpec *pspec, gpointer data) g_debug ("Changed preview text %s", gtk_font_chooser_get_preview_text (GTK_FONT_CHOOSER (fontchooser))); } +static void +font_activated_cb (GtkFontChooser *chooser, const gchar *font_name, gpointer data) +{ + g_debug ("font-activated: %s", font_name); +} + int main (int argc, char *argv[]) { @@ -53,10 +78,12 @@ main (int argc, char *argv[]) g_signal_connect (window, "delete-event", G_CALLBACK (gtk_main_quit), NULL); - g_signal_connect (fontchooser, "notify::font-name", - G_CALLBACK (notify_font_name_cb), NULL); + g_signal_connect (fontchooser, "notify::font", + G_CALLBACK (notify_font_cb), NULL); g_signal_connect (fontchooser, "notify::preview-text", G_CALLBACK (notify_preview_text_cb), NULL); + g_signal_connect (fontchooser, "font-activated", + G_CALLBACK (font_activated_cb), NULL); gtk_font_chooser_set_font (GTK_FONT_CHOOSER (fontchooser), "Bitstream Vera Sans 45"); gtk_font_chooser_set_preview_text (GTK_FONT_CHOOSER (fontchooser), "[user@host ~]$ &>>"); |