add GUI element to display simple `pijul log` results

CrepeGoat
Oct 9, 2024, 3:42 AM
IQY5LHEN34KNUOZ75S5V5LZDZQCZ65LV7YXXRYJMIE6WSXMKFMXAC

Dependencies

  • [2] 4RPYR65C connect GUI to pijul to display simple channel list
  • [3] NSE6BLWA init slint project from https://github.com/slint-ui/slint-rust-template
  • [*] NCRTU7M4 cargo init

Change contents

  • replacement in ui/app-window.slint at line 1
    [3.57][3.58:115]()
    import { Button, VerticalBox } from "std-widgets.slint";
    [3.57]
    [3.115]
    import { Button, VerticalBox, HorizontalBox, ScrollView } from "std-widgets.slint";
  • edit in ui/app-window.slint at line 5
    [2.47]
    [2.47]
    in-out property <string> changes_log: "";
  • replacement in ui/app-window.slint at line 7
    [2.84][3.239:272](),[3.239][3.239:272](),[3.272][2.85:139](),[2.139][3.318:328](),[3.318][3.318:328]()
    VerticalBox {
    Text {
    text: "channels: \n\{root.channel_list}";
    }
    [2.84]
    [3.328]
    callback request-changes-log();
    width: 600px;
    height: 400px;
  • edit in ui/app-window.slint at line 12
    [3.329]
    [3.329]
    VerticalBox {
  • edit in ui/app-window.slint at line 14
    [3.346]
    [2.140]
    vertical-stretch: 0;
  • edit in ui/app-window.slint at line 18
    [2.215]
    [3.454]
    root.request-changes-log();
  • edit in ui/app-window.slint at line 21
    [3.478]
    [3.478]
    HorizontalBox {
    vertical-stretch: 1;
    VerticalBox {
    alignment: start;
    preferred-width: 150px;
    Text {
    text: "channels";
    }
    Text {
    text: "\{root.channel_list}";
    }
    }
    ScrollView {
    VerticalBox {
    alignment: start;
    preferred-width: 500px;
    Text {
    text: "log";
    }
    Text {
    text: "\{root.changes_log}";
    }
    }
    }
    }
  • replacement in src/main.rs at line 9
    [2.269][2.269:288]()
    use cmds::channel;
    [2.269]
    [2.288]
    use cmds::{channel, log};
  • edit in src/main.rs at line 34
    [2.884]
    [3.1019]
    }
    });
    ui.on_request_changes_log({
    let ui_handle = ui.as_weak();
    move || {
    let ui = ui_handle.unwrap();
    let log_output = log(
    Path::new("/Users/beckerawqatty/.nix-profile/bin/pijul"),
    Path::new("/Users/beckerawqatty/Repos/pijul-gui/"),
    );
    let log = match log_output {
    Ok(log) => log,
    Err(e) => {
    println!("{:?}", e);
    return;
    }
    };
    ui.set_changes_log(SharedString::from(&log));
  • edit in src/cmds.rs at line 8
    [2.1147]
    [2.1147]
    .arg("--no-prompt")
    .arg("--repository")
    .arg(repo);
    let output = cmd.output()?;
    check_exit_status(cmd, output.status)?;
    Ok(String::from_utf8(output.stdout)?)
    }
    pub fn log(exe: &std::path::Path, repo: &std::path::Path) -> Result<String, Error> {
    let mut cmd = Command::new(exe);
    let cmd = cmd
    .arg("log")