summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2008-10-01 14:32:11 +0000
committerRay Strode <halfline@src.gnome.org>2008-10-01 14:32:11 +0000
commit30535cf82b5f0de5358afda3d152e506576e245f (patch)
tree94fabf22b1faa1fc509fd1b3225588ed9a3f54c2 /gui
parentea0b8b0487cad8b0250230fc8be163c1ed5c7e8d (diff)
downloadgdm-30535cf82b5f0de5358afda3d152e506576e245f.tar.gz
Filter out duplicates from gconf mru lists that back language selector on
2008-10-01 Ray Strode <rstrode@redhat.com> * gui/simple-greeter/gdm-language-option-widget.c: * gui/simple-greeter/gdm-recent-option-widget.[ch]: Filter out duplicates from gconf mru lists that back language selector on panel svn path=/trunk/; revision=6554
Diffstat (limited to 'gui')
-rw-r--r--gui/simple-greeter/gdm-language-option-widget.c14
-rw-r--r--gui/simple-greeter/gdm-layout-option-widget.c10
-rw-r--r--gui/simple-greeter/gdm-recent-option-widget.c18
-rw-r--r--gui/simple-greeter/gdm-recent-option-widget.h8
4 files changed, 33 insertions, 17 deletions
diff --git a/gui/simple-greeter/gdm-language-option-widget.c b/gui/simple-greeter/gdm-language-option-widget.c
index 64d02b4a..af2d804d 100644
--- a/gui/simple-greeter/gdm-language-option-widget.c
+++ b/gui/simple-greeter/gdm-language-option-widget.c
@@ -173,7 +173,7 @@ gdm_language_option_widget_class_init (GdmLanguageOptionWidgetClass *klass)
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 (GdmRecentOptionWidget *widget,
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 (GdmRecentOptionWidget *widget,
g_free (language);
g_free (lang_tag);
- return TRUE;
+ return normalized_locale;
}
static void
@@ -294,7 +298,7 @@ gdm_language_option_widget_set_current_language_name (GdmLanguageOptionWidget *w
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 --git a/gui/simple-greeter/gdm-layout-option-widget.c b/gui/simple-greeter/gdm-layout-option-widget.c
index 8334e574..129cd910 100644
--- a/gui/simple-greeter/gdm-layout-option-widget.c
+++ b/gui/simple-greeter/gdm-layout-option-widget.c
@@ -176,24 +176,24 @@ gdm_layout_option_widget_class_init (GdmLayoutOptionWidgetClass *klass)
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 --git a/gui/simple-greeter/gdm-recent-option-widget.c b/gui/simple-greeter/gdm-recent-option-widget.c
index 76fa76bd..06067534 100644
--- a/gui/simple-greeter/gdm-recent-option-widget.c
+++ b/gui/simple-greeter/gdm-recent-option-widget.c
@@ -159,13 +159,24 @@ gdm_recent_option_widget_sync_items_from_gconf (GdmRecentOptionWidget *widget)
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_gconf (GdmRecentOptionWidget *widget)
g_free (name);
g_free (comment);
+ g_free (id);
}
}
diff --git a/gui/simple-greeter/gdm-recent-option-widget.h b/gui/simple-greeter/gdm-recent-option-widget.h
index 68b5c2d7..e5d1d73b 100644
--- a/gui/simple-greeter/gdm-recent-option-widget.h
+++ b/gui/simple-greeter/gdm-recent-option-widget.h
@@ -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);