Re: gtk-mailund-980804-0.patch.gz




James A <nevyn@and.org> writes:

> Owen Taylor <otaylor@redhat.com> writes:
> 
> [snip]
> 
> > The way Thomas's set_property works now, the key/value thing doesn't
> > really work the way that we are thinking of it, because it completely
> > replaces the existing properties with the new ones. So perhaps
> > it should be changed to gtk_text_change_properties() with the
> > semantics that it overlays the specified properties on to
> > of the existing properties for the span, creating new properties
> > as necessary.
> > 
> > (That is, if I apply the 'red' foreground to some portion of
> > a string in 'courier', with
> > 
> >  gtk_text_change_properties (text, NULL, red, NULL, NULL, NULL, 10);
> > 
> > then I get red courier text.
> > 
> > But this raises and additional problem is that there are two distinct
> > meanings for 'font' 'fore' and 'back' being equal to NULL -
> >  
> >  1) Same as current values for the text.
> >  2) Same as default.
> 
>  You could also say that NULL indicates it will always take the
> current values, with the default just being the special case of not
> having changed them.

But then there is no way to _unset_ the current values back
to the default values. (See below for why get_default...
doesn't work)
 
> > This becomes an especially important distinction when you
> > allow changing the style of a text widget on the fly.
> > (This doesn't work now, but it will work for 1.2).
> > 
> > So, either we have to add a flags field, or split this into:
> > 
> >  gtk_text_change_font ()
> >  gtk_text_change_fore ()
> >  gtk_text_change_back ()
> >  gtk_text_change_data ()
> > 
> > (which could all be frontends to an internal function with
> >  a flags field)
> 
>  Or do the above and have gtk_text_default_font () etc. which seems
> nicer IMO. I'm guessing that most of the time you are going to want to 
> keep what is there.

Consider the following scenario:

- A text widget is all in the default color (say black) except one
  word, which is red.

- The default color is changed to red.

- The default color is changed back to black.

Is the red word still there? From this example, you see that
text which is has the default color is different from
text whose color happens to match the default color.

(The default colors and fonts are those set in the Widget's style)
 
> > - gtk_text_set_set_property should not freeze() / thaw() unconditionally,
> >   since that will thaw a previously frozen text widget.
> 
>  Would it not be easier to add recursive freezing/thawing in ?

Not easier, but probably marginally cleaner. Freeze-thaw is
a bit of a hack to begin with, in any case.
 
> > - This all conflicts somewhat some changes I have around here to
> >   allow properties to store the fact they have the default values.
> >   (But don't worry about that - they may not make it for
> >   another week or two, and I can deal with merging at that
> >   point)
> 
>  Hmm if you have the above default functions, then you can just
> compare them -- although it won't be as fast but then again it will
> take less memory.

The memory is pretty trivial - one guint flags field per property -
and you can't get the correct behavior without it.

Regards,
                                        Owen



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