Skip to content

Commit

Permalink
DriveRow: use GLib.Menu
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed Sep 6, 2024
1 parent c7858fb commit 780dea4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
5 changes: 0 additions & 5 deletions libcore/PopupMenuBuilder.vala
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ public class PopupMenuBuilder : Object {
return menu;
}

public void add_safely_remove () {
// Do we need different text for USB sticks and optical drives?
add_with_action_name (_("Safely Remove"), "mountable.safely-remove");
}

public PopupMenuBuilder add_empty_mount_trash (MenuitemCallback cb) {
var menu_item = new Gtk.MenuItem.with_mnemonic (_("Permanently Delete Trash on this Mount"));
menu_item.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
Expand Down
9 changes: 6 additions & 3 deletions src/View/Sidebar/DriveRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,13 @@ public class Sidebar.DriveRow : Sidebar.AbstractMountableRow, SidebarItemInterfa
// usable actions. In future, actions like "Format" might be added.
var sort_key = drive.get_sort_key ();
if (sort_key != null && sort_key.contains ("hotplug")) {
var menu_builder = new PopupMenuBuilder ();
menu_builder.add_safely_remove ();
var menu = new GLib.Menu ();
menu.append (_("Safely Remove"), "mountable.safely-remove");

menu_builder.build (this).popup_at_pointer (null);
var gtk_menu = new Gtk.Menu.from_model (menu) {
attach_widget = this
};
gtk_menu.popup_at_pointer (null);
}
}
}
2 changes: 1 addition & 1 deletion src/View/Sidebar/VolumeRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public class Sidebar.VolumeRow : Sidebar.AbstractMountableRow, SidebarItemInterf
var sort_key = drive.get_sort_key ();
if (sort_key != null && sort_key.contains ("hotplug")) {
menu_builder.add_separator ();
menu_builder.add_safely_remove ();
menu_builder.add_with_action_name (_("Safely Remove"), "mountable.safely-remove");
} else if (mount == null && drive.can_eject ()) {
menu_builder.add_separator ();
// Do we need different text for USB sticks and optical drives?
Expand Down

0 comments on commit 780dea4

Please sign in to comment.