Re: TreeView Questions



SkyRat23 aol com writes:

Hi.  I have recently begun porting one of my programs to GTK2 and have decided to use the TreeView instead 
of the CList.  Now it is much more difficult to learn how to properly use the TreeView than a CList and I 
have a few things I cannot figure out.

1st How does one change the color for the font of just a single row.
I could use gtk_clist_set_foreground before but now I am at a loss to
figure it out.

Put the string you want in your model and hook it up to the "foreground"
property.  For example, if you have the following list:

[ "text",  "black",
  "text2", "red",
  "text3", "black" ]

you can create your column like this:

gtk_tree_view_column_new_with_attributes ("Title",
                                          gtk_cell_renderer_text_new (),
                                          "text", 0,
                                          "foreground", 1,
                                          NULL);

2nd I need to catch double click signals from the user input on the
treeview.  I do this using a button press event, I check for the
double click by checking the event type.  This works fine however
because I catch the button press signal, the row that the user clicks
on is never selected (even on a sigle click).  I would like for it to
be selected however.  I was thinking the function
gtk_selection_select_path could be used b/c I have a path to the row
however, what would/where would/how would I get the GtkTreeSelection
that the function requires.

Connect to the "GtkTreeView::row_activated" signal.  Note that you
probably returned TRUE in your event handler which will stop GTK+ from
getting the event.

Thanks,
-Jonathan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]