network-cell: Show spinner while mounting/unmounting

This commit is contained in:
António Fernandes 2024-01-21 16:38:45 +00:00
parent c674046e29
commit 3494cd79df
3 changed files with 33 additions and 6 deletions

View file

@ -6829,8 +6829,11 @@ file_mount_callback (NautilusFile *file,
gpointer callback_data)
{
g_autoptr (NautilusFilesView) self = NAUTILUS_FILES_VIEW (callback_data);
NautilusFilesViewPrivate *priv = nautilus_files_view_get_instance_private (self);
NautilusViewItem *item = nautilus_view_model_get_item_for_file (priv->model, file);
nautilus_file_invalidate_attributes (file, NAUTILUS_FILE_ATTRIBUTE_MOUNT);
nautilus_view_item_set_loading (item, FALSE);
if (error != NULL &&
(error->domain != G_IO_ERROR ||
@ -6855,6 +6858,10 @@ file_unmount_callback (NautilusFile *file,
gpointer callback_data)
{
g_autoptr (NautilusFilesView) self = NAUTILUS_FILES_VIEW (callback_data);
NautilusFilesViewPrivate *priv = nautilus_files_view_get_instance_private (self);
NautilusViewItem *item = nautilus_view_model_get_item_for_file (priv->model, file);
nautilus_view_item_set_loading (item, FALSE);
if (error != NULL &&
(error->domain != G_IO_ERROR ||
@ -6919,13 +6926,12 @@ action_mount_volume (GSimpleAction *action,
GVariant *state,
gpointer user_data)
{
NautilusFilesView *view = NAUTILUS_FILES_VIEW (user_data);
NautilusFilesViewPrivate *priv = nautilus_files_view_get_instance_private (view);
NautilusFile *file;
GList *selection, *l;
NautilusFilesView *view;
GMountOperation *mount_op;
view = NAUTILUS_FILES_VIEW (user_data);
selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
for (l = selection; l != NULL; l = l->next)
{
@ -6933,6 +6939,9 @@ action_mount_volume (GSimpleAction *action,
if (nautilus_file_can_mount (file))
{
NautilusViewItem *item = nautilus_view_model_get_item_for_file (priv->model, file);
nautilus_view_item_set_loading (item, TRUE);
mount_op = gtk_mount_operation_new (nautilus_files_view_get_containing_window (view));
g_mount_operation_set_password_save (mount_op, G_PASSWORD_SAVE_FOR_SESSION);
nautilus_file_mount (file, mount_op, NULL,
@ -6949,12 +6958,11 @@ action_unmount_volume (GSimpleAction *action,
GVariant *state,
gpointer user_data)
{
NautilusFilesView *view = NAUTILUS_FILES_VIEW (user_data);
NautilusFilesViewPrivate *priv = nautilus_files_view_get_instance_private (view);
NautilusFile *file;
g_autolist (NautilusFile) selection = NULL;
GList *l;
NautilusFilesView *view;
view = NAUTILUS_FILES_VIEW (user_data);
selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
@ -6964,6 +6972,9 @@ action_unmount_volume (GSimpleAction *action,
if (nautilus_file_can_unmount (file))
{
GMountOperation *mount_op;
NautilusViewItem *item = nautilus_view_model_get_item_for_file (priv->model, file);
nautilus_view_item_set_loading (item, TRUE);
mount_op = gtk_mount_operation_new (nautilus_files_view_get_containing_window (view));
nautilus_file_unmount (file, mount_op, NULL,
file_unmount_callback, g_object_ref (view));

View file

@ -87,6 +87,8 @@ nautilus_network_cell_init (NautilusNetworkCell *self)
/* Connect automatically to an item. */
self->item_signal_group = g_signal_group_new (NAUTILUS_TYPE_VIEW_ITEM);
g_signal_group_connect_swapped (self->item_signal_group, "notify::loading",
(GCallback) on_file_changed, self);
g_signal_group_connect_swapped (self->item_signal_group, "file-changed",
(GCallback) on_file_changed, self);
g_signal_connect_object (self->item_signal_group, "bind",

View file

@ -56,6 +56,20 @@
</child>
</object>
</child>
<child>
<object class="GtkSpinner" id="spinner">
<binding name="spinning">
<lookup name="loading">
<lookup name="item">NautilusNetworkCell</lookup>
</lookup>
</binding>
<binding name="visible">
<lookup name="loading">
<lookup name="item">NautilusNetworkCell</lookup>
</lookup>
</binding>
</object>
</child>
<child>
<object class="GtkButton" id="unmount_button">
<property name="tooltip-text" translatable="yes">Disconnect</property>