Re: Distinguish column header from normal button
- From: Federico Mena Quintero <federico ximian com>
- To: remenic gmail com
- Cc: gtk-devel-list <gtk-devel-list gnome org>
- Subject: Re: Distinguish column header from normal button
- Date: Tue, 13 Sep 2005 17:48:44 -0500
On Tue, 2005-09-13 at 23:45 +0200, Richard Stellingwerff wrote:
> To distinguish Column headers from normal buttons, I check if its
> parent is a GtkTreeView or a GtkCList. A horrible way, but afaik the
> only way.
> In order to properly distinguish a column header from a normal button,
> I was thinking about setting a name on the column header button, using
> gtk_widget_set_name. Perhaps something like "Header:First",
> "Header:Middle", and "Header:Last".
The right way to do it is to add a private API to GtkButton, so that the
tree view can tell the button which hint to pass to the gtk_paint_*()
functions. The theme engine will then use this hint to draw the proper
box type for the tree column's buttons.
> a) Where do I set the names of these widgets. It needs to be done when
> a column is added, removed, moved, or its visibility is toggled. Which
> function catches these events, or do I need to add them myself?
You want to change the hints in the buttons whenever the tree view emits
the "columns-changed" signal.
Grep for "COLUMNS_CHANGED" (note the underscore) in gtktreeview.c;
you'll find three emissions thereof. That's where you want to do
something like
GList *l;
for (l = tree_view->priv->columns; l; l = l->next)
{
GtkTreeViewColumn *col;
const char *hint;
col = l->data;
if (l->prev == NULL)
{
if (l->next == NULL)
hint = "gtk-treeview-header-left-right";
else
hint = "gtk-treeview-header-left";
}
else if (l->next == NULL)
hint = "gtk-treeview-header-right";
else
hint = "gtk-treeview-header-middle";
_gtk_button_set_hint (col->button, hint);
}
Making that work in RTL mode is left as an exercise for the reader.
Speaking of Clearlooks... currently, the hints that get passed to the
gtk_paint*() functions are totally undocumented. Theme authors have to
dig in the GTK+ sources to see how each widget draws itself. It would
be *fantastic* if you could cook a list of the hints for each widget,
and leave it as a reference for other theme authors :)
Good luck, and keep up the sexy,
Federico
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]