Commit Graph

1005 Commits

Author SHA1 Message Date
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
Matthias Clasen
4a0d3d7acc docs: Reduce redundancy
Remove a boatload of "or %NULL" from nullable parameters
and return values. gi-docgen generates suitable text from
the annotation that we don't need to duplicate.

This adds a few missing nullable annotations too.
2021-05-20 20:45:06 -04:00
Matthias Clasen
7fe0610b68 introspection: Stop using allow-none
allow-none has been deprecated for a long time
already. Instead use optional and nullable everywhere.
2021-05-20 19:17:49 -04:00
Matthias Clasen
8ba16eb4f1 Documentation fixes
Mostly fixing up indentation of continuation lines,
and other small cleanups.
2021-05-20 19:17:49 -04:00
Alexander Mikhaylenko
0fa4b7a249 textview: Invalidate selection when its style changes 2021-05-04 00:16:05 +05:00
Matthias Clasen
019855a27f textview: Use device timestamps for obscured cursors
Stash away the device timestamp when obscuring
the pointer, and compare it when we decice whether
to unobscure it. This fixes a problem where synthetic
motion events would make the cursor reappear
prematurely.

Fixes: #3792
2021-03-26 10:30:33 -04:00
Matthias Clasen
50139ad184 textview: Convert docs 2021-03-11 16:37:36 +00:00
Matthias Clasen
c46480fe7e textview: Use markdown for css tree 2021-03-11 16:37:35 +00:00
Matthias Clasen
50df5e0ec2 textview: Add property annotations
Connect properties, getters, and setters with annotations.
2021-03-11 16:37:32 +00:00
Emmanuele Bassi
538f935d44 docs: Fix the annotation for GtkTextView:justification 2021-03-11 16:37:31 +00:00
Matthias Clasen
f94fc28eb5 textview: Convert docs
Change link syntax, add an example image, generally clean things up.
2021-03-11 16:37:30 +00:00
Emmanuele Bassi
af8d8113eb docs: Remove the last few remaining '+' from GTK 2021-03-11 16:37:30 +00:00
Emmanuele Bassi
e8b6e6cad0 docs: Clean up the first paragraph for various symbols
The documentation engine will use the first paragraph as the summary for
a type or constant.
2021-03-11 16:37:30 +00:00
Matthias Clasen
d28df0b87e textview: Delete selection when preedit starts
This prevents confusing misrendering when the preedit text
pushes the selection text out of the rendered selection.

Fixes: #1123
2021-03-04 15:18:30 -05:00
Matthias Clasen
d1fbfb9c4e textview: Send anchor with surrounding
We have the api to do it now.
2021-03-04 15:18:30 -05:00
Alexander Mikhaylenko
f63e6394ac dragsource: Use double coordinates for checking drag threshold
If multiple nested widgets have drag sources on them, both using bubble
phase, we need to reliably pick the inner one. Both of them will try to
start dragging, and we need to make sure there are no situations where the
outer widget starts drag earlier and cancels the inner one.

Currently, this can easily happen via integer rounding: start and current
coordinates passed into gtk_drag_check_threshold() are initially doubles
(other than in GtkNotebook and GtkIconView), and are casted to ints. Then
those rounded values are used to calculate deltas to compare to the drag
threshold, losing quite a lot of precision along the way, and often
resulting in the outer widget getting larger deltas.

To avoid it, just don't round it. Introduce a variant of the function that
operates on doubles: gtk_drag_check_threshold_double() and use it instead
of the original everywhere.
2021-01-29 12:01:34 +05:00
Matthias Clasen
10d5705b70 Reduce use of GtkStyleContext
Remove some unnecessary uses of GtkStyleContext where
we can directly go to the GtkCssStyle, and and drop
unnnecessary includes.
2021-01-28 12:27:07 -05:00
Carlos Garnacho
47d0b5ad0c gkt/textview: Set an iter position for event-less menu activation
This went missing. Use the current insertion position as a reference.
Fixes invoking the menu via keyboard.
2020-12-08 23:27:03 +01:00
Jonas Ådahl
517bc0db84 gtk/texthandle: Use gtk_text_handle_present() instead of GtkNative 2020-12-07 20:37:29 +01:00
Jonas Ådahl
2cddec7798 gtk/popover: Use gtk_popover_present() instead of going via GtkNative
This makes it more explicit that managers of popovers make it "present".
2020-12-07 20:37:29 +01:00
Bilal Elmoussaoui
b47ea9421f TextView: add missing nullability annotations 2020-12-02 10:28:07 -05:00
Christian Hergert
1e994419ee textview: fix precondition assertions
It is a programmer error to call this with a child widget that has not
been placed within the GtkTextView.

Fixes #3386
2020-11-24 08:29:52 -08:00
Matthias Clasen
2ef72442ec docs: Fix the links for keybinding signals
GtkBindingSignal does not exist anymore, so link to
GtkSignalAction for an explanation of keybinding signals.
2020-11-17 07:34:52 -05:00