two buttons
This commit is contained in:
parent
097fefb947
commit
0b46e51694
32
src/main.rs
32
src/main.rs
@ -4,38 +4,54 @@ use chrono::Local;
|
|||||||
|
|
||||||
use gtk4 as gtk;
|
use gtk4 as gtk;
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use gtk::{glib, Application, ApplicationWindow, Button};
|
use gtk::{glib};
|
||||||
|
|
||||||
fn main() -> glib::ExitCode {
|
fn main() -> glib::ExitCode {
|
||||||
let application = Application::builder()
|
let application = gtk::Application::builder()
|
||||||
.application_id("de.privacy1st.pdt")
|
.application_id("de.privacy1st.pdt")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
application.connect_activate(build_ui);
|
application.connect_activate(build_ui);
|
||||||
|
|
||||||
application.run()
|
application.run()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_ui(app: >k::Application) {
|
fn build_ui(app: >k::Application) {
|
||||||
let window = ApplicationWindow::builder()
|
let window = gtk::ApplicationWindow::builder()
|
||||||
.application(app)
|
.application(app)
|
||||||
.title("PleaseDisturbTimer")
|
.title("PleaseDisturbTimer")
|
||||||
.default_width(350)
|
.default_width(350)
|
||||||
.default_height(70)
|
.default_height(70)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let button_start = Button::with_label("Start");
|
let container = gtk::Box::builder()
|
||||||
|
.orientation(gtk::Orientation::Vertical)
|
||||||
|
.margin_top(24)
|
||||||
|
.margin_bottom(24)
|
||||||
|
.margin_start(24)
|
||||||
|
.margin_end(24)
|
||||||
|
.halign(gtk::Align::Center)
|
||||||
|
.valign(gtk::Align::Center)
|
||||||
|
.spacing(24)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
let button_start = gtk::Button::with_label("Start");
|
||||||
button_start.connect_clicked(|_| {
|
button_start.connect_clicked(|_| {
|
||||||
eprintln!("Timer started.");
|
eprintln!("Timer started.");
|
||||||
});
|
});
|
||||||
window.set_child(Some(&button_start));
|
container.append(&button_start);
|
||||||
|
|
||||||
|
let button_stop = gtk::Button::with_label("Stop");
|
||||||
|
button_stop.connect_clicked(|_| {
|
||||||
|
eprintln!("Timer stopped.");
|
||||||
|
});
|
||||||
|
container.append(&button_stop);
|
||||||
|
|
||||||
let time = current_time();
|
let time = current_time();
|
||||||
let label = gtk::Label::default();
|
let label = gtk::Label::default();
|
||||||
label.set_text(&time);
|
label.set_text(&time);
|
||||||
// label.set_halign(gtk::Align::Center);
|
// label.set_halign(gtk::Align::Center);
|
||||||
window.set_child(Some(&label));
|
container.append(&label);
|
||||||
|
|
||||||
|
window.set_child(Some(&container));
|
||||||
window.present();
|
window.present();
|
||||||
|
|
||||||
// we are using a closure to capture the label (else we could also use a normal function)
|
// we are using a closure to capture the label (else we could also use a normal function)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user