summaryrefslogtreecommitdiffstats
path: root/src/files.rs
diff options
context:
space:
mode:
authorrabite <rabite@posteo.de>2019-05-21 20:50:54 +0200
committerrabite <rabite@posteo.de>2019-05-21 20:52:04 +0200
commite8d9c6ad1f82d6b0bbf3cf9449ce53dd525cb77a (patch)
treee9615c4cf832f1a17a640a229c5dd79710ad601e /src/files.rs
parent6f8a6366039282cfce272a4a430590de83f48045 (diff)
merge in media-preview stuff
Squashed commit of the following: commit 4087cee2f2a72bc2d3e44832809cbe99d25a3309 Author: rabite <rabite@posteo.de> Date: Tue May 21 20:40:27 2019 +0200 rename to preview-gen commit 275fd420a01c24393ae9cc07287204fde309130a Author: rabite <rabite@posteo.de> Date: Tue May 21 20:30:50 2019 +0200 update Cargo.toml and README commit bf4c3fec0f8e0ff4628153297ac64fe165b4e443 Author: rabite <rabite@posteo.de> Date: Tue May 21 20:30:33 2019 +0200 add config options for media commit 3bf681cd078177d634507c51d04a45bdae184f1b Author: rabite <rabite@posteo.de> Date: Tue May 21 13:46:00 2019 +0200 always use unicode icons for play/pause/mute commit ed2a0b31d1911e4d42086699ca1db636c327bacf Author: rabite <rabite@posteo.de> Date: Tue May 21 13:04:11 2019 +0200 rename to mediaview and some fixups commit bda3f8f83bec07c3f52d06cf5f8eaad7fdbd85a0 Author: rabite <rabite@posteo.de> Date: Tue May 21 11:44:52 2019 +0200 fix warnings commit 9c917903cfa958b225f268ed4fb9f55f27162be0 Author: rabite <rabite@posteo.de> Date: Tue May 21 01:10:58 2019 +0200 play audio through viedo widget commit 9fe208b213710fae889f7701bdb3bf96d599c9a8 Author: rabite <rabite@posteo.de> Date: Tue May 21 00:15:12 2019 +0200 fixed play when autoplay is off commit d4036d52864d0a4e08f7da2cf6f7419ef070c1a9 Author: rabite <rabite@posteo.de> Date: Mon May 20 13:15:44 2019 +0200 add icons for play/pause/mute commit 29f0d203cfd7501b50d80501de146da9d89388bb Author: rabite <rabite@posteo.de> Date: Mon May 20 12:26:53 2019 +0200 add basic gif support commit 8d28e4c23a91b0ef83739554c3a2f6671a9ff6f5 Author: rabite <rabite@posteo.de> Date: Mon May 20 11:43:57 2019 +0200 fixed play after pause commit 142017df78de77bcfffd8f3dd9612a06927e183b Author: rabite <rabite@posteo.de> Date: Sun May 19 14:22:16 2019 +0200 change to stale on drop commit c0026c7f56f6a841df18e41bd1c9b33543e26cfb Author: rabite <rabite@posteo.de> Date: Sat May 18 23:46:27 2019 +0200 handle errors in gstreamer closure commit ef37f872c54b9d21ed5505c2edb480c793afaef9 Author: rabite <rabite@posteo.de> Date: Sat May 18 23:40:24 2019 +0200 add image-only mode to preview-gen commit 15752464563463c6ecf892c1d8a14651bf32e1e5 Author: rabite <rabite@posteo.de> Date: Sat May 18 23:28:33 2019 +0200 add copyright note commit 4c9f08fc4de5d3bffefd42284b60aa81cfbae9f7 Author: rabite <rabite@posteo.de> Date: Sat May 18 23:27:30 2019 +0200 make image/video previews optional commit 9c2c2db2b20ecd4c30acbb1c77ad18c71f528c4c Author: rabite <rabite@posteo.de> Date: Sat May 18 22:13:25 2019 +0200 remove blank space under video commit f7056d70fbe9147b3b95d7c10950653eadbb4f48 Author: rabite <rabite@posteo.de> Date: Sat May 18 22:06:49 2019 +0200 remove dbg commit cce820657ff1258cdb78d455dd3cf04564450cea Author: rabite <rabite@posteo.de> Date: Sat May 18 21:50:25 2019 +0200 added error handling to preview-gen commit 80bbe15bacb99d1f4f97504a5d10ecf59544993f Author: rabite <rabite@posteo.de> Date: Sat May 18 21:04:31 2019 +0200 add time and visual seek bars to videoview commit 4349945cc5549334f246be64bc7c8e2db43f9150 Author: rabite <rabite@posteo.de> Date: Thu May 16 22:39:19 2019 +0200 fix sneaky process commit 373128b7096d4de29924617e549a613a3aeea5b2 Author: rabite <rabite@posteo.de> Date: Thu May 16 22:07:27 2019 +0200 fix out of controll processes commit e061e065e913ab3923ffac1079a9f0a2be0df532 Author: rabite <rabite@posteo.de> Date: Thu May 16 20:51:56 2019 +0200 add media_preview commit f68c754895a9718d1a962980de9fbf02e5cb48cd Author: rabite <rabite@posteo.de> Date: Thu May 16 19:37:04 2019 +0200 beta image/video previews commit 9a5460e553dd26ebccffaf819c64a8dc6ba74818 Author: rabite <rabite@posteo.de> Date: Tue May 14 20:36:25 2019 +0200 external img preview commit 3c4edfcb7611b36f6e537c73743e0b6bd269037b Author: rabite <rabite@posteo.de> Date: Tue May 14 20:35:12 2019 +0200 video preview
Diffstat (limited to 'src/files.rs')
-rw-r--r--src/files.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/files.rs b/src/files.rs
index 17b2612..25e3393 100644
--- a/src/files.rs
+++ b/src/files.rs
@@ -18,6 +18,8 @@ use failure::Error;
use notify::DebouncedEvent;
use rayon::{ThreadPool, ThreadPoolBuilder};
use alphanumeric_sort::compare_str;
+use mime_guess;
+
use pathbuftools::PathBufTools;
use async_value::{Async, Stale};
@@ -830,9 +832,12 @@ impl File {
Ok((size, unit))
}
- // pub fn get_mime(&self) -> String {
- // tree_magic::from_filepath(&self.path)
- // }
+ pub fn get_mime(&self) -> Option<mime_guess::Mime> {
+ if let Some(ext) = self.path.extension() {
+ let mime = mime_guess::get_mime_type(&ext.to_string_lossy());
+ Some(mime)
+ } else { None }
+ }
pub fn is_text(&self) -> bool {
tree_magic::match_filepath("text/plain", &self.path)