From ed96ea20cad3884fb5b1ec80c8773db5761a3ffa Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Sat, 2 Dec 2023 15:21:29 +0100 Subject: [PATCH] some ui? --- Cargo.toml | 2 ++ src/main.rs | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- src/video.rs | 13 +++++++++++++ 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 src/video.rs diff --git a/Cargo.toml b/Cargo.toml index b02b729..bca2f49 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,4 +6,6 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +anyhow = "1.0.75" +gstreamer = "0.21.2" gtk = { version = "0.7.3", package = "gtk4", features = ["v4_8"] } diff --git a/src/main.rs b/src/main.rs index 4a04498..7ee4ba5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ -use gtk::prelude::*; -use gtk::{glib, Application, ApplicationWindow}; +use gtk::{prelude::*,ListBox, glib, Application, ApplicationWindow, Button, Video, Box, LayoutManager, ffi::gtk_layout_manager_allocate}; + +mod video; const APP_ID: &str = "de.cscherr.vshot"; @@ -15,10 +16,53 @@ fn main() -> glib::ExitCode { } fn build_ui(app: &Application) { + let select_button = Button::builder() + .label("select video") + .margin_top(12) + .margin_bottom(12) + .margin_start(12) + .margin_end(12) + .build(); + select_button.connect_clicked(|button| { + println!("TODO"); + }); + let save_image_button = Button::builder() + .label("save") + .margin_top(12) + .margin_bottom(12) + .margin_start(12) + .margin_end(12) + .build(); + save_image_button.connect_clicked(|button| { + println!("TODO"); + }); + + let video_play = Video::builder() + .build(); + // Create a `ListBox` and add labels with integers from 0 to 100 + let meta_box = Box::builder() + .build(); + meta_box.append(&save_image_button); + meta_box.append(&select_button); + let video_box = Box::builder() + .height_request(550) + .width_request(750) + .orientation(gtk::Orientation::Vertical) + .build(); + video_box.append(&video_play); + + let list = ListBox::builder() + .build(); + list.append(&video_box); + list.append(&meta_box); + // Create a window and set the title let window = ApplicationWindow::builder() .application(app) .title("vshot") + .child(&list) + .default_height(600) + .default_width(800) .build(); // Present window diff --git a/src/video.rs b/src/video.rs new file mode 100644 index 0000000..20e7c81 --- /dev/null +++ b/src/video.rs @@ -0,0 +1,13 @@ +use std::{ + env, + sync::{Arc, Mutex}, +}; + +use anyhow::Error; +use gstreamer::prelude::*; + + +fn try_play_video(uri: &str) -> Result<(), Error> { + print!("hello world!"); + return Ok(()) +}