d3c1b0
--- gdm-2.17.8/gui/gdmcommon.h.hide-uninstalled-languages	2007-03-09 12:30:58.000000000 -0500
d3c1b0
+++ gdm-2.17.8/gui/gdmcommon.h	2007-03-09 12:31:59.000000000 -0500
d3c1b0
@@ -67,5 +67,5 @@
d3c1b0
 void      gdm_common_atspi_launch           (void);
d3c1b0
 gchar*    gdm_common_expand_text            (const gchar *text);
d3c1b0
 gchar*    gdm_common_get_clock              (struct tm **the_tm);
d3c1b0
-
d3c1b0
+gboolean  gdm_common_locale_is_displayable (const gchar *locale);
d3c1b0
 #endif /* GDM_COMMON_H */
7c71c5
--- gdm-2.17.8/gui/gdmlogin.c.hide-uninstalled-languages	2007-03-09 12:22:36.000000000 -0500
7c71c5
+++ gdm-2.17.8/gui/gdmlogin.c	2007-03-09 12:22:39.000000000 -0500
7c71c5
@@ -1192,6 +1192,11 @@
7c71c5
 
7c71c5
 	    li->data = NULL;
7c71c5
 
7c71c5
+	    if (!gdm_common_locale_is_displayable (lang)) {
7c71c5
+		    g_free (lang);
7c71c5
+		    continue;
7c71c5
+	    }
7c71c5
+
7c71c5
 	    group = name = gdm_lang_name (lang,
7c71c5
 					  FALSE /* never_encoding */,
7c71c5
 					  FALSE /* no_group */,
7c71c5
@@ -1202,6 +1207,8 @@
7c71c5
 		    continue;
7c71c5
 	    }
7c71c5
 
7c71c5
+
7c71c5
+
7c71c5
 	    untranslated = gdm_lang_untranslated_name (lang,
7c71c5
 						       TRUE /* markup */);
7c71c5
 
7c71c5
--- gdm-2.17.8/gui/gdmcommon.c.hide-uninstalled-languages	2007-02-26 03:59:31.000000000 -0500
7c71c5
+++ gdm-2.17.8/gui/gdmcommon.c	2007-03-09 12:21:29.000000000 -0500
7c71c5
@@ -33,6 +33,8 @@
7c71c5
 #include <sys types.h="">
7c71c5
 #include <signal.h>
7c71c5
 
7c71c5
+#include <fontconfig fontconfig.h="">
7c71c5
+
7c71c5
 #include <glib gi18n.h="">
7c71c5
 #include <gdk gdkx.h="">
7c71c5
 #include <gtk gtk.h="">
7c71c5
@@ -843,3 +845,95 @@
7c71c5
   return g_string_free (str, FALSE);
7c71c5
 }
7c71c5
 
7c71c5
+typedef enum
7c71c5
+{
7c71c5
+  LOCALE_UP_TO_LANGUAGE = 0,
7c71c5
+  LOCALE_UP_TO_COUNTRY,
7c71c5
+  LOCALE_UP_TO_ENCODING,
7c71c5
+  LOCALE_UP_TO_MODIFIER,
7c71c5
+} LocaleScope;
7c71c5
+
7c71c5
+static char *
7c71c5
+get_less_specific_locale (const char *locale,
7c71c5
+                          LocaleScope scope)
7c71c5
+{
7c71c5
+  char *generalized_locale;
7c71c5
+  char *end;
7c71c5
+
7c71c5
+  generalized_locale = strdup (locale);
7c71c5
+
7c71c5
+  end = strchr (generalized_locale, '_');
7c71c5
+
7c71c5
+  if (end != NULL && scope <= LOCALE_UP_TO_LANGUAGE)
7c71c5
+    {
7c71c5
+      *end = '\0';
7c71c5
+      return generalized_locale;
7c71c5
+    }
7c71c5
+
7c71c5
+  end = strchr (generalized_locale, '.');
7c71c5
+
7c71c5
+  if (end != NULL && scope <= LOCALE_UP_TO_COUNTRY)
7c71c5
+    {
7c71c5
+      *end = '\0';
7c71c5
+      return generalized_locale;
7c71c5
+    }
7c71c5
+
7c71c5
+  end = strchr (generalized_locale, '@');
7c71c5
+
7c71c5
+  if (end != NULL && scope <= LOCALE_UP_TO_ENCODING)
7c71c5
+    {
7c71c5
+      *end = '\0';
7c71c5
+      return generalized_locale;
7c71c5
+    }
7c71c5
+
7c71c5
+  return generalized_locale;
7c71c5
+}
7c71c5
+
7c71c5
+gboolean
7c71c5
+gdm_common_locale_is_displayable (const gchar *locale)
7c71c5
+{
7c71c5
+  char *language_code;
7c71c5
+  gboolean is_displayable;
7c71c5
+
7c71c5
+  FcPattern *pattern;
7c71c5
+  FcObjectSet *object_set;
7c71c5
+  FcFontSet *font_set;
7c71c5
+
7c71c5
+  is_displayable = FALSE;
7c71c5
+  pattern = NULL;
7c71c5
+  object_set = NULL;
7c71c5
+  font_set = NULL;
7c71c5
+
7c71c5
+  language_code = get_less_specific_locale (locale, LOCALE_UP_TO_LANGUAGE);
7c71c5
+
7c71c5
+  pattern = FcPatternBuild (NULL, FC_LANG, FcTypeString, language_code, NULL);
7c71c5
+
7c71c5
+  if (pattern == NULL)
7c71c5
+    goto done;
7c71c5
+
7c71c5
+  object_set = FcObjectSetBuild (NULL, NULL);
7c71c5
+
7c71c5
+  if (object_set == NULL)
7c71c5
+    goto done;
7c71c5
+
7c71c5
+  font_set = FcFontList (NULL, pattern, object_set);
7c71c5
+
7c71c5
+  if (font_set == NULL)
7c71c5
+    goto done;
7c71c5
+
7c71c5
+  is_displayable = (font_set->nfont > 0);
7c71c5
+
7c71c5
+done:
7c71c5
+
7c71c5
+  if (font_set != NULL)
7c71c5
+    FcFontSetDestroy (font_set);
7c71c5
+
7c71c5
+  if (object_set != NULL)
7c71c5
+    FcObjectSetDestroy (object_set);
7c71c5
+
7c71c5
+  if (pattern != NULL)
7c71c5
+    FcPatternDestroy (pattern);
7c71c5
+
7c71c5
+  g_free (language_code);
7c71c5
+  return is_displayable;
7c71c5
+}
7c71c5
--- gdm-2.17.8/gui/greeter/greeter_action_language.c.hide-uninstalled-languages	2007-02-26 03:59:30.000000000 -0500
d3c1b0
+++ gdm-2.17.8/gui/greeter/greeter_action_language.c	2007-03-09 12:37:17.000000000 -0500
7c71c5
@@ -86,6 +86,11 @@
7c71c5
 
7c71c5
       li->data = NULL;
7c71c5
 
d3c1b0
+      if (!gdm_common_locale_is_displayable (lang)) {
7c71c5
+            g_free (lang);
7c71c5
+	    continue;
7c71c5
+      }
7c71c5
+
7c71c5
       name = gdm_lang_name (lang,
7c71c5
 			    FALSE /* never_encoding */,
7c71c5
 			    TRUE /* no_group */,