[gtkada] more questions on a ctree widget

Emmanuel Briot briot at ACT-Europe.FR
Thu Apr 25 18:23:05 CEST 2002


"Ebert, Rolf" <ebert at bms.de> writes:

> 1) Now, that I have managed to display a popup menu from a ctree widget, I'd
> like it to be a *context* menu.  
> 
> Do I have to calculate the context myself using the X and Y coordinates of
> the event, or are there any convenience functions which tell me the row
> (node) and column? (comparable to the "select_row" signal)

Yes, you should compute this yourself. Here is the code:

            Row, Column       : Gint;
            Is_Valid          : Boolean;
            Node              : Gtk_Ctree_Node;
         begin
            if Event /= null then
               Get_Selection_Info
                 (Tree, Gint (Get_X (Event)), Gint (Get_Y (Event)),
                  Row, Column, Is_Valid);

               if not Is_Valid then
                  return null;
               end if;

               Node := Node_Nth (T.Tree, Guint (Row));
            end if;
        end;

> 2) I want to temporarily hide some rows (nodes) in the ctree.  Do I have to
> rebuild the ctree from scratch applying my rules each time the rules change?
> Or is there an attribute which I can simply set?

Yes, that's unfortunately a very strong limitation of the GtkCtree. If you are
using gtk2.0, consider using a GtkTreeView instead. More complex to manipulate,
but much more powerful.

Emmanuel




More information about the gtkada mailing list