chore: restart the repository with a clean history
CI / Docker image (push) Successful in 12s
CI / Server (push) Successful in 25s
CI / CLI (push) Successful in 13s
Development image / Development image (push) Successful in 21s
CI / CLI (windows) (push) Successful in 57s
CI / CLI (linux-arm64, static) (push) Successful in 1m37s
Release / Prepare release (push) Successful in 2s
Release / Server (linux-x64) (push) Successful in 53s
Release / CLI (linux-arm64, static) (push) Successful in 1m32s
Release / Docker image (push) Successful in 2m48s
Release / Server (windows-x64) (push) Successful in 6m20s
Release / CLI (windows-x64) (push) Successful in 6m48s
Release / CLI (linux-x64) (push) Successful in 7m8s
Release / Publish release (push) Successful in 1s
CI / Docker image (push) Successful in 12s
CI / Server (push) Successful in 25s
CI / CLI (push) Successful in 13s
Development image / Development image (push) Successful in 21s
CI / CLI (windows) (push) Successful in 57s
CI / CLI (linux-arm64, static) (push) Successful in 1m37s
Release / Prepare release (push) Successful in 2s
Release / Server (linux-x64) (push) Successful in 53s
Release / CLI (linux-arm64, static) (push) Successful in 1m32s
Release / Docker image (push) Successful in 2m48s
Release / Server (windows-x64) (push) Successful in 6m20s
Release / CLI (windows-x64) (push) Successful in 6m48s
Release / CLI (linux-x64) (push) Successful in 7m8s
Release / Publish release (push) Successful in 1s
Squash the tree into one commit, drop docs/architecture.html, reset the version line to 0.3.0, consolidate the changelog, enable Renovate automerge for non-major updates and add AGENTS.md.
This commit is contained in:
438 files changed
+45070
No files matched your search
@@ -0,0 +1,88 @@
|
||||
use anyhow::Result;
|
||||
use std::sync::mpsc::Sender;
|
||||
use tokio::runtime::Handle;
|
||||
use super::{Repaint, Wake};
|
||||
|
||||
const ICON_SIZE: u32 = 32;
|
||||
const ICON_RGBA: &[u8] = include_bytes!("../../assets/icon-32.rgba");
|
||||
|
||||
pub struct Tray { _keep: Box<dyn std::any::Any> }
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Notifier { wake: Sender<Wake>, repaint: Repaint }
|
||||
|
||||
impl Notifier {
|
||||
fn send(&self, wake: Wake) {
|
||||
let _ = self.wake.send(wake);
|
||||
self.repaint.ping();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn start(wake: Sender<Wake>, repaint: Repaint, runtime: &Handle) -> Result<Tray> {
|
||||
use ksni::{menu::{MenuItem, StandardItem}, Icon, ToolTip, TrayMethods};
|
||||
|
||||
struct FrislitTray { notify: Notifier }
|
||||
|
||||
impl ksni::Tray for FrislitTray {
|
||||
fn id(&self) -> String { "frislit".into() }
|
||||
fn title(&self) -> String { "frislit".into() }
|
||||
fn tool_tip(&self) -> ToolTip { ToolTip { title: "frislit".into(), ..Default::default() } }
|
||||
fn icon_pixmap(&self) -> Vec<Icon> {
|
||||
let mut data = Vec::with_capacity(ICON_RGBA.len());
|
||||
for pixel in ICON_RGBA.chunks(4) { data.extend_from_slice(&[pixel[3], pixel[0], pixel[1], pixel[2]]); }
|
||||
vec![Icon { width: ICON_SIZE as i32, height: ICON_SIZE as i32, data }]
|
||||
}
|
||||
fn activate(&mut self, _x: i32, _y: i32) { self.notify.send(Wake::Toggle); }
|
||||
fn menu(&self) -> Vec<MenuItem<Self>> {
|
||||
vec![
|
||||
StandardItem { label: "Open frislit".into(), activate: Box::new(|tray: &mut Self| tray.notify.send(Wake::Show)), ..Default::default() }.into(),
|
||||
MenuItem::Separator,
|
||||
StandardItem { label: "Quit".into(), activate: Box::new(|tray: &mut Self| tray.notify.send(Wake::Quit)), ..Default::default() }.into(),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
let tray = FrislitTray { notify: Notifier { wake, repaint } };
|
||||
let handle = runtime.block_on(tray.spawn()).map_err(|err| anyhow::anyhow!("No tray available: {err}"))?;
|
||||
Ok(Tray { _keep: Box::new(handle) })
|
||||
}
|
||||
|
||||
#[cfg(any(windows, target_os = "macos"))]
|
||||
pub fn start(wake: Sender<Wake>, repaint: Repaint, _runtime: &Handle) -> Result<Tray> {
|
||||
use tray_icon::{menu::{Menu, MenuEvent, MenuItem, PredefinedMenuItem}, Icon, MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent};
|
||||
|
||||
let notify = Notifier { wake, repaint };
|
||||
|
||||
let menu = Menu::new();
|
||||
let open = MenuItem::new("Open frislit", true, None);
|
||||
let quit = MenuItem::new("Quit", true, None);
|
||||
menu.append_items(&[&open, &PredefinedMenuItem::separator(), &quit])?;
|
||||
let (open_id, quit_id) = (open.id().clone(), quit.id().clone());
|
||||
|
||||
let icon = Icon::from_rgba(ICON_RGBA.to_vec(), ICON_SIZE, ICON_SIZE)?;
|
||||
let tray = TrayIconBuilder::new()
|
||||
.with_menu(Box::new(menu))
|
||||
.with_tooltip("frislit")
|
||||
.with_icon(icon)
|
||||
.with_icon_as_template(cfg!(target_os = "macos"))
|
||||
.with_menu_on_left_click(false)
|
||||
.build()?;
|
||||
|
||||
let clicks = notify.clone();
|
||||
TrayIconEvent::set_event_handler(Some(move |event: TrayIconEvent| {
|
||||
if let TrayIconEvent::Click { button: MouseButton::Left, button_state: MouseButtonState::Up, .. } = event {
|
||||
clicks.send(Wake::Toggle);
|
||||
}
|
||||
}));
|
||||
MenuEvent::set_event_handler(Some(move |event: MenuEvent| {
|
||||
if *event.id() == open_id { notify.send(Wake::Show); }
|
||||
else if *event.id() == quit_id { notify.send(Wake::Quit); }
|
||||
}));
|
||||
Ok(Tray { _keep: Box::new(tray) })
|
||||
}
|
||||
|
||||
#[cfg(not(any(windows, target_os = "macos", target_os = "linux")))]
|
||||
pub fn start(_wake: Sender<Wake>, _repaint: Repaint, _runtime: &Handle) -> Result<Tray> {
|
||||
anyhow::bail!("No tray on this platform")
|
||||
}
|
||||
Reference in new issue
Block a user