From 3fc3f8d2ff0006094bc0da385959a3558161eacc Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 21 Oct 2022 21:24:48 -0400 Subject: [PATCH] gtk-demo: Replace combobox in font rendering Out with the combobox, in with the dropdown. --- demos/gtk-demo/fontrendering.c | 32 +++++++++++++++++--------------- demos/gtk-demo/fontrendering.ui | 19 +++++++++++-------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/demos/gtk-demo/fontrendering.c b/demos/gtk-demo/fontrendering.c index 434f7e99ee..a187f41397 100644 --- a/demos/gtk-demo/fontrendering.c +++ b/demos/gtk-demo/fontrendering.c @@ -10,8 +10,6 @@ #include -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - static GtkWidget *window = NULL; static GtkWidget *font_button = NULL; static GtkWidget *entry = NULL; @@ -45,7 +43,6 @@ update_image (void) cairo_t *cr; GdkPixbuf *pixbuf; GdkPixbuf *pixbuf2; - const char *hint; cairo_font_options_t *fopt; cairo_hint_style_t hintstyle; cairo_hint_metrics_t hintmetrics; @@ -60,18 +57,23 @@ update_image (void) fopt = cairo_font_options_copy (pango_cairo_context_get_font_options (context)); - hint = gtk_combo_box_get_active_id (GTK_COMBO_BOX (hinting)); - hintstyle = CAIRO_HINT_STYLE_DEFAULT; - if (hint) + switch (gtk_drop_down_get_selected (GTK_DROP_DOWN (hinting))) { - if (strcmp (hint, "none") == 0) - hintstyle = CAIRO_HINT_STYLE_NONE; - else if (strcmp (hint, "slight") == 0) - hintstyle = CAIRO_HINT_STYLE_SLIGHT; - else if (strcmp (hint, "medium") == 0) - hintstyle = CAIRO_HINT_STYLE_MEDIUM; - else if (strcmp (hint, "full") == 0) - hintstyle = CAIRO_HINT_STYLE_FULL; + case 0: + hintstyle = CAIRO_HINT_STYLE_NONE; + break; + case 1: + hintstyle = CAIRO_HINT_STYLE_SLIGHT; + break; + case 2: + hintstyle = CAIRO_HINT_STYLE_MEDIUM; + break; + case 3: + hintstyle = CAIRO_HINT_STYLE_FULL; + break; + default: + hintstyle = CAIRO_HINT_STYLE_DEFAULT; + break; } cairo_font_options_set_hint_style (fopt, hintstyle); @@ -420,7 +422,7 @@ do_fontrendering (GtkWidget *do_widget) g_signal_connect (down_button, "clicked", G_CALLBACK (scale_down), NULL); g_signal_connect (entry, "notify::text", G_CALLBACK (update_image), NULL); g_signal_connect (font_button, "notify::font-desc", G_CALLBACK (update_image), NULL); - g_signal_connect (hinting, "notify::active", G_CALLBACK (update_image), NULL); + g_signal_connect (hinting, "notify::selected", G_CALLBACK (update_image), NULL); g_signal_connect (anti_alias, "notify::active", G_CALLBACK (update_image), NULL); g_signal_connect (hint_metrics, "notify::active", G_CALLBACK (update_image), NULL); g_signal_connect (text_radio, "notify::active", G_CALLBACK (update_image), NULL); diff --git a/demos/gtk-demo/fontrendering.ui b/demos/gtk-demo/fontrendering.ui index a28491a85a..23b782cf4e 100644 --- a/demos/gtk-demo/fontrendering.ui +++ b/demos/gtk-demo/fontrendering.ui @@ -116,15 +116,18 @@ - - 0 + center - - None - Slight - Medium - Full - + + + + None + Slight + Medium + Full + + + -- 2.30.2