[gnome-disk-utility/gnome-3-28] Query NTFS tooling from UDisks
- From: Kai Lüke <kailueke src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility/gnome-3-28] Query NTFS tooling from UDisks
- Date: Thu, 31 May 2018 09:23:12 +0000 (UTC)
commit 0c66a9ebba6fe348b973b6cb43e706bd427ecf8f
Author: Kai Lüke <kailueke riseup net>
Date: Wed May 30 19:10:33 2018 +0900
Query NTFS tooling from UDisks
Disks queried for mkntfs in the $PATH directly
which does not work for non-sudoers.
Port the gdu_utils_is_ntfs_available function
to ask UDisks 2.7.2 (if available) whether
NTFS creation is supported.
https://gitlab.gnome.org/GNOME/gnome-disk-utility/issues/83
(cherry picked from commit 27d1bcb019e640509efd0646fe6ebadc7c260e62)
src/disks/gducreatefilesystempage.c | 6 +++---
src/disks/gducreatefilesystempage.h | 3 ++-
src/disks/gducreateformatdialog.c | 2 +-
src/libgdu/gduutils.c | 15 ++++++++++++++-
src/libgdu/gduutils.h | 2 +-
5 files changed, 21 insertions(+), 7 deletions(-)
---
diff --git a/src/disks/gducreatefilesystempage.c b/src/disks/gducreatefilesystempage.c
index f7ce643f..c4b5cd8d 100644
--- a/src/disks/gducreatefilesystempage.c
+++ b/src/disks/gducreatefilesystempage.c
@@ -183,7 +183,7 @@ on_fs_type_changed (GtkToggleButton *object, gpointer user_data)
}
GduCreateFilesystemPage *
-gdu_create_filesystem_page_new (gboolean show_custom, UDisksDrive *drive)
+gdu_create_filesystem_page_new (UDisksClient *client, gboolean show_custom, UDisksDrive *drive)
{
GduCreateFilesystemPage *page;
GduCreateFilesystemPagePrivate *priv;
@@ -208,7 +208,7 @@ gdu_create_filesystem_page_new (gboolean show_custom, UDisksDrive *drive)
/* default FAT for flash and disks/media smaller than 20G (assumed to be flash cards) */
if (gdu_utils_is_flash (drive) ||
udisks_drive_get_size (drive) < 20UL * 1000UL*1000UL*1000UL ||
- !gdu_utils_is_ntfs_available ()
+ !gdu_utils_is_ntfs_available (client)
)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->all_radiobutton), TRUE);
@@ -219,7 +219,7 @@ gdu_create_filesystem_page_new (gboolean show_custom, UDisksDrive *drive)
}
}
- gtk_widget_set_sensitive (GTK_WIDGET (priv->windows_radiobutton), gdu_utils_is_ntfs_available ());
+ gtk_widget_set_sensitive (GTK_WIDGET (priv->windows_radiobutton), gdu_utils_is_ntfs_available (client));
return page;
}
diff --git a/src/disks/gducreatefilesystempage.h b/src/disks/gducreatefilesystempage.h
index 3dfd29dc..af38c055 100644
--- a/src/disks/gducreatefilesystempage.h
+++ b/src/disks/gducreatefilesystempage.h
@@ -17,7 +17,8 @@ G_BEGIN_DECLS
#define GDU_TYPE_CREATE_FILESYSTEM_PAGE gdu_create_filesystem_page_get_type ()
G_DECLARE_FINAL_TYPE (GduCreateFilesystemPage, gdu_create_filesystem_page, GDU, CREATE_FILESYSTEM_PAGE,
GtkGrid)
-GduCreateFilesystemPage *gdu_create_filesystem_page_new (gboolean show_custom,
+GduCreateFilesystemPage *gdu_create_filesystem_page_new (UDisksClient *client,
+ gboolean show_custom,
UDisksDrive *drive);
const gchar * gdu_create_filesystem_page_get_name (GduCreateFilesystemPage *page);
diff --git a/src/disks/gducreateformatdialog.c b/src/disks/gducreateformatdialog.c
index e09d4cf1..626b9489 100644
--- a/src/disks/gducreateformatdialog.c
+++ b/src/disks/gducreateformatdialog.c
@@ -440,7 +440,7 @@ gdu_create_format_show (UDisksClient *client,
data->partition_page = NULL;
}
- data->filesystem_page = gdu_create_filesystem_page_new (show_custom, data->drive);
+ data->filesystem_page = gdu_create_filesystem_page_new (data->client, show_custom, data->drive);
gtk_stack_add_titled (data->stack, GTK_WIDGET (data->filesystem_page), FORMAT_PAGE, _("Format Volume"));
g_signal_connect (data->filesystem_page, "notify::complete", G_CALLBACK (update_dialog), data);
data->other_page = gdu_create_other_page_new (data->client);
diff --git a/src/libgdu/gduutils.c b/src/libgdu/gduutils.c
index 21ce36f9..c1093e16 100644
--- a/src/libgdu/gduutils.c
+++ b/src/libgdu/gduutils.c
@@ -872,18 +872,31 @@ gdu_utils_show_confirmation (GtkWindow *parent_window,
/* ---------------------------------------------------------------------------------------------------- */
gboolean
-gdu_utils_is_ntfs_available (void)
+gdu_utils_is_ntfs_available (UDisksClient *client)
{
static gsize once = 0;
static gboolean available = FALSE;
if (g_once_init_enter (&once))
{
+#ifdef HAVE_UDISKS2_7_2
+ GVariant *out_available;
+ gchar *missing_util;
+
+ if (udisks_manager_call_can_format_sync (udisks_client_get_manager (client),
+ "ntfs", &out_available, NULL, NULL))
+ {
+ g_variant_get (out_available, "(bs)", &available, &missing_util);
+ g_variant_unref (out_available);
+ g_free (missing_util);
+ }
+#else
gchar *path;
path = g_find_program_in_path ("mkntfs");
if (path != NULL)
available = TRUE;
g_free (path);
+#endif
g_once_init_leave (&once, (gsize) 1);
}
return available;
diff --git a/src/libgdu/gduutils.h b/src/libgdu/gduutils.h
index d5773a69..59004329 100644
--- a/src/libgdu/gduutils.h
+++ b/src/libgdu/gduutils.h
@@ -75,7 +75,7 @@ gboolean gdu_utils_show_confirmation (GtkWindow *parent_window,
UDisksClient *client,
GList *objects);
-gboolean gdu_utils_is_ntfs_available (void);
+gboolean gdu_utils_is_ntfs_available (UDisksClient *client);
#ifdef HAVE_UDISKS2_7_2
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]