diff --git a/data/gtk/window.ui b/data/gtk/window.ui index 2feffa0..a851416 100644 --- a/data/gtk/window.ui +++ b/data/gtk/window.ui @@ -42,6 +42,10 @@
+ + _Help + app.help + _Keyboard Shortcuts win.show-help-overlay diff --git a/help/C/index.page b/help/C/index.page new file mode 100644 index 0000000..fa1c4e3 --- /dev/null +++ b/help/C/index.page @@ -0,0 +1,19 @@ + + + + Help for Loupe. + <media its:translate="no" type="image" src="figures/org.gnome.eog-symbolic.svg"/> + Loupe + Loupe + + Christopher Davis + christopherdavis@gnome.org + 2020 + + + +Loupe + diff --git a/help/meson.build b/help/meson.build new file mode 100644 index 0000000..7d09c73 --- /dev/null +++ b/help/meson.build @@ -0,0 +1,8 @@ +sources = [ + 'index.page' +] + +gnome.yelp( + meson.project_name(), + sources: sources, +) diff --git a/meson.build b/meson.build index 1ac8616..49d87dd 100644 --- a/meson.build +++ b/meson.build @@ -53,6 +53,7 @@ conf.set('localedir', iv_localedir) conf.set('pkgdatadir', iv_pkgdatadir) subdir('data') +subdir('help') subdir('src') subdir('po') diff --git a/src/application.rs b/src/application.rs index 4bd3ac0..131d58d 100644 --- a/src/application.rs +++ b/src/application.rs @@ -20,9 +20,11 @@ use crate::deps::*; use crate::util::gettext::*; +use crate::util::spawn; use adw::prelude::*; use adw::subclass::prelude::*; +use glib::clone; use crate::config; use crate::window::LpWindow; @@ -112,6 +114,9 @@ impl LpApplication { gio::ActionEntryBuilder::new("about") .activate(|app: &Self, _, _| app.show_about()) .build(), + gio::ActionEntryBuilder::new("help") + .activate(|app: &Self, _, _| app.show_help()) + .build(), gio::ActionEntryBuilder::new("quit") .activate(|app: &Self, _, _| app.quit()) .build(), @@ -125,6 +130,7 @@ impl LpApplication { self.add_action_entries(actions); + self.set_accels_for_action("app.help", &["F1"]); self.set_accels_for_action("app.quit", &["Q"]); self.set_accels_for_action("app.new-window", &["N"]); @@ -207,4 +213,16 @@ impl LpApplication { about.present(); } + + pub fn show_help(&self) { + spawn(clone!(@weak self as app => async move { + let context = app + .active_window() + .map(|w| gtk::prelude::WidgetExt::display(&w).app_launch_context()); + + if let Err(e) = gio::AppInfo::launch_default_for_uri_future("help:loupe", context.as_ref()).await { + log::error!("Failed to launch help: {}", e.message()); + } + })); + } }