use gtk::glib; use gtk::prelude::*; const APP_ID: &str = "org.gtk_rs.HelloWorld1"; fn main() -> glib::ExitCode { // Create a new application let app = gtk::Application::builder().application_id(APP_ID).build(); app.connect_activate(build_ui); // Run the application app.run() } pub struct App { pub window: gtk::Window, pub container: gtk::Paned, pub center: gtk::Button, pub toolbar: gtk::Button, pub header: Header, } impl App { fn new() -> App { let window = gtk::Window::new(); let container = gtk::Paned::new(gtk::Orientation::Horizontal); let header = Header::new(); let toolbar = gtk::Button::builder() .label("Press me!") .margin_top(12) .margin_bottom(12) .margin_start(12) .margin_end(12) .build(); let center = gtk::Button::builder() .label("Press me!") .margin_top(12) .margin_bottom(12) .margin_start(12) .margin_end(12) .build(); window.set_titlebar(Some(&header.container)); window.set_title(Some("Thyme")); container.set_start_child(Some(&toolbar)); container.set_end_child(Some(¢er)); window.set_child(Some(&container)); App { window, center, container, toolbar, header, } } } pub struct Header { pub container: gtk::HeaderBar, pub open_btn: gtk::Button, pub save_btn: gtk::Button, pub save_as_btn: gtk::Button, } impl Header { fn new() -> Header { let container = gtk::HeaderBar::new(); let open_btn = gtk::Button::with_label("open"); let save_btn = gtk::Button::with_label("save"); let save_as_btn = gtk::Button::with_label("save as"); open_btn.connect_clicked(Header::do_open); container.pack_start(&open_btn); container.pack_end(&save_btn); container.pack_end(&save_as_btn); Header { container, open_btn, save_btn, save_as_btn, } } fn do_open(_: >k::Button) { let _open_dialog = gtk::FileChooserDialog::new( Some("Open"), Some(>k::Window::new()), gtk::FileChooserAction::Open, &[ ("Cancel", gtk::ResponseType::Cancel), ("Open", gtk::ResponseType::Ok), ], ); } } fn build_ui(app: >k::Application) { let thyme_app = App::new(); thyme_app.window.set_application(Some(app)); thyme_app.window.present(); }