sort imports
This commit is contained in:
parent
4cde2d02e6
commit
9c1e48a4f6
15 changed files with 136 additions and 104 deletions
|
@ -1,10 +1,12 @@
|
||||||
use hyprland::dispatch::{DispatchType, WindowIdentifier};
|
|
||||||
use hyprland::prelude::HyprData;
|
|
||||||
use hyprland::shared::Address;
|
|
||||||
use rayon::prelude::*;
|
|
||||||
use std::{env, sync::Arc};
|
use std::{env, sync::Arc};
|
||||||
use sysinfo::{Pid, System};
|
|
||||||
|
|
||||||
|
use hyprland::{
|
||||||
|
dispatch::{DispatchType, WindowIdentifier},
|
||||||
|
prelude::HyprData,
|
||||||
|
shared::Address,
|
||||||
|
};
|
||||||
|
use rayon::prelude::*;
|
||||||
|
use sysinfo::{Pid, System};
|
||||||
use worf_lib::{
|
use worf_lib::{
|
||||||
config::{self, Config},
|
config::{self, Config},
|
||||||
desktop::EntryType,
|
desktop::EntryType,
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
use std::collections::HashMap;
|
use std::{collections::HashMap, env, process::Command, thread::sleep, time::Duration};
|
||||||
use std::env;
|
|
||||||
use std::process::Command;
|
use worf_lib::{
|
||||||
use std::thread::sleep;
|
config::{self, Config, CustomKeyHintLocation},
|
||||||
use std::time::Duration;
|
desktop::{copy_to_clipboard, spawn_fork},
|
||||||
use worf_lib::config::{Config, CustomKeyHintLocation};
|
gui::{self, CustomKeyHint, CustomKeys, ItemProvider, Key, KeyBinding, MenuItem, Modifier},
|
||||||
use worf_lib::desktop::{copy_to_clipboard, spawn_fork};
|
};
|
||||||
use worf_lib::gui::{CustomKeyHint, CustomKeys, ItemProvider, Key, KeyBinding, MenuItem, Modifier};
|
|
||||||
use worf_lib::{config, gui};
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct MenuItemMetaData {
|
struct MenuItemMetaData {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
use crate::Error;
|
use std::{env, fs, path::PathBuf, str::FromStr};
|
||||||
|
|
||||||
use clap::{Parser, ValueEnum};
|
use clap::{Parser, ValueEnum};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use std::path::PathBuf;
|
|
||||||
use std::str::FromStr;
|
|
||||||
use std::{env, fs};
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
|
use crate::Error;
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Serialize, Deserialize)]
|
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Serialize, Deserialize)]
|
||||||
pub enum Anchor {
|
pub enum Anchor {
|
||||||
Top,
|
Top,
|
||||||
|
|
|
@ -2,12 +2,8 @@ use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
env,
|
env,
|
||||||
ffi::OsStr,
|
ffi::OsStr,
|
||||||
fs,
|
fs, io,
|
||||||
io,
|
os::unix::{fs::PermissionsExt, prelude::CommandExt},
|
||||||
os::unix::{
|
|
||||||
fs::PermissionsExt,
|
|
||||||
prelude::CommandExt,
|
|
||||||
},
|
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
process::{Command, Stdio},
|
process::{Command, Stdio},
|
||||||
time::Instant,
|
time::Instant,
|
||||||
|
@ -20,8 +16,8 @@ use regex::Regex;
|
||||||
use wl_clipboard_rs::copy::{ClipboardType, MimeType, ServeRequests, Source};
|
use wl_clipboard_rs::copy::{ClipboardType, MimeType, ServeRequests, Source};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::{expand_path, Config},
|
|
||||||
Error,
|
Error,
|
||||||
|
config::{Config, expand_path},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Returns a regex with supported image extensions
|
/// Returns a regex with supported image extensions
|
||||||
|
|
|
@ -1,34 +1,37 @@
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::{
|
||||||
use std::rc::Rc;
|
collections::{HashMap, HashSet},
|
||||||
use std::sync::{Arc, Mutex, RwLock};
|
rc::Rc,
|
||||||
use std::thread;
|
sync::{Arc, Mutex, RwLock},
|
||||||
use std::time::Instant;
|
thread,
|
||||||
|
time::Instant,
|
||||||
|
};
|
||||||
|
|
||||||
use crossbeam::channel;
|
use crossbeam::channel::{self, Sender};
|
||||||
use crossbeam::channel::Sender;
|
use gdk4::{
|
||||||
use gdk4::Display;
|
Display,
|
||||||
use gdk4::gio::File;
|
gio::File,
|
||||||
use gdk4::glib::{MainContext, Propagation};
|
glib::{self, MainContext, Propagation},
|
||||||
use gdk4::prelude::{Cast, DisplayExt, MonitorExt, SurfaceExt};
|
prelude::{Cast, DisplayExt, MonitorExt, SurfaceExt},
|
||||||
use gtk4::glib::ControlFlow;
|
|
||||||
use gtk4::prelude::{
|
|
||||||
ApplicationExt, ApplicationExtManual, BoxExt, EditableExt, FlowBoxChildExt, GestureSingleExt,
|
|
||||||
GtkWindowExt, ListBoxRowExt, NativeExt, OrientableExt, WidgetExt,
|
|
||||||
};
|
};
|
||||||
use gtk4::{
|
use gtk4::{
|
||||||
Align, EventControllerKey, Expander, FlowBox, FlowBoxChild, GestureClick, Image, Label,
|
Align, Application, ApplicationWindow, CssProvider, EventControllerKey, Expander, FlowBox,
|
||||||
ListBox, ListBoxRow, NaturalWrapMode, Ordering, PolicyType, ScrolledWindow, SearchEntry,
|
FlowBoxChild, GestureClick, Image, Label, ListBox, ListBoxRow, NaturalWrapMode, Ordering,
|
||||||
Widget, gdk, glib,
|
Orientation, PolicyType, ScrolledWindow, SearchEntry, Widget,
|
||||||
|
glib::ControlFlow,
|
||||||
|
prelude::{
|
||||||
|
ApplicationExt, ApplicationExtManual, BoxExt, EditableExt, FlowBoxChildExt,
|
||||||
|
GestureSingleExt, GtkWindowExt, ListBoxRowExt, NativeExt, OrientableExt, WidgetExt,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
use gtk4::{Application, ApplicationWindow, CssProvider, Orientation};
|
|
||||||
use gtk4_layer_shell::{Edge, KeyboardMode, LayerShell};
|
use gtk4_layer_shell::{Edge, KeyboardMode, LayerShell};
|
||||||
use log;
|
use log;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Error, config,
|
Error,
|
||||||
config::{
|
config::{
|
||||||
Anchor, Config, CustomKeyHintLocation, KeyDetectionType, MatchMethod, SortOrder, WrapMode,
|
self, Anchor, Config, CustomKeyHintLocation, KeyDetectionType, MatchMethod, SortOrder,
|
||||||
|
WrapMode,
|
||||||
},
|
},
|
||||||
desktop::known_image_extension_regex_pattern,
|
desktop::known_image_extension_regex_pattern,
|
||||||
};
|
};
|
||||||
|
@ -229,7 +232,7 @@ pub enum Key {
|
||||||
Tilde, // ~
|
Tilde, // ~
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<gdk::Key> for Key {
|
impl From<gtk4::gdk::Key> for Key {
|
||||||
fn from(value: gdk4::Key) -> Self {
|
fn from(value: gdk4::Key) -> Self {
|
||||||
match value {
|
match value {
|
||||||
// Letters
|
// Letters
|
||||||
|
@ -1396,7 +1399,7 @@ fn create_menu_row<T: Clone + 'static + Send>(
|
||||||
let element_clone = element_to_add.clone();
|
let element_clone = element_to_add.clone();
|
||||||
|
|
||||||
let click = GestureClick::new();
|
let click = GestureClick::new();
|
||||||
click.set_button(gdk::BUTTON_PRIMARY);
|
click.set_button(gtk4::gdk::BUTTON_PRIMARY);
|
||||||
click.connect_pressed(move |_gesture, n_press, _x, _y| {
|
click.connect_pressed(move |_gesture, n_press, _x, _y| {
|
||||||
if n_press == 2 {
|
if n_press == 2 {
|
||||||
if let Err(e) = handle_selected_item(
|
if let Err(e) = handle_selected_item(
|
||||||
|
|
|
@ -1,14 +1,19 @@
|
||||||
use crate::config::Config;
|
|
||||||
use crate::desktop::spawn_fork;
|
|
||||||
use crate::gui::{ItemProvider, MenuItem};
|
|
||||||
use crate::modes::drun::{DRunProvider, update_drun_cache_and_run};
|
|
||||||
use crate::modes::file::FileItemProvider;
|
|
||||||
use crate::modes::math::MathProvider;
|
|
||||||
use crate::modes::ssh;
|
|
||||||
use crate::modes::ssh::SshProvider;
|
|
||||||
use crate::{Error, gui};
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
Error,
|
||||||
|
config::Config,
|
||||||
|
desktop::spawn_fork,
|
||||||
|
gui::{self, ItemProvider, MenuItem},
|
||||||
|
modes::{
|
||||||
|
drun::{DRunProvider, update_drun_cache_and_run},
|
||||||
|
file::FileItemProvider,
|
||||||
|
math::MathProvider,
|
||||||
|
ssh,
|
||||||
|
ssh::SshProvider,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
enum AutoRunType {
|
enum AutoRunType {
|
||||||
Math,
|
Math,
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
use crate::config::{Config, SortOrder};
|
use std::io::{self, Read};
|
||||||
use crate::gui::{ItemProvider, MenuItem};
|
|
||||||
use crate::{Error, gui};
|
use crate::{
|
||||||
use std::io;
|
Error,
|
||||||
use std::io::Read;
|
config::{Config, SortOrder},
|
||||||
|
gui::{self, ItemProvider, MenuItem},
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct DMenuProvider {
|
struct DMenuProvider {
|
||||||
|
|
|
@ -1,16 +1,23 @@
|
||||||
use crate::config::{Config, SortOrder};
|
use std::{
|
||||||
use crate::desktop::{
|
collections::{HashMap, HashSet},
|
||||||
find_desktop_files, get_locale_variants, lookup_name_with_locale, save_cache_file, spawn_fork,
|
path::PathBuf,
|
||||||
|
time::Instant,
|
||||||
};
|
};
|
||||||
use crate::gui::{ItemProvider, MenuItem};
|
|
||||||
use crate::modes::load_cache;
|
|
||||||
use crate::{Error, gui};
|
|
||||||
use freedesktop_file_parser::EntryType;
|
use freedesktop_file_parser::EntryType;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::{HashMap, HashSet};
|
|
||||||
use std::path::PathBuf;
|
use crate::{
|
||||||
use std::time::Instant;
|
Error,
|
||||||
|
config::{Config, SortOrder},
|
||||||
|
desktop::{
|
||||||
|
find_desktop_files, get_locale_variants, lookup_name_with_locale, save_cache_file,
|
||||||
|
spawn_fork,
|
||||||
|
},
|
||||||
|
gui::{self, ItemProvider, MenuItem},
|
||||||
|
modes::load_cache,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||||
struct DRunCache {
|
struct DRunCache {
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
use crate::config::{Config, SortOrder};
|
use crate::{
|
||||||
use crate::desktop::copy_to_clipboard;
|
Error,
|
||||||
use crate::gui::{ItemProvider, MenuItem};
|
config::{Config, SortOrder},
|
||||||
use crate::{Error, gui};
|
desktop::copy_to_clipboard,
|
||||||
|
gui::{self, ItemProvider, MenuItem},
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub(crate) struct EmojiProvider {
|
pub(crate) struct EmojiProvider {
|
||||||
|
|
|
@ -1,11 +1,17 @@
|
||||||
use crate::config::{Config, SortOrder, expand_path};
|
use std::{
|
||||||
use crate::desktop::spawn_fork;
|
fs,
|
||||||
use crate::gui::{ItemProvider, MenuItem};
|
os::unix::fs::FileTypeExt,
|
||||||
use crate::{Error, gui};
|
path::{Path, PathBuf},
|
||||||
|
};
|
||||||
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::fs;
|
|
||||||
use std::os::unix::fs::FileTypeExt;
|
use crate::{
|
||||||
use std::path::{Path, PathBuf};
|
Error,
|
||||||
|
config::{Config, SortOrder, expand_path},
|
||||||
|
desktop::spawn_fork,
|
||||||
|
gui::{self, ItemProvider, MenuItem},
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub(crate) struct FileItemProvider<T: Clone> {
|
pub(crate) struct FileItemProvider<T: Clone> {
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
use crate::config::Config;
|
|
||||||
use crate::gui;
|
|
||||||
use crate::gui::{ItemProvider, MenuItem};
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
config::Config,
|
||||||
|
gui::{self, ItemProvider, MenuItem},
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub(crate) struct MathProvider<T: Clone> {
|
pub(crate) struct MathProvider<T: Clone> {
|
||||||
menu_item_data: T,
|
menu_item_data: T,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
use std::{collections::HashMap, path::PathBuf};
|
||||||
|
|
||||||
use crate::desktop::{create_file_if_not_exists, load_cache_file};
|
use crate::desktop::{create_file_if_not_exists, load_cache_file};
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
pub mod auto;
|
pub mod auto;
|
||||||
pub mod dmenu;
|
pub mod dmenu;
|
||||||
|
|
|
@ -1,12 +1,18 @@
|
||||||
use crate::config::{Config, SortOrder};
|
use std::{
|
||||||
use crate::desktop::{is_executable, save_cache_file};
|
collections::{HashMap, HashSet},
|
||||||
use crate::gui::{ItemProvider, MenuItem};
|
env,
|
||||||
use crate::modes::load_cache;
|
ffi::CString,
|
||||||
use crate::{Error, gui};
|
fs,
|
||||||
use std::collections::{HashMap, HashSet};
|
path::PathBuf,
|
||||||
use std::ffi::CString;
|
};
|
||||||
use std::path::PathBuf;
|
|
||||||
use std::{env, fs};
|
use crate::{
|
||||||
|
Error,
|
||||||
|
config::{Config, SortOrder},
|
||||||
|
desktop::{is_executable, save_cache_file},
|
||||||
|
gui::{self, ItemProvider, MenuItem},
|
||||||
|
modes::load_cache,
|
||||||
|
};
|
||||||
|
|
||||||
impl ItemProvider<i32> for RunProvider {
|
impl ItemProvider<i32> for RunProvider {
|
||||||
fn get_elements(&mut self, _: Option<&str>) -> (bool, Vec<MenuItem<i32>>) {
|
fn get_elements(&mut self, _: Option<&str>) -> (bool, Vec<MenuItem<i32>>) {
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
use crate::config::{Config, SortOrder};
|
|
||||||
use crate::desktop::spawn_fork;
|
|
||||||
use crate::gui::{ItemProvider, MenuItem};
|
|
||||||
use crate::{Error, gui};
|
|
||||||
use regex::Regex;
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
|
use regex::Regex;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
Error,
|
||||||
|
config::{Config, SortOrder},
|
||||||
|
desktop::spawn_fork,
|
||||||
|
gui::{self, ItemProvider, MenuItem},
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub(crate) struct SshProvider<T: Clone> {
|
pub(crate) struct SshProvider<T: Clone> {
|
||||||
elements: Vec<MenuItem<T>>,
|
elements: Vec<MenuItem<T>>,
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use worf_lib::config::Mode;
|
|
||||||
use worf_lib::desktop::fork_if_configured;
|
use worf_lib::{Error, config, config::Mode, desktop::fork_if_configured, modes};
|
||||||
use worf_lib::{Error, config, modes};
|
|
||||||
|
|
||||||
fn main() -> anyhow::Result<()> {
|
fn main() -> anyhow::Result<()> {
|
||||||
env_logger::Builder::new()
|
env_logger::Builder::new()
|
||||||
|
|
Loading…
Add table
Reference in a new issue