Skip to content

Commit

Permalink
AbstractMountableRow: add empty trash action
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed Sep 4, 2024
1 parent e339a37 commit 4e3919c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 6 additions & 2 deletions libcore/PopupMenuBuilder.vala
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,14 @@ public class PopupMenuBuilder : Object {
return add_item (menu_item, cb);
}

public PopupMenuBuilder add_empty_mount_trash (MenuitemCallback cb) {
public void add_empty_mount_trash () {
var menu_item = new Gtk.MenuItem.with_mnemonic (_("Permanently Delete Trash on this Mount"));
menu_item.set_detailed_action_name (
Action.print_detailed_name ("mountable.empty-trash", null)
);
menu_item.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
return add_item (menu_item, cb);

add_item (menu_item);
}

public PopupMenuBuilder add_separator () {
Expand Down
12 changes: 6 additions & 6 deletions src/View/Sidebar/AbstractMountableRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,15 @@ public abstract class Sidebar.AbstractMountableRow : Sidebar.BookmarkRow, Sideba
var unmount_action = new SimpleAction ("unmount", null);
unmount_action.activate.connect (() => unmount_mount.begin ());

var empty_trash_action = new SimpleAction ("empty-trash", null);
empty_trash_action.activate.connect (() => Files.FileOperations.empty_trash_for_mount (this, mount));

var action_group = new SimpleActionGroup ();
action_group.add_action (safely_remove_action);
action_group.add_action (eject_action);
action_group.add_action (properties_action);
action_group.add_action (unmount_action);
action_group.add_action (empty_trash_action);

insert_action_group ("mountable", action_group);
}
Expand Down Expand Up @@ -256,12 +260,8 @@ public abstract class Sidebar.AbstractMountableRow : Sidebar.BookmarkRow, Sideba

if (mount != null) {
if (Files.FileOperations.has_trash_files (mount)) {
menu_builder
.add_separator ()
.add_empty_mount_trash (() => {
Files.FileOperations.empty_trash_for_mount (this, mount);
})
;
menu_builder.add_separator ();
menu_builder.add_empty_mount_trash ();
}

if (mount.can_unmount ()) {
Expand Down

0 comments on commit 4e3919c

Please sign in to comment.