After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 456750 - gtksourceview.SourceTagStyle().mask is not writable
gtksourceview.SourceTagStyle().mask is not writable
Status: RESOLVED WONTFIX
Product: gnome-python-desktop
Classification: Deprecated
Component: gtksourceview
2.18.x
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2007-07-13 23:12 UTC by Josselin Mouette
Modified: 2007-07-29 12:36 UTC
See Also:
GNOME target: ---
GNOME version: 2.17/2.18



Description Josselin Mouette 2007-07-13 23:12:52 UTC
[ forwarded from http://bugs.debian.org/431962 by Adeodato Simó ]

It seems that the 'mask' attribute of gtksourceview.SourceTagStyle
objects is not writable, but instead derived whenever
SourceTagSytle.foreground or SourceTagStyle.background are set (see
gtksourceview.override).

I see no reason for this to be this way, since it breaks setting all
three foreground, background and mask, letting the TagStyle object
figure out which colors to finally use. Which works from C (it's what
gedit does, see string_to_tag_style() in gedit-languages-manager.c).

All this makes it necessary when working in Python code to check the
value of mask, and refraining from setting foreground or background
colors according to its value, which seems more unpythonic to me than
having the attribute writable.

Thanks.
Comment 1 Gustavo Carneiro 2007-07-14 14:24:50 UTC
I disagree.  The 'mask' field only exists because of limitations in the C language.  In Python we can instead automatically compute mask based on the attributes that have been actually set, which is more intuitive and less error prone.  I don't know why you'd ever want to e.g. modify style.background but not set the flag in style.mask saying background was set.
Comment 2 Josselin Mouette 2007-07-29 12:36:05 UTC
The original submitter added:

> > it breaks setting all
> > three foreground, background and mask, letting the TagStyle object
> > figure out which colors to finally use. Which works from C (it's what
> > gedit does, see string_to_tag_style() in gedit-languages-manager.c).

If you read from gedit's configuration files, background and foreground
are stored, even if only the foreground was configured (the background
is set to #000). So what gedit does is set both colors, plus the mask
(which is also stored), and let the tagstyle code figure out what to
use. That is not possible from Python.

8< --- 8< --- 8< ---

This is to show you the actual use case the user is facing. I'm not really agreeing with this idea, as it is definitely not something you'd use in the general case. You could make it so that the automatically computed mask can be overriden, but I'm afraid it would make the API confusing.