50 lines
1.3 KiB
Rust
50 lines
1.3 KiB
Rust
|
use gio::prelude::*;
|
||
|
use gtk::prelude::*;
|
||
|
use std::env::args;
|
||
|
use gtk::Orientation;
|
||
|
|
||
|
const SPACING: i32 = 16;
|
||
|
|
||
|
fn build_ui(application: >k::Application) {
|
||
|
let window = gtk::ApplicationWindow::new(application);
|
||
|
|
||
|
window.set_title("youtube-dl");
|
||
|
window.set_border_width(10);
|
||
|
window.set_position(gtk::WindowPosition::Center);
|
||
|
window.set_default_size(400, 100);
|
||
|
|
||
|
let vertical = gtk::Box::new(Orientation::Vertical, SPACING);
|
||
|
let url = gtk::Entry::new();
|
||
|
let horizontal = gtk::Box::new(Orientation::Horizontal, SPACING);
|
||
|
let convert_to_mp3 = gtk::CheckButton::with_label("convert to mp3");
|
||
|
let button = gtk::Button::with_label("Go!");
|
||
|
|
||
|
url.set_placeholder_text(Some("Enter URL here"));
|
||
|
|
||
|
horizontal.set_spacing(SPACING);
|
||
|
horizontal.set_homogeneous(true);
|
||
|
|
||
|
window.add(&vertical);
|
||
|
|
||
|
vertical.add(&url);
|
||
|
vertical.add(&horizontal);
|
||
|
|
||
|
horizontal.add(&convert_to_mp3);
|
||
|
horizontal.add(&button);
|
||
|
|
||
|
window.show_all();
|
||
|
}
|
||
|
|
||
|
fn main() {
|
||
|
let application = gtk::Application::new(
|
||
|
Some("dev.tinybird.max.youtube-dl-gtk"),
|
||
|
Default::default()
|
||
|
).expect("Initialization failed...");
|
||
|
|
||
|
application.connect_activate(|app| {
|
||
|
build_ui(app);
|
||
|
});
|
||
|
|
||
|
application.run(&args().collect::<Vec<_>>());
|
||
|
}
|