Re: Distinguish column header from normal button



On 14 Sep 2005 19:08:39 +0200, Soeren Sandmann <sandmann daimi au dk> wrote:
> Federico Mena Quintero <federico ximian com> writes:
> 
> > 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.
> 
> There is precedence in the toolbar for just setting a name:
> 
> static void
> gtk_toolbar_init (GtkToolbar *toolbar)
> {
>   ...
>   priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
>   gtk_widget_set_name (priv->arrow, "gtk-toolbar-arrow");
>   gtk_widget_show (priv->arrow);
>   ...
> }

If this is done for the arrow, then why not do it for buttons as well?
For example
gtk_widget_set_name (priv->button, "column-header-first");

This would not break any existing apps. An added advantage is that
'fake' GTK+ apps and custom widgets can use this system too, avoiding
the need to derive from a GtkTreeView. However, doing a string
comparison on every button inside the engine sounds pretty hacky
too...

But I think there's a better solution.

Maybe some new API could be added that an engine can use to determine
if there are special properties?
gboolean gtk_widget_has_extended_style(GtkWidget*);
const gchar* gtk_widget_get_extended_style(GtkWidget *widget, const
gchar *property);

I'm not 100% sure, but I assume this can be done without breaking the ABI. 

Ofcourse, it would still require a 'dummy' GtkWidget object for
Mozilla and other fake GTK+ apps, but it's better than nothing.

- Richard Stellingwerff.



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