[gtk+/builder-details: 3/4] Fix GtkComboBoxText GtkBuildable <items> parsing to handle incomming text accumulatively
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/builder-details: 3/4] Fix GtkComboBoxText GtkBuildable <items> parsing to handle incomming text accumulatively
- Date: Wed, 26 Jan 2011 12:43:58 +0000 (UTC)
commit d10c862acd6aa750e2c3410c4bea6dbd3612ec6b
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Wed Jan 26 21:44:18 2011 +0900
Fix GtkComboBoxText GtkBuildable <items> parsing to handle incomming text accumulatively
gtk/gtkcomboboxtext.c | 48 ++++++++++++++++++++++++++----------------------
1 files changed, 26 insertions(+), 22 deletions(-)
---
diff --git a/gtk/gtkcomboboxtext.c b/gtk/gtkcomboboxtext.c
index 60da361..c7a6da4 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);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]