Compare commits
6 Commits
6c35eb8f55
...
5478d388cb
Author | SHA1 | Date |
---|---|---|
Savanni D'Gerinel | 5478d388cb | |
Savanni D'Gerinel | e203b17c8b | |
Savanni D'Gerinel | 69583dfd64 | |
Savanni D'Gerinel | d59c2585db | |
Savanni D'Gerinel | a6fcbfac71 | |
Savanni D'Gerinel | 4f940099da |
|
@ -367,7 +367,7 @@ dependencies = [
|
|||
"geo-types",
|
||||
"gio",
|
||||
"glib",
|
||||
"glib-build-tools",
|
||||
"glib-build-tools 0.16.3",
|
||||
"gtk4",
|
||||
"ifc",
|
||||
"lazy_static",
|
||||
|
@ -869,6 +869,12 @@ version = "0.16.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "251935cb159350458a627642b0852a7fb8e027e3c5916dc2cebcd70f025de3fc"
|
||||
|
||||
[[package]]
|
||||
name = "glib-build-tools"
|
||||
version = "0.17.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a65d79efe318ef2cbbbb37032b125866fd82c34ea44c816132621bbc552e716"
|
||||
|
||||
[[package]]
|
||||
name = "glib-macros"
|
||||
version = "0.17.10"
|
||||
|
@ -894,6 +900,24 @@ dependencies = [
|
|||
"system-deps",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gm-control-panel"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"config",
|
||||
"config-derive",
|
||||
"futures",
|
||||
"gdk4",
|
||||
"gio",
|
||||
"glib",
|
||||
"glib-build-tools",
|
||||
"gtk4",
|
||||
"libadwaita",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gobject-sys"
|
||||
version = "0.17.10"
|
||||
|
@ -1085,7 +1109,7 @@ dependencies = [
|
|||
"coordinates",
|
||||
"gio",
|
||||
"glib",
|
||||
"glib-build-tools",
|
||||
"glib-build-tools 0.16.3",
|
||||
"gtk4",
|
||||
"image",
|
||||
]
|
||||
|
@ -1313,6 +1337,21 @@ dependencies = [
|
|||
"typeshare",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kifu-gtk"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cairo-rs",
|
||||
"gio",
|
||||
"glib",
|
||||
"glib-build-tools 0.17.10",
|
||||
"gtk4",
|
||||
"image",
|
||||
"kifu-core",
|
||||
"screenplay",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
|
@ -1736,9 +1775,9 @@ checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
|
|||
|
||||
[[package]]
|
||||
name = "png"
|
||||
version = "0.17.9"
|
||||
version = "0.17.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "59871cc5b6cce7eaccca5a802b4173377a1c2ba90654246789a8fa2334426d11"
|
||||
checksum = "dd75bf2d8dd3702b9707cdbc56a5b9ef42cec752eb8b3bafc01234558442aa64"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"crc32fast",
|
||||
|
@ -2262,9 +2301,9 @@ checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a"
|
|||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.7.1"
|
||||
version = "3.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc02fddf48964c42031a0b3fe0428320ecf3a73c401040fc0096f97794310651"
|
||||
checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"fastrand",
|
||||
|
@ -2743,9 +2782,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.48.3"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "27f51fb4c64f8b770a823c043c7fad036323e1c48f55287b7bbb7987b2fcdf3b"
|
||||
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
|
@ -2758,45 +2797,45 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.48.3"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fde1bb55ae4ce76a597a8566d82c57432bc69c039449d61572a7a353da28f68c"
|
||||
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.48.3"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1513e8d48365a78adad7322fd6b5e4c4e99d92a69db8df2d435b25b1f1f286d4"
|
||||
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.48.3"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60587c0265d2b842298f5858e1a5d79d146f9ee0c37be5782e92a6eb5e1d7a83"
|
||||
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.48.3"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "224fe0e0ffff5d2ea6a29f82026c8f43870038a0ffc247aa95a52b47df381ac4"
|
||||
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.48.3"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62fc52a0f50a088de499712cbc012df7ebd94e2d6eb948435449d76a6287e7ad"
|
||||
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.48.3"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2093925509d91ea3d69bcd20238f4c2ecdb1a29d3c281d026a09705d0dd35f3d"
|
||||
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.48.3"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6ade45bc8bf02ae2aa34a9d54ba660a1a58204da34ba793c00d83ca3730b5f1"
|
||||
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
||||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
|
|
|
@ -9,10 +9,12 @@ members = [
|
|||
"emseries",
|
||||
"flow",
|
||||
"fluent-ergonomics",
|
||||
"kifu/core",
|
||||
"geo-types",
|
||||
"gm-control-panel",
|
||||
"hex-grid",
|
||||
"ifc",
|
||||
"kifu/core",
|
||||
"kifu/gtk",
|
||||
"memorycache",
|
||||
"screenplay",
|
||||
"sgf",
|
||||
|
|
4
build.sh
4
build.sh
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
set -x
|
||||
|
||||
RUST_ALL_TARGETS=(
|
||||
"changeset"
|
||||
|
@ -14,8 +13,11 @@ RUST_ALL_TARGETS=(
|
|||
"flow"
|
||||
"fluent-ergonomics"
|
||||
"geo-types"
|
||||
"gm-control-panel"
|
||||
"hex-grid"
|
||||
"ifc"
|
||||
"kifu-core"
|
||||
"kifu-gtk"
|
||||
"memorycache"
|
||||
"screenplay"
|
||||
"sgf"
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
[package]
|
||||
name = "gm-control-panel"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
adw = { version = "0.4", package = "libadwaita", features = [ "v1_2", "gtk_v4_6" ] }
|
||||
config = { path = "../config" }
|
||||
config-derive = { path = "../config-derive" }
|
||||
futures = { version = "0.3" }
|
||||
gio = { version = "0.17" }
|
||||
glib = { version = "0.17" }
|
||||
gdk = { version = "0.6", package = "gdk4" }
|
||||
gtk = { version = "0.6", package = "gtk4", features = [ "v4_6" ] }
|
||||
serde = { version = "1" }
|
||||
serde_json = { version = "*" }
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
|
||||
[build-dependencies]
|
||||
glib-build-tools = "0.16"
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fn main() {
|
||||
glib_build_tools::compile_resources(
|
||||
"resources",
|
||||
"resources/gresources.xml",
|
||||
"com.luminescent-dreams.gm-control-panel.gresource",
|
||||
);
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="/com/luminescent-dreams/gm-control-panel/">
|
||||
<file>style.css</file>
|
||||
</gresource>
|
||||
</gresources>
|
|
@ -0,0 +1,6 @@
|
|||
.playlist-card {
|
||||
margin: 8px;
|
||||
padding: 8px;
|
||||
min-width: 100px;
|
||||
min-height: 100px;
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
use crate::PlaylistCard;
|
||||
use adw::prelude::AdwApplicationWindowExt;
|
||||
use gio::resources_lookup_data;
|
||||
use gtk::{prelude::*, STYLE_PROVIDER_PRIORITY_USER};
|
||||
use std::iter::Iterator;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ApplicationWindow {
|
||||
pub window: adw::ApplicationWindow,
|
||||
pub layout: gtk::FlowBox,
|
||||
pub playlists: Vec<PlaylistCard>,
|
||||
}
|
||||
|
||||
impl ApplicationWindow {
|
||||
pub fn new(app: &adw::Application) -> Self {
|
||||
let window = adw::ApplicationWindow::builder()
|
||||
.application(app)
|
||||
.title("GM-control-panel")
|
||||
.width_request(500)
|
||||
.build();
|
||||
|
||||
let stylesheet = String::from_utf8(
|
||||
resources_lookup_data(
|
||||
"/com/luminescent-dreams/gm-control-panel/style.css",
|
||||
gio::ResourceLookupFlags::NONE,
|
||||
)
|
||||
.expect("stylesheet should just be available")
|
||||
.to_vec(),
|
||||
)
|
||||
.expect("to parse stylesheet");
|
||||
|
||||
let provider = gtk::CssProvider::new();
|
||||
provider.load_from_data(&stylesheet);
|
||||
let context = window.style_context();
|
||||
context.add_provider(&provider, STYLE_PROVIDER_PRIORITY_USER);
|
||||
|
||||
let layout = gtk::FlowBox::new();
|
||||
|
||||
let playlists: Vec<PlaylistCard> = vec![
|
||||
"Creepy Cathedral",
|
||||
"Joyful Tavern",
|
||||
"Exploring",
|
||||
"Out on the streets",
|
||||
"The North Abbey",
|
||||
]
|
||||
.into_iter()
|
||||
.map(|name| {
|
||||
let playlist = PlaylistCard::new();
|
||||
playlist.set_name(name);
|
||||
playlist
|
||||
})
|
||||
.collect();
|
||||
|
||||
playlists.iter().for_each(|card| layout.append(card));
|
||||
|
||||
window.set_content(Some(&layout));
|
||||
|
||||
Self {
|
||||
window,
|
||||
layout,
|
||||
playlists,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
use config::define_config;
|
||||
use config_derive::ConfigOption;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::path::PathBuf;
|
||||
|
||||
define_config! {
|
||||
Language(Language),
|
||||
MusicPath(MusicPath),
|
||||
PlaylistDatabasePath(PlaylistDatabasePath),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ConfigOption)]
|
||||
pub struct Language(String);
|
||||
|
||||
impl std::ops::Deref for Language {
|
||||
type Target = String;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ConfigOption)]
|
||||
pub struct MusicPath(PathBuf);
|
||||
|
||||
impl std::ops::Deref for MusicPath {
|
||||
type Target = PathBuf;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ConfigOption)]
|
||||
pub struct PlaylistDatabasePath(PathBuf);
|
||||
|
||||
impl std::ops::Deref for PlaylistDatabasePath {
|
||||
type Target = PathBuf;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
use glib::{Continue, Sender};
|
||||
use gtk::prelude::*;
|
||||
use std::{
|
||||
env,
|
||||
sync::{Arc, RwLock},
|
||||
};
|
||||
|
||||
mod app_window;
|
||||
use app_window::ApplicationWindow;
|
||||
|
||||
mod config;
|
||||
|
||||
mod playlist_card;
|
||||
use playlist_card::PlaylistCard;
|
||||
|
||||
mod types;
|
||||
use types::PlaybackState;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Message {}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Core {
|
||||
tx: Arc<RwLock<Option<Sender<Message>>>>,
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
gio::resources_register_include!("com.luminescent-dreams.gm-control-panel.gresource")
|
||||
.expect("Failed to register resource");
|
||||
|
||||
let app = adw::Application::builder()
|
||||
.application_id("com.luminescent-dreams.gm-control-panel")
|
||||
.build();
|
||||
|
||||
let runtime = tokio::runtime::Builder::new_multi_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
let core = Core {
|
||||
tx: Arc::new(RwLock::new(None)),
|
||||
};
|
||||
|
||||
app.connect_activate(move |app| {
|
||||
let (gtk_tx, gtk_rx) =
|
||||
gtk::glib::MainContext::channel::<Message>(gtk::glib::PRIORITY_DEFAULT);
|
||||
|
||||
*core.tx.write().unwrap() = Some(gtk_tx);
|
||||
|
||||
let window = ApplicationWindow::new(app);
|
||||
window.window.present();
|
||||
|
||||
gtk_rx.attach(None, move |_msg| Continue(true));
|
||||
});
|
||||
|
||||
let args: Vec<String> = env::args().collect();
|
||||
ApplicationExtManual::run_with_args(&app, &args);
|
||||
runtime.shutdown_background();
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
use crate::PlaybackState;
|
||||
use glib::Object;
|
||||
use gtk::{prelude::*, subclass::prelude::*};
|
||||
|
||||
pub struct PlaylistCardPrivate {
|
||||
name: gtk::Label,
|
||||
playing: gtk::Label,
|
||||
}
|
||||
|
||||
impl Default for PlaylistCardPrivate {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
name: gtk::Label::new(None),
|
||||
playing: gtk::Label::new(Some("Stopped")),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for PlaylistCardPrivate {
|
||||
const NAME: &'static str = "PlaylistCard";
|
||||
type Type = PlaylistCard;
|
||||
type ParentType = gtk::Box;
|
||||
}
|
||||
|
||||
impl ObjectImpl for PlaylistCardPrivate {}
|
||||
impl WidgetImpl for PlaylistCardPrivate {}
|
||||
impl BoxImpl for PlaylistCardPrivate {}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct PlaylistCard(ObjectSubclass<PlaylistCardPrivate>) @extends gtk::Box, gtk::Widget, @implements gtk::Orientable;
|
||||
}
|
||||
|
||||
impl PlaylistCard {
|
||||
pub fn new() -> Self {
|
||||
let s: Self = Object::builder().build();
|
||||
s.set_orientation(gtk::Orientation::Vertical);
|
||||
s.add_css_class("playlist-card");
|
||||
s.add_css_class("card");
|
||||
|
||||
s.append(&s.imp().name);
|
||||
s.append(&s.imp().playing);
|
||||
|
||||
s
|
||||
}
|
||||
|
||||
pub fn set_name(&self, s: &str) {
|
||||
self.imp().name.set_text(s);
|
||||
}
|
||||
|
||||
pub fn set_playback(&self, s: PlaybackState) {
|
||||
self.imp().playing.set_text(&format!("{}", s))
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum PlaybackState {
|
||||
Stopped,
|
||||
Playing,
|
||||
}
|
||||
|
||||
impl fmt::Display for PlaybackState {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
Self::Stopped => write!(f, "Stopped"),
|
||||
Self::Playing => write!(f, "Playing"),
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,12 +21,12 @@ screenplay = { path = "../../screenplay" }
|
|||
[build-dependencies]
|
||||
glib-build-tools = "0.17"
|
||||
|
||||
[[bin]]
|
||||
name = "kifu-gtk"
|
||||
path = "src/main.rs"
|
||||
# [[bin]]
|
||||
# name = "kifu-gtk"
|
||||
# path = "src/main.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "screenplay"
|
||||
path = "src/bin/screenplay.rs"
|
||||
required-features = [ "screenplay" ]
|
||||
# [[bin]]
|
||||
# name = "screenplay"
|
||||
# path = "src/bin/screenplay.rs"
|
||||
# required-features = [ "screenplay" ]
|
||||
|
||||
|
|
Loading…
Reference in New Issue