added UI for `pijul change`

CrepeGoat
Oct 12, 2024, 4:57 AM
F6YAQWVDXG6UZBJPJDTIJBQDBMXVMT7P6INK6GPJ5SR3BDDRX4EQC

Dependencies

  • [2] 337EO2TU add selection callback to changelog UI (& fix deselection)
  • [3] SOTD66FO set Changelog UI to display log from selected channel in ChannelsList UI
  • [4] HZV5P57Y changed channel and log views to use `ListView` (looks much cleaner)
  • [5] XERTHGSY consolidated `pijul log` UI elements into their own component
  • [6] IQY5LHEN add GUI element to display simple `pijul log` results
  • [7] G2CHQAOP parsed `pijul log` text blob into individual entries & fields
  • [*] NSE6BLWA init slint project from https://github.com/slint-ui/slint-rust-template
  • [*] PL4TK55O added command-line argument to specify executable path
  • [*] 4RPYR65C connect GUI to pijul to display simple channel list
  • [*] NCRTU7M4 cargo init
  • [*] 6ECOC7L5 parsed `pijul channel` text blob into individual UI components

Change contents

  • edit in ui/app-window.slint at line 11
    [4.170]
    [4.0]
    component DeltasList {
    in property <string> delta;
    VerticalBox {
    Text {
    vertical-stretch: 0;
    text: "change";
    }
  • edit in ui/app-window.slint at line 21
    [4.1]
    [4.170]
    ScrollView {
    vertical-stretch: 1;
    viewport-width <=> text.width;
    viewport-height <=> text.height;
    text := Text {
    width: 100%;
    text: delta;
    }
    }
    }
    }
  • replacement in ui/app-window.slint at line 94
    [4.281][4.281:317]()
    preferred-width: 500px;
    [4.281]
    [2.264]
    // preferred-width: 400px;
  • edit in ui/app-window.slint at line 191
    [9.161]
    [10.0]
    preferred-width: 960px;
    preferred-height: 720px;
  • edit in ui/app-window.slint at line 199
    [4.606]
    [11.47]
    in-out property <string> delta <=> deltas.delta;
  • edit in ui/app-window.slint at line 202
    [3.42]
    [4.168]
    callback request-change-delta(string);
  • edit in ui/app-window.slint at line 211
    [3.113]
    [9.454]
    if log.selected >= 0 {
    root.request-change-delta(changes_log[log.selected].hash)
    } else {
    delta = "";
    }
  • edit in ui/app-window.slint at line 222
    [3.148]
    [3.148]
    horizontal-stretch: 0;
  • replacement in ui/app-window.slint at line 228
    [4.873][4.644:677]()
    log := Changelog { }
    [4.873]
    [4.1007]
    log := Changelog {
    horizontal-stretch: 2;
    selection-changed => {
    if log.selected >= 0 {
    root.request-change-delta(changes_log[log.selected].hash)
    } else {
    delta = "";
    }
    }
    }
    deltas := DeltasList {
    horizontal-stretch: 3;
    }
  • edit in src/main.rs at line 92
    [4.1836]
    [9.1019]
    }
    });
    ui.on_request_change_delta({
    let ui_handle = ui.as_weak();
    move |change_hash: SharedString| {
    let change_hash = change_hash.as_str();
    let ui = ui_handle.unwrap();
    let exe_path_string = ui.get_exe_path();
    let exe_path = Path::new(exe_path_string.as_str());
    let repo_path_string = ui.get_repo_path();
    let repo_path = Path::new(repo_path_string.as_str());
    let change_output = cmds::change(exe_path, repo_path, change_hash);
    let delta = match change_output {
    Ok(delta) => delta,
    Err(e) => {
    println!("{:?}", e);
    return;
    }
    };
    ui.set_delta((&String::from(delta)[..]).into());
  • edit in src/cmds.rs at line 51
    [4.2058]
    [11.1342]
    }
    pub fn change(exe: &std::path::Path, repo: &std::path::Path, hash: &str) -> Result<String, Error> {
    let mut cmd = Command::new(exe);
    let cmd = cmd
    .arg("change")
    .arg("--no-prompt")
    .arg("--repository")
    .arg(repo)
    .arg(hash);
    let output = cmd.output()?;
    check_exit_status(cmd, output.status)?;
    // TODO this will fail when diffing binary data
    Ok(String::from_utf8(output.stdout)?)
  • edit in src/cmds.rs at line 67
    [11.1345]
    [11.1345]
    ///////////////////////////////////////////////////////////////////////////////
    // copied from https://users.rust-lang.org/t/best-error-handing-practices-when-using-std-command/42259/7
  • edit in src/cmds.rs at line 87
    [13.2202]
    [13.2202]
    // end copy
    ///////////////////////////////////////////////////////////////////////////////