Commit Graph

64 Commits

Author SHA1 Message Date
Benjamin Otte
632fab0ca7 stylecontext: Get rid of gtk_style_context_get()
... and replace all the calls to it with
gtk_style_context_peek_property().

All the calls are hacks that need to go away btw.
2020-01-28 02:58:02 +01:00
Matthias Clasen
112aed590f Remove builtin icons altogether
This removes support for GtkCssImageBuiltin and
GtkCssImageBuiltinType from everywhere.
2020-01-10 14:34:56 -05:00
Christian Hergert
bd26cce812 gtk: rely on default marshallers
Similar to previous removals of g_cclosure_marshal_VOID__VOID we can remove
other marshallers for which are a simple G_TYPE_NONE with single parameter.
In those cases, GLib will setup both a c_marshaller and va_marshaller for
us. Before this commit, we would not get a va_marshaller because the
c_marshaller is set.

Related to GNOME/Initiatives#10
2019-05-30 20:56:50 -07:00
Matthias Clasen
5b78a3048f gizmo: Add a contains_func
Let GtkGizmo override the contains() implementation.
Update all callers to pass NULL for the contains_func.
2019-04-07 15:47:24 +00:00
Matthias Clasen
3ebf19b783 text handle: Stop using ::hierarchy-changed
Use notify::root instead.
2019-02-23 09:43:57 -05:00
Timm Bäder
20429f4764 Remove :active state handling on widgets 2019-01-29 07:19:54 +01:00
Timm Bäder
c49cc977fa gizmo: return void from snapshot func
This boolean return was from the old gadget code and we weren't using it
in the new gizmo code.
2019-01-18 19:43:50 +01:00
Carlos Garnacho
b3e91b7111 gtktexthandle: Update to gtk4 rendering/input
GtkTextHandle was neglected by whoever removed the ::draw signal,
leaving it entirely broken. Update to using GtkGizmo so we can
implement snapshot of text handles.

Input has received a revamp too, handling is done through a
GtkGestureDrag and coordinate calculations simplified by storing
the delta to the hotspot on ::begin instead of ::update, as this
value is constant throughout the gesture. Widget state management
on crossing events happens implicitly, so no longer needs to be
done here.

Last but not least, CSS has also been updated so handles are
rendered at the correct size and proportion, and with the padding
that code expects of it.
2018-06-21 12:54:03 +02:00
Matthias Clasen
506b436f09 Revert "text handler: Stop using GtkWidget::event"
This reverts commit 74f563b501.

Turns out we'll keep ::event, so this was misguided.
2018-01-02 18:13:34 -05:00
Matthias Clasen
74f563b501 text handler: Stop using GtkWidget::event
This signal is going away.
2017-12-30 22:38:14 -05:00
Matthias Clasen
9c477951cb text handle: Use GdkEvent API 2017-09-19 18:39:03 +02:00
Carlos Garnacho
35301530bb texthandle: Update to using GdkEvent API 2017-09-19 18:39:02 +02:00
Benjamin Otte
18c086a46c texthandle: Don't use GtkEventBox 2017-08-02 16:58:47 +01:00
Timm Bäder
b71f644cf5 eventbox: Remove visible-window property
The GdkWindow that was supposed to back it is gone.
2017-07-27 21:53:42 +02:00
Carlos Garnacho
a72404dd5a gtk: Mass delete all GtkWidget event mask API
We now rely on toplevels receiving and forwarding all the events
the windowing should be able to handle. Event masks are no longer a
way to determine whether an event is deliverable ot a widget.

Events will always be delivered in the three captured/target/bubbled
phases, widgets can now just attach GtkEventControllers and let those
handle the events.
2017-05-25 16:25:58 +02:00
Matthias Clasen
0e37d67393 text handle: Don't leak adjustments
This can happen if the weak pointer is triggered before the
adjustments are unset. Pointed out in

https://bugzilla.gnome.org/show_bug.cgi?id=774790
2016-11-23 13:57:03 -05:00
Benjamin Otte
1518fe0a8f API: stylecontext: Remove state argument from getters
The argument must always be the current state.
2016-10-16 18:18:58 +02:00
Timm Bäder
9f5baf9130 GtkTextHandle: Use min-width/min-height
instead of GtkWidget's text-handle-width/text-handle-height style
properties
2016-10-16 18:17:21 +02:00
Carlos Garnacho
60d7f4376e GtkTextHandle: Look up for the first child of a scrolled window found
Text handles use to connect to the first GtkScrollable up the hierarchy
so they can be repositioned when scrolling. It makes more sense to look
up the first child of a GtkScrolledWindow, it must be an scrollable too,
and will be the scrollable that can actually change the position of the
text handles.

https://bugzilla.gnome.org/show_bug.cgi?id=761676
2016-02-24 17:58:19 +01:00
Matthias Clasen
ea51db1feb text handle: Port to CSS nodes
Use cursor-handle as the element name for the CSS node that
is used to render text the selection handles.
2015-11-09 23:33:54 -05:00
Carlos Garnacho
4f61fd09c5 texthandle: Request raising of text handle popovers.
https://bugzilla.gnome.org/show_bug.cgi?id=756670
2015-11-03 07:25:33 -05:00
Carlos Garnacho
8147f12eca texthandle: Ensure handles are invalidated on mode changes
Otherwise the "cursor" handle stays with "cursor" appearance instead of
"selection end" when a text selection is started.
2015-10-14 18:44:34 +02:00
Carlos Garnacho
14dde08e33 texthandle: small refactor
These long enums are used too often, shorten things a bit with temp vars.
2015-10-14 18:44:34 +02:00
Carlos Garnacho
cfaa421433 texthandle: Fix Y positioning of text handles
It is assumed that border.top is the same than pointing_to.height (which
equals the strong cursor position), which is not since some time ago.

The border calculation has been move on top too, it is now used in the
Y position one, and doesn't depend on anything we calculate later.
2015-10-14 18:44:34 +02:00
Carlos Garnacho
73bf16b3b0 texthandle: Fix handle dragging on wayland
Text handles are subsurfaces on wayland, so sort of their own toplevel.
This made gtk_widget_translate_coordinates() to bail out there, resulting
in text handles being mispositioned and jumpy. To fix this, translate to
toplevel GtkWindow coordinates manually, and translate coordinates from
there.

Along the way, the coordinates reported in ::handle-dragged have been
fixed so there is no small jumps in either axis (most noticeable in the
X axis when you started dragging, and in the Y axis when moving between
lines of different heights.
2015-10-14 18:44:34 +02:00
Carlos Garnacho
7f57f63eba gtkwindow: Only allow unrestricted positioning to text handle popovers
This behavior has been made optional on add_popover() time, text handles
will keep being able to overflow the window, in order to allow text
selection on views too close to the window edge.

Regular GtkPopovers are reinstaurated to the previous size positioning
logic though, that is, limited by the visible area of the window.
2015-07-06 16:39:06 +02:00
Carlos Garnacho
15bb9acc8a texthandle: Avoid double rendering of background/frame
gtk_render_handle() already renders background/frame itself, avoid
doing this twice.
2015-06-17 15:58:55 +02:00
Carlos Garnacho
76dc8aced5 window: Add concept of popover "parent"
This will be the widget that the popover relates to (::pointing-to in
GtkPopover, ::parent in GtkTextHandle).

Additional API to check the popover/parent relationship between widgets
has been added, which will be useful wherever this is necessary in a
generic manner.

https://bugzilla.gnome.org/show_bug.cgi?id=750993
2015-06-17 15:56:42 +02:00
Ting-Wei Lan
d8657a8156 Fix return value error in _gtk_text_handle_set_direction
https://bugzilla.gnome.org/show_bug.cgi?id=750888
2015-06-13 23:00:21 +08:00
Carlos Garnacho
5a499ef3e1 texthandle: Remove knowledge about window borders
We need to expand beyond these if necessary, so don't artificially
limit things here.
2015-06-11 17:14:23 +02:00
Carlos Garnacho
3a7689bae0 texthandle: Handle ltr/rtl positioning
This setting is per handle, as is dependent on the selected text, rather
than the locale.
2015-06-11 17:14:23 +02:00
Carlos Garnacho
fc6871b43b texthandles: Move start handle to bottom
The asset is going to change to point upwards, so physically place
the handle below the text position.

https://bugzilla.gnome.org/show_bug.cgi?id=750692
2015-06-11 17:12:06 +02:00
Matthias Clasen
ecebdfc58c GtkTextHandle: Improve handle positioning
When we are close the window edge, we need to shrink the 'invisible
border' around the handle to avoid mispositioning it. A fiddly
calculation, but it works.
2015-06-09 21:19:17 -04:00
Matthias Clasen
0b3835a93f GtkTextHandle: position handles properly
Move the handles so that the asymmetric assets align with the
start/end of the selection.
2015-06-09 17:06:27 -04:00
Matthias Clasen
805fa78221 GtkTextHandle: add a drag-started signal
This will be used to discriminate drags from taps.
2015-06-08 06:55:21 -04:00
Carlos Garnacho
1e8be1c446 texthandle: Set prelight state on the pointer-interacted handle
This will be useful with the theming changes to come.

https://bugzilla.gnome.org/show_bug.cgi?id=750396
2015-06-05 08:57:43 -04:00
Carlos Garnacho
88d88591d2 texthandle: Allow setting individual states, and separately to handles
Now each handle gets its individual current state, and we can accumulate
more than one state on these.

https://bugzilla.gnome.org/show_bug.cgi?id=750396
2015-06-05 08:57:43 -04:00
Carlos Garnacho
79f8db1c0d texthandle: Use active state when handles are being dragged
The active state flags is set on both handles when this happens.
2014-12-18 21:20:17 +01:00
Carlos Garnacho
e0b9330880 texthandle: Use the handle widget style context for rendering
Using the parent widget context is a leftover of the pre-popover
implementation, which used GdkWindows directly. This will make the context
reflect widget state, at the expense of changing the selector paths
that used to match the handles.
2014-12-18 21:20:17 +01:00
Matthias Clasen
d4e8a501a0 GtkTextHandle: Better draw() implementation
Conceptually, text handles are boxes, whose content is a 'handle',
so draw background, frame and handle. With this, and the previous
commit, the cursor-handle theming in Adwaita now works as intended.
2014-07-13 13:58:16 -04:00
Carlos Garnacho
ca1510177c texthandle: Mind the invisible area when moving the handle
The handle is still centered horizontally, but the extra vertical
space wasn't taken into account, leading to misplacing the dragging
point (and the handle) during motion events.
2014-05-23 19:54:33 +02:00
Carlos Garnacho
2ba89256f4 texthandle: Make a bigger hit area around texthandles
The hit area now extends to all sides around the handle, instead
of just towards where the text is. This makes it easier to grab
handles once shown.
2014-05-23 19:54:32 +02:00
Matthias Clasen
479babf339 GtkTextHandle: Deal with parent_scrollable going away
Use a weak reference to notice when parent_scrollable is
going away.

https://bugzilla.gnome.org/show_bug.cgi?id=724392
2014-02-19 00:24:30 -05:00
Carlos Garnacho
9fe26a93eb texthandle: Update child visibility of handles within scrollables
If the rect a handle points to starts falling outside of the parent
scrollable allocation, the handle will be automatically hidden, and
shown again when the rectangle is visible too.
2014-01-22 17:10:07 +01:00
Carlos Garnacho
328404795b texthandle: Track parent scrollable adjustments
This makes sure texthandles follow the parent if it is contained within a
GtkScrollable.
2014-01-22 17:10:07 +01:00
Carlos Garnacho
360d5f04c0 texthandle: ensure handles are recreated on parent hierarchy changes
This ensures the handles come out right even if the parent widget is
reparented to a different toplevel.
2014-01-22 17:10:07 +01:00
Carlos Garnacho
834ad653ea texthandle: Use GtkWindow private popover API. 2014-01-22 17:10:07 +01:00
Carlos Garnacho
31042fe95f popover: Fix memory management of popovers
Popovers are strange in the sense that they aren't attached to a
parent directly, they rely on the relative_to widget so the toplevel
is shared, and when they have a parent, it is the toplevel itself,
not relative_to. This also means that there are conditions where the
popover loses it's parent, so they must survive unparenting.

The previous code would be floating the last reference as soon as the
parent is gone, but it was non-obvious who'd own that reference. So
fix this situation by granting the ownership of popovers to their
relative_to widget, an extra reference may be held by the toplevel
when the popover has a parent, but the popover object will be
guaranteed to be alive as long as the parent lives.

This way, memory management of popovers is as hidden from the user
as regular widgets within containers are, users are free to call
gtk_widget_destroy() on a popover, but it'd eventually become
destructed when relative_to is.
2014-01-22 17:10:06 +01:00
Carlos Garnacho
bd5490ad62 texthandle: Fix arguments in ::style-updated callback 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