[gnome-disk-utility] gduwindow: Add dialog to the take ownership action
- From: Kai Lüke <kailueke src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility] gduwindow: Add dialog to the take ownership action
- Date: Fri, 23 Jul 2021 21:35:32 +0000 (UTC)
commit 6396518b4012c2335cdda80d59152f803f813ca4
Author: Manuel Wassermann <manuel wassermann97 gmail com>
Date: Fri Jul 16 11:29:25 2021 +0200
gduwindow: Add dialog to the take ownership action
Take-Ownership had no dialog with a description, this makes it inconsistent
with the other actions in the volume menu. Additionally, it was not possible
to activate the recursive mode.
Add dialog with a description and the ability to enable recursive mode.
po/POTFILES.in | 1 +
src/disks/gduwindow.c | 53 +++++++++++++++++++++++++++++++----
src/disks/gnome-disks.gresource.xml | 1 +
src/disks/ui/take-ownership-dialog.ui | 45 +++++++++++++++++++++++++++++
src/disks/ui/volume-menu.ui | 2 +-
5 files changed, 95 insertions(+), 7 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index d267f514..7bfd77ac 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -61,6 +61,7 @@ src/disks/ui/resize-dialog.ui
src/disks/ui/restore-disk-image-dialog.ui
src/disks/ui/shortcuts.ui
src/disks/ui/smart-dialog.ui
+src/disks/ui/take-ownership-dialog.ui
src/disks/ui/unlock-device-dialog.ui
src/disks/ui/volume-menu.ui
src/libgdu/gduutils.c
diff --git a/src/disks/gduwindow.c b/src/disks/gduwindow.c
index 0cf82736..6f8e8456 100644
--- a/src/disks/gduwindow.c
+++ b/src/disks/gduwindow.c
@@ -3079,6 +3079,24 @@ on_volume_menu_item_repair (GSimpleAction *action,
/* ---------------------------------------------------------------------------------------------------- */
+static void
+on_recursive_checkbutton (GtkToggleButton *togglebutton,
+ gpointer user_data)
+{
+ GtkWidget *ok_button = GTK_WIDGET (user_data);
+
+ if (gtk_toggle_button_get_active (togglebutton))
+ {
+ gtk_style_context_remove_class (gtk_widget_get_style_context (ok_button), "suggested-action");
+ gtk_style_context_add_class (gtk_widget_get_style_context (ok_button), "destructive-action");
+ }
+ else
+ {
+ gtk_style_context_remove_class (gtk_widget_get_style_context (ok_button), "destructive-action");
+ gtk_style_context_add_class (gtk_widget_get_style_context (ok_button), "suggested-action");
+ }
+}
+
static void
fs_take_ownership_cb (UDisksFilesystem *filesystem,
GAsyncResult *res,
@@ -3102,19 +3120,42 @@ on_volume_menu_item_take_ownership (GSimpleAction *action,
gpointer user_data)
{
GduWindow *window;
+ GtkBuilder *builder;
+ GVariantBuilder options_builder;
+ GtkWidget *dialog;
+ GtkWidget *recursive_checkbutton;
+ GtkWidget *ok_button;
UDisksObject *object;
UDisksFilesystem *filesystem;
window = GDU_WINDOW (user_data);
object = gdu_volume_grid_get_selected_device (GDU_VOLUME_GRID (window->volume_grid));
g_assert (object != NULL);
-
filesystem = udisks_object_peek_filesystem (object);
- udisks_filesystem_call_take_ownership (filesystem,
- g_variant_new ("a{sv}", NULL),
- NULL,
- (GAsyncReadyCallback) fs_take_ownership_cb,
- window);
+
+ builder = gtk_builder_new_from_resource ("/org/gnome/Disks/ui/take-ownership-dialog.ui");
+ dialog = GTK_WIDGET (gtk_builder_get_object (builder, "take-ownership-dialog"));
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window));
+
+ ok_button = gtk_dialog_get_widget_for_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+ recursive_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "recursive-checkbutton"));
+ g_signal_connect (recursive_checkbutton, "toggled", G_CALLBACK (on_recursive_checkbutton), ok_button);
+
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
+ {
+ g_variant_builder_init (&options_builder, G_VARIANT_TYPE_VARDICT);
+
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (recursive_checkbutton)))
+ g_variant_builder_add (&options_builder, "{sv}", "recursive", g_variant_new_boolean (TRUE));
+
+ udisks_filesystem_call_take_ownership (filesystem,
+ g_variant_builder_end (&options_builder),
+ NULL,
+ (GAsyncReadyCallback) fs_take_ownership_cb,
+ window);
+ }
+
+ gtk_widget_destroy (dialog);
}
/* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/disks/gnome-disks.gresource.xml b/src/disks/gnome-disks.gresource.xml
index 5ce8a3e9..d7b47c9d 100644
--- a/src/disks/gnome-disks.gresource.xml
+++ b/src/disks/gnome-disks.gresource.xml
@@ -28,6 +28,7 @@
<file preprocess="xml-stripblanks">ui/restore-disk-image-dialog.ui</file>
<file preprocess="xml-stripblanks">ui/shortcuts.ui</file>
<file preprocess="xml-stripblanks">ui/smart-dialog.ui</file>
+ <file preprocess="xml-stripblanks">ui/take-ownership-dialog.ui</file>
<file preprocess="xml-stripblanks">ui/unlock-device-dialog.ui</file>
<file preprocess="xml-stripblanks">ui/volume-menu.ui</file>
<file>ui/gdu.css</file>
diff --git a/src/disks/ui/take-ownership-dialog.ui b/src/disks/ui/take-ownership-dialog.ui
new file mode 100644
index 00000000..b130d34d
--- /dev/null
+++ b/src/disks/ui/take-ownership-dialog.ui
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <object class="GtkMessageDialog" id="take-ownership-dialog">
+ <property name="text" translatable="yes">Confirm Taking Ownership</property>
+ <property name="secondary-text" translatable="yes">Changes ownership of the filesystem to your user
and group. The recursive mode does also change the ownership of all subdirectories and files, this can lead
to destructive results when the filesystem contains a directory structure where ownership should belong to
different users (e.g., a system backup or a filesystem that is accessed by multiple users).</property>
+ <property name="resizable">False</property>
+ <property name="modal">True</property>
+ <property name="window_position">center-on-parent</property>
+ <child internal-child="vbox">
+ <object class="GtkBox">
+ <child>
+ <object class="GtkCheckButton" id="recursive-checkbutton">
+ <property name="label" translatable="yes">Enable _recursive mode</property>
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="margin-start">40</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="action">
+ <object class="GtkButton">
+ <property name="label">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ <property name="has-focus">True</property>
+ </object>
+ </child>
+ <child type="action">
+ <object class="GtkButton" id="ok-button">
+ <property name="label">gtk-ok</property>
+ <property name="visible">True</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ <style>
+ <class name="suggested-action"/>
+ </style>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="ok">ok-button</action-widget>
+ </action-widgets>
+ </object>
+</interface>
\ No newline at end of file
diff --git a/src/disks/ui/volume-menu.ui b/src/disks/ui/volume-menu.ui
index 3cabc2ff..a1fb94e8 100644
--- a/src/disks/ui/volume-menu.ui
+++ b/src/disks/ui/volume-menu.ui
@@ -35,7 +35,7 @@
<attribute name="action">win.repair-fs</attribute>
</item>
<item>
- <attribute name="label" translatable="yes">_Take Ownership</attribute>
+ <attribute name="label" translatable="yes">_Take Ownership…</attribute>
<attribute name="action">win.take-ownership</attribute>
</item>
</section>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]