It's actually not enough to get proper colors for inner text tags. The
main color is correct, but color for subtext is currently not managed.
This must be fixed.
When replacing a selection, take and apply markup (if any)
from the first character of the selection for the entered
text.
This fixes the case when you no longer can change the
global layer text properties after replacing the text.
Also, this changes the behavior introduced in #1220.
Fixes: #7948 (GNOME/Gimp tracker)
* Don't generate our own marshallers if they are available in GLib
already
* Don't set the c_marshaller parameter in `g_signal_new()` if it's a
default marshaller provided by GLib. See commit message of commit
39e4aa3c57 on why this is the case.
When an error occurs, we want to prevent overwriting any previous
version of the file by incomplete contents. So run
g_output_stream_close() with a cancelled GCancellable to do so.
See also discussion in #2565.
Add signal GimpTextBuffer::color-applied which is emitted when text is
inserted or when color is applied to a span of text.
In GimpTextTool, connect to the signal and update the global color
history.
Unrelated: rename gimp_text_tag_get_color() to get_fg_color() and add
boolean return values to get_fg_color() and get_fg_color() which
indicates if a color is set on the tag at all. This ended up unneeded
in the fix but is an improvement regardless.
In particular, I don't want the preedit foreground colors to be
displayed in the text style editor UI. They are only temporary hints
and should not be taken into account as user-chosen style.
There is nothing in our UI to set background color to text, but this
can be used internally, for instance to display input method's preedit
texts with specific colors.
- use G_FILE_CREATE_NONE instead of 0
- don't put "Could not open <file> for writing: <error>" around the
returned error, the returned message is already verbose
When font, size or color were changed, set the text buffer's current
insert_tags just as we already do for the bold, italic etc. toggle
buttons. Changed gimp_text_style_editor_list_tags() to also return
the tags for font, size or color.
One possible way to decrease the incompatibilities
between letter spacing in a tagged gtk_text_buffer
and in an equivalent pango_layout
Remove also a valgrind reported invalid write in
gimptextbuffer.c
Change the generated tag names to use #rrggbb notation and compare the
colors on an 8 bit basis to make sure the comparison and the tag names
exist in the same set of values (otherwise the text buffer gets into
an inconsistent state that can even lead to crashes).
and also #define the names of the properties we (ab)use, so we don't
have to use magic strings all over the place, and we don't have to use
g_object_get() either.
- in GimpText, make "text" and "markup" mutually exclusive, so that
whenever one is set to non-NULL, the other is cleared automatically.
- add gimp_text_buffer_has_markup() which returns TRUE if any char
in the buffer is tagged.
- in the text tool, only set "markup" on the text proxy if there is
actually markup in the buffer, and set "text" otherwise.
This way we don't push "text" *and* "markup" undos on each keystroke,
and undo compression works the way it did before.
Instead, keep a list of tags to explicitely remove around (the list of
unchecked toggles), and remove only these tags, so the tags that have
no widget in the UI are not affected by the insert_tags logic.
Add gimp_text_buffer_get_iter_at_index() which does the reverse thing
than the already existing function gimp_text_buffer_get_iter_index().
Use the new function when cursor-navigation lines. Add "gboolean
layout_index" to both functions, which if TRUE indicates that the
passed in/out index is an index into the PangoLayout's content rather
than the text buffer's. When dealing with layout indices, take into
account the additional characters we insert into the serialized markup
(and thus the layout) for each character that is tagged with spacing.
because it breaks the invariant that the pango layout used for
navigating in the on-canvas editor must be a 1:1 view on the text
buffer used for editing. Will have to fix that somehow...
The copy doesn't do anything yet, but this will enable us to do
transformations on the buffer contents before turning them into
markup, and the other way around.
Use gtk_text_buffer_begin_user_action() and end_user_action() to group
all text buffer operations triggered by a single editing operation.
Connect to the buffer's "end-user-action" signal instead of to
"changed", "apply-tag" and "remove-tag" separately, so we only update
the text proxy once per user editing.
Add a list of available baseline tags to GimpTextBuffer and
automatically create baseline tags as needed. They get serialized as
<span rise="value">, so add attribute and value parameters to the
buffer's tag_to_name() and name_to_tag() functions. Properly managing
the rise's amount is a TODO, currently each keystroke changes the
baseline by 1024 pango units, which might be whatever depending on the
output grid.
instead of using the toggles only to change the style of selected text.
Introduces a list of "insert tags" in GimpTextBuffer that is applied
on newly inserted text if it exists. Clear the list on each content
or cursor/selection change, so we always display wthe style at the
cursor unless the buttons were clicked explicitely.
- keep around tags for styles in GimpTextBuffer. For now only bold,
italic, underline and strikethrough.
- add GimpTextStyleEditor, a widget which allows setting tags on
a GimpTextBuffer's selection.
- add serialize/deserialize code to/from pango markup using
GtkTextBuffer's rich text (de)serialization infrastructure.
Doesn't produce or handle <span> yet.
Pull all text buffer utility functions as methods and use
GimpTextBuffer all over the place instead of GtkTextBuffer.
Some actually usefuly features coming soon...