comparison src/main.rs @ 8:51a6c86d3141

Add mnemonic to all current tools.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 01 Nov 2020 14:49:26 +0100
parents 9c3e2d2efaa8
children d1972fc49a5b
comparison
equal deleted inserted replaced
7:9c3e2d2efaa8 8:51a6c86d3141
288 let hbox = gtk::Box::new(gtk::Orientation::Horizontal, 0); 288 let hbox = gtk::Box::new(gtk::Orientation::Horizontal, 0);
289 let tools_box = gtk::Box::new(gtk::Orientation::Vertical, 0); 289 let tools_box = gtk::Box::new(gtk::Orientation::Vertical, 0);
290 290
291 macro_rules! impl_tool { 291 macro_rules! impl_tool {
292 ($tool:tt) => { 292 ($tool:tt) => {
293 let tool = gtk::Button::with_label($tool); 293 let tool = gtk::Button::with_mnemonic($tool);
294 let state_weak = Arc::downgrade(&state); 294 let state_weak = Arc::downgrade(&state);
295 tool.connect_clicked(move |b| { 295 tool.connect_clicked(move |b| {
296 let state = state_weak.upgrade().unwrap(); 296 let state = state_weak.upgrade().unwrap();
297 let mut state = state.lock().unwrap(); 297 let mut state = state.lock().unwrap();
298 state.selected_tool = match b.get_label().unwrap().as_str() { 298 state.selected_tool = match b.get_label().unwrap().as_str() {
299 "Pen" => Key::ButtonToolPen, 299 "_Pen" => Key::ButtonToolPen,
300 "Rubber" => Key::ButtonToolRubber, 300 "_Rubber" => Key::ButtonToolRubber,
301 "Brush" => Key::ButtonToolBrush, 301 "_Brush" => Key::ButtonToolBrush,
302 "Pencil" => Key::ButtonToolPencil, 302 "P_encil" => Key::ButtonToolPencil,
303 "Airbrush" => Key::ButtonToolAirbrush, 303 "_Airbrush" => Key::ButtonToolAirbrush,
304 _ => unreachable!(), 304 _ => unreachable!(),
305 }; 305 };
306 }); 306 });
307 tools_box.add(&tool); 307 tools_box.add(&tool);
308 }; 308 };
309 }; 309 };
310 impl_tool!("Pen"); 310 impl_tool!("_Pen");
311 impl_tool!("Rubber"); 311 impl_tool!("_Rubber");
312 impl_tool!("Brush"); 312 impl_tool!("_Brush");
313 impl_tool!("Pencil"); 313 impl_tool!("P_encil");
314 impl_tool!("Airbrush"); 314 impl_tool!("_Airbrush");
315 315
316 let drawing_area = gtk::DrawingArea::new(); 316 let drawing_area = gtk::DrawingArea::new();
317 drawing_area.set_size_request(WIDTH, HEIGHT); 317 drawing_area.set_size_request(WIDTH, HEIGHT);
318 drawing_area.set_hexpand(true); 318 drawing_area.set_hexpand(true);
319 drawing_area.set_events( 319 drawing_area.set_events(