summaryrefslogtreecommitdiff
path: root/gtk/gtkcomboboxtext.c
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.van.berkom@gmail.com>2011-01-26 21:44:18 +0900
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2011-01-26 23:55:01 +0900
commite8157126d8dbca789d4438e5fe2edca3db7d21b9 (patch)
tree9fe88c789909ace46f93a07ea873d61009aa50c7 /gtk/gtkcomboboxtext.c
parent8397a79b7df6968aba1cc6e9dfb17736e057f922 (diff)
downloadgtk+-e8157126d8dbca789d4438e5fe2edca3db7d21b9.tar.gz
Fix GtkComboBoxText GtkBuildable <items> parsing to handle incomming text accumulatively
Diffstat (limited to 'gtk/gtkcomboboxtext.c')
-rw-r--r--gtk/gtkcomboboxtext.c48
1 files changed, 26 insertions, 22 deletions
diff --git a/gtk/gtkcomboboxtext.c b/gtk/gtkcomboboxtext.c
index 60da361f9b..c7a6da44fb 100644
--- a/gtk/gtkcomboboxtext.c
+++ b/gtk/gtkcomboboxtext.c
@@ -151,8 +151,9 @@ typedef struct {
GObject *object;
const gchar *domain;
+ GString *string;
+
gchar *context;
- gchar *string;
guint translatable : 1;
guint is_text : 1;
@@ -211,23 +212,8 @@ item_text (GMarkupParseContext *context,
return;
string = g_strndup (text, text_len);
-
- if (data->translatable && text_len)
- {
- gchar *translated;
-
- /* FIXME: This will not use the domain set in the .ui file,
- * since the parser is not telling the builder about the domain.
- * However, it will work for gtk_builder_set_translation_domain() calls.
- */
- translated = _gtk_builder_parser_translate (data->domain,
- data->context,
- string);
- g_free (string);
- string = translated;
- }
-
- data->string = string;
+ g_string_append (data->string, string);
+ g_free (string);
}
static void
@@ -239,14 +225,30 @@ item_end_element (GMarkupParseContext *context,
ItemParserData *data = (ItemParserData*)user_data;
/* Append the translated strings */
- if (data->string)
- gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (data->object), data->string);
+ if (data->string->len)
+ {
+ if (data->translatable)
+ {
+ gchar *translated;
+
+ /* FIXME: This will not use the domain set in the .ui file,
+ * since the parser is not telling the builder about the domain.
+ * However, it will work for gtk_builder_set_translation_domain() calls.
+ */
+ translated = _gtk_builder_parser_translate (data->domain,
+ data->context,
+ data->string->str);
+ g_string_set_size (data->string, 0);
+ g_string_append (data->string, translated);
+ }
+
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (data->object), data->string->str);
+ }
data->translatable = FALSE;
+ g_string_set_size (data->string, 0);
g_free (data->context);
- g_free (data->string);
data->context = NULL;
- data->string = NULL;
data->is_text = FALSE;
}
@@ -277,6 +279,7 @@ gtk_combo_box_text_buildable_custom_tag_start (GtkBuildable *buildable,
parser_data->builder = g_object_ref (builder);
parser_data->object = g_object_ref (buildable);
parser_data->domain = gtk_builder_get_translation_domain (builder);
+ parser_data->string = g_string_new ("");
*parser = item_parser;
*data = parser_data;
return TRUE;
@@ -302,6 +305,7 @@ gtk_combo_box_text_buildable_custom_finished (GtkBuildable *buildable,
g_object_unref (data->object);
g_object_unref (data->builder);
+ g_string_free (data->string, TRUE);
g_slice_free (ItemParserData, data);
}
}