Commit Graph

1027 Commits

Author SHA1 Message Date
Jacob Mealey
272a40a01a Update TextTag and TextView indent Documentation
Change the documentation for both to be in line with Pango documentation
specifically regarding hanging indentation.
2023-02-12 23:12:51 +00:00
Marco Trevisan (Treviño)
9eac7ed8b9 gtktextview: Avoid calling gdk_rgba_free for NULL values
Related to glib#2908
2023-02-03 16:41:56 +01:00
Carlos Garnacho
1e1d79d4f7 gtktextview: Avoid gtk_gesture_set_sequence_state()
Use gtk_gesture_set_state() as this widget does not need specific
knowledge on the sequence being used for interaction.
2023-02-02 12:50:59 +01:00
Matthias Clasen
23a3bf7a3c Merge branch 'show-hide-cleanup' into 'main'
gtk: Stop using gtk_widget_show/hide

See merge request GNOME/gtk!5273
2022-11-29 07:30:04 +00:00
Matthias Clasen
f339cc276c gtk: Stop using gtk_widget_show/hide
gtk_widget_set_visible and gtk_window_present
are better alternatives, and calling gtk_widget_show
on newly created widgets is no longer necessary
anyway.
2022-11-28 14:34:55 -05:00
Carlos Garnacho
6cbb7b848a gtktextview: Invoke OSK on button/touch taps that move/undo selection
If the ::release handler is invoked, the press/release happened without
drags in between. Additionally check that there is no selection at all.

This makes OSK invoked on taps that move the caret around, while tapping
in the selection invokes edition popup and text handles without bringing
in the OSK.
2022-11-28 15:46:41 +01:00
Carlos Garnacho
ed81c265ac gtktextview: Claim drag gesture after an actual selection change
This way, the drag gesture lets the click gesture ::release handler
happen if there was no actual changes to the selected text (i.e.
too short drags). This matches the ::release handler behavior match
the situations in which the OSK was being invoked by the wayland
GtkIMContext.
2022-11-28 15:46:41 +01:00
Matthias Clasen
e09138ce45 textview: Stop using gtk_style_context_save_to_node 2022-10-12 15:35:00 -04:00
Matthias Clasen
616e0a0d32 textview: Stop using gtk_snapshot_render api
The gtk_snapshot_render api is deprecated, so avoid using it.
2022-10-12 15:35:00 -04:00
Matthias Clasen
60dafebd91 Deprecate gtk_snapshot_render apis
Move the implementations from gtksnapshot.c to
gtk/deprecated/gtkrender.c and deprecated these
functions. We want to get rid of them.

These functions are still used in some of our widgetry,
so use G_GNUC_BEGIN/END_IGNORE_DEPRECATIONS around
them.
2022-10-12 15:35:00 -04:00
Matthias Clasen
7c5e1c6195 gtk: Rename some private headers
Improve the consistency of our private header
naming, by add 'private' to a bunch of them.
2022-10-05 23:01:28 -04:00
Matthias Clasen
aa9a7a931d Merge branch 'wip/carlosg/shuffle-reset-take2' into 'main'
gtkimcontextwayland: Shuffle full resets after IM changes

Closes #5200

See merge request GNOME/gtk!5050
2022-09-28 01:39:49 +00:00
Matthias Clasen
e499a09759 Drop gtkintl.h
Include gtkprivate.h for I_() and glib-i18n.h for
gettext macros.
2022-09-24 10:03:37 -04:00
Carlos Garnacho
fb280e47d6 gtkimcontextwayland: Shuffle full resets after IM changes
Doing reset() on the text widgets after commit and delete_surrounding
is still too eager for some IMs (e.g. those that expect being able
to commit text while keeping a preedit buffer shown).

However, reset() is more of a "synchronize state" action on Wayland,
and it is still desirable to do that after changes that do come from
the IM (e.g. requesting the new surrounding text and cursor/anchor
positions). Notably here, the text_input protocol may still come up
with a preedit string after this state synchronization happens.

Shuffle the code so that the text widgets do not reset() the IM
context after text is deleted or committed, but the Wayland IM does
apply its practical effects after these actions happen. This keeps
the Wayland IM fully up-to-date wrt text widget state, while not
altering the ::commit and ::delete-surrounding-text behavior for
other IM context implementations.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5200
Fixes: 5b78fe2721 (gtktextview: Also reset IM context after IM...)
Fixes: 7c0a395ff9 (gtktext: Also reset IM context after IM...)
Fixes: 52ac71b972 (gtktextview: Shuffle the places doing IM reset)
Fixes: 9e29739e66 (gtktext: Shuffle the places doing IM reset)
2022-09-24 11:52:16 +02:00
Carlos Garnacho
5b78fe2721 gtktextview: Also reset IM context after IM surrounding text deletion
When the IM commands the GtkText to delete text, the cursor position
would change, and so would the surrounding text. Reset the IM context
so that these updates are properly picked up by the IM.

Fixes backspace	key behavior in	the GNOME Shell OSK, since that	relies
on the surrounding text	being properly updated for the next iteration.
2022-09-06 22:17:40 +02:00
Carlos Garnacho
41f26975a9 gtktext: Avoid early IM reset on updates
Resetting the IM on IM updates is too eager and indeed the simple
IM context doesn't like that this happens in the middle of dead
key handling.

We however want to reset the IM after actual text buffer changes
(say, a committed string) moved the cursor position, altered the
surrounding text, etc. So that the IM implementation does know to
update its state.

Since there is going to be an actual IM reset anyways, it does
no longer make sense to try to preserve the old priv->need_im_reset
status during commit handling.

Fixes: 52ac71b972 ("gtktextview: Shuffle the places doing IM reset")
Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5133
2022-09-06 22:17:40 +02:00
Carlos Garnacho
52ac71b972 gtktextview: Shuffle the places doing IM reset
During text widget manipulation (inserting or deleting text via keyboard)
the IM context is reset somewhat early, before the actual change took place.
This makes IM lag behind in terms of surrounding text and cursor position.

Shuffle these IM reset calls so that they happen after the changes, and
ensure that the IM is actually reset, since that is currently toggled on
a pretty narrow set of circumstances.

Also, fix a bug during GtkEventControllerKey::im-update where the condition
on cursor position editability to reset the IM context was inverted.
2022-08-18 19:07:12 +02:00
JCWasmx86
af5f75aa77 textview: Include gutter while computing child allocations
The width of the left gutter and the height of the top gutter
are now used while computing the child allocations for e.g.
anchors, otherwise - if such a gutter is present - the
widget would be at the wrong position.

Closes #5016
2022-07-13 07:02:55 +02:00
Sophie Herold
a546ae32d7 Remove all nicks and blurbs from param specs
Those property features don't seem to be in use anywhere.
They are redundant since the docs cover the same information
and more. They also created unnecessary translation work.

Closes #4904
2022-05-11 18:16:29 +02:00
Matthias Clasen
46a7aaac76 Merge branch 'wip/chergert/fix-textview-dnd-move-same-view' into 'main'
textview: remove drag selection after dnd move action

See merge request GNOME/gtk!4346
2022-01-07 03:15:48 +00:00
Christian Hergert
e14d6fe9d5 textview: remove drag selection after dnd move action
If we have a GDK_ACTION_MOVE, we need to delete the selection. However,
previously this only worked when the drop target and drag source were
different applications, as the selection would get messed up along the
way.

Instead, we stash marks for the duration of the operation so that we can
delete the appropriate selection when completing the move.
2022-01-06 16:30:34 -08:00
Christian Hergert
344ad0355e textview: scroll insert onscreen after undo/redo
After performing an action such as undo/redo, we need to actually scroll
to the position where the operation occurred.

I do note that the scroll here seems to often get invalidated if it is
pages away, and we never make the full scroll. But I've seen this all over
the place elsewhere too and that needs to be handled, most likely, as a
more comprehensive fix for scrolling during line validation.

Related #4575
2021-12-26 12:56:42 -08:00
Matthias Clasen
2f7fa10434 Merge branch 'textview-im-surrounding' into 'main'
textview: Provide more context to input methods

See merge request GNOME/gtk!4209
2021-12-03 20:26:54 +00:00
Matthias Clasen
d5c01098fd textview: Provide more context to input methods
When returning surrounding context to input methods,
include at least 2 words before and after the insertion
point.

Update the affected input method tests.
2021-12-03 14:44:05 -05:00
Matthias Clasen
67ad566188 textview: Improve scroll-to-mark behavior
The idea of within-margin is to scroll as little
as possible to bring the mark within the margins
defined by the factor. The code was achieving
that when scrolling down, but not when scrolling
up. This change makes things symmetrical.

Fixes: #4325
2021-12-01 19:35:11 -05:00
Matthias Clasen
b3b0321620 textview: Avoid misplacing the Emoji chooser
When the iter is at the end of the buffer,
gtk_text_view_get_iter_location returns a
rectangle with width 0, which in turn makes
gdk_rectangle_intersect return FALSE.

Avoid that by always giving the rectangle
non-empty dimensions.

Fixes: #4503
2021-11-30 19:44:26 -05:00
Matthias Clasen
f66172451d textview: Respect editability for Emoji
Switch the Emoji chooser keybinding to use the
action, so that disabling the action has the
desired effect.
2021-11-30 18:37:33 -05:00
Matthias Clasen
4c029af6cd textview: Don't leave embedded children behind
When scrolling embedded widgets out of view,
they sometimes get left behind because we don't
reallocated them. To avoid that, move _all_ children
out of view in size_allocate, and let the current
child allocation plumbing move the visible ones
back in place.
2021-11-08 14:17:42 -05:00
Matthias Clasen
1c6efea370 Remove a confusing comment
It talks about propagating to unanchored children,
but then iterates over anchored_children. That does
not add up.
2021-11-08 14:17:42 -05:00
Christian Hergert
659393049e textview: improve undo grouping when overwriting
We want to group in more than one undo group when removing a selection
and replacing it with a new character or characters, unless we're
replacing a single character. In that case, the natural thing is to treat
it as an atomic change.
2021-09-23 13:25:41 -07:00
Jordan Yelloz
5f913e9558 gtktextview: Fixed arrow key crash.
When pressing the keyboard arrows to move around when the insertion point is
hidden, it causes an assertion error in blink_cb.

Insertion point blinks should only be scheduled when blinking is enabled and the
insertion point is visible.

Closes #4275
2021-09-21 09:14:22 -07:00
Matthias Clasen
9cfce67d0f textview: Remove a dead store
Pointed out by clang.
2021-09-17 22:06:21 -04:00
Matthias Clasen
754212d0f9 textview: Invalidate Pango contexts
We need to invalidate the Pango contexts when
font settings change. Use the new helper
gtk_widget_update_pango_context to make it less
likely that we forget to update some things.
2021-09-04 15:42:05 -04:00
Matthias Clasen
3a50ff57d8 Clean up the code
Avoid compiler warnings, and make the code
a bit more compact.
2021-08-26 20:45:17 -04:00
Matthias Clasen
8ac2e8d495 textview: Apply font features from css
We were forgetting to propagate these values from
CSS to the default attributes. Share the code for
getting these values out of a GtkCssStyle.
2021-08-26 20:21:23 -04:00
Matthias Clasen
e56cf85fd1 textview: Apply text transform from css
We were forgetting to propagate these values from
CSS to the default attributes.
2021-08-26 18:53:30 -04:00
Matthias Clasen
1c6aef1862 textview: Apply line decoration from css
We were forgetting to propagate these values from
CSS to the default attributes.
2021-08-26 18:46:57 -04:00
Matthias Clasen
93148d302f textview: Don't forget to collect css letterspacing
There are more properties missing, this is just
the start.

Fixes: #4207
2021-08-26 15:01:23 -04:00
Matthias Clasen
4759afcc3e textview: Set line height from css
Set the line height in the default attributes from
the CSS style. This makes line height work in
GtkTextView.
2021-08-22 15:15:50 -04:00
Matthias Clasen
8aa25046dc textview: Improve word selection
Avoid selecting a whole extra paragraph when a select-by-words
selection is extended beyond the end of the previous paragraph.

Fixes: #4177
2021-08-19 00:33:03 -04:00
Matthias Clasen
f6659fea8d imcontext: Improve docs
Add some more docs around GtkIMContext.
2021-08-17 22:33:26 -04:00
Christian Hergert
fc701baef8 Revert "textview: fix yoffset position when top_margin is set"
This reverts commit 908b1e5e12.

This commit broke top-margin altogether.
2021-08-05 11:52:45 -07:00
Matthias Clasen
d119c55b72 textview: Fix the get_surrounding implementation
This was, sadly, returning garbage.
2021-08-02 20:44:40 -04:00
Matthias Clasen
253e25a73c Add a private getter for the textview key controller
This will be used in tests.
2021-08-02 20:44:40 -04:00
Christian Hergert
908b1e5e12 textview: fix yoffset position when top_margin is set
This doesn't need to be included in the calculation or it will cause the
yoffset to continually shift while the window is resized.

Fixes #4134
2021-07-29 16:45:04 -07:00
Matthias Clasen
19b534f7de Avoid copying static debug strings
The g_source_set_name calls were showing up as a
major source of strdups in our profiles. Avoid that
by using new GLib api when available.
2021-07-28 22:42:46 -04:00
Christian Hergert
d63d9b2319 joinedmenu: add helper to join menus instead of nesting
In many cases, we have an "extra-menu" property that is used to allow
applications to join menus into the native menu for the widget. Previously,
this was done by nesting that menu in a section.

Doing so increases the complexity of the rules for GtkMenuTracker as you
may want different handling from inside of the section vs toplevel
sections.

If instead we synthetically glue the menus together, we have a much more
natural joining of menus as the application developer would expect for
their menu.

This also ports GtkLabel, GtkText, GtkPasswordEntry, and GtkTextView to
use the joined menu helper.

The joined menu helper comes originally from GNOME Builder and has had
extensive use there.

Fixes #4094
2021-07-08 14:16:06 -07:00
Christian Hergert
a6101f0181 textview: give application developers access to RTL and LTR context
This allows developers to modify the pango context that is used when
rendering text within the text view.

Such access can be useful to alter how rounding occurs with API such as
pango_context_set_round_glyph_positions() and is needed by GtkSourceView
for proper placement of glyphs within the overview map.
2021-06-19 12:28:18 -07:00
Matthias Clasen
74a39bbae0 textview: Cosmetic docs changes 2021-05-22 17:25:27 -04:00
Matthias Clasen
91f7b9663f gtk: Clean up docs syntax
Replace leftover gtk-doc syntax (#Type) with backquotes.
2021-05-22 17:25:26 -04:00