- canonicalize codeset to match output of locale -m

- filter duplicates from language list
This commit is contained in:
Ray Strode 2008-09-17 15:15:09 +00:00
parent cc940de6a3
commit e1ea6b93ab
3 changed files with 186 additions and 1 deletions

View File

@ -0,0 +1,39 @@
--- gdm/gui/simple-greeter/gdm-languages.c (revision 6468)
+++ gdm/gui/simple-greeter/gdm-languages.c (working copy)
@@ -216,6 +216,25 @@ construct_language_name (const char *lan
return name;
}
+static void
+make_codeset_canonical_for_locale (const *name,
+ const char **codeset)
+{
+ char *old_locale;
+ char *canonical_codeset;
+
+ old_locale = setlocale (LC_CTYPE, name);
+
+ if (old_locale == NULL) {
+ return;
+ }
+
+ g_free (*codeset);
+ *codeset = g_strdup (nl_langinfo (CODESET));
+
+ setlocale (LC_CTYPE, old_locale);
+}
+
char *
gdm_normalize_language_name (const char *name)
{
@@ -234,6 +253,10 @@ gdm_normalize_language_name (const char
&territory_code,
&codeset, &modifier);
+ if (codeset != NULL) {
+ make_codeset_canonical_for_locale (name, &codeset);
+ }
+
normalized_name = construct_language_name (language_code,
territory_code,
codeset, modifier);

View File

@ -0,0 +1,138 @@
diff -up gdm-2.23.92/gui/simple-greeter/gdm-language-option-widget.c.filter-dupes-from-lang-list gdm-2.23.92/gui/simple-greeter/gdm-language-option-widget.c
--- gdm-2.23.92/gui/simple-greeter/gdm-language-option-widget.c.filter-dupes-from-lang-list 2008-08-26 15:04:00.000000000 -0400
+++ gdm-2.23.92/gui/simple-greeter/gdm-language-option-widget.c 2008-09-17 11:07:51.000000000 -0400
@@ -173,7 +173,7 @@ gdm_language_option_widget_class_init (G
g_type_class_add_private (klass, sizeof (GdmLanguageOptionWidgetPrivate));
}
-static gboolean
+static char *
gdm_language_option_widget_lookup_item (GdmRecentOptionWidget *widget,
const char *locale,
char **name,
@@ -182,11 +182,15 @@ gdm_language_option_widget_lookup_item (
char *language;
char *readable_language;
char *lang_tag;
+ char *normalized_locale;
- language = gdm_get_language_from_name (locale, locale);
+ normalized_locale = gdm_normalize_language_name (locale);
+
+ language = gdm_get_language_from_name (locale, normalized_locale);
if (language == NULL) {
- return FALSE;
+ g_free (normalized_locale);
+ return NULL;
}
readable_language = gdm_get_language_from_name (locale, NULL);
@@ -197,7 +201,7 @@ gdm_language_option_widget_lookup_item (
g_free (language);
g_free (lang_tag);
- return TRUE;
+ return normalized_locale;
}
static void
@@ -294,7 +298,7 @@ gdm_language_option_widget_set_current_l
if (normalized_language_name != NULL &&
!gdm_option_widget_lookup_item (GDM_OPTION_WIDGET (widget),
- normalized_language_name, NULL, NULL, NULL)) {
+ &normalized_language_name, NULL, NULL, NULL)) {
gdm_recent_option_widget_add_item (GDM_RECENT_OPTION_WIDGET (widget),
normalized_language_name);
}
diff -up gdm-2.23.92/gui/simple-greeter/gdm-layout-option-widget.c.filter-dupes-from-lang-list gdm-2.23.92/gui/simple-greeter/gdm-layout-option-widget.c
--- gdm-2.23.92/gui/simple-greeter/gdm-layout-option-widget.c.filter-dupes-from-lang-list 2008-09-17 10:55:20.000000000 -0400
+++ gdm-2.23.92/gui/simple-greeter/gdm-layout-option-widget.c 2008-09-17 11:08:07.000000000 -0400
@@ -176,24 +176,24 @@ gdm_layout_option_widget_class_init (Gdm
g_type_class_add_private (klass, sizeof (GdmLayoutOptionWidgetPrivate));
}
-static gboolean
+static char *
gdm_layout_option_widget_lookup_item (GdmRecentOptionWidget *widget,
- const char *id,
+ const char *key,
char **name,
char **comment)
{
char *layout;
- layout = gdm_get_layout_from_name (id);
+ layout = gdm_get_layout_from_name (key);
if (layout == NULL) {
- return FALSE;
+ return NULL;
}
*name = layout;
*comment = NULL;
- return TRUE;
+ return g_strdup (key);
}
static void
diff -up gdm-2.23.92/gui/simple-greeter/gdm-recent-option-widget.c.filter-dupes-from-lang-list gdm-2.23.92/gui/simple-greeter/gdm-recent-option-widget.c
--- gdm-2.23.92/gui/simple-greeter/gdm-recent-option-widget.c.filter-dupes-from-lang-list 2008-08-26 15:04:00.000000000 -0400
+++ gdm-2.23.92/gui/simple-greeter/gdm-recent-option-widget.c 2008-09-17 11:06:34.000000000 -0400
@@ -159,13 +159,24 @@ gdm_recent_option_widget_sync_items_from
default_is_set = FALSE;
for (tmp = list; tmp != NULL; tmp = tmp->next) {
- const char *id;
+ const char *key;
+ char *id;
char *name;
char *comment;
- id = (char *) tmp->data;
+ key = (char *) tmp->data;
+
+ id = widget->priv->lookup_item_func (widget, key, &name, &comment);
+
+ if (id != NULL) {
+ gboolean item_exists;
+
+ item_exists = gdm_option_widget_lookup_item (GDM_OPTION_WIDGET (widget), id, NULL, NULL, NULL);
+
+ if (item_exists) {
+ continue;
+ }
- if (widget->priv->lookup_item_func (widget, id, &name, &comment)) {
gdm_option_widget_add_item (GDM_OPTION_WIDGET (widget),
id, name, comment,
GDM_OPTION_WIDGET_POSITION_MIDDLE);
@@ -177,6 +188,7 @@ gdm_recent_option_widget_sync_items_from
g_free (name);
g_free (comment);
+ g_free (id);
}
}
diff -up gdm-2.23.92/gui/simple-greeter/gdm-recent-option-widget.h.filter-dupes-from-lang-list gdm-2.23.92/gui/simple-greeter/gdm-recent-option-widget.h
--- gdm-2.23.92/gui/simple-greeter/gdm-recent-option-widget.h.filter-dupes-from-lang-list 2008-08-26 15:04:00.000000000 -0400
+++ gdm-2.23.92/gui/simple-greeter/gdm-recent-option-widget.h 2008-09-17 11:07:40.000000000 -0400
@@ -48,10 +48,10 @@ typedef struct
GdmOptionWidgetClass parent_class;
} GdmRecentOptionWidgetClass;
-typedef gboolean (* GdmRecentOptionLookupItemFunc) (GdmRecentOptionWidget *widget,
- const char *id,
- char **name,
- char **comment);
+typedef char * (* GdmRecentOptionLookupItemFunc) (GdmRecentOptionWidget *widget,
+ const char *key,
+ char **name,
+ char **comment);
GType gdm_recent_option_widget_get_type (void);

View File

@ -16,7 +16,7 @@
Summary: The GNOME Display Manager
Name: gdm
Version: 2.23.92
Release: 7%{?dist}
Release: 8%{?dist}
Epoch: 1
License: GPLv2+
Group: User Interface/X
@ -87,6 +87,8 @@ Patch4: username-leak.patch
Patch5: data-leak.patch
# http://bugzilla.gnome.org/show_bug.cgi?id=552578
Patch6: ssid-leak.patch
Patch7: gdm-2.23.92-filter-dupes-from-lang-list.patch
Patch8: gdm-2.23.92-another-locale-fixup.patch
# Fedora-specific
Patch99: gdm-2.23.1-fedora-logo.patch
@ -114,6 +116,8 @@ multiple simulanteous logged in users.
%patch4 -p1 -b .username-leak
%patch5 -p1 -b .data-leak
%patch6 -p1 -b .ssid-leak
%patch7 -p1 -b .filter-dupes-from-lang-list
%patch8 -p1 -b .another-locale-fixup
%patch99 -p1 -b .fedora-logo
@ -316,6 +320,10 @@ fi
%{_datadir}/gnome-2.0/ui/GNOME_FastUserSwitchApplet.xml
%changelog
* Wed Sep 17 2008 Ray Strode <rstrode@redhat.com> - 1:2.23.92-8
- canonicalize codeset to match output of locale -m
- filter duplicates from language list
* Tue Sep 16 2008 Matthias Clasen <mclasen@redhat.com> - 1:2.23.92-7
- Plug a few memory leaks