Mercurial > tablet-emu
comparison src/main.rs @ 5:cdbf3a2c9af8
Add a very simple menu.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sun, 01 Nov 2020 14:34:02 +0100 |
parents | 2e074d185151 |
children | dd10331549c6 |
comparison
equal
deleted
inserted
replaced
4:2e074d185151 | 5:cdbf3a2c9af8 |
---|---|
1 use gio::prelude::*; | 1 use gio::prelude::*; |
2 use gtk::prelude::*; | 2 use gtk::prelude::*; |
3 use glib::clone; | |
3 | 4 |
4 use std::env::args; | 5 use std::env::args; |
5 use std::fs::{File, OpenOptions}; | 6 use std::fs::{File, OpenOptions}; |
6 use std::io::ErrorKind; | 7 use std::io::ErrorKind; |
7 use std::sync::{Arc, Mutex}; | 8 use std::sync::{Arc, Mutex}; |
198 selected_tool: Key, | 199 selected_tool: Key, |
199 pressed: bool, | 200 pressed: bool, |
200 } | 201 } |
201 | 202 |
202 fn build_ui(application: >k::Application) { | 203 fn build_ui(application: >k::Application) { |
204 let quit = gio::SimpleAction::new("quit", None); | |
205 application.set_accels_for_action("app.quit", &["<Control>q"]); | |
206 application.add_action(&quit); | |
207 quit.connect_activate(clone!(@weak application => move |_, _| application.quit())); | |
208 | |
209 let about = gio::SimpleAction::new("about", None); | |
210 application.add_action(&about); | |
211 about.connect_activate(|_, _| { | |
212 let about = gtk::AboutDialog::new(); | |
213 about.set_program_name("TabletEmu"); | |
214 about.set_logo_icon_name(Some("input-tablet")); | |
215 about.set_website(Some("https://hg.linkmauve.fr/tablet-emu")); | |
216 about.set_version(Some("0.1")); | |
217 about.set_license_type(gtk::License::Agpl30); | |
218 about.set_program_name("TabletEmu"); | |
219 about.run(); | |
220 unsafe { about.destroy(); } | |
221 }); | |
222 | |
223 let menu = gio::Menu::new(); | |
224 { | |
225 let file = gio::Menu::new(); | |
226 file.append(Some("_Quit"), Some("app.quit")); | |
227 menu.append_submenu(Some("_File"), &file); | |
228 } | |
229 { | |
230 let help = gio::Menu::new(); | |
231 help.append(Some("_About"), Some("app.about")); | |
232 menu.append_submenu(Some("_Help"), &help); | |
233 } | |
234 application.set_menubar(Some(&menu)); | |
235 | |
203 let dev = match create_uinput_device() { | 236 let dev = match create_uinput_device() { |
204 Ok(dev) => dev, | 237 Ok(dev) => dev, |
205 Err(err) => { | 238 Err(err) => { |
206 match err.kind() { | 239 match err.kind() { |
207 ErrorKind::NotFound => { | 240 ErrorKind::NotFound => { |