Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/tsukinaha/tsukimi into feat…
Browse files Browse the repository at this point in the history
…ure/win
  • Loading branch information
Kosette committed Apr 5, 2024
2 parents 82ae545 + c68b0c8 commit ce6cbeb
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 19 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@ For Linux ~~Only~~.
## Build
请见 [Dockerfile](https://github.com/tsukinaha/tsukimi/blob/main/Dockerfile)

## MPV Config
- Linux: 读取默认配置 (`$XDG_CONFIG_HOME/mpv`)
- Windows:
首先读取以下路径中的配置
```
|__bin\
|__share\
|__lib\
|__mpv\
| |__mpv.conf
| |__input.conf
| |__scripts\
| | |__ .......
| |__ .......
|__config\
```
如果没有配置,则读取环境变量`$MPV_HOME`,都没有则保持libmpv默认行为

**具体配置请见:[MPV-manual#files](https://mpv.io/manual/master/#files)**

## Credits
- [gtk4-rs](https://github.com/gtk-rs/gtk4-rs)
- [MPV](https://github.com/mpv-player/mpv)
Expand Down
4 changes: 4 additions & 0 deletions resources/resources.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@
<file compressed="true" preprocess="xml-stripblanks">home.ui</file>
<file compressed="true" preprocess="xml-stripblanks">list.ui</file>
</gresource>
<gresource prefix="/moe/tsukimi/icons">
<file alias="tsukimi">icons/tsukimi.png</file>
</gresource>

</gresources>
Binary file added resources/ui/icons/tsukimi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/ui/icons/tsukimi.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion resources/ui/item.ui
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
<property name="transition-duration">700</property>
<property name="reveal-child">False</property>
<child>
<object class="GtkScrolledWindow">
<object class="GtkScrolledWindow" id="episodescrolled">
<property name="overlay-scrolling">true</property>
<property name="vscrollbar-policy">never</property>
<property name="valign">fill</property>
Expand Down
5 changes: 3 additions & 2 deletions resources/ui/window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
</item>
</menu>
<template class="AppWindow" parent="AdwApplicationWindow">
<property name="title" translatable="yes">Login</property>
<property name="title" translatable="yes">Tsukimi</property>
<property name="width-request">1280</property>
<property name="height-request">920</property>
<property name="icon-name">tsukimi</property>
<child>
<object class="AdwBreakpoint">
<condition>max-width: 500sp</condition>
Expand Down Expand Up @@ -258,7 +259,7 @@
<property name="content">
<object class="GtkStack" id="insidestack">
<property name="hexpand">True</property>
<property name="transition-type">slide-up-down</property>
<property name="transition-type">crossfade</property>
<child>
<object class="GtkStackPage">
<property name="name">homepage</property>
Expand Down
2 changes: 2 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use std::{env, fs::File, io::Read};
use toml;
use uuid::Uuid;

pub const VERSION: &str = "0.3.0";

#[derive(Serialize, Debug, Deserialize, Default)]
pub struct Config {
pub domain: String,
Expand Down
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ fn main() -> glib::ExitCode {
// Load the CSS from the resource file
app.connect_startup(|_| ui::load_css());
// Connect to "activate" signal of `app`
app.connect_activate(ui::build_ui);
app.connect_activate(|app| ui::build_ui(app));

app.set_accels_for_action("win.about", &["<Ctrl>N"]);

// Run the application
app.run()
Expand Down
16 changes: 16 additions & 0 deletions src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@ use gtk::{prelude::*, CssProvider};
pub fn build_ui(app: &adw::Application) {
// Create new window and present it
let window = widgets::window::Window::new(app);
let about_action = gtk::gio::ActionEntry::builder("about")
.activate(|_, _, _| {
let about = adw::AboutWindow::builder()
.application_name("Tsukimi")
.version(crate::config::VERSION)
.comments("A simple third-party Emby client.\nTest version: tsukimi 0.3.0 \n2024.4.5 16:02")
.website("https://github.com/tsukinaha/tsukimi")
.application_icon("tsukimi")
.license_type(gtk::License::Gpl30)
.build();
about.add_acknowledgement_section(Some("Code"),&["Inaha","Kosette"]);
about.add_acknowledgement_section(Some("Special Thanks"), &["Qound","Eikano"]);
about.present();
})
.build();
window.add_action_entries([about_action]);
window.present();
}

Expand Down
2 changes: 2 additions & 0 deletions src/ui/mpv/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ pub fn play(url: String, suburl: Option<String>, name: Option<String>, back: Bac
let mpv = Mpv::with_initializer(|init| {
init.set_property("osc", true)?;
init.set_property("config", true)?;
#[cfg(not(target_os = "windows"))]
init.set_property("input-vo-keyboard", true)?;
init.set_property("input-default-bindings", true)?;
init.set_property("force-window", "immediate")?;
if let Some(name) = name {
Expand Down
17 changes: 17 additions & 0 deletions src/ui/widgets/fix.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use ::gtk::prelude::*;

pub fn fix(scrolledwindow: gtk::ScrolledWindow) -> gtk::ScrolledWindow {
let controller = scrolledwindow.observe_controllers();
let count = controller.n_items();
for i in 0..count {
let item = controller.item(i).unwrap();
if item.is::<gtk::EventControllerScroll>() {
let controller = item.downcast::<gtk::EventControllerScroll>().unwrap();
controller.set_flags(
gtk::EventControllerScrollFlags::HORIZONTAL
| gtk::EventControllerScrollFlags::KINETIC,
);
}
}
scrolledwindow
}
5 changes: 4 additions & 1 deletion src/ui/widgets/home.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use glib::Object;
use gtk::gdk::Event;
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use gtk::{gio, glib};

use crate::ui::network::Latest;

use self::imp::Page;
use super::fix::fix;
use super::item::ItemPage;
use super::list::ListPage;
use super::movie::MoviePage;
Expand Down Expand Up @@ -127,7 +129,7 @@ impl HomePage {

pub fn set_libraryscorll(&self, views: &Vec<crate::ui::network::View>) {
let imp = self.imp();
let libscrolled = imp.libscrolled.get();
let libscrolled = fix(imp.libscrolled.get());
imp.librevealer.set_reveal_child(true);
let store = gtk::gio::ListStore::new::<glib::BoxedAnyObject>();
for view in views {
Expand Down Expand Up @@ -234,6 +236,7 @@ impl HomePage {
.vscrollbar_policy(gtk::PolicyType::Never)
.overlay_scrolling(true)
.build();
let scrolledwindow = fix(scrolledwindow);
let scrollbox = gtk::Box::new(gtk::Orientation::Vertical, 15);
let revealer = gtk::Revealer::builder()
.transition_type(gtk::RevealerTransitionType::SlideUp)
Expand Down
13 changes: 10 additions & 3 deletions src/ui/widgets/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ use gtk::{gio, glib};

use crate::ui::network::SeriesInfo;

use super::fix::fix;

mod imp {
use crate::ui::network;
use crate::ui::widgets::fix::fix;
use crate::APP_ID;
use adw::subclass::prelude::*;
use glib::subclass::InitializingObject;
Expand Down Expand Up @@ -57,6 +60,8 @@ mod imp {
#[template_child]
pub actorscrolled: TemplateChild<gtk::ScrolledWindow>,
#[template_child]
pub episodescrolled: TemplateChild<gtk::ScrolledWindow>,
#[template_child]
pub actorlist: TemplateChild<gtk::ListView>,
pub selection: gtk::SingleSelection,
pub seasonselection: gtk::SingleSelection,
Expand Down Expand Up @@ -98,6 +103,7 @@ mod imp {
fn constructed(&self) {
self.parent_constructed();
let obj = self.obj();
fix(self.episodescrolled.get());
let itemrevealer = self.itemrevealer.get();
let id = obj.id();
let idc = id.clone();
Expand Down Expand Up @@ -467,9 +473,10 @@ impl ItemPage {
.hscrollbar_policy(gtk::PolicyType::Automatic)
.vscrollbar_policy(gtk::PolicyType::Never)
.overlay_scrolling(true)
.sensitive(false)
.build();

let mediascrolled = fix(mediascrolled);

let mediabox = gtk::Box::new(gtk::Orientation::Horizontal, 5);
for mediapart in mediasource.MediaStreams {
if mediapart.Type == "Attachment" {
Expand Down Expand Up @@ -565,7 +572,7 @@ impl ItemPage {

pub fn setlinksscrolled(&self, links: Vec<crate::ui::network::Urls>) {
let imp = self.imp();
let linksscrolled = imp.linksscrolled.get();
let linksscrolled = fix(imp.linksscrolled.get());
let linksrevealer = imp.linksrevealer.get();
if !links.is_empty() {
linksrevealer.set_reveal_child(true);
Expand Down Expand Up @@ -598,7 +605,7 @@ impl ItemPage {

pub fn setactorscrolled(&self, actors: Vec<crate::ui::network::People>) {
let imp = self.imp();
let actorscrolled = imp.actorscrolled.get();
let actorscrolled = fix(imp.actorscrolled.get());
let actorrevealer = imp.actorrevealer.get();
if !actors.is_empty() {
actorrevealer.set_reveal_child(true);
Expand Down
1 change: 1 addition & 0 deletions src/ui/widgets/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod episoderow;
pub mod fix;
pub mod history;
pub mod home;
pub mod item;
Expand Down
9 changes: 6 additions & 3 deletions src/ui/widgets/movie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use adw::subclass::prelude::*;
use glib::Object;
use gtk::prelude::*;
use gtk::{gio, glib};

use super::fix::fix;
mod imp {
use crate::ui::network::{self, runtime, SearchResult};
use crate::APP_ID;
Expand Down Expand Up @@ -248,9 +250,10 @@ impl MoviePage {
.hscrollbar_policy(gtk::PolicyType::Automatic)
.vscrollbar_policy(gtk::PolicyType::Never)
.overlay_scrolling(true)
.sensitive(false)
.build();

let mediascrolled = fix(mediascrolled);

let mediabox = gtk::Box::new(gtk::Orientation::Horizontal, 5);
for mediapart in mediasource.MediaStreams {
if mediapart.Type == "Attachment" {
Expand Down Expand Up @@ -346,7 +349,7 @@ impl MoviePage {

pub fn setlinksscrolled(&self, links: Vec<crate::ui::network::Urls>) {
let imp = self.imp();
let linksscrolled = imp.linksscrolled.get();
let linksscrolled = fix(imp.linksscrolled.get());
let linksrevealer = imp.linksrevealer.get();
if !links.is_empty() {
linksrevealer.set_reveal_child(true);
Expand Down Expand Up @@ -379,7 +382,7 @@ impl MoviePage {

pub fn setactorscrolled(&self, actors: Vec<crate::ui::network::People>) {
let imp = self.imp();
let actorscrolled = imp.actorscrolled.get();
let actorscrolled = fix(imp.actorscrolled.get());
let actorrevealer = imp.actorrevealer.get();
if !actors.is_empty() {
actorrevealer.set_reveal_child(true);
Expand Down
8 changes: 0 additions & 8 deletions src/ui/widgets/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ mod imp {
klass.install_action("win.relogin", None, move |window, _action, _parameter| {
window.placeholder();
});
klass.install_action("win.about", None, move |window, _action, _parameter| {
window.about();
});
klass.install_action("win.sidebar", None, move |window, _action, _parameter| {
window.sidebar();
});
Expand Down Expand Up @@ -225,11 +222,6 @@ impl Window {
imp.stack.set_visible_child_name("placeholder");
}

fn about(&self) {
let imp = self.imp();
imp.stack.set_visible_child_name("placeholder");
}

fn homepage(&self) {
let imp = self.imp();
imp.homepage
Expand Down

0 comments on commit ce6cbeb

Please sign in to comment.