adding base for drag n drop
This commit is contained in:
parent
f79e61f2ed
commit
1ce365fc04
8 changed files with 139 additions and 49 deletions
|
@ -1,6 +1,7 @@
|
|||
use super::kinds::ServiceItemKind;
|
||||
use super::{kinds::ServiceItemKind, service_items::ServiceItem};
|
||||
|
||||
pub trait Content {
|
||||
fn title(&self) -> String;
|
||||
fn kind(&self) -> ServiceItemKind;
|
||||
fn to_service_item(&self) -> ServiceItem;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,10 @@ impl Content for Image {
|
|||
fn kind(&self) -> ServiceItemKind {
|
||||
ServiceItemKind::Image(self.clone())
|
||||
}
|
||||
|
||||
fn to_service_item(&self) -> super::service_items::ServiceItem {
|
||||
self.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Value> for Image {
|
||||
|
|
|
@ -44,6 +44,10 @@ impl Content for Presentation {
|
|||
fn kind(&self) -> ServiceItemKind {
|
||||
ServiceItemKind::Presentation(self.clone())
|
||||
}
|
||||
|
||||
fn to_service_item(&self) -> super::service_items::ServiceItem {
|
||||
self.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Value> for Presentation {
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
use std::borrow::Cow;
|
||||
use std::ops::Deref;
|
||||
|
||||
use cosmic::iced::clipboard::mime::{AllowedMimeTypes, AsMimeTypes};
|
||||
use crisp::types::{Keyword, Symbol, Value};
|
||||
use miette::Result;
|
||||
use miette::{miette, Result};
|
||||
use tracing::{debug, error};
|
||||
|
||||
use crate::Slide;
|
||||
|
@ -22,6 +24,48 @@ pub struct ServiceItem {
|
|||
// pub item: Box<dyn ServiceTrait>,
|
||||
}
|
||||
|
||||
impl TryFrom<(Vec<u8>, String)> for ServiceItem {
|
||||
type Error = miette::Error;
|
||||
|
||||
fn try_from(
|
||||
value: (Vec<u8>, String),
|
||||
) -> std::result::Result<Self, Self::Error> {
|
||||
let sto = value.0.to_owned();
|
||||
let song = Song {
|
||||
title: "Death Was Arrested".to_string(),
|
||||
..Default::default()
|
||||
};
|
||||
debug!(?value);
|
||||
Ok(Self::from(&song))
|
||||
}
|
||||
}
|
||||
|
||||
impl AllowedMimeTypes for ServiceItem {
|
||||
fn allowed() -> Cow<'static, [String]> {
|
||||
Cow::from(vec!["application/service-item".to_string()])
|
||||
}
|
||||
}
|
||||
|
||||
impl AsMimeTypes for ServiceItem {
|
||||
fn available(&self) -> std::borrow::Cow<'static, [String]> {
|
||||
debug!(?self);
|
||||
Cow::from(vec!["application/service-item".to_string()])
|
||||
}
|
||||
|
||||
fn as_bytes(
|
||||
&self,
|
||||
mime_type: &str,
|
||||
) -> Option<std::borrow::Cow<'static, [u8]>> {
|
||||
todo!();
|
||||
debug!(?self);
|
||||
debug!(mime_type);
|
||||
Some(Cow::from(
|
||||
r#"(slide :background (image :source "~/pics/frodo.jpg" :fit fill)
|
||||
(text "This is frodo" :font-size 70))"#.to_string().into_bytes()
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl ServiceItem {
|
||||
pub fn title(&self) -> String {
|
||||
self.title.clone()
|
||||
|
|
|
@ -44,6 +44,10 @@ impl Content for Song {
|
|||
fn kind(&self) -> ServiceItemKind {
|
||||
ServiceItemKind::Song(self.clone())
|
||||
}
|
||||
|
||||
fn to_service_item(&self) -> super::service_items::ServiceItem {
|
||||
self.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl ServiceTrait for Song {
|
||||
|
|
|
@ -35,6 +35,10 @@ impl Content for Video {
|
|||
fn kind(&self) -> ServiceItemKind {
|
||||
ServiceItemKind::Video(self.clone())
|
||||
}
|
||||
|
||||
fn to_service_item(&self) -> super::service_items::ServiceItem {
|
||||
self.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Value> for Video {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue