Skip to content

Commit

Permalink
upgrade to relm 0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
euclio committed Jul 31, 2024
1 parent f796a17 commit 43a0289
Show file tree
Hide file tree
Showing 12 changed files with 631 additions and 476 deletions.
616 changes: 342 additions & 274 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ itertools = "0.10.5"
mime = "0.3.16"
once_cell = "1.9.0"
pathdiff = "0.2.1"
poppler-rs = { version = "0.21.0" }
relm4 = { version = "0.6.0-alpha", features = ["libadwaita", "libpanel", "gnome_43"] }
poppler-rs = { version = "0.24.1" }
relm4 = { version = "0.9.0", features = ["libadwaita", "libpanel", "gnome_43"] }
serde = { version = "1.0.136", features = ["derive"] }
serde_json = "1.0.79"
sourceview5 = "0.6.0"
sourceview5 = "0.9.0"
tracing = "0.1.37"
tracing-subscriber = { version = "0.3.16", features = ["env-filter"] }
tracing-tree = "0.2.4"
12 changes: 6 additions & 6 deletions src/component/alert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use gtk::prelude::*;
use relm4::prelude::*;
use relm4::MessageBroker;

pub static ERROR_BROKER: MessageBroker<AlertModel> = MessageBroker::new();
pub static ERROR_BROKER: MessageBroker<AlertMsg> = MessageBroker::new();

#[derive(Debug)]
pub struct AlertModel {
Expand All @@ -18,7 +18,7 @@ pub struct AlertModel {
#[derive(Debug)]
pub enum AlertMsg {
Show { text: String },
Response(gtk::ResponseType),
Response,
}

#[relm4::component(pub)]
Expand All @@ -33,8 +33,8 @@ impl SimpleComponent for AlertModel {
set_message_type: gtk::MessageType::Error,
#[watch]
set_visible: model.is_active,
connect_response[sender] => move |_, response| {
sender.input(AlertMsg::Response(response));
connect_response[sender] => move |_, _| {
sender.input(AlertMsg::Response);
},
set_text: Some("Something went wrong"),
#[watch]
Expand All @@ -44,7 +44,7 @@ impl SimpleComponent for AlertModel {
}
}

fn init(_: (), root: &Self::Root, sender: ComponentSender<Self>) -> ComponentParts<Self> {
fn init(_: (), root: Self::Root, sender: ComponentSender<Self>) -> ComponentParts<Self> {
let model = AlertModel {
is_active: false,
text: String::default(),
Expand All @@ -61,7 +61,7 @@ impl SimpleComponent for AlertModel {
self.text = text;
self.is_active = true;
}
AlertMsg::Response(_) => {
AlertMsg::Response => {
self.is_active = false;
}
}
Expand Down
34 changes: 14 additions & 20 deletions src/component/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub enum Transfer {
#[derive(Debug)]
pub enum AppMsg {
/// Display an arbitrary error in an alert dialog.
Error(Box<dyn std::error::Error>),
Error(Box<dyn std::error::Error + Send>),

/// The file root has changed. Existing directory trees are now invalid and must be popped off
/// the stack.
Expand All @@ -72,9 +72,9 @@ pub enum AppMsg {
/// number of possible changes:
///
/// - If the new selection is higher in the directory tree than the old selection, the lower
/// listings must be removed.
/// listings must be removed.
/// - If the new selection is a directory, a new directory listing is pushed onto the listing
/// stack.
/// stack.
/// - If the new selection is a file, the preview must be updated.
NewSelection(Selection),

Expand Down Expand Up @@ -178,7 +178,7 @@ impl Component for AppModel {
warn!("unable to write application state: {}", e);
}

gtk::Inhibit(false)
glib::signal::Propagation::Proceed
}
}
}
Expand All @@ -194,11 +194,7 @@ impl Component for AppModel {
}
}

fn init(
dir: PathBuf,
root: &Self::Root,
sender: ComponentSender<Self>,
) -> ComponentParts<Self> {
fn init(dir: PathBuf, root: Self::Root, sender: ComponentSender<Self>) -> ComponentParts<Self> {
let dir = if !dir.is_dir() {
dir.parent().unwrap_or(&dir)
} else {
Expand Down Expand Up @@ -226,14 +222,12 @@ impl Component for AppModel {

let mut model = AppModel {
root: dir.clone(),
directories: FactoryVecDeque::new(
widgets.directory_panes.clone(),
sender.input_sender(),
),
progress: FactoryVecDeque::new(
widgets.transfer_progress.clone(),
sender.input_sender(),
),
directories: FactoryVecDeque::builder()
.launch(widgets.directory_panes.clone())
.forward(sender.input_sender(), identity),
progress: FactoryVecDeque::builder()
.launch(widgets.transfer_progress.clone())
.forward(sender.input_sender(), identity),
mount: Mount::builder()
.transient_for(&widgets.main_window)
.launch(())
Expand All @@ -250,18 +244,18 @@ impl Component for AppModel {

model.directories.guard().push_back(dir);

let group = RelmActionGroup::<WindowActionGroup>::new();
let mut group = RelmActionGroup::<WindowActionGroup>::new();

let sender_ = sender.clone();
let about_action: RelmAction<AboutAction> = RelmAction::new_stateless(move |_| {
sender_.input(AppMsg::About);
});
group.add_action(&about_action);
group.add_action(about_action);

let mount_action: RelmAction<MountAction> = RelmAction::new_stateless(move |_| {
sender.input(AppMsg::Mount);
});
group.add_action(&mount_action);
group.add_action(mount_action);

widgets
.main_window
Expand Down
Loading

0 comments on commit 43a0289

Please sign in to comment.