Skip to content

Commit

Permalink
Move HistoryModel and RowData to the new history module
Browse files Browse the repository at this point in the history
Feels like a better organization
  • Loading branch information
RealKC committed Jul 23, 2023
1 parent 57786c2 commit 62de550
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/appwindow.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use gtk4::glib;

use crate::{historymodel::HistoryModel, kcshot::KCShot};
use crate::{history::HistoryModel, kcshot::KCShot};

glib::wrapper! {
pub struct AppWindow(ObjectSubclass<underlying::AppWindow>)
Expand Down Expand Up @@ -31,7 +31,7 @@ mod underlying {
use once_cell::unsync::OnceCell;

use crate::{
editor::EditorWindow, history, historymodel::RowData, kcshot::KCShot,
editor::EditorWindow, history, history::RowData, kcshot::KCShot,
settings_window::SettingsWindow,
};

Expand Down
2 changes: 1 addition & 1 deletion src/editor/underlying.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::{
operations::{OperationStack, SelectionMode, Tool},
utils,
},
historymodel::ModelNotifier,
history::ModelNotifier,
kcshot::KCShot,
log_if_err,
postcapture::run_postcapture_actions,
Expand Down
4 changes: 4 additions & 0 deletions src/history.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
mod context_menu;
mod model;
mod row_data;

pub use context_menu::context_menu;
pub use model::{HistoryModel, ModelNotifier};
pub use row_data::RowData;
2 changes: 1 addition & 1 deletion src/history/context_menu.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use gtk4::{gdk, gio, prelude::*};

use crate::historymodel::RowData;
use super::RowData;

/// Creates a context menu with the usual operations you'd expect from a context menu on a history entry
pub fn context_menu(data: RowData, parent: &gtk4::Widget) -> gtk4::PopoverMenu {
Expand Down
8 changes: 3 additions & 5 deletions src/historymodel.rs → src/history/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ use gtk4::{
subclass::prelude::ObjectSubclassIsExt,
};

pub use self::rowdata::RowData;

mod rowdata;
use super::RowData;

glib::wrapper! {
pub struct HistoryModel(ObjectSubclass<underlying::ListModel>)
Expand All @@ -33,7 +31,7 @@ impl Default for HistoryModel {
/// This type is used to notify the HistoryModel that a new screenshot was taken, and it additionally
/// carries a [`self::RowData`] with the newly taken screenshot.
///
/// It caused [`HistoryModel::insert_screenshot`] to be called.
/// It causes [`HistoryModel::insert_screenshot`] to be called.
pub type ModelNotifier = Sender<RowData>;

mod underlying {
Expand All @@ -46,7 +44,7 @@ mod underlying {
subclass::prelude::*,
};

use super::rowdata::RowData;
use super::RowData;
use crate::{db, kcshot::KCShot};

#[derive(Default)]
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/kcshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use kcshot_data::settings::Settings;

use crate::{
appwindow,
historymodel::{HistoryModel, ModelNotifier},
history::{HistoryModel, ModelNotifier},
};

glib::wrapper! {
Expand Down Expand Up @@ -96,7 +96,7 @@ mod underlying {
use crate::{
appwindow, db,
editor::EditorWindow,
historymodel::{HistoryModel, ModelNotifier, RowData},
history::{HistoryModel, ModelNotifier, RowData},
systray,
};

Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ mod appwindow;
mod db;
mod editor;
mod history;
mod historymodel;
mod kcshot;
mod postcapture;
mod settings_window;
Expand Down
2 changes: 1 addition & 1 deletion src/postcapture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use kcshot_data::settings::Settings;

use crate::{
db,
historymodel::{ModelNotifier, RowData},
history::{ModelNotifier, RowData},
};

/// Trait for the post capture actions.
Expand Down

0 comments on commit 62de550

Please sign in to comment.