[gtk/fix-double-underscore-mnemonic: 2/2] Avoid pango deprecations




commit 1e22572716b63f2b77d4491b24b170d9c435beb4
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Aug 1 22:43:43 2021 -0400

    Avoid pango deprecations
    
    This function has been deprecated on the main
    branch of pango. Since we don't want to bump our
    pango dependency to 1.49 yet, ignore the deprecation.

 gtk/gtkfontchooserwidget.c | 77 ++++++++++++++++++++++++++--------------------
 1 file changed, 43 insertions(+), 34 deletions(-)
---
diff --git a/gtk/gtkfontchooserwidget.c b/gtk/gtkfontchooserwidget.c
index be3b4cd027..64a666d1d7 100644
--- a/gtk/gtkfontchooserwidget.c
+++ b/gtk/gtkfontchooserwidget.c
@@ -386,15 +386,18 @@ user_filter_cb (gpointer item,
 
           ret = FALSE;
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
           langs = pango_fc_font_get_languages (PANGO_FC_FONT (font));
-          for (i = 0; langs[i]; i++)
-            {
-              if (langs[i] == self->filter_language)
-                {
-                  ret = TRUE;
-                  break;
-                }
-            }
+G_GNUC_END_IGNORE_DEPRECATIONS
+          if (langs)
+            for (i = 0; langs[i]; i++)
+              {
+                if (langs[i] == self->filter_language)
+                  {
+                    ret = TRUE;
+                    break;
+                  }
+              }
         }
 
       g_object_unref (font);
@@ -600,17 +603,20 @@ maybe_update_preview_text (GtkFontChooserWidget *self,
           alt_default = pango_language_from_string (q);
         }
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
       languages = pango_fc_font_get_languages (PANGO_FC_FONT (font));
+G_GNUC_END_IGNORE_DEPRECATIONS
 
       /* If the font supports the default language, just use it. */
-      for (i = 0; languages[i]; i++)
-        {
-          if (languages[i] == default_lang || languages[i] == alt_default)
-            {
-              lang = default_lang;
-              goto found;
-            }
-        }
+      if (languages)
+        for (i = 0; languages[i]; i++)
+          {
+            if (languages[i] == default_lang || languages[i] == alt_default)
+              {
+                lang = default_lang;
+                goto found;
+              }
+          }
 
       /* Otherwise, we make a list of representative languages */
       langs = g_hash_table_new (NULL, NULL);
@@ -1066,28 +1072,31 @@ add_languages_from_font (GtkFontChooserWidget *self,
       PangoLanguage **langs;
       int i;
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
       langs = pango_fc_font_get_languages (PANGO_FC_FONT (font));
-      for (i = 0; langs[i]; i++)
-        {
-          if (!g_hash_table_contains (self->language_table, langs[i]))
-            {
-              g_hash_table_add (self->language_table, langs[i]);
-              if (get_language_name (langs[i]))
-                {
-                  const char *l = pango_language_to_string (langs[i]);
-                  gulong id = 0;
+G_GNUC_END_IGNORE_DEPRECATIONS
+      if (langs)
+        for (i = 0; langs[i]; i++)
+          {
+            if (!g_hash_table_contains (self->language_table, langs[i]))
+              {
+                g_hash_table_add (self->language_table, langs[i]);
+                if (get_language_name (langs[i]))
+                  {
+                    const char *l = pango_language_to_string (langs[i]);
+                    gulong id = 0;
 
-                  /* Pre-select the default language */
-                  if (pango_language_matches (default_lang, l))
-                    id = g_signal_connect (model, "items-changed", G_CALLBACK (select_added), NULL);
+                    /* Pre-select the default language */
+                    if (pango_language_matches (default_lang, l))
+                      id = g_signal_connect (model, "items-changed", G_CALLBACK (select_added), NULL);
 
-                  gtk_string_list_append (self->languages, l);
+                    gtk_string_list_append (self->languages, l);
 
-                  if (id)
-                    g_signal_handler_disconnect (model, id);
-                }
-            }
-        }
+                    if (id)
+                      g_signal_handler_disconnect (model, id);
+                  }
+              }
+          }
     }
 
   g_object_unref (font);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]