json parsing works, and invidious extra works, yay??
ci/woodpecker/push/woodpecker Pipeline failed Details

This commit is contained in:
Midou36O 2022-09-10 16:32:54 +01:00
parent f8bc34a93d
commit aaabc484ad
Signed by: midou
GPG Key ID: 08063D5407090BC2
3 changed files with 45 additions and 10 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "gtk-hello"
version = "0.1.0"
name = "gtubek"
version = "0.0.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -9,4 +9,8 @@ edition = "2021"
gtk = { version = "0.4.8", package = "gtk4" }
adw = { version = "0.1.1", package = "libadwaita" }
invidious = "0.3.2"
gtk-ui-builder = "0.2.0"
gtk-ui-builder = "0.2.0"
serde_json = "1.0"
[profile.release]
strip = true

View File

@ -1,10 +1,13 @@
use invidious::reqwest::blocking::Client;
use std::error::Error;
//use serde::{Deserialize, Serialize};
//use serde_json::Result;
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 video = client.video("5C_HPTJg5ek", None)?;
print!("{:?}", video);
Ok(())
println!("{:?}", video.title);
println!("{:?}", video.views);
Ok(())
}

View File

@ -5,7 +5,7 @@ use gtk::gio;
use std::fs::File;
use std::path::Path;
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;
mod inv;
@ -22,7 +22,6 @@ fn main() {
let output = inv::inv();
print!("{:?}", output);
inv();
// Run the application
app.run();
}
@ -31,24 +30,53 @@ fn build_ui(app: &Application) {
// Create a button
let button = Button::builder()
.label("Press me!")
.icon_name("fingerprint-authentication-symbolic")
.valign(Fill)
.vexpand(true)
.margin_top(12)
.margin_bottom(12)
.margin_start(12)
.margin_end(12)
.build();
//button.connect_clicked(move |_| trig_play());
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
let window = ApplicationWindow::builder()
.application(app)
.default_width(1280)
.default_height(720)
.title("My GTK App")
.child(&button)
.child(&video)
.child(&scrolled_window)
.build();
// Present window
window.present();
}
//fn trig_play() {
// let trigger =
//}