gdritter repos palladio / 489d34c
Some buttons and bad drawing Getty Ritter 6 years ago
1 changed file(s) with 27 addition(s) and 5 deletion(s). Collapse all Expand all
1515
1616 pub struct Header {
1717 pub container: gtk::HeaderBar,
18 pub open_btn: gtk::Button,
19 pub save_btn: gtk::Button,
20 pub save_as_btn: gtk::Button,
1821 }
1922
2023 impl App {
2427 let canvas = gtk::DrawingArea::new();
2528
2629 window.set_titlebar(&header.container);
27 window.set_title("App name");
28 window.set_wmclass("app-name", "App name");
30 window.set_title("Palladio");
31 window.set_wmclass("palladio", "Palladio");
2932 window.add(&canvas);
3033
3134 canvas.connect_draw(|cv, ctx| {
3235 let w = cv.get_allocated_width();
3336 let h = cv.get_allocated_height();
34 ctx.set_source_rgb(0.0, 0.0, 0.0);
37 ctx.set_source_rgb(1.0, 1.0, 1.0);
3538 ctx.rectangle(0.0, 0.0, w as f64, h as f64);
3639 ctx.fill();
40 ctx.set_source_rgb(0.8, 0.8, 0.8);
41 for x in 0..((w / 32) + 1) {
42 ctx.move_to(x as f64 * 32.0, 0.0);
43 ctx.line_to(x as f64 * 32.0, h as f64);
44 ctx.stroke();
45 }
46 for y in 0..((h / 32) + 1) {
47 ctx.move_to(0.0, y as f64 * 32.0);
48 ctx.line_to(w as f64, y as f64 * 32.0);
49 ctx.stroke();
50 }
3751 gtk::Inhibit(false)
3852 });
3953
6276 impl Header {
6377 fn new() -> Header {
6478 let container = gtk::HeaderBar::new();
65 container.set_title("App name");
79 container.set_title("Palladio");
6680 container.set_show_close_button(true);
6781
68 Header { container }
82 let open_btn = gtk::Button::new_with_label("Open");
83 let save_btn = gtk::Button::new_with_label("Save");
84 let save_as_btn = gtk::Button::new_with_label("Save As");
85
86 container.pack_start(&open_btn);
87 container.pack_end(&save_btn);
88 container.pack_end(&save_as_btn);
89
90 Header { container, open_btn, save_btn, save_as_btn }
6991 }
7092 }