Some buttons and bad drawing
Getty Ritter
6 years ago
15 | 15 | |
16 | 16 | pub struct Header { |
17 | 17 | pub container: gtk::HeaderBar, |
18 | pub open_btn: gtk::Button, | |
19 | pub save_btn: gtk::Button, | |
20 | pub save_as_btn: gtk::Button, | |
18 | 21 | } |
19 | 22 | |
20 | 23 | impl App { |
24 | 27 | let canvas = gtk::DrawingArea::new(); |
25 | 28 | |
26 | 29 | 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"); | |
29 | 32 | window.add(&canvas); |
30 | 33 | |
31 | 34 | canvas.connect_draw(|cv, ctx| { |
32 | 35 | let w = cv.get_allocated_width(); |
33 | 36 | let h = cv.get_allocated_height(); |
34 |
ctx.set_source_rgb( |
|
37 | ctx.set_source_rgb(1.0, 1.0, 1.0); | |
35 | 38 | ctx.rectangle(0.0, 0.0, w as f64, h as f64); |
36 | 39 | 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 | } | |
37 | 51 | gtk::Inhibit(false) |
38 | 52 | }); |
39 | 53 | |
62 | 76 | impl Header { |
63 | 77 | fn new() -> Header { |
64 | 78 | let container = gtk::HeaderBar::new(); |
65 |
container.set_title(" |
|
79 | container.set_title("Palladio"); | |
66 | 80 | container.set_show_close_button(true); |
67 | 81 | |
68 |
|
|
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 } | |
69 | 91 | } |
70 | 92 | } |