Skip to content

Commit

Permalink
Move code for shortcuts helper into shortcuts.rs file.
Browse files Browse the repository at this point in the history
  • Loading branch information
luleyleo committed Nov 12, 2024
1 parent e20e5dd commit ae854b5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
24 changes: 8 additions & 16 deletions gnome/src/app.rs
Original file line number Diff line number Diff line change
@@ -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::<adw::Application>().unwrap();
Expand Down Expand Up @@ -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::<gtk::ShortcutsWindow>("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);
Expand Down
1 change: 1 addition & 0 deletions gnome/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod config;
mod error_window;
mod search;
mod search_window;
mod shortcuts;

const APP_ID: &str = env!("APP_ID");

Expand Down
15 changes: 15 additions & 0 deletions gnome/src/shortcuts.rs
Original file line number Diff line number Diff line change
@@ -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::<gtk::ShortcutsWindow>("help-overlay")
.unwrap();
help_overlay.set_transient_for(Some(window));
help_overlay.set_application(window.application().as_ref());
help_overlay.present();
}

0 comments on commit ae854b5

Please sign in to comment.