Re: [gtk-list] Re: [Q] gtk_widget_set_style



Owen Taylor wrote:

> > How do I "copy the default style to it"? Do I have to copy
> > every single field of the struct? That seems like a lot of
> > work for changing only the font in one widget.
> 
> You can almost do:
> 
>   *style = *old_style
> 
> but that is a bad idea since there are some private fields.  (The
> reference count included!)  Right now, you would have to copy each
> field. Or better, just use a rc file to create the new style.
> 
> > Is there any reason for not supplying a new
> >
> > GtkStyle *gtk_style_new( GtkStyle* template );
> >
> > function, which would copy the field and you could
> > then selectivly change the field you want to change.
> 
> I don't think so. I would call it gtk_style_copy () since
> gtk_style_new is already taken. But otherwise, it is a good
> idea. (Or maybe gtk_style_new_from_style ())

That sounds consistent, I'll try to make a patch.

> > Apart from that, I don't think that the font should
> > be in the style struct. Changing an item's font is
> > nothing unusual. Changing the style of all item seems
> > like a drastic measure.
> 
> The point is that the font should be something configurable
> by the user.
> 
> I _loved_ having that ability when someone decided to
> change all the GIMP's fonts to 8-point. All I had to do
> was edit my gimprc once, instead of patching the code with
> every new release.
> 
> In anything but the most trivial demo applications, if you
> want something to have a different font, you should use
> a gtkrc and set up a separate named style for that usage,
> instead of hard-coding it into your program.

Am I writing the wxWindows wrapper for GTK, so gtkrc is
not an issue as the users of wxWindows won't have access
to it.

In wxWindows, dialog elements inherit the font from their
parents upon creation. Afterwards, you can set individual 
fonts for each dialog item as you wish. This is flexible
and simple and I dare to say also quite intuitive. As this
is currently hardly possible under GTK, it might be worth
to consider a change of policy in the way descibed above
for the GTK.

Why not move a widget's font from a widget's style to the 
widget itself and let the widget inherit the font from the 
parent widget? A toplevel widget could still use a style font
defined in gtkrc (or whereever) and - using ref counting -
hardly any memory or speed would be wasted. This would also
solve the problem for list items inheriting the font from
their container.

  Regards,

     Robert Roebling



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