Skip to content

Commit

Permalink
Add back mount option to unmounted VolumeRow. (#2145)
Browse files Browse the repository at this point in the history
Co-authored-by: Ryan Kornheisl <ryan@skarva.tech>
  • Loading branch information
Jeremy Wootten and zeebok authored Mar 2, 2023
1 parent 83b09e4 commit 6d88de1
Showing 1 changed file with 34 additions and 17 deletions.
51 changes: 34 additions & 17 deletions src/View/Sidebar/VolumeRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,7 @@ public class Sidebar.VolumeRow : Sidebar.AbstractMountableRow, SidebarItemInterf
return;
}

working = true;
Files.FileOperations.mount_volume_full.begin (volume, null, (obj, res) => {
Files.FileOperations.mount_volume_full.end (res);
var mount = volume.get_mount ();
if (mount != null) {
uri = mount.get_default_location ().get_uri ();
if (volume.get_uuid () == null) {
uuid = uri;
}

list.open_item (this, flag);
}

working = false;
add_mountable_tooltip.begin ();
}
);
mount_volume (true, flag);
}

private void on_volume_removed (Volume removed_volume) {
Expand Down Expand Up @@ -148,11 +132,44 @@ public class Sidebar.VolumeRow : Sidebar.AbstractMountableRow, SidebarItemInterf
add_extra_menu_items_for_drive (volume.get_drive (), menu_builder);
}

private void mount_volume (bool open = false, Files.OpenFlag flag = Files.OpenFlag.DEFAULT) {
working = true;
Files.FileOperations.mount_volume_full.begin (
volume,
null,
(obj, res) => {
Files.FileOperations.mount_volume_full.end (res);
var mount = volume.get_mount ();
if (mount != null) {
uri = mount.get_default_location ().get_uri ();
if (volume.get_uuid () == null) {
uuid = uri;
}

if (open) {
list.open_item (this, flag);
}
}

working = false;
add_mountable_tooltip.begin ();
}
);
}

protected void add_extra_menu_items_for_drive (Drive? drive, PopupMenuBuilder menu_builder) {
if (drive == null) {
return;
}

if (!is_mounted) {
var mount_item = new Gtk.MenuItem.with_mnemonic (_("Mount"));
mount_item.activate.connect (() => {
mount_volume ();
});
menu_builder.add_item (mount_item);
}

var sort_key = drive.get_sort_key ();
if (sort_key != null && sort_key.contains ("hotplug")) {
menu_builder
Expand Down

0 comments on commit 6d88de1

Please sign in to comment.