Re: Default settings for GtkTextAttributes
- From: Oisin Boydell <Oisin Boydell Sun COM>
- To: gtk-devel-list gnome org
- Cc: otaylor redhat com
- Subject: Re: Default settings for GtkTextAttributes
- Date: Wed, 6 Jun 2001 13:09:57 +0100 (BST)
> Delivered-To: gtk-devel-list gnome org
> To: gtk-devel-list gnome org
> Cc: Oisin Boydell <Oisin Boydell Sun COM>
> Subject: Re: Default settings for GtkTextAttributes
> From: Owen Taylor <otaylor redhat com>
> User-Agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7
> X-BeenThere: gtk-devel-list gnome org
> X-Loop: gtk-devel-list gnome org
> X-Mailman-Version: 2.0.5
> List-Help: <mailto:gtk-devel-list-request gnome org?subject=help>
> List-Post: <mailto:gtk-devel-list gnome org>
> List-Subscribe: <http://mail.gnome.org/mailman/listinfo/gtk-devel-list>,
<mailto:gtk-devel-list-request gnome org?subject=subscribe>
> List-Id: Development of GTK+ <gtk-devel-list.gnome.org>
> List-Unsubscribe: <http://mail.gnome.org/mailman/listinfo/gtk-devel-list>,
<mailto:gtk-devel-list-request gnome org?subject=unsubscribe>
> List-Archive: <http://mail.gnome.org/archives/gtk-devel-list/>
> Date: 01 Jun 2001 17:22:24 -0400
>
>
> Oisin Boydell <Oisin Boydell Sun COM> writes:
>
> > I noticed that the function gtk_text_attributes_new() which sets up a new
GtkTextAttributes structure sets most
> > of the values to 0 by default. This is not correct since setting 0 for the
> > GtkTextAttributes->(PangoFontDescription)font->(PangoStretch)stretch
corresponds to
> > "PANGO_STRETCH_ULTRA_CONDENSED" in the PangoStretch enum. The default value
should be 4 which corresponds to
> > "PANGO_STRETCH_NORMAL". It is also incorrect to set
> > GtkTextAttributes->(PangoFontDescription)font->(PangoWeight)weight to 0
which corresponds to
> > "PANGO_WEIGHT_ULTRALIGHT". It should be "PANGO_WEIGHT_NORMAL".
> >
> > Problems arise when using gtk_text_iter_get_attributes() which fills a
GtkTextAttributes struct given as
> > parameter. If I use a newly created GtkTextAttributes initialized with
gtk_text_attributes_new() then any
> > values which are not set by tags in the text remain as the default values...
the wrong default values as
> > mentioned above such as PANGO_STRETCH_ULTRA_CONDENSED when the text has no
stretch attribute associated with
> > it. The value should be PANGO_STRETCH_NORMAL.
> >
> > I will send a patch soon for gtktexttag.c which sets a GtkTextAttributes
struct to correct default values when
> > initialized with gtk_text_attributes_new().
>
> I'm not sure that PANGO_WEIGHT_NORMAL is really any better of a default
> than PANGO_WEIGHT_ULTRALIGHT.
>
> What you really need is a function to get the default attributes for a
> particular text view - this is stored as view->layout->default_style,
> but there is no public accessor for this.
>
> So, some function like gtk_text_view_get_default_attributes() that
> a bit like:
>
> {
> gtk_text_view_ensure_layout (text_view);
>
> return gtk_text_attributes_copy (text_view->layout->default_style);
> }
>
But there is no way of knowing whether a particular attribute has been set or
not. For example, if the PangoWeight attribute was not set (either as the
default for the text, or in a particular range of the text) then it would still
have to be equal to one of PANGO_WEIGHT_ULTRALIGHT, PANGO_WEIGHT_LIGHT,
PANGO_WEIGHT_NORMAL, PANGO_WEIGHT_BOLD, PANGO_WEIGHT_ULTRABOLD,
PANGO_WEIGHT_HEAVY in the GtkTextAttribute struct since there is no value in
PangoWeight specifying NOT_SET.
I am implementing a function in the atk accessability interface which returns a
GList of gchar* name/value pairs which describe the attributes that are set at a
particular point in the text. If a particular attribute is not set, the function
will not return any mention of it since only attributes that are explicity set
are of interest. But it is impossible to tell whether an attribute is set or not
by looking at a GtkTextAttribute struct since all values will be set to some
default value. I do not know if the font stretch was explicitly set to
PANGO_STRETCH_ULTRA_CONDENSED or if this is just the default value for example.
There are two solutions to this that I can see:
1. Add a new value to all the Pango enumerations specifying that no value is set
such as PANGO_WEIGHT_UNSET, PANGO_STRETCH_UNSET etc.
2. Add flags to the GtkTextAttributes struct to specify which values are
set/unset.
I noticed that GtkTextTags have flags specifying if values are set/unset but
when tags are converted into a GtkTextAttributes struct by the
_gtk_text_attributes_fill_from_tags() function as part of the public
gtk_text_iter_get_attributes() this information is lost.
Oisin.
> Regards,
> Owen
>
> _______________________________________________
> gtk-devel-list mailing list
> gtk-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-devel-list
******************************************************
Oisin Boydell
Sun Microsystems Ireland
Phone: +353 (0)1 8199778
Mobile: +353 (0)86 3045117
******************************************************
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]