After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 771356 - Delete actions button should have 'destructive-action' style class
Delete actions button should have 'destructive-action' style class
Status: RESOLVED FIXED
Product: nautilus
Classification: Core
Component: general
3.21.x
Other Linux
: Normal normal
: 3.24
Assigned To: Nautilus Maintainers
Nautilus Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-09-13 12:03 UTC by Mohammed Sadiq
Modified: 2017-03-07 09:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Nautilus Shift Delete confirmation (image) (122.07 KB, image/png)
2016-09-13 12:03 UTC, Mohammed Sadiq
  Details
Use 'destructive-action' style class (1.47 KB, patch)
2017-02-20 16:43 UTC, Eduard Čuba
none Details | Review
destructive-action: change button style when permanently deleting file (2.44 KB, patch)
2017-02-20 16:53 UTC, Marek Tamaškovič
none Details | Review
destructive-action: change button style when permanently deleting file (2.49 KB, patch)
2017-02-20 17:59 UTC, Marek Tamaškovič
needs-work Details | Review
Use 'destructive-action' style class for delete button. (1.70 KB, patch)
2017-02-21 15:25 UTC, Eduard Čuba
none Details | Review
Use 'destructive-action' style class for delete button. (1.70 KB, patch)
2017-02-24 11:13 UTC, Eduard Čuba
committed Details | Review

Description Mohammed Sadiq 2016-09-13 12:03:06 UTC
Created attachment 335436 [details]
Nautilus Shift Delete confirmation (image)

Delte buttons in confirmation dialog don't have any style classes. Adding 'destructive-action' would be nice.
Comment 1 Carlos Soriano 2016-09-13 12:50:06 UTC
good idea
Comment 2 Jeremy Bicha 2017-02-15 11:46:04 UTC
Here's an example of how this can be implemented:
https://git.gnome.org/browse/gnome-control-center/tree/panels/privacy/cc-privacy-panel.c#n1035
Comment 3 Eduard Čuba 2017-02-20 16:43:36 UTC
Created attachment 346271 [details] [review]
Use 'destructive-action' style class

Proposal of patch from GNOME hackaton @FIT.
Comment 4 Marek Tamaškovič 2017-02-20 16:53:01 UTC
Created attachment 346272 [details] [review]
destructive-action: change button style when permanently deleting file

In this commit we changed color of button in confirmation dialog when user permanently deletinf file.

The problem is that native dialog hasn't any color warning on buttons which are dangerous with no way back.

So we changed a color of delete button to inform users that it is dangerous one and it is on his own risk to click on it.
Comment 5 Marek Tamaškovič 2017-02-20 17:56:26 UTC
Review of attachment 346272 [details] [review]:

There is a problem with deleting file.
After shift+del it only adds a file to a pending list!
Comment 6 Marek Tamaškovič 2017-02-20 17:59:57 UTC
Created attachment 346280 [details] [review]
destructive-action: change button style when permanently deleting file

In this commit we changed color of button in confirmation dialog when user permanently deletinf file.

The problem is that native dialog hasn't any color warning on buttons which are dangerous with no way back.

So we changed a color of delete button to inform users that it is dangerous one and it is on his own risk to click on it.
Comment 7 Carlos Soriano 2017-02-21 11:59:20 UTC
Review of attachment 346271 [details] [review]:

The code looks good. The commit message needs some work, as I explained in the hackathon and how is explained in here: https://wiki.gnome.org/Newcomers/CodeContributionWorkflow#Commit_guidelines

You can point out that this is mentioned in the HIG (Human Interface Guidelines) for buttons and dialogs in: https://developer.gnome.org/hig/stable/buttons.html.en (that's why the change)
Comment 8 Carlos Soriano 2017-02-21 12:26:09 UTC
Review of attachment 346280 [details] [review]:

Hey good work on the patch! The code needs work, but the commit message is good. See the code review:

::: src/nautilus-file-operations.c
@@ +1484,3 @@
+                                   NULL);
+
+                                   0,

it's better to use the API of GtkDialog rather than g_object_set, it's clearer.

@@ +1485,3 @@
+
+    g_object_set(dialog, "text", primary_text, "secondary-text", secondary_text, NULL);
+                                   GTK_MESSAGE_WARNING,

missing space after commas

@@ +1486,3 @@
+    g_object_set(dialog, "text", primary_text, "secondary-text", secondary_text, NULL);
+    gtk_dialog_add_button(GTK_DIALOG(dialog),_("_Cancel"),GTK_RESPONSE_CANCEL);
+                                   GTK_MESSAGE_WARNING,

Here we are in a generic "run_warning" function, but this code does something more specific than that. We should either change the function name or make the code more generic.
Since we already have other code that deals with this situation (the run_simple_dialog_va) we should modify that instead.

@@ +1489,3 @@
+
+    gtk_dialog_set_default_response(GTK_DIALOG(dialog),FALSE);
+                                   NULL);

you can actually get this button from the gtk_dialog_add_button call as a return value

@@ +1497,2 @@
     va_end (varargs);
+    return res == GTK_RESPONSE_OK;

What's returned it's not a boolean, but the actual response_id, so you need to return "res" as before.

@@ +1708,3 @@
                             NULL);
 
+

spurious style change
Comment 9 Eduard Čuba 2017-02-21 15:25:44 UTC
Created attachment 346367 [details] [review]
Use 'destructive-action' style class for delete button.

Edited commit message.
Comment 10 Carlos Soriano 2017-02-23 11:04:36 UTC
Review of attachment 346367 [details] [review]:

Hey! Commit message is now good, just a small code change which I didn't realized before:

::: src/nautilus-file-operations.c
@@ +1318,3 @@
         gtk_dialog_set_default_response (GTK_DIALOG (dialog), response_id);
+
+        if (!g_strcmp0(button_title, DELETE))

Just realized this thanks to Sadiq, can you use != 0? Here you are using a logic operand with a rational value, which is wrong.
Comment 11 Eduard Čuba 2017-02-23 17:14:03 UTC
(In reply to Carlos Soriano from comment #10)
> Review of attachment 346367 [details] [review] [review]:
> 
> Hey! Commit message is now good, just a small code change which I didn't
> realized before:
> 
> ::: src/nautilus-file-operations.c
> @@ +1318,3 @@
>          gtk_dialog_set_default_response (GTK_DIALOG (dialog), response_id);
> +
> +        if (!g_strcmp0(button_title, DELETE))
> 
> Just realized this thanks to Sadiq, can you use != 0? Here you are using a
> logic operand with a rational value, which is wrong.

g_strcmp0(str1, str2) returns 0 if str1 == str2.

https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strcmp0

I could use == 0, if you find that more readable, but technically it should be the same.
Comment 12 Carlos Soriano 2017-02-23 17:47:06 UTC
> 
> I could use == 0, if you find that more readable, but technically it should
> be the same.

Yes, it's about the correct semantics
Comment 13 Eduard Čuba 2017-02-24 11:13:42 UTC
Created attachment 346624 [details] [review]
Use 'destructive-action' style class for delete button.

fixed '!' -> == 0
Comment 14 Carlos Soriano 2017-02-24 12:49:59 UTC
Review of attachment 346624 [details] [review]:

Now it looks good! Congrats for your first contribution!
Comment 15 Marek Tamaškovič 2017-03-07 09:09:04 UTC
Thank you, guys.  I gained so many experiences through this bug fix. I appreciate a code review you gave me. I think I will continue in these contributions to open source.

Thanks!
Comment 16 Carlos Soriano 2017-03-07 09:16:12 UTC
(In reply to Marek Tamaškovič from comment #15)
> Thank you, guys.  I gained so many experiences through this bug fix. I
> appreciate a code review you gave me. I think I will continue in these
> contributions to open source.
> 
> Thanks!

Really happy to hear that!