Commit 27d1bcb0 authored by Kai Lüke's avatar Kai Lüke

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.

GNOME/gnome-disk-utility#83
parent b5284a1e
......@@ -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;
}
......@@ -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);
......
......@@ -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);
......
......@@ -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;
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment