Commit Graph

728 Commits

Author SHA1 Message Date
Sebastien Lafargue
8baab8f33d GtkTextView: fix margin/padding scroll behaviour
When you move line by line, only padding is
automaticly shown and you need to use Page key to show margin.

This commit also fix cursor going out of the screen bug.
2015-08-19 22:51:39 +02:00
Sebastien Lafargue
d1381569fd text view: add padding and margin
Add API to set top and bottom margins, and add the CSS padding
from the theme to the programmatically set margins.

https://bugzilla.gnome.org/show_bug.cgi?id=406159
2015-08-17 01:40:32 -04:00
Matthias Clasen
72d0b4d2c2 text view: Use gtk_simulate_touchscreen
Instead of repeated manual tests.
2015-07-31 13:46:34 -04:00
Matthias Clasen
5c2759af3c Use standard cursor names
This changes GTK+ to use gdk_cursor_new_from_name() with the
'standard' css names, instead of GdkCursorType.

https://bugzilla.gnome.org/show_bug.cgi?id=652085
2015-07-26 01:45:06 -04:00
Cosimo Cecchi
e6f97f10dd textview: don't call gtk_style_context_set_background() 2015-07-01 16:09:23 -07:00
Cosimo Cecchi
15908cfdf9 treeview: don't call gtk_style_context_set_background() 2015-07-01 16:09:23 -07:00
Carlos Garnacho
5c38991367 textview: Set handles' mode to "none" if showing the bubble
show_or_hide_handles() tries to disable visibility when the popover is
shown, although it triggers a bit late, and lets the handles flash briefly
if both popover and handles try to show at the same time (eg. when
pressing on the selection of a previously unfocused textview, the handles
were previously hidden, so they try to show again on focus in).
2015-06-12 13:04:45 +02:00
Carlos Garnacho
c11906fcdb textview: Perform tougher handle visibility checks after hiding the popover
The handles might fall outside the visible area, and shouldn't be shown
then. Just call gtk_text_view_update_handles() which will perform these
checks, and keep the handle conveniently hidden.

This was leading to unexpectedly visible handles (and in the
wrong/previous position, the handle code doesn't relocate the widget
it's about to hide) when "select all" was selected in the popover on
a textview needing scrollbars.
and extending the selection beyond the view above and/or below.
2015-06-12 12:45:03 +02:00
Carlos Garnacho
8d56346f9b textview: set text direction information on text handles
This makes them point to the correct place, given the theme supports
this.
2015-06-11 17:14:23 +02:00
Matthias Clasen
ac5fcc6b72 text view: Select word on double tap
This is an initial attempt at implementing double-tap selection.
2015-06-09 23:31:00 -04:00
Matthias Clasen
8ad0ef27a1 text view: Make touch selection work with mouse
The buttons on the popover where stealing the focus from the text
view on click, causing the popover to be dismissed before the action
was taken. Fix this by making the buttons not take focus on click.
2015-06-09 15:49:10 -04:00
Matthias Clasen
0a2b1b68fa text view: Always clear handles for mouse interaction
There were some cases where we left a handle visible
during mouse interaction, which is a little weird.
2015-06-08 06:56:12 -04:00
Matthias Clasen
76836dcd81 text view: Move touch selection a little further away
Otherwise, it looks cramped, and we end up under the finger.
2015-06-08 06:55:21 -04:00
Matthias Clasen
4511ff76fa text view: Use the drag-started signal
Use the drag-started signal to differentiate between drags that
move a handle and taps on a handle. Show the touch selection popup
for the latter, but not the former.
2015-06-08 06:55:21 -04:00
Matthias Clasen
32be35010f text view: Don't popup after drag selection
Don't show the touch selection popover after a selection drag
ends. Instead, the popover will be triggered by an explicit
touch on the selection.
2015-06-08 06:55:21 -04:00
Matthias Clasen
aff47da950 text view: Never show handles and popover at the same time
Hide the handles when the popover appears, and brind them back
when it disappears. This will need revisiting if we start using
the popover for mouse interaction as well, where we may not
want handles to show up.
2015-06-08 06:55:21 -04:00
Matthias Clasen
0c6205d538 text view: Shorten touch selection timeout
We don't want the popover to appear spontaneously, so eventually
the timeout may go away altogether. For now, shorten it to 50ms,
to avoid rewriting all the places where the timeout is set or
unset.
2015-06-08 06:51:08 -04:00
Matthias Clasen
6bbaa70c4c Update touch selection style
Update style for touch selection in GtkEntry and GtkTextView
according to https://wiki.gnome.org/Design/OS/Selections

Add 'Select All' to the default actions, change actions
to use icons and move the popover to the bottom. If there is
no selection, just offer to paste.
2015-06-07 01:08:33 -04:00
Carlos Garnacho
243cfd21a2 textview: Update handles after flushing scroll changes
Text insertion/pasting might trigger scroll, so we'd have to wait
until the text was revalidated and the scrolling truly happened
before we can check the new handle(s) position.
2015-06-02 17:30:09 +02:00
Carlos Garnacho
b54031d505 textview: Avoid usage of gdk_window_get_device_position() during DnD
Just use the last coordinates given on XdndPosition/drag_motion() in
order to trigger scrolling.

When running on Xwayland, the pointer position is unknown at this
stage on the X11 side, so the coordinates given here are bogus.
This change avoids both roundtrips and this situation.

https://bugzilla.gnome.org/show_bug.cgi?id=749679
2015-05-21 18:11:21 +02:00
Matthias Clasen
eea16f03f5 Stop using GDK_POINTER_MOTION_HINT_MASK in widgets
It is deprecated and no longer needed, and,as observed in
https://bugzilla.gnome.org/show_bug.cgi?id=746253 it
interferes with turning off event compression.
2015-03-22 17:33:38 -04:00
Matthias Clasen
c723eba135 text view: Avoid clang compiler warnings
Again, our habit to use -1 as an unset value for enum types.
2015-03-22 15:19:17 -04:00
Philip Withnall
4fc6880d83 gtktextview: Fix a definite use of an uninitialised variable
This seems to have been a typo in the original code, and allowed access
to virtual_cursor_y when it was uninitialised.

Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=712760
2015-03-09 13:41:37 +00:00
Matthias Clasen
1aee4f0384 Fix a typo
commit aa1b7fab9c introduced a misuse of G_UNLIKELY in
several places. Fix all those.
2015-01-28 10:08:13 -05:00
Benjamin Otte
aa1b7fab9c css: Remove _gtk_css_style_property_changes_affect_size()
... and _gtk_css_style_property_changes_affect_font().

Replace it with _gtk_css_style_property_get_mask_affecting().
2015-01-27 05:04:34 +01:00
Nelson Benitez Leon
885b36a6d5 GtkTextView: allow to extend text selection with mouse scrollwheel
Fixes bug 710612
2015-01-10 14:36:17 -05:00
Christian Hergert
21360a453c textview: fix duplicated binding entries. use kp variants instead.
This appears to have accidentally used the normal keypresses twice instead
of the KP variants. This resulted in shift+insert pasting twice.

https://bugzilla.gnome.org/show_bug.cgi?id=742170
2014-12-31 23:27:55 -08:00
Matthias Clasen
52b3b4207f GtkTextView: disconnect the magifier on destroy
This prevents warnings that would otherwise happen when
the magifier is finalized.
2014-12-20 19:19:24 -05:00
Carlos Garnacho
51e1e3b416 textview: make magnifier size dependent on text size
The magnifier is now set enough height to show the line being currently
manipulated, which makes it just big enough to show the layout height at
that size and magnification.
2014-12-18 21:21:33 +01:00
Carlos Garnacho
025340bfc4 textview: Implement friendlier touch selection
- It is not possible anymore to trigger text DnD through touch, pressing
  and dragging from within the selection will instead extend it. Text
  shrinking is still available through the handles
- The selection mode for touch is per-word, char-level manipulation is
  still available through the handles.
- Tapping within the selection will bring in text handles, and toggle
  text selection popover.
2014-12-18 21:20:18 +01:00
Carlos Garnacho
8c091d1484 textview: Make "extend selection" only extend
This mode could also shrink the selection, plus the starting point would
seem somewhat arbitrary (actually dependent on the dragging direction of
the last selection).

Made this mode more consistent by only allowing it to extend the selection,
only in one direction for each operation, and so it keeps the current
selection as a minimum.
2014-12-18 21:20:18 +01:00
Carlos Garnacho
a2e71203c2 textview: Pass a boolean telling whether a selection drag should extend
Instead of passing a GdkEvent and let the function figure out whether the
selection should be extended, let that to the caller and just pass a
boolean here.
2014-12-18 21:20:17 +01:00
Carlos Garnacho
ccdebb6aa0 textview: Show magnifier on top of current line
The X coordinate is dependent on touch position, but Y is stepped.
2014-12-18 21:20:17 +01:00
Sébastien Wilmet
020258f85a textview: add extend-selection signal
To be able to customize the double-click and triple-click behaviors, to
provide custom selection boundaries.

https://bugzilla.gnome.org/show_bug.cgi?id=111503
2014-12-17 12:20:02 +01:00
Matthias Clasen
f74a75ae7e Handle KP keys in copy/paste keybindings
We currently handle KP variants of some keys, but not consistenly.

https://bugzilla.gnome.org/show_bug.cgi?id=364566
2014-12-07 23:28:52 -05:00
Matthias Clasen
888304b172 Minor documentation fixes 2014-12-05 20:10:07 -05:00
Lapo Calamandrei
268efd1475 textview: remove osd style class from touch selection popover
The touch-selection class is sufficient since that needs special
casing whatever.
2014-11-15 16:09:39 +01:00
Matthias Clasen
f93795d272 Add a style class for touch selection popovers 2014-10-07 13:27:52 -04:00
Matthias Clasen
0004e667ab GtkTextView: Add a monospace property
This is a convenient shortcut for a common case. It is implemented
by adding a .monospace style class to the text view, and letting
the theme decide about the monospace font to use.
2014-10-07 00:39:42 -04:00
Benjamin Otte
91467a45fc stylecontext: Deprecate functions
- gtk_style_context_get_background_color()
- gtk_style_context_get_border_color()

Those functions shouldn't be used anymore, because they don't represent
anything from the CSS styling we support. The background color often
isn't used due to background images and there are actually 4 different
border colors (1 for each side) - if there isn't also a border image in
use.
2014-10-03 06:18:06 +02:00
Matthias Clasen
459bdbb143 Revert "Make Ctrl-u and Ctrl-k work in GtkTextView too"
This reverts commit 5744bb3cf1.

This causes conflicts with already existing shortcuts e.g.
in gedit.
2014-09-28 11:43:08 -04:00
Matthias Clasen
5744bb3cf1 Make Ctrl-u and Ctrl-k work in GtkTextView too
It doesn't make sense to have them work in entries, but not here.
2014-09-26 17:53:07 -04:00
Paolo Borelli
290a19e93d TextView: clear the background using the default bg color
Try to tidy up how the background is set on the textview:
 *) the .view class should be applied only to the text window, not
    to the margins
 *) when setting the background on the margins we must use .left etc
 *) use context_set_bg instead of manually setting the color

https://bugzilla.gnome.org/show_bug.cgi?id=735368
2014-08-26 09:55:53 +02:00
Carlos Garnacho
5bc437d2bc textview: Unset bubble timeout ID right after requesting the clipboard
The timeout ID used to be unset after we got the targets from the
clipboard, but there's still a moment between the clipboard request and
the GDK_SELECTION_NOTIFY event that the ID points to an already gone
timeout.
2014-08-22 13:24:56 +02:00
Carlos Garnacho
c5839708cc textview: Make multipress gesture accept all buttons
That gesture is meant to handle clicks on multiple buttons, so unset
the GDK_BUTTON_PRIMARY default. Also, remove unnecessary boilerplate
with the new GtkGestureSingle/GtkEventController defaults.

https://bugzilla.gnome.org/show_bug.cgi?id=734285
2014-08-15 13:53:40 +02:00
Matthias Clasen
7d55355d4d GtkTextView: Preserve the cairo context around draw_layer
Otherwise, draw_layer might unintentionally wreak havoc on the
regular drawing that happens between the two draw_layer calls.
2014-08-13 09:18:08 -04:00
Matthias Clasen
7450277708 GtkTextView: Change draw_layer signature
Vfuncs should really take 'this' of the right type - the type
that the vfunc is added in.
2014-08-13 09:18:08 -04:00
Carlos Garnacho
9d7f1caca7 textview: Avoid relocating adjustments on ::size-allocate while these are animating
An animation may be scheduled while the textview content changed in size, so the resize
queued would just unset the animation and set the adjusments with a current value,
defeating gtk_text_view_scroll_to_iter(). In this case, just avoid the adjustment change,
as there is a target value on the way.

https://bugzilla.gnome.org/show_bug.cgi?id=733406
2014-08-03 20:12:47 +02:00
Alexander Larsson
5b53eb287c textview: Add draw_layer vfunc
This allows subclasses to render things below and above the text
in the text view. This allows e.g. GtkSourceView to highlight the
cursor row and to render overlays for colum 80. This used to be done
by rendering before/after chaining up to the parent, but that doesn't
work anymore since the view now renders a background, and due to the
use of the pixel cache.
2014-07-28 16:23:33 +02:00
Alexander Larsson
4fe051bb4a Revert "GtkTextView: Fix regression in GtkSourceView drawing"
This reverts commit 1ac13435b7.

We want to instead replace this with special vfunc for drawing
below/above the main text so that gtksourceview can use it.
2014-07-28 16:23:33 +02:00
Sébastien Wilmet
9527205291 GtkTextView: use GSlice
GSlice is better for allocating structs.

https://bugzilla.gnome.org/show_bug.cgi?id=733407
2014-07-20 12:26:01 +02:00
Matthias Clasen
34245515e5 Add a 'touchscreen' debug flag
This has the same effect as the GTK_TEST_TOUCHSCREEN environment
variable, but can be toggled at runtime.
2014-07-10 10:12:02 -04:00
Carlos Garnacho
7178e342b1 textview: Call gtk_widget_size_allocate() on children widgets invariably
There was this hack, taken verbatim from GtkCList according to the comment,
that would recursively translate the allocation during scrolling, and set
it on children widgets through the direct gtk_widget_set_allocation() setter.

Since commit 4f89eb05cf, this has caused the wrong clipping areas to children
widgets of a textview. The reasons for this seem lost in time, and the approach
seems indeed wrong for windowed widgets as the repositioning of those windows
couldn't happen.

So replace all of this with just a gtk_widget_size_allocate() call, which does
work ok for the children widgets embedded in the "multiple views" gtk demo, and
ought to work for every other widget.

https://bugzilla.gnome.org/show_bug.cgi?id=732900
2014-07-09 22:57:52 -04:00
Carlos Garnacho
ea19e595a1 textview: Fix cursor positioning oddities when scrolling through Pg Up/Down
Use the adjustment target value when repositioning the cursor, and remove the
checks that ensured the cursor was made onscreen immediately, as there will
be definitely a delay on animated adjustment changes.
2014-07-08 21:14:41 -04:00
Carlos Garnacho
6aa8511495 textview: Use adjustment animations in gtk_text_view_scroll_to_iter()
This makes keyboard-triggered scrolling animated, as this function is
used underneath in order to make the cursor onscreen after it is
displaced.
2014-07-08 21:14:41 -04:00
Carlos Garnacho
f7e983a4c9 textview: Use the adjustment target value to figure out if keynav failed
When moving the cursor, compare current adjustment value with the post-animation
target value, in order to avoid false "keynav failed" positives as the animation
hasn't started yet, so dx/dy are still 0 at that time.
2014-07-08 21:14:41 -04:00
Benjamin Otte
2fde5e95ee textview: Fix compiler warning
No need to use braces anymore.
2014-07-07 20:06:39 +02:00
Matthias Clasen
b04e3835cb GtkTextView: Animate keybindings 2014-07-02 20:58:16 -04:00
Paolo Borelli
715b8744f5 TextView: render the background of border windows
Set the .top, .left, etc css classes and render the background
of the border windows.
Change the reftest implementation accordingly.
2014-06-15 18:57:06 +02:00
Carlos Garnacho
05810f80a4 textview: Unobscure the mouse cursor on motion events
This used to be done before the gestures port, and was removed
accidentally, so keep the motion_notify_event handler just for
this, and fallback to having those events handled by gestures
too.
2014-06-12 23:23:43 +02:00
Matthias Clasen
6e64bc13de GtkTextView: Use G_PARAM_EXPLICIT_NOTIFY 2014-06-09 13:31:12 -04:00
Carlos Garnacho
995b6d1fd4 textview: Only trigger drag gesture on GDK_BUTTON_PRIMARY
This gesture was only meant to react on GDK_BUTTON_PRIMARY (either
through real pointer events, or implicitly assumed from touch events),
as it used to behave before gestures. Otherwise the gtk_drag_begin*()
call assumes being triggered by button 1, and the drag misbehaves
because that button isn't really in the state mask.

https://bugzilla.gnome.org/show_bug.cgi?id=731016
2014-05-31 15:11:05 +02:00
Carlos Garnacho
907e9f1946 gtk: Update GtkGesture users to the GtkPropagationPhase semantics change
Mainly doing s/TARGET/BUBBLE/ on the fully ported widgets, but GtkTreeView
where the double click handler has moved to GTK_PHASE_TARGET so it runs
parallelly to the still existing event handlers.
2014-05-27 17:47:12 +02:00
Carlos Garnacho
d05a9f9a7b gesture: Replace gtk_gesture_attach/detach with event controller API
Event controllers now auto-attach, and the GtkCapturePhase only determines
when are events dispatched, but all controllers are managed by the widget wrt
grabs.

All callers have been updated.
2014-05-27 17:47:12 +02:00
Carlos Garnacho
c9f54aef69 textview: Check first whether the sequence is handled, fetch later the event
And always unset/hide the selection popover if unhandled, that means the
sequence went grabbed/claimed somewhere else and cancelled here.
2014-05-23 19:54:33 +02:00
Carlos Garnacho
bd5fb3a09f textview: Show the magnifier popover a bit farther from the touch position
Somewhat arbitrary at the moment, would be nice to have minimal units
support for this, or at least hidpi support.
2014-05-23 19:54:31 +02:00
Carlos Garnacho
b2d56c588a textview: Improve touch popover interaction
Presses alternatively show and dismiss the popover, the popover is still
always shown invariably after any dragging happens (either text selection,
or dragging a text handle)
2014-05-23 19:54:31 +02:00
Carlos Garnacho
24f20864b4 textview: Set up controllers on the GTK_PHASE_TARGET propagation phase
This way events are managed by gestures in the event handlers themselves,
respecting the execution order already assumed by subclasses around.
2014-05-23 19:54:30 +02:00
Carlos Garnacho
d97e4bf6b7 textview: Convert gestures' coordinates to text window ones
And make some code shared between multipress/drag gesture.
2014-05-23 19:54:30 +02:00
Carlos Garnacho
f47138b653 textview: Use GtkGestureDrag for text selection/DnD
remaining code in button press/release, motion notify, and grab
notify handlers has been shuffled to be managed by this gesture.
2014-05-23 19:54:30 +02:00
Carlos Garnacho
a4da4f8dfa textview: Use GtkGestureMultiPress for click handling
The button press handler is no longer necessary, and most of its
code has been shuffled into the GtkGestureMultiPress::pressed
handler.
2014-05-23 19:54:30 +02:00
Carlos Garnacho
2ef4f1bc61 textview: remove superfluous GTK+ grabs 2014-05-23 19:54:25 +02:00
Matthias Clasen
49cf5142ba Deprecate GdkColor
It has been replaced by GdkRGBA. Time to make it official.
http://bugzilla.gnome.org/show_bug.cgi?id=636695
2014-05-22 09:09:55 -04:00
Cosimo Cecchi
a3cbcc6451 textview: always use interior focus 2014-05-09 11:02:42 -07:00
Sébastien Wilmet
d69d57afa7 textview: inline a function
gtk_text_view_move_cursor_internal() was exactly the same as
gtk_text_view_move_cursor(), and was called only in the latter function.

https://bugzilla.gnome.org/show_bug.cgi?id=727908
2014-04-13 14:04:11 -07:00
Benjamin Otte
6e1fc27528 textview: Call map/unmap functions on pixel cache
https://bugzilla.gnome.org/show_bug.cgi?id=726475
2014-04-10 00:16:54 +02:00
Bastien Nocera
f71f7215ab all: Name more idles and timeouts
Following up from 438cd857c4,
name more timeouts and idles.

The original grep was missing checking for gdk_threads_add_*()
functions (at least for some of the files).

https://bugzilla.gnome.org/show_bug.cgi?id=726870
2014-03-26 20:09:30 -04:00
Carlos Garnacho
3693045566 textview: Mind the lateral windows when setting handles/popovers positions
If a textview had lateral windows that might displace the text window, the
handles and popovers would appear displaced. Those lateral windows aren't
affected by RTL/LTR settings, so just checking for left/top is ok here.
2014-03-17 18:26:41 +01:00
Carlos Garnacho
a86ca5c561 textview: Postpone text handles creation until when needed
This is only necessary for touch devices, so unnecessary on many setups.
2014-03-10 23:07:21 +01:00
Carlos Garnacho
7b0a5674e2 textview: Postpone magnifier creation until when needed
This is only necessary for touch devices, so unlikely on many setups.
2014-03-10 23:07:21 +01:00
William Jon McCann
469d333aa2 docs: use Returns: consistently
Instead of Return value:
2014-02-19 18:56:05 -05:00
Matthias Clasen
c779b42476 Docs: use // for comments in examples
Without sgml mode, we can't escape /* as /* anymore,
so just switch to // for comments in examples.
2014-02-14 23:34:22 -05:00
William Jon McCann
326da2da58 docs: don't use <anchor> 2014-02-07 15:40:52 -05:00
William Jon McCann
cb6483d382 docs: use apostrophe in *'d 2014-02-07 13:39:53 -05:00
William Jon McCann
e34bd4137d docs: use apostrophes in *n't 2014-02-07 13:32:47 -05:00
William Jon McCann
7a208fbbf3 docs: use proper apostrophe
https://wiki.gnome.org/Design/OS/Typography
2014-02-07 13:06:10 -05:00
William Jon McCann
0ce016650b docs: Use markup for links 2014-02-07 09:42:12 -05:00
William Jon McCann
2a45418b67 docs: use proper quotes 2014-02-05 15:08:42 -05:00
William Jon McCann
a22358c0c0 docs: use ` instead of <literal> 2014-02-04 18:24:29 -05:00
Matthias Clasen
30cc1512e6 Docs: Use markdown for lists
This greatly reduces the amount of xml in the docs.
2014-02-02 01:07:39 -05:00
William Jon McCann
4c8bd8e7cf docs: Identify examples that are C code
https://bugzilla.gnome.org/show_bug.cgi?id=723119
2014-01-29 12:45:49 -05:00
William Jon McCann
2d003553e8 docs: don't use <emphasis>
It is a little heavy handed. The text can speak for itself.
2014-01-28 02:02:05 -05:00
Carlos Garnacho
5bb259bc6a textview: Set GTK_STYLE_CLASS_OSD on text selection popovers 2014-01-22 17:10:06 +01:00
Carlos Garnacho
1d495cbafd popover: Add a "modal" boolean property to GtkPopover
This property is TRUE by default, when a popover is modal, it
will automatically set a GTK+ grab on the popover, and grab
the keyboard focus into the popover.
2014-01-22 17:10:06 +01:00
Carlos Garnacho
4a8a2286e1 texthandle: Remove relative_to API
It's unused now, GtkTextHandle uses widget coordinates.
2014-01-22 17:10:05 +01:00
Carlos Garnacho
d7acd29421 textview: Set use-underline in popover GtkToolButtons 2014-01-22 17:10:05 +01:00
Carlos Garnacho
3e6462c71b textview: Use GtkMagnifier on touch selection
The magnifier renders the area covered by the finger, making it easier to follow
the text being selected.
2014-01-22 17:10:05 +01:00
Carlos Garnacho
caeb896096 Introduce GtkPopover
Now that the GtkBubbleWindow object has been cleaned up and made
more generic, rename it as GtkPopover and make it public.
2014-01-22 17:10:04 +01:00
Carlos Garnacho
1813c8391c textview: Avoid bubblewindow popup/popdown API
Besides setting all positioning properties at once, popup() would just
show the widget, so do that directly after just updating the position.
2014-01-22 17:10:04 +01:00
Carlos Garnacho
923da6a8b8 bubblewindow: Make it relative to GtkWidget coordinates
GdkWindows are gone now from the API, the pointed_to rectangle
is from now on relative to the widget allocation. GtkTextView
and GtkEntry were updated to adapt to this change.
2014-01-22 17:10:04 +01:00
Alexander Larsson
664fe89f6e GtkTextView: Fix scrolling of added children
The behaviour of gtk_text_view_add_child_in_window() used to be
quite broken. It scrolled with the window during scrolling, then
jumped to the absolute position when the widget resized. Furthermore,
in 3.10 we broke the first feature, making it always be fixed.

The "proper" way to handle this is to always follow scrolling. This
is what the only user so far (gedit) wants, and if you want some
kind of overlay you should use GtkOverlay instead.

So, this changes the behaviour to something that is internally consistent
and works. I.e. all added widgets scroll with the textview as needed.

https://bugzilla.gnome.org/show_bug.cgi?id=711826
2014-01-10 12:08:52 +01:00
Bastien Nocera
438cd857c4 all: Add names to timeouts
Add names to every timeout we setup, so it's easier to track their
usage, and debug possible misbehaviour.

https://bugzilla.gnome.org/show_bug.cgi?id=710651
2013-10-23 13:31:18 +02:00
Alexander Larsson
79e5069dff GtkTextView: Fix horizontal scrolling
We didn't properly invalidate when scrolling horizontally.

https://bugzilla.gnome.org/show_bug.cgi?id=708019
2013-10-02 16:23:41 +02:00
Alexander Larsson
1ac13435b7 GtkTextView: Fix regression in GtkSourceView drawing
GtkSourceView draws before chaining upo to GtkTextView and assumes
that this will be visible, but the pixelcache will just overdraw
that with background.

So, we stop drawing the background to the pixel cache and instead
make it an CAIRO_CONTENT_COLOR_ALPHA surface to make the previously
drawn content see through.

This is slower, but more backwards compatible.

https://bugzilla.gnome.org/show_bug.cgi?id=708423
2013-10-02 16:23:41 +02:00
Sébastien Wilmet
f75aa5fdb4 GtkTextView: add create_buffer virtual method pointer
This allows subclasses of GtkTextView that require a corresponding
subclass of GtkTextBuffer to automatically do the right thing when
constructed with a NULL buffer. An example of this is GtkSourceView
which requires a GtkSourceBuffer.

https://bugzilla.gnome.org/show_bug.cgi?id=708584
2013-09-26 18:36:20 +02:00
Christian Hergert
9a45712ad6 textview: use pixelcache rendered area to inform invalidation region.
Use the pixelcache rendered area to inform what part of the cache should
be invalidated upon changes to the underlying textlayout.

By rendering the background to the pixelcache, we can avoid the need to
use RGBA content.

Also, we're using the pixel cache on the text windows bin_window (see
gtk_text_view_get_window) so we need to register the invalidation handler
on that, otherwise the region passed to the invalidate handler will get
clipped to the visible region.

https://bugzilla.gnome.org/show_bug.cgi?id=707244
2013-09-09 10:47:30 +02:00
Christian Hergert
0eb8479256 textview: only set invalidate handler for text window. 2013-09-06 15:57:22 -07:00
Paolo Borelli
fa3a0963ee textview: Use guint since we specify ": 1" 2013-09-01 12:16:27 +02:00
Alexander Larsson
de1f551271 GtkTextView: Use *some* extra size for horizontal scrolling
Horizontal scrolling is unusual, but specifying some extra offscreen
space for it in free in the normal case where the viewport is the
same width as the canvas anyway, so lets do it.
2013-08-26 21:17:45 +02:00
Christian Hergert
d96882bc16 textview: use pixelcache to indirectly renderer to widget.
This patch uses GtkPixelCache to render the contents of the widget,
and typically a bit more, to an offscreen surface. The pixel cache in
turn manages rendering to the actual surface for the widget.

The current strategy for the size to render is the size of the widget
plus half the height.

https://bugzilla.gnome.org/show_bug.cgi?id=701125
2013-08-26 21:17:45 +02:00
Matthias Clasen
624ec0fb7d Add a style class for context menus
Attached widgets inherit from the style of the widget they are
attached to. This can sometimes have unintended consequences,
like a context menu in the main view of gedit inheriting the font
that is configured for documents, or the context menu of the preview
in the font chooser coming up with humongous font size.

To fix this problem, we introduce a context menu style class
and use it for all menus that are used like that. The theme
can then set a font for this style class.

https://bugzilla.gnome.org/show_bug.cgi?id=697127
2013-08-18 13:46:48 -04:00
Matthias Clasen
f8412eca34 Revert "Deprecate and ignore the cursor blink settings"
This reverts commit b2e666bf8f.

We need to keep cursor blinking configurable for accessibility
reasons.

https://bugzilla.gnome.org/show_bug.cgi?id=704134

Conflicts:
	gdk/win32/gdkproperty-win32.c
	gdk/x11/gdksettings.c
	gtk/gtksettings.c
	gtk/gtktextview.c
2013-08-16 22:45:13 -04:00
Jasper St. Pierre
030b62d122 gtkdnd: Introduce a new API for more accurate drag origin data
When trying to drag, we currently the position of the first motion
event to determine where the drag came from. This might be alright
in the case of the old animation, but the data will be inaccurate
if the user has moved the pointer quite a bit since pressing the
cursor to start dragging. While we could monkey patch the GdkEvent
at the widget layer, this is unintuitive and strange.

Add a new API that takes a set of pointer coordinates describing
the origin of the drag. Additionally, adapt most widgets to use
it and use it with correct coordinates.

https://bugzilla.gnome.org/show_bug.cgi?id=705605
2013-08-14 07:12:52 -04:00
Matthias Clasen
2f1fa7cdc3 Drop some unnecessary includes
Drop includes of deprecated headers where they are
no longer needed.
2013-07-19 22:32:23 -04:00
Matthias Clasen
0aa57d26b5 Move wholly deprecated classes to gtk/deprecated/
We've recently a number of classes wholly. For these cases,
move the headers and sources to gtk/deprecated/ and adjust
Makefiles and includes accordingly.

Affected classes:
GtkAction
GtkActionGroup
GtkActivatable
GtkIconFactory
GtkImageMenuItem
GtkRadioAction
GtkRecentAction
GtkStock
GtkToggleAction
GtkUIManager
2013-07-19 21:39:47 -04:00
Emmanuele Bassi
0899ef7cc9 gtk: Use new macros for defining private data
https://bugzilla.gnome.org/show_bug.cgi?id=702996
2013-07-09 09:30:02 +01:00
William Jon McCann
b2e666bf8f Deprecate and ignore the cursor blink settings
And hardcode them to reasonable values.
2013-06-26 12:32:31 -04:00
William Jon McCann
02c793f24a Start migrating internals away from GtkStock 2013-06-24 22:20:49 -04:00
Matthias Clasen
27a15d9a7d GtkTextView: Remove the Unicode and input method menus
Submenus in the context menu are not great, and these two
in particular are not something we want to have there.
2013-06-07 18:13:20 -04:00
Sébastien Wilmet
6b50045f90 Doc: various small fixes
https://bugzilla.gnome.org/show_bug.cgi?id=700007
2013-05-12 18:09:28 +02:00
Giovanni Campagna
ca2368dba9 GtkTextView: don't popdown a bubble if we don't have one
This causes a segfault.

https://bugzilla.gnome.org/show_bug.cgi?id=695304
2013-03-06 17:08:48 +01:00
Matthias Clasen
e1edc998a2 Rename property to be more neutral
Don't put toolbar in the name of the property - we may use
a different container down the road, and then this name
would be misleading.
2013-03-05 16:48:01 -05:00
Matthias Clasen
3c04597306 Really keep GtkBubbleWindow private
_-prefix the symbols to keep them from leaking out.
Also, un-doc-commentize the sources.
2013-03-05 16:48:01 -05:00
Matthias Clasen
7c2a752b37 Small documentation tweak 2013-03-05 16:48:01 -05:00
Matthias Clasen
190dcfe050 Popdown the bubble window when text view is scrolled 2013-03-05 16:48:01 -05:00
Matthias Clasen
88623b98a7 Allow to populate bubbles with extra content
We do this by making the ::populate-popup signals a little more
flexible. They used to just accept a GtkMenu as argument, now
they can take a menu or a toolbar. To not break the expectations
of existing callbacks, we only emit ::populate-popup with a toolbar
if the :populate-toolbar property is TRUE.
2013-03-05 16:48:00 -05:00
Matthias Clasen
bb3c56abe2 Do without GtkSelectionWindow
Just populate a toolbar directly, in GtkEntry and GtkTextView.
2013-03-05 16:48:00 -05:00
Carlos Garnacho
ceeed09d07 Made GtkBubble/SelectionWindow private at the moment 2013-03-05 16:48:00 -05:00
Carlos Garnacho
0ba92bc26d Use gdk_threads_add_timeout to popup the selection window
Second granularity may bite us back there
2013-03-05 16:47:59 -05:00
Carlos Garnacho
320613c439 textview: Use GtkSelectionWindow for touch text selection
This enables touch devices to manipulate the text selection
2013-03-05 16:47:59 -05:00
Carlos Garnacho
17d3775555 Ensure the insertion handle stays on fake events (eg from IM)
Don't set handles mode to none if the event has send_event set.
For consistency with GtkEntry, also make GtkTextView keep the
handle mode on buffer changes.
2013-03-05 16:47:58 -05:00
Alexander Larsson
b5ee44b419 TextView: Properly render background
We always need to render the background, as the window
background is not always set (i.e. during gtk_widget_draw()) or
when its partially visible.

https://bugzilla.gnome.org/show_bug.cgi?id=694925
2013-03-01 12:50:20 +01:00
Alexander Larsson
3d4cd4db3e Add gtk_widget_(un)register_window
This replaces the previously hardcoded calls to gdk_window_set_user_data,
and also lets us track which windows are a part of a widget. Old code
should continue working as is, but new features that require the
windows may not work perfectly.

We need this for the transparent widget support to work, as we need
to specially mark the windows of child widgets.

https://bugzilla.gnome.org/show_bug.cgi?id=687842
2013-02-07 11:11:37 +01:00
Matthias Clasen
edd1c66041 Make GtkTextView deal better with !can_focus
This was pointed out in
https://bugzilla.gnome.org/show_bug.cgi?id=693050
2013-02-03 15:44:41 -05:00
Matthias Clasen
e4b5e94eb9 Make accessible implementations public
This commit exposes the get_type() functions and standard
headers for accessible implementations. This makes it possible
to derive from the GTK accessible implementations without
GType magic tricks. This is necessary, because we require the
a11y type hierarchy to be parallel to the widget type hierarchy.
So, if you derive a widget and need to adjust its a11y implementation,
you have to be able to derive its accessible implementation.

This commit probably exposes more than is absolutely necessary,
it also exposes accessibles of widgets that are unlikely candidates
for deriving from.
2012-12-27 11:23:22 -05:00
Cosimo Cecchi
b855e91f7a build: fix some GCC warnings 2012-12-07 11:35:06 -05:00
Alexander Larsson
fd964ca178 textview: Only clear the layout in style_update if the font actually changes 2012-12-06 21:16:19 +01:00
Benjamin Otte
055b5d83d5 gtk: Use gtk_style_context_get()
... instead of soon-to-be-deprecated gtk_style_context_get_font().
2012-12-06 02:57:18 +01:00
Matthias Clasen
8c3a668d52 Add a way to test touch features
The GTK_TEST_TOUCHSCREEN envvar is now checked in entries
and textviews to allow testing of text handles with other
kinds of devices.
2012-09-03 00:19:46 -04:00
Carlos Garnacho
5bda3a001d Implement touch text selection in GtkTextView
GtkTextHandle is used to indicate both the cursor position
and the selection bound, dragging the handles will modify
the selection and scroll if necessary.

Backwards text selection is also blocked for touch devices,
so the handles don't get inverted positions and possibly
obscure portions of the selected text.
2012-09-03 00:19:46 -04:00
Matthias Clasen
0cb56312b9 Trivial: Fix a whitespace messup
Pointed out by Carlos Garnacho in bug 651244.
2012-08-25 14:24:20 -04:00
Cosimo Cecchi
4e9f4fbc77 textview: fix a typo in method gtk-doc annotation
This was causing a warning from the introspection scanner.
2012-08-21 11:14:46 +02:00
Matthias Clasen
0101a735a3 Add documentation
Document the new API and properties, and their interaction with
existing properties.

https://bugzilla.gnome.org/show_bug.cgi?id=651244
2012-08-20 18:54:22 -04:00
Matthias Clasen
7d1c1a8d20 GtkTextView: Add input purpose and hints
Add input-purpose and input-hints properties and pass these through
to the GtkIMContext.

https://bugzilla.gnome.org/show_bug.cgi?id=651244
2012-08-20 18:54:22 -04:00
Bastien Nocera
c1f01eb929 Add support for disabling middle click paste
Adds a gtk-enable-primary-paste setting that is backed by
and X setting, and make GtkEntry and GtkTextView respect it.

https://bugzilla.gnome.org/show_bug.cgi?id=665243
2012-05-03 21:59:54 -04:00
Benjamin Otte
3610ef90c3 Revert part of "textview: Remove extra magic for drawing children"
This partially reverts commit df37446f9b.
The commit changed API that was public (or at least semi-public) and
it's not worth changing that.

The original bug should still be fixed.

https://bugzilla.gnome.org/show_bug.cgi?id=673839
2012-04-10 16:21:07 +02:00
Benjamin Otte
df37446f9b textview: Remove extra magic for drawing children
Instead, just draw the children. The cairo code will keep track of
things, so there's no need to track things.
Also, the old code was doing it wrong.

https://bugzilla.gnome.org/show_bug.cgi?id=672544
2012-04-07 13:01:25 +02:00
Benjamin Otte
917ca6a802 gtk: Don't call gdk_window_process_updates() when scrolling
This can cause lagging when scrolling as it causes us to repaint
on every scroll event. This wasn't historically a great problem,
but with smooth scrolling we get a lot more events, so this
now creates visible lagging on slower machines.
2012-04-05 15:48:51 +02:00
Daniel Stone
134ef22a4e Add smooth-scroll to GtkTextView event mask
Without any extra supporting code, just adding GTK_SMOOTH_SCROLL_MASK to
the event mask for GtkTextView makes GEdit do the right thing and scroll
smoothly.  Lovely.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>

https://bugzilla.gnome.org/show_bug.cgi?id=671488
2012-03-06 21:45:09 +01:00
Javier Jardón
9d0febc9a6 Change FSF Address 2012-02-27 17:06:11 +00:00