[gnome-desktop/wip/locale-info: 3/10] gnome-xkb-info: Handle duplicated layouts
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-desktop/wip/locale-info: 3/10] gnome-xkb-info: Handle duplicated layouts
- Date: Tue, 5 Feb 2013 00:54:42 +0000 (UTC)
commit b9714c7fe89ccbb5474f48bfb806c4d7465d3fe2
Author: Rui Matos <tiagomatos gmail com>
Date: Mon Jan 21 17:31:34 2013 +0100
gnome-xkb-info: Handle duplicated layouts
When merging entries from another .xml file (i.e. when
show-all-sources is active) there might be layout entries which were
already added before. In that case we don't want to create new entries
and replace the old ones because layout variants which were already
added depend on the existence of the old main layout.
https://bugzilla.gnome.org/show_bug.cgi?id=692219
libgnome-desktop/gnome-xkb-info.c | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/libgnome-desktop/gnome-xkb-info.c b/libgnome-desktop/gnome-xkb-info.c
index 9e6e377..f0dd9bc 100644
--- a/libgnome-desktop/gnome-xkb-info.c
+++ b/libgnome-desktop/gnome-xkb-info.c
@@ -287,6 +287,8 @@ parse_start_element (GMarkupParseContext *context,
}
else if (strcmp (element_name, "variant") == 0)
{
+ Layout *layout;
+
if (priv->current_parser_variant)
{
g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
@@ -301,9 +303,20 @@ parse_start_element (GMarkupParseContext *context,
return;
}
+ if (!priv->current_parser_layout->xkb_name)
+ {
+ g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
+ "'variant' elements must be inside named 'layout' elements");
+ return;
+ }
+
+ layout = g_hash_table_lookup (priv->layouts_table, priv->current_parser_layout->xkb_name);
+ if (!layout)
+ layout = priv->current_parser_layout;
+
priv->current_parser_variant = g_slice_new0 (Layout);
priv->current_parser_variant->is_variant = TRUE;
- priv->current_parser_variant->main_layout = priv->current_parser_layout;
+ priv->current_parser_variant->main_layout = layout;
}
else if (strcmp (element_name, "group") == 0)
{
@@ -407,6 +420,12 @@ parse_end_element (GMarkupParseContext *context,
priv->current_parser_layout->id = g_strdup (priv->current_parser_layout->xkb_name);
+ if (g_hash_table_contains (priv->layouts_table, priv->current_parser_layout->id))
+ {
+ g_clear_pointer (&priv->current_parser_layout, free_layout);
+ return;
+ }
+
g_hash_table_replace (priv->layouts_table,
priv->current_parser_layout->id,
priv->current_parser_layout);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]