json parsing works, and invidious extra works, yay??
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
parent
f8bc34a93d
commit
aaabc484ad
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "gtk-hello"
|
name = "gtubek"
|
||||||
version = "0.1.0"
|
version = "0.0.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
@ -10,3 +10,7 @@ gtk = { version = "0.4.8", package = "gtk4" }
|
|||||||
adw = { version = "0.1.1", package = "libadwaita" }
|
adw = { version = "0.1.1", package = "libadwaita" }
|
||||||
invidious = "0.3.2"
|
invidious = "0.3.2"
|
||||||
gtk-ui-builder = "0.2.0"
|
gtk-ui-builder = "0.2.0"
|
||||||
|
serde_json = "1.0"
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
strip = true
|
@ -1,10 +1,13 @@
|
|||||||
use invidious::reqwest::blocking::Client;
|
use invidious::reqwest::blocking::Client;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
//use serde::{Deserialize, Serialize};
|
||||||
|
//use serde_json::Result;
|
||||||
|
|
||||||
pub fn inv() -> Result<(), Box<dyn Error>> {
|
pub fn inv() -> Result<(), Box<dyn Error>> {
|
||||||
let client = Client::new(String::from("https://vid.puffyan.us"));
|
let client = Client::new(String::from("https://invidious.projectsegfau.lt"));
|
||||||
let search_results = client.search(Some("q=rust programming"))?.items;
|
let search_results = client.search(Some("q=rust programming"))?.items;
|
||||||
let video = client.video("5C_HPTJg5ek", None)?;
|
let video = client.video("5C_HPTJg5ek", None)?;
|
||||||
print!("{:?}", video);
|
println!("{:?}", video.title);
|
||||||
|
println!("{:?}", video.views);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
36
src/main.rs
36
src/main.rs
@ -5,7 +5,7 @@ use gtk::gio;
|
|||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use gtk::{self, ApplicationWindow, Button, prelude::*};
|
use gtk::{self, ApplicationWindow, Button, prelude::*, ListBox, FlowBox, PolicyType, ScrolledWindow, Box, Orientation, Align::*};
|
||||||
use crate::inv::inv;
|
use crate::inv::inv;
|
||||||
mod inv;
|
mod inv;
|
||||||
|
|
||||||
@ -22,7 +22,6 @@ fn main() {
|
|||||||
let output = inv::inv();
|
let output = inv::inv();
|
||||||
|
|
||||||
print!("{:?}", output);
|
print!("{:?}", output);
|
||||||
inv();
|
|
||||||
// Run the application
|
// Run the application
|
||||||
app.run();
|
app.run();
|
||||||
}
|
}
|
||||||
@ -31,24 +30,53 @@ fn build_ui(app: &Application) {
|
|||||||
// Create a button
|
// Create a button
|
||||||
let button = Button::builder()
|
let button = Button::builder()
|
||||||
.label("Press me!")
|
.label("Press me!")
|
||||||
|
.icon_name("fingerprint-authentication-symbolic")
|
||||||
|
.valign(Fill)
|
||||||
|
.vexpand(true)
|
||||||
.margin_top(12)
|
.margin_top(12)
|
||||||
.margin_bottom(12)
|
.margin_bottom(12)
|
||||||
.margin_start(12)
|
.margin_start(12)
|
||||||
.margin_end(12)
|
.margin_end(12)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
//button.connect_clicked(move |_| trig_play());
|
||||||
|
|
||||||
let video = Video::for_file(Some(&gio::File::for_path("/home/midou/Vidéos/miui.mp4")));
|
let video = Video::for_file(Some(&gio::File::for_path("/home/midou/Vidéos/miui.mp4")));
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Set a listBox
|
||||||
|
let listbox = ListBox::builder()
|
||||||
|
.child(&video)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Set a box
|
||||||
|
let boxy = Box::new(Orientation::Vertical, 0);
|
||||||
|
boxy.append(&video);
|
||||||
|
boxy.append(&button);
|
||||||
|
|
||||||
|
// Then make the window scrollable
|
||||||
|
let scrolled_window = ScrolledWindow::builder()
|
||||||
|
// .hscrollbar_policy(PolicyType::Never) // Disable horizontal scrolling
|
||||||
|
// .hscrollbar_policy()
|
||||||
|
.min_content_width(360)
|
||||||
|
.child(&boxy)
|
||||||
|
.build();
|
||||||
|
|
||||||
// Create a window
|
// Create a window
|
||||||
let window = ApplicationWindow::builder()
|
let window = ApplicationWindow::builder()
|
||||||
.application(app)
|
.application(app)
|
||||||
|
.default_width(1280)
|
||||||
|
.default_height(720)
|
||||||
.title("My GTK App")
|
.title("My GTK App")
|
||||||
.child(&button)
|
.child(&scrolled_window)
|
||||||
.child(&video)
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Present window
|
// Present window
|
||||||
window.present();
|
window.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//fn trig_play() {
|
||||||
|
// let trigger =
|
||||||
|
//}
|
Loading…
Reference in New Issue
Block a user