diff options
author | Ryan Lortie <desrt@desrt.ca> | 2012-01-04 16:32:39 -0500 |
---|---|---|
committer | Ryan Lortie <desrt@desrt.ca> | 2012-01-04 17:00:35 -0500 |
commit | 0ea48c4139aa8651cb8a94ee7f20e2a60b53bb15 (patch) | |
tree | 1d5c5274fe0f06d05f30803659f8ba0bf4e880be /gtk/gtkcomboboxtext.c | |
parent | eeb9de80e17d1915d877c98eabd9a9a1f4423e9c (diff) | |
download | gtk+-0ea48c4139aa8651cb8a94ee7f20e2a60b53bb15.tar.gz |
GtkComboBoxText: allow id='' tag in builder markup
Presently, GtkComboBoxText lets you list the items for it in the
GtkBuilder markup like so:
<items>
<item translatable='yes'>Red</item>
<item translatable='yes'>Blue</item>
</items>
but has no way to set the "id" column for added items. Add an id='' tag
for that purpose so that you can do:
<item id='red' translatable='yes'>Red</item>
https://bugzilla.gnome.org/show_bug.cgi?id=667319
Diffstat (limited to 'gtk/gtkcomboboxtext.c')
-rw-r--r-- | gtk/gtkcomboboxtext.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/gtk/gtkcomboboxtext.c b/gtk/gtkcomboboxtext.c index b11c6454c6..f077c8e6fc 100644 --- a/gtk/gtkcomboboxtext.c +++ b/gtk/gtkcomboboxtext.c @@ -157,6 +157,7 @@ typedef struct { GtkBuilder *builder; GObject *object; const gchar *domain; + gchar *id; GString *string; @@ -199,6 +200,8 @@ item_start_element (GMarkupParseContext *context, } else if (strcmp (names[i], "context") == 0) data->context = g_strdup (values[i]); + else if (strcmp (names[i], "id") == 0) + data->id = g_strdup (values[i]); else g_warning ("Unknown custom combo box item attribute: %s", names[i]); } @@ -244,13 +247,15 @@ item_end_element (GMarkupParseContext *context, g_string_append (data->string, translated); } - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (data->object), data->string->str); + gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (data->object), data->id, data->string->str); } data->translatable = FALSE; g_string_set_size (data->string, 0); g_free (data->context); data->context = NULL; + g_free (data->id); + data->id = NULL; data->is_text = FALSE; } |