diff options
author | Matthias Clasen <mclasen@redhat.com> | 2022-10-21 21:24:48 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2022-10-21 21:48:39 -0400 |
commit | 3fc3f8d2ff0006094bc0da385959a3558161eacc (patch) | |
tree | 38f37f015e8f07658724e4509fa1ee681db4a5f1 /demos/gtk-demo | |
parent | 2868f1b50914521d6119fe5b770658a0eade83a8 (diff) | |
download | gtk+-3fc3f8d2ff0006094bc0da385959a3558161eacc.tar.gz |
gtk-demo: Replace combobox in font rendering
Out with the combobox, in with the dropdown.
Diffstat (limited to 'demos/gtk-demo')
-rw-r--r-- | demos/gtk-demo/fontrendering.c | 32 | ||||
-rw-r--r-- | 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 <gtk/gtk.h> -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 @@ </object> </child> <child> - <object class="GtkComboBoxText" id="hinting"> - <property name="active">0</property> + <object class="GtkDropDown" id="hinting"> <property name="valign">center</property> - <items> - <item translatable="yes" id="none">None</item> - <item translatable="yes" id="slight">Slight</item> - <item translatable="yes" id="medium">Medium</item> - <item translatable="yes" id="full">Full</item> - </items> + <property name="model"> + <object class="GtkStringList"> + <items> + <item translatable="yes">None</item> + <item translatable="yes">Slight</item> + <item translatable="yes">Medium</item> + <item translatable="yes">Full</item> + </items> + </object> + </property> </object> </child> <layout> |