After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 622762 - No accessors for button/arrow members
No accessors for button/arrow members
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTreeView
2.22.x
Other Linux
: Normal normal
: ---
Assigned To: gtktreeview-bugs
gtktreeview-bugs
Depends on:
Blocks: 597610
 
 
Reported: 2010-06-25 20:59 UTC by Xan Lopez
Modified: 2011-02-04 16:12 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Xan Lopez 2010-06-25 20:59:53 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.
Comment 1 Xan Lopez 2010-06-25 21:04:18 UTC
And well, the "just stop doing it" only applies to myself (WebKitGTK+) in this case, obviously...
Comment 2 Kristian Rietveld 2010-06-25 21:14:36 UTC
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.
Comment 3 Matthew Barnes 2010-06-30 09:54:48 UTC
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.
Comment 4 Matthias Clasen 2011-01-04 03:48:32 UTC
There's a gtk_tree_view_column_get_button now.