GtkTreeView, buttons, and keyboard input



I have a GtkTreeView representing a "recently used" history of items. I know Gtk has specialized "recent" managers, but for my purposes they didn't seem entirely appropriate.

Anyway, I'd like a way to delete items from this history. Three options present themselves:

1) Have a delete button on each row. Since I can't seem to find a cell renderer corresponding to a non-toggle button, this may not be possible.
2) Have a delete button near the GtkTreeView which acts on the currently selected row, and desensitizes if no row is selected.
3) Tie the delete key to the same function as (2).

My work with keyboard input so far is limited to something like:

window = gtk_widget_get_toplevel();
if (TOPLEVEL_WIDGET(window))
    g_signal_connect(G_OBJECT(window),"button-press-event", G_CALLBACK(function),args);

However, since my GtkTreeView lives inside a C++ class which will only be attached to a hierarchy rooted at a toplevel window *after* the class is created, doing this at creation time is right out. Previously this was handled by calling the class members to do this after the class is attached to the proper hierarchy, but it seems like there must be a better way. After all, the GtkTreeView handles some input types automatically......

I've read about "grabs", but those don't seem quite appropriate because I don't want to intercept *all* input, merely a particular key.

So, two questions: 
1) Is it possible to render a normal click-button in  a GtkTreeCell?
2) What's the "proper" way to handle keyboard input?


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