Commit 497bfd3b authored by Kai Lüke's avatar Kai Lüke

Redesign Format Dialog

Since the format dialog used hiding of widgets it was
sometimes jumping around. The appearance of the passphrase
entries were bound to a special LUKS+Ext4 mixed entry
within a combo box. Also that apporach does not scale well
if other filesystems should be listed for encryption.

The dialog is redesinged and implemented with several pages,
and thus adaptive to the needs of adding partitions, a new
custom filesystem list and encryption, step for step.
The default FS choices are still kept and shown via radio
buttons on the format page.

https://bugzilla.gnome.org/show_bug.cgi?id=770738
parent 20fdc386
......@@ -11,15 +11,18 @@ src/disks/gduatasmartdialog.c
src/disks/gdubenchmarkdialog.c
src/disks/gduchangepassphrasedialog.c
src/disks/gducreatediskimagedialog.c
src/disks/gducreatefilesystemwidget.c
src/disks/gducreatepartitiondialog.c
src/disks/gducrypttabdialog.c
src/disks/gdudevicetreemodel.c
src/disks/gdudisksettingsdialog.c
src/disks/gduestimator.c
src/disks/gdufilesystemdialog.c
src/disks/gduformatdiskdialog.c
src/disks/gduformatvolumedialog.c
src/disks/gducreateformatdialog.c
src/disks/gducreatepartitionpage.c
src/disks/gducreatefilesystempage.c
src/disks/gducreateotherpage.c
src/disks/gducreatepasswordpage.c
src/disks/gducreateconfirmpage.c
src/disks/gdufstabdialog.c
src/disks/gdunewdiskimagedialog.c
src/disks/gdupartitiondialog.c
......@@ -35,8 +38,12 @@ src/disks/ui/about-dialog.ui
src/disks/ui/app-menu.ui
src/disks/ui/benchmark-dialog.ui
src/disks/ui/change-passphrase-dialog.ui
src/disks/ui/create-confirm-page.ui
src/disks/ui/create-disk-image-dialog.ui
src/disks/ui/create-partition-dialog.ui
src/disks/ui/create-filesystem-page.ui
src/disks/ui/create-other-page.ui
src/disks/ui/create-partition-page.ui
src/disks/ui/create-password-page.ui
src/disks/ui/disk-settings-dialog.ui
src/disks/ui/disks.ui
src/disks/ui/edit-crypttab-dialog.ui
......@@ -46,9 +53,8 @@ src/disks/ui/edit-fstab-dialog.ui
src/disks/ui/edit-gpt-partition-dialog.ui
src/disks/ui/edit-partition-dialog.ui
src/disks/ui/erase-multiple-disks-dialog.ui
src/disks/ui/filesystem-create.ui
src/disks/ui/format-disk-dialog.ui
src/disks/ui/format-volume-dialog.ui
src/disks/ui/create-format.ui
src/disks/ui/new-disk-image-dialog.ui
src/disks/ui/resize-dialog.ui
src/disks/ui/restore-disk-image-dialog.ui
......
......@@ -17,7 +17,7 @@
#include <unistd.h>
#include "gduapplication.h"
#include "gduformatvolumedialog.h"
#include "gducreateformatdialog.h"
#include "gdurestorediskimagedialog.h"
#include "gdunewdiskimagedialog.h"
#include "gduwindow.h"
......@@ -257,14 +257,15 @@ gdu_application_command_line (GApplication *_app,
{
gdu_window_select_object (app->window, object_to_select);
if (opt_format)
gdu_format_volume_dialog_show (app->window, object_to_select);
gdu_create_format_show (app->client, GTK_WINDOW (app->window), object_to_select,
FALSE, FALSE, 0, 0, NULL, NULL);
}
}
else if (opt_format)
{
g_application_hold (_app);
gdu_format_volume_dialog_show_for_xid (app->client, opt_xid, object_to_select,
(GCallback)g_application_release, _app);
gdu_create_format_show (app->client, NULL, object_to_select,
FALSE, FALSE, 0, 0, (GCallback) g_application_release, _app);
}
if (opt_restore_disk_image != NULL)
......
/*
* Copyright (C) 2017 Kai Lüke
*
* Licensed under GPL version 2 or later.
*
* Author: Kai Lüke <kailueke@riseup.net>
*/
#include "config.h"
#include <glib/gi18n.h>
#include "gducreateconfirmpage.h"
struct _GduCreateConfirmPage
{
GtkGrid parent_instance;
};
typedef struct _GduCreateConfirmPagePrivate GduCreateConfirmPagePrivate;
struct _GduCreateConfirmPagePrivate
{
GtkLabel *device_name_label;
GtkLabel *volume_name_label;
GtkLabel *used_label;
GtkLabel *used_amount_label;
GtkLabel *location_path_label;
UDisksClient *client;
UDisksObject *object;
UDisksBlock *block;
};
enum
{
PROP_0,
PROP_COMPLETE
};
G_DEFINE_TYPE_WITH_PRIVATE (GduCreateConfirmPage, gdu_create_confirm_page, GTK_TYPE_GRID);
static void
gdu_create_confirm_page_init (GduCreateConfirmPage *page)
{
gtk_widget_init_template (GTK_WIDGET (page));
}
static void
gdu_create_confirm_page_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
switch (property_id)
{
case PROP_COMPLETE:
g_value_set_boolean (value, TRUE);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gdu_create_confirm_page_class_init (GduCreateConfirmPageClass *class)
{
GObjectClass *gobject_class;
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gnome/Disks/ui/create-confirm-page.ui");
/* confirm page with information on current device usage */
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), GduCreateConfirmPage, device_name_label);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), GduCreateConfirmPage, volume_name_label);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), GduCreateConfirmPage, used_amount_label);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), GduCreateConfirmPage, used_label);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), GduCreateConfirmPage, location_path_label);
gobject_class = G_OBJECT_CLASS (class);
gobject_class->get_property = gdu_create_confirm_page_get_property;
g_object_class_install_property (gobject_class, PROP_COMPLETE,
g_param_spec_boolean ("complete", NULL, NULL,
TRUE,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
}
void
gdu_create_confirm_page_fill_confirmation (GduCreateConfirmPage *page)
{
GduCreateConfirmPagePrivate *priv;
UDisksObjectInfo *info;
gint64 unused_space = -1;
gint64 size;
const gchar *s;
gchar *s1;
gchar *s2;
priv = gdu_create_confirm_page_get_instance_private (page);
/* gather data on current device usage for the confirmation page */
info = udisks_client_get_object_info (priv->client, priv->object);
unused_space = gdu_utils_get_unused_for_block (priv->client, priv->block);
/* Translators: In most cases this should not need translation unless the
* separation character '—' is not appropriate. The strings come
* from UDisks, first is description, second the name:
* "Partition 1 of 32 GB Flash Disk – /dev/sdb1".
*/
s1 = g_strdup_printf (_("%s — %s"), udisks_object_info_get_description (info),
udisks_object_info_get_name (info));
gtk_label_set_text (priv->device_name_label, s1);
g_free (s1);
s = udisks_block_get_id_label (priv->block);
if (s != NULL && strlen(s) > 0)
gtk_label_set_text (priv->volume_name_label, s);
else
gtk_label_set_text (priv->volume_name_label, udisks_block_get_id_type (priv->block));
size = udisks_block_get_size (priv->block);
if (unused_space > 0)
{
gtk_widget_show (GTK_WIDGET (priv->used_label));
gtk_widget_show (GTK_WIDGET (priv->used_amount_label));
s1 = udisks_client_get_size_for_display (priv->client, size - unused_space, FALSE, FALSE);
/* Translators: Disk usage in the format '3 GB (7%)', unit string comes from UDisks.
*/
s2 = g_strdup_printf (_("%s (%.1f%%)"), s1, 100.0 * (size - unused_space) / size);
gtk_label_set_text (priv->used_amount_label, s2);
g_free (s1);
g_free (s2);
}
else
{
gtk_widget_hide (GTK_WIDGET (priv->used_label));
gtk_widget_hide (GTK_WIDGET (priv->used_amount_label));
}
gtk_label_set_text (priv->location_path_label, udisks_block_get_preferred_device (priv->block));
g_object_unref (info);
}
GduCreateConfirmPage *
gdu_create_confirm_page_new (UDisksClient *client, UDisksObject *object, UDisksBlock *block)
{
GduCreateConfirmPage *page;
GduCreateConfirmPagePrivate *priv;
page = g_object_new (GDU_TYPE_CREATE_CONFIRM_PAGE, NULL);
priv = gdu_create_confirm_page_get_instance_private (page);
priv->client = client;
priv->object = object;
priv->block = block;
return page;
}
/*
* Copyright (C) 2017 Kai Lüke
*
* Licensed under GPL version 2 or later.
*
* Author: Kai Lüke <kailueke@riseup.net>
*/
#ifndef __GDU_CREATE_CONFIRM_PAGE_H__
#define __GDU_CREATE_CONFIRM_PAGE_H__
#include <gtk/gtk.h>
#include "gdutypes.h"
G_BEGIN_DECLS
#define GDU_TYPE_CREATE_CONFIRM_PAGE gdu_create_confirm_page_get_type ()
G_DECLARE_FINAL_TYPE (GduCreateConfirmPage, gdu_create_confirm_page, GDU, CREATE_CONFIRM_PAGE, GtkGrid)
GduCreateConfirmPage *gdu_create_confirm_page_new (UDisksClient *client,
UDisksObject *object,
UDisksBlock *block);
void gdu_create_confirm_page_fill_confirmation (GduCreateConfirmPage *page);
G_END_DECLS
#endif /* __GDU_CREATE_CONFIRM_PAGE_H__ */
......@@ -27,7 +27,6 @@
#include "gduwindow.h"
#include "gducreatediskimagedialog.h"
#include "gduvolumegrid.h"
#include "gducreatefilesystemwidget.h"
#include "gduestimator.h"
#include "gdulocaljob.h"
......
/*
* Copyright (C) 2017 Kai Lüke
*
* Licensed under GPL version 2 or later.
*
* Author: Kai Lüke <kailueke@riseup.net>
*/
#include "config.h"
#include <glib/gi18n.h>
#include "gducreatefilesystempage.h"
struct _GduCreateFilesystemPage
{
GtkGrid parent_instance;
};
typedef struct _GduCreateFilesystemPagePrivate GduCreateFilesystemPagePrivate;
struct _GduCreateFilesystemPagePrivate
{
GtkEntry *name_entry;
GtkSwitch *erase_switch;
GtkRadioButton *internal_radiobutton;
GtkCheckButton *internal_encrypt_checkbutton;
GtkRadioButton *windows_radiobutton;
GtkRadioButton *all_radiobutton;
GtkRadioButton *other_radiobutton;
gboolean complete;
};
enum
{
PROP_0,
PROP_COMPLETE
};
G_DEFINE_TYPE_WITH_PRIVATE (GduCreateFilesystemPage, gdu_create_filesystem_page, GTK_TYPE_GRID);
static void
gdu_create_filesystem_page_init (GduCreateFilesystemPage *page)
{
gtk_widget_init_template (GTK_WIDGET (page));
}
static void
gdu_create_filesystem_page_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GduCreateFilesystemPage *page = GDU_CREATE_FILESYSTEM_PAGE (object);
GduCreateFilesystemPagePrivate *priv;
priv = gdu_create_filesystem_page_get_instance_private (page);
switch (property_id)
{
case PROP_COMPLETE:
g_value_set_boolean (value, priv->complete);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gdu_create_filesystem_page_class_init (GduCreateFilesystemPageClass *class)
{
GObjectClass *gobject_class;
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/org/gnome/Disks/ui/create-filesystem-page.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), GduCreateFilesystemPage, name_entry);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), GduCreateFilesystemPage, erase_switch);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), GduCreateFilesystemPage, internal_radiobutton);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), GduCreateFilesystemPage, internal_encrypt_checkbutton);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), GduCreateFilesystemPage, windows_radiobutton);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), GduCreateFilesystemPage, all_radiobutton);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), GduCreateFilesystemPage, other_radiobutton);
gobject_class = G_OBJECT_CLASS (class);
gobject_class->get_property = gdu_create_filesystem_page_get_property;
g_object_class_install_property (gobject_class, PROP_COMPLETE,
g_param_spec_boolean ("complete", NULL, NULL,
FALSE,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
}
const gchar *
gdu_create_filesystem_page_get_name (GduCreateFilesystemPage *page)
{
GduCreateFilesystemPagePrivate *priv;
priv = gdu_create_filesystem_page_get_instance_private (page);
return gtk_entry_get_text (priv->name_entry);
}
gboolean
gdu_create_filesystem_page_is_other (GduCreateFilesystemPage *page)
{
GduCreateFilesystemPagePrivate *priv;
priv = gdu_create_filesystem_page_get_instance_private (page);
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->other_radiobutton));
}
const gchar *
gdu_create_filesystem_page_get_fs (GduCreateFilesystemPage *page)
{
GduCreateFilesystemPagePrivate *priv;
priv = gdu_create_filesystem_page_get_instance_private (page);
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->internal_radiobutton)))
return "ext4";
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->windows_radiobutton)))
return "ntfs";
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->all_radiobutton)))
return "vfat";
else
return NULL;
}
gboolean
gdu_create_filesystem_page_is_encrypted (GduCreateFilesystemPage *page)
{
GduCreateFilesystemPagePrivate *priv;
priv = gdu_create_filesystem_page_get_instance_private (page);
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->internal_radiobutton)) &&
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->internal_encrypt_checkbutton));
}
const gchar *
gdu_create_filesystem_page_get_erase (GduCreateFilesystemPage *page)
{
GduCreateFilesystemPagePrivate *priv;
priv = gdu_create_filesystem_page_get_instance_private (page);
if (gtk_switch_get_active (priv->erase_switch))
return "zero";
else /* TODO: "ata-secure-erase", "ata-secure-erase-enhanced" */
return NULL;
}
static void
on_fs_name_changed (GObject *object, GParamSpec *pspec, gpointer user_data)
{
GduCreateFilesystemPage *page = GDU_CREATE_FILESYSTEM_PAGE (user_data);
GduCreateFilesystemPagePrivate *priv;
priv = gdu_create_filesystem_page_get_instance_private (page);
priv->complete = gtk_entry_get_text_length (priv->name_entry) > 0; /* require a label */
g_object_notify (G_OBJECT (page), "complete");
_gtk_entry_buffer_truncate_bytes (gtk_entry_get_buffer (priv->name_entry),
gdu_utils_get_max_label_length (gdu_create_filesystem_page_get_fs (page)));
}
static void
on_fs_type_changed (GtkToggleButton *object, gpointer user_data)
{
GduCreateFilesystemPage *page = GDU_CREATE_FILESYSTEM_PAGE (user_data);
GduCreateFilesystemPagePrivate *priv;
priv = gdu_create_filesystem_page_get_instance_private (page);
_gtk_entry_buffer_truncate_bytes (gtk_entry_get_buffer (priv->name_entry),
gdu_utils_get_max_label_length (gdu_create_filesystem_page_get_fs (page)));
g_object_notify (G_OBJECT (page), "complete");
}
GduCreateFilesystemPage *
gdu_create_filesystem_page_new (gboolean show_custom, UDisksDrive *drive)
{
GduCreateFilesystemPage *page;
GduCreateFilesystemPagePrivate *priv;
page = g_object_new (GDU_TYPE_CREATE_FILESYSTEM_PAGE, NULL);
priv = gdu_create_filesystem_page_get_instance_private (page);
g_signal_connect (priv->name_entry, "notify::text", G_CALLBACK (on_fs_name_changed), page);
g_signal_connect (priv->internal_encrypt_checkbutton, "toggled", G_CALLBACK (on_fs_type_changed), page);
g_signal_connect (priv->internal_radiobutton, "toggled", G_CALLBACK (on_fs_type_changed), page);
g_signal_connect (priv->windows_radiobutton, "toggled", G_CALLBACK (on_fs_type_changed), page);
g_signal_connect (priv->all_radiobutton, "toggled", G_CALLBACK (on_fs_type_changed), page);
g_signal_connect (priv->other_radiobutton, "toggled", G_CALLBACK (on_fs_type_changed), page);
g_object_bind_property (priv->internal_radiobutton, "active", priv->internal_encrypt_checkbutton, "sensitive", G_BINDING_SYNC_CREATE);
if (!show_custom)
gtk_widget_hide (GTK_WIDGET (priv->other_radiobutton));
/* Default to FAT or NTFS for removable drives... */
if (drive != NULL && udisks_drive_get_removable (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 ()
)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->all_radiobutton), TRUE);
}
else
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->windows_radiobutton), TRUE);
}
}
gtk_widget_set_sensitive (GTK_WIDGET (priv->windows_radiobutton), gdu_utils_is_ntfs_available ());
return page;
}
/*
* Copyright (C) 2017 Kai Lüke
*
* Licensed under GPL version 2 or later.
*
* Author: Kai Lüke <kailueke@riseup.net>
*/
#ifndef __GDU_CREATE_FILESYSTEM_PAGE_H__
#define __GDU_CREATE_FILESYSTEM_PAGE_H__
#include <gtk/gtk.h>
#include "gdutypes.h"
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,
UDisksDrive *drive);
const gchar * gdu_create_filesystem_page_get_name (GduCreateFilesystemPage *page);
const gchar * gdu_create_filesystem_page_get_fs (GduCreateFilesystemPage *page);
gboolean gdu_create_filesystem_page_is_other (GduCreateFilesystemPage *page);
gboolean gdu_create_filesystem_page_is_encrypted (GduCreateFilesystemPage *page);
const gchar * gdu_create_filesystem_page_get_erase (GduCreateFilesystemPage *page);
G_END_DECLS
#endif /* __GDU_CREATE_FILESYSTEM_PAGE_H__ */
This diff is collapsed.
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2008-2013 Red Hat, Inc.
*
* Licensed under GPL version 2 or later.
*
* Author: David Zeuthen <zeuthen@gmail.com>
*/
#ifndef __GDU_CREATE_FILESYSTEM_WIDGET_H__
#define __GDU_CREATE_FILESYSTEM_WIDGET_H__
#include <gtk/gtk.h>
#include "gdutypes.h"
G_BEGIN_DECLS
#define GDU_TYPE_CREATE_FILESYSTEM_WIDGET gdu_create_filesystem_widget_get_type()
#define GDU_CREATE_FILESYSTEM_WIDGET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDU_TYPE_CREATE_FILESYSTEM_WIDGET, GduCreateFilesystemWidget))
#define GDU_IS_CREATE_FILESYSTEM_WIDGET(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDU_TYPE_CREATE_FILESYSTEM_WIDGET))
GType gdu_create_filesystem_widget_get_type (void) G_GNUC_CONST;
GtkWidget* gdu_create_filesystem_widget_new (GduApplication *application,
UDisksDrive *drive,
const gchar * const *addtional_fstypes);
const gchar *gdu_create_filesystem_widget_get_name (GduCreateFilesystemWidget *widget);
const gchar *gdu_create_filesystem_widget_get_erase (GduCreateFilesystemWidget *widget);
const gchar *gdu_create_filesystem_widget_get_fstype (GduCreateFilesystemWidget *widget);
const gchar *gdu_create_filesystem_widget_get_passphrase (GduCreateFilesystemWidget *widget);
gboolean gdu_create_filesystem_widget_get_encrypt (GduCreateFilesystemWidget *widget);
gboolean gdu_create_filesystem_widget_get_has_info (GduCreateFilesystemWidget *widget);
GtkWidget *gdu_create_filesystem_widget_get_name_entry (GduCreateFilesystemWidget *widget);
G_END_DECLS
#endif /* __GDU_CREATE_FILESYSTEM_WIDGET_H__ */
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2008-2013 Red Hat, Inc.
* Copyright (C) 2017 Kai Lüke
*
* Licensed under GPL version 2 or later.
*
* Author: David Zeuthen <zeuthen@gmail.com>, Kai Lüke <kailueke@riseup.net>
*/
#include "config.h"
#include <glib/gi18n.h>
#include "gduapplication.h"
#include "gduwindow.h"
#include "gducreateformatdialog.h"
#include "gducreatepartitionpage.h"
#include "gducreatefilesystempage.h"
#include "gducreateotherpage.h"
#include "gducreatepasswordpage.h"
#include "gducreateconfirmpage.h"
#include "gduvolumegrid.h"
#define PARTITION_PAGE "partition"
#define FORMAT_PAGE "format"
#define OTHER_PAGE "other"
#define PASSWORD_PAGE "password"
#define CONFIRM_PAGE "confirm"
typedef struct
{
GtkWindow *parent_window;
UDisksObject *object;
UDisksBlock *block;
UDisksDrive *drive;
UDisksPartitionTable *table;
UDisksClient *client;
GtkBuilder *builder;
GtkDialog *dialog;
GtkStack *stack;
GtkButton *back;
GtkButton *forward;
const gchar *current; /* page names */
const gchar *prev;
const gchar *next;
gboolean add_partition; /* mode: format vs add partition and format */
guint64 add_partition_offset;
guint64 add_partition_maxsize;
GduCreatePartitionPage *partition_page; /* create partition page */
GduCreateFilesystemPage *filesystem_page; /* main format page */
GduCreateOtherPage *other_page; /* custom filesystem page */
GduCreatePasswordPage *password_page; /* set password page */
GduCreateConfirmPage *confirm_page; /* confirm format page */
GCallback finished_cb;
gpointer cb_data;
} CreateFormatData;
static void
create_format_data_free (CreateFormatData *data)
{
if (data->finished_cb)
((GDestroyNotify) data->finished_cb) (data->cb_data);
g_clear_object (&data->parent_window);
g_object_unref (data->object);
g_object_unref (data->block);
g_clear_object (&data->drive);
if (data->dialog != NULL)
{
gtk_widget_hide (GTK_WIDGET (data->dialog));
gtk_widget_destroy (GTK_WIDGET (data->dialog));
}
if (data->builder != NULL)
g_object_unref (data->builder);
g_free (data);
}
static const gchar *
get_filesystem (CreateFormatData *data)
{
if (data->add_partition && gdu_create_partition_page_is_extended (data->partition_page))
return "dos_extended";
else if (gdu_create_filesystem_page_get_fs (data->filesystem_page) != NULL)
return gdu_create_filesystem_page_get_fs (data->filesystem_page);
else
return gdu_create_other_page_get_fs (data->other_page);
}
static gboolean
get_encrypt (CreateFormatData *data)
{
return gdu_create_filesystem_page_is_encrypted (data->filesystem_page) ||
(gdu_create_filesystem_page_is_other (data->filesystem_page) &&
gdu_create_other_page_is_encrypted (data->other_page));
}
static void
update_dialog (GtkWidget *widget, GParamSpec *child_property, CreateFormatData *data)
{
GValue title = G_VALUE_INIT;
gboolean complete = FALSE;
GtkWidget *child;
gpointer page = NULL;
g_value_init (&title, G_TYPE_STRING);
child = gtk_stack_get_child_by_name (data->stack, data->current);
gtk_container_child_get_property (GTK_CONTAINER (data->stack), child, "title", &title);
gtk_window_set_title (GTK_WINDOW (data->dialog), g_value_get_string (&title));
data->prev = NULL;
data->next = CONFIRM_PAGE;
if (data->add_partition)
data->next = NULL;
if (g_strcmp0 (data->current, PARTITION_PAGE) == 0)
{
page = data->partition_page;
data->next = FORMAT_PAGE;
if (gdu_create_partition_page_is_extended (data->partition_page))
data->next = NULL;
}
else if (g_strcmp0 (data->current, FORMAT_PAGE) == 0)
{
page = data->filesystem_page;
if (data->add_partition)
data->prev = PARTITION_PAGE;
if (gdu_create_filesystem_page_is_other (data->filesystem_page))
data->next = OTHER_PAGE;
if (gdu_create_filesystem_page_is_encrypted (data->filesystem_page))
data->next = PASSWORD_PAGE;
}
else if (g_strcmp0 (data->current, OTHER_PAGE) == 0)
{
page = data->other_page;
data->prev = FORMAT_PAGE;
if (gdu_create_other_page_is_encrypted (data->other_page))
data->next = PASSWORD_PAGE;
}
else if (g_strcmp0 (data->current, PASSWORD_PAGE) == 0)
{
page = data->password_page;
if (gdu_create_filesystem_page_is_encrypted (data->filesystem_page))
data->prev = FORMAT_PAGE;