mirror of
https://github.com/13hannes11/focus_annotator.git
synced 2024-09-03 23:21:01 +02:00
58 lines
1.6 KiB
Rust
58 lines
1.6 KiB
Rust
use adw::prelude::*;
|
|
use gtk::prelude::*;
|
|
|
|
use adw::{ActionRow, ApplicationWindow, HeaderBar};
|
|
use gtk::{Application, Box, ListBox, Orientation};
|
|
|
|
fn main() {
|
|
let application = Application::builder()
|
|
.application_id("com.example.FirstAdwaitaApp")
|
|
.build();
|
|
|
|
application.connect_startup(|_| {
|
|
adw::init();
|
|
});
|
|
|
|
application.connect_activate(|app| {
|
|
// ActionRows are only available in Adwaita
|
|
let row = ActionRow::builder()
|
|
.activatable(true)
|
|
.selectable(false)
|
|
.title("Click me")
|
|
.build();
|
|
row.connect_activated(|x| {
|
|
eprintln!("Clicked! {:?}", x);
|
|
});
|
|
|
|
|
|
let list = ListBox::builder()
|
|
.margin_top(32)
|
|
.margin_end(32)
|
|
.margin_bottom(32)
|
|
.margin_start(32)
|
|
// the content class makes the list look nicer
|
|
.css_classes(vec![String::from("content")])
|
|
.build();
|
|
list.append(&row);
|
|
|
|
// Combine the content in a box
|
|
let content = Box::new(Orientation::Vertical, 0);
|
|
// Adwaitas' ApplicationWindow does not include a HeaderBar
|
|
content.append(
|
|
&HeaderBar::builder()
|
|
.title_widget(&adw::WindowTitle::new("First App", ""))
|
|
.build(),
|
|
);
|
|
content.append(&list);
|
|
|
|
let window = ApplicationWindow::builder()
|
|
.application(app)
|
|
.default_width(350)
|
|
// add content to window
|
|
.content(&content)
|
|
.build();
|
|
window.show();
|
|
});
|
|
|
|
application.run();
|
|
} |