Commit graph

25291 commits

Author SHA1 Message Date
António Fernandes
746f9c4247 internal-place-file: Really don't access self pointer after destruction
We've avoided the trivial case of cancellation on destruction, as part of 
commit 16b81477b3 

But there may be cases where the async task returns an error even before it's cancelled,
but the async callback is only called in a future iteration where the file is already 
destroyed. So, handle that case too and add a warning while at it.

(cherry picked from commit 7d80a9ad823b05b961837fa5fbf729caa5e7ca99)
2024-06-10 23:24:11 +00:00
António Fernandes
da4dd182a1 window-slot: Import go up and down actions
To make them reusable in the upcoming FileChooser window.

Part of https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3413
2024-06-10 10:17:12 +00:00
António Fernandes
2d6f4b8280 window-slot: Import back/forward actions
This will allow them to be used by the upcoming FileChooser window.

Part of https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3413
2024-06-10 10:17:12 +00:00
António Fernandes
13ae2e6fd3 files-view: Don't add accels to application
Same change as for NautilusWindowSlot. Refer to parent commit.

Part of: https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3411
2024-06-10 10:17:12 +00:00
António Fernandes
9dbe8569c3 window-slot: Don't add accels to application
We've been using GtkApplication, through a NautilusApplication method,
to set accelerators (i.e., global shortctus which trigger regardless
of where the focus is on the application window).

This will not work if NautilusWindowSlot is added to a window which
is nor a GtkApplicationWindow instance, as will be the case for the
upcoming FileChooser window.

Let's instead add them to a shortcut controller in the slow, but with
a "managed" scope which allows it to trigger even if the focus is not
on the slot.

Part of: https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3411
2024-06-10 10:17:12 +00:00
António Fernandes
3f17995dbc window: Limit managed shortcuts to :child
In order for some window-level shortcuts to trigger on a FileChooser
dialog, which do not belong to NautilusApplication, we need to stop
using gtk_application_set_accels_for_action() and set the shortcuts
directly on widgets.

While at it, their GtkShortcutScope is to be changed from `GLOBAL`
to `MANAGED`. This gives us an opportunity to fully control their
scope and, thus, prevent them from being triggered while, e.g., an
AdwDialog is up.

Related to https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3411
2024-06-10 10:17:12 +00:00
Khalid Abu Shawarib
9edcd430c3 file-operations: Fix incorrect operation
The ternary operator has lower precedence than bitwise or and thus had
made the expression a tautology.
2024-06-08 23:25:37 +00:00
Khalid Abu Shawarib
78e22d0448 window-slot: Drop superflous code
These lines do nothing as explained in the previous commit.
2024-06-08 23:25:37 +00:00
Peter Eisenmann
e19923adf8 window-slot: Inline location loading helper function
The bigger code block of activating a pending file only applies for one
caller, so the helper function did not deduplicate any code and really
only created more overhead, making the code harder to follow.

One significant side affect of this refactoring is that we don't pass
`self->pending_selection` by value to `nautilus_view_set_selection()`.
This resolves a crash in the case when `nautilus_view_set_location()`
will reach a code [1] that uses and frees `self->pending_selection`,
thus leaving the pointer passed by value for selection to become a
dangling pointer if it was pointing to `self->pending_selection`.

[1] d046bf4a8b/src/nautilus-files-view.c (L3896)

Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/3036
2024-06-08 23:25:37 +00:00
Khalid Abu Shawarib
c57c9f57ae files-view: Fix heap overflow
Fix a heap overflow by designating the data type as a buffer instead
of a string in the case of a template copy and check for the operation
type to perform copying correctly.
2024-06-08 23:25:37 +00:00
Martin
2288345ba2 Update Slovenian translation 2024-06-08 21:22:03 +00:00
Automeris naranja
88a941ff74 file-properties-change-permissions: Modernize the UI
Use AdwPreferencesPage, AdwPreferencesGroup and AdwComboRow. Also,
add mnemonics.
2024-06-08 18:08:43 +00:00
António Fernandes
d98967693e general: Stop importing nautilus-window.h where unnecessary 2024-06-05 11:50:10 +01:00
António Fernandes
33aedd51fd window-slot: Drop :window property
We need NautilusWindowSlot to be reusable in the FileChooser window.

This means it cannot assume its parent is a NautilusWindow.

For NautilusWindowSlot code, rely on gtk_widget_get_root().
For NautilusApplication we can assume a NautilusWindow ancestor.

Part of: https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3402
2024-06-05 11:50:10 +01:00
António Fernandes
00019651b6 window-slot: Clean up location loading error handling
We have a whole branch of dead code under the condition that a window
is not visible. This is dead code because, as of GTK4, the :visible
property is TRUE by default; but even before that, I doubt the window
wasn't presented already before this callback.

The logic on this conditional branch is ancient[0] and employs rather
drastic measures: destroy the window if it failed to load its initial
location. At a later point[1], a special case hase been added not to
destroy the window if there is no other nautilus window. It would open
Home instead, or, failing that, the filesystem root. But if both fail,
it would still resort to destroying the window.

Not only is destroying the window unecessary, the special case of a
single application window assumes NautilusWindowSlot can only exist
inside a NautilusWindow (belonging to NautilusApplication). This is
going to be a problem for the FileChooser window, which will not be
a NautilusWindow, not belong to the NautilusApplication, but still
run in the same process.

Let's drop the dead branch. But salvage the handling of rare cases
where $HOME fails to load for some reason.

Part of https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3402

[0] commit 4ce7b8ead3
[1] commit 06f5c77133
2024-06-05 11:50:10 +01:00
António Fernandes
cc9374e87d files-view: Don't assume NautilusWindow ancestor
We don't need to, for a matter of fact. `gtk_widget_get_root()` is
just as effective and is going to make it easier to reuse in the
upcoming FileChoser window.

Part of: https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3402
2024-06-05 11:50:10 +01:00
António Fernandes
d1742d078d previewer: Manage window handles internally
We've been expecting NautilusFilesView to pass a window handle to
nautilus_previewer_call_show_file(), requiring it to call async
methods from NautilusWindow to get them.

There are a few problems with this approach:

  1. It's a layer violation for the view to call into the window.
     Not only is this conceptually wrong, it's keeping us from
     reusing the view in other windows which are not NautilusWindow
     instances, like as the upcoming FileChooser window.
  2. It's leaking details of the NautilusPreviewer2 D-Bus API into
     NautilusFilesView and NautilusWindow, namely the expected format
     of the window handle.
  3. Even though this format is a de-facto standard nowadays, we are
     not using it for anything else, so there is no value in keeping
     it in NautilusWindow API.
  4. Even if we start using it for other purposes, there it nothing
     specific to NautilusWindow in how to generate a window handle;
     it's the same process for any toplevel surface.
  5. Tying the window handle's validity to the lifetime of the
     NautilusWindow instance means we keep it exported even if no
     longer used by the previewer, and in theory we would use the
     same handle for multiple peers.

So, have NautilusFilesView pass a generic GtkRoot pointer instead
and handle the exporting and unexporting lifetime of window handles
in the previewer glue code instead.

The NautilusWindow API, no unused, is also removed. If the need arises
in the future to reuse this export/unexport logic, we can always move
it into ui-utilities.c or something like that.

Part of: https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3402
2024-06-05 11:50:10 +01:00
António Fernandes
0c5d28bcd6 previewer: Drop ununsed XID parameter
It's been supperceeded by the window handle string, which, for X11
windows, is a concatenation of "x11:" and the XID.
2024-06-05 11:50:10 +01:00
António Fernandes
9698bcaccf history-controls: Don't assume NautilusWindow
Middle click on back/forward buttons opens the previous/next location
in a new tab.

We want to reuse the history controls for FileChooser window, but it
will neither have tabs nor be a NautilusWindow at all.

So, make this feature conditional on the root widget being an instance
of NautilusWindow.

Part of: https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3402
2024-06-05 11:50:10 +01:00
António Fernandes
c036a1178c pathbar: Don't call NautilusWindow nor NautilusApplication
We want to make the pathbar reusable for the FileChooser window,
which is neither going to be a NautilusWindow nor part of the
NautilusApplication instance.

But we don't really need anything from the application or window
classes which cannot be done directly with the slot class. And
the slot is going to be reused in FileChooser too.

In order to have access to the slot, expect the pathbar owner
(currently only NautilusToolbar) to set it as a property. The
FileChooser is going to be able to set the slot itself as well.

Part of: https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3402
2024-06-05 11:50:10 +01:00
António Fernandes
a501907f70 toolbar: Have PathBar and LocationEntry in UI template
We have "container" boxes in the .ui file to which we add the
actual widgets in code.

I believe this was done back when we desired these UI files to
be editable in Glade, which didn't know our custom widgets.

But we no longer care about that, so let's do everything in the
UI template. This will make the next commit simpler by enabling
bindings to be declared in the UI template as well.
2024-06-05 11:50:10 +01:00
António Fernandes
c3d4cbdd0e files-view: Stop getting active slot from the window
We can ask the slot directly whether it is the active one.

This removes one NautilusWindow method call from inner widgets,
which is a layer violation and gets in the way of reusing them
for the upcoming FileChooser window.

Part of: https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3402
2024-06-05 11:50:10 +01:00
António Fernandes
095f699da1 window-slot: Import the stop and reload actions
These actions have been living in the window, but they are actually
implemented by the slot, and conceptually they are slot actions.

Import them in preparation to use them also in the FileChooser window.

Part of https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3413
2024-06-05 11:50:10 +01:00
António Fernandes
13e0bba7ff window-slot: Don't manually sync allow-stop
We do so in two cases: active slot change, or :allow-stop change.

Have the window handle both cases: it is the one who changes active
slot already, and listening to NautilusWindowSlot:allow-stop changes
is trivial.

This resolves a layer violation and is one fewer NautilusWindow
method being called by NautilusWindowSlot, preparing the later for
reuse in the FileChooser portal dialog window.

Part of https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3402
2024-06-05 11:50:10 +01:00
António Fernandes
0f52276179 window: Drop nautilus_window_reset_menus()
This is used by NautilusFilesView, which is a layer violation. But
it's also useless, because the only thing it does is sync the
start/reload actions, and that's already done by the slot calling
nautilus_window_sync_allow_stop() anyway in the same situations
(i.e. when view starts or ends loading).

Drop it, to prepare the view to be reusable in FileChooser dialogs.

Part of: https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3402
2024-06-05 11:50:10 +01:00
António Fernandes
3efa7fa6e8 window-slot: Stop sync'ing location widgets
Like the previous commit, this resolves a layer violation and paves the
way for NautilusWindowSlot to be reusable in future FileChooser dialog,
by not using NautilusWindow methods.

On this particular case, we have been updating window widgets which
depend of current location whenever the active lot changes or the the
location of the active slot changes.

On the first case, the window is in charge of setting the active slot,
and in the second case it is already listening to the locatio change.
In both cases, on_location_changed() in nautilus-window.c is called.

So, sync the location widgets from on_location_changed() and stop
exposing it in the header.

Part of https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3402
2024-06-05 11:50:10 +01:00
António Fernandes
22d214e818 window: Bind title to expression
We rely on the slots calling sync_title() on the window, which is
wasteful (if the slot is not active), fragile, and a layer violation.

We already have properties for all of these pieces, so let's use
expressions. This also helps with preparation for FileChooser window,
as we need NautilusWindowSlot to stop calling NautilusWindow method,
as part of https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3402
2024-06-05 11:50:10 +01:00
António Fernandes
30194a1fdc window-slot: Stop calling nautilus_window_get_active_slot()
We call it to assert the slot being set as inactive is (still) active.

Not only is this counter intuitive, but it also relies on order of
events in nautilus_window_set_active_slot(). Therefore, the assertion
is useless because we already rely on NautilusWindow doing it right.

Instead, make the caller of nautilus_window_slot_set_active() (i.e. the
window) responsible for ensuring consistency. To ensure it is not set
by any other means, make the property read-only.

One less NautilusWindow method being called by NautilusWindowSlot, as
part of https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3402
2024-06-05 11:50:10 +01:00
António Fernandes
bb9231b6a0 window-slot: Don't access the tab view
The slot accesses the window's tab view to change the selected tab.

This is a layer violation, which is both completely unnecessary and
is getting in the way of reusing the slot widget in a tabs-less
window (such as the upcoming FileChooser window).

So, have NautilusWindow manage the selected tab directly. This is
one less NautilusWindow method being called by NautilusWindowSlot.

Part of https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3402
2024-06-05 11:50:09 +01:00
António Fernandes
6bd4e06faa window-slot: Rework and document grab_focus() call
We'v been relying on a gtk_widget_grab_focus() call to avoid broken
focus states after view (re)loading.

But there is one particular case where we must not do it: if the
popover menu is shown. This is a rare situation which is currently
only possible to trigger by pressing [Spacebar] while the "Show
Hidden Files" menu item has focus.

But this currently relies on the slot calling a NautilusWindow method,
which is a layer violation which is getting in the way of reusing
NautilusWindowSlot in the FileChooser window[4].

Let's use generic GTK/GDK API to assess wether the menu is shown,
and drop the NautilusWindow method.

Originally I've just removed the grab_focus() call, but came to
realize it was still needed, so let's also document my findings here.

Part of: https://gitlab.gnome.org/GNOME/nautilus/-/work_items/3402
2024-06-05 11:50:09 +01:00
António Fernandes
c960cfa439 files-view: Make logic order look intentional
The selection check is done after the emission of delayed singals which
may change it, as per commit 09f4546d50.

However, nowadays we have a habit of combining declaration and
assingment into a single statement. So, during future hacking, one
might be tempted to move the assignments into the declaration lines,
effectively reverting that commit.

Let's keep declaration and assingment together but after that call,
and also add a comment to make it clear this order is intentional.
2024-06-04 23:09:54 +01:00
António Fernandes
e5e53ea2c9 window: Don't leak file 2024-06-04 22:29:20 +01:00
Martin
10d823295a Update Slovenian translation 2024-06-04 07:33:02 +00:00
Khalid Abu Shawarib
d4bc511f69 test/file-utilities-get-common-filename-prefix: Add tests
Adds tests for `nautilus_get_common_filename_prefix()`
2024-06-04 01:59:56 +00:00
Khalid Abu Shawarib
89ae1730b9 test/file-utilities-get-common-filename-prefix: Increase test level
Embed the existing tests in a new category in preperation for
adding another one.
2024-06-04 01:59:56 +00:00
António Fernandes
fceb9ee923 window: Drop actual wayland export handle
We've not been dropping handles properly, and we've been getting
warnings from gdk_wayland_toplevel_real_unexport_handle() as such.

This is because we are passing the "wayland:"-prefixed string, but
the actual wayland export handle is only the part after the colon.

Fixes a regression from commit ad865de618


(cherry picked from commit 4fc8812040520f40ef01f8b016c02018077e4c23)
2024-06-04 01:43:05 +00:00
José Guilherme
fa7b77fe6c window: Add Star Folder context menu entries
Add starring and unstarring actions to the pathbar context menu.

In order to disallow starring the home directory, add a new function to
the tag manager, which checks if a given directory can be starred.
2024-06-04 01:42:36 +00:00
piegames
626a04509c Floating-bar: Make background slightly darker
This improves the contrast against the background, and is consistent
with the background color of the path bar.
2024-06-03 20:28:32 +00:00
António Fernandes
16b81477b3 internal-place-file: Don't access self pointer after destruction
If the file is destroyed before the mount operation is completed,
we cancel the mount operation.

However, due to the nature of GAsyncResult, the callback is still
called in a future iteration of the main loop, when the file is
long gone. But since it's passed as callback data, we try to
cast it, with predictably bad results.

Access the file pointer only if the operation hasn't been cancelled.
2024-06-02 17:18:55 +01:00
António Fernandes
12980ee1bd files-view: Update actions immediately on selection change
In the network view, if the row is not selected, clicking the unmount
button does nothing. Indeed, the action is still disabled, despite an
elligible item being selected already.

This happens because the actions state is updated on idle along with
the context menus. This is reasonable as the context menus update can
be expensive.

However, not updating actions state imimediately is unexpected, so
let's immediately update them when selection changes.
2024-06-02 15:39:09 +00:00
António Fernandes
e4deb16def files-view: Disable a few more action on network view
The Properties dialog is useless unless locations are mounted.

Also, disable a few current location menu actions.
2024-06-02 15:39:09 +00:00
António Fernandes
37634b960b files-view: Add network view actions 2024-06-02 15:39:09 +00:00
António Fernandes
fcbfcd4c5d files-view: Omit some menu sections on Network View
These actions do not make sense on the virtual files of that view.
2024-06-02 15:39:09 +00:00
António Fernandes
6d47c4c1f3 network-view: Disable background context menu
It's useless here.
2024-06-02 15:39:09 +00:00
António Fernandes
0ff13a90f0 files-view: Add network view empty state 2024-06-02 15:39:09 +00:00
António Fernandes
3494cd79df network-cell: Show spinner while mounting/unmounting 2024-06-02 15:39:09 +00:00
António Fernandes
c674046e29 files-view: Prevent use-after-free with mount and stop
Unmount and eject are already doing this since commit 80dd8fb8ff

Let's do the same for mount and stop, and use g_autoptr() to emphasize
the callback taking ownership of the reference passed to the method.
2024-06-02 15:39:09 +00:00
António Fernandes
da79c2f3bf files-view: Update file mount info when mounted
Otherwise, nautilus_file_can_unmount() will still return FALSE for
a file which is already mounted, until the can-unmount attribute
is updated asynchronously by the file monitor.

This is needed for the next commit to be able to check whether
unmount is possible as soon as the mount operation completes.
2024-06-02 15:39:09 +00:00
António Fernandes
7e6af9d61d general: Introduce Network place
And request network view for network view directory.

Remember whether the previous view was grid or list, to preserve
per-window settings.
2024-06-02 15:39:09 +00:00
António Fernandes
d1437e9fd6 network-view: Introduce new view and cells
This is the replacement for the Other Locations.

See https://gitlab.gnome.org/GNOME/nautilus/-/issues/2785
2024-06-02 15:39:09 +00:00