Is there a way to get the pointer to the GtkColumnView widget from the pointer to a GtkColumnViewCell that it contains (the list item that I have in a call back) ?
Hi,
Do you mean the mouse pointer, or the pointer to the widget in memory?
For the mouse pointer, look at translate_coordinates()
For the memory pointer, you can call get_child() on the Cell, then get_ancestor() to find the ColumnView.
No … I have a GtkColumnView that contains cells with GtkEntry widgets.
I connect a signal so that a callback is triggered when I focus on GtkEntry.
static void
setup_cb (GtkSignalListItemFactory *self, GtkListItem *list_item, gpointer user_data)
{
GtkWidget *wEntry = gtk_entry_new ();
GtkEventController *controller = gtk_event_controller_focus_new ( );
g_signal_connect( controller, "enter", G_CALLBACK( enter ), list_item );
gtk_widget_add_controller ( wEntry, controller );
When the callback occurs I can find out what row the GtkEntry is. I need to use that to change the row selection in the model. To do this I need to get the GtkColumnView (in order to get the GtkSelectionModel).
I say ‘pointer to’ because that is what you get (rather than the widget itself) (at least in C … I don’t know about Python or Rust)
Michael
void
enter ( GtkEventControllerFocus* self, gpointer wListItem ) {
g_print( "Row: %d / List Item type: %s\n",
gtk_column_view_cell_get_position ( (GtkColumnViewCell *)( wListItem ) ),
G_OBJECT_TYPE_NAME( G_OBJECT( wListItem ) ) );
}
Yes, that works!! thanks.
GtkWidget *wColumnView = gtk_widget_get_ancestor( gtk_column_view_cell_get_child( wListItem ), GTK_TYPE_COLUMN_VIEW );
GtkSelectionModel *model = gtk_column_view_get_model( GTK_COLUMN_VIEW( wColumnView ) );
gtk_selection_model_select_item ( model, gtk_column_view_cell_get_position ( (GtkColumnViewCell *)( wListItem ) ), TRUE );