- hide langauges that aren't displayable from the list (bug 206048)

This commit is contained in:
Ray Strode 2007-03-09 17:24:57 +00:00
parent 0c3f4e09fa
commit 7c71c5ede9
2 changed files with 152 additions and 1 deletions

View File

@ -0,0 +1,144 @@
--- gdm-2.17.8/gui/gdmlogin.c.hide-uninstalled-languages 2007-03-09 12:22:36.000000000 -0500
+++ gdm-2.17.8/gui/gdmlogin.c 2007-03-09 12:22:39.000000000 -0500
@@ -1192,6 +1192,11 @@
li->data = NULL;
+ if (!gdm_common_locale_is_displayable (lang)) {
+ g_free (lang);
+ continue;
+ }
+
group = name = gdm_lang_name (lang,
FALSE /* never_encoding */,
FALSE /* no_group */,
@@ -1202,6 +1207,8 @@
continue;
}
+
+
untranslated = gdm_lang_untranslated_name (lang,
TRUE /* markup */);
--- gdm-2.17.8/gui/gdmcommon.c.hide-uninstalled-languages 2007-02-26 03:59:31.000000000 -0500
+++ gdm-2.17.8/gui/gdmcommon.c 2007-03-09 12:21:29.000000000 -0500
@@ -33,6 +33,8 @@
#include <sys/types.h>
#include <signal.h>
+#include <fontconfig/fontconfig.h>
+
#include <glib/gi18n.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
@@ -843,3 +845,95 @@
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.17.8/gui/greeter/greeter_action_language.c.hide-uninstalled-languages 2007-02-26 03:59:30.000000000 -0500
+++ gdm-2.17.8/gui/greeter/greeter_action_language.c 2007-03-09 12:21:29.000000000 -0500
@@ -86,6 +86,11 @@
li->data = NULL;
+ if (!gdm_common_language_is_displayable (lang)) {
+ g_free (lang);
+ continue;
+ }
+
name = gdm_lang_name (lang,
FALSE /* never_encoding */,
TRUE /* no_group */,

View File

@ -16,7 +16,7 @@
Summary: The GNOME Display Manager
Name: gdm
Version: 2.17.8
Release: 2%{?dist}
Release: 3%{?dist}
Epoch: 1
License: LGPL/GPL
Group: User Interface/X
@ -56,6 +56,9 @@ Patch29: gdm-2.17.7-greeter.patch
Patch30: gdm-2.17.7-user-list-keynav.patch
Patch31: gdm-2.17.8-hide-uninstalled-languages.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Prereq: /usr/sbin/useradd
@ -129,6 +132,7 @@ several different X sessions on your local machine at the same time.
%patch28 -p1 -b .desensitize-entry
%patch29 -p0 -b .greeter
%patch30 -p1 -b .keynav
%patch31 -p1 -b .hide-uninstalled-languages
%build
cp -f %{SOURCE1} config/gdm
@ -330,6 +334,9 @@ fi
%attr(1770, root, gdm) %dir %{_localstatedir}/gdm
%changelog
* Fri Mar 9 2007 Ray Strode <rstrode@redhat.com> - 1:2.17.8-3
- hide langauges that aren't displayable from the list (bug 206048)
* Tue Mar 6 2007 Ray Strode <rstrode@redhat.com> - 1:2.17.8-2
- turn off pam sanity check because it conflicts with audit