Re: GtkBuilder Public API - Last call



Kalle Vahlman wrote:
2007/6/14, Yevgen Muntyan <muntyan tamu edu>:
Kalle Vahlman wrote:
> 2007/6/14, Yevgen Muntyan <muntyan tamu edu>:
>> Kalle Vahlman wrote:
>> > 2007/6/14, Yevgen Muntyan <muntyan tamu edu>:
>> >> Set widget name in constructor or init(), then create this widget
>> with
>> >> GtkBuilder.
>> >> Yeah, "semi-broken".
>> >
>> > Why is that preferrable over matching by the widget class name?
>> >
>> See
>> http://svn.gnome.org/viewcvs/gtksourceview/trunk/gtksourceview/gtksourcestylescheme.c?view=markup
>>
>> for cursor color thing, set_cursor_colors() function.
>
> Which part of it breaks due GtkBuilder? I don't see GtkSourceView
> setting it's name (nor the cursor colors) in the constructor, which
> was the primary concern you brought up.

Oh well,
http://mooedit.sourceforge.net/hg/moo/?f=4c33c8446db7;file=moo/mooedit/mootextview.c
see moo_text_view_init. What does it change?

Is there a particular reason to set the name in _init() rather than in
_set_cursor_colors()? It would avoid setting it completely if using
Gtk+ >=2.11.3

Code was written before Gtk+ >= 2.11.3.

and since it does nothing(?) if the custom colors are
not set...

Also, why is it neccessary when the colors are not set explicitly?
Isn't the class name as good as any for setting default values in
themes?

What's necessary? Let's not consider funny cases when nothing changed,
think white cursor and white text color and black background in a usual
black-on-white gtk theme (people actually do use dark themes, it's not
some academic exercise about how to override theme colors).


The GtkSourceView code (and code above) was an example
of code which uses unique widget name to modify style property,
since you didn't seem to believe it is possible and may be
needed.

I never said it wouldn't be needed. I'm just saying that there is no
reason to do it in construction stage,

You were talking about class matching and whatnot, so I got
that impression. Anyway, one possible reason is that constructor
and init() are natural places for things which are done once for
whole life of the widget. Another reason is that one may still
change the name if he knows what he's doing (GtkBuilder doesn't
and it's what sucks). Dunno, it just happened so. Now, "If you want
the widget to be used with GtkBuilder you must not set widget
name until after construction. Why? No reason really, just because."
It's silly.

since it will not give you
anything over matching by class.

That setting is *per-widget*, not per-class.

If you need to hack styles in later,
you can set the name then and hope the user doesn't go and change it
afterwards. Also you can hope that the user didn't want to customize
the theming of that widget by his own account and get angry at you
since the widget changes it's name making it impossible...

So there are possible problems (of course), so I shouldn't mind
one more possible complication? Note that this latter complication
is not related to theme business (as opposed to user changing styles
manually and breaking things), it's just some strange function
call in a place seemingly unrelated to the theme business.


[snip]

The widget does
*not* violate any Gtk rules, it uses properties and whatnot.
It uses widget name just as docs say widget name is intended
to be used. And so on and so forth.

Or let's get back to "gtk-tooltips". No, symbolic colors
won't solve it as long as it's not mandatory for a theme to have
some predefined "tooltip" color, and it will never be the case.

*Nothing* is mandatory in a theme. In fact, you can run GTK+ without a
theme at all! Making widgets that won't work in that case is (ie.
without specific style set) is just plain wrong.

Who makes such widgets? Is it relevant?

They may look like
shit, but that's hardly the point, they still should be usable (even
if it means the cursor color won't be pink, but matches the foreground
color...).

I think that GTK+ should have a stock-item style database for colors
too, so one could finally start theming widgets a bit more sensibly
(but that's really some other thread of discussion).

Well, if documented usage of gtk_widget_set_name() will die
because we get API and everything for everything, it will be
great. As well it would be great if everything was great.


If you write a widget which looks like a tooltip, you can't use
it with GtkBuilder, very simple.

You mean you can't use it if you want the theme's colors on it, which
is unfortunate (but fixable by making the tooltip window a derived
class I think?).

You can't use it with GtkBuilder (without resetting name manually
after construction) if you want it to be yellow (i.e. have the tooltip color
from the theme). And no, not a window (derivation has nothing to
do with it, absolutely). gedit message area thing is yellow tooltip-like.

Sorry, it's the last one. After all, I am not making tooltip-like things,
not making them with glade, and gtk got new API for cursor color.
No problems, it seems.

Yevgen




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