gtk-demo: Replace combobox in font rendering
authorMatthias Clasen <mclasen@redhat.com>
Sat, 22 Oct 2022 01:24:48 +0000 (21:24 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 22 Oct 2022 01:48:39 +0000 (21:48 -0400)
Out with the combobox, in with the dropdown.

demos/gtk-demo/fontrendering.c
demos/gtk-demo/fontrendering.ui

index 434f7e99eea52c927ee4acc28ac85edfdbabae3a..a187f41397bbd52cbdac9bb7983d5ae91ab31254 100644 (file)
@@ -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);
index a28491a85a8e7bbcd1e92893c21c5963f6df3683..23b782cf4e7b5f846c6df89d17b6c96856388b25 100644 (file)
                   </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>