131 lines
3.2 KiB
Diff
131 lines
3.2 KiB
Diff
--- gdm-2.19.1/gui/gdmcommon.c.hide-uninstalled-languages 2007-05-13 22:08:15.000000000 -0400
|
|
+++ gdm-2.19.1/gui/gdmcommon.c 2007-05-21 13:24:20.000000000 -0400
|
|
@@ -32,6 +32,8 @@
|
|
#include <sys/types.h>
|
|
#include <signal.h>
|
|
|
|
+#include <fontconfig/fontconfig.h>
|
|
+
|
|
#include <glib/gi18n.h>
|
|
#include <gdk/gdkx.h>
|
|
#include <gtk/gtk.h>
|
|
@@ -928,3 +930,95 @@ gdm_common_expand_text (const gchar *tex
|
|
return g_string_free (str, FALSE);
|
|
}
|
|
|
|
+typedef enum
|
|
+{
|
|
+ LOCALE_UP_TO_LANGUAGE = 0,
|
|
+ LOCALE_UP_TO_COUNTRY,
|
|
+ LOCALE_UP_TO_ENCODING,
|
|
+ LOCALE_UP_TO_MODIFIER,
|
|
+} LocaleScope;
|
|
+
|
|
+static char *
|
|
+get_less_specific_locale (const char *locale,
|
|
+ LocaleScope scope)
|
|
+{
|
|
+ char *generalized_locale;
|
|
+ char *end;
|
|
+
|
|
+ generalized_locale = strdup (locale);
|
|
+
|
|
+ end = strchr (generalized_locale, '_');
|
|
+
|
|
+ if (end != NULL && scope <= LOCALE_UP_TO_LANGUAGE)
|
|
+ {
|
|
+ *end = '\0';
|
|
+ return generalized_locale;
|
|
+ }
|
|
+
|
|
+ end = strchr (generalized_locale, '.');
|
|
+
|
|
+ if (end != NULL && scope <= LOCALE_UP_TO_COUNTRY)
|
|
+ {
|
|
+ *end = '\0';
|
|
+ return generalized_locale;
|
|
+ }
|
|
+
|
|
+ end = strchr (generalized_locale, '@');
|
|
+
|
|
+ if (end != NULL && scope <= LOCALE_UP_TO_ENCODING)
|
|
+ {
|
|
+ *end = '\0';
|
|
+ return generalized_locale;
|
|
+ }
|
|
+
|
|
+ return generalized_locale;
|
|
+}
|
|
+
|
|
+gboolean
|
|
+gdm_common_locale_is_displayable (const gchar *locale)
|
|
+{
|
|
+ char *language_code;
|
|
+ gboolean is_displayable;
|
|
+
|
|
+ FcPattern *pattern;
|
|
+ FcObjectSet *object_set;
|
|
+ FcFontSet *font_set;
|
|
+
|
|
+ is_displayable = FALSE;
|
|
+ pattern = NULL;
|
|
+ object_set = NULL;
|
|
+ font_set = NULL;
|
|
+
|
|
+ language_code = get_less_specific_locale (locale, LOCALE_UP_TO_LANGUAGE);
|
|
+
|
|
+ pattern = FcPatternBuild (NULL, FC_LANG, FcTypeString, language_code, NULL);
|
|
+
|
|
+ if (pattern == NULL)
|
|
+ goto done;
|
|
+
|
|
+ object_set = FcObjectSetBuild (NULL, NULL);
|
|
+
|
|
+ if (object_set == NULL)
|
|
+ goto done;
|
|
+
|
|
+ font_set = FcFontList (NULL, pattern, object_set);
|
|
+
|
|
+ if (font_set == NULL)
|
|
+ goto done;
|
|
+
|
|
+ is_displayable = (font_set->nfont > 0);
|
|
+
|
|
+done:
|
|
+
|
|
+ if (font_set != NULL)
|
|
+ FcFontSetDestroy (font_set);
|
|
+
|
|
+ if (object_set != NULL)
|
|
+ FcObjectSetDestroy (object_set);
|
|
+
|
|
+ if (pattern != NULL)
|
|
+ FcPatternDestroy (pattern);
|
|
+
|
|
+ g_free (language_code);
|
|
+ return is_displayable;
|
|
+}
|
|
--- gdm-2.19.1/gui/gdmlanguages.c.hide-uninstalled-languages 2007-05-21 13:29:38.000000000 -0400
|
|
+++ gdm-2.19.1/gui/gdmlanguages.c 2007-05-21 13:30:28.000000000 -0400
|
|
@@ -705,6 +705,11 @@ gdm_lang_initialize_model (gchar * local
|
|
|
|
li->data = NULL;
|
|
|
|
+ if (!gdm_common_locale_is_displayable (lang)) {
|
|
+ g_free (lang);
|
|
+ continue;
|
|
+ }
|
|
+
|
|
name = gdm_lang_name (lang,
|
|
FALSE /* never_encoding */,
|
|
TRUE /* no_group */,
|
|
--- gdm-2.19.1/gui/gdmcommon.h.hide-uninstalled-languages 2007-05-13 22:08:15.000000000 -0400
|
|
+++ gdm-2.19.1/gui/gdmcommon.h 2007-05-21 13:24:20.000000000 -0400
|
|
@@ -70,5 +70,5 @@ void gdm_common_pre_fetch_launch
|
|
void gdm_common_atspi_launch (void);
|
|
gchar* gdm_common_expand_text (const gchar *text);
|
|
gchar* gdm_common_get_clock (struct tm **the_tm);
|
|
-
|
|
+gboolean gdm_common_locale_is_displayable (const gchar *locale);
|
|
#endif /* GDM_COMMON_H */
|