Skip to content

Commit

Permalink
Rest of the owl
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed Sep 10, 2024
1 parent c6fc251 commit 1c83f3e
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 103 deletions.
2 changes: 1 addition & 1 deletion libcore/Interfaces/SidebarItemInterface.vala
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public interface Sidebar.SidebarItemInterface : Object {
gicon = icon;
}

public virtual void add_extra_menu_items (PopupMenuBuilder menu_builder) {}
public virtual void add_extra_menu_items (GLib.Menu menu) {}
public virtual void update_plugin_data (Files.SidebarPluginItem item) {}

public virtual void activated (Files.OpenFlag flag = Files.OpenFlag.DEFAULT) {
Expand Down
64 changes: 0 additions & 64 deletions libcore/PopupMenuBuilder.vala

This file was deleted.

1 change: 0 additions & 1 deletion libcore/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ pantheon_files_core_vala_files = files(
'Preferences.vala',
'PluginManager.vala',
'Plugin.vala',
'PopupMenuBuilder.vala',
'ProgressInfo.vala',
'ProgressInfoManager.vala',
'Resources.vala',
Expand Down
1 change: 0 additions & 1 deletion po/POTFILES
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ libcore/marlin-file-operations.c
libcore/PixbufUtils.vala
libcore/PluginManager.vala
libcore/Plugin.vala
libcore/PopupMenuBuilder.vala
libcore/Preferences.vala
libcore/ProgressInfoManager.vala
libcore/ProgressInfo.vala
Expand Down
17 changes: 11 additions & 6 deletions src/View/Sidebar/AbstractMountableRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -252,26 +252,31 @@ public abstract class Sidebar.AbstractMountableRow : Sidebar.BookmarkRow, Sideba
update_visibilities ();
}

protected void add_extra_menu_items_for_mount (Mount? mount, PopupMenuBuilder menu_builder) {
protected void add_extra_menu_items_for_mount (Mount? mount, GLib.Menu menu) {
// Do not add items for a volume that is in the middle of being mounted or unmounted
if (working) {
return;
}

if (mount != null) {
var menu_section = new GLib.Menu ();

if (Files.FileOperations.has_trash_files (mount)) {
menu_builder.add_separator ();
// FIXME: any way to make destructive?
menu_builder.add_with_action_name (_("Permanently Delete Trash on this Mount"), "mountable.empty-trash");
menu_section.append (_("Permanently Delete Trash on this Mount"), "mountable.empty-trash");
}

if (mount.can_unmount ()) {
menu_builder.add_with_action_name (_("_Unmount"), "mountable.unmount");
menu_section.append (_("_Unmount"), "mountable.unmount");
}

menu.append_section (null, menu_section);
}

menu_builder.add_separator ();
menu_builder.add_with_action_name (_("Properties"), "mountable.properties"); // This will mount if necessary
var properties_section = new GLib.Menu ();
properties_section.append (_("Properties"), "mountable.properties"); // This will mount if necessary

menu.append_section (null, properties_section);
}

protected async bool get_filesystem_space_for_root (File root, Cancellable? update_cancellable) {
Expand Down
45 changes: 26 additions & 19 deletions src/View/Sidebar/BookmarkRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -312,36 +312,41 @@ public class Sidebar.BookmarkRow : Gtk.ListBoxRow, SidebarItemInterface {
}

protected virtual void popup_context_menu () {
var menu_builder = new PopupMenuBuilder ();
menu_builder.add_with_action_name (_("Open"), "bookmark.open");
menu_builder.add_separator ();
menu_builder.add_with_action_name (_("Open in New _Tab"), "bookmark.open-tab");
menu_builder.add_with_action_name (_("Open in New _Window"), "bookmark.open-window");
var open_section = new GLib.Menu ();
open_section.append (_("Open in New _Tab"), "bookmark.open-tab");
open_section.append (_("Open in New _Window"), "bookmark.open-window");

add_extra_menu_items (menu_builder);
var glib_menu = new GLib.Menu ();
glib_menu.append (_("Open"), "bookmark.open");
glib_menu.append_section (null, open_section);

add_extra_menu_items (glib_menu);

var popupmenu = new Gtk.Menu.from_model (glib_menu) {
attach_widget = this
};

if (menu_model != null) {
menu_builder
.build_from_model (menu_model, action_group_namespace, action_group)
.popup_at_pointer (null);
} else {
menu_builder
.build (this)
.popup_at_pointer (null);
popupmenu.insert_action_group (action_group_namespace, action_group);
glib_menu.append_section (null, menu_model);
}

popupmenu.popup_at_pointer (null);
}

protected override void add_extra_menu_items (PopupMenuBuilder menu_builder) {
protected override void add_extra_menu_items (GLib.Menu menu) {
/* Rows under "Bookmarks" can be removed or renamed */
var menu_section = new GLib.Menu ();
if (!permanent) {
menu_builder.add_separator ();
menu_builder.add_with_action_name (_("Remove"), "bookmark.remove");
menu_section.append (_("Remove"), "bookmark.remove");
}

if (!pinned) {
menu_builder.add_with_action_name (_("Rename"), "bookmark.rename");
menu_section.append (_("Rename"), "bookmark.rename");
}

menu.append_section (null, menu_section);

if (Uri.parse_scheme (uri) == "trash") {
var volume_monitor = VolumeMonitor.@get ();
int mounts_with_trash = 0;
Expand All @@ -353,9 +358,11 @@ public class Sidebar.BookmarkRow : Gtk.ListBoxRow, SidebarItemInterface {

var text = mounts_with_trash > 0 ? _("Permanently Delete All Trash") : _("Permanently Delete Trash");

menu_builder.add_separator ();
var trash_section = new GLib.Menu ();
// FIXME: any way to make destructive?
menu_builder.add_with_action_name (text, "bookmark.empty-all-trash");
trash_section.append (text, "bookmark.empty-all-trash");

menu.append_section (null, trash_section);

empty_all_trash_action.set_enabled (!Files.TrashMonitor.get_default ().is_empty);
}
Expand Down
20 changes: 11 additions & 9 deletions src/View/Sidebar/VolumeRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ public class Sidebar.VolumeRow : Sidebar.AbstractMountableRow, SidebarItemInterf
}
}

protected override void add_extra_menu_items (PopupMenuBuilder menu_builder) {
protected override void add_extra_menu_items (GLib.Menu menu) {
if (working) {
return;
}

add_extra_menu_items_for_mount (volume.get_mount (), menu_builder);
add_extra_menu_items_for_drive (volume.get_drive (), menu_builder);
add_extra_menu_items_for_mount (volume.get_mount (), menu);
add_extra_menu_items_for_drive (volume.get_drive (), menu);
}

private void mount_volume (bool open = false, Files.OpenFlag flag = Files.OpenFlag.DEFAULT) {
Expand Down Expand Up @@ -165,24 +165,26 @@ public class Sidebar.VolumeRow : Sidebar.AbstractMountableRow, SidebarItemInterf
);
}

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

if (!is_mounted) {
menu_builder.add_with_action_name (_("Mount"), "volume.mount");
menu.append (_("Mount"), "volume.mount");
}

var menu_section = new GLib.Menu ();

var sort_key = drive.get_sort_key ();
if (sort_key != null && sort_key.contains ("hotplug")) {
menu_builder.add_separator ();
menu_builder.add_with_action_name (_("Safely Remove"), "mountable.safely-remove");
menu_section.append (_("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?
menu_builder.add_with_action_name (_("Eject Media"), "mountable.eject");
menu_section.append (_("Eject Media"), "mountable.eject");
}

menu.append_section (null, menu_section);
}

protected override async bool get_filesystem_space (Cancellable? update_cancellable) {
Expand Down
4 changes: 2 additions & 2 deletions src/View/Sidebar/VolumelessMountRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ public class Sidebar.VolumelessMountRow : Sidebar.AbstractMountableRow, SidebarI
}
}

protected override void add_extra_menu_items (PopupMenuBuilder menu_builder) {
add_extra_menu_items_for_mount (mount, menu_builder);
protected override void add_extra_menu_items (GLib.Menu menu) {
add_extra_menu_items_for_mount (mount, menu);
}

protected override async bool get_filesystem_space (Cancellable? update_cancellable) {
Expand Down

0 comments on commit 1c83f3e

Please sign in to comment.