forked from AuroraMiddleware/gtk
Merge branch 'gtk-4-add-spinner-to-sidebar-row' into 'master'
gtkplacessidebar: Show busy spinner in sidebar row during mount ops See merge request GNOME/gtk!261
This commit is contained in:
commit
c5afea0c6b
@ -2350,7 +2350,8 @@ volume_mount_cb (GObject *source_object,
|
|||||||
GAsyncResult *result,
|
GAsyncResult *result,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GtkPlacesSidebar *sidebar = GTK_PLACES_SIDEBAR (user_data);
|
GtkSidebarRow *row = GTK_SIDEBAR_ROW (user_data);
|
||||||
|
GtkPlacesSidebar *sidebar;
|
||||||
GVolume *volume;
|
GVolume *volume;
|
||||||
GError *error;
|
GError *error;
|
||||||
gchar *primary;
|
gchar *primary;
|
||||||
@ -2358,6 +2359,7 @@ volume_mount_cb (GObject *source_object,
|
|||||||
GMount *mount;
|
GMount *mount;
|
||||||
|
|
||||||
volume = G_VOLUME (source_object);
|
volume = G_VOLUME (source_object);
|
||||||
|
g_object_get (row, "sidebar", &sidebar, NULL);
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
if (!g_volume_mount_finish (volume, result, &error))
|
if (!g_volume_mount_finish (volume, result, &error))
|
||||||
@ -2375,6 +2377,7 @@ volume_mount_cb (GObject *source_object,
|
|||||||
}
|
}
|
||||||
|
|
||||||
sidebar->mounting = FALSE;
|
sidebar->mounting = FALSE;
|
||||||
|
gtk_sidebar_row_set_busy (row, FALSE);
|
||||||
|
|
||||||
mount = g_volume_get_mount (volume);
|
mount = g_volume_get_mount (volume);
|
||||||
if (mount != NULL)
|
if (mount != NULL)
|
||||||
@ -2388,32 +2391,42 @@ volume_mount_cb (GObject *source_object,
|
|||||||
g_object_unref (G_OBJECT (mount));
|
g_object_unref (G_OBJECT (mount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_object_unref (row);
|
||||||
g_object_unref (sidebar);
|
g_object_unref (sidebar);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mount_volume (GtkPlacesSidebar *sidebar,
|
mount_volume (GtkSidebarRow *row,
|
||||||
GVolume *volume)
|
GVolume *volume)
|
||||||
{
|
{
|
||||||
|
GtkPlacesSidebar *sidebar;
|
||||||
GMountOperation *mount_op;
|
GMountOperation *mount_op;
|
||||||
|
|
||||||
|
g_object_get (row, "sidebar", &sidebar, NULL);
|
||||||
|
|
||||||
mount_op = get_mount_operation (sidebar);
|
mount_op = get_mount_operation (sidebar);
|
||||||
g_mount_operation_set_password_save (mount_op, G_PASSWORD_SAVE_FOR_SESSION);
|
g_mount_operation_set_password_save (mount_op, G_PASSWORD_SAVE_FOR_SESSION);
|
||||||
|
|
||||||
|
g_object_ref (row);
|
||||||
g_object_ref (sidebar);
|
g_object_ref (sidebar);
|
||||||
g_volume_mount (volume, 0, mount_op, NULL, volume_mount_cb, sidebar);
|
g_volume_mount (volume, 0, mount_op, NULL, volume_mount_cb, row);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
open_drive (GtkPlacesSidebar *sidebar,
|
open_drive (GtkSidebarRow *row,
|
||||||
GDrive *drive,
|
GDrive *drive,
|
||||||
GtkPlacesOpenFlags open_flags)
|
GtkPlacesOpenFlags open_flags)
|
||||||
{
|
{
|
||||||
|
GtkPlacesSidebar *sidebar;
|
||||||
|
|
||||||
|
g_object_get (row, "sidebar", &sidebar, NULL);
|
||||||
|
|
||||||
if (drive != NULL &&
|
if (drive != NULL &&
|
||||||
(g_drive_can_start (drive) || g_drive_can_start_degraded (drive)))
|
(g_drive_can_start (drive) || g_drive_can_start_degraded (drive)))
|
||||||
{
|
{
|
||||||
GMountOperation *mount_op;
|
GMountOperation *mount_op;
|
||||||
|
|
||||||
|
gtk_sidebar_row_set_busy (row, TRUE);
|
||||||
mount_op = get_mount_operation (sidebar);
|
mount_op = get_mount_operation (sidebar);
|
||||||
g_drive_start (drive, G_DRIVE_START_NONE, mount_op, NULL, drive_start_from_bookmark_cb, NULL);
|
g_drive_start (drive, G_DRIVE_START_NONE, mount_op, NULL, drive_start_from_bookmark_cb, NULL);
|
||||||
g_object_unref (mount_op);
|
g_object_unref (mount_op);
|
||||||
@ -2421,15 +2434,20 @@ open_drive (GtkPlacesSidebar *sidebar,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
open_volume (GtkPlacesSidebar *sidebar,
|
open_volume (GtkSidebarRow *row,
|
||||||
GVolume *volume,
|
GVolume *volume,
|
||||||
GtkPlacesOpenFlags open_flags)
|
GtkPlacesOpenFlags open_flags)
|
||||||
{
|
{
|
||||||
|
GtkPlacesSidebar *sidebar;
|
||||||
|
|
||||||
|
g_object_get (row, "sidebar", &sidebar, NULL);
|
||||||
|
|
||||||
if (volume != NULL && !sidebar->mounting)
|
if (volume != NULL && !sidebar->mounting)
|
||||||
{
|
{
|
||||||
sidebar->mounting = TRUE;
|
sidebar->mounting = TRUE;
|
||||||
sidebar->go_to_after_mount_open_flags = open_flags;
|
sidebar->go_to_after_mount_open_flags = open_flags;
|
||||||
mount_volume (sidebar, volume);
|
gtk_sidebar_row_set_busy (row, TRUE);
|
||||||
|
mount_volume (row, volume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2481,11 +2499,11 @@ open_row (GtkSidebarRow *row,
|
|||||||
}
|
}
|
||||||
else if (volume != NULL)
|
else if (volume != NULL)
|
||||||
{
|
{
|
||||||
open_volume (sidebar, volume, open_flags);
|
open_volume (row, volume, open_flags);
|
||||||
}
|
}
|
||||||
else if (drive != NULL)
|
else if (drive != NULL)
|
||||||
{
|
{
|
||||||
open_drive (sidebar, drive, open_flags);
|
open_drive (row, drive, open_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (sidebar);
|
g_object_unref (sidebar);
|
||||||
@ -2821,7 +2839,7 @@ mount_shortcut_cb (GSimpleAction *action,
|
|||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (volume != NULL)
|
if (volume != NULL)
|
||||||
mount_volume (sidebar, volume);
|
mount_volume (sidebar->context_row, volume);
|
||||||
|
|
||||||
g_object_unref (volume);
|
g_object_unref (volume);
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "gtkrevealer.h"
|
#include "gtkrevealer.h"
|
||||||
#include "gtkselection.h"
|
#include "gtkselection.h"
|
||||||
#include "gtkintl.h"
|
#include "gtkintl.h"
|
||||||
|
#include "gtkspinner.h"
|
||||||
|
|
||||||
#ifdef HAVE_CLOUDPROVIDERS
|
#ifdef HAVE_CLOUDPROVIDERS
|
||||||
#include <cloudproviders/cloudprovidersaccount.h>
|
#include <cloudproviders/cloudprovidersaccount.h>
|
||||||
@ -56,6 +57,7 @@ struct _GtkSidebarRow
|
|||||||
gboolean placeholder;
|
gboolean placeholder;
|
||||||
GtkPlacesSidebar *sidebar;
|
GtkPlacesSidebar *sidebar;
|
||||||
GtkWidget *revealer;
|
GtkWidget *revealer;
|
||||||
|
GtkWidget *busy_spinner;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (GtkSidebarRow, gtk_sidebar_row, GTK_TYPE_LIST_BOX_ROW)
|
G_DEFINE_TYPE (GtkSidebarRow, gtk_sidebar_row, GTK_TYPE_LIST_BOX_ROW)
|
||||||
@ -613,6 +615,7 @@ gtk_sidebar_row_class_init (GtkSidebarRowClass *klass)
|
|||||||
gtk_widget_class_bind_template_child (widget_class, GtkSidebarRow, label_widget);
|
gtk_widget_class_bind_template_child (widget_class, GtkSidebarRow, label_widget);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GtkSidebarRow, eject_button);
|
gtk_widget_class_bind_template_child (widget_class, GtkSidebarRow, eject_button);
|
||||||
gtk_widget_class_bind_template_child (widget_class, GtkSidebarRow, revealer);
|
gtk_widget_class_bind_template_child (widget_class, GtkSidebarRow, revealer);
|
||||||
|
gtk_widget_class_bind_template_child (widget_class, GtkSidebarRow, busy_spinner);
|
||||||
|
|
||||||
gtk_widget_class_bind_template_callback (widget_class, on_child_revealed);
|
gtk_widget_class_bind_template_callback (widget_class, on_child_revealed);
|
||||||
gtk_widget_class_set_css_name (widget_class, I_("row"));
|
gtk_widget_class_set_css_name (widget_class, I_("row"));
|
||||||
@ -644,3 +647,12 @@ gtk_sidebar_row_get_eject_button (GtkSidebarRow *self)
|
|||||||
{
|
{
|
||||||
return self->eject_button;
|
return self->eject_button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gtk_sidebar_row_set_busy (GtkSidebarRow *row,
|
||||||
|
gboolean is_busy)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GTK_IS_SIDEBAR_ROW (row));
|
||||||
|
|
||||||
|
gtk_widget_set_visible (row->busy_spinner, is_busy);
|
||||||
|
}
|
||||||
|
@ -53,6 +53,8 @@ void gtk_sidebar_row_set_start_icon (GtkSidebarRow *self,
|
|||||||
GIcon *icon);
|
GIcon *icon);
|
||||||
void gtk_sidebar_row_set_end_icon (GtkSidebarRow *self,
|
void gtk_sidebar_row_set_end_icon (GtkSidebarRow *self,
|
||||||
GIcon *icon);
|
GIcon *icon);
|
||||||
|
void gtk_sidebar_row_set_busy (GtkSidebarRow *row,
|
||||||
|
gboolean is_busy);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@ -54,6 +54,14 @@
|
|||||||
</style>
|
</style>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSpinner" id="busy_spinner">
|
||||||
|
<property name="active">1</property>
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="margin-start">4px</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
Loading…
Reference in New Issue
Block a user