diff --git a/Cargo.lock b/Cargo.lock index 9a732ae..17f3c0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1060,7 +1060,7 @@ dependencies = [ [[package]] name = "nixos-conf-editor" -version = "0.0.3" +version = "0.0.4" dependencies = [ "brotli", "curl", diff --git a/Cargo.toml b/Cargo.toml index 9d64be8..3d0b590 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nixos-conf-editor" -version = "0.0.3" +version = "0.0.4" edition = "2021" default-run = "nixos-conf-editor" diff --git a/README.md b/README.md index 3adc134..dfcd69f 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ let nixos-conf-editor = (import (pkgs.fetchFromGitHub { owner = "vlinkz"; repo = "nixos-conf-editor"; - rev = "0.0.3"; + rev = "0.0.4"; sha256 = "0000000000000000000000000000000000000000000000000000"; })) {}; in diff --git a/default.nix b/default.nix index 88ce9e3..538535b 100644 --- a/default.nix +++ b/default.nix @@ -4,14 +4,14 @@ }: pkgs.stdenv.mkDerivation rec { pname = "nixos-conf-editor"; - version = "0.0.3"; + version = "0.0.4"; src = [ ./. ]; cargoDeps = pkgs.rustPlatform.fetchCargoTarball { inherit src; name = "${pname}-${version}"; - hash = "sha256-pka7LD7DZKbIhIBFZ5u05rG0vTY1NlhHbAa/7FhhaOQ="; + hash = "sha256-glG1hHnFUkSaqPYCydGjEUP3ly85PRReJJpFLeNZvsY="; }; nativeBuildInputs = with pkgs; [ @@ -41,10 +41,6 @@ pkgs.stdenv.mkDerivation rec { gnome.adwaita-icon-theme ]; - mesonFlags = [ - "-Dprofile=development" - ]; - postInstall = '' wrapProgram $out/bin/nixos-conf-editor --prefix PATH : '${lib.makeBinPath [ pkgs.pandoc ]}' ''; diff --git a/src/ui/about.rs b/src/ui/about.rs index cef81a0..57903c1 100644 --- a/src/ui/about.rs +++ b/src/ui/about.rs @@ -54,7 +54,7 @@ impl SimpleComponent for AboutModel { ComponentParts { model, widgets } } - fn update(&mut self, msg: Self::Input, sender: &ComponentSender) { + fn update(&mut self, msg: Self::Input, _sender: &ComponentSender) { match msg { AboutMsg::Show => { self.hidden = false; diff --git a/src/ui/optionpage.rs b/src/ui/optionpage.rs index 4b050af..a511549 100644 --- a/src/ui/optionpage.rs +++ b/src/ui/optionpage.rs @@ -60,7 +60,7 @@ impl SimpleComponent for OptPageModel { set_spacing: 15, set_vexpand: true, add_css_class: "labels", - append = >k::Label { + gtk::Label { set_margin_top: 5, set_margin_bottom: 5, set_halign: gtk::Align::Start, @@ -186,26 +186,27 @@ impl SimpleComponent for OptPageModel { }, }, - append = >k::Box { + gtk::Box { set_orientation: gtk::Orientation::Vertical, set_spacing: 10, #[watch] set_visible: model.data.example.is_some(), - append: example_box = >k::Box { + #[name(example_box)] + gtk::Box { set_orientation: gtk::Orientation::Horizontal, add_css_class: "header", add_css_class: "single-line", - append: example_header = >k::Label { + #[name(example_header)] + gtk::Label { set_halign: gtk::Align::Start, add_css_class: "heading", add_css_class: "h4", set_label: "Example", } }, - append = >k::Frame { + gtk::Frame { add_css_class: "code", - #[wrap(Some)] - set_child = &sourceview5::View { + sourceview5::View { set_editable: false, set_monospace: true, set_cursor_visible: false, @@ -237,16 +238,17 @@ impl SimpleComponent for OptPageModel { }, }, }, - append = >k::Separator { + gtk::Separator { set_opacity: 0.0, set_margin_top: 5, }, - append = >k::Box { + gtk::Box { #[watch] set_visible: valuestack.is_child_visible(), set_orientation: gtk::Orientation::Vertical, set_spacing: 10, - append: simplevalue_box = >k::Box { + #[name(simplevalue_box)] + gtk::Box { set_orientation: gtk::Orientation::Horizontal, add_css_class: "header", add_css_class: "single-line", @@ -256,8 +258,10 @@ impl SimpleComponent for OptPageModel { set_label: "Value", } }, - append: valuestack = >k::Stack { - add_child: number = >k::SpinButton { + #[name(valuestack)] + gtk::Stack { + #[name(number)] + gtk::SpinButton { set_halign: gtk::Align::Start, set_adjustment: >k::Adjustment::new(0.0, f64::MIN, f64::MAX, 1.0, 5.0, 0.0), set_climb_rate: 1.0, @@ -268,7 +272,8 @@ impl SimpleComponent for OptPageModel { } }, }, - add_child: stringentry = >k::Entry { + #[name(stringentry)] + gtk::Entry { set_halign: gtk::Align::Start, connect_changed[sender] => move |x| { if x.is_sensitive() { @@ -276,10 +281,12 @@ impl SimpleComponent for OptPageModel { } }, }, - add_child: truefalse = >k::Box { + #[name(truefalse)] + gtk::Box { add_css_class: "linked", set_orientation: gtk::Orientation::Horizontal, - append: truebtn = >k::ToggleButton { + #[name(truebtn)] + gtk::ToggleButton { set_label: "True", connect_toggled[sender] => move |x| { if x.is_active() { @@ -287,7 +294,8 @@ impl SimpleComponent for OptPageModel { } } }, - append: falsebtn = >k::ToggleButton { + #[name(falsebtn)] + gtk::ToggleButton { set_label: "False", set_group: Some(&truebtn), connect_toggled[sender] => move |x| { @@ -296,7 +304,8 @@ impl SimpleComponent for OptPageModel { } } }, - // append: nullbtn = >k::ToggleButton { + // #[name(nullbtn)] + // gtk::ToggleButton { // set_label: "null", // set_group: Some(&truebtn), // } @@ -304,23 +313,23 @@ impl SimpleComponent for OptPageModel { } }, - append = >k::Box { + gtk::Box { set_orientation: gtk::Orientation::Vertical, set_spacing: 10, - append: value_box = >k::Box { + #[name(value_box)] + gtk::Box { set_orientation: gtk::Orientation::Horizontal, add_css_class: "header", add_css_class: "single-line", - append = >k::Label { + gtk::Label { set_halign: gtk::Align::Start, add_css_class: "heading", set_label: "Attribute Value", } }, - append = >k::Frame { + gtk::Frame { add_css_class: "code", - #[wrap(Some)] - set_child = &sourceview5::View { + sourceview5::View { set_background_pattern: sourceview5::BackgroundPatternType::Grid, set_height_request: 100, set_editable: true, @@ -356,10 +365,10 @@ impl SimpleComponent for OptPageModel { } }, }, - append = >k::Box { + gtk::Box { set_orientation: gtk::Orientation::Horizontal, set_spacing: 10, - append = >k::Button { + gtk::Button { set_label: "Reset", #[watch] set_sensitive: model.conf != model.modifiedconf, @@ -367,7 +376,7 @@ impl SimpleComponent for OptPageModel { sender.input(OptPageMsg::ResetConf) } }, - append = >k::Button { + gtk::Button { set_label: "Clear", #[watch] set_sensitive: !model.modifiedconf.is_empty(), @@ -375,10 +384,12 @@ impl SimpleComponent for OptPageModel { sender.input(OptPageMsg::ClearConf) } }, - append: savestack = >k::Stack { + #[name(savestack)] + gtk::Stack { set_halign: gtk::Align::End, set_hexpand: true, - add_child: savebtn = >k::Button { + #[name(savebtn)] + gtk::Button { set_label: "Save", add_css_class: "suggested-action", #[watch] @@ -387,7 +398,8 @@ impl SimpleComponent for OptPageModel { sender.input(OptPageMsg::SaveConf) }, }, - add_child: spinner = >k::Spinner { + #[name(spinner)] + gtk::Spinner { #[watch] set_spinning: model.saving, }, diff --git a/src/ui/preferencespage.rs b/src/ui/preferencespage.rs index 455d642..3d30f1e 100644 --- a/src/ui/preferencespage.rs +++ b/src/ui/preferencespage.rs @@ -236,29 +236,29 @@ impl SimpleComponent for WelcomeModel { set_modal: true, #[watch] set_visible: !model.hidden, - #[wrap(Some)] - set_content = >k::Box { + gtk::Box { set_orientation: gtk::Orientation::Vertical, - append = >k::Box { + gtk::Box { set_valign: gtk::Align::Center, set_vexpand: true, set_orientation: gtk::Orientation::Vertical, set_spacing: 20, set_margin_all: 20, - append = >k::Box { + gtk::Box { set_orientation: gtk::Orientation::Vertical, set_spacing: 10, - append = >k::Label { + gtk::Label { add_css_class: "title-1", set_text: "Welcome the NixOS Configuration Editor", set_justify: gtk::Justification::Center, }, - append = >k::Label { + gtk::Label { add_css_class: "dim-label", set_text: "If your configuration file is not in the default location, you can change it here.", }, }, - append: confentry = >k::Entry { + #[name(confentry)] + gtk::Entry { set_width_chars: 20, #[track(model.changed(WelcomeModel::confpath()))] set_text: &model.confpath, @@ -267,7 +267,8 @@ impl SimpleComponent for WelcomeModel { set_hexpand: false, set_halign: gtk::Align::Center, }, - append: btn = >k::Button { + #[name(btn)] + gtk::Button { add_css_class: "pill", add_css_class: "suggested-action", set_label: "Continue", diff --git a/src/ui/rebuild.rs b/src/ui/rebuild.rs index ffebbc0..af5a94e 100644 --- a/src/ui/rebuild.rs +++ b/src/ui/rebuild.rs @@ -1,4 +1,4 @@ -use super::window::{AppModel, AppMsg}; +use super::window::AppMsg; use adw::prelude::*; use relm4::*; use sourceview5::prelude::*; @@ -63,68 +63,71 @@ impl SimpleComponent for RebuildModel { set_visible: !model.hidden, add_css_class: "dialog", add_css_class: "message", - #[wrap(Some)] - set_content = >k::Box { + gtk::Box { set_orientation: gtk::Orientation::Vertical, - append: statusstack = >k::Stack { + #[name(statusstack)] + gtk::Stack { set_margin_top: 20, set_transition_type: gtk::StackTransitionType::Crossfade, set_vhomogeneous: false, - add_child: building = >k::Box { + #[name(building)] + gtk::Box { set_orientation: gtk::Orientation::Vertical, set_spacing: 10, - append: spinner = >k::Spinner { + gtk::Spinner { set_spinning: true, set_height_request: 60, }, - append = >k::Label { + gtk::Label { set_label: "Building...", add_css_class: "title-1", }, }, - add_child: success = >k::Box { + #[name(success)] + gtk::Box { set_orientation: gtk::Orientation::Vertical, set_spacing: 10, - append = >k::Image { + gtk::Image { add_css_class: "success", set_icon_name: Some("object-select-symbolic"), set_pixel_size: 128, }, - append = >k::Label { + gtk::Label { set_label: "Done!", add_css_class: "title-1", }, - append = >k::Label { + gtk::Label { set_label: "Rebuild successful!", add_css_class: "dim-label", } }, - add_child: error = >k::Box { + #[name(error)] + gtk::Box { set_orientation: gtk::Orientation::Vertical, set_spacing: 10, - append = >k::Image { + gtk::Image { add_css_class: "error", set_icon_name: Some("dialog-error-symbolic"), set_pixel_size: 128, }, - append = >k::Label { + gtk::Label { set_label: "Error!", add_css_class: "title-1", }, - append = >k::Label { + gtk::Label { set_label: "Rebuild failed! See below for error message.", add_css_class: "dim-label", } } }, - append = >k::Frame { + gtk::Frame { set_margin_all: 20, - #[wrap(Some)] - set_child: scrollwindow = >k::ScrolledWindow { + #[name(scrollwindow)] + gtk::ScrolledWindow { set_max_content_height: 500, set_min_content_height: 100, - #[wrap(Some)] - set_child: outview = &sourceview5::View { + #[name(outview)] + sourceview5::View { set_editable: false, set_cursor_visible: false, set_monospace: true, @@ -144,13 +147,13 @@ impl SimpleComponent for RebuildModel { } } }, - append = >k::Box { + gtk::Box { add_css_class: "dialog-action-area", set_orientation: gtk::Orientation::Horizontal, set_homogeneous: true, #[track(model.changed(RebuildModel::status()))] set_visible: model.status != RebuildStatus::Building, - append = >k::Button { + gtk::Button { set_label: "Close", #[track(model.changed(RebuildModel::status()))] set_visible: model.status == RebuildStatus::Success, @@ -158,7 +161,7 @@ impl SimpleComponent for RebuildModel { sender.input(RebuildMsg::Save) } }, - append = >k::Button { + gtk::Button { add_css_class: "destructive-action", set_label: "Save Anyways", #[track(model.changed(RebuildModel::status()))] @@ -167,7 +170,7 @@ impl SimpleComponent for RebuildModel { sender.input(RebuildMsg::Save) } }, - append = >k::Button { + gtk::Button { set_label: "Reset Changes", #[track(model.changed(RebuildModel::status()))] set_visible: model.status == RebuildStatus::Error, @@ -175,7 +178,7 @@ impl SimpleComponent for RebuildModel { sender.input(RebuildMsg::Reset) } }, - append = >k::Button { + gtk::Button { set_label: "Keep Editing", #[track(model.changed(RebuildModel::status()))] set_visible: model.status == RebuildStatus::Error, diff --git a/src/ui/savechecking.rs b/src/ui/savechecking.rs index 5de2297..4d2a089 100644 --- a/src/ui/savechecking.rs +++ b/src/ui/savechecking.rs @@ -1,6 +1,5 @@ -use super::optionpage::*; -use super::window::{AppModel, AppMsg}; -use crate::ui::optionpage::{OptPageMsg}; +use super::window::AppMsg; +use crate::ui::optionpage::OptPageMsg; use adw::prelude::*; use log::{debug, info}; use relm4::*; @@ -153,8 +152,7 @@ impl SimpleComponent for SaveErrorModel { set_margin_end: 20, gtk::ScrolledWindow { set_vscrollbar_policy: gtk::PolicyType::Never, - #[wrap(Some)] - set_child = &sourceview5::View { + sourceview5::View { set_vexpand: true, set_editable: false, set_cursor_visible: false, diff --git a/src/ui/searchentry.rs b/src/ui/searchentry.rs index 83a56e4..2dad806 100644 --- a/src/ui/searchentry.rs +++ b/src/ui/searchentry.rs @@ -49,17 +49,16 @@ impl SimpleComponent for SearchEntryModel { x.grab_focus(); } }, - #[wrap(Some)] - set_child: main_box = >k::Box { + #[name(main_box)] + gtk::Box { set_orientation: gtk::Orientation::Vertical, - append = &adw::Clamp { - #[wrap(Some)] - set_child = >k::Box { + adw::Clamp { + gtk::Box { set_margin_start: 15, set_margin_end: 15, set_spacing: 15, set_orientation: gtk::Orientation::Vertical, - append = &adw::PreferencesGroup { + adw::PreferencesGroup { #[local_ref] add = datalistbox -> gtk::ListBox { add_css_class: "boxed-list", @@ -67,7 +66,7 @@ impl SimpleComponent for SearchEntryModel { #[watch] set_visible: !model.data.is_empty(), }, - append = &adw::PreferencesGroup { + adw::PreferencesGroup { #[local_ref] add = nameoptslistbox -> gtk::ListBox { set_margin_bottom: 15, diff --git a/src/ui/searchfactory.rs b/src/ui/searchfactory.rs index 3176556..19f9de0 100644 --- a/src/ui/searchfactory.rs +++ b/src/ui/searchfactory.rs @@ -24,14 +24,14 @@ impl FactoryComponent for SearchOption { set_orientation: gtk::Orientation::Horizontal, set_spacing: 6, set_margin_all: 15, - append = >k::Label { + gtk::Label { set_text: &self.value.join("."), }, - append = >k::Separator { + gtk::Separator { set_hexpand: true, set_opacity: 0.0, }, - append = >k::Image { + gtk::Image { set_icon_name: Some("object-select-symbolic"), set_visible: self.configured, }, diff --git a/src/ui/searchpage.rs b/src/ui/searchpage.rs index df0fedd..7f57626 100644 --- a/src/ui/searchpage.rs +++ b/src/ui/searchpage.rs @@ -26,7 +26,8 @@ impl SimpleComponent for SearchPageModel { view! { view = gtk::Stack { set_transition_type: gtk::StackTransitionType::Crossfade, - add_child: options = &adw::PreferencesPage { + #[name(options)] + adw::PreferencesPage { set_title: "Attributes", add = &adw::PreferencesGroup { set_title: "Options", @@ -44,10 +45,11 @@ impl SimpleComponent for SearchPageModel { }, } }, - add_child: empty = >k::Box { + #[name(empty)] + gtk::Box { set_orientation: gtk::Orientation::Vertical, set_valign: gtk::Align::Center, - append = &adw::StatusPage { + adw::StatusPage { set_icon_name: Some("edit-find-symbolic"), set_title: "No options found!", set_description: Some("Try a different search"), diff --git a/src/ui/treefactory.rs b/src/ui/treefactory.rs index 65084f0..3dafcf5 100644 --- a/src/ui/treefactory.rs +++ b/src/ui/treefactory.rs @@ -27,7 +27,7 @@ impl FactoryComponent for AttrPos { set_orientation: gtk::Orientation::Horizontal, set_spacing: 6, set_margin_all: 15, - append = >k::Label { + gtk::Label { set_text: &{ if self.replacefor == Some(String::from("*")) { format!("[{}]", self.value.last().unwrap_or(&String::new())) @@ -37,11 +37,11 @@ impl FactoryComponent for AttrPos { }, set_use_markup: true, }, - append = >k::Separator { + gtk::Separator { set_hexpand: true, set_opacity: 0.0, }, - append = >k::Image { + gtk::Image { set_icon_name: if self.modified { Some("system-run-symbolic") } else { Some("object-select-symbolic") }, set_visible: self.configured || self.modified, }, @@ -90,16 +90,16 @@ impl FactoryComponent for OptPos { set_orientation: gtk::Orientation::Horizontal, set_spacing: 6, set_margin_all: 15, - append = >k::Label { + gtk::Label { set_text: &{ self.value.last().unwrap_or(&String::new()).to_string() }, }, - append = >k::Separator { + gtk::Separator { set_hexpand: true, set_opacity: 0.0, }, - append = >k::Image { + gtk::Image { set_icon_name: if self.modified { Some("system-run-symbolic") } else { Some("object-select-symbolic") }, set_visible: self.configured || self.modified, }, diff --git a/src/ui/window.rs b/src/ui/window.rs index 4d5a9da..241e8a5 100644 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -1,18 +1,13 @@ -use super::about; use super::about::AboutModel; -use super::nameentry; use super::nameentry::NameEntryModel; -use super::optionpage; use super::optionpage::*; use super::preferencespage::PrefModel; use super::preferencespage::WelcomeModel; use super::preferencespage::WelcomeMsg; -use super::quitdialog; use super::quitdialog::QuitInit; use super::rebuild::RebuildModel; use super::savechecking::SaveErrorModel; use super::savechecking::SaveErrorMsg; -use super::searchentry; use super::searchentry::SearchEntryModel; use super::windowloading::LoadErrorModel; use super::windowloading::WindowAsyncHandler; @@ -39,8 +34,8 @@ use crate::ui::searchentry::SearchEntryMsg; use crate::ui::windowloading::LoadErrorMsg; use adw::prelude::*; use log::*; -use relm4::{actions::*, factory::*, *}; use relm4::gtk::glib::object::Cast; +use relm4::{actions::*, factory::*, *}; use std::collections::HashMap; use std::convert::identity; @@ -185,19 +180,21 @@ impl SimpleComponent for AppModel { set_content: main_box = >k::Box { set_orientation: gtk::Orientation::Vertical, - append = &adw::HeaderBar { + adw::HeaderBar { #[wrap(Some)] set_title_widget: headerstack = >k::Stack { set_transition_type: gtk::StackTransitionType::Crossfade, - add_child: title = >k::Label { + #[name(title)] + gtk::Label { set_label: "NixOS Configuration Editor", }, - - add_child: buttons = >k::Box { + + #[name(buttons)] + gtk::Box { set_orientation: gtk::Orientation::Horizontal, set_halign: gtk::Align::Center, add_css_class: "linked", - + #[local_ref] buttonsbox -> gtk::Box { #[local] @@ -211,7 +208,9 @@ impl SimpleComponent for AppModel { add_css_class: "linked", } }, - add_child: search = >k::SearchEntry { + + #[name(search)] + gtk::SearchEntry { add_css_class: "inline", set_placeholder_text: Some("Search"), set_halign: gtk::Align::Center, @@ -219,9 +218,9 @@ impl SimpleComponent for AppModel { //set_search_delay: 500, // Change once gtk4-rs 4.8 is out connect_search_changed[sender] => move |x| { if x.text().is_empty() { - send!(sender, AppMsg::HideSearchPage); + sender.input(AppMsg::HideSearchPage); } else { - send!(sender, AppMsg::ShowSearchPage(x.text().to_string())); + sender.input(AppMsg::ShowSearchPage(x.text().to_string())); } }, }, @@ -237,7 +236,7 @@ impl SimpleComponent for AppModel { set_active: model.header == HeaderBar::Search, set_icon_name: "edit-find-symbolic", connect_toggled[sender] => move |x| { - send!(sender, { + sender.input({ if x.is_active() { AppMsg::ShowSearch } else { @@ -249,27 +248,29 @@ impl SimpleComponent for AppModel { pack_start = >k::Button { set_label: "Rebuild", connect_clicked[sender] => move |_| { - send!(sender, AppMsg::Rebuild); + sender.input(AppMsg::Rebuild); }, } }, #[name(stack)] gtk::Stack { - // set_transition_type: gtk::StackTransitionType::Crossfade, - add_child: loading = >k::Box { + #[name(loading)] + gtk::Box { set_orientation: gtk::Orientation::Vertical, set_halign: gtk::Align::Center, set_valign: gtk::Align::Center, set_spacing: 10, - append = >k::Spinner { + gtk::Spinner { + #[watch] set_spinning: true, set_height_request: 80, }, - append = >k::Label { + gtk::Label { set_label: "Loading...", }, }, - add_child: treeview = &adw::PreferencesPage { + #[name(treeview)] + adw::PreferencesPage { add: attrgroup = &adw::PreferencesGroup { set_title: "Attributes", #[track(model.changed(AppModel::position()))] @@ -285,7 +286,7 @@ impl SimpleComponent for AppModel { #[wrap(Some)] set_child = >k::Box { set_margin_all: 15, - append = >k::Image { + gtk::Image { set_halign: gtk::Align::Center, set_hexpand: true, set_icon_name: Some("list-add-symbolic"), @@ -293,15 +294,14 @@ impl SimpleComponent for AppModel { } } }, - // factory!(model.attributes), connect_row_activated[sender] => move |_, y| { if let Ok(l) = y.clone().downcast::() { if l.title() != "" { let text = l.title().to_string(); let v = text.split('.').map(|x| x.to_string()).collect::>(); - send!(sender, AppMsg::MoveToRow(v)); + sender.input(AppMsg::MoveToRow(v)); } else { - send!(sender, AppMsg::AddAttr); + sender.input(AppMsg::AddAttr); } } }, @@ -325,7 +325,8 @@ impl SimpleComponent for AppModel { }, } }, - add_child: optpage = >k::Box { + #[name(optpage)] + gtk::Box { append: model.optionpage.widget() }, add_titled: (model.searchpage.widget(), Some("SearchPage"), "SearchPage") @@ -460,7 +461,7 @@ impl SimpleComponent for AppModel { let group = RelmActionGroup::::new(); let sender = sender.clone(); let prefaction: RelmAction = RelmAction::new_stateless(move |_| { - send!(sender, AppMsg::ShowPrefMenu); + sender.input(AppMsg::ShowPrefMenu); }); let aboutsender = model.about.sender().clone(); @@ -478,7 +479,7 @@ impl SimpleComponent for AppModel { let sender = sender.clone(); let group = RelmActionGroup::::new(); let searchaction: RelmAction = RelmAction::new_stateless(move |_| { - send!(sender, AppMsg::ToggleSearch); + sender.input(AppMsg::ToggleSearch); }); group.add_action(searchaction); let actions = group.into_action_group(); @@ -489,12 +490,9 @@ impl SimpleComponent for AppModel { { let sender = sender.clone(); adw::StyleManager::default() - .connect_dark_notify(move |x| send!(sender, AppMsg::SetDarkMode(x.is_dark()))); + .connect_dark_notify(move |x| sender.input(AppMsg::SetDarkMode(x.is_dark()))); } - send!( - sender, - AppMsg::SetDarkMode(adw::StyleManager::default().is_dark()) - ); + sender.input(AppMsg::SetDarkMode(adw::StyleManager::default().is_dark())); ComponentParts { model, widgets } } @@ -560,10 +558,10 @@ impl SimpleComponent for AppModel { } AppMsg::MoveToSelf => { info!("Received AppMsg::MoveToSelf"); - send!( - sender, - AppMsg::MoveTo(self.position.clone(), self.refposition.clone()) - ); + sender.input(AppMsg::MoveTo( + self.position.clone(), + self.refposition.clone(), + )); } AppMsg::MoveToRow(pos) => { info!("Received AppMsg::MoveToRow"); @@ -577,10 +575,7 @@ impl SimpleComponent for AppModel { match attrvec.iter().find(|x| x.value == pos) { Some(x) => { debug!("FOUND ATTR: {:?}", x); - send!( - sender, - AppMsg::MoveTo(x.value.to_vec(), x.refvalue.to_vec()) - ); + sender.input(AppMsg::MoveTo(x.value.to_vec(), x.refvalue.to_vec())); } None => { error!("Received AppMsg::MoveToRow, but no attribute found"); @@ -620,12 +615,11 @@ impl SimpleComponent for AppModel { options_guard.push_back(OptPos { value: o, refvalue: r, - configured: if pos.eq(&newref) { opconfigured(&self.conf, &pos, op.clone()) } else { opconfigured2( - &self.configpath, - &pos, - &newref, - op.clone(), - ) }, + configured: if pos.eq(&newref) { + opconfigured(&self.conf, &pos, op.clone()) + } else { + opconfigured2(&self.configpath, &pos, &newref, op.clone()) + }, modified: opconfigured(&self.editedopts, &pos, op), }); } @@ -719,12 +713,16 @@ impl SimpleComponent for AppModel { attributes.push(AttrPos { value: p, refvalue: r, - configured: if pos.eq(&newref) { opconfigured(&self.conf, &pos, attr.to_string()) } else { opconfigured2( - &self.configpath, - &pos, - &newref, - attr.to_string(), - ) }, + configured: if pos.eq(&newref) { + opconfigured(&self.conf, &pos, attr.to_string()) + } else { + opconfigured2( + &self.configpath, + &pos, + &newref, + attr.to_string(), + ) + }, modified: opconfigured( &self.editedopts, &newref, @@ -860,10 +858,7 @@ impl SimpleComponent for AppModel { match optvec.iter().find(|x| x.value == pos) { Some(x) => { - send!( - sender, - AppMsg::OpenOption(x.value.to_vec(), x.refvalue.to_vec()) - ); + sender.input(AppMsg::OpenOption(x.value.to_vec(), x.refvalue.to_vec())); } None => { error!("Received AppMsg::OpenOptionRow, but no options found"); @@ -886,9 +881,9 @@ impl SimpleComponent for AppModel { AppMsg::ToggleSearch if !self.busy => { info!("Received AppMsg::ToggleSearch"); if self.header == HeaderBar::Search { - send!(sender, AppMsg::HideSearch); + sender.input(AppMsg::HideSearch); } else { - send!(sender, AppMsg::ShowSearch); + sender.input(AppMsg::ShowSearch); } } AppMsg::ShowSearchPage(s) if !self.busy => { @@ -1004,10 +999,10 @@ impl SimpleComponent for AppModel { info!("Received AppMsg::ResetConfig"); self.update_editedopts(|x| x.clear()); if self.page == Page::Option { - send!( - sender, - AppMsg::OpenOption(self.position.clone(), self.refposition.clone()) - ); + sender.input(AppMsg::OpenOption( + self.position.clone(), + self.refposition.clone(), + )); } } AppMsg::SaveConfig => { @@ -1016,23 +1011,20 @@ impl SimpleComponent for AppModel { let conf = match parseconfig(&self.configpath) { Ok(x) => x, Err(_) => { - send!( - sender, - AppMsg::LoadError( - String::from("Error loading configuration file"), - format!( - "{} may be an invalid configuration file", - self.configpath - ) - ) - ); + sender.input(AppMsg::LoadError( + String::from("Error loading configuration file"), + format!( + "{} may be an invalid configuration file", + self.configpath + ), + )); return; } }; self.set_conf(conf); - send!(sender, AppMsg::SetBusy(true)); + sender.input(AppMsg::SetBusy(true)); self.set_page(Page::Loading); - send!(sender, AppMsg::TryLoad); + sender.input(AppMsg::TryLoad); } AppMsg::ShowPrefMenu => { info!("Received AppMsg::ShowPrefMenu"); @@ -1073,7 +1065,7 @@ impl SimpleComponent for AppModel { self.update_starattrs(|x| { x.insert(pos.to_string(), *x.get(&pos).unwrap_or(&0) + 1); }); - send!(sender, AppMsg::MoveToSelf); + sender.input(AppMsg::MoveToSelf); } AddAttrOptions::None => { error!("Cannot add attribute without name or star"); @@ -1100,7 +1092,7 @@ impl SimpleComponent for AppModel { } }); debug!("ADD NEW {:?}", self.nameattrs); - send!(sender, AppMsg::MoveToSelf); + sender.input(AppMsg::MoveToSelf); } AppMsg::AddStar(pos) => { info!("Received AppMsg::AddStar"); diff --git a/src/ui/windowloading.rs b/src/ui/windowloading.rs index 6b4baae..6ceb6ae 100644 --- a/src/ui/windowloading.rs +++ b/src/ui/windowloading.rs @@ -63,12 +63,8 @@ impl Worker for WindowAsyncHandler { } }; sender.output(AppMsg::InitialLoad(LoadValues { data, tree, conf })) - // }).drop_on_shutdown(); - // }) } WindowAsyncHandlerMsg::GetConfigPath => { - // sender.command(|out, shutdown| { - // shutdown.register(async move { if let Ok(false) = configexists() { sender.output(AppMsg::Welcome); return;