[gnome-disk-utility] UI: Highlight destructive actions



commit d7526e3b8f527c485000b1032700bfbe00005d1b
Author: Manuel Wassermann <manuel wassermann97 gmail com>
Date:   Sat Jul 10 21:52:56 2021 +0000

    UI: Highlight destructive actions

 src/disks/gduformatdiskdialog.c       |   2 +-
 src/disks/gdurestorediskimagedialog.c |   2 +-
 src/disks/gduwindow.c                 |   4 +-
 src/disks/ui/disks.ui                 | 119 ++++++++++++++++++++++------------
 src/libgdu/gduutils.c                 |  12 +++-
 src/libgdu/gduutils.h                 |   3 +-
 6 files changed, 95 insertions(+), 47 deletions(-)
---
diff --git a/src/disks/gduformatdiskdialog.c b/src/disks/gduformatdiskdialog.c
index dfac028e..f6b258ae 100644
--- a/src/disks/gduformatdiskdialog.c
+++ b/src/disks/gduformatdiskdialog.c
@@ -443,7 +443,7 @@ gdu_format_disk_dialog_show (GduWindow    *window,
                                         str->str,
                                         _("_Format"),
                                         NULL, NULL,
-                                        gdu_window_get_client (data->window), objects))
+                                        gdu_window_get_client (data->window), objects, TRUE))
         {
           g_list_free (objects);
           g_string_free (str, TRUE);
diff --git a/src/disks/gdurestorediskimagedialog.c b/src/disks/gdurestorediskimagedialog.c
index 2f0e044a..bccf97e9 100644
--- a/src/disks/gdurestorediskimagedialog.c
+++ b/src/disks/gdurestorediskimagedialog.c
@@ -1036,7 +1036,7 @@ on_dialog_response (GtkDialog     *dialog,
                                         _("All existing data will be lost"),
                                         _("_Restore"),
                                         NULL, NULL,
-                                        gdu_window_get_client (data->window), objects))
+                                        gdu_window_get_client (data->window), objects, TRUE))
         {
           dialog_data_complete_and_unref (data);
           goto out;
diff --git a/src/disks/gduwindow.c b/src/disks/gduwindow.c
index aaaf4341..f900fd88 100644
--- a/src/disks/gduwindow.c
+++ b/src/disks/gduwindow.c
@@ -3572,7 +3572,7 @@ do_power_off (GduWindow *window)
                                         message,
                                         _("_Power Off"),
                                         NULL, NULL,
-                                        window->client, objects))
+                                        window->client, objects, FALSE))
         goto out;
     }
 
@@ -3776,7 +3776,7 @@ on_partition_delete_tool_button_clicked (GtkToolButton *button, gpointer user_da
                                     _("All data on the partition will be lost"),
                                     _("_Delete"),
                                     NULL, NULL,
-                                    window->client, objects))
+                                    window->client, objects, TRUE))
     goto out;
 
   gdu_window_ensure_unused (window,
diff --git a/src/disks/ui/disks.ui b/src/disks/ui/disks.ui
index 5fb963ac..2dfeff56 100644
--- a/src/disks/ui/disks.ui
+++ b/src/disks/ui/disks.ui
@@ -654,137 +654,176 @@
                                       </object>
                                     </child>
                                     <child>
-                                      <object class="GtkToolbar" id="devtab-grid-toolbar">
+                                      <object class="GtkBox" id="devtab-grid-toolbar">
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
-                                        <property name="icon_size">1</property>
                                         <style>
                                           <class name="inline-toolbar"/>
                                         </style>
                                         <child>
-                                          <object class="GtkToolButton" id="toolbutton-mount">
+                                          <object class="GtkButton" id="toolbutton-mount">
                                             <property name="visible">True</property>
                                             <property name="can_focus">False</property>
                                             <property name="tooltip_text" translatable="yes">Mount selected 
partition</property>
-                                            <property name="label" translatable="yes" context="Accessibility 
label for toolbutton-mount">Mount</property>
                                             <property name="use_underline">True</property>
-                                            <property 
name="icon_name">media-playback-start-symbolic</property>
+                                            <child>
+                                              <object class="GtkImage">
+                                                <property name="visible">True</property>
+                                                <property 
name="icon-name">media-playback-start-symbolic</property>
+                                              </object>
+                                            </child>
                                           </object>
                                           <packing>
                                             <property name="expand">False</property>
-                                            <property name="homogeneous">True</property>
                                           </packing>
                                         </child>
                                         <child>
-                                          <object class="GtkToolButton" id="toolbutton-unmount">
+                                          <object class="GtkButton" id="toolbutton-unmount">
                                             <property name="visible">True</property>
                                             <property name="can_focus">False</property>
                                             <property name="tooltip_text" translatable="yes">Unmount 
selected partition</property>
-                                            <property name="label" translatable="yes" context="Accessibility 
label for toolbutton-unmount">Unmount</property>
                                             <property name="use_underline">True</property>
-                                            <property 
name="icon_name">media-playback-stop-symbolic</property>
+                                            <child>
+                                              <object class="GtkImage">
+                                                <property name="visible">True</property>
+                                                <property 
name="icon-name">media-playback-stop-symbolic</property>
+                                              </object>
+                                            </child>
                                           </object>
                                           <packing>
                                             <property name="expand">False</property>
-                                            <property name="homogeneous">True</property>
                                           </packing>
                                         </child>
                                         <child>
-                                          <object class="GtkToolButton" id="toolbutton-activate-swap">
+                                          <object class="GtkButton" id="toolbutton-activate-swap">
                                             <property name="visible">True</property>
                                             <property name="can_focus">False</property>
                                             <property name="tooltip_text" translatable="yes">Activate 
selected swap partition</property>
-                                            <property name="label" translatable="yes" context="Accessibility 
label for toolbutton-activate-swap">Activate swap</property>
                                             <property name="use_underline">True</property>
-                                            <property 
name="icon_name">media-playback-start-symbolic</property>
+                                            <child>
+                                              <object class="GtkImage">
+                                                <property name="visible">True</property>
+                                                <property 
name="icon-name">media-playback-start-symbolic</property>
+                                              </object>
+                                            </child>
                                           </object>
                                           <packing>
                                             <property name="expand">False</property>
-                                            <property name="homogeneous">True</property>
                                           </packing>
                                         </child>
                                         <child>
-                                          <object class="GtkToolButton" id="toolbutton-deactivate-swap">
+                                          <object class="GtkButton" id="toolbutton-deactivate-swap">
                                             <property name="visible">True</property>
                                             <property name="can_focus">False</property>
                                             <property name="tooltip_text" translatable="yes">Deactivate 
selected swap partition</property>
-                                            <property name="label" translatable="yes" context="Accessibility 
label for toolbutton-deactivate-swap">Deactivate swap</property>
                                             <property name="use_underline">True</property>
-                                            <property 
name="icon_name">media-playback-stop-symbolic</property>
+                                            <child>
+                                              <object class="GtkImage">
+                                                <property name="visible">True</property>
+                                                <property 
name="icon-name">media-playback-stop-symbolic</property>
+                                              </object>
+                                            </child>
                                           </object>
                                           <packing>
                                             <property name="expand">False</property>
-                                            <property name="homogeneous">True</property>
                                           </packing>
                                         </child>
                                         <child>
-                                          <object class="GtkToolButton" id="toolbutton-unlock">
+                                          <object class="GtkButton" id="toolbutton-unlock">
                                             <property name="visible">True</property>
                                             <property name="can_focus">False</property>
                                             <property name="tooltip_text" translatable="yes">Unlock selected 
encrypted partition</property>
-                                            <property name="label" translatable="yes" context="Accessibility 
label for toolbutton-unlock">Unlock</property>
                                             <property name="use_underline">True</property>
-                                            <property name="icon_name">changes-allow-symbolic</property>
+                                            <child>
+                                              <object class="GtkImage">
+                                                <property name="visible">True</property>
+                                                <property name="icon-name">changes-allow-symbolic</property>
+                                              </object>
+                                            </child>
                                           </object>
                                           <packing>
                                             <property name="expand">False</property>
-                                            <property name="homogeneous">True</property>
                                           </packing>
                                         </child>
                                         <child>
-                                          <object class="GtkToolButton" id="toolbutton-lock">
+                                          <object class="GtkButton" id="toolbutton-lock">
                                             <property name="visible">True</property>
                                             <property name="can_focus">False</property>
                                             <property name="tooltip_text" translatable="yes">Lock selected 
encrypted partition</property>
-                                            <property name="label" translatable="yes" context="Accessibility 
label for toolbutton-lock">Lock</property>
                                             <property name="use_underline">True</property>
-                                            <property name="icon_name">changes-prevent-symbolic</property>
+                                            <child>
+                                              <object class="GtkImage">
+                                                <property name="visible">True</property>
+                                                <property 
name="icon-name">changes-prevent-symbolic</property>
+                                              </object>
+                                            </child>
                                           </object>
                                           <packing>
                                             <property name="expand">False</property>
-                                            <property name="homogeneous">True</property>
                                           </packing>
                                         </child>
                                         <child>
-                                          <object class="GtkToolButton" id="toolbutton-partition-create">
+                                          <object class="GtkButton" id="toolbutton-partition-create">
                                             <property name="visible">True</property>
                                             <property name="can_focus">False</property>
                                             <property name="tooltip_text" translatable="yes">Create 
partition in unallocated space</property>
-                                            <property name="label" translatable="yes" context="Accessibility 
label for toolbutton-partition-create">Create partition</property>
                                             <property name="use_underline">True</property>
-                                            <property name="icon_name">list-add-symbolic</property>
+                                            <child>
+                                              <object class="GtkImage">
+                                                <property name="visible">True</property>
+                                                <property name="icon-name">list-add-symbolic</property>
+                                              </object>
+                                            </child>
                                           </object>
                                           <packing>
                                             <property name="expand">False</property>
-                                            <property name="homogeneous">True</property>
                                           </packing>
                                         </child>
                                         <child>
-                                          <object class="GtkToolButton" id="toolbutton-partition-delete">
+                                          <object class="GtkButton" id="toolbutton-volume-menu">
                                             <property name="visible">True</property>
                                             <property name="can_focus">False</property>
-                                            <property name="tooltip_text" translatable="yes">Delete selected 
partition</property>
-                                            <property name="label" translatable="yes" context="Accessibility 
label for toolbutton-partition-delete">Delete partition</property>
+                                            <property name="tooltip_text" translatable="yes">Additional 
partition options</property>
                                             <property name="use_underline">True</property>
-                                            <property name="icon_name">list-remove-symbolic</property>
+                                            <child>
+                                              <object class="GtkImage">
+                                                <property name="visible">True</property>
+                                                <property name="icon-name">system-run-symbolic</property>
+                                              </object>
+                                            </child>
                                           </object>
                                           <packing>
                                             <property name="expand">False</property>
-                                            <property name="homogeneous">True</property>
                                           </packing>
                                         </child>
                                         <child>
-                                          <object class="GtkToolButton" id="toolbutton-volume-menu">
+                                          <object class="GtkSeparator">
+                                            <property name="visible">True</property>
+                                            <property name="can-focus">False</property>
+                                            <property name="halign">GTK_ALIGN_START</property>
+                                          </object>
+                                          <packing>
+                                            <property name="expand">True</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <object class="GtkButton" id="toolbutton-partition-delete">
                                             <property name="visible">True</property>
                                             <property name="can_focus">False</property>
-                                            <property name="tooltip_text" translatable="yes">Additional 
partition options</property>
-                                            <property name="label" translatable="yes" context="Accessibility 
label for toolbutton-volume-menu">Menu</property>
+                                            <property name="tooltip_text" translatable="yes">Delete selected 
partition</property>
                                             <property name="use_underline">True</property>
-                                            <property name="icon_name">system-run-symbolic</property>
+                                            <style>
+                                              <class name="destructive-action"/>
+                                            </style>
+                                            <child>
+                                              <object class="GtkImage">
+                                                <property name="visible">True</property>
+                                                <property name="icon-name">list-remove-symbolic</property>
+                                              </object>
+                                            </child>
                                           </object>
                                           <packing>
                                             <property name="expand">False</property>
-                                            <property name="homogeneous">True</property>
                                           </packing>
                                         </child>
                                       </object>
diff --git a/src/libgdu/gduutils.c b/src/libgdu/gduutils.c
index d46254ad..997019a8 100644
--- a/src/libgdu/gduutils.c
+++ b/src/libgdu/gduutils.c
@@ -781,10 +781,12 @@ gdu_utils_show_confirmation (GtkWindow    *parent_window,
                              const gchar  *checkbox_mnemonic,
                              gboolean     *inout_checkbox_value,
                              UDisksClient *client,
-                             GList        *objects)
+                             GList        *objects,
+                             gboolean     destructive_action)
 {
   GtkWidget *check_button = NULL;
   GtkWidget *dialog;
+  GtkWidget *affirmative_button;
   gint response;
 
   dialog = gtk_message_dialog_new_with_markup (parent_window,
@@ -848,10 +850,16 @@ gdu_utils_show_confirmation (GtkWindow    *parent_window,
                           FALSE, FALSE, 0);
     }
 
-  gtk_dialog_add_button (GTK_DIALOG (dialog),
+  affirmative_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
                          affirmative_verb,
                          GTK_RESPONSE_OK);
 
+  if (destructive_action) {
+      GtkStyleContext *context;
+      context = gtk_widget_get_style_context (affirmative_button);
+      gtk_style_context_add_class (context,"destructive-action");
+  }
+
   gtk_widget_grab_focus (gtk_dialog_get_widget_for_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL));
   gtk_widget_show_all (dialog);
 
diff --git a/src/libgdu/gduutils.h b/src/libgdu/gduutils.h
index da2c01b9..e54a56a6 100644
--- a/src/libgdu/gduutils.h
+++ b/src/libgdu/gduutils.h
@@ -73,7 +73,8 @@ gboolean        gdu_utils_show_confirmation (GtkWindow    *parent_window,
                                              const gchar  *checkbox_mnemonic,
                                              gboolean     *inout_checkbox_value,
                                              UDisksClient *client,
-                                             GList        *objects);
+                                             GList        *objects,
+                                             gboolean     destructive_action);
 
 gboolean gdu_utils_is_ntfs_available (UDisksClient *client);
 


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