Commit Graph

39958 Commits

Author SHA1 Message Date
Corey Berla
c8b4f0c8e8 columnviewtitle: Prevent header clicks from propagating
The header in GtkColumnView has multiple event handlers
there is a ::pressed handler in GtkColumnView for
resizing the columns in CAPTURE as well as a motion
and drag controller.  The ::release handler is in
GtkColumnViewTitle.   We can't claim the event in the
existing handlers because then the ::release handler will
never get called.  Currently, however, all clicks get propagated
to the ColumnView from the header which can be problematic.
Since we don't usually want the clicks from the header
handled on the view, claim it in the BUBBLE phase.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5425
2023-03-01 01:38:18 +02:00
Alexander Mikhaylenko
52f7afeecd builderparser: Don't exit too early on nested custom tags
Currently nested custom tags work only as long as the element names differ
from the root one. If it's same, for example:

<condition type="any">
  <condition type="max-width">600</condition>
  <condition type="max-height">600</condition>
</condition>

then it will fail. Meanwhile the same tags wrapped into <conditions> would
work.

The problem is that custom tag parsing is considered finished as soon as we
encounter a closing tag with the same element name. So instead, track the
nesting level.
2023-03-01 01:20:48 +02:00
Ivan Molodetskikh
370ab8aa52 widget: Reset alloc_needed_on_child before allocating children
Reset alloc_needed_on_child *before* allocating the children. This is
because some child's size_allocate() may call queue_allocate(), which
will bubble up alloc_needed_on_child. An example of this happening is
with GtkScrollable implementations, which are supposed to configure
their adjustments in size_allocate(), which will cause GtkScrollbar's
GtkRange to notice and queue_allocate() on itself.

If we reset alloc_needed_on_child after this happens, then our children
will have a lingering alloc_needed_on_child and will not receive an
allocation.

This commit fixes widgets occasionally losing an allocation when this
scenario happens.
2023-03-01 01:20:17 +02:00
Matthias Clasen
08479ae4b2 text: Make editable API irreversible
Programmatic changes to the entry contents should
not become part of the undo history.

Sadly, the editable implementations are also used
in the code paths that we use for user-initiated changes,
so we have to be careful to only set them as
irreversible if we are not already in a user action.

Fixes: #5622
2023-03-01 01:19:54 +02:00
Matthias Clasen
45d6ffcce8 text: Fix disabling of history
Keep a separate boolean for enable-undo, and
disable the history if it is false, or the entry
is not using visible text, or isn't editable.

Related to: #5622
2023-03-01 01:19:34 +02:00
Lukáš Tyrychtr
f3b09a8725 GtkNotebook: Improve the labels of notebook pages for a11y 2023-03-01 01:18:05 +02:00
Matthias Clasen
d6d5a22306 filechooser: Fix paned limits
The intention of the ui file was to not let
the paned shrink both children down to nothing,
but using <child> for the children effectively
overrides the setting of the shrink properties.
Fix that by using child properties instead of
<child>.
2023-03-01 01:17:50 +02:00
Alexandros Theodotou
5cf5b9c7f5 Remove timeout when disposing GtkEditableLabel
Fixes: #5584
2023-03-01 01:11:46 +02:00
Matthias Clasen
c4ddf47d8f placessidebar: Make all rows ellipsize
Otherwise, we end up with a single long row
pushing the content of all the other rows
off to the left, which is much worse than
ellipsizing.

Fixes: #4710
2023-03-01 01:10:38 +02:00
Matthias Clasen
069fef6f99 passwordentry: Fix an asymmetry
When connecting a signal in realize,
we should disconnect in unrealize.

Fixes: #5285
2023-03-01 01:06:14 +02:00
Matthias Clasen
5caecf16ac tooltip: Prevent too-wide tooltip windows
Set the label to expand, so it actually fills
the width that we allocated for it, instead
of shrinking back to the minimum width for
its height.

Fixes: #5521
2023-03-01 01:05:45 +02:00
Matthias Clasen
8203b69e74 tooltip: Don't play games with max-width-chars
Setting max-width-chars to the number of characters
in the string works ok only as long as the average
char width we get from Pango matches reality. Sadly
that seems not always the case, and this code was
causing short Chinese tooltips to always be broken
into two lines.

Fixes: #4470
2023-03-01 01:05:27 +02:00
Sophie Herold
189c1dd306 scrolledWindow: Propagate event for no scrolling 2023-03-01 01:00:06 +02:00
Christian Hergert
a4512a4c95 istring: fix istring_prepend() on malloc transition
When transitioning from internal to malloc, the strings were placed in
the wrong order to g_strconcat(). This fixes an issue with undo where
if you hit the boundary in just the right way, your undo stack will do
unexpected things.

Fixes #5506
2023-03-01 00:53:03 +02:00
Corey Berla
ce01d7d7a3 gtkmodelbutton: Ensure that accel label is always aligned to end
When the model button just has a text label and accel text,
the button fills and the accel label is implicitly aigned to end.
When there's also a icon, even though it's not shown (because
icons are only shown if there's no text), the button doesn't fill
and the accel ends up not aligned (assuming one of the other buttons
is longer). Ensure that the accel label is aligned to the end.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5504
2023-03-01 00:51:30 +02:00
Barnabás Pőcze
a4758db75e a11y: Use fallback logic when GApplication has no DBus object path
Use the fallback logic to generate the base path for the GtkAtSpiRoot
if the GApplication has no DBus object path to guarantee that
the base path will not stay NULL.
2023-03-01 00:51:00 +02:00
Barnabás Pőcze
6a991cf05a a11y: Check if path is NULL when removing from cache
`gtk_at_spi_cache_add_context()` checks if the GtkAtSpiContext's path
is NULL before inserting the context object into the hash table.
Do the same in `gtk_at_spi_cache_remove_context()` to avoid a NULL
pointer dereference in `g_str_hash()` during the hash table lookup
if a context with NULL path is removed. That can happen when the
GtkAtSpiRoot::base_path is NULL, which, in turn, can happen if
`g_application_get_dbus_object_path()` returns NULL.

  ==394047==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7fd1966f8b84 bp 0x7fff11e3ded0 sp 0x7fff11e3de58 T0)
  ==394047==The signal is caused by a READ memory access.
  ==394047==Hint: address points to the zero page.
      #0 0x7fd1966f8b84 in g_str_hash (/usr/lib/libglib-2.0.so.0+0x37b84)
      #1 0x7fd1966f9c09 in g_hash_table_contains (/usr/lib/libglib-2.0.so.0+0x38c09)
      #2 0x7fd196062c10 in gtk_at_spi_cache_remove_context ../gtk/a11y/gtkatspicache.c:447
      #3 0x7fd19606e0a9 in gtk_at_spi_root_unregister ../gtk/a11y/gtkatspiroot.c:653
      #4 0x7fd196067f58 in gtk_at_spi_context_unrealize ../gtk/a11y/gtkatspicontext.c:1559
      #5 0x7fd195ced97f in gtk_at_context_unrealize ../gtk/gtkatcontext.c:668
      #6 0x7fd195f5576e in gtk_widget_unroot_at_context ../gtk/gtkwidget.c:2399
      #7 0x7fd195f55bd2 in gtk_widget_unroot ../gtk/gtkwidget.c:2499
      ...
2023-03-01 00:50:49 +02:00
robxnano
0c83807a5a filechoosernativewin32: Set default extension 2023-03-01 00:49:42 +02:00
Corey Berla
254eca269a calendar: Set marked days immediately
The marked days are set only as part of gtk_calendar_select_day().
This is insufficient, especially because the day-selected signal
is emitted after the marked days are set in gtk_calendar_select_day().
2023-03-01 00:48:05 +02:00
Corey Berla
a59bf6e3cc calendar: Only apply the marked_day to the current month
The marked day gets applied to the current month, and either the previous
or subsequent month if they are visible within the current month.
This doesn't make any sense and likely was an accidental regression
in a6f9052cf1.  Clarify the docs.
2023-03-01 00:47:36 +02:00
Corey Berla
b06294d5d7 calendar: Add css style for marked days
As part of a6f9052cf1, marked days lost
their style, essentially making that function worthless.  Previously,
they were simply bolded, but that doesn't give them proper justice.
2023-03-01 00:47:06 +02:00
Arjan Molenaar
3f9b7dd863 macos: Command should not come from gettext
Instead, just provide the right character.

See also
https://gitlab.gnome.org/GNOME/gtk/-/blob/main/gtk/gtkaccelgroup.c#L916.
2023-03-01 00:45:27 +02:00
Arjan Molenaar
3b36459630 macos: Use Command key symbol for meta
Show the Apple Command symbol ⌘ as keyboard shortcut for the Meta key on macos,
similar to GtkAccelGroup.
2023-03-01 00:45:09 +02:00
Corey Berla
5c4f3a1943 gtkdroptarget: Notify value property on local drag
The value property is only getting notified when it's unset
or when it's set from gdk_drop_real_value_async().  Make sure
to always notify :value when its changed
2023-03-01 00:39:41 +02:00
Lukáš Tyrychtr
b53bd5b670 Don't present GTK class names to assistive technologies even as a fallback
A screen reader user is not interested in GTK internals, for example,
he does not care whether a button is an image button or not,
and a screen reader will report the fact that it is a button anyway.
Same applies for GtkEntry widgets, for example.

This actually is sufficient to fix gnome-control-center#2244.
And, according to the discussion in #5145, it should be fine.
2023-03-01 00:36:07 +02:00
Akira TAGOH
e18e99209e Revert "Fix an assertion in GtkFontChooserWidget when setting a filter."
Actually this filter hasn't ported to 4.8 branch and
the merge request GNOME/gtk!5514 has been accidentally merged.

This reverts commit f4768f16c8.
2023-02-28 21:42:00 +09:00
Akira TAGOH
f4768f16c8 Fix an assertion in GtkFontChooserWidget when setting a filter.
(cherry-picked from commit 4532c3020b)
2023-02-14 15:12:52 +09:00
Matteo Percivaldi
1ff3a26c96 gtkcssanimatedstyle: Fix return of new_advance()
This was causing animation and transition to stop randomly and reset
their state to initial state.

This issue has existed since commit
7b68bdb831.

Closes #4426
2023-01-13 15:15:10 -05:00
Matthias Clasen
92ebf8ab13 fontchooser: Drop a few errant translations
No point in translating these properties, they
are not strings.

Fixes: #5146
2023-01-12 18:38:44 -05:00
Benjamin Otte
2aaefd9ff6 Merge branch 'wip/corey/list-item-visible' into 'main'
listitemwidget: Setup factory only once the widget is visible

See merge request GNOME/gtk!5374

(cherry picked from commit 188f9269b7)

7ad693f8 gtkcolumnviewcolumn: Only create cells when the column is visible
2022-12-30 19:45:00 -05:00
Luca Bacci
5844ecf381 Merge branch 'include-hicolor-index-theme-as-resource-rebased' into 'main'
Include hicolor index.theme as a resource (rebased)

Closes #5303

See merge request GNOME/gtk!5361
2022-12-20 21:52:17 -05:00
Benjamin Otte
14823c6bd6 Merge branch 'wip/antoniof/listbase-rubberband-better-fix' into 'main'
listbase: Cancel rubberband if not handling drag

See merge request GNOME/gtk!4831

(cherry picked from commit ae097d9674)

efbd2289 listbase: Cancel rubberband if not handling drag
2022-12-20 20:19:15 -05:00
Benjamin Otte
9df10fa96f Merge branch 'wip/corey/listbase-focus' into 'main'
listbase: Use set_focus_child properly

Closes #5433 and #5432

See merge request GNOME/gtk!5169

(cherry picked from commit 1f001a8f6a)

7081bfc6 listbase: Split scroll_to_item for reuse
93e591fd listbase: Use set_focus_child properly
2022-12-14 22:21:54 -05:00
Matthias Clasen
55d8469fde mountoperation: Add a mnemonic to a button
This is a good practice, even if this is a rarely
used dialog.
2022-12-14 11:28:19 -05:00
Matthias Clasen
8d4a14e082 mountoperation: Don't use a treeview
Port the process list from GtkTreeView
to GtkListView, and fix a number of broken
things along the way.
2022-12-14 11:28:19 -05:00
Matthias Clasen
55dd442955 mountoperation: Survive on Wayland
The code was assuming it is dealing with an
X11 display, and trigger assertions. Fix that
to make it work at least as well as it does
on Windows.
2022-12-14 11:28:19 -05:00
Matthias Clasen
9f4baac5a2 text: Prevent unexpected notify::direction emissions
Calling gdk_device_get_direction can trigger a
notify::direction emissions, since the X11 backend
determines the direction on demand. Prevent that by
forcing the direction to be determined ahead of time.

Fixes: #5311
2022-12-14 11:28:19 -05:00
Corey Berla
4a04cf610e atspicontext: Log more helpful warnings when the a11y bus doesn't exist 2022-12-09 08:09:28 -10:00
Corey Berla
9252b88c23 atspicontext: Cache empty atspi bus address
We are caching the bus address as data on the display object when it
exists, but fail to set the data when the bus address doesn't exist.
That causing excessive calls to GetAddress when the accesssbility
bus doesn't exist. Make sure to cache a non-existent accessibility
bus by setting the "" string.
2022-12-09 08:09:24 -10:00
Corey Berla
b2356dbe7b atspicontext: Log failure to connect to a11y
GTK depends on the a11y infrastructure to be in place unless GTK_A11Y is
set to none.  It appears that despite that, users attempt to
get around the a11y requirement without setting GTK_A11Y.
This can cause, amongst other issues, performance problems
with gtk applications.  Log failure to connect to the a11y
bus.
2022-12-09 08:09:05 -10:00
Carlos Garnacho
3b940b12f6 gtktext: Claim gesture more selectively
Even though button 1 (or touch down) presses do most often have
an effect in one way or another (starting drag, moving focus,
starting selection, ...), there is one situation that they do
immediately nothing: When clicking on the entry does not move
the text caret around. Dragging might start a selection, but
the entry did not do anything just yet, and an immediate
button/touch release should remain at "did nothing".

And that is precisely the hint that the Wayland IM context's click
gesture takes, clicks that do not scroll nor move the caret around,
having the GtkText not claim the gesture in that situation makes
the IM gesture able to do its thing without in-fighting.

This is typically not a problem when the GtkText is embedded in
another GtkEditable implementation (e.g. GtkEntry), since the
IM gesture is inactive and capturing from the parent widget, so
gets a pass that it otherwise doesn't get when both gestures are
in the same widget. This makes it work regardless of GtkText not
being a child of a composite widget, like NautilusQueryEditor
and AdwRowEntry.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5351

(cherry-picked from commit 09b982f0264e42bda3e8471bb25abec5ee742ecc)
2022-11-18 18:36:32 +01:00
Adam Williamson
824ff01eee focus: fall back to old behaviour if we didn't focus anything
8455b9ac74 seems to have introduced a problem where we can wind
up focusing no widget at all if the `while (parent)` loop doesn't
find a widget it can successfully move the focus to. This 'fixes'
that by falling back to doing the previous thing if we make it
all the way through that loop without moving the focus. Thanks to
@coreyberla for a hint to improve the implementation.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
2022-11-12 03:37:52 +02:00
Mat
339b9eb1b9 Revert "treepopover: Do not propagate natural width of content"
This reverts commit 9c919ffa46.
2022-10-26 13:51:23 +03:00
Matthias Clasen
070926a4cc Merge branch 'wip/antoniof/backport-list-focus' into 'gtk-4-8'
Backport MR !5023 to 4.8

See merge request GNOME/gtk!5157
2022-10-21 17:34:35 +00:00
Matthias Clasen
14c7a001a6 editablelabel: Defer changes on focus-out
We can get spurious focus-out/-in pairs when
the editable label is in a popover that gets
a Wayland keyboard enter event as a result of
clicking the editable label.

A timeout isn't a great solution, but nothing
better is available right now.

Fixes: #4864
2022-10-21 14:38:08 +03:00
Matthias Clasen
bcad03da6c window: Keep a reference to move_focus_widget
If we don't take a reference, it can happen that
the pointer is no longer valid by the time we
dereference it in after_paint.
2022-10-21 14:37:43 +03:00
António Fernandes
5d9576abb9 columnview: Forward all focus to child
For the same reasoning as the preceding commit.

Also don't make GtkColumnView focusable. Its internal list view
is already focusable, which is enough to take care of the empty
view case.


(cherry picked from commit 9cb8d21cb5)
2022-10-21 08:03:43 +00:00
António Fernandes
b86c91de1d listbase: Grab focus on items instead of container
The container view itself being focusable makes keyboard navigation
slower by adding a useless focus step.

It also means if an item gets removed, the focus jumps back to the view,
instead of jumping to the next item, as seen in nautilus bug report:
https://gitlab.gnome.org/GNOME/nautilus/-/issues/2489

Instead of making the GtkListBase container itself focusable, override
the .grab_focus() vfunc. This way, calling gtk_widget_grab_focus() on
the view container keeps working sucessfully, but focuses the focus
item directly instead.

This is particularly useful to have because applicaiton authors do
not have direct acess to this class's children, so they can't call
gtk_widget_grab_focus() on them directly.


(cherry picked from commit 4fc4298920)
2022-10-21 08:03:14 +00:00
Matthias Clasen
a0d85f36ab window: Don't focus invisible widgets
Only clear a queued move_focus if the widget
we are focusing is actually visible.

This was happening in some cases when popovers
are dismissed by clicking outside, and it was
causing us to miss proper focus updates that
were already queued.
2022-10-18 20:37:19 +03:00
Matthias Clasen
8455b9ac74 window: Fix focus updates
This partially undoes changes from 3dbf5038fa.

That commit did two things:
1) Move the focus update to after-paint time
2) Change from grabbing focus to the visible parent
   to  calling move_focus (TAB)

The second part did have the unintended consequence
of moving focus laterally.

Fixes: #4903
2022-10-18 20:37:05 +03:00