[gnome-disk-utility/wip/mdraid] Make it possible to show a check-box in gdu_utils_show_confirmation()
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility/wip/mdraid] Make it possible to show a check-box in gdu_utils_show_confirmation()
- Date: Sat, 15 Sep 2012 16:48:56 +0000 (UTC)
commit a7c0ab52341ec8050752a6fcc63a4ee1dbae6ef6
Author: David Zeuthen <zeuthen gmail com>
Date: Sat Sep 15 12:47:40 2012 -0400
Make it possible to show a check-box in gdu_utils_show_confirmation()
Signed-off-by: David Zeuthen <zeuthen gmail com>
src/disks/gduformatdiskdialog.c | 3 +-
src/disks/gduformatvolumedialog.c | 3 +-
src/disks/gdumdraiddisksdialog.c | 46 +++++----------------------------
src/disks/gdurestorediskimagedialog.c | 3 +-
src/disks/gduwindow.c | 3 +-
src/libgdu/gduutils.c | 20 +++++++++++++-
src/libgdu/gduutils.h | 4 ++-
7 files changed, 37 insertions(+), 45 deletions(-)
---
diff --git a/src/disks/gduformatdiskdialog.c b/src/disks/gduformatdiskdialog.c
index 0bc536c..897fdb7 100644
--- a/src/disks/gduformatdiskdialog.c
+++ b/src/disks/gduformatdiskdialog.c
@@ -408,7 +408,8 @@ gdu_format_disk_dialog_show (GduWindow *window,
if (!gdu_utils_show_confirmation (GTK_WINDOW (window),
primary_message,
str->str,
- _("_Format")))
+ _("_Format"),
+ NULL, NULL))
{
g_string_free (str, TRUE);
goto out;
diff --git a/src/disks/gduformatvolumedialog.c b/src/disks/gduformatvolumedialog.c
index f9fc5f5..2a4f0bd 100644
--- a/src/disks/gduformatvolumedialog.c
+++ b/src/disks/gduformatvolumedialog.c
@@ -161,7 +161,8 @@ gdu_format_volume_dialog_show (GduWindow *window,
if (!gdu_utils_show_confirmation (GTK_WINDOW (window),
primary_message,
str->str,
- _("_Format")))
+ _("_Format"),
+ NULL, NULL))
{
g_string_free (str, TRUE);
goto out;
diff --git a/src/disks/gdumdraiddisksdialog.c b/src/disks/gdumdraiddisksdialog.c
index 129ac1b..14c82cc 100644
--- a/src/disks/gdumdraiddisksdialog.c
+++ b/src/disks/gdumdraiddisksdialog.c
@@ -221,50 +221,18 @@ on_remove_toolbutton_clicked (GtkToolButton *tool_button,
gpointer user_data)
{
DialogData *data = user_data;
- GtkWidget *dialog;
- GtkWidget *check_button;
- gint response;
- const gchar *message;
- const gchar *secondary_message;
- const gchar *affirmative_verb;
- gboolean opt_wipe = FALSE;
+ gboolean opt_wipe = TRUE;
GVariantBuilder options_builder;
UDisksBlock *selected_block = NULL;
UDisksObject *selected_block_object = NULL;
GtkTreeIter titer;
- message = C_("mdraid-disks", "Are you sure you want to remove the disk?");
- secondary_message = C_("mdraid-disks", "Removing a disk from a RAID array may degrade it");
- affirmative_verb = C_("mdraid-disks", "_Remove");
-
- dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (data->dialog),
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_INFO,
- GTK_BUTTONS_CANCEL,
- "<big><b>%s</b></big>",
- message);
- gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog),
- "%s",
- secondary_message);
-
- check_button = gtk_check_button_new_with_mnemonic (C_("mdraid-disks", "_Wipe disk after removal"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), TRUE);
- gtk_box_pack_start (GTK_BOX (gtk_message_dialog_get_message_area (GTK_MESSAGE_DIALOG (dialog))),
- check_button,
- FALSE, FALSE, 0);
-
- gtk_dialog_add_button (GTK_DIALOG (dialog),
- affirmative_verb,
- GTK_RESPONSE_OK);
-
- gtk_widget_show_all (dialog);
- response = gtk_dialog_run (GTK_DIALOG (dialog));
-
- opt_wipe = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_button));
-
- gtk_widget_destroy (dialog);
-
- if (response != GTK_RESPONSE_OK)
+ if (!gdu_utils_show_confirmation (GTK_WINDOW (data->dialog),
+ C_("mdraid-disks", "Are you sure you want to remove the disk?"),
+ C_("mdraid-disks", "Removing a disk from a RAID array may degrade it"),
+ C_("mdraid-disks", "_Remove"),
+ C_("mdraid-disks", "_Quick-format after removal"),
+ &opt_wipe))
goto out;
g_variant_builder_init (&options_builder, G_VARIANT_TYPE_VARDICT);
diff --git a/src/disks/gdurestorediskimagedialog.c b/src/disks/gdurestorediskimagedialog.c
index 6bc0963..01770f8 100644
--- a/src/disks/gdurestorediskimagedialog.c
+++ b/src/disks/gdurestorediskimagedialog.c
@@ -486,7 +486,8 @@ on_dialog_response (GtkDialog *dialog,
if (!gdu_utils_show_confirmation (GTK_WINDOW (data->dialog),
_("Are you sure you want to write the disk image to the device?"),
_("All existing data will be lost"),
- _("_Restore")))
+ _("_Restore"),
+ NULL, NULL))
{
restore_disk_image_data_complete (data);
goto out;
diff --git a/src/disks/gduwindow.c b/src/disks/gduwindow.c
index 502b4ec..9154797 100644
--- a/src/disks/gduwindow.c
+++ b/src/disks/gduwindow.c
@@ -3482,7 +3482,8 @@ on_devtab_action_partition_delete_activated (GtkAction *action,
if (!gdu_utils_show_confirmation (GTK_WINDOW (window),
_("Are you sure you want to delete the partition?"),
_("All data on the partition will be lost"),
- _("_Delete")))
+ _("_Delete"),
+ NULL, NULL))
goto out;
object = gdu_volume_grid_get_selected_device (GDU_VOLUME_GRID (window->volume_grid));
diff --git a/src/libgdu/gduutils.c b/src/libgdu/gduutils.c
index 408d4bf..35f969d 100644
--- a/src/libgdu/gduutils.c
+++ b/src/libgdu/gduutils.c
@@ -617,8 +617,11 @@ gboolean
gdu_utils_show_confirmation (GtkWindow *parent_window,
const gchar *message,
const gchar *secondary_message,
- const gchar *affirmative_verb)
+ const gchar *affirmative_verb,
+ const gchar *checkbox_mnemonic,
+ gboolean *inout_checkbox_value)
{
+ GtkWidget *check_button = NULL;
GtkWidget *dialog;
gint response;
@@ -632,12 +635,27 @@ gdu_utils_show_confirmation (GtkWindow *parent_window,
"%s",
secondary_message);
+ if (checkbox_mnemonic != NULL)
+ {
+ check_button = gtk_check_button_new_with_mnemonic (checkbox_mnemonic);
+ gtk_box_pack_start (GTK_BOX (gtk_message_dialog_get_message_area (GTK_MESSAGE_DIALOG (dialog))),
+ check_button,
+ FALSE, FALSE, 0);
+ if (inout_checkbox_value != NULL)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), *inout_checkbox_value);
+ }
+
gtk_dialog_add_button (GTK_DIALOG (dialog),
affirmative_verb,
GTK_RESPONSE_OK);
+ gtk_widget_show_all (dialog);
+
response = gtk_dialog_run (GTK_DIALOG (dialog));
+ if (inout_checkbox_value != NULL && check_button != NULL)
+ *inout_checkbox_value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_button));
+
gtk_widget_destroy (dialog);
return response == GTK_RESPONSE_OK;
diff --git a/src/libgdu/gduutils.h b/src/libgdu/gduutils.h
index 4ea1fcc..1db94ea 100644
--- a/src/libgdu/gduutils.h
+++ b/src/libgdu/gduutils.h
@@ -53,7 +53,9 @@ void gdu_utils_show_error (GtkWindow *parent_window,
gboolean gdu_utils_show_confirmation (GtkWindow *parent_window,
const gchar *message,
const gchar *secondary_message,
- const gchar *affirmative_verb);
+ const gchar *affirmative_verb,
+ const gchar *checkbox_mnemonic,
+ gboolean *inout_checkbox_value);
gboolean gdu_utils_is_ntfs_available (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]