Commit Graph

39430 Commits

Author SHA1 Message Date
Garrett Regier
8b228e7471 builder: Use a flexible array for attributes in precompile 2021-12-13 23:44:02 -05:00
Garrett Regier
4ce07f41ca builder: Reduce memory usage in precompile
Split the Element and Text nodes into separate structures.
2021-12-13 23:44:02 -05:00
Garrett Regier
1bfd0e5e38 builder: Use a GQueue in precompile
This avoids g_list_last() and
embeds the GList link in the RecordDataTree.
2021-12-13 23:44:02 -05:00
Garrett Regier
b962d37f79 builder: Use a reasonable default string size in precompile 2021-12-13 23:44:02 -05:00
Garrett Regier
c6ecf02a07 builder: Embed text length in precompile 2021-12-13 23:44:02 -05:00
Garrett Regier
8b7d4b423c builder: Combine attribute name and value allocations 2021-12-13 23:44:02 -05:00
Garrett Regier
83dc126565 builder: Use a string chunk for precompile
Also use an explicit length and avoid g_strndup().
2021-12-13 23:44:02 -05:00
Garrett Regier
f2d3d7e710 builder: Avoid double string lookup in precompile 2021-12-13 23:44:02 -05:00
Matthias Clasen
f991428cb9 builder: Use GMarkup properly
We must call end_parse to ensure we get errors
for incomplete documents.
2021-12-13 23:42:47 -05:00
Chun-wei Fan
e2b4108377 Revert "gtk/meson.build: Fix linking on Visual Studio 2013"
We now require a Pango version that requires Visual Studio 2015 or later to
build, and non-UCRT-based (VS2013) binaries may not bode well with
UCRT-based binaries (VS2015+). Drop the support for VS2013 as a result.

This reverts commit e208e0e07886248d4d86118aa5591c9882f0ed5c.
2021-12-14 10:29:28 +08:00
Benjamin Otte
02c484e844 label: Fix docs 2021-12-13 18:23:32 +01:00
Benjamin Otte
5face79cd0 label: word-char wrapping should word-wrap for natural size
Testcase added

Fixes #4535
2021-12-13 14:49:39 +01:00
Matthias Clasen
da6f86bd79 colorbutton: No nested drag sources, please
This is causing trouble on X11.
2021-12-12 22:23:31 -05:00
Matthias Clasen
42fd499af4 dragicon: Make color icons work in X11
We need to disable the DND support in
GtkColorSwatch completely for this to work
in X11.
2021-12-12 22:09:28 -05:00
Matthias Clasen
de5b88477a colorswatch: Make drag source optional
When using a colorswatch as a drag icon,
this can get in the way, so make it optional.
2021-12-12 22:09:16 -05:00
Matthias Clasen
df025fcb88 dragicon: Provide default icons for more types
Provide default icons for paintables and files.
This is easy to do, and makes sense.

fixup drag icon
2021-12-12 21:29:36 -05:00
Matthias Clasen
bbb1404bd3 dragicon: No events, please
We run into trouble on X11 if the widgets
in the drag icon have drop targets attached.
Prevent this by suppressing event delivery
to drag icons outright.
2021-12-12 21:28:34 -05:00
Matthias Clasen
dbe5e57b8e inspector: Show more datatypes for the clipboard
It is easy enough to show colors, files and pixbufs.
2021-12-12 18:36:58 -05:00
Matthias Clasen
9a872f059f droptarget: Improve the docs
Add the signal connection to the example.
2021-12-12 16:27:36 -05:00
Matthias Clasen
e72df9cd5f docs: Small improvement
I could not find the attributes of the <binding>
element mentioned anywhere in the docs.
2021-12-12 09:03:11 -05:00
Benjamin Otte
4cd0a39794 Merge branch 'wip/otte/inspector' into 'main'
inspector: Add a clipboard page

See merge request GNOME/gtk!4237
2021-12-11 22:46:30 +00:00
Benjamin Otte
600ab5ba5f inspector: Add a clipboard page
Shows all the formats supported by the clipboard (and primary clipboard)
and allows displaying them (by potentially downloading them)
2021-12-11 23:01:42 +01:00
Matthias Clasen
66910ed998 Restore the GtkTextchild abi
Move the new chars field to a private struct.

Fixes: #4531
2021-12-11 10:58:58 -05:00
Matthias Clasen
79375dd7dd Merge branch 'fix-printer-enumeration' into 'main'
Fix dialog-less printing

Closes #4439

See merge request GNOME/gtk!4215
2021-12-10 18:01:59 +00:00
Matthias Clasen
0bf87281e0 Merge branch 'missing-since-tag' into 'main'
Add a missing since tag

See merge request GNOME/gtk!4229
2021-12-10 17:15:32 +00:00
Matthias Clasen
2d062fedd9 Add a missing since tag
gtk_text_child_anchor_new_with_replacement was
recently added.
2021-12-10 11:26:46 -05:00
Matthias Clasen
c6a68f3de2 Fix dialog-less printing
We were sometimes ending printer enumeration prematurely,
and the code was confused about the meaning of found_printer.

The new setup follows these rules:
- We *only* end the search prematurely if found_printer
  is set, which indicates that we found the right printer
- We *always* call find_printer_idle exactly once, and
  make it return less than perfect matches like the
  default printer, or the first printer we found

Fixes: #4439
2021-12-10 11:26:23 -05:00
Jakub Steiner
d74e62886c selections: have unfocused state
- text selections for unfocused elements - textview, label, entry,
  spinbutton

fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/4393
2021-12-10 12:00:12 +01:00
Jakub Steiner
d8505f09eb Revert "styling: Have unfocused selections"
This reverts commit 96f63a6bf3.
2021-12-10 11:36:10 +01:00
Christian Hergert
99a8202015 macos: fix crash in imcontextquartz 2021-12-09 12:26:33 -08:00
Benjamin Otte
17c903e246 Merge branch 'fix-picture-natural-size-0' into 'main'
picture: Return natural size 0 for size 0

See merge request GNOME/gtk!4177
2021-12-08 19:33:28 +00:00
Ivan Molodetskikh
7ef54e9c53 picture: Return natural size 0 for size 0
It was returning the full natural size (same as -1) due to default value
handling in the code below.

Tests have been updated to match this output.
2021-12-08 19:20:24 +01:00
Matthias Clasen
12bb700c62 Merge branch 'wip/chergert/fix-recursive-action-muxer' into 'main'
actionmuxer: avoid duplicate and recursive work

Closes #4422, #4519, and gnome-text-editor#220

See merge request GNOME/gtk!4223
2021-12-08 10:47:40 +00:00
Christian Hergert
d1aec0c3f1 actionmuxer: avoid duplicate and recursive work
If we've already done the tracking into the parent muxer, there is no need
to do it again. This can save a great deal of recursive work when adding
items to the muxer.

This makes showing the context menu in gnome-text-editor repeatedly fast
even as spelling corrections are changed.

It is likely that this could fix #4422 as well.

Fixes #4519
Fixes https://gitlab.gnome.org/GNOME/gnome-text-editor/-/issues/220
2021-12-08 00:32:36 -08:00
Christian Hergert
00d5f72d6e menutracker: reduce allocations and signal emission
When handling action-added callbacks the code was previously using a
freeze_notify/thaw_notify in all cases. This turns out to allocate a
significant amount of memory when called a lot.

That said, it shouldn't be getting called this much but given the current
state of affairs elsewhere in GtkActionMuxer, this brought temporary
allocations down from 9MiB to 9KiB in gnome-text-editor after showing
the context menu a few times.

Related #4422
2021-12-07 22:42:04 -08:00
Benjamin Otte
ce7b0656c0 viewport: Allocate properly
Instead of allocation width for height for width for height or whatever
that code was doing, actually allocate the size we were given or the
requested size, whatever is larger.
2021-12-08 00:12:35 +01:00
Benjamin Otte
fd0d360f9b Revert "viewport: Actually report the size we're gonna allocate"
This reverts commit b8468af411.
2021-12-07 23:52:21 +01:00
Benjamin Otte
b8468af411 viewport: Actually report the size we're gonna allocate
Don't just pass on measure() calls, but actually behave in the way we
behave during size allocate.

This should improve cases where GtkScrolledWindow is used with GTK_POLICY_NEVER.
2021-12-07 21:58:42 +01:00
Benjamin Otte
9fd7e319f3 viewport: Use array for member variables
That way we can index them by orientation in future commits.
2021-12-07 21:58:42 +01:00
Benjamin Otte
b9d4da9cfe gtktypes: GTK_INVALID_LIST_POSITION should be an int
GListModel uses guint, so the macros we define for it should match that.

Related: !3738
2021-12-07 16:15:17 +01:00
Emmanuele Bassi
5bf5b58eb3 Merge branch 'gi-const' into 'main'
gtk: fix GTK_INVALID_LIST_POSITION type

See merge request GNOME/gtk!3738
2021-12-07 14:22:40 +00:00
Carlos Garnacho
ce1b970b46 gtkimcontextwayland: Set a higher IO extension priority
We want this to take precedence in the wayland platform to other
modules that might be loaded via the IO extension point. None of
those is going to bode well in this platform.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4443
2021-12-04 00:21:53 +01:00
Matthias Clasen
ceb77d6100 Merge branch 'wip/hadess/listbox-fixes' into 'main'
listbox: Explain behaviour of GtkListBoxCreateWidgetFunc

See merge request GNOME/gtk!4194
2021-12-03 23:05:13 +00:00
Matthias Clasen
02579a1333 Merge branch 'wip/chergert/inspector-im-module' into 'main'
inspector: add im-module

Closes #4512

See merge request GNOME/gtk!4214
2021-12-03 22:51:32 +00: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
Christian Hergert
6be352f446 inspector: add im-module
This adds a new row to the Global/Information section which displays the
GTK im-module that is likely to be in use unless changed by an application.
It responds to updates of GtkSettings:gtk-im-module unless the
GTK_IM_MODULE environment variable is set.

Fixes #4512
2021-12-03 12:11:25 -08:00
Matthias Clasen
4d2be2e322 Merge branch 'text-scroll-test' into 'main'
Improve scroll-to mark behavior

Closes #4325

See merge request GNOME/gtk!4208
2021-12-03 20:00:05 +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
Georg Vienna
c517e945de textchildanchor: allow to specify replacement character 2021-12-03 16:02:48 +00:00
Matthias Clasen
be949496ac Merge branch 'issue-4376' into 'main'
Update placeholder visibility when setting a buffer

Closes #4376

See merge request GNOME/gtk!4211
2021-12-02 17:38:16 +00:00
Emmanuele Bassi
b57b12fdb7 Update placeholder visibility when setting a buffer
If we set the placeholder text before setting a buffer, we end up with
both the placeholder *and* the buffer's contents visible at the same
time.

Fixes: #4376
2021-12-02 17:17:12 +00:00
Carlos Garnacho
c8d83b7a63 gesturestylus: Use GtkEventControllerEvent events to track changes
We use gtk_gesture_get_last_event() underneath at places that need to
work during ::proximity emission. Since GtkGesture only tracks events
while there are button/touch presses involved, this is not going to
bring the right result there.

Use gtk_event_controller_get_current_event() consistently inside,
which always pokes at the event being handled (which is the correct
intent here).
2021-12-02 17:06:35 +01: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
2611a996ff Merge branch 'matthiasc/for-main' into 'main'
textbuffer: Fix pasting text

Closes #4357

See merge request GNOME/gtk!4205
2021-12-01 02:59:10 +00:00
Matthias Clasen
3e7618fef7 textbuffer: Try harder to fix pasting
It turns out we can't just use the size returned
by the memory stream as-is, since it may contain
unfilled garbage at the end, which utf8 validation
will choke on. So, cut it off at the first '\0'
we find.
2021-11-30 21:42:19 -05:00
Matthias Clasen
5b1b75b055 textbuffer: Fix pasting text
The memory stolen from a memory outputstream
isn't guaranteed to be 0-terminated, so don't
make that assumption.

Fixes: #4357
2021-11-30 20:37:25 -05:00
Matthias Clasen
f1612e36ee Merge branch 'update_focus_indicators_in_popovers' into 'main'
update focus indicators in popovers

See merge request GNOME/gtk!4124
2021-12-01 01:21:32 +00: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
e0deacd236 inspector: Make dropdowns bigger
If there's enough values to warrant scrolling,
the dropdown was much too small for comfort.
2021-11-30 18:38:33 -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
Benjamin Otte
07cfdd8ca0 label: Don't set ellipsized size as natural size
Natural size should never ellipsize.

Tests added.
2021-11-30 15:10:02 +01:00
Matthias Clasen
ddd5704c92 Update references to master in the repository 2021-11-29 17:37:49 -05:00
Benjamin Otte
3ba6d2bd27 Merge branch 'wip/otte/hfw-min-size' into 'master'
window: Implement height-for-width for min size

See merge request GNOME/gtk!4183
2021-11-29 10:31:42 +00:00
Matthias Clasen
e9d8bf96e0 fontchooser: Avoid setting variations needlessly
Setting variations to their default value causes
them to show up in the serialization of the font
description - a font description has no idea about
the default values, so can't filter them out.

Avoid that.
2021-11-27 17:13:23 -05:00
Bastien Nocera
6b3a612bbc listbox: Explain behaviour of GtkListBoxCreateWidgetFunc
It might be an interesting shortcut for applications to use, but it
needs to be documented to be useful and agreed.
2021-11-25 12:33:10 +01:00
Emmanuele Bassi
c742debea8 Merge branch 'fix_typo_gesture' into 'master'
gesture: fix typo in docs

See merge request GNOME/gtk!4191
2021-11-24 19:56:42 +00:00
Alexandros Theodotou
cd60ec1576
gesture: fix typo in docs 2021-11-24 19:34:49 +00:00
Benjamin Otte
0709dc7a6a window: Add a new fancy way to compute min size
Try to compute a min size that matches the current aspect ratio.

This means that when interactively resizing, we adapt the min size to
the current window area dynamically.

And that means that we always have a min size that is large enough, but
users can interactively cause it to be small-width x large-height,
large-width x small-width or anything inbetween.
2021-11-21 18:52:42 +00:00
Benjamin Otte
15528599f4 Merge branch 'wip/otte/for-master' into 'master'
window: Always clamp to max size

See merge request GNOME/gtk!4185
2021-11-21 18:44:26 +00:00
Emmanuele Bassi
031aab3ef6 Merge branch 'ebassi/issue-4421' into 'master'
Unrealize ATContext on unroot

Closes #4421

See merge request GNOME/gtk!4136
2021-11-21 15:36:25 +00:00
Benjamin Otte
c990134e49 window: Properly distribute size between title and child
Otherwise we can end up with a window that's too small in certain corner
cases after resizing.
2021-11-21 08:19:07 +01:00
Benjamin Otte
822508f33e widget: Clear size request cache on queue_resize()
... and not later.

Otherwise future calls to sizing fucntions will reuse an outdated cache
and compute wrong values.
2021-11-21 06:08:06 +01:00
Benjamin Otte
358893aa84 window: Always clamp to max size
When computing the window size, always try to clamp to the max size.
This will shrink a window down into a sane size if it was too big
before.
2021-11-21 05:33:28 +01:00
Benjamin Otte
c025bc5098 paned: Compute the right handle size
Testcase included

Fixes #4469
2021-11-21 01:49:40 +01:00
Benjamin Otte
170bc0a8de window: properly compute desired size
Previously, the code did not expand the size properly when a default
size was already set.

Reftest included.
2021-11-21 01:31:06 +01:00
Benjamin Otte
eefb6a0dd4 sizerequest: Change critical message
Printing the affected widget leads people to assume that it is to blame
for the error. However, the widget is the object the function is being
called on, not the caller. And the caller is doing it wrong.

Usually the caller is the parent widget, so we could print that one, but
it's only usually, it can be an issue propagating from a grandparent and
it doesn't tell you from where the function is called (allocation or
measuring), so you need a debugger anyway.

So don't put anything there instead.
2021-11-20 17:05:36 +01:00
Benjamin Otte
1eb86d6394 widget: Remove a check
That consistency check is entirely outdated and just prints confusing
stuff.
2021-11-20 06:04:10 +01:00
Benjamin Otte
a0ca936e8d sizerequestcache: Increase size
This is a quickfix to avoid infinite runtime in nested boxes with
wrapped labels.

Test included
2021-11-20 06:04:10 +01:00
Benjamin Otte
de3c50a237 sizerequest: Use g_printerr() for debug messages
glib doesn't print debug messages by default anymore.
2021-11-20 06:04:10 +01:00
Benjamin Otte
244ddea0ea paned: Always query at least min size
For shrinking children, we would not make sure of this and just throw
the current size at them.
2021-11-20 06:04:10 +01:00
Benjamin Otte
6c94835f5d stack: Make sure to not under-measure children
When the stack is homogeneous in only one direction, the other direction
may produce min sizes to small for all children. Make sure to query at
least the min size for those.
2021-11-20 06:04:10 +01:00
Benjamin Otte
617566128d stack: Index the homogeneous array by orientation 2021-11-20 06:04:10 +01:00
Benjamin Otte
7bf772111c stack: Turn the homogenenous variables into an array
that way, we can index them by orientation.
2021-11-20 06:04:10 +01:00
Benjamin Otte
50e0893497 widget: force adjustment method is one size is FILL
If halign=fill, force adjustment to height-for-width.
If valign=fill, force adjustment to width-for-height.
Otherwise look at request mode.

This way we don't try to adapt the filled dimension and only adjust
the one that is not set to fill.
2021-11-20 06:04:10 +01:00
Benjamin Otte
7459d430eb widget: Don't forget margins when adjusting
This could lead to the wrong values being passed and computing invalid
sizes which would then lead to very unhappy code.

Test included.
2021-11-19 23:46:59 +01:00
Benjamin Otte
163616cc0a sizerequest: Add a critical when for_size is too small
It's not expensive to check it because we'll cache the dfault size
request anyway, and people do it wrong a lot.
As a bonus, don't do any return_if_fail(), just use the min size
instead.
2021-11-19 23:46:59 +01:00
Fred Morcos
f019e9d856 Documentation fix and whitespace cleanup
- gtk_init() does not parse command-line options anymore.
- Gitlab's  WebIDE automatically cleans up whitespace.
2021-11-19 13:21:56 +00:00
Benjamin Otte
899cb44519 label: Don't add a pixel where none should be added
When the text width is larger than the measuring width, set the min
width to that value, don't also add 1 to it.
2021-11-18 07:16:09 +00:00
Marco Melorio
d3347e64ba picture: Setting keep-aspect-ratio requires a redraw 2021-11-18 02:39:15 +01:00
Matthias Clasen
0c53b608f9 Merge branch 'bilelmoussaoui/since-annotations' into 'master'
g-i: add missing since annotations

See merge request GNOME/gtk!4154
2021-11-16 21:34:58 +00:00
Matthias Clasen
d9d220cfc9 Merge branch 'wip/carlosg/x11-wm-drags' into 'master'
gtkmain: Disable implicit grab active state on CROSSING_GRAB leave events

Closes #4416

See merge request GNOME/gtk!4162
2021-11-16 17:21:38 +00:00
Matthias Clasen
2026256823 Merge branch 'compose-cache-symlinks' into 'master'
composetable: invalidate cache based on symlink mtime too

See merge request GNOME/gtk!4163
2021-11-16 17:21:04 +00:00
Matthias Clasen
012baeb909 Merge branch 'wip/carlosg/cancelled-gestures' into 'master'
gtkwidget: Do not check event sequence state before cancelling gesture

Closes #4387

See merge request GNOME/gtk!4160
2021-11-16 17:19:55 +00:00
Emmanuele Bassi
c4b2fe6ee5 docs: Add blurb for GtkEditableProperties. 2021-11-16 13:50:52 +00:00
Emmanuele Bassi
cea320af24 docs: Fix description for CellRendererAccelMode
Link to the property, instead of copy-pasting its description.
2021-11-16 13:41:52 +00:00
Emmanuele Bassi
a5bf0591ee docs: Fix link in GtkSymbolicColor description 2021-11-16 13:37:33 +00:00
Naïm Favier
22f5236943
composetable: invalidate cache based on symlink mtime too
When the compose file is a symbolic link, take the link itself's
modification time into account (in addition to its target's) in
determining whether to invalidate the compose cache.

This is useful e.g. on NixOS systems where the compose file might point
to a store path with an irrelevant modification time, and we want the
cache to expire when the symlink itself changes.
2021-11-16 12:53:38 +01:00
Carlos Garnacho
f84bcfbb97 gtkmain: Disable implicit grab active state on CROSSING_GRAB leave events
This grab-induced crossing event may come from outer means while there are
buttons pressed (e.g. WM window drags/resizes in X11), the implicit active
state should be undone in that situation.

Also, separate the handling of GDK_LEAVE_NOTIFY, as it's fundamentally
different from GDK_TOUCH_END/CANCEL handling.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4416
2021-11-16 10:58:03 +01:00
Carlos Garnacho
f36ee67226 gtkgesture: Do not cancel gesture when setting DENIED state
Touchpoint state and tracking are tangential, this is mixing up both.
This change was added in the fixes for
https://gitlab.gnome.org/GNOME/gtk/-/issues/3016 but is now unnecessary.
2021-11-16 00:47:57 +01:00
Carlos Garnacho
615b8fc569 gtkwidget: Do not check event sequence state before cancelling gesture
The sequence should be cancelled from the gesture despite its current state.
Also, there was a piece of pointer emulation that was not dropped here,
maybe breaking things further for the pointer emulated touchpoint.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4387
2021-11-16 00:41:17 +01:00
Emmanuele Bassi
ff3bb7f671 docs: Annotate Label.get_selection_bounds() out arguments
They are optional, and should be marked as such.

See issue: #4452
2021-11-15 15:35:13 +00:00
Bilal Elmoussaoui
40c08954db g-i: add missing since annotations 2021-11-13 17:50:53 +01:00
Benjamin Otte
7f7809f523 label: Don't do more work than necessary
We only want to determine the size pixel-exact, not pango-unit-exact, so
don't spend lots of time wondering if text is half a pixel or a quarter
pixel wider.
2021-11-11 05:24:58 +01:00
Benjamin Otte
46f8600b6a css: Don't crash when color stop offsets descend
Testcase included.

Fixes #4424
2021-11-10 17:28:14 +01:00
Benjamin Otte
1e47b1c610 label: Handle width-chars > text width
This was broken in wrapping labels.

Testcase included.
2021-11-09 18:34:35 +01:00
Matthias Clasen
bf40b89b53 Merge branch 'wip/jimmac/unfocused-selections' into 'master'
styling: Have unfocused selections

Closes #4393

See merge request GNOME/gtk!4113
2021-11-09 11:34:37 +00:00
Benjamin Otte
76c4673944 boxlayout: Fix broken min-size-for-opposite-size
Assume a vbox with 2 wrapping labels saying
  Hello World
  Hi Ho
being measured for their minimum width for 3 rows of text.
This should be layouted like
  Hello
  World
  Hi Ho
and measured accordingly.

However, previously this was layouted as
  Hello World
  Hi Ho
with 1.5 lines being assigned to both labels.
That will obviously not compute the above wrapping which clearly
results in a smaller min width.

A reftest testing exactly this was included.
2021-11-09 03:41:43 +01:00
Benjamin Otte
0a31201c88 boxlayout: Split loop into if statmement
Turns it into 2 loops, one for the homogeneous part and one for the
complicated part.
2021-11-09 03:41:43 +01:00
Benjamin Otte
afe94e303a boxlayout: Don't listen to comments
... when they are wrong.

Instead, remove them.

Or in other words: GTK4 does not have a fill child property anymore, so
we don't need to run the measuring loop above to determine the size.
2021-11-09 03:41:43 +01:00
Benjamin Otte
b004706009 Revert "sizerequest: Only check reported baselines if requested"
This reverts commit cf7fa931d3.

We store the baseline in the cache and we do not know if baselines might
be queried in the future. So always store them.

No reftest because I don't know how to write one.

premature optimization == √😈
2021-11-09 03:41:43 +01:00
Benjamin Otte
81169d18c3 label: max-width-chars should be ignored sometimes
When a widget is neither wrappable nor ellipsizable, we cannot modify
the label to fit into any size. So we cannot respect max-width-chars.
2021-11-09 03:41:43 +01:00
Benjamin Otte
cce6a603a6 label: max-width-chars has no effect on smaller text
Having a short text and a large max-width-chars should request the
natural width of the text, not the limit from max-width-chars.

This caused huge message dialogs.

Reftests added.
2021-11-09 03:41:43 +01:00
Matthias Clasen
60c45dac56 css: Change the way case variants are handled
Instead of translating font-variant-caps directly
to OpenType features, translate them to a PangoVariant,
now that that enumeration reflects all the css values.

This allows pango to emulate Small Caps for fonts that
don't support the OpenType feature.
2021-11-08 14:17:42 -05:00
Matthias Clasen
7bee4fa44b Handle new pango api
The PangoVariant enumeration has gained new values
to match css. Handle those in switches.
2021-11-08 14:17:42 -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
Emmanuele Bassi
018388d321 Unrealize ATContext on unroot
Non-root widgets should unrealize their ATContext, if they have one,
when they are unrooted, as they don't have a connection to a top level
any more.

Fixes: #4421
2021-11-08 10:18:22 +00:00
Emmanuele Bassi
59f45aa30c docs: Fix wrong fragments in type links
Due to a bug in gi-docgen we're not getting a warning if a fragment to a
type does not match the actual type, and we're generating a broken link.

See: https://gitlab.gnome.org/GNOME/gi-docgen/-/merge_requests/120
2021-11-07 18:40:24 +00:00
Marco Melorio
da72cfea40 docs: Tag Gdk.ModifierType as flags 2021-11-07 18:14:15 +01:00
Benjamin Otte
4f4f2d169a Merge branch 'wip/otte/for-master' into 'master'
boxlayout: Be more careful with what to consider natural size

See merge request GNOME/gtk!4129
2021-11-06 03:54:08 +00:00
Benjamin Otte
222d6f1db1 label: Don't deduce label width from logical rect
The width of a logical rect after line breaking is sometimes not
wide enough to cause line breaking to break at the exact same points.
(Is that by design or a bug in Pango? I don't know.)

So don't use the width, and only relyon values we actually set to
pango_layout_set_width().
2021-11-06 03:15:04 +01:00
Benjamin Otte
4ffa60be50 boxlayout: Be more careful with what to consider natural size
Don't just use the natural size as the max size, the natural size
is the ideal size, not necessarily the maximum size.

Also check the nat size for opposite min size.
2021-11-06 00:56:55 +01:00
Matthias Clasen
7da72d1295 Merge branch 'remove_some_unused_declarations' into 'master'
remove some unused declarations

See merge request GNOME/gtk!4125
2021-11-05 23:08:56 +00:00
Matthias Clasen
c9735e8ea9 Merge branch 'wip/baedert/for-master' into 'master'
paned: Don't pass values < -1 to gtk_widget_measure()

Closes #4404

See merge request GNOME/gtk!4126
2021-11-05 23:08:28 +00:00
Benjamin Otte
8a7868d006 Merge branch 'wip/otte/for-master' into 'master'
Revert "label: Never measure more than max-width-chars"

Closes #4399

See merge request GNOME/gtk!4120
2021-11-05 22:11:00 +00:00
Benjamin Otte
c4e5242be0 picture: Setting can-shrink requires a resize
So queue one.
2021-11-05 20:51:00 +01:00
Benjamin Otte
5c9ae28937 boxlayout: Compute opposite size properly
For size -1 in the opposite orientation, GtkBoxLayout used to measure
the children based on their min size in the box's orientation instead of
-1. That wasn't really intended, but was a side effect of how the sizing
code did (not) distribute extra size above the minimum size.

This is clearly not what we want.
What we want is measuring the orientation as is for size -1. Then we
want to just take the maximum of all children and use that.

A reftest is incldued that ensures a vbox wraps a label just like an
hbox does.
2021-11-05 20:30:49 +01:00
Benjamin Otte
8e27fc7f9b label: Redo measure() code
The old code couldn't properly do height-for-width because it only
computed the widest and smallest layout instead of looking at the actual
passed in for-size.

The label-sizing reftest has been adapted as the label code is now smart
enough to always display the whole text and no longer requests a too
small width-for-single-row when wrapping.
2021-11-05 20:29:42 +01:00
Timm Bäder
c87d1c2fb9 paned: Don't pass values < -1 to gtk_widget_measure()
Fixes #4404
2021-11-05 17:41:42 +01:00
Caolán McNamara
c66d24b41a remove some unused declarations 2021-11-05 14:03:47 +00:00
Caolán McNamara
155b791d43 update focus indicators in popovers
https://gitlab.gnome.org/GNOME/gtk/-/issues/4383
2021-11-05 13:50:48 +00:00
Benjamin Otte
53acff167b Revert "label: Never measure more than max-width-chars"
This reverts commit ba44e7a228.

The change was meant to revert to old GTK3 behavior but it actually
broke new GTK4 behavior that is in use where max-width-chars is used to
determine an ideal size, but where we don't want to limit the width to
that size.

So what happens is the reintroduction of GTK3-style lots of whitepsace
bugs, and we really don't want those.

We also don't want to break backwards compat if we can avoid it.

So let's revert this.

The reftest that was made for this purpose has been adapted.

Fixes #4399
2021-11-05 06:12:33 +01:00
Emmanuele Bassi
a1861112ee build: Don't use ld when cross-compiling
We can't guarantee anything on the target toolchain, in that case.
2021-11-04 13:41:35 +00:00
TAO ZUHONG
db2a03ed33 Update gtk/ui/gtkdialog.ui 2021-11-04 08:25:03 +00:00
TAO ZUHONG
9e8bf10653 Make dialog content_area box as vertical, keep compatibility with GTK3 2021-11-04 08:23:04 +00:00
Matthias Clasen
c20a631ab7 Merge branch 'listview-sink-adjustment' into 'master'
listbase: Sink adjustments

Closes #4403

See merge request GNOME/gtk!4117
2021-11-04 01:58:56 +00:00
Matthias Clasen
3c2818b30a listbase: Sink adjustments
gtk_adjustment_new returns floating objects.
Sink them.

Fixes: #4403
2021-11-03 21:09:37 -04:00
Maximiliano Sandoval R
0aa3a7e71c
combo_box: Use mnemonic_activate on override
This is changing the existing behavior where the mnemonic activation
would just grab the focus of the button, this was the behavior in GTK 3.
2021-11-04 00:48:05 +01:00
Maximiliano Sandoval R
3918cdd989
dropdown: Make DropDown activatable
The activation is simply forwarded to the button
within.
2021-11-04 00:47:02 +01:00
Maximiliano Sandoval R
c4df987eef
combobox: Make combo box activatable
The activation is simply forwarded to the button
within.
2021-11-04 00:46:47 +01:00
Jakub Steiner
96f63a6bf3 styling: Have unfocused selections
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/4393
2021-11-03 13:08:01 +01:00
Tobias Bernard
9b23602806 icon: revert object-symbolic check to be smaller
The larger check works well in the headerbar, but not inline in various UI elements. This reverts the larger check since the latter is more common. For selection mode, a separate larger icon (selection-mode-symbolic) has been added to adwaita-icon-theme.
2021-11-01 18:54:22 +01:00
Emmanuele Bassi
5cc6b3e342 docs: Add missing annotation 2021-11-01 12:54:35 +00:00
Alexandros Theodotou
266fceddf0
fix typo in GtkDragSource doc
GtkDrag => GdkDrag
2021-11-01 03:48:52 +00:00
Bilal Elmoussaoui
d1e246c68d gtk: fix broken gi-docgen annotation in IconView 2021-10-30 09:37:12 +00:00
Bilal Elmoussaoui
13defc7ceb gtk: remove unneeded backtick from gi-docgen item 2021-10-29 18:32:06 +00:00
Matthias Clasen
031c37c7b0 theme: Remove GtkToolbar remnants
We don't ship a widget with css name 'toolbar'
anymore, so don't waste selectors on it.
2021-10-29 11:51:18 -04:00
Matthias Clasen
860821114a Don't make all buttons in toolbars flat
When a combobox is put in a toolbar, we don't want
its button to lose its border.

Fixes: #4384
2021-10-29 11:51:18 -04:00
Benjamin Otte
c97a758aa7 cssparser: Remove unused argument
The base_directory argument is never used. So don't have it.
2021-10-28 03:19:08 +02:00
Matthias Clasen
68eb601194 Merge branch 'gtkeventcontroller.c-fix' into 'master'
master: premature controller unreferencing in gtk_event_controller_handle_event

See merge request GNOME/gtk!4099
2021-10-27 23:50:13 +00:00
Maxim Zakharov
af2d0f188c gtk: Hold reference on controller until events are fully handled
Fixes premature controller unreferencing in
gtk_event_controller_handle_event() if the controller itself is being
removed while handling the event.
2021-10-28 10:23:32 +11:00
Benjamin Otte
ac8c4245b2 css: Don't throw warnings on broken URL in image css
If a URL can't be loaded, we might end up with a NULL file. Handle that
case properly by creating an invalid image instead and don't crash or
complain to stderr when files are NULL.

This was broken since 0886ade182

A new reftest has been included. We need a reftest instead of a
CSS parser test, because the error only becomes visible when
compute()ing the actual image.

Fixes #4373
2021-10-26 23:52:38 +02:00
Matthias Clasen
4ea84d3144 Merge branch 'bilelmoussaoui/missing-since-annotations' into 'master'
since annotations cleanup

See merge request GNOME/gtk!4086
2021-10-26 17:53:06 +00:00
Alexander Mikhaylenko
83319a3ea6 inspector: Expand the controllers column view 2021-10-24 22:27:50 +05:00
Alexander Mikhaylenko
516dc79605 inspector: Use .list for property list as well 2021-10-24 22:27:50 +05:00
Alexander Mikhaylenko
2aa2b7f61e inspector: Clean up the .list style
Make it work with the property list as well, handle spinbuttons, adjust
paddings so that buttons don't touch each other, don't override horizontal
padding unnecessarily.
2021-10-24 22:27:24 +05:00
Alexander Mikhaylenko
0053160f28 inspector: Stop using .sidebar for the recorder page
Those aren't sidebars. Add separators manually instead of misusing the
style class.
2021-10-24 04:01:35 +05:00
Alexander Mikhaylenko
2ac8132499 inspector: Use consistent GtkTextView margins 2021-10-24 03:58:21 +05:00
Alexander Mikhaylenko
7aa34cb3d2 inspector: Add a separator under toolbar in css editor
Same as object properties.
2021-10-24 03:55:26 +05:00
Alexander Mikhaylenko
3aee23c172 inspector: Use tabular figures for list position label
Avoid buttons jumping around while moving through list models.
2021-10-24 03:37:01 +05:00
Alexander Mikhaylenko
bec9141233 inspector: Use .toolbar for toolbars
Remove all of the manual margins, spacing and has-frame=0, be more
consistent.
2021-10-24 03:37:01 +05:00
Alexander Mikhaylenko
131683fdcf inspector: Use a GtkSeparator for the object details toolbar
Remove a hardcoded light grey border from the sidebar that was used for
this.
2021-10-24 02:53:22 +05:00
Alexander Mikhaylenko
8176b0c2fc inspector: Remove list header style
The one from the theme works just fine.
2021-10-24 02:51:07 +05:00
Benjamin Otte
2b2fd23815 Merge branch 'wip/otte/center-center-center' into 'master'
Add a bunch of reftests and fix their failures

Closes #4285

See merge request GNOME/gtk!4085
2021-10-22 16:35:41 +00:00
Benjamin Otte
1606a41116 widget: adjust allocation even better
This fixes fallout from 3742fabae0 where
we would no longer allocate widgets to their natural size when
align flags where used.

GtkPicture wants to be allocated at 100% in that case, so a picture with
a 100x100 image inside a 200x200 window should be allocated 100x100.

The new adjustment code now does the following (for width-for-height
instead of height-for-width, swap width and height in the following):

1. query the minimum width for the allocated height
2. query the natural width
3. compute the maximum of (1) and (2)
4. set the widget width to the minimum of (3) and the allocated
   width.
5. compute the natural height for (4)
6. set the widget height to the minimum of (5) and the allocated height.
2021-10-22 17:51:40 +02:00
Bilal Elmoussaoui
cb3eae1042 g-i: add missing since 4.6 annotations 2021-10-21 15:34:39 +01:00
Benjamin Otte
350a5edb87 css: Emit a special error for a common error
This CSS:
  calc(5px+3px)
is wrong because it gets broken to:
  calc(  5px  +3px  )
which is 2 numbers inside the calc, and what you want is:
  calc(  5px  +  3px  )
but you need to add a space to get this, like so:
  calc(5px + 3px)
which is the recommended way to write calc() statements.

So whenever we encounter an error, check if the next token is a signed
number and if so, include it in the error message.
2021-10-21 00:16:20 +02:00
Benjamin Otte
c11bd57422 css: Split dimension token
Add a signed and an unsigned version.

This will become useful real soon.
2021-10-21 00:16:20 +02:00
Matthias Clasen
14e6d9555d Merge branch 'setlocale-gapplication-help' into 'master'
GtkApplication: Call setlocale early

Closes #4234

See merge request GNOME/gtk!3928
2021-10-19 02:48:41 +00:00
Matthias Clasen
46ba4b9d8c Merge branch 'fix-win11-sdk' into 'master'
Fix building against the Windows 11 SDK (GTK master/4.x)

See merge request GNOME/gtk!4063
2021-10-19 02:42:15 +00:00
Matthias Clasen
464f76ce5d Merge branch 'line-height-percentage' into 'master'
css: Fix handling of percentage for line-height

Closes #3254 and #4354

See merge request GNOME/gtk!4075
2021-10-19 02:41:09 +00:00
Matthias Clasen
9965f26d97 Merge branch 'wip/exalm/levelbar' into 'master'
levelbar: Fill the whole space for discrete level bars

See merge request GNOME/gtk!4042
2021-10-19 02:40:26 +00:00
Benjamin Otte
bf5350e13c Merge branch 'label-sizing' into 'master'
Make label-sizing reftest pass

See merge request GNOME/gtk!4076
2021-10-19 00:19:52 +00:00
Benjamin Otte
3742fabae0 widget: Don't overadjust allocations
When adjusting allocations, don't query height for the current width,
but query it for the adjusted width.

And adjust width not to the width-for-any-height, but to
width-for-allocated-height.
2021-10-19 01:55:59 +02:00
Benjamin Otte
ba44e7a228 label: Never measure more than max-width-chars
Even when we have tons of width available, still do the wrapping at
max-width-chars.

This is what happened in GTK3, too, but it happened automatically
because GTK3 did for_size = MIN (for_size, nat_size) and GTK4 does not.

So we do this manually in the label now.

Fixes the label-sizing.ui reftest.
2021-10-19 01:04:25 +02:00
Alexander Mikhaylenko
1c5a4de176 levelbar: Fill the whole space for discrete level bars
Ideally this would be using box layout, but it overrides measure() so it's
not possible - so reimplement it instead. Fix an accidentally int division
along the way.
2021-10-19 02:13:49 +05:00
Emmanuele Bassi
ad46e65dff Merge branch 'wip/cdavis/flowbox-add-functions' into 'master'
gtkflowbox: Add prepend() and append()

Closes #4277

See merge request GNOME/gtk!4013
2021-10-18 21:09:10 +00:00
Matthias Clasen
5dec1b0cc0 Merge branch 'wip/baedert/for-master' into 'master'
Some fixes, hmm yes

See merge request GNOME/gtk!4068
2021-10-18 20:58:46 +00:00
Matthias Clasen
c80e877c28 css: Fix handling of percentage for line-height
We weren't doing the right thing here.
This is simpler, and works.

Fixes: #4354
2021-10-18 16:53:46 -04:00
Matthias Clasen
5ff9f4a435 Merge branch 'matthiasc/for-master' into 'master'
Small fixes

Closes #4248

See merge request GNOME/gtk!4072
2021-10-18 18:00:33 +00:00
Matthias Clasen
bd1649e5f4 Merge branch 'feature/calendar-first-day' into 'master'
calendar: Fix abbreviated day names

Closes #4338

See merge request GNOME/gtk!4061
2021-10-18 15:08:35 +00:00
Matthias Clasen
bddf9f9ca3 docs: Cosmetics
Do a round of "the the" removal.
2021-10-18 08:35:54 -04:00
Timm Bäder
085f0171c1 Ensure blur nodes have a positive blur radius 2021-10-17 12:15:34 +02:00
Timm Bäder
e7ac8275ea main: Flip set_widget_active_state() logic
The function used to take a boolean, just to set the active state of the
widget to the exact opposite of that boolean. Fix that.
2021-10-17 11:21:00 +02:00
Timm Bäder
03d4ac1863 theme: enable tabular numbers in GtkCalendar
It aligns numbers a lot so this makes sense.
2021-10-17 11:12:14 +02:00
Timm Bäder
beda50f631 cssparser: Make a signed expression unsigned 2021-10-17 11:12:14 +02:00
Chun-wei Fan
3481ebdafb gtk: Fix version resource on for Windows 11 SDK
The rc.exe that comes with the Windows 11 SDK does not allow one to include
winuser.h directly in the .rc scripts, so make sure that it is not included
by gtk-win32.rc.body.in, but instead include windows.h with WIN32_LEAN_AND_MEAN
defined.
2021-10-13 12:21:10 +08:00
Christopher Davis
454ca897bb gtkflowbox: Add prepend() and append()
These functions are common across container implementations,
but GtkFlowBox was missing them.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/4277
2021-10-12 11:07:17 -07:00
Niels De Graef
41ca09d645 calendar: Add an explanatory comment
On the magic numbers used to get the abbreviated day names.
2021-10-12 19:37:13 +02:00
Niels De Graef
dcbfd61558 calendar: Fix abbreviated day names
... if the current locale has a different starting day than Sunday.

This needed 2 fixes:
* We need to take into account `calendar->week_start` when
  creating/adding the appropriate `day_name_labels` field
* we were only calculating `calendar->week_start` _after_ attaching the
  `day_name_labels`, so it was still set to 0 (the default value).

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/4338
2021-10-12 19:29:26 +02:00
Bilal Elmoussaoui
257adb4464 gtk: fix Snapshot.push_shadow annotation 2021-10-12 09:00:03 +00:00
Matthias Clasen
49a64da7ec Merge branch 'ngl-is-the-new-gl' into 'master'
Rename ngl to gl

Closes #4318

See merge request GNOME/gtk!4037
2021-10-11 06:43:41 +00:00
John Ralls
cfadca696b [gtkimcontextquartz] Accommodate moving GdkSurface widget to private.
Fixes macOS build.
2021-10-10 13:16:49 -07:00
Benjamin Otte
8c1f7f7531 glcontext: Deprecate gdk_gl_context_set_use_es()
Make it call gdk_gl_context_set_allowed_apis().

Also port callers to use this function.
2021-10-08 03:31:07 +02:00
Benjamin Otte
222d927e93 Merge branch 'wip/otte/for-master' into 'master'
css: Render the background-clip area, not the background-origin

Closes #4324

See merge request GNOME/gtk!4043
2021-10-07 19:11:28 +00:00
Benjamin Otte
30164d5b46 css: Render the background-clip area, not the background-origin
Testcase included

Fixes #4324
2021-10-07 19:59:44 +02:00
Matthias Clasen
f868c67429 Skip gsk_ngl type funcs
The only type we have with this prefix is the
deprecated duplicate of gsk_gl_renderer_get_type(),
and including it causes some tests to break.
So skip it.
2021-10-07 13:05:53 -04:00
Matthias Clasen
144f727d5a Rename ngl to gl
We have only one gl renderer now, and it is
a bit odd for it not be called gl.
2021-10-07 13:05:53 -04:00
Christopher Davis
0775e21131 Add support for pango markup in menu items
Before c4a2234a28
menu models could use markup for items and the markup would
be parsed, but this was not intended behavior.

This commit adds official support for using markup
for menu items via the `use-markup` property.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/4306
2021-10-07 02:49:11 -07:00
Matthias Clasen
c7d6bf733a filechooserportal: Take a ref on transient-for
This may fix a crash that has been reported in
file_chooser_portal_data_free.

Fixes: #4314
2021-10-06 22:37:45 -04:00