Commit graph

24968 commits

Author SHA1 Message Date
António Fernandes 167fb75719 list-view: Guard against gone file usage
Between the time this was scheduled and the actual call, the file
may have been removed from the directory and, as such, from the
view, and the only reason the row, item and file weren't destroyed
is because we kept a reference to the row. But it's invalid to
access the file now.
2024-01-21 23:30:41 +00:00
António Fernandes 8d1cca7d2a list-view: Stop calling NautilusFilesView for subdirectories
We want to stop being a NautilusFilesView subclass.

Emit signals instead and have NautilusFilesView handle them.
The logical flow is the same.

Also simplify on_row_expanded_changed() while touching it.
2024-01-21 23:30:41 +00:00
António Fernandes f4870ee042 list-view: Optimize subdirectory unloading
Instead of iterating the model to find the row matching the item,
store the row itself.
2024-01-21 23:30:41 +00:00
António Fernandes 3890c997d5 files-view: Ensure subdirectory models are cleared
There is no reason to delegate this task on the list view.
2024-01-21 23:30:41 +00:00
António Fernandes d1d482a490 name-cell: Improve subfolder loading indication
Reduce the timeout from 1 s to 200 ms and move the spinner after the
name, not to move things around.
2024-01-21 23:30:41 +00:00
António Fernandes 36fec089ec list-view: Stop handling NautilusDirectory:done-loading
That's the job of NautilusFilesView, and, incidentally, it already
handles it. So, it may as well take care of everything.

However, NautilusFilesView has no access to the expander, so the
NautilusNameCell itself takes over that job. As it should.
2024-01-21 23:30:41 +00:00
António Fernandes c5e56ecaeb files-view: Handle directory load state correctly
Multiple subdirectories may be loading at the same time, so it's
incorrect to set .subdirectory_loading to FALSE when one of them
is done loading.

Instead keep a list of subdirectories which are loading.
2024-01-21 23:30:41 +00:00
António Fernandes e5ce4db3f8 view-item: Refine subfolder loading property 2024-01-21 23:30:41 +00:00
António Fernandes a9acad6938 list-view: Assume GtkTreeListRow:item is non-NULL
gtk_tree_list_row_get_item() is only marked as nullable for backwards
compatibility reasons. In the gtk version we depend on this is never
NULL.
2024-01-21 23:30:41 +00:00
António Fernandes 566a652285 files-view: Drop get_nautilus_window_slot()
Reload the list view via calling the respective action on self. This
removes the last external usage of `get_nautilus_window_slot`.
2024-01-21 23:30:41 +00:00
António Fernandes 5b7ac54ac6 list-view: Optimize .get_backing_item()
Iterate only the selection, not the whole model.
2024-01-21 23:30:40 +00:00
António Fernandes d2f2c46027 files-view: Drop .get_backing_uri() virtual method
Have NautilusListBase provide a virtual method for list view to
implement instead.
2024-01-21 23:30:02 +00:00
António Fernandes d52805b5d9 list-base: Fix crash on repeated drops
nautilus_view_get_location() doesn't transfer a reference, but we've
been unref'ing the location since ee00f7c2f3

Use nautilus_file_get_location() instead, which transfers a reference.

This removes the last usage of NautilusView interface methods on self,
which prepares us to stop inheriting from NautilusFilesView.
2024-01-21 18:23:08 +00:00
António Fernandes 119e3628cb list-base: Don't call nautilus_dnd_perform_drop()
It requires a NautilusFilesView parameter, and we are going to stop
being a NautilusFilesView subclass soon.

So emit a matching signal and have NautilusFilesView handle it by
swapping itself in as the first parameter.
2024-01-21 18:23:08 +00:00
António Fernandes 17fb0ed931 list-base: Handle hover directly
We are including files-view-dnd.h for a single method of which we are
the single user. And nothing about it requires NautilusFilesView at all
if we ignore the awkward and pointless slot getter.
2024-01-21 18:23:08 +00:00
António Fernandes eabca038f0 list-base: Stop using nautilus_view_get_selection()
We want to stop inheriting from NautilusFilesView, which means we are
not going to be a NautilusView implementation either.

So we must create the selected files list ourselves.

(Conceptually, code dealing with NautilusFile objects should be moved
to files-view.c, but that's not a show-stopper at this time.)
2024-01-21 18:23:08 +00:00
António Fernandes 0d01682b2d list-base: Stop using nautilus_view_set_selection()
The only usage is to clear selection.
We can use GtkSelectionModel API for that purpose instead.

This reduces the reliance on NautilusView methods, because this
class is not going set to stop inheriting from NautilusFilesView,
which implements that interface.
2024-01-21 18:23:08 +00:00
António Fernandes 68b34f774b list-base: Don't call NautilusFilesView menu methods
Instead emit signals and let NautilusFilesView do everything itself.
2024-01-21 18:23:08 +00:00
António Fernandes 33525d16aa list-base: Stop implementing .reveal_for_selection_context_menu()
NautilusFilesView can reuse the code from the previous commit instead.

Now we don't implement any NautilusFilesViewClass fvunction anymore,
which gets us closer to the plan from https://gitlab.gnome.org/GNOME/nautilus/-/issues/3042
2024-01-21 18:23:08 +00:00
António Fernandes ae8828c973 files-view: Drop .compute_rename_popover_pointing_to()
One less vfunc for NautilusListBase to implement.

get_selected_rectangle() is going to be reused next commit.
2024-01-21 18:23:08 +00:00
Quentin PAGÈS 6094379817 Update Occitan translation 2024-01-20 19:54:13 +00:00
Lukáš Tyrychtr a43d6b4eae a11y: Add a tooltip to the star button
By doing that, a visually ipaired person knows whether the current item is
starred or not.
2024-01-19 16:17:06 +00:00
Peter Eisenmann fa3a66ba6d ci: fix inverted branch inclusion
This was an oversight in [1] and causes the pipeline not to run for
release branches, but for any other branch. Fixed by inverting the
condition.

[1] ecac11569e
2024-01-19 14:39:19 +01:00
Automeris naranja a2a2f1b411 new-folder-dialog: Use header capitalization & add mnemonics
- Add mnemonics to "Create" and "Cancel"
buttons

- Use header capitalization in the "Folder name"
label, as recommended by HIG:
https://developer.gnome.org/hig/guidelines/writing-style.html#header-capitalization
2024-01-19 01:49:08 +00:00
Khalid Abu Shawarib ebda18f3ab nautilus-extension: Restore definition
It's used for more than just non repetition, and was wrongly
removed in 20040dead1.
2024-01-18 11:27:28 +00:00
Khalid Abu Shawarib 7bab768ec3 nautilus-extension: Use G_(BEGIN/END)_DECLS in headers
This fixes issues with exporting to C++.

Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/1884
2024-01-18 11:20:05 +03:00
Khalid Abu Shawarib 20040dead1 nautilus-extension: Use pragma once in header 2024-01-18 03:14:09 +03:00
Danial Behzadi 81a0f5d4a5 Update Persian translation 2024-01-17 23:06:26 +00:00
Quentin PAGÈS fa5c8d81d9 Update Occitan translation 2024-01-17 19:29:48 +00:00
Quentin PAGÈS 50dce51330 Update Occitan translation 2024-01-17 19:03:08 +00:00
Alexandre Franke 89b2d9a2d1 Update French translation
(cherry picked from commit 540d72b4da)
2024-01-17 16:56:38 +00:00
Peter Eisenmann 7c23f126d1 uncrustify: remove nonexistent animation folder 2024-01-17 03:40:29 +00:00
Peter Eisenmann d92a6f02e6 audio-video-properties: format with uncrustify
While the code is imported, indentions on the current files are a mess.
This makes it more difficult for contributors to get things right, so
incude these files in the uncrustify script and format them.
2024-01-17 03:40:29 +00:00
Corey Berla 9c177d1aaa window: Fix page tooltip when searching
Binding the slot's location to the page's tooltip doesn't work for
search because the location will change only when the search begins,
but not for any subsequent updates to the query.  Instead, listen
for changes to the slot's title, and use the existing logic to
actually update the tooltip
2024-01-17 03:16:10 +00:00
Corey Berla b3c88098f6 window: Escape tooltips for tab pages
AdwTabPage tooltips can accept markup by default, so we need to escape
them.
2024-01-17 03:16:10 +00:00
Corey Berla 77086ce4f8 docs: A couple more tweaks to the man page 2024-01-17 02:37:27 +00:00
Corey Berla c0b7d51455 docs: Remove --check from man page
Update the nautilus man page to reflect that the self check option was
removed in commit 8c21a037fc ("general: remove self-checking
functionality").
2024-01-17 02:37:27 +00:00
António Fernandes 607176359d view-model: Drop find()
This wraps a linear search in an apparently simple call, which invites
lazy coding and invites future performance regressions.

This is not to say there is no need to iterate the model linearly. But
when doing so, it's best to do it explicitly, in a for/while loop, to
make it easy to spot performance issues.
2024-01-16 21:07:47 +00:00
António Fernandes c93c320d58 window-slot: Always select file to activate
The `.pending_scroll_to` file is only ever relevant if we don't set a
`.pending_selection`. This only ever happens when we are asked to
handle a file which extracts.

In that case, there is no reason not to additionally select it as well.
The extracted files are going to be selected afterwards anyway.

This allows us remove some now-dead code. There is no optimization
here though, because nautilus_files_view_call_set_selection() runs
a linear search not unlike nautilus_view_model_find().
2024-01-16 21:07:47 +00:00
António Fernandes 5304523401 files-view: Drop .get_last_visible_file()
Just like its recently removed sibling, it's utterly broken. The
but is similar to the one reported on [0], except it happens on
reload instead of view mode switch.

Likewise, it relies on intensive fragile computation, because GTK
doesn't give us the visible range in item positions.[1] There is
no hope to fix this without GTK help.

This is	only used by the slot when reloading and if nothing is
selected. The cases where this is most benefitial are very long
lists, but these take long to load and the scroll happens at the
end mostly as a surprise.

This is one less virtual method	for NautilusListBase to	inherit.

[0] https://gitlab.gnome.org/GNOME/nautilus/-/issues/3034
[1] https://gitlab.gnome.org/GNOME/gtk/-/issues/4688
2024-01-16 21:07:47 +00:00
António Fernandes f3f03ccd4b list-base: Reuse virtual function wrapper
Unused since last commit, but useful in other places.
2024-01-16 21:07:47 +00:00
Corey Berla 7dc9b5fbb5 view-cell: Prioritize thumbnails on mapped cells
After the last commit, get_first_visible() file is only used for
thumbnail prioritization logic. prioritize_thumbnailing_on_idle()
is very inefficient and over complex as it constantly iterates
through the bound items to see what is visible.

Instead, let's rely on an GTK implementation detail: list widget
children outside the scrolled viewport area are not mapped. With
this assumption, we can connect to ::map in the cells needing a
thumbnail.

The only catch is that it maps more items initially than are
visible, so also connect to ::unmap revert the prioritization for
items that are mapped and immediately unmapped.
2024-01-16 21:07:47 +00:00
António Fernandes 6457e45603 window-slot: Prioritize ancestor selection when going back
The last commit introduced restoration of selection from history.

When going back, we want to select the parent (or other ancestor),
which is usually, but not always, the saved selection. Not to change
the pre-existant behavior, ensure the ancestor selection always
takes priority over the requested selection when going back.
2024-01-16 21:04:39 +00:00
António Fernandes 728f5944ba window-slot: Save selection on history, not scroll position
For one, the restored scroll position is not faithful to the original
scroll position:  https://gitlab.gnome.org/GNOME/nautilus/-/issues/3034

Instead, restoring selection provides more benefit. Save selection as
a vector of URIs (storing NautilusFile lists would be a hassle, because
it requires listening for ::changed in order to remove a file when it is
marked as gone...)

Closes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2818
2024-01-16 18:49:44 +00:00
António Fernandes 28c93d16e8 files-view: Don't warn if requested selection doesn't exist
More often than not, there is a legitimate reason for the
requested selection not to be found.

E.g.: You are on list view with expandable folders enabled,
and a file in an expanded subfolder is selected. When you
switch to grid view, it tries to restore the previously
selected item, but it's not found anywhere anymore.

The  next commit is going to introduce another such case.
2024-01-16 18:49:44 +00:00
António Fernandes 16659edce1 files-view: Drop .get_first_visible_file()
Let's admit it: it's utterly broken.[0]

It relies on intensive fragile computation (shared with thumbnail
priorizatio), because GTK doesn't give us the visible range in
item positions.[1] There is no hope to fix this without GTK help.

This is only used by the slot when switching view mode anyway, and
only if nothing is selected. The cases where this is most benefitial
are very long lists, but these take long to load and the scroll
happens at the end mostly as a surprise.

This is one less virtual method for NautilusListBase to inherit.

[0] https://gitlab.gnome.org/GNOME/nautilus/-/issues/3034
[1] https://gitlab.gnome.org/GNOME/gtk/-/issues/4688
2024-01-16 18:49:44 +00:00
António Fernandes 239f7ec4cd files-view: Drop .reveal_selection()
With one exception, it's called right after setting selection, so we
can simply do both things at the same time with set_cursor().

The exception is revealing the item for the popover to attach into,
for rectangle computation, which is easily solved by having the
reveal (i.e. scrolling) be done by the rectangle computing function.

This is one less virtual function for NautilusListBase to inherit,
as part of the plan from https://gitlab.gnome.org/GNOME/nautilus/-/issues/3042
2024-01-16 18:49:44 +00:00
António Fernandes bed07fd278 files-view: Drop unnecessary wrapper
Use compound literals instead. This simplifies the next commit.
2024-01-16 18:49:44 +00:00
António Fernandes 6df055c7c4 files-view: Minor selection optimizations
Mostly avoiding overhead of g_list_length() when we only need to know
whether the selection is empty or contains a single item. But also in a
few cases avoid allocating a file list at all by checking the selection
bitset directly or doing it only if needed (like the debug case).

While touching it, also unexport a function which is no longer used by
subclasses and remove its obsolete documentation comment.
2024-01-16 18:49:44 +00:00
António Fernandes d95944205e list-base: Optimize get_first_selected_item()
This removes another usage of nautilus_view_model_find(), which
is a performance liability.

Also reuse this helper function in another place where we were
already doing the same thing.
2024-01-16 18:49:44 +00:00