[gtk: 1/2] gtkplacessidebar: Show busy spinner in sidebar row during mount ops
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk: 1/2] gtkplacessidebar: Show busy spinner in sidebar row during mount ops
- Date: Mon, 30 Jul 2018 12:06:16 +0000 (UTC)
commit 791da76ae16304144c07a0d8099146cb42b75aed
Author: segfault <segfault riseup net>
Date: Sun Jul 22 13:47:46 2018 +0200
gtkplacessidebar: Show busy spinner in sidebar row during mount ops
gtk/gtkplacessidebar.c | 38 ++++++++++++++++++++++++++++----------
gtk/gtksidebarrow.c | 12 ++++++++++++
gtk/gtksidebarrowprivate.h | 2 ++
gtk/ui/gtksidebarrow.ui | 8 ++++++++
4 files changed, 50 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index 3ffe5ec3f1..20d32f47d1 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -2350,7 +2350,8 @@ volume_mount_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
- GtkPlacesSidebar *sidebar = GTK_PLACES_SIDEBAR (user_data);
+ GtkSidebarRow *row = GTK_SIDEBAR_ROW (user_data);
+ GtkPlacesSidebar *sidebar;
GVolume *volume;
GError *error;
gchar *primary;
@@ -2358,6 +2359,7 @@ volume_mount_cb (GObject *source_object,
GMount *mount;
volume = G_VOLUME (source_object);
+ g_object_get (row, "sidebar", &sidebar, NULL);
error = NULL;
if (!g_volume_mount_finish (volume, result, &error))
@@ -2375,6 +2377,7 @@ volume_mount_cb (GObject *source_object,
}
sidebar->mounting = FALSE;
+ gtk_sidebar_row_set_busy (row, FALSE);
mount = g_volume_get_mount (volume);
if (mount != NULL)
@@ -2388,32 +2391,42 @@ volume_mount_cb (GObject *source_object,
g_object_unref (G_OBJECT (mount));
}
+ g_object_unref (row);
g_object_unref (sidebar);
}
static void
-mount_volume (GtkPlacesSidebar *sidebar,
- GVolume *volume)
+mount_volume (GtkSidebarRow *row,
+ GVolume *volume)
{
+ GtkPlacesSidebar *sidebar;
GMountOperation *mount_op;
+ g_object_get (row, "sidebar", &sidebar, NULL);
+
mount_op = get_mount_operation (sidebar);
g_mount_operation_set_password_save (mount_op, G_PASSWORD_SAVE_FOR_SESSION);
+ g_object_ref (row);
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
-open_drive (GtkPlacesSidebar *sidebar,
+open_drive (GtkSidebarRow *row,
GDrive *drive,
GtkPlacesOpenFlags open_flags)
{
+ GtkPlacesSidebar *sidebar;
+
+ g_object_get (row, "sidebar", &sidebar, NULL);
+
if (drive != NULL &&
(g_drive_can_start (drive) || g_drive_can_start_degraded (drive)))
{
GMountOperation *mount_op;
+ gtk_sidebar_row_set_busy (row, TRUE);
mount_op = get_mount_operation (sidebar);
g_drive_start (drive, G_DRIVE_START_NONE, mount_op, NULL, drive_start_from_bookmark_cb, NULL);
g_object_unref (mount_op);
@@ -2421,15 +2434,20 @@ open_drive (GtkPlacesSidebar *sidebar,
}
static void
-open_volume (GtkPlacesSidebar *sidebar,
+open_volume (GtkSidebarRow *row,
GVolume *volume,
GtkPlacesOpenFlags open_flags)
{
+ GtkPlacesSidebar *sidebar;
+
+ g_object_get (row, "sidebar", &sidebar, NULL);
+
if (volume != NULL && !sidebar->mounting)
{
sidebar->mounting = TRUE;
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)
{
- open_volume (sidebar, volume, open_flags);
+ open_volume (row, volume, open_flags);
}
else if (drive != NULL)
{
- open_drive (sidebar, drive, open_flags);
+ open_drive (row, drive, open_flags);
}
g_object_unref (sidebar);
@@ -2821,7 +2839,7 @@ mount_shortcut_cb (GSimpleAction *action,
NULL);
if (volume != NULL)
- mount_volume (sidebar, volume);
+ mount_volume (sidebar->context_row, volume);
g_object_unref (volume);
}
diff --git a/gtk/gtksidebarrow.c b/gtk/gtksidebarrow.c
index 590ff0c948..3623b67847 100644
--- a/gtk/gtksidebarrow.c
+++ b/gtk/gtksidebarrow.c
@@ -28,6 +28,7 @@
#include "gtkrevealer.h"
#include "gtkselection.h"
#include "gtkintl.h"
+#include "gtkspinner.h"
#ifdef HAVE_CLOUDPROVIDERS
#include <cloudproviders/cloudprovidersaccount.h>
@@ -56,6 +57,7 @@ struct _GtkSidebarRow
gboolean placeholder;
GtkPlacesSidebar *sidebar;
GtkWidget *revealer;
+ GtkWidget *busy_spinner;
};
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, eject_button);
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_set_css_name (widget_class, I_("row"));
@@ -644,3 +647,12 @@ gtk_sidebar_row_get_eject_button (GtkSidebarRow *self)
{
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);
+}
diff --git a/gtk/gtksidebarrowprivate.h b/gtk/gtksidebarrowprivate.h
index f9337572e6..7ac9294e4f 100644
--- a/gtk/gtksidebarrowprivate.h
+++ b/gtk/gtksidebarrowprivate.h
@@ -53,6 +53,8 @@ void gtk_sidebar_row_set_start_icon (GtkSidebarRow *self,
GIcon *icon);
void gtk_sidebar_row_set_end_icon (GtkSidebarRow *self,
GIcon *icon);
+void gtk_sidebar_row_set_busy (GtkSidebarRow *row,
+ gboolean is_busy);
G_END_DECLS
diff --git a/gtk/ui/gtksidebarrow.ui b/gtk/ui/gtksidebarrow.ui
index 1b27223261..aebe097e1b 100644
--- a/gtk/ui/gtksidebarrow.ui
+++ b/gtk/ui/gtksidebarrow.ui
@@ -54,6 +54,14 @@
</style>
</object>
</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>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]