diff --git a/gnome/src/app.rs b/gnome/src/app.rs index 544a6d3..149feb1 100644 --- a/gnome/src/app.rs +++ b/gnome/src/app.rs @@ -1,12 +1,11 @@ +use crate::{about, search_window::SearchWindow, shortcuts}; use adw::prelude::*; -use gtk::gio::SimpleAction; -use gtk::gio::{self}; -use gtk::glib::{self, clone}; -use gtk::{gdk, STYLE_PROVIDER_PRIORITY_APPLICATION}; -use gtk_blueprint::include_blp; - -use crate::about; -use crate::search_window::SearchWindow; +use gtk::{ + gdk, + gio::{self, SimpleAction}, + glib::{self, clone}, + STYLE_PROVIDER_PRIORITY_APPLICATION, +}; pub fn start(app: &adw::Application, files: &[gio::File]) { let app = app.downcast_ref::().unwrap(); @@ -42,14 +41,7 @@ pub fn start(app: &adw::Application, files: &[gio::File]) { #[weak] window, move |_, _| { - let blueprint = include_blp!("gnome/src/shortcuts.blp"); - let builder = gtk::Builder::from_string(blueprint); - let help_overlay = builder - .object::("help-overlay") - .unwrap(); - help_overlay.set_transient_for(Some(&window)); - help_overlay.set_application(window.application().as_ref()); - help_overlay.present(); + shortcuts::show_shortcuts(&window); } )); app.add_action(&shortcuts_action); diff --git a/gnome/src/main.rs b/gnome/src/main.rs index 160418f..3402038 100644 --- a/gnome/src/main.rs +++ b/gnome/src/main.rs @@ -8,6 +8,7 @@ mod config; mod error_window; mod search; mod search_window; +mod shortcuts; const APP_ID: &str = env!("APP_ID"); diff --git a/gnome/src/shortcuts.rs b/gnome/src/shortcuts.rs new file mode 100644 index 0000000..72491cb --- /dev/null +++ b/gnome/src/shortcuts.rs @@ -0,0 +1,15 @@ +use gtk::prelude::*; +use gtk_blueprint::include_blp; + +use crate::search_window::SearchWindow; + +pub fn show_shortcuts(window: &SearchWindow) { + let blueprint = include_blp!("gnome/src/shortcuts.blp"); + let builder = gtk::Builder::from_string(blueprint); + let help_overlay = builder + .object::("help-overlay") + .unwrap(); + help_overlay.set_transient_for(Some(window)); + help_overlay.set_application(window.application().as_ref()); + help_overlay.present(); +}