Skip to content

Commit

Permalink
Move ui related code into ui module.
Browse files Browse the repository at this point in the history
  • Loading branch information
luleyleo committed Nov 12, 2024
1 parent ae854b5 commit 75336eb
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 16 deletions.
8 changes: 4 additions & 4 deletions gnome/src/app.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{about, search_window::SearchWindow, shortcuts};
use crate::ui;
use adw::prelude::*;
use gtk::{
gdk,
Expand All @@ -18,7 +18,7 @@ pub fn start(app: &adw::Application, files: &[gio::File]) {
STYLE_PROVIDER_PRIORITY_APPLICATION,
);

let window = SearchWindow::new(app);
let window = ui::SearchWindow::new(app);

if let Some(dir) = files.first() {
if let Some(path) = dir.path() {
Expand All @@ -32,7 +32,7 @@ pub fn start(app: &adw::Application, files: &[gio::File]) {
about_action.connect_activate(clone!(
#[weak]
window,
move |_, _| about::dialog().present(Some(&window))
move |_, _| ui::about_dialog().present(Some(&window))
));
app.add_action(&about_action);

Expand All @@ -41,7 +41,7 @@ pub fn start(app: &adw::Application, files: &[gio::File]) {
#[weak]
window,
move |_, _| {
shortcuts::show_shortcuts(&window);
ui::show_shortcuts(&window);
}
));
app.add_action(&shortcuts_action);
Expand Down
5 changes: 1 addition & 4 deletions gnome/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ use adw::prelude::*;
use gtk::gio::ApplicationFlags;
use std::path::PathBuf;

mod about;
mod app;
mod config;
mod error_window;
mod search;
mod search_window;
mod shortcuts;
mod ui;

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

Expand Down
2 changes: 1 addition & 1 deletion gnome/src/about.rs → gnome/src/ui/about.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ static RELEASE_NOTES: &str = r#"
</ul>
"#;

pub fn dialog() -> adw::AboutDialog {
pub fn about_dialog() -> adw::AboutDialog {
adw::AboutDialog::builder()
.application_name("Clapgrep")
.version("1.2")
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use glib::subclass::InitializingObject;
use gtk::{glib, CompositeTemplate};
use std::cell::RefCell;

use crate::search_window::SearchWindow;
use crate::ui::SearchWindow;

#[derive(CompositeTemplate, glib::Properties, Default)]
#[template(file = "src/error_window/error_window.blp")]
#[template(file = "src/ui/error_window/error_window.blp")]
#[properties(wrapper_type = super::ErrorWindow)]
pub struct ErrorWindow {
#[property(get, set)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod imp;
use glib::Object;
use gtk::{gio, glib, prelude::*};

use crate::search_window::SearchWindow;
use crate::ui::SearchWindow;

glib::wrapper! {
pub struct ErrorWindow(ObjectSubclass<imp::ErrorWindow>)
Expand Down
11 changes: 11 additions & 0 deletions gnome/src/ui/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
mod about;
pub use about::about_dialog;

mod shortcuts;
pub use shortcuts::show_shortcuts;

mod error_window;
pub use error_window::ErrorWindow;

mod search_window;
pub use search_window::SearchWindow;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{config::Config, error_window::ErrorWindow, search::SearchModel};
use crate::{config::Config, search::SearchModel, ui::ErrorWindow};
use adw::subclass::prelude::*;
use clapgrep_core::{SearchEngine, SearchFlags, SearchMessage, SearchParameters};
use glib::subclass::InitializingObject;
Expand All @@ -15,7 +15,7 @@ use std::{
};

#[derive(CompositeTemplate, glib::Properties, Default)]
#[template(file = "src/search_window/search_window.blp")]
#[template(file = "src/ui/search_window/search_window.blp")]
#[properties(wrapper_type = super::SearchWindow)]
pub struct SearchWindow {
#[property(get, set)]
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions gnome/src/shortcuts.rs → gnome/src/ui/shortcuts/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use gtk::prelude::*;
use gtk_blueprint::include_blp;

use crate::search_window::SearchWindow;
use crate::ui::SearchWindow;

pub fn show_shortcuts(window: &SearchWindow) {
let blueprint = include_blp!("gnome/src/shortcuts.blp");
let blueprint = include_blp!("gnome/src/ui/shortcuts/shortcuts.blp");
let builder = gtk::Builder::from_string(blueprint);
let help_overlay = builder
.object::<gtk::ShortcutsWindow>("help-overlay")
Expand Down
File renamed without changes.

0 comments on commit 75336eb

Please sign in to comment.