API Change request: gtk_paint_focus and GtkStyleClass->draw_focus



Hi All:

I mentioned an API issue embedded in my outstanding theme patch for GTK+
yesterday.  Here are the details.  BTW, I said yesterday that my patch
was 9 weeks old but to be clear, that's the ago of my original patch.  A
more generally correct, but considerably larger, patch was submitted
only a little over 5 weeks ago.  It requires the following API change to
gtk_paint_focus, and to the draw_focus method of GtkStyleClass:


void
gtk_paint_focus (GtkStyle      *style,
                 GdkWindow     *window,
                 GdkRectangle  *area,
                 GtkWidget     *widget,
+		 GtkStateType   state_type,
                 const gchar   *detail,
                 gint           x,
                 gint           y,
                 gint           width,
                 gint           height)
{
  g_return_if_fail (GTK_IS_STYLE (style));
  g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_focus != NULL);
  
+  GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, area, widget,
state_type, detail, x, y, width, height);
-  GTK_STYLE_GET_CLASS (style)->draw_focus (style, window, area, widget,
detail, x, y, width, height);
}


The reasons for this are several: currently GTK+ focus drawing is
hard-coded to use a black focus line of fixed width and pattern.  This
not only prevents theming of focus linewidths, which makes low-vision
themes impossible without a separate engine, it also means that for
themes with black as a possible widget bg color the focus line is
sometimes invisible.  

To fix this properly one needs to use 'fg' graphics context (and color)
rather than hard-coded black (hard-coded colors in generic draw routines
are never a good thing).  One also needs to know the state of the item
that is focussed (not always GTK_STATE_NORMAL).  For widgets, this can
be gotten by querying the state of the widget, we then use fg[state] as
the focus line color.

Problem is, gtk_paint_focus is used not just for widgets but for
lightweight/'flyweight' components such as GtkTreeView cells, etc.  In
these cases a NULL 'widget' param is passed, thus the need for a
separate 'state-type' param.  Without this fix focus indication in lists
and tables is particularly broken, and high-contrast RC themes are
impossible to implement.

gtk_paint_focus is called 17 times in gtk+.  The only use I have found
outside gtk+ in gnome libraries is in gal/e-text, where it appears
twice.  It does not seem to appear in eel, gnomeui, or other UI libs.

This is perhaps a little more intrusive a change (incompat API) than we
would like at this stage, but I think that the impact is confined to
GTK+ at the moment, and the cost of *not* making the change is quite
high from an accessibility point of view.

Thanks,

Bill



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