Merge branch 'refs/heads/master' into recent_section
# Conflicts: # Cargo.lock # src/tab.rs
This commit is contained in:
commit
a27e67b957
6 changed files with 306 additions and 170 deletions
76
src/app.rs
76
src/app.rs
|
|
@ -211,7 +211,7 @@ impl MenuAction for NavMenuAction {
|
|||
pub enum Message {
|
||||
AddToSidebar(Option<Entity>),
|
||||
AppTheme(AppTheme),
|
||||
CloseToast(usize),
|
||||
CloseToast(widget::ToastId),
|
||||
Config(Config),
|
||||
Copy(Option<Entity>),
|
||||
Cut(Option<Entity>),
|
||||
|
|
@ -231,6 +231,7 @@ pub enum Message {
|
|||
NavBarContext(Entity),
|
||||
NavMenuAction(NavMenuAction),
|
||||
NewItem(Option<Entity>, bool),
|
||||
#[cfg(feature = "notify")]
|
||||
Notification(Arc<Mutex<notify_rust::NotificationHandle>>),
|
||||
NotifyEvents(Vec<DebouncedEvent>),
|
||||
NotifyWatcher(WatcherWrapper),
|
||||
|
|
@ -263,7 +264,7 @@ pub enum Message {
|
|||
TabRescan(Entity, Location, Vec<tab::Item>, Option<PathBuf>),
|
||||
ToggleContextPage(ContextPage),
|
||||
Undo(usize),
|
||||
UndoTrash(usize, Arc<[PathBuf]>),
|
||||
UndoTrash(widget::ToastId, Arc<[PathBuf]>),
|
||||
UndoTrashStart(Vec<TrashItem>),
|
||||
WindowClose,
|
||||
WindowNew,
|
||||
|
|
@ -368,6 +369,7 @@ pub struct App {
|
|||
modifiers: Modifiers,
|
||||
mounters: Mounters,
|
||||
mounter_items: HashMap<MounterKey, MounterItems>,
|
||||
#[cfg(feature = "notify")]
|
||||
notification_opt: Option<Arc<Mutex<notify_rust::NotificationHandle>>>,
|
||||
pending_operation_id: u64,
|
||||
pending_operations: BTreeMap<u64, (Operation, f32)>,
|
||||
|
|
@ -604,6 +606,7 @@ impl App {
|
|||
fn update_notification(&mut self) -> Command<Message> {
|
||||
// Handle closing notification if there are no operations
|
||||
if self.pending_operations.is_empty() {
|
||||
#[cfg(feature = "notify")]
|
||||
if let Some(notification_arc) = self.notification_opt.take() {
|
||||
return Command::perform(
|
||||
async move {
|
||||
|
|
@ -1067,6 +1070,7 @@ impl Application for App {
|
|||
modifiers: Modifiers::empty(),
|
||||
mounters: mounters(),
|
||||
mounter_items: HashMap::new(),
|
||||
#[cfg(feature = "notify")]
|
||||
notification_opt: None,
|
||||
pending_operation_id: 0,
|
||||
pending_operations: BTreeMap::new(),
|
||||
|
|
@ -1463,6 +1467,7 @@ impl Application for App {
|
|||
}
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "notify")]
|
||||
Message::Notification(notification) => {
|
||||
self.notification_opt = Some(notification);
|
||||
}
|
||||
|
|
@ -2830,38 +2835,43 @@ impl Application for App {
|
|||
//TODO: inhibit suspend/shutdown?
|
||||
|
||||
if self.window_id_opt.is_none() {
|
||||
struct NotificationSubscription;
|
||||
subscriptions.push(subscription::channel(
|
||||
TypeId::of::<NotificationSubscription>(),
|
||||
1,
|
||||
move |msg_tx| async move {
|
||||
let msg_tx = Arc::new(tokio::sync::Mutex::new(msg_tx));
|
||||
tokio::task::spawn_blocking(move || match notify_rust::Notification::new()
|
||||
.summary(&fl!("notification-in-progress"))
|
||||
.timeout(notify_rust::Timeout::Never)
|
||||
.show()
|
||||
{
|
||||
Ok(notification) => {
|
||||
let _ = futures::executor::block_on(async {
|
||||
msg_tx
|
||||
.lock()
|
||||
.await
|
||||
.send(Message::Notification(Arc::new(Mutex::new(
|
||||
notification,
|
||||
))))
|
||||
.await
|
||||
});
|
||||
}
|
||||
Err(err) => {
|
||||
log::warn!("failed to create notification: {}", err);
|
||||
}
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
#[cfg(feature = "notify")]
|
||||
{
|
||||
struct NotificationSubscription;
|
||||
subscriptions.push(subscription::channel(
|
||||
TypeId::of::<NotificationSubscription>(),
|
||||
1,
|
||||
move |msg_tx| async move {
|
||||
let msg_tx = Arc::new(tokio::sync::Mutex::new(msg_tx));
|
||||
tokio::task::spawn_blocking(move || {
|
||||
match notify_rust::Notification::new()
|
||||
.summary(&fl!("notification-in-progress"))
|
||||
.timeout(notify_rust::Timeout::Never)
|
||||
.show()
|
||||
{
|
||||
Ok(notification) => {
|
||||
let _ = futures::executor::block_on(async {
|
||||
msg_tx
|
||||
.lock()
|
||||
.await
|
||||
.send(Message::Notification(Arc::new(Mutex::new(
|
||||
notification,
|
||||
))))
|
||||
.await
|
||||
});
|
||||
}
|
||||
Err(err) => {
|
||||
log::warn!("failed to create notification: {}", err);
|
||||
}
|
||||
}
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
pending().await
|
||||
},
|
||||
));
|
||||
pending().await
|
||||
},
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
99
src/tab.rs
99
src/tab.rs
|
|
@ -59,11 +59,27 @@ use std::{
|
|||
fmt,
|
||||
fs::{self, Metadata},
|
||||
num::NonZeroU16,
|
||||
os::unix::fs::MetadataExt,
|
||||
path::PathBuf,
|
||||
sync::{Arc, Mutex},
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
app::{self, Action},
|
||||
clipboard::{ClipboardCopy, ClipboardKind, ClipboardPaste},
|
||||
config::{IconSizes, TabConfig, ICON_SCALE_MAX, ICON_SIZE_GRID},
|
||||
dialog::DialogKind,
|
||||
fl,
|
||||
localize::{LANGUAGE_CHRONO, LANGUAGE_SORTER},
|
||||
menu,
|
||||
mime_app::{mime_apps, MimeApp},
|
||||
mime_icon::{mime_for_path, mime_icon},
|
||||
mouse_area,
|
||||
};
|
||||
use unix_permissions_ext::UNIXPermissionsExt;
|
||||
use users::{get_group_by_gid, get_user_by_uid};
|
||||
|
||||
pub const DOUBLE_CLICK_DURATION: Duration = Duration::from_millis(500);
|
||||
pub const HOVER_DURATION: Duration = Duration::from_millis(1600);
|
||||
|
||||
|
|
@ -202,6 +218,49 @@ fn format_size(size: u64) -> String {
|
|||
format!("{} B", size)
|
||||
}
|
||||
}
|
||||
enum PermissionOwner {
|
||||
Owner,
|
||||
Group,
|
||||
Other,
|
||||
}
|
||||
|
||||
fn format_permissions_owner(metadata: &Metadata, owner: PermissionOwner) -> String {
|
||||
return match owner {
|
||||
PermissionOwner::Owner => get_user_by_uid(metadata.uid())
|
||||
.and_then(|user| user.name().to_str().map(ToOwned::to_owned))
|
||||
.unwrap_or_default(),
|
||||
PermissionOwner::Group => get_group_by_gid(metadata.gid())
|
||||
.and_then(|group| group.name().to_str().map(ToOwned::to_owned))
|
||||
.unwrap_or_default(),
|
||||
PermissionOwner::Other => String::from(""),
|
||||
};
|
||||
}
|
||||
fn format_permissions(metadata: &Metadata, owner: PermissionOwner) -> String {
|
||||
let mut perms: Vec<String> = Vec::new();
|
||||
if match owner {
|
||||
PermissionOwner::Owner => metadata.permissions().readable_by_owner(),
|
||||
PermissionOwner::Group => metadata.permissions().readable_by_group(),
|
||||
PermissionOwner::Other => metadata.permissions().readable_by_other(),
|
||||
} {
|
||||
perms.push(fl!("read"));
|
||||
}
|
||||
if match owner {
|
||||
PermissionOwner::Owner => metadata.permissions().writable_by_owner(),
|
||||
PermissionOwner::Group => metadata.permissions().writable_by_group(),
|
||||
PermissionOwner::Other => metadata.permissions().writable_by_other(),
|
||||
} {
|
||||
perms.push(fl!("write"));
|
||||
}
|
||||
if match owner {
|
||||
PermissionOwner::Owner => metadata.permissions().executable_by_owner(),
|
||||
PermissionOwner::Group => metadata.permissions().executable_by_group(),
|
||||
PermissionOwner::Other => metadata.permissions().executable_by_other(),
|
||||
} {
|
||||
perms.push(fl!("execute"));
|
||||
}
|
||||
|
||||
perms.join(" ")
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
fn hidden_attribute(_metadata: &Metadata) -> bool {
|
||||
|
|
@ -907,6 +966,46 @@ impl Item {
|
|||
.format_localized(TIME_FORMAT, *LANGUAGE_CHRONO)
|
||||
)));
|
||||
}
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
{
|
||||
column = column.push(
|
||||
widget::Row::new()
|
||||
.push(widget::text(format!("{}:", fl!("owner"))))
|
||||
.push(widget::text(format_permissions_owner(
|
||||
metadata,
|
||||
PermissionOwner::Owner,
|
||||
)))
|
||||
.push(widget::text(format!(
|
||||
"({})",
|
||||
format_permissions(metadata, PermissionOwner::Owner,)
|
||||
)))
|
||||
.spacing(10),
|
||||
);
|
||||
|
||||
column = column.push(
|
||||
widget::Row::new()
|
||||
.push(widget::text(format!("{}:", fl!("group"))))
|
||||
.push(widget::text(format_permissions_owner(
|
||||
metadata,
|
||||
PermissionOwner::Group,
|
||||
)))
|
||||
.push(widget::text(format!(
|
||||
"({})",
|
||||
format_permissions(metadata, PermissionOwner::Group,)
|
||||
)))
|
||||
.spacing(10),
|
||||
);
|
||||
|
||||
column = column.push(
|
||||
widget::Row::new()
|
||||
.push(widget::text(format!("{}", fl!("other"))))
|
||||
.push(widget::text(format!(
|
||||
"({})",
|
||||
format_permissions(metadata, PermissionOwner::Other,)
|
||||
)))
|
||||
.spacing(10),
|
||||
);
|
||||
}
|
||||
}
|
||||
ItemMetadata::Trash { .. } => {
|
||||
//TODO: trash metadata
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue