diff --git a/Cargo.toml b/Cargo.toml index 3508a7f..59fb934 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" \ No newline at end of file +gtk-ui-builder = "0.2.0" +serde_json = "1.0" + +[profile.release] +strip = true \ No newline at end of file diff --git a/src/inv.rs b/src/inv.rs index 45df73c..38b395b 100644 --- a/src/inv.rs +++ b/src/inv.rs @@ -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> { - 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(()) } diff --git a/src/main.rs b/src/main.rs index 956cffb..f494eff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 = +//} \ No newline at end of file