Skip to content

Commit

Permalink
Clean up new relm4 macros
Browse files Browse the repository at this point in the history
  • Loading branch information
vlinkz committed Jul 30, 2022
1 parent 2a7e8ab commit b649b63
Show file tree
Hide file tree
Showing 15 changed files with 176 additions and 177 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "nixos-conf-editor"
version = "0.0.3"
version = "0.0.4"
edition = "2021"
default-run = "nixos-conf-editor"

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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; [
Expand Down Expand Up @@ -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 ]}'
'';
Expand Down
2 changes: 1 addition & 1 deletion src/ui/about.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl SimpleComponent for AboutModel {
ComponentParts { model, widgets }
}

fn update(&mut self, msg: Self::Input, sender: &ComponentSender<Self>) {
fn update(&mut self, msg: Self::Input, _sender: &ComponentSender<Self>) {
match msg {
AboutMsg::Show => {
self.hidden = false;
Expand Down
70 changes: 41 additions & 29 deletions src/ui/optionpage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl SimpleComponent for OptPageModel {
set_spacing: 15,
set_vexpand: true,
add_css_class: "labels",
append = &gtk::Label {
gtk::Label {
set_margin_top: 5,
set_margin_bottom: 5,
set_halign: gtk::Align::Start,
Expand Down Expand Up @@ -186,26 +186,27 @@ impl SimpleComponent for OptPageModel {
},
},

append = &gtk::Box {
gtk::Box {
set_orientation: gtk::Orientation::Vertical,
set_spacing: 10,
#[watch]
set_visible: model.data.example.is_some(),
append: example_box = &gtk::Box {
#[name(example_box)]
gtk::Box {
set_orientation: gtk::Orientation::Horizontal,
add_css_class: "header",
add_css_class: "single-line",
append: example_header = &gtk::Label {
#[name(example_header)]
gtk::Label {
set_halign: gtk::Align::Start,
add_css_class: "heading",
add_css_class: "h4",
set_label: "Example",
}
},
append = &gtk::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,
Expand Down Expand Up @@ -237,16 +238,17 @@ impl SimpleComponent for OptPageModel {
},
},
},
append = &gtk::Separator {
gtk::Separator {
set_opacity: 0.0,
set_margin_top: 5,
},
append = &gtk::Box {
gtk::Box {
#[watch]
set_visible: valuestack.is_child_visible(),
set_orientation: gtk::Orientation::Vertical,
set_spacing: 10,
append: simplevalue_box = &gtk::Box {
#[name(simplevalue_box)]
gtk::Box {
set_orientation: gtk::Orientation::Horizontal,
add_css_class: "header",
add_css_class: "single-line",
Expand All @@ -256,8 +258,10 @@ impl SimpleComponent for OptPageModel {
set_label: "Value",
}
},
append: valuestack = &gtk::Stack {
add_child: number = &gtk::SpinButton {
#[name(valuestack)]
gtk::Stack {
#[name(number)]
gtk::SpinButton {
set_halign: gtk::Align::Start,
set_adjustment: &gtk::Adjustment::new(0.0, f64::MIN, f64::MAX, 1.0, 5.0, 0.0),
set_climb_rate: 1.0,
Expand All @@ -268,26 +272,30 @@ impl SimpleComponent for OptPageModel {
}
},
},
add_child: stringentry = &gtk::Entry {
#[name(stringentry)]
gtk::Entry {
set_halign: gtk::Align::Start,
connect_changed[sender] => move |x| {
if x.is_sensitive() {
sender.input(OptPageMsg::UpdateConfMod(format!("\"{}\"", x.text())));
}
},
},
add_child: truefalse = &gtk::Box {
#[name(truefalse)]
gtk::Box {
add_css_class: "linked",
set_orientation: gtk::Orientation::Horizontal,
append: truebtn = &gtk::ToggleButton {
#[name(truebtn)]
gtk::ToggleButton {
set_label: "True",
connect_toggled[sender] => move |x| {
if x.is_active() {
sender.input(OptPageMsg::UpdateConfMod(String::from("true")))
}
}
},
append: falsebtn = &gtk::ToggleButton {
#[name(falsebtn)]
gtk::ToggleButton {
set_label: "False",
set_group: Some(&truebtn),
connect_toggled[sender] => move |x| {
Expand All @@ -296,31 +304,32 @@ impl SimpleComponent for OptPageModel {
}
}
},
// append: nullbtn = &gtk::ToggleButton {
// #[name(nullbtn)]
// gtk::ToggleButton {
// set_label: "null",
// set_group: Some(&truebtn),
// }
},
}
},

append = &gtk::Box {
gtk::Box {
set_orientation: gtk::Orientation::Vertical,
set_spacing: 10,
append: value_box = &gtk::Box {
#[name(value_box)]
gtk::Box {
set_orientation: gtk::Orientation::Horizontal,
add_css_class: "header",
add_css_class: "single-line",
append = &gtk::Label {
gtk::Label {
set_halign: gtk::Align::Start,
add_css_class: "heading",
set_label: "Attribute Value",
}
},
append = &gtk::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,
Expand Down Expand Up @@ -356,29 +365,31 @@ impl SimpleComponent for OptPageModel {
}
},
},
append = &gtk::Box {
gtk::Box {
set_orientation: gtk::Orientation::Horizontal,
set_spacing: 10,
append = &gtk::Button {
gtk::Button {
set_label: "Reset",
#[watch]
set_sensitive: model.conf != model.modifiedconf,
connect_clicked[sender] => move |_| {
sender.input(OptPageMsg::ResetConf)
}
},
append = &gtk::Button {
gtk::Button {
set_label: "Clear",
#[watch]
set_sensitive: !model.modifiedconf.is_empty(),
connect_clicked[sender] => move |_| {
sender.input(OptPageMsg::ClearConf)
}
},
append: savestack = &gtk::Stack {
#[name(savestack)]
gtk::Stack {
set_halign: gtk::Align::End,
set_hexpand: true,
add_child: savebtn = &gtk::Button {
#[name(savebtn)]
gtk::Button {
set_label: "Save",
add_css_class: "suggested-action",
#[watch]
Expand All @@ -387,7 +398,8 @@ impl SimpleComponent for OptPageModel {
sender.input(OptPageMsg::SaveConf)
},
},
add_child: spinner = &gtk::Spinner {
#[name(spinner)]
gtk::Spinner {
#[watch]
set_spinning: model.saving,
},
Expand Down
17 changes: 9 additions & 8 deletions src/ui/preferencespage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,29 +236,29 @@ impl SimpleComponent for WelcomeModel {
set_modal: true,
#[watch]
set_visible: !model.hidden,
#[wrap(Some)]
set_content = &gtk::Box {
gtk::Box {
set_orientation: gtk::Orientation::Vertical,
append = &gtk::Box {
gtk::Box {
set_valign: gtk::Align::Center,
set_vexpand: true,
set_orientation: gtk::Orientation::Vertical,
set_spacing: 20,
set_margin_all: 20,
append = &gtk::Box {
gtk::Box {
set_orientation: gtk::Orientation::Vertical,
set_spacing: 10,
append = &gtk::Label {
gtk::Label {
add_css_class: "title-1",
set_text: "Welcome the NixOS Configuration Editor",
set_justify: gtk::Justification::Center,
},
append = &gtk::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 = &gtk::Entry {
#[name(confentry)]
gtk::Entry {
set_width_chars: 20,
#[track(model.changed(WelcomeModel::confpath()))]
set_text: &model.confpath,
Expand All @@ -267,7 +267,8 @@ impl SimpleComponent for WelcomeModel {
set_hexpand: false,
set_halign: gtk::Align::Center,
},
append: btn = &gtk::Button {
#[name(btn)]
gtk::Button {
add_css_class: "pill",
add_css_class: "suggested-action",
set_label: "Continue",
Expand Down
Loading

0 comments on commit b649b63

Please sign in to comment.