Re: GtkComboBox Text Markup
- From: Vikram Ambrose <noel ambrose gmail com>
- To: Tristan Van Berkom <tvb gnome org>
- Cc: gtk-list gnome org
- Subject: Re: GtkComboBox Text Markup
- Date: Mon, 07 Mar 2011 17:02:00 -0500
On 03/07/2011 04:50 PM, Tristan Van Berkom wrote:
On Tue, Mar 8, 2011 at 6:35 AM, Vikram Ambrose<noel ambrose gmail com> wrote:
On 03/03/2011 10:09 PM, Tristan Van Berkom wrote:
On Fri, Mar 4, 2011 at 12:00 PM, Vikram Ambrose<noel ambrose gmail com>
wrote:
Hello List,
How do you do pango markup for text in a GtkComboBox?
- You create your combo box
- Create a GtkListStore with a G_TYPE_STRING column where you store
the markup for each row
- Give the list store to the combo
- Add a GtkCellRendererText to the combo
- Assign the "markup" attribute of the cell renderer to the column
in the store that holds the markup.
Tada !
Thanks. I'll give it a try.
Seems like massive overkill though. Couldnt this be done using a combobox
made from gtk_combo_box_new_text()?
I only need to store two items.
No it cannot, the _text() apis are the convenience that takes
care of the simple tasks such as:
a.) creating a liststore to store the text
b.) creating a cellrenderertext to display the text in the liststore
It's just a small wrapping api that does the work for the simple
case of a combo box that only shows simple text entries.
Well I managed to do it like this...
combo = gtk_combo_box_new_text();
cell_list = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(combo));
if(cell_list && cell_list->data){
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo),cell_list->data,"markup",0,NULL);
}
I'm guessing this could break without notice but at the moment its a
million times better than bringing in the clunky GtkTreeModel API for
just two items.
Thanks.
V.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]