[gnome-disk-utility] Rework/refactor formatting tool



commit a53227b9f9ce022f932620c81f50f49b8a83a70f
Author: David Zeuthen <davidz redhat com>
Date:   Fri May 1 13:03:00 2009 -0400

    Rework/refactor formatting tool
---
 src/format-tool/Makefile.am                  |   12 +-
 src/format-tool/format-window-operation.c    |  804 --------------------------
 src/format-tool/format-window-operation.h    |   74 ---
 src/format-tool/format-window.c              |  578 ------------------
 src/format-tool/format-window.h              |   91 ---
 src/format-tool/gdu-format-dialog.c          |  452 +++++++++++++++
 src/format-tool/gdu-format-dialog.h          |   71 +++
 src/format-tool/gdu-format-progress-dialog.c |  263 +++++++++
 src/format-tool/gdu-format-progress-dialog.h |   63 ++
 src/format-tool/gdu-format-tool.c            |  349 ++++++++++--
 src/format-tool/gdu-utils.c                  |  148 -----
 src/format-tool/gdu-utils.h                  |   48 --
 src/gdu-gtk/gdu-gtk.c                        |    5 +-
 src/nautilus-extension/nautilus-gdu.c        |    7 +-
 14 files changed, 1174 insertions(+), 1791 deletions(-)

diff --git a/src/format-tool/Makefile.am b/src/format-tool/Makefile.am
index eddf057..3d7f61c 100644
--- a/src/format-tool/Makefile.am
+++ b/src/format-tool/Makefile.am
@@ -38,14 +38,10 @@ CORE_LIBADD = 						\
 
 libexec_PROGRAMS = gdu-format-tool
 
-gdu_format_tool_SOURCES =		\
-	format-window.c			\
-	format-window.h			\
-	format-window-operation.c	\
-	format-window-operation.h	\
-	gdu-utils.c			\
-	gdu-utils.h			\
-	gdu-format-tool.c		\
+gdu_format_tool_SOURCES =						\
+					gdu-format-tool.c		\
+	gdu-format-dialog.h		gdu-format-dialog.c		\
+	gdu-format-progress-dialog.h	gdu-format-progress-dialog.c	\
 	$(NULL)
 
 gdu_format_tool_CPPFLAGS = $(CORE_CFLAGS) -DG_LOG_DOMAIN=\"GDU-Format-Tool\"
diff --git a/src/format-tool/format-window-operation.c b/src/format-tool/format-window-operation.c
deleted file mode 100644
index bf72abc..0000000
--- a/src/format-tool/format-window-operation.c
+++ /dev/null
@@ -1,804 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-/*
- *  format-window-operation.c
- *
- *  Copyright (C) 2008-2009 Red Hat, Inc.
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Library General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public
- *  License along with this library; if not, write to the Free
- *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *  Author: Tomas Bzatek <tbzatek redhat com>
- *
- */
-
-#include "config.h"
-
-#include <glib/gi18n-lib.h>
-
-#include <gdu-gtk/gdu-gtk.h>
-
-#include <polkit-gnome/polkit-gnome.h>
-
-#include "gdu-utils.h"
-#include "format-window-operation.h"
-
-
-
-/*  TODO: find a better way for this  */
-#define DEVICE_SETTLE_TIMEOUT 3000
-
-
-/*  Look whether the device needs to be partitioned  */
-/*  - generally we don't want to have partitions on optical drives and floppy disks  */
-static gboolean
-device_needs_partition_table (GduDevice *device)
-{
-        gchar **media_compat;
-        gboolean needs = TRUE;  /*  default to TRUE  */
-
-        media_compat = gdu_device_drive_get_media_compatibility (device);
-        for (; *media_compat; media_compat++) {
-                g_debug ("     compat '%s'\n", *media_compat);
-                /*  http://hal.freedesktop.org/docs/DeviceKit-disks/Device.html#Device:drive-media-compatibility  */
-                if (strstr (*media_compat, "optical") == *media_compat ||
-                    strstr (*media_compat, "floppy") == *media_compat) {
-                        needs = FALSE;
-                        break;
-                }
-        }
-#if 0
-        g_strfreev (media_compat);   /* so, is this const then?  */
-#endif
-        g_debug ("device_needs_partition_table = %d", needs);
-        return needs;
-}
-
-/* -------------------------------------------------------------------------- */
-
-static gboolean
-job_progress_pulse_timeout_handler (gpointer user_data)
-{
-        FormatProcessData *data = user_data;
-
-        g_return_val_if_fail (data != NULL, TRUE);
-
-        gtk_progress_bar_pulse (GTK_PROGRESS_BAR (data->priv->progress_bar));
-
-        return TRUE;
-}
-
-static void
-do_progress_bar_update (FormatProcessData *data,
-                        const gchar       *label,
-                        gdouble            percentage,
-                        gboolean           active)
-{
-        if (active) {
-                if (label)
-                        gtk_progress_bar_set_text (GTK_PROGRESS_BAR (data->priv->progress_bar), label);
-
-                if (percentage < 0) {
-                        gtk_progress_bar_set_pulse_step (GTK_PROGRESS_BAR (data->priv->progress_bar), 2.0 / 50);
-                        gtk_progress_bar_pulse (GTK_PROGRESS_BAR (data->priv->progress_bar));
-                        if (data->job_progress_pulse_timer_id == 0) {
-                                data->job_progress_pulse_timer_id = g_timeout_add (
-                                                                                   1000 / 50,
-                                                                                   job_progress_pulse_timeout_handler,
-                                                                                   data);
-                        }
-                } else {
-                        if (data->job_progress_pulse_timer_id > 0) {
-                                g_source_remove (data->job_progress_pulse_timer_id);
-                                data->job_progress_pulse_timer_id = 0;
-                        }
-                        gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (data->priv->progress_bar),
-                                                       percentage / 100.0);
-                }
-        }
-        else {
-                if (data->job_progress_pulse_timer_id > 0) {
-                        g_source_remove (data->job_progress_pulse_timer_id);
-                        data->job_progress_pulse_timer_id = 0;
-                }
-        }
-}
-
-static void
-presentable_job_changed (GduPresentable *presentable,
-                         gpointer        user_data)
-{
-        FormatProcessData *data = user_data;
-        gchar *job_description;
-        gdouble percentage;
-
-        g_return_if_fail (data != NULL);
-
-        if (data->device != NULL && gdu_device_job_in_progress (data->device)) {
-                job_description = gdu_get_job_description (gdu_device_job_get_id (data->device));
-
-                percentage = gdu_device_job_get_percentage (data->device);
-                do_progress_bar_update (data, job_description, percentage, TRUE);
-
-                g_free (job_description);
-
-        } else {
-                /*  do_progress_bar_update (data, NULL, -1, FALSE);  */
-                /*  Mask inactivity by bouncing -- this should be fixed in libgdu  */
-                do_progress_bar_update (data, NULL, -1, TRUE);
-        }
-}
-
-
-/* -------------------------------------------------------------------------- */
-
-static void unmount_auth_end_callback (PolKitGnomeAction *action, gboolean gained_privilege, gpointer user_data);
-static void format_auth_end_callback (PolKitGnomeAction *action, gboolean gained_privilege, gpointer user_data);
-static void format_action_callback (GtkAction *action, gpointer user_data);
-static void part_modify_auth_end_callback (PolKitGnomeAction *action, gboolean gained_privilege, gpointer user_data);
-static void part_modify_action_callback (GtkAction *action, gpointer user_data);
-static void part_table_new_auth_end_callback (PolKitGnomeAction *action, gboolean gained_privilege, gpointer user_data);
-static void part_table_new_action_callback (GtkAction *action, gpointer user_data);
-static void part_new_auth_end_callback (PolKitGnomeAction *action, gboolean gained_privilege, gpointer user_data);
-static void part_new_action_callback (GtkAction *action, gpointer user_data);
-
-void
-update_ui_progress (FormatDialogPrivate *priv,
-                    FormatProcessData   *data,
-                    gboolean             working)
-{
-        g_return_if_fail (priv != NULL);
-
-        priv->job_running = working;
-
-        if (working) {
-                gtk_progress_bar_set_text (GTK_PROGRESS_BAR (priv->progress_bar), NULL);
-                gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->progress_bar), 0.0);
-                gtk_button_set_label (GTK_BUTTON (priv->close_button), GTK_STOCK_STOP);
-                gtk_widget_show (priv->progress_bar_box);
-                gtk_widget_hide (priv->all_controls_box);
-                if (data) {
-                        g_signal_connect (data->presentable, "job-changed", G_CALLBACK (presentable_job_changed), data);
-
-                        /*  set up PolicyKit actions  */
-                        data->pk_format_action = polkit_action_new ();
-                        polkit_action_set_action_id (data->pk_format_action, "org.freedesktop.devicekit.disks.change");
-                        data->format_action = polkit_gnome_action_new_default ("format", data->pk_format_action, NULL, NULL);
-                        g_signal_connect (data->format_action, "auth-end", G_CALLBACK (format_auth_end_callback), data);
-                        g_signal_connect (data->format_action, "activate", G_CALLBACK (format_action_callback), data);
-
-                        data->pk_part_modify_action = polkit_action_new ();
-                        /*  action_id is the same as for format, but sometimes authentication is one shot  */
-                        polkit_action_set_action_id (data->pk_part_modify_action, "org.freedesktop.devicekit.disks.change");
-                        data->part_modify_action = polkit_gnome_action_new_default ("part_modify", data->pk_part_modify_action, NULL, NULL);
-                        g_signal_connect (data->part_modify_action, "auth-end", G_CALLBACK (part_modify_auth_end_callback), data);
-                        g_signal_connect (data->part_modify_action, "activate", G_CALLBACK (part_modify_action_callback), data);
-
-                        data->pk_part_table_new_action = polkit_action_new ();
-                        polkit_action_set_action_id (data->pk_part_table_new_action, "org.freedesktop.devicekit.disks.change");
-                        data->part_table_new_action = polkit_gnome_action_new_default ("part_table_new", data->pk_part_table_new_action, NULL, NULL);
-                        g_signal_connect (data->part_table_new_action, "auth-end", G_CALLBACK (part_table_new_auth_end_callback), data);
-                        g_signal_connect (data->part_table_new_action, "activate", G_CALLBACK (part_table_new_action_callback), data);
-
-                        data->pk_part_new_action = polkit_action_new ();
-                        polkit_action_set_action_id (data->pk_part_new_action, "org.freedesktop.devicekit.disks.change");
-                        data->part_new_action = polkit_gnome_action_new_default ("part_new", data->pk_part_new_action, NULL, NULL);
-                        g_signal_connect (data->part_new_action, "auth-end", G_CALLBACK (part_new_auth_end_callback), data);
-                        g_signal_connect (data->part_new_action, "activate", G_CALLBACK (part_new_action_callback), data);
-
-                }
-        }
-        else
-                {
-                        if (data) {
-                                g_signal_handlers_disconnect_matched (data->format_action, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, data);
-                                g_signal_handlers_disconnect_matched (data->part_modify_action, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, data);
-                                g_signal_handlers_disconnect_matched (data->part_table_new_action, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, data);
-                                g_signal_handlers_disconnect_matched (data->part_new_action, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, data);
-
-                                /*  destroy PolicyKit actions  */
-                                polkit_action_unref (data->pk_format_action);
-                                g_object_unref (data->format_action);
-                                polkit_action_unref (data->pk_part_modify_action);
-                                g_object_unref (data->part_modify_action);
-                                polkit_action_unref (data->pk_part_table_new_action);
-                                g_object_unref (data->part_table_new_action);
-                                polkit_action_unref (data->pk_part_new_action);
-                                g_object_unref (data->part_new_action);
-
-                                g_signal_handlers_disconnect_matched (data->presentable, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, data);
-                                if (data->job_progress_pulse_timer_id > 0) {
-                                        g_source_remove (data->job_progress_pulse_timer_id);
-                                        data->job_progress_pulse_timer_id = 0;
-                                }
-                        }
-                        gtk_widget_show (priv->all_controls_box);
-                        gtk_widget_hide (priv->progress_bar_box);
-                        gtk_button_set_label (GTK_BUTTON (priv->close_button), GTK_STOCK_CLOSE);
-                }
-        update_ui_controls (priv);
-}
-
-static void
-free_format_action_data (FormatProcessData *data)
-{
-        if (data) {
-                update_ui_progress (data->priv, data, FALSE);
-                if (data->presentable != NULL)
-                        g_object_unref (data->presentable);
-                if (data->device != NULL)
-                        g_object_unref (data->device);
-                g_free (data->encrypt_passphrase);
-                g_free (data->fslabel);
-                g_free (data);
-        }
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-
-static void
-action_finished (FormatProcessData *data,
-                 gchar             *new_device_path)
-{
-        GduDevice *new_device;
-        GduPresentable *new_presentable = NULL;
-
-        g_return_if_fail (data != NULL);
-
-        /*  we don't want to destroy objects at this point, don't pass data in */
-        update_ui_progress (data->priv, NULL, FALSE);
-
-        /*  change to the new device  */
-        if (new_device_path) {
-                new_device = gdu_pool_get_by_object_path (data->priv->pool, new_device_path);
-                if (new_device) {
-                        g_object_unref (data->device);
-                        data->device = new_device;
-                        new_presentable = gdu_pool_get_volume_by_device (data->priv->pool, new_device);
-                        if (new_presentable) {
-                                /*  switch to new presentable  */
-                                g_debug ("setting new presentable...");
-                        }
-                } else {
-                        g_warning ("action_finished: cannot find device for the %s device path", new_device_path);
-                }
-                g_free (new_device_path);
-        }
-
-        /*  Force refresh of the new presentable  */
-        select_new_presentable (data->priv, new_presentable != NULL ? new_presentable : data->priv->presentable);
-        if (new_presentable)
-                g_object_unref (new_presentable);
-
-        /*  TODO: show encryption info somewhere?  */
-        if (data->encrypt_passphrase != NULL) {
-                /* now set the passphrase if requested */
-                if (data->save_in_keyring || data->save_in_keyring_session) {
-                        gdu_util_save_secret (data->device,
-                                              data->encrypt_passphrase,
-                                              data->save_in_keyring_session);
-                }
-        }
-}
-
-/* -------------------------------------------------------------------------- */
-static void
-fix_focus_cb (GtkDialog *dialog,
-              gpointer   data)
-{
-        GtkWidget *button;
-
-        button = gtk_window_get_default_widget (GTK_WINDOW (dialog));
-        gtk_widget_grab_focus (button);
-}
-
-static void
-expander_cb (GtkExpander *expander,
-             GParamSpec  *pspec,
-             GtkWindow   *dialog)
-{
-        gtk_window_set_resizable (dialog, gtk_expander_get_expanded (expander));
-}
-
-/*  keep in sync with gdu-shell.c/gdu_shell_raise_error()                                               */
-static void
-nautilus_gdu_show_error (GtkWidget      *parent_window,
-                         GduPresentable *presentable,
-                         GError         *error,
-                         const gchar    *primary_markup_format,
-                         ...)
-{
-        GtkWidget *dialog;
-        gchar *error_text;
-        gchar *window_title;
-        GIcon *window_icon;
-        va_list args;
-        GtkWidget *box, *hbox, *expander, *sw, *tv;
-        GList *children;
-        GtkTextBuffer *buffer;
-
-        g_return_if_fail (presentable != NULL);
-        g_return_if_fail (error != NULL);
-
-        window_title = gdu_presentable_get_name (presentable);
-        window_icon = gdu_presentable_get_icon (presentable);
-
-        va_start (args, primary_markup_format);
-        error_text = g_strdup_vprintf (primary_markup_format, args);
-        va_end (args);
-
-        dialog = gtk_message_dialog_new_with_markup (
-                                                     GTK_WINDOW (parent_window),
-                                                     GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
-                                                     GTK_MESSAGE_ERROR,
-                                                     GTK_BUTTONS_CLOSE,
-                                                     "<big><b>%s</b></big>",
-                                                     error_text);
-        gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s",
-                                                  trim_dk_error (error->message));
-
-        gtk_window_set_title (GTK_WINDOW (dialog), window_title);
-        /*  TODO: no support for GIcon in GtkWindow  */
-        /*  gtk_window_set_icon_name (GTK_WINDOW (dialog), window_icon_name);  */
-
-        g_signal_connect_swapped (dialog,
-                                  "response",
-                                  G_CALLBACK (gtk_main_quit),
-                                  NULL);
-        gtk_window_present (GTK_WINDOW (dialog));
-
-        g_free (window_title);
-        if (window_icon != NULL)
-                g_object_unref (window_icon);
-        g_free (error_text);
-}
-
-/* -------------------------------------------------------------------------- */
-
-static void
-modify_partition_completed (GduDevice  *device,
-                            GError     *error,
-                            gpointer    user_data)
-{
-        FormatProcessData *data = user_data;
-
-        g_debug ("modify_partition_completed");
-        g_return_if_fail (data != NULL);
-
-        if (error != NULL) {
-                nautilus_gdu_show_error (GTK_WIDGET (data->priv->dialog),
-                                         data->presentable,
-                                         error,
-                                         _("Error modifying partition"));
-                g_error_free (error);
-        }
-        else
-                {
-                        /*  -- don't refresh here, wait for the "changed" callback
-                            update_ui (data->priv);  */
-                }
-        /*  save encryption info even if operation fails  */
-        action_finished (data, NULL);
-        free_format_action_data (data);
-}
-
-static void
-part_modify_action_callback (GtkAction *action,
-                             gpointer   user_data)
-{
-        FormatProcessData *data = user_data;
-
-        g_return_if_fail (data != NULL);
-        g_debug ("part_modify_action_callback");
-
-        if (data->priv->job_cancelled)
-                return;
-
-        /*  DK is buggy, passing a label string causes the operation to fail  */
-        gdu_device_op_partition_modify (data->device, data->recommended_part_type, NULL, NULL, modify_partition_completed, data);
-}
-
-static void
-part_modify_auth_end_callback (PolKitGnomeAction *action,
-                               gboolean           gained_privilege,
-                               gpointer           user_data)
-{
-        FormatProcessData *data = user_data;
-
-        g_return_if_fail (data != NULL);
-        g_debug ("part_modify_auth_end_callback");
-
-        if (! gained_privilege) {
-                /*  cancel the whole operation  */
-                free_format_action_data (data);
-        }
-        else {
-                /*  positive reply should be handled by part_modify_action_callback  */
-        }
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-
-static void
-format_action_completed (GduDevice  *device,
-                         GError     *error,
-                         gpointer    user_data)
-{
-        FormatProcessData *data = user_data;
-        const gchar *part_type;
-        GduPresentable *toplevel_presentable;
-        GduDevice *toplevel_device;
-
-        g_debug ("format_action_completed");
-        g_return_if_fail (data != NULL);
-
-        if (error != NULL) {
-                nautilus_gdu_show_error (GTK_WIDGET (data->priv->dialog),
-                                         data->presentable,
-                                         error,
-                                         _("Error creating partition"));
-                g_error_free (error);
-        }
-        else
-                {
-                        /*  Get device scheme if needed  */
-                        if (! data->scheme || strlen (data->scheme) == 0) {
-                                toplevel_presentable = gdu_presentable_get_toplevel (data->presentable);
-                                if (toplevel_presentable) {
-                                        toplevel_device = gdu_presentable_get_device (toplevel_presentable);
-                                        if (toplevel_device) {
-                                                data->scheme = gdu_device_partition_table_get_scheme (toplevel_device);
-                                                g_object_unref (toplevel_device);
-                                        }
-                                        g_object_unref (toplevel_presentable);
-                                }
-                        }
-
-                        /*  Correct partition type  */
-                        if (! data->priv->job_cancelled && data->scheme && strlen (data->scheme) > 0) {
-                                part_type = gdu_device_partition_get_type (device);
-                                data->recommended_part_type = gdu_util_get_default_part_type_for_scheme_and_fstype (data->scheme, data->fstype, gdu_device_partition_get_size (device));
-                                g_debug ("format_action_completed: part_type = %s, recommended_part_type = %s", part_type, data->recommended_part_type);
-                                /*  Change partition type if necessary  */
-                                if (strcmp (part_type, data->recommended_part_type) != 0)
-                                        {
-                                                g_debug ("changing part type to %s, device = %s", data->recommended_part_type, gdu_device_get_device_file (device));
-                                                gtk_action_activate (GTK_ACTION (data->part_modify_action));
-                                                return;  /*  don't change the UI yet  */
-                                        }
-                        }
-
-                        /*  formatting finished  */
-                        action_finished (data, NULL);
-                }
-        free_format_action_data (data);
-}
-
-static void
-format_action_callback (GtkAction *action,
-                        gpointer   user_data)
-{
-        FormatProcessData *data = user_data;
-
-        g_return_if_fail (data != NULL);
-        g_debug ("format_action_callback");
-
-        if (data->priv->job_cancelled)
-                return;
-
-        gdu_device_op_filesystem_create (data->device,
-                                         data->fstype,
-                                         data->fslabel,
-                                         data->encrypt_passphrase,
-                                         data->take_ownership,
-                                         format_action_completed,
-                                         data);
-}
-
-static void
-format_auth_end_callback (PolKitGnomeAction *action,
-                          gboolean           gained_privilege,
-                          gpointer           user_data)
-{
-        FormatProcessData *data = user_data;
-
-        g_return_if_fail (data != NULL);
-        g_debug ("format_auth_end_callback");
-
-        if (! gained_privilege) {
-                /*  cancel the whole operation  */
-                free_format_action_data (data);
-        }
-        else {
-                /*  positive reply should be handled by format_action_callback  */
-        }
-}
-
-
-/* ---------------------------------------------------------------------------------------------------- */
-
-static gboolean
-part_table_new_timeout_handler (gpointer user_data)
-{
-        FormatProcessData *data = user_data;
-
-        g_return_val_if_fail (data != NULL, FALSE);
-        g_debug ("part_table_new_timeout_handler");
-
-        gtk_action_activate (GTK_ACTION (data->part_new_action));
-
-        return FALSE;
-}
-
-static void
-part_table_new_completed (GduDevice *device,
-                          GError    *error,
-                          gpointer   user_data)
-{
-        FormatProcessData *data = user_data;
-
-        /*  BUG: callback shouldn't be spawned until all changes are reflected in pool  */
-        g_return_if_fail (data != NULL);
-
-        g_debug ("part_table_new_completed");
-        update_ui_controls (data->priv);
-
-        if (error != NULL) {
-                nautilus_gdu_show_error (GTK_WIDGET (data->priv->dialog),
-                                         data->presentable,
-                                         error,
-                                         _("Error creating new partition table"));
-                free_format_action_data (data);
-                g_error_free (error);
-        }
-        else
-                {
-                        g_debug ("  creating partition...");
-                        if (data->priv->job_cancelled)
-                                return;
-                        /*  TODO: we should wait here for proper refresh  */
-                        g_timeout_add (DEVICE_SETTLE_TIMEOUT, part_table_new_timeout_handler, data);
-                        do_progress_bar_update (data, _("Waiting for device to settle..."), -1, TRUE);
-                        /*  gtk_action_activate (GTK_ACTION (data->part_new_action));  -- disabled  */
-                }
-}
-
-static void
-part_table_new_action_callback (GtkAction *action,
-                                gpointer   user_data)
-{
-        FormatProcessData *data = user_data;
-
-        g_return_if_fail (data != NULL);
-        g_debug ("part_table_new_action_callback");
-
-        if (data->priv->job_cancelled)
-                return;
-
-        /*  default to MBR  */
-        data->scheme = "mbr";
-
-        gdu_device_op_partition_table_create (data->device, data->scheme, part_table_new_completed, data);
-}
-
-static void
-part_table_new_auth_end_callback (PolKitGnomeAction *action,
-                                  gboolean           gained_privilege,
-                                  gpointer           user_data)
-{
-        FormatProcessData *data = user_data;
-
-        g_return_if_fail (data != NULL);
-        g_debug ("part_table_new_auth_end_callback");
-
-        if (! gained_privilege) {
-                /*  cancel the whole operation  */
-                free_format_action_data (data);
-        }
-        else {
-                /*  positive reply should be handled by unmount_action_callback  */
-        }
-}
-
-/* -------------------------------------------------------------------------- */
-
-static void
-part_new_completed (GduDevice *device,
-                    gchar     *created_device_object_path,
-                    GError    *error,
-                    gpointer   user_data)
-{
-        FormatProcessData *data = user_data;
-
-        /*  BUG: callback shouldn't be spawned until all changes are reflected in pool  */
-        g_return_if_fail (data != NULL);
-
-        g_debug ("part_new_completed, created_device_object_path = %s", error == NULL ? created_device_object_path : NULL);
-
-        if (error != NULL) {
-                nautilus_gdu_show_error (GTK_WIDGET (data->priv->dialog),
-                                         data->presentable,
-                                         error,
-                                         _("Error creating new partition"));
-                g_error_free (error);
-        }
-        else
-                {
-                        /*  formatting finished  */
-                        /*  TODO: we should wait here for proper refresh  */
-                        action_finished (data, g_strdup (created_device_object_path));
-                }
-        free_format_action_data (data);
-}
-
-static void
-part_new_action_callback (GtkAction *action,
-                          gpointer   user_data)
-{
-        FormatProcessData *data = user_data;
-        guint64 offset;
-        guint64 size;
-        gchar *type;
-
-        g_return_if_fail (data != NULL);
-        g_debug ("part_new_action_callback, device = %s", gdu_device_get_device_file (data->device));
-
-        if (data->priv->job_cancelled)
-                return;
-
-        offset = gdu_presentable_get_offset (data->presentable);
-        size = gdu_presentable_get_size (data->presentable);
-
-        if (! data->scheme || strlen (data->scheme) == 0)
-                data->scheme = gdu_device_partition_table_get_scheme (data->device);   /*  we should have toplevel device here  */
-        if (! data->scheme || strlen (data->scheme) == 0)
-                data->scheme = "mbr";   /*  default to MBR  */
-
-        type = gdu_util_get_default_part_type_for_scheme_and_fstype (data->scheme, data->fstype, size);
-
-        g_debug ("creating new partition, offset = %lu, size = %lu, scheme = %s, type = %s", offset, size, data->scheme, type);
-
-        gdu_device_op_partition_create (data->device, offset, size, type, NULL, NULL,
-                                        data->fstype, data->fslabel, data->encrypt_passphrase, data->take_ownership,
-                                        part_new_completed, data);
-        g_free (type);
-}
-
-static void
-part_new_auth_end_callback (PolKitGnomeAction *action,
-                            gboolean           gained_privilege,
-                            gpointer           user_data)
-{
-        FormatProcessData *data = user_data;
-
-        g_return_if_fail (data != NULL);
-        g_debug ("part_new_auth_end_callback");
-
-        if (! gained_privilege) {
-                /*  cancel the whole operation  */
-                free_format_action_data (data);
-        }
-        else {
-                /*  positive reply should be handled by unmount_action_callback  */
-        }
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-
-/*  taken from palimpsest/gdu-section-unrecognized.c  */
-void
-do_format (FormatDialogPrivate *priv)
-{
-        FormatProcessData *data;
-        GduPresentable *toplevel_presentable;
-        GduDevice *toplevel_device;
-        gboolean create_new_part_table = FALSE;
-        gboolean create_new_partition = FALSE;
-        GduKnownFilesystem *kfs;
-        gint part_combo_item_index;
-
-
-        priv->job_cancelled = FALSE;
-        data = g_new0 (FormatProcessData, 1);
-        data->priv = priv;
-        data->job_progress_pulse_timer_id = 0;
-        toplevel_presentable = NULL;
-        toplevel_device = NULL;
-
-
-        data->presentable = g_object_ref (priv->presentable);
-        toplevel_presentable = gdu_presentable_get_toplevel (data->presentable);
-        if (toplevel_presentable == NULL) {
-                g_warning ("%s: no toplevel presentable",  __FUNCTION__);
-        }
-        toplevel_device = gdu_presentable_get_device (toplevel_presentable);
-        if (toplevel_device == NULL) {
-                g_warning ("%s: no device for toplevel presentable",  __FUNCTION__);
-                free_format_action_data (data);
-                goto out;
-        }
-        data->device = gdu_presentable_get_device (data->presentable);
-
-        if (data->device == NULL && toplevel_device != NULL) {
-                /*  no device, i.e. partition table exists but no partition  */
-                data->device = g_object_ref (toplevel_device);
-                create_new_part_table = FALSE;
-                create_new_partition = TRUE;
-                g_debug ("Partition table exists but has no partition for the selected device.");
-        } else
-                if (toplevel_device != NULL && ! gdu_device_is_partition_table (toplevel_device)) {
-                        /*  no partition table on the device, create partition table first.  */
-                        /*  also empty (zeroed) device  */
-                        create_new_part_table = TRUE;
-                        create_new_partition = TRUE;
-                        g_debug ("Device is known but doesn't have partition table, we need to create it first.");
-                } else
-                        if (toplevel_device != NULL && data->device != NULL && toplevel_device == data->device && device_needs_partition_table (data->device)) {
-                                /*  device is toplevel, check if we need new partitions  */
-                                create_new_partition = TRUE;
-                                g_debug ("Device is known but requires partitioning, we'll create new one.");
-                        }
-
-        if (data->device == NULL) {
-                g_warning ("%s: device is not supposed to be NULL",  __FUNCTION__);
-                free_format_action_data (data);
-                goto out;
-        }
-
-        part_combo_item_index = gtk_combo_box_get_active (GTK_COMBO_BOX (priv->part_type_combo_box));
-        if (part_combo_item_index < 0 || part_combo_item_index >= (int) G_N_ELEMENTS (filesystem_combo_items)) {
-                g_warning ("%s: no valid filesystem type specified",  __FUNCTION__);
-                free_format_action_data (data);
-                goto out;
-        }
-        data->fstype = filesystem_combo_items[part_combo_item_index].fstype;
-        data->fslabel = g_strdup (GTK_WIDGET_IS_SENSITIVE (priv->label_entry) ?
-                                  gtk_entry_get_text (GTK_ENTRY (priv->label_entry)) : "");
-
-        data->take_ownership = FALSE;
-        kfs = gdu_pool_get_known_filesystem_by_id (priv->pool, data->fstype);
-        if (kfs != NULL) {
-                if (gdu_known_filesystem_get_supports_unix_owners (kfs))
-                        data->take_ownership = TRUE;
-                g_object_unref (kfs);
-        }
-
-        update_ui_progress (priv, data, TRUE);
-
-        if (filesystem_combo_items[part_combo_item_index].encrypted) {
-                data->encrypt_passphrase = gdu_util_dialog_ask_for_new_secret (GTK_WIDGET (priv->dialog),
-                                                                               &data->save_in_keyring,
-                                                                               &data->save_in_keyring_session);
-                if (data->encrypt_passphrase == NULL) {
-                        free_format_action_data (data);
-                        goto out;
-                }
-        }
-
-        if (create_new_part_table && device_needs_partition_table (data->device)) {
-                /*  device is zeroed, create partition table first  */
-                gtk_action_activate (GTK_ACTION (data->part_table_new_action));
-        } else
-                if (create_new_partition && device_needs_partition_table (data->device)) {
-                        /*  device has partition table but has no partition  */
-                        gtk_action_activate (GTK_ACTION (data->part_new_action));
-                } else {
-                        gtk_action_activate (GTK_ACTION (data->format_action));
-                }
-
- out:
-        if (toplevel_presentable != NULL)
-                g_object_unref (toplevel_presentable);
-        if (toplevel_device != NULL)
-                g_object_unref (toplevel_device);
-}
diff --git a/src/format-tool/format-window-operation.h b/src/format-tool/format-window-operation.h
deleted file mode 100644
index 39f5499..0000000
--- a/src/format-tool/format-window-operation.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-/*
- *  format-window-operation.h
- *
- *  Copyright (C) 2008-2009 Red Hat, Inc.
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Library General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public
- *  License along with this library; if not, write to the Free
- *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *  Author: Tomas Bzatek <tbzatek redhat com>
- *
- */
-
-#ifndef FORMAT_WINDOW_OPERATION_H
-#define FORMAT_WINDOW_OPERATION_H
-
-#include <gtk/gtk.h>
-#include <gdu/gdu.h>
-#include "format-window.h"
-
-
-G_BEGIN_DECLS
-
-typedef struct
-{
-        FormatDialogPrivate *priv;
-        gchar *encrypt_passphrase;
-        gboolean save_in_keyring;
-        gboolean save_in_keyring_session;
-        gchar *fslabel;
-        const gchar *fstype;
-        GduDevice *device;
-        GduPresentable *presentable;
-        gboolean take_ownership;
-        const gchar *recommended_part_type;
-        const gchar *scheme;
-
-        guint job_progress_pulse_timer_id;
-
-        PolKitAction *pk_format_action;
-        PolKitGnomeAction *format_action;
-        PolKitAction *pk_part_modify_action;
-        PolKitGnomeAction *part_modify_action;
-        PolKitAction *pk_part_table_new_action;
-        PolKitGnomeAction *part_table_new_action;
-        PolKitAction *pk_part_new_action;
-        PolKitGnomeAction *part_new_action;
-} FormatProcessData;
-
-
-/*  update UI controls when operation is in progress  */
-void update_ui_progress  (FormatDialogPrivate *priv,
-                          FormatProcessData   *data,
-                          gboolean             working);
-
-/*  start the format operation  */
-void do_format           (FormatDialogPrivate *priv);
-
-
-G_END_DECLS
-
-#endif  /* FORMAT_WINDOW_OPERATION_H */
-
diff --git a/src/format-tool/format-window.c b/src/format-tool/format-window.c
deleted file mode 100644
index 61a8da4..0000000
--- a/src/format-tool/format-window.c
+++ /dev/null
@@ -1,578 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-/*
- *  format-window.c
- *
- *  Copyright (C) 2008-2009 Red Hat, Inc.
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Library General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public
- *  License along with this library; if not, write to the Free
- *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *  Author: Tomas Bzatek <tbzatek redhat com>
- *
- */
-
-#include "config.h"
-
-#include <glib/gi18n-lib.h>
-
-#include <gdu/gdu.h>
-#include <gdu-gtk/gdu-gtk.h>
-
-#include "gdu-utils.h"
-#include "format-window.h"
-#include "format-window-operation.h"
-
-#define DISK_MANAGEMENT_UTILITY  "palimpsest"
-
-
-
-/* ---------------------------------------------------------------------------*/
-
-static void set_new_presentable (FormatDialogPrivate *priv,
-                                 GduPresentable      *presentable);
-
-/* -------------------------------------------------------------------------- */
-
-
-static void
-populate_type_combo (FormatDialogPrivate *priv)
-{
-        guint i;
-        gint old_active;
-
-        g_return_if_fail (priv != NULL);
-
-        old_active = gtk_combo_box_get_active (GTK_COMBO_BOX (priv->part_type_combo_box));
-
-        for (i = G_N_ELEMENTS (filesystem_combo_items); i > 0; i--)
-                gtk_combo_box_remove_text (GTK_COMBO_BOX (priv->part_type_combo_box), i - 1);
-
-        for (i = 0; i < G_N_ELEMENTS (filesystem_combo_items); i++) {
-                if (! filesystem_combo_items[i].encrypted || gdu_pool_supports_luks_devices (priv->pool))
-                        gtk_combo_box_append_text (GTK_COMBO_BOX (priv->part_type_combo_box), _(filesystem_combo_items[i].title));
-        }
-
-        gtk_combo_box_set_active (GTK_COMBO_BOX (priv->part_type_combo_box), old_active);
-        /*  fallback  */
-        if (gtk_combo_box_get_active (GTK_COMBO_BOX (priv->part_type_combo_box)) == -1)
-                gtk_combo_box_set_active (GTK_COMBO_BOX (priv->part_type_combo_box), 0);
-}
-
-static void
-type_combo_box_changed (GtkWidget           *combo_box,
-                        FormatDialogPrivate *priv)
-{
-        const gchar *fstype;
-        GduKnownFilesystem *kfs;
-        gint max_label_len;
-        gint part_combo_item_index;
-
-        fstype = NULL;
-
-        max_label_len = 0;
-
-        part_combo_item_index = gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box));
-        if (part_combo_item_index < 0 || part_combo_item_index >= (int) G_N_ELEMENTS (filesystem_combo_items))
-                return;
-        fstype = filesystem_combo_items[part_combo_item_index].fstype;
-
-        kfs = gdu_pool_get_known_filesystem_by_id (priv->pool, fstype);
-        if (kfs != NULL) {
-                max_label_len = gdu_known_filesystem_get_max_label_len (kfs);
-                g_object_unref (kfs);
-        }
-
-        gtk_entry_set_max_length (GTK_ENTRY (priv->label_entry), max_label_len);
-}
-
-void
-update_ui_controls (FormatDialogPrivate *priv)
-{
-        GduDevice *device = NULL;
-        gboolean sensitive;
-
-        g_return_if_fail (priv != NULL);
-
-        if (priv->presentable && GDU_IS_PRESENTABLE (priv->presentable))
-                device = gdu_presentable_get_device (priv->presentable);
-
-        /*  mount warning box  */
-        if (device && gdu_device_is_mounted (device))
-                gtk_widget_show (priv->mount_warning);
-        else
-                gtk_widget_hide (priv->mount_warning);
-
-        /*  read only info box  */
-        if (device && gdu_device_is_read_only (device))
-                gtk_widget_show (priv->readonly_warning);
-        else
-                gtk_widget_hide (priv->readonly_warning);
-
-        /*  no media info box  */
-        if (! device || gdu_device_is_media_available (device))
-                gtk_widget_hide (priv->no_media_warning);
-        else
-                gtk_widget_show (priv->no_media_warning);
-
-        /*  controls sensitivity  */
-        sensitive = priv->presentable != NULL && GDU_IS_PRESENTABLE (priv->presentable) && (! priv->job_running);
-        if (device)
-                sensitive = sensitive && ! gdu_device_is_read_only (device) && gdu_device_is_media_available (device);
-
-        /*  volume label max length  */
-        type_combo_box_changed (priv->part_type_combo_box, priv);
-
-        gtk_widget_set_sensitive (priv->controls_box, sensitive);
-        gtk_dialog_set_response_sensitive (priv->dialog, GTK_RESPONSE_OK, sensitive && gtk_combo_box_get_active (GTK_COMBO_BOX (priv->part_type_combo_box)) >= 0);
-        gtk_dialog_set_response_sensitive (priv->dialog, GTK_RESPONSE_ACCEPT, ! priv->job_running);
-
-        if (device != NULL)
-                g_object_unref (device);
-}
-
-
-static void
-update_ui (FormatDialogPrivate *priv)
-{
-        gchar *s;
-        gchar *title;
-        const gchar *name;
-        GdkPixbuf *pixbuf;
-        GduDevice *device;
-        gchar *icon_name;
-        GIcon *presentable_icon;
-
-
-        g_return_if_fail (priv != NULL);
-        g_return_if_fail (priv->presentable != NULL);
-
-        device = gdu_presentable_get_device (priv->presentable);
-        name = gdu_presentable_get_name (priv->presentable);
-
-        /*  icon stuff  */
-        pixbuf = gdu_util_get_pixbuf_for_presentable_at_pixel_size (priv->presentable, 48);
-        gtk_image_set_from_pixbuf (GTK_IMAGE (priv->icon_image), pixbuf);
-        if (pixbuf)
-                g_object_unref (pixbuf);
-        presentable_icon = gdu_presentable_get_icon (priv->presentable);
-        if (presentable_icon) {
-                icon_name = _g_icon_get_string (presentable_icon);
-                gtk_window_set_icon_name (GTK_WINDOW (priv->dialog), icon_name);
-                g_free (icon_name);
-                g_object_unref (presentable_icon);
-        }
-
-        /*  window title  */
-        s = g_strdup_printf (_("Format Volume '%s'"), name);
-        gtk_window_set_title (GTK_WINDOW (priv->dialog), s);
-        g_free (s);
-
-        /*  title label  */
-        title = g_strconcat ("<big><big><b>", _("Format Volume '%s'?"), "</b></big></big>", NULL);
-        s = g_strdup_printf (title, name);
-        gtk_label_set_markup (GTK_LABEL (priv->name_label), s);
-        g_free (s);
-        g_free (title);
-
-        s = g_strdup_printf (_("You are about to format the volume \"%s\" (%s). All existing data will be irrevocably erased. Make sure important data is backed up. This action cannot be undone."),
-                             name, gdu_device_get_device_file (device));
-        gtk_label_set_markup (GTK_LABEL (priv->details_label), s);
-        g_free (s);
-
-        /*  partition type combo  */
-        if (! priv->job_running) {
-                populate_type_combo (priv);
-        }
-        /*  Is device mounted?  */
-        update_ui_controls (priv);
-
-        if (device != NULL)
-                g_object_unref (device);
-}
-
-
-/* -------------------------------------------------------------------------- */
-
-static void
-nautilus_gdu_destroy (FormatDialogPrivate  *priv)
-{
-        g_return_if_fail (priv != NULL);
-
-        /*  disconnect our handlers, since the presentable (resp. the pool) reference
-         *  counter doesn't really need to be zero
-         */
-        set_new_presentable (priv, NULL);
-        g_signal_handlers_disconnect_matched (priv->pool, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, priv);
-
-        /*  destroy the dialog and internal struct  */
-        gtk_widget_destroy (GTK_WIDGET (priv->dialog));
-        g_object_unref (priv->pool);
-        g_free (priv);
-
-        gtk_main_quit ();
-}
-
-static void
-presentable_removed (GduPresentable      *presentable,
-                     FormatDialogPrivate *priv)
-{
-        g_return_if_fail (priv != NULL);
-        g_warning ("Presentable removed event.");
-
-        nautilus_gdu_destroy (priv);
-}
-
-static void
-presentable_changed (GduPresentable      *presentable,
-                     FormatDialogPrivate *priv)
-{
-        g_return_if_fail (priv != NULL);
-        g_warning ("Presentable changed event.");
-
-        /*  TODO: shall we preserve label or any other settings?  */
-        update_ui (priv);
-}
-
-/*  we do ref presentable ourselves  */
-void
-select_new_presentable (FormatDialogPrivate *priv,
-                        GduPresentable      *presentable)
-{
-        /*  TODO: force refresh when no standalone mode ? */
-        /*  if (presentable != priv->presentable)  */
-        set_new_presentable (priv, presentable);
-}
-
-static void
-set_new_presentable (FormatDialogPrivate *priv,
-                     GduPresentable      *presentable)
-{
-        g_return_if_fail (priv != NULL);
-
-        if (priv->presentable) {
-                /*  first of all, disconnect handlers from the old presentable  */
-                g_signal_handlers_disconnect_matched (priv->presentable, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, priv);
-                /*    g_debug ("before unreffing presentable, count = %d [%p]", ((GObject*)priv->presentable)->ref_count, priv->presentable);  */
-                g_object_unref (priv->presentable);
-                priv->presentable = NULL;
-        }
-
-        if (presentable) {
-                priv->presentable = g_object_ref (presentable);
-                /*    g_debug ("set_new_presentable: after reffing presentable, count = %d [%p]", ((GObject*)priv->presentable)->ref_count, priv->presentable);  */
-
-                /*  catch Presentable events  */
-                g_signal_connect (G_OBJECT (priv->presentable), "removed",
-                                  G_CALLBACK (presentable_removed), priv);
-                g_signal_connect (G_OBJECT (priv->presentable), "changed",
-                                  G_CALLBACK (presentable_changed), priv);
-        }
-}
-
-/* -------------------------------------------------------------------------- */
-static void
-spawn_palimpsest (FormatDialogPrivate *priv)
-{
-        gchar *argv[] = { DISK_MANAGEMENT_UTILITY, NULL, NULL };
-
-        GduDevice *device;
-
-        device = gdu_presentable_get_device (priv->presentable);
-        if (device) {
-                argv[1] = g_strdup_printf ("--%s=%s", GDU_IS_DRIVE (priv->presentable) ? "show-drive" : "show-volume", gdu_device_get_device_file (device));
-                g_object_unref (device);
-        }
-
-        g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
-        g_free (argv[1]);
-}
-
-/* -------------------------------------------------------------------------- */
-
-static void
-cancel_operation (FormatDialogPrivate *priv)
-{
-        GduDevice *device;
-
-        g_return_if_fail (priv != NULL);
-        g_return_if_fail (priv->job_running == TRUE);
-        /*  TODO: check for valid device  */
-        g_return_if_fail (priv->presentable != NULL);
-        g_warning ("Cancelling...");
-
-        priv->job_cancelled = TRUE;
-        device = gdu_presentable_get_device (priv->presentable);
-
-        g_return_if_fail (device != NULL);
-        gdu_device_op_cancel_job (device, NULL, NULL);
-        g_object_unref (device);
-}
-
-static gboolean
-window_delete_event (GtkWidget            *widget,
-                     GdkEvent             *event,
-                     FormatDialogPrivate  *priv)
-{
-        g_return_val_if_fail (priv != NULL, FALSE);
-
-        if (priv->job_running) {
-                cancel_operation (priv);
-                return TRUE;  /*  consume the event  */
-        }
-
-        return FALSE;
-}
-
-static void
-format_dialog_got_response (GtkDialog            *dialog,
-                            gint                  response_id,
-                            FormatDialogPrivate  *priv)
-{
-        if (response_id == GTK_RESPONSE_OK) {
-                do_format (priv);
-        }
-        else if (response_id == GTK_RESPONSE_ACCEPT) {
-                spawn_palimpsest (priv);
-                nautilus_gdu_destroy (priv);
-        }
-        else if (priv->job_running) {
-                cancel_operation (priv);
-        }
-        else {
-                /*  destroy the window and unref the presentable  */
-                nautilus_gdu_destroy (priv);
-        }
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-static void
-set_default_volume_label (FormatDialogPrivate *priv)
-{
-        gchar *s;
-        GDate *date;
-
-        date = g_date_new ();
-        g_date_set_time_t (date, time (NULL));
-        s = g_strdup_printf (_("Data %d%.2d%.2d"), g_date_get_year (date), g_date_get_month (date), g_date_get_day (date));
-        gtk_entry_set_text (GTK_ENTRY (priv->label_entry), s);
-        g_free (s);
-        g_date_free (date);
-}
-
-/* -------------------------------------------------------------------------- */
-
-void
-nautilus_gdu_spawn_dialog (GduPresentable *presentable)
-{
-        FormatDialogPrivate *priv;
-        GtkDialog *dialog;
-        GtkWidget *content_area;
-        GtkWidget *button;
-        GtkWidget *icon;
-        GtkWidget *label;
-        GtkWidget *align;
-        GtkWidget *vbox3;
-        GtkWidget *vbox2;
-        GtkWidget *hbox;
-        GtkWidget *image;
-        GtkWidget *table;
-        GtkWidget *entry;
-        GtkWidget *combo_box;
-        GtkWidget *progress_bar;
-        gint row;
-
-        g_return_if_fail (presentable != NULL);
-
-        priv = g_new0 (FormatDialogPrivate, 1);
-        priv->job_running = FALSE;
-        priv->pool = gdu_presentable_get_pool (presentable);
-
-        dialog = GTK_DIALOG (gtk_dialog_new ());
-        priv->dialog = dialog;
-
-        /*  HIG stuff...  */
-        gtk_dialog_set_has_separator (dialog, FALSE);
-        gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
-        gtk_box_set_spacing (GTK_BOX (dialog->vbox), 2);
-        gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 5);
-        gtk_box_set_spacing (GTK_BOX (dialog->action_area), 6);
-
-        gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
-        gtk_window_set_title (GTK_WINDOW (dialog), "");
-
-        gtk_dialog_add_buttons (dialog,
-                                _("_Format"), GTK_RESPONSE_OK,
-                                NULL);
-        priv->close_button = gtk_dialog_add_button (dialog, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
-        button = gtk_dialog_add_button (dialog, _("Open Disk Utility"), GTK_RESPONSE_ACCEPT);
-        icon = gtk_image_new_from_icon_name ("palimpsest", GTK_ICON_SIZE_BUTTON);
-        gtk_button_set_image (GTK_BUTTON (button), icon);
-        gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (gtk_dialog_get_action_area (dialog)), button, TRUE);
-        gtk_widget_set_tooltip_text (button, _("Format volume using the Palimpsest Disk Utility"));
-        gtk_dialog_set_default_response (dialog, GTK_RESPONSE_CLOSE);
-
-        content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
-        gtk_container_set_border_width (GTK_CONTAINER (content_area), 10);
-
-
-        /*  headlines  */
-        priv->all_controls_box = gtk_vbox_new (FALSE, 0);
-        gtk_box_pack_start (GTK_BOX (content_area), priv->all_controls_box, FALSE, TRUE, 0);
-
-        hbox = gtk_hbox_new (FALSE, 0);
-        gtk_box_pack_start (GTK_BOX (priv->all_controls_box), hbox, TRUE, TRUE, 0);
-
-        image = gtk_image_new ();
-        gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 5);
-        priv->icon_image = image;
-
-        label = gtk_label_new (NULL);
-        gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 5);
-        priv->name_label = label;
-
-        /*  partition  */
-        vbox3 = gtk_vbox_new (FALSE, 2);
-        align = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
-        gtk_alignment_set_padding (GTK_ALIGNMENT (align), 10, 30, 14, 10);
-        gtk_container_add (GTK_CONTAINER (align), vbox3);
-        gtk_box_pack_start (GTK_BOX (priv->all_controls_box), align, FALSE, TRUE, 0);
-
-        label = gtk_label_new (NULL);
-        gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-        gtk_misc_set_padding (GTK_MISC (label), 10, 10);
-        gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
-        /*  gtk_label_set_width_chars (GTK_LABEL (label), 50);  */
-        gtk_box_pack_start (GTK_BOX (vbox3), label, FALSE, TRUE, 0);
-        priv->details_label = label;
-
-        vbox2 = gtk_vbox_new (FALSE, 5);
-        align = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
-        gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 0, 24, 0);
-        gtk_container_add (GTK_CONTAINER (align), vbox2);
-        gtk_box_pack_start (GTK_BOX (vbox3), align, FALSE, TRUE, 0);
-        priv->controls_box = vbox2;
-
-        row = 0;
-
-        table = gtk_table_new (2, 2, FALSE);
-        gtk_box_pack_start (GTK_BOX (vbox2), table, FALSE, FALSE, 0);
-
-        /*  partition type  */
-        label = gtk_label_new (NULL);
-        gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
-        gtk_label_set_markup_with_mnemonic (GTK_LABEL (label), _("_Type:"));
-        gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row + 1,
-                          GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2);
-        combo_box = gtk_combo_box_new_text ();
-        gtk_table_attach (GTK_TABLE (table), combo_box, 1, 2, row, row +1,
-                          GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2);
-        gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo_box);
-        priv->part_type_combo_box = combo_box;
-        row++;
-
-        /*  volume label  */
-        label = gtk_label_new (NULL);
-        gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
-        gtk_label_set_markup_with_mnemonic (GTK_LABEL (label), _("_Name:"));
-        gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row + 1,
-                          GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2);
-        entry = gtk_entry_new ();
-        gtk_table_attach (GTK_TABLE (table), entry, 1, 2, row, row + 1,
-                          GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2);
-        gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
-        priv->label_entry = entry;
-        row++;
-
-        /*  mounted warning box  */
-        hbox = gtk_hbox_new (FALSE, 7);
-        align = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
-        gtk_alignment_set_padding (GTK_ALIGNMENT (align), 15, 15, 20, 0);
-        gtk_container_add (GTK_CONTAINER (align), hbox);
-        gtk_box_pack_start (GTK_BOX (priv->all_controls_box), align, FALSE, TRUE, 0);
-        priv->mount_warning = align;
-        image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_LARGE_TOOLBAR);
-        gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
-        label = gtk_label_new (_("The volume is currently mounted. Please make sure to close all open files before formatting."));
-        gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
-        gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
-        gtk_widget_show_all (priv->mount_warning);
-        gtk_widget_hide (priv->mount_warning);
-        gtk_widget_set_no_show_all (priv->mount_warning, TRUE);
-
-        /*  readonly info box  */
-        hbox = gtk_hbox_new (FALSE, 7);
-        align = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
-        gtk_alignment_set_padding (GTK_ALIGNMENT (align), 10, 10, 20, 0);
-        gtk_container_add (GTK_CONTAINER (align), hbox);
-        gtk_box_pack_start (GTK_BOX (priv->all_controls_box), align, FALSE, TRUE, 0);
-        priv->readonly_warning = align;
-        image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_LARGE_TOOLBAR);
-        gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
-        label = gtk_label_new (_("Device is read only"));
-        gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
-        gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
-        gtk_widget_show_all (priv->readonly_warning);
-        gtk_widget_hide (priv->readonly_warning);
-        gtk_widget_set_no_show_all (priv->readonly_warning, TRUE);
-
-        /*  no media info box  */
-        hbox = gtk_hbox_new (FALSE, 7);
-        align = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
-        gtk_alignment_set_padding (GTK_ALIGNMENT (align), 10, 10, 20, 0);
-        gtk_container_add (GTK_CONTAINER (align), hbox);
-        gtk_box_pack_start (GTK_BOX (priv->all_controls_box), align, FALSE, TRUE, 0);
-        priv->no_media_warning = align;
-        image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_LARGE_TOOLBAR);
-        gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
-        label = gtk_label_new (_("No media in drive"));
-        gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
-        gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
-        gtk_widget_show_all (priv->no_media_warning);
-        gtk_widget_hide (priv->no_media_warning);
-        gtk_widget_set_no_show_all (priv->no_media_warning, TRUE);
-
-        /*  progress bar  */
-        align = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
-        gtk_alignment_set_padding (GTK_ALIGNMENT (align), 75, 75, 30, 30);
-        priv->progress_bar_box = align;
-
-        progress_bar = gtk_progress_bar_new ();
-        gtk_widget_set_size_request (progress_bar, 375, -1);   /*  TODO: this is an ugly hack  */
-        priv->progress_bar = progress_bar;
-        gtk_container_add (GTK_CONTAINER (align), progress_bar);
-        gtk_box_pack_start (GTK_BOX (content_area), align, TRUE, FALSE, 0);
-        gtk_widget_show_all (priv->progress_bar_box);
-        gtk_widget_hide (priv->progress_bar_box);
-        gtk_widget_set_no_show_all (priv->progress_bar_box, TRUE);
-
-
-        g_signal_connect (priv->dialog, "delete-event",
-                          G_CALLBACK (window_delete_event), priv);
-        g_signal_connect (priv->part_type_combo_box, "changed",
-                          G_CALLBACK (type_combo_box_changed), priv);
-        /*  update sensivity and length of fs label + entry  */
-        g_signal_connect (G_OBJECT (dialog), "response",
-                          G_CALLBACK (format_dialog_got_response), priv);
-
-        gtk_widget_show_all (GTK_WIDGET (dialog));
-        gtk_widget_grab_focus (priv->close_button);
-        set_new_presentable (priv, presentable);
-        update_ui (priv);
-        update_ui_progress (priv, NULL, FALSE);
-        set_default_volume_label (priv);
-}
diff --git a/src/format-tool/format-window.h b/src/format-tool/format-window.h
deleted file mode 100644
index c9d7421..0000000
--- a/src/format-tool/format-window.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-/*
- *  format-window.h
- *
- *  Copyright (C) 2008-2009 Red Hat, Inc.
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Library General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public
- *  License along with this library; if not, write to the Free
- *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *  Author: Tomas Bzatek <tbzatek redhat com>
- *
- */
-
-#ifndef FORMAT_WINDOW_H
-#define FORMAT_WINDOW_H
-
-#include <gtk/gtk.h>
-#include <gdu/gdu.h>
-#include <polkit-gnome/polkit-gnome.h>
-
-
-G_BEGIN_DECLS
-
-typedef struct
-{
-        GtkDialog *dialog;
-        GtkWidget *close_button;
-        GtkWidget *icon_image;
-        GtkWidget *name_label;
-        GtkWidget *details_label;
-        GtkWidget *mount_warning;
-        GtkWidget *readonly_warning;
-        GtkWidget *no_media_warning;
-        GtkWidget *label_entry;
-        GtkWidget *part_type_combo_box;
-        GtkWidget *progress_bar;
-        GtkWidget *progress_bar_box;
-        GtkWidget *controls_box;
-        GtkWidget *all_controls_box;
-
-        GduPresentable *presentable;
-        GduPool *pool;
-
-        gboolean job_running;
-        gboolean job_cancelled;
-} FormatDialogPrivate;
-
-
-typedef struct
-{
-        const char *fstype;
-        gboolean encrypted;
-        char *title;
-} FormatComboBoxItem;
-
-
-static FormatComboBoxItem filesystem_combo_items[] =
-        {
-                {"vfat", FALSE, "Compatible with all systems (FAT)"},
-                {"ext2", FALSE, "Compatible with Linux systems, no journal (ext2)"},
-                {"ext3", FALSE, "Compatible with Linux systems (ext3)"},
-                {"ext3", TRUE, "Encrypted, compatible with Linux systems (LUKS)"}
-        };
-
-
-/*  pass presentable=NULL and standalone_mode=TRUE to display volume selector */
-/*  we do ref presentable ourselves */
-void  nautilus_gdu_spawn_dialog  (GduPresentable      *presentable);
-
-/*  update sensitivity of main controls, action buttons etc.  */
-void  update_ui_controls         (FormatDialogPrivate *priv);
-
-/*  we do ref presentable ourselves  */
-void  select_new_presentable     (FormatDialogPrivate *priv,
-                                  GduPresentable      *presentable);
-
-G_END_DECLS
-
-#endif  /* FORMAT_WINDOW_H */
-
diff --git a/src/format-tool/gdu-format-dialog.c b/src/format-tool/gdu-format-dialog.c
new file mode 100644
index 0000000..7c24284
--- /dev/null
+++ b/src/format-tool/gdu-format-dialog.c
@@ -0,0 +1,452 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/*
+ *  format-window.c
+ *
+ *  Copyright (C) 2008-2009 Red Hat, Inc.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public
+ *  License along with this library; if not, write to the Free
+ *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *  Author: Tomas Bzatek <tbzatek redhat com>
+ *          David Zeuthen <davidz redhat com>
+ *
+ */
+
+#include "config.h"
+
+#include <glib/gi18n-lib.h>
+#include <gdu/gdu.h>
+#include <gdu-gtk/gdu-gtk.h>
+
+#include "gdu-format-dialog.h"
+
+struct GduFormatDialogPrivate
+{
+        GduVolume *volume;
+        gchar *fs_type;
+        gboolean encrypt;
+        GduPool *pool;
+        GtkWidget *fs_label_entry;
+};
+
+enum
+{
+        PROP_0,
+        PROP_VOLUME,
+        PROP_FS_TYPE,
+        PROP_FS_LABEL,
+        PROP_ENCRYPT,
+};
+
+static void gdu_format_dialog_constructed (GObject *object);
+
+G_DEFINE_TYPE (GduFormatDialog, gdu_format_dialog, GTK_TYPE_DIALOG)
+
+static void
+gdu_format_dialog_finalize (GObject *object)
+{
+        GduFormatDialog *dialog = GDU_FORMAT_DIALOG (object);
+
+        g_object_unref (dialog->priv->volume);
+        g_object_unref (dialog->priv->pool);
+        g_free (dialog->priv->fs_type);
+
+        if (G_OBJECT_CLASS (gdu_format_dialog_parent_class)->finalize != NULL)
+                G_OBJECT_CLASS (gdu_format_dialog_parent_class)->finalize (object);
+}
+
+static void
+gdu_format_dialog_get_property (GObject    *object,
+                                guint       property_id,
+                                GValue     *value,
+                                GParamSpec *pspec)
+{
+        GduFormatDialog *dialog = GDU_FORMAT_DIALOG (object);
+
+        switch (property_id) {
+        case PROP_VOLUME:
+                g_value_set_object (value, dialog->priv->volume);
+                break;
+
+        case PROP_FS_TYPE:
+                g_value_set_string (value, dialog->priv->fs_type);
+                break;
+
+        case PROP_FS_LABEL:
+                g_value_set_string (value, gdu_format_dialog_get_fs_label (dialog));
+                break;
+
+        case PROP_ENCRYPT:
+                g_value_set_boolean (value, dialog->priv->encrypt);
+                break;
+
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                break;
+        }
+}
+
+static void
+gdu_format_dialog_set_property (GObject      *object,
+                                   guint         property_id,
+                                   const GValue *value,
+                                   GParamSpec   *pspec)
+{
+        GduFormatDialog *dialog = GDU_FORMAT_DIALOG (object);
+
+        switch (property_id) {
+        case PROP_VOLUME:
+                dialog->priv->volume = g_value_dup_object (value);
+                dialog->priv->pool = gdu_presentable_get_pool (GDU_PRESENTABLE (dialog->priv->volume));
+                break;
+
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                break;
+        }
+}
+
+static void
+gdu_format_dialog_class_init (GduFormatDialogClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+        g_type_class_add_private (klass, sizeof (GduFormatDialogPrivate));
+
+        object_class->get_property = gdu_format_dialog_get_property;
+        object_class->set_property = gdu_format_dialog_set_property;
+        object_class->constructed  = gdu_format_dialog_constructed;
+        object_class->finalize     = gdu_format_dialog_finalize;
+
+        g_object_class_install_property (object_class,
+                                         PROP_VOLUME,
+                                         g_param_spec_object ("volume",
+                                                              _("Volume"),
+                                                              _("The volume to format"),
+                                                              GDU_TYPE_VOLUME,
+                                                              G_PARAM_READABLE |
+                                                              G_PARAM_WRITABLE |
+                                                              G_PARAM_CONSTRUCT_ONLY |
+                                                              G_PARAM_STATIC_NAME |
+                                                              G_PARAM_STATIC_NICK |
+                                                              G_PARAM_STATIC_BLURB));
+
+        g_object_class_install_property (object_class,
+                                         PROP_FS_TYPE,
+                                         g_param_spec_string ("fs-type",
+                                                              _("Filesystem type"),
+                                                              _("The selected filesystem type"),
+                                                              NULL,
+                                                              G_PARAM_READABLE |
+                                                              G_PARAM_STATIC_NAME |
+                                                              G_PARAM_STATIC_NICK |
+                                                              G_PARAM_STATIC_BLURB));
+
+        g_object_class_install_property (object_class,
+                                         PROP_FS_LABEL,
+                                         g_param_spec_string ("fs-label",
+                                                              _("Filesystem label"),
+                                                              _("The requested filesystem label"),
+                                                              NULL,
+                                                              G_PARAM_READABLE |
+                                                              G_PARAM_STATIC_NAME |
+                                                              G_PARAM_STATIC_NICK |
+                                                              G_PARAM_STATIC_BLURB));
+
+        g_object_class_install_property (object_class,
+                                         PROP_ENCRYPT,
+                                         g_param_spec_boolean ("encrypt",
+                                                               _("Encryption"),
+                                                               _("Whether the volume should be encrypted"),
+                                                               FALSE,
+                                                               G_PARAM_READABLE |
+                                                               G_PARAM_STATIC_NAME |
+                                                               G_PARAM_STATIC_NICK |
+                                                               G_PARAM_STATIC_BLURB));
+}
+
+static void
+gdu_format_dialog_init (GduFormatDialog *dialog)
+{
+        dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (dialog, GDU_TYPE_FORMAT_DIALOG, GduFormatDialogPrivate);
+}
+
+GtkWidget *
+gdu_format_dialog_new (GtkWindow *parent,
+                       GduVolume *volume)
+{
+        return GTK_WIDGET (g_object_new (GDU_TYPE_FORMAT_DIALOG,
+                                         "transient-for", parent,
+                                         "volume", volume,
+                                         NULL));
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+gchar *
+gdu_format_dialog_get_fs_type  (GduFormatDialog *dialog)
+{
+        g_return_val_if_fail (GDU_IS_FORMAT_DIALOG (dialog), NULL);
+        return g_strdup (dialog->priv->fs_type);
+}
+
+gchar *
+gdu_format_dialog_get_fs_label (GduFormatDialog *dialog)
+{
+        g_return_val_if_fail (GDU_IS_FORMAT_DIALOG (dialog), NULL);
+        return g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->priv->fs_label_entry)));
+}
+
+gboolean
+gdu_format_dialog_get_encrypt  (GduFormatDialog *dialog)
+{
+        g_return_val_if_fail (GDU_IS_FORMAT_DIALOG (dialog), FALSE);
+        return dialog->priv->encrypt;
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static void
+on_combo_box_changed (GtkWidget *combo_box,
+                      gpointer   user_data)
+{
+        GduFormatDialog *dialog = GDU_FORMAT_DIALOG (user_data);
+        GduKnownFilesystem *kfs;
+        gint max_label_len;
+
+        /* keep in sync with where combo box is constructed in constructed() */
+        g_free (dialog->priv->fs_type);
+        switch (gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box))) {
+        case 0:
+                dialog->priv->fs_type = g_strdup ("vfat");
+                dialog->priv->encrypt = FALSE;
+                break;
+        case 1:
+                dialog->priv->fs_type = g_strdup ("ext2");
+                dialog->priv->encrypt = FALSE;
+                break;
+        case 2:
+                dialog->priv->fs_type = g_strdup ("ext3");
+                dialog->priv->encrypt = FALSE;
+                break;
+        case 3:
+                dialog->priv->fs_type = g_strdup ("vfat");
+                dialog->priv->encrypt = TRUE;
+                break;
+        default:
+                g_assert_not_reached ();
+                break;
+        }
+
+        max_label_len = 0;
+        kfs = gdu_pool_get_known_filesystem_by_id (dialog->priv->pool, dialog->priv->fs_type);
+        if (kfs != NULL) {
+                max_label_len = gdu_known_filesystem_get_max_label_len (kfs);
+                g_object_unref (kfs);
+        }
+        gtk_entry_set_max_length (GTK_ENTRY (dialog->priv->fs_label_entry), max_label_len);
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static void
+on_presentable_removed (GduPresentable *presentable,
+                        gpointer        user_data)
+{
+        GduFormatDialog *dialog = GDU_FORMAT_DIALOG (user_data);
+
+        gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static void
+gdu_format_dialog_constructed (GObject *object)
+{
+        GduFormatDialog *dialog = GDU_FORMAT_DIALOG (object);
+        GtkWidget *content_area;
+        GtkWidget *button;
+        GtkWidget *icon;
+        GtkWidget *label;
+        GtkWidget *hbox;
+        GtkWidget *image;
+        GtkWidget *table;
+        GtkWidget *entry;
+        GtkWidget *combo_box;
+        GtkWidget *vbox2;
+        GdkPixbuf *pixbuf;
+        gint row;
+        GduPool *pool;
+        GduDevice *device;
+        GduPresentable *toplevel;
+        gchar *drive_name;
+        gchar *name;
+        gchar *primary;
+        gchar *secondary;
+        gboolean ret;
+        GtkWidget *align;
+
+        toplevel = NULL;
+        name = NULL;
+        drive_name = NULL;
+        primary = NULL;
+        secondary = NULL;
+        ret = FALSE;
+
+        pool = gdu_presentable_get_pool (GDU_PRESENTABLE (dialog->priv->volume));
+        device = gdu_presentable_get_device (GDU_PRESENTABLE (dialog->priv->volume));
+        name = gdu_presentable_get_name (GDU_PRESENTABLE (dialog->priv->volume));
+        toplevel = gdu_presentable_get_toplevel (GDU_PRESENTABLE (dialog->priv->volume));
+        if (toplevel != NULL && GDU_IS_DRIVE (toplevel)) {
+                drive_name = gdu_presentable_get_name (toplevel);
+        }
+
+        pixbuf = gdu_util_get_pixbuf_for_presentable (GDU_PRESENTABLE (dialog->priv->volume), GTK_ICON_SIZE_DIALOG);
+
+        primary = g_strconcat ("<big><big><b>",
+                               _("Are you sure you want to format the volume?"),
+                               "</b></big></big>", NULL);
+        if (drive_name != NULL) {
+                secondary = g_strdup_printf (_("You are about to format the volume \"%s\" on the drive \"%s\" (%s). "
+                                               "All existing data will be irrevocably erased."),
+                                             name,
+                                             drive_name,
+                                             gdu_device_get_device_file (device));
+        } else {
+                secondary = g_strdup_printf (_("You are about to format the volume \"%s\" (%s). "
+                                               "All existing data will be irrevocably erased."),
+                                             name,
+                                             gdu_device_get_device_file (device));
+        }
+
+        gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
+        gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
+        gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 0);
+        gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 5);
+        gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->action_area), 6);
+
+        gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+        gtk_window_set_title (GTK_WINDOW (dialog), "");
+        gtk_window_set_icon_name (GTK_WINDOW (dialog), "nautilus-gdu");
+
+        gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+        button = gtk_dialog_add_button (GTK_DIALOG (dialog),
+                                        _("_Format"),
+                                        GTK_RESPONSE_OK);
+        icon = gtk_image_new_from_stock (GTK_STOCK_CLEAR, GTK_ICON_SIZE_BUTTON);
+        gtk_button_set_image (GTK_BUTTON (button), icon);
+        button = gtk_dialog_add_button (GTK_DIALOG (dialog), _("Disk _Utility"), GTK_RESPONSE_ACCEPT);
+        icon = gtk_image_new_from_icon_name ("palimpsest", GTK_ICON_SIZE_BUTTON);
+        gtk_button_set_image (GTK_BUTTON (button), icon);
+        gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (gtk_dialog_get_action_area (GTK_DIALOG (dialog))),
+                                            button,
+                                            TRUE);
+        gtk_widget_set_tooltip_text (button, _("Open volume in Palimpsest Disk Utility"));
+        gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
+
+        content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+        gtk_container_set_border_width (GTK_CONTAINER (content_area), 10);
+
+        /*  icon and primary+secondary labels  */
+        hbox = gtk_hbox_new (FALSE, 0);
+        gtk_box_pack_start (GTK_BOX (content_area), hbox, FALSE, TRUE, 0);
+
+        image = gtk_image_new_from_pixbuf (pixbuf);
+        gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
+        gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 12);
+
+        align = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
+        gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 12, 0, 0);
+        gtk_box_pack_start (GTK_BOX (hbox), align, TRUE, TRUE, 0);
+
+        vbox2 = gtk_vbox_new (FALSE, 12);
+        gtk_container_add (GTK_CONTAINER (align), vbox2);
+
+        label = gtk_label_new (NULL);
+        gtk_label_set_markup (GTK_LABEL (label), primary);
+        gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+        gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+        gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, TRUE, 0);
+
+        label = gtk_label_new (NULL);
+        gtk_label_set_markup (GTK_LABEL (label), secondary);
+        gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+        gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+        gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, TRUE, 0);
+
+        row = 0;
+
+        table = gtk_table_new (2, 2, FALSE);
+        gtk_table_set_col_spacings (GTK_TABLE (table), 12);
+        gtk_table_set_row_spacings (GTK_TABLE (table), 6);
+        gtk_box_pack_start (GTK_BOX (vbox2), table, FALSE, FALSE, 0);
+
+        /*  filesystem type  */
+        label = gtk_label_new (NULL);
+        gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
+        gtk_label_set_markup_with_mnemonic (GTK_LABEL (label), _("_Type:"));
+        gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row + 1,
+                          GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2);
+        combo_box = gtk_combo_box_new_text ();
+        /* keep in sync with on_combo_box_changed() */
+        gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box),
+                                   _("Compatible with all systems (FAT)"));
+        gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box),
+                                   _("Compatible with Linux (ext2)"));
+        gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box),
+                                   _("Compatible with Linux (ext3)"));
+        gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box),
+                                   _("Encrypted, compatible with Linux (FAT)"));
+        gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), 0);
+        dialog->priv->fs_type = g_strdup ("vfat");
+        dialog->priv->encrypt = FALSE;
+        gtk_table_attach (GTK_TABLE (table), combo_box, 1, 2, row, row +1,
+                          GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2);
+        gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo_box);
+        row++;
+
+        /*  filesystem label  */
+        label = gtk_label_new (NULL);
+        gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
+        gtk_label_set_markup_with_mnemonic (GTK_LABEL (label), _("_Name:"));
+        gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row + 1,
+                          GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2);
+        entry = gtk_entry_new ();
+        /* Translators: Keep length of translation of "New Volume" to less than 16 characters */
+        gtk_entry_set_text (GTK_ENTRY (entry), _("New Volume"));
+        gtk_table_attach (GTK_TABLE (table), entry, 1, 2, row, row + 1,
+                          GTK_FILL, GTK_EXPAND | GTK_FILL, 2, 2);
+        gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
+        dialog->priv->fs_label_entry = entry;
+        row++;
+
+        g_signal_connect (combo_box,
+                          "changed",
+                          G_CALLBACK (on_combo_box_changed),
+                          dialog);
+
+        /* nuke dialog if device is yanked */
+        g_signal_connect (dialog->priv->volume,
+                          "removed",
+                          G_CALLBACK (on_presentable_removed),
+                          dialog);
+
+        gtk_widget_grab_focus (entry);
+        gtk_editable_select_region (GTK_EDITABLE (entry), 0, 1000);
+
+        if (G_OBJECT_CLASS (gdu_format_dialog_parent_class)->constructed != NULL)
+                G_OBJECT_CLASS (gdu_format_dialog_parent_class)->constructed (object);
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/format-tool/gdu-format-dialog.h b/src/format-tool/gdu-format-dialog.h
new file mode 100644
index 0000000..57e9896
--- /dev/null
+++ b/src/format-tool/gdu-format-dialog.h
@@ -0,0 +1,71 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/*
+ *  format-window.h
+ *
+ *  Copyright (C) 2008-2009 Red Hat, Inc.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public
+ *  License along with this library; if not, write to the Free
+ *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *  Author: Tomas Bzatek <tbzatek redhat com>
+ *          David Zeuthen <davidz redhat com>
+ *
+ */
+
+#ifndef __GDU_FORMAT_DIALOG_H
+#define __GDU_FORMAT_DIALOG_H
+
+#include <gtk/gtk.h>
+#include <gdu/gdu.h>
+#include <polkit-gnome/polkit-gnome.h>
+
+G_BEGIN_DECLS
+
+/* TODO: move to libgdu-gtk */
+
+#define GDU_TYPE_FORMAT_DIALOG            gdu_format_dialog_get_type()
+#define GDU_FORMAT_DIALOG(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDU_TYPE_FORMAT_DIALOG, GduFormatDialog))
+#define GDU_FORMAT_DIALOG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GDU_TYPE_FORMAT_DIALOG, GduFormatDialogClass))
+#define GDU_IS_FORMAT_DIALOG(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDU_TYPE_FORMAT_DIALOG))
+#define GDU_IS_FORMAT_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDU_TYPE_FORMAT_DIALOG))
+#define GDU_FORMAT_DIALOG_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GDU_TYPE_FORMAT_DIALOG, GduFormatDialogClass))
+
+typedef struct GduFormatDialog        GduFormatDialog;
+typedef struct GduFormatDialogClass   GduFormatDialogClass;
+typedef struct GduFormatDialogPrivate GduFormatDialogPrivate;
+
+struct GduFormatDialog
+{
+        GtkDialog parent;
+
+        /*< private >*/
+        GduFormatDialogPrivate *priv;
+};
+
+struct GduFormatDialogClass
+{
+        GtkDialogClass parent_class;
+};
+
+GType       gdu_format_dialog_get_type     (void) G_GNUC_CONST;
+GtkWidget*  gdu_format_dialog_new          (GtkWindow *parent,
+                                            GduVolume *volume);
+gchar      *gdu_format_dialog_get_fs_type  (GduFormatDialog *dialog);
+gchar      *gdu_format_dialog_get_fs_label (GduFormatDialog *dialog);
+gboolean    gdu_format_dialog_get_encrypt  (GduFormatDialog *dialog);
+
+G_END_DECLS
+
+#endif  /* __GDU_FORMAT_DIALOG_H */
+
diff --git a/src/format-tool/gdu-format-progress-dialog.c b/src/format-tool/gdu-format-progress-dialog.c
new file mode 100644
index 0000000..63de555
--- /dev/null
+++ b/src/format-tool/gdu-format-progress-dialog.c
@@ -0,0 +1,263 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/* gdu-slow-unmount-dialog.c
+ *
+ * Copyright (C) 2009 David Zeuthen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <glib/gi18n.h>
+
+#include <gdu-gtk/gdu-gtk.h>
+
+#include "gdu-format-progress-dialog.h"
+
+struct GduFormatProgressDialogPrivate
+{
+        GduDevice *device;
+        GduPool *pool;
+        GduPresentable *presentable;
+        gchar *device_name;
+
+        gchar *text;
+
+        GtkWidget *label;
+        GtkWidget *progress_bar;
+        GtkWidget *details_label;
+
+        guint pulse_timer_id;
+};
+
+enum
+{
+        PROP_0,
+        PROP_DEVICE,
+        PROP_TEXT,
+};
+
+G_DEFINE_TYPE (GduFormatProgressDialog, gdu_format_progress_dialog, GTK_TYPE_DIALOG)
+
+static void
+gdu_format_progress_dialog_finalize (GObject *object)
+{
+        GduFormatProgressDialog *dialog = GDU_FORMAT_PROGRESS_DIALOG (object);
+
+        g_object_unref (dialog->priv->device);
+        g_object_unref (dialog->priv->pool);
+        g_object_unref (dialog->priv->presentable);
+        if (dialog->priv->pulse_timer_id > 0)
+                g_source_remove (dialog->priv->pulse_timer_id);
+        g_free (dialog->priv->device_name);
+
+        if (G_OBJECT_CLASS (gdu_format_progress_dialog_parent_class)->finalize != NULL)
+                G_OBJECT_CLASS (gdu_format_progress_dialog_parent_class)->finalize (object);
+}
+
+static void
+gdu_format_progress_dialog_get_property (GObject    *object,
+                                   guint       property_id,
+                                   GValue     *value,
+                                   GParamSpec *pspec)
+{
+        GduFormatProgressDialog *dialog = GDU_FORMAT_PROGRESS_DIALOG (object);
+
+        switch (property_id) {
+        case PROP_DEVICE:
+                g_value_set_object (value, dialog->priv->device);
+                break;
+
+        case PROP_TEXT:
+                g_value_set_string (value, dialog->priv->text);
+                break;
+
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                break;
+        }
+}
+
+static void
+gdu_format_progress_dialog_set_property (GObject      *object,
+                                   guint         property_id,
+                                   const GValue *value,
+                                   GParamSpec   *pspec)
+{
+        GduFormatProgressDialog *dialog = GDU_FORMAT_PROGRESS_DIALOG (object);
+
+        switch (property_id) {
+        case PROP_DEVICE:
+                dialog->priv->device = g_value_dup_object (value);
+                dialog->priv->pool = gdu_device_get_pool (dialog->priv->device);
+                dialog->priv->presentable = gdu_pool_get_volume_by_device (dialog->priv->pool,
+                                                                           dialog->priv->device);
+                dialog->priv->device_name = gdu_presentable_get_name (dialog->priv->presentable);
+                break;
+
+        case PROP_TEXT:
+                g_free (dialog->priv->text);
+                dialog->priv->text = g_value_dup_string (value);
+                if (dialog->priv->label != NULL) {
+                        gtk_label_set_markup (GTK_LABEL (dialog->priv->label),
+                                              dialog->priv->text);
+                }
+                break;
+
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                break;
+        }
+}
+
+static gboolean
+on_pulse_timeout (gpointer user_data)
+{
+        GduFormatProgressDialog *dialog = GDU_FORMAT_PROGRESS_DIALOG (user_data);
+
+        /* TODO: would be nice to show a progress bar instead of pulse once
+         *       DeviceKit-disks is able to report progress on FilesystemCreate()
+         */
+
+        gtk_progress_bar_pulse (GTK_PROGRESS_BAR (dialog->priv->progress_bar));
+
+        /* keep timeout around */
+        return TRUE;
+}
+
+static void
+gdu_format_progress_dialog_constructed (GObject *object)
+{
+        GduFormatProgressDialog *dialog = GDU_FORMAT_PROGRESS_DIALOG (object);
+        GtkWidget *content_area;
+        GtkWidget *align;
+        GtkWidget *vbox;
+        GtkWidget *label;
+        GtkWidget *progress_bar;
+        gchar *s;
+
+
+        gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
+
+        gtk_window_set_title (GTK_WINDOW (dialog), "");
+        gtk_window_set_icon_name (GTK_WINDOW (dialog), "nautilus-gdu");
+
+        content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+        align = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
+        gtk_alignment_set_padding (GTK_ALIGNMENT (align), 12, 12, 12, 12);
+        gtk_box_pack_start (GTK_BOX (content_area), align, TRUE, TRUE, 0);
+
+        vbox = gtk_vbox_new (FALSE, 12);
+        gtk_container_add (GTK_CONTAINER (align), vbox);
+
+        label = gtk_label_new (NULL);
+        gtk_label_set_markup (GTK_LABEL (label), dialog->priv->text);
+	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+	gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+        gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+        dialog->priv->label = label;
+
+        progress_bar = gtk_progress_bar_new ();
+        gtk_box_pack_start (GTK_BOX (vbox), progress_bar, FALSE, FALSE, 0);
+        dialog->priv->progress_bar = progress_bar;
+
+        label = gtk_label_new (NULL);
+	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+	gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+        s = g_strconcat ("<small>",
+                         _("To prevent data corruption, wait until this has finished before removing "
+                           "media or disconnecting the device."),
+                         "</small>",
+                         NULL);
+        gtk_label_set_markup (GTK_LABEL (label), s);
+        g_free (s);
+        gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+        dialog->priv->details_label = label;
+
+        dialog->priv->pulse_timer_id = g_timeout_add (50,
+                                                      on_pulse_timeout,
+                                                      dialog);
+
+        if (G_OBJECT_CLASS (gdu_format_progress_dialog_parent_class)->constructed != NULL)
+                G_OBJECT_CLASS (gdu_format_progress_dialog_parent_class)->constructed (object);
+}
+
+static void
+gdu_format_progress_dialog_class_init (GduFormatProgressDialogClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+        g_type_class_add_private (klass, sizeof (GduFormatProgressDialogPrivate));
+
+        object_class->get_property = gdu_format_progress_dialog_get_property;
+        object_class->set_property = gdu_format_progress_dialog_set_property;
+        object_class->constructed  = gdu_format_progress_dialog_constructed;
+        object_class->finalize     = gdu_format_progress_dialog_finalize;
+
+        g_object_class_install_property (object_class,
+                                         PROP_DEVICE,
+                                         g_param_spec_object ("device",
+                                                              _("Device"),
+                                                              _("The device to show the dialog for"),
+                                                              GDU_TYPE_DEVICE,
+                                                              G_PARAM_READABLE |
+                                                              G_PARAM_WRITABLE |
+                                                              G_PARAM_CONSTRUCT_ONLY |
+                                                              G_PARAM_STATIC_NAME |
+                                                              G_PARAM_STATIC_NICK |
+                                                              G_PARAM_STATIC_BLURB));
+
+        g_object_class_install_property (object_class,
+                                         PROP_TEXT,
+                                         g_param_spec_string ("text",
+                                                              _("text"),
+                                                              _("Text to show"),
+                                                              NULL,
+                                                              G_PARAM_READABLE |
+                                                              G_PARAM_WRITABLE |
+                                                              G_PARAM_CONSTRUCT |
+                                                              G_PARAM_STATIC_NAME |
+                                                              G_PARAM_STATIC_NICK |
+                                                              G_PARAM_STATIC_BLURB));
+}
+
+static void
+gdu_format_progress_dialog_init (GduFormatProgressDialog *dialog)
+{
+        dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (dialog,
+                                                    GDU_TYPE_FORMAT_PROGRESS_DIALOG,
+                                                    GduFormatProgressDialogPrivate);
+}
+
+GtkWidget *
+gdu_format_progress_dialog_new (GtkWindow   *parent,
+                                GduDevice   *device,
+                                const gchar *text)
+{
+        return GTK_WIDGET (g_object_new (GDU_TYPE_FORMAT_PROGRESS_DIALOG,
+                                         "transient-for", parent,
+                                         "device", device,
+                                         "text", text,
+                                         NULL));
+}
+
+void
+gdu_format_progress_dialog_set_text (GduFormatProgressDialog *dialog,
+                                     const gchar             *text)
+{
+        g_return_if_fail (GDU_IS_FORMAT_PROGRESS_DIALOG (dialog));
+        g_object_set (dialog, "text", text, NULL);
+}
diff --git a/src/format-tool/gdu-format-progress-dialog.h b/src/format-tool/gdu-format-progress-dialog.h
new file mode 100644
index 0000000..75009ab
--- /dev/null
+++ b/src/format-tool/gdu-format-progress-dialog.h
@@ -0,0 +1,63 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/* gdu-ata-smart-dialog.h
+ *
+ * Copyright (C) 2009 David Zeuthen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef __GDU_FORMAT_PROGRESS_DIALOG_H
+#define __GDU_FORMAT_PROGRESS_DIALOG_H
+
+#include <gdu/gdu.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GDU_TYPE_FORMAT_PROGRESS_DIALOG         gdu_format_progress_dialog_get_type()
+#define GDU_FORMAT_PROGRESS_DIALOG(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), GDU_TYPE_FORMAT_PROGRESS_DIALOG, GduFormatProgressDialog))
+#define GDU_FORMAT_PROGRESS_DIALOG_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST ((k), GDU_TYPE_FORMAT_PROGRESS_DIALOG, GduFormatProgressDialogClass))
+#define GDU_IS_FORMAT_PROGRESS_DIALOG(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDU_TYPE_FORMAT_PROGRESS_DIALOG))
+#define GDU_IS_FORMAT_PROGRESS_DIALOG_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), GDU_TYPE_FORMAT_PROGRESS_DIALOG))
+#define GDU_FORMAT_PROGRESS_DIALOG_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDU_TYPE_FORMAT_PROGRESS_DIALOG, GduFormatProgressDialogClass))
+
+typedef struct GduFormatProgressDialog        GduFormatProgressDialog;
+typedef struct GduFormatProgressDialogClass   GduFormatProgressDialogClass;
+typedef struct GduFormatProgressDialogPrivate GduFormatProgressDialogPrivate;
+
+struct GduFormatProgressDialog
+{
+        GtkDialog parent;
+
+        /*< private >*/
+        GduFormatProgressDialogPrivate *priv;
+};
+
+struct GduFormatProgressDialogClass
+{
+        GtkDialogClass parent_class;
+};
+
+GType       gdu_format_progress_dialog_get_type (void) G_GNUC_CONST;
+GtkWidget*  gdu_format_progress_dialog_new      (GtkWindow               *parent,
+                                                 GduDevice               *device,
+                                                 const gchar             *text);
+void        gdu_format_progress_dialog_set_text (GduFormatProgressDialog *dialog,
+                                                 const gchar             *text);
+
+G_END_DECLS
+
+#endif /* __GDU_FORMAT_PROGRESS_DIALOG_H */
diff --git a/src/format-tool/gdu-format-tool.c b/src/format-tool/gdu-format-tool.c
index 796d9f4..02079d3 100644
--- a/src/format-tool/gdu-format-tool.c
+++ b/src/format-tool/gdu-format-tool.c
@@ -19,6 +19,7 @@
  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  *  Author: Tomas Bzatek <tbzatek redhat com>
+ *          David Zeuthen <davidz redhat com>
  *
  */
 
@@ -29,48 +30,136 @@
 #include <glib/gthread.h>
 #include <gio/gio.h>
 #include <gdu/gdu.h>
+#include <gdu-gtk/gdu-gtk.h>
 #include <gtk/gtk.h>
+#include <stdlib.h>
 
-#include "gdu-utils.h"
-#include "format-window.h"
+#include "gdu-format-dialog.h"
+#include "gdu-format-progress-dialog.h"
 
+typedef struct
+{
+        GMainLoop *loop;
+        GError    *error;
+        gchar     *mount_point;
+} FormatData;
 
+static gboolean
+on_hack_timeout (gpointer user_data)
+{
+        GMainLoop *loop = user_data;
+        g_main_loop_quit (loop);
+        return FALSE;
+}
 
-static gchar *_mount = NULL;
-static gchar *_device = NULL;
+static void
+fs_mount_cb (GduDevice *device,
+             gchar     *mount_point,
+             GError    *error,
+             gpointer   user_data)
+{
+        FormatData *data = user_data;
+        if (error != NULL)
+                data->error = error;
+        else
+                data->mount_point = g_strdup (mount_point);
+        g_main_loop_quit (data->loop);
+}
 
+static void
+fs_create_cb (GduDevice *device,
+              GError    *error,
+              gpointer   user_data)
+{
+        FormatData *data = user_data;
+        if (error != NULL)
+                data->error = error;
+        g_main_loop_quit (data->loop);
+}
 
-static gboolean
-setup_window ()
+static void
+show_error_dialog (GtkWindow *parent,
+                   const gchar *primary,
+                   const gchar *secondary)
 {
-        GduPresentable *presentable = NULL;
+        GtkWidget *dialog;
 
-        if (_mount != NULL)
-                presentable = find_presentable_from_mount_path (_mount);
-        if (_device != NULL && presentable == NULL)
-                presentable = find_presentable_from_device_path (_device);
+        dialog = gtk_message_dialog_new_with_markup (parent,
+                                                     GTK_DIALOG_MODAL,
+                                                     GTK_MESSAGE_ERROR,
+                                                     GTK_BUTTONS_OK,
+                                                     "<b><big><big>%s</big></big></b>\n\n%s",
+                                                     primary,
+                                                     secondary);
+        gtk_widget_show_all (dialog);
+        gtk_dialog_run (GTK_DIALOG (dialog));
+        gtk_widget_destroy (dialog);
+}
 
-        if (! presentable)
-                return FALSE;
+static void
+launch_palimpsest (const gchar *device_file)
+{
+        gchar *command_line;
+        GError *error;
 
-        nautilus_gdu_spawn_dialog (presentable);
-        g_object_unref (presentable);
+        command_line = g_strdup_printf ("palimpsest --show-volume \"%s\"", device_file);
 
-        return TRUE;
+        error = NULL;
+        if (!g_spawn_command_line_async (command_line, &error)) {
+                show_error_dialog (NULL,
+                                   _("Error launching Disk Utility"),
+                                   error->message);
+                g_error_free (error);
+        }
+        g_free (command_line);
 }
 
+static void
+launch_file_manager (const gchar *mount_point)
+{
+        gchar *command_line;
+
+        /* Nautilus itself will complain on errors so no need to do error handling*/
+        command_line = g_strdup_printf ("nautilus \"%s\"", mount_point);
+        g_spawn_command_line_async (command_line, NULL);
+        g_free (command_line);
+}
 
+static gchar *device_file = NULL;
+static GOptionEntry entries[] = {
+        { "device-file", 'd', 0, G_OPTION_ARG_FILENAME, &device_file, N_("Device to format"), N_("DEVICE") },
+        { NULL }
+};
 
 int
 main (int argc, char *argv[])
 {
-        static GOptionEntry entries[] =
-                {
-                        { "mount", 'm', 0, G_OPTION_ARG_STRING, &_mount, N_("Find volume by mount"), NULL },
-                        { NULL }
-                };
+        int ret;
+        GError *error;
+        GduPool *pool;
+        GduDevice *device;
+        GduDevice *device_to_mount;
+        GduPresentable *volume;
+        GtkWidget *dialog;
+        gint response;
+        gchar *fs_type;
+        gchar *fs_label;
+        gboolean encrypt;
+        gchar *passphrase;
+        gboolean save_passphrase_in_keyring;
+        gboolean save_passphrase_in_keyring_session;
+        GMainLoop *loop;
 
-        GError *error = NULL;
+        ret = 1;
+        pool = NULL;
+        device = NULL;
+        device_to_mount = NULL;
+        volume = NULL;
+        dialog = NULL;
+        fs_type = NULL;
+        fs_label = NULL;
+        passphrase = NULL;
+        loop = NULL;
 
         g_thread_init (NULL);
 
@@ -80,26 +169,216 @@ main (int argc, char *argv[])
         textdomain (GETTEXT_PACKAGE);
 
         /*  Initialize gtk  */
-        if (! gtk_init_with_args (&argc, &argv, "[device_file]", entries, GETTEXT_PACKAGE, &error)) {
+        error = NULL;
+        if (! gtk_init_with_args (&argc, &argv, NULL, entries, GETTEXT_PACKAGE, &error)) {
                 g_printerr ("Could not parse arguments: %s\n", error->message);
                 g_error_free (error);
-                return 1;
+                goto out;
+        }
+
+        loop = g_main_loop_new (NULL, FALSE);
+
+        g_set_prgname ("gdu-format-tool");
+        g_set_application_name (_("Gnome Disk Utility formatting tool"));
+
+        if (device_file == NULL) {
+                g_printerr ("Incorrect usage. Try --help.\n");
+                goto out;
+        }
+
+        pool = gdu_pool_new ();
+        if (pool == NULL) {
+                g_warning ("Unable to get device pool");
+                goto out;
+        }
+
+        device = gdu_pool_get_by_device_file (pool, device_file);
+        if (device == NULL) {
+                g_printerr ("No device for %s\n", device_file);
+                goto out;
         }
 
-        /*  Get the device parameter  */
-        if (argc > 0 && argv[1])
-                _device = g_strdup (argv[1]);
+        volume = gdu_pool_get_volume_by_device (pool, device);
+        if (volume == NULL) {
+                g_printerr ("%s is not a volume\n", device_file);
+                goto out;
+        }
+
+        dialog = gdu_format_dialog_new (NULL, GDU_VOLUME (volume));
+        gtk_widget_show_all (dialog);
+
+        response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+        switch (response) {
+        case GTK_RESPONSE_OK:
+                break;
+
+        case GTK_RESPONSE_ACCEPT:
+                gtk_widget_destroy (dialog);
+                dialog = NULL;
+                launch_palimpsest (device_file);
+                goto out;
+
+        default: /* explicit fallthrough */
+        case GTK_RESPONSE_CANCEL:
+                goto out;
+        }
+
+        fs_type = gdu_format_dialog_get_fs_type (GDU_FORMAT_DIALOG (dialog));
+        fs_label = gdu_format_dialog_get_fs_label (GDU_FORMAT_DIALOG (dialog));
+        encrypt = gdu_format_dialog_get_encrypt (GDU_FORMAT_DIALOG (dialog));
+        gtk_widget_destroy (dialog);
+        dialog = NULL;
+
+        passphrase = NULL;
+        save_passphrase_in_keyring = FALSE;
+        save_passphrase_in_keyring_session = FALSE;
+        if (encrypt) {
+                passphrase = gdu_util_dialog_ask_for_new_secret (NULL,
+                                                                 &save_passphrase_in_keyring,
+                                                                 &save_passphrase_in_keyring_session);
+                if (passphrase == NULL)
+                        goto out;
+        }
+
+        gboolean take_ownership;
+        FormatData data;
+
+        take_ownership = (g_strcmp0 (fs_type, "vfat") != 0);
 
-        if (! setup_window ()) {
-                g_printerr ("Could not find presentable\n");
-                return 1;
+ try_again:
+        data.loop = loop;
+        data.error = NULL;
+        dialog = gdu_format_progress_dialog_new (NULL,
+                                                 device,
+                                                 _("Formatting volume..."));
+        gtk_widget_show_all (dialog);
+        gdu_device_op_filesystem_create (device,
+                                         fs_type,
+                                         fs_label,
+                                         passphrase,
+                                         take_ownership,
+                                         fs_create_cb,
+                                         &data);
+        g_main_loop_run (loop);
+        if (data.error != NULL) {
+                PolKitAction *pk_action;
+                PolKitResult pk_result;
+                if (gdu_error_check_polkit_not_authorized (data.error,
+                                                           &pk_action,
+                                                           &pk_result)) {
+                        gtk_widget_destroy (dialog);
+                        dialog = NULL;
+
+                        if (pk_result == POLKIT_RESULT_UNKNOWN ||
+                            pk_result == POLKIT_RESULT_NO) {
+                                show_error_dialog (NULL,
+                                                   _("You are not authorized to format the volume"),
+                                                   _("Contact your system administrator to obtain "
+                                                     "the necessary authorization."));
+                                g_error_free (data.error);
+                                polkit_action_unref (pk_action);
+                                goto out;
+                        } else {
+                                char *action_id;
+                                DBusError dbus_error;
+                                polkit_action_get_action_id (pk_action, &action_id);
+                                dbus_error_init (&dbus_error);
+                                if (!polkit_auth_obtain (action_id, 0, getpid (), &dbus_error)) {
+                                        polkit_action_unref (pk_action);
+                                        dbus_error_free (&dbus_error);
+                                        goto out;
+                                } else {
+                                        g_error_free (data.error);
+                                        /* try again */
+                                        goto try_again;
+                                }
+                        }
+
+                } else {
+                        gtk_widget_destroy (dialog);
+                        dialog = NULL;
+
+                        /* TODO: we could handle things like GDU_ERROR_BUSY here, e.g. unmount
+                         *       and/or tear down LUKS mapping
+                         */
+                        show_error_dialog (NULL,
+                                           _("Error creating filesystem"),
+                                           data.error->message);
+                        g_error_free (data.error);
+                        goto out;
+                }
+        }
+
+        /* ugh, DeviceKit-disks bug - spin around in the mainloop for some time to ensure we
+         * have gotten all changes
+         */
+        gdu_format_progress_dialog_set_text (GDU_FORMAT_PROGRESS_DIALOG (dialog),
+                                             _("Mounting volume..."));
+        g_timeout_add (1500, on_hack_timeout, loop);
+        g_main_loop_run (loop);
+
+        /* OK, peachy, now mount the volume and open a window */
+        if (passphrase != NULL) {
+                const gchar *cleartext_objpath;
+
+                g_assert (gdu_device_is_luks (device));
+                cleartext_objpath = gdu_device_luks_get_holder (device);
+                device_to_mount = gdu_pool_get_by_object_path (pool, cleartext_objpath);
+        } else {
+                device_to_mount = g_object_ref (device);
+        }
+
+        gdu_device_op_filesystem_mount (device_to_mount,
+                                        NULL,
+                                        fs_mount_cb,
+                                        &data);
+        g_main_loop_run (loop);
+        gtk_widget_destroy (dialog);
+        dialog = NULL;
+        if (data.error != NULL) {
+                show_error_dialog (NULL,
+                                   _("Error mounting device"),
+                                   data.error->message);
+                g_error_free (data.error);
+                goto out;
         }
 
-        g_set_prgname ("gnome-disk-utility-format");
-        g_set_application_name (_("Gnome Disk Formatter"));
+        /* open file manager */
+        launch_file_manager (data.mount_point);
+
+        g_free (data.mount_point);
+
+        /* save passphrase in keyring if requested */
+        if (passphrase != NULL && (save_passphrase_in_keyring || save_passphrase_in_keyring_session)) {
+                if (!gdu_util_save_secret (device,
+                                           passphrase,
+                                           save_passphrase_in_keyring_session)) {
+                        show_error_dialog (NULL,
+                                           _("Error storing passphrase in keyring"),
+                                           "");
+                        goto out;
+                }
+        }
 
-        /*  Run the application  */
-        gtk_main ();
+        ret = 0;
 
-        return 0;
+ out:
+        g_free (passphrase);
+        g_free (fs_type);
+        g_free (fs_label);
+        g_free (device_file);
+        if (loop != NULL)
+                g_main_loop_unref (loop);
+        if (dialog != NULL)
+                gtk_widget_destroy (dialog);
+        if (volume != NULL)
+                g_object_unref (volume);
+        if (device != NULL)
+                g_object_unref (device);
+        if (device_to_mount != NULL)
+                g_object_unref (device_to_mount);
+        if (pool != NULL)
+                g_object_unref (pool);
+        return ret;
 }
diff --git a/src/format-tool/gdu-utils.c b/src/format-tool/gdu-utils.c
deleted file mode 100644
index ce9d375..0000000
--- a/src/format-tool/gdu-utils.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-/*  gdu-utils.c
- *
- *  Copyright (C) 2008-2009 Red Hat, Inc.
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Library General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public
- *  License along with this library; if not, write to the Free
- *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *  Author: Tomas Bzatek <tbzatek redhat com>
- */
-
-#include "config.h"
-
-#include <glib/gi18n-lib.h>
-#include <gio/gio.h>
-#include <gdu/gdu.h>
-#include <gtk/gtk.h>
-
-#include "gdu-utils.h"
-
-
-GduPresentable *
-find_presentable_from_mount_path (const gchar *mount_path)
-{
-        GduPool *pool;
-        GList *devices, *l;
-        GduPresentable *presentable = NULL;
-        GduDevice *device;
-        const gchar *device_mount;
-        GFile *file1, *file2;
-
-        g_return_val_if_fail (mount_path != NULL, NULL);
-        g_return_val_if_fail (strlen (mount_path) > 1, NULL);
-
-        pool = gdu_pool_new ();
-        devices = gdu_pool_get_devices (pool);
-
-        for (l = devices; l != NULL; l = l->next) {
-                device = GDU_DEVICE (l->data);
-                device_mount = gdu_device_get_mount_path (device);
-
-                if (mount_path && device_mount && strlen (device_mount) > 1) {
-                        /*  compare via GFile routines  */
-                        file1 = g_file_new_for_commandline_arg (mount_path);
-                        file2 = g_file_new_for_path (device_mount);
-                        if (g_file_equal (file1, file2))
-                                presentable = gdu_pool_get_volume_by_device (pool, device);   /*  auto-ref here  */
-                        g_object_unref (file1);
-                        g_object_unref (file2);
-                        if (presentable)
-                                break;
-                }
-        }
-
-        g_list_foreach (devices, (GFunc) g_object_unref, NULL);
-        g_list_free (devices);
-        g_object_unref (pool);
-
-        return presentable;
-}
-
-GduPresentable *
-find_presentable_from_device_path (const gchar *device_path)
-{
-        GduPool *pool;
-        GduDevice *device;
-        GduPresentable *presentable = NULL;
-
-        g_return_val_if_fail (device_path != NULL, NULL);
-        g_return_val_if_fail (strlen (device_path) > 1, NULL);
-
-        pool = gdu_pool_new ();
-        device = gdu_pool_get_by_device_file (pool, device_path);
-        if (device) {
-                presentable = gdu_pool_get_volume_by_device (pool, device);
-                g_object_unref (device);
-        }
-        g_object_unref (pool);
-
-        return presentable;
-}
-
-
-gchar *
-_g_icon_get_string (GIcon *icon)
-{
-        const gchar *icon_text = NULL;
-        const gchar * const *icon_names;
-
-        if (! icon)
-                return NULL;
-
-        if (G_IS_THEMED_ICON (icon)) {
-                icon_names = g_themed_icon_get_names (G_THEMED_ICON (icon));
-                while (icon_text == NULL && icon_names != NULL && *icon_names != NULL) {
-                        if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default (), *icon_names))
-                                icon_text = *icon_names;
-                        icon_names++;
-                }
-        }
-
-        return g_strdup (icon_text);
-}
-
-gboolean
-is_active_luks (GduPool *pool, GduPresentable *presentable)
-{
-        gboolean res;
-        GduDevice *device;
-
-        res = FALSE;
-        device = gdu_presentable_get_device (presentable);
-
-        if (GDU_IS_VOLUME (presentable) && device && strcmp (gdu_device_id_get_usage (device), "crypto") == 0) {
-                GList *enclosed_presentables;
-                enclosed_presentables = gdu_pool_get_enclosed_presentables (pool, presentable);
-                res = (enclosed_presentables != NULL) && (g_list_length (enclosed_presentables) == 1);
-                g_list_foreach (enclosed_presentables, (GFunc) g_object_unref, NULL);
-                g_list_free (enclosed_presentables);
-                g_object_unref (device);
-        }
-
-        return res;
-}
-
-const gchar *
-trim_dk_error (const gchar *message)
-{
-        const gchar *text, *p;
-
-        if (g_str_has_prefix (message, "org.freedesktop.DeviceKit"))
-                text = (p = strchr (message, ':')) ? p + 1 : message;
-        else
-                text = message;
-
-        return text;
-}
diff --git a/src/format-tool/gdu-utils.h b/src/format-tool/gdu-utils.h
deleted file mode 100644
index 80d1bba..0000000
--- a/src/format-tool/gdu-utils.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-/* gdu-utils.h
- *
- *  Copyright (C) 2008-2009 Red Hat, Inc.
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Library General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public
- *  License along with this library; if not, write to the Free
- *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *  Author: Tomas Bzatek <tbzatek redhat com>
- */
-
-#ifndef __GDU_UTILS_H
-#define __GDU_UTILS_H
-
-#include <glib-object.h>
-#include <gio/gio.h>
-#include <gdu/gdu.h>
-
-G_BEGIN_DECLS
-
-/*  caller must unref the returned object  */
-GduPresentable *  find_presentable_from_mount_path (const gchar *mount_path);
-
-/*  caller must unref the returned object  */
-GduPresentable *  find_presentable_from_device_path (const gchar *device_path);
-
-gchar *           _g_icon_get_string (GIcon *icon);
-
-gboolean          is_active_luks (GduPool        *pool,
-                                  GduPresentable *presentable);
-
-const gchar *     trim_dk_error (const gchar *message);
-
-G_END_DECLS
-
-#endif  /* __GDU_UTILS_H */
-
diff --git a/src/gdu-gtk/gdu-gtk.c b/src/gdu-gtk/gdu-gtk.c
index 399c747..3496d7f 100644
--- a/src/gdu-gtk/gdu-gtk.c
+++ b/src/gdu-gtk/gdu-gtk.c
@@ -717,8 +717,9 @@ gdu_util_dialog_secret_internal (GtkWidget   *parent_window,
                 gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (" "), FALSE, FALSE, 0);
                 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
 
-                g_signal_connect (data->password_entry, "changed",
-                                  (GCallback) gdu_util_dialog_secret_entry_changed, data);
+                if (data->password_entry != NULL)
+                        g_signal_connect (data->password_entry, "changed",
+                                          (GCallback) gdu_util_dialog_secret_entry_changed, data);
                 g_signal_connect (data->password_entry_new, "changed",
                                   (GCallback) gdu_util_dialog_secret_entry_changed, data);
                 g_signal_connect (data->password_entry_verify, "changed",
diff --git a/src/nautilus-extension/nautilus-gdu.c b/src/nautilus-extension/nautilus-gdu.c
index 589a5c2..66a3e56 100644
--- a/src/nautilus-extension/nautilus-gdu.c
+++ b/src/nautilus-extension/nautilus-gdu.c
@@ -123,15 +123,16 @@ get_device_from_nautilus_file (NautilusFileInfo *nautilus_file)
 static void
 open_format_utility (NautilusMenuItem *item)
 {
-        const gchar *format_argv[3];
+        const gchar *format_argv[4];
         GduDevice *device;
         GError *error;
 
         device = GDU_DEVICE (g_object_get_data (G_OBJECT (item), "gdu-device"));
 
         format_argv[0] = LIBEXECDIR "/gdu-format-tool";
-        format_argv[1] = gdu_device_get_device_file (device);
-        format_argv[2] = NULL;
+        format_argv[1] = "--device-file";
+        format_argv[2] = gdu_device_get_device_file (device);
+        format_argv[3] = NULL;
 
         error = NULL;
         g_spawn_async (NULL,        /* working_directory */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]