GNOME Bugzilla – Bug 622762
No accessors for button/arrow members
Last modified: 2011-02-04 16:12:22 UTC
The pseudo-GTK theming code used by Mozilla and WebKitGTK+ to fake GTK theming in web forms accesses those members, the rationale is as follows (from the code): static gint ensure_tree_header_cell_widget() { if(!gParts->treeHeaderCellWidget) { /* * Some GTK engines paint the first and last cell * of a TreeView header with a highlight. * Since we do not know where our widget will be relative * to the other buttons in the TreeView header, we must * paint it as a button that is between two others, * thus ensuring it is neither the first or last button * in the header. * GTK doesn't give us a way to do this explicitly, * so we must paint with a button that is between two * others. */ GtkTreeViewColumn* firstTreeViewColumn; GtkTreeViewColumn* lastTreeViewColumn; ensure_tree_view_widget(); /* Create and append our three columns */ firstTreeViewColumn = gtk_tree_view_column_new(); gtk_tree_view_column_set_title(firstTreeViewColumn, "M"); gtk_tree_view_append_column(GTK_TREE_VIEW(gParts->treeViewWidget), firstTreeViewColumn); gParts->middleTreeViewColumn = gtk_tree_view_column_new(); gtk_tree_view_column_set_title(gParts->middleTreeViewColumn, "M"); gtk_tree_view_append_column(GTK_TREE_VIEW(gParts->treeViewWidget), gParts->middleTreeViewColumn); lastTreeViewColumn = gtk_tree_view_column_new(); gtk_tree_view_column_set_title(lastTreeViewColumn, "M"); gtk_tree_view_append_column(GTK_TREE_VIEW(gParts->treeViewWidget), lastTreeViewColumn); /* Use the middle column's header for our button */ gParts->treeHeaderCellWidget = gParts->middleTreeViewColumn->button; gParts->treeHeaderSortArrowWidget = gParts->middleTreeViewColumn->arrow; g_object_set_data(G_OBJECT(gParts->treeHeaderCellWidget), "transparent-bg-hint", GINT_TO_POINTER(TRUE)); g_object_set_data(G_OBJECT(gParts->treeHeaderSortArrowWidget), "transparent-bg-hint", GINT_TO_POINTER(TRUE)); } return MOZ_GTK_SUCCESS; } -- So we need to either provide some kind of API to do what this code wants, just stop doing it, or provide the accessors for those members.
And well, the "just stop doing it" only applies to myself (WebKitGTK+) in this case, obviously...
I think the main issue here is that button/arrow could be NULL/unused ... I think the original idea of the API has always been to hide these from the public. An obvious issue is that also gtk_tree_view_column_get_widget() does not give you access to the button in case the default button is used.
Another use case for providing access to at least the button member: I had been using it to catch right-clicks on the column header, which would show a pop-up menu with add/remove column options. I can't come up with any way to do this in GTK3 short of recreating the default button widget myself. Would it make sense for gtk_tree_view_column_get_widget() to return the default button if it hasn't been overridden with gtk_tree_view_column_set_widget(), or would that break API semantics? Another option is to break the default button into a new standalone widget, so developers have something to start with if that need the default button + some custom behavior. You could provide access to the arrow too that way.
There's a gtk_tree_view_column_get_button now.