-
Notifications
You must be signed in to change notification settings - Fork 0
feat: linux back-end abstraction #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -234,6 +234,10 @@ pub fn run(capture: CaptureResult, settings: Settings, current_mode: CaptureMode | |
| close_after_copy_toggle.set_active(settings.borrow().close_after_copy); | ||
| close_after_copy_toggle | ||
| .set_tooltip_text(Some("Close the editor immediately after Ctrl+C or Copy.")); | ||
| let close_after_save_toggle = gtk::CheckButton::with_label("Close After Save"); | ||
| close_after_save_toggle.set_active(settings.borrow().close_after_save); | ||
| close_after_save_toggle | ||
| .set_tooltip_text(Some("Close the editor immediately after Save or Save As.")); | ||
| let open_after_save_toggle = gtk::CheckButton::with_label("Open After Save"); | ||
| open_after_save_toggle.set_active(settings.borrow().open_after_save); | ||
| open_after_save_toggle | ||
|
|
@@ -278,15 +282,20 @@ pub fn run(capture: CaptureResult, settings: Settings, current_mode: CaptureMode | |
| let c = canvas.clone(); | ||
| let s = Rc::clone(&settings); | ||
| let status_label = status_label.clone(); | ||
| let app = app.clone(); | ||
| save_btn.connect_clicked(move |_| { | ||
| if let Ok(png) = c.render_png() { | ||
| let cfg = s.borrow(); | ||
| if let Ok(path) = export::save_capture(&png, &cfg, current_mode) { | ||
| let close_after_save = cfg.close_after_save; | ||
| c.mark_saved(); | ||
| let _ = export::maybe_open_saved_path(&path, &cfg); | ||
| status_label | ||
| .set_text(&format!("Saved annotated image to {}.", path.display())); | ||
| eprintln!("Saved annotated image: {}", path.display()); | ||
| if close_after_save { | ||
| app.quit(); | ||
| } | ||
|
Comment on lines
+285
to
+298
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major | 🏗️ Heavy lift Please add coverage for the new close-after-save branches. Both save paths now have extra quit behavior, but there’s no inline regression coverage for either branch. Even a small extracted post-save helper would make this much easier to test and would keep future save-flow changes safer. As per coding guidelines, "Add Rust unit tests inline under Also applies to: 803-845 🤖 Prompt for AI Agents |
||
| } else { | ||
| status_label.set_text("Saving failed. Check the terminal for details."); | ||
| } | ||
|
|
@@ -312,6 +321,14 @@ pub fn run(capture: CaptureResult, settings: Settings, current_mode: CaptureMode | |
| let _ = settings_service::save(&guard); | ||
| }); | ||
| } | ||
| { | ||
| let s = Rc::clone(&settings); | ||
| close_after_save_toggle.connect_toggled(move |toggle| { | ||
| let mut guard = s.borrow_mut(); | ||
| guard.close_after_save = toggle.is_active(); | ||
| let _ = settings_service::save(&guard); | ||
| }); | ||
| } | ||
| { | ||
| let s = Rc::clone(&settings); | ||
| open_after_save_toggle.connect_toggled(move |toggle| { | ||
|
|
@@ -491,6 +508,7 @@ pub fn run(capture: CaptureResult, settings: Settings, current_mode: CaptureMode | |
| inspector.append(&export_settings_title); | ||
| inspector.append(&folder_btn); | ||
| inspector.append(&close_after_copy_toggle); | ||
| inspector.append(&close_after_save_toggle); | ||
| inspector.append(&open_after_save_toggle); | ||
|
|
||
| shell.append(&tools_panel); | ||
|
|
@@ -513,8 +531,9 @@ pub fn run(capture: CaptureResult, settings: Settings, current_mode: CaptureMode | |
| let s = Rc::clone(&settings); | ||
| let status_label = status_label.clone(); | ||
| let window = window.clone(); | ||
| let app = app.clone(); | ||
| save_as_btn.connect_clicked(move |_| { | ||
| prompt_save_as(&window, &c, &s, &status_label, current_mode); | ||
| prompt_save_as(&window, &c, &s, &status_label, &app, current_mode); | ||
| }); | ||
| } | ||
| { | ||
|
|
@@ -786,6 +805,7 @@ fn prompt_save_as( | |
| canvas: &EditorCanvas, | ||
| settings: &Rc<RefCell<Settings>>, | ||
| status_label: >k::Label, | ||
| app: &adw::Application, | ||
| current_mode: CaptureMode, | ||
| ) { | ||
| let cfg = settings.borrow().clone(); | ||
|
|
@@ -804,6 +824,7 @@ fn prompt_save_as( | |
| let canvas = canvas.clone(); | ||
| let settings = Rc::clone(settings); | ||
| let status_label = status_label.clone(); | ||
| let app = app.clone(); | ||
| dialog.run_async(move |dialog, response| { | ||
| if response == gtk::ResponseType::Accept { | ||
| if let Some(file) = dialog.file() { | ||
|
|
@@ -813,11 +834,15 @@ fn prompt_save_as( | |
| Ok(()) => { | ||
| canvas.mark_saved(); | ||
| let cfg = settings.borrow(); | ||
| let close_after_save = cfg.close_after_save; | ||
| let _ = export::maybe_open_saved_path(&path, &cfg); | ||
| status_label.set_text(&format!( | ||
| "Saved annotated image to {}.", | ||
| path.display() | ||
| )); | ||
| if close_after_save { | ||
| app.quit(); | ||
| } | ||
| } | ||
| Err(err) => { | ||
| status_label.set_text(&format!("Save As failed: {err}")); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,10 @@ pub fn run(mode: CaptureMode, settings: &Settings) -> AppResult<CaptureExecution | |
| ) | ||
| } | ||
|
|
||
| #[expect( | ||
| clippy::too_many_arguments, | ||
| reason = "test hook injection keeps the production workflow free of trait-object plumbing" | ||
| )] | ||
|
Comment on lines
+37
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Check if Cargo.toml exists and view its current contents
cat Cargo.toml | head -30Repository: remcostoeten/kiekje Length of output: 832 🏁 Script executed: # Check if src/services/capture.rs exists and view lines 37-40
if [ -f "src/services/capture.rs" ]; then
echo "File exists. Viewing lines 37-40:"
sed -n '37,40p' src/services/capture.rs
else
echo "File not found at src/services/capture.rs"
# Try to find it
find . -name "capture.rs" -type f
fiRepository: remcostoeten/kiekje Length of output: 237 🌐 Web query:
💡 Result: Rust’s #[expect] macro/attribute for lints (from RFC 2383 “lint_reasons”) was stabilized in Rust 1.81.0.[1][2] The Rust 1.81.0 release blog states that “1.81 stabilizes … a new lint level, expect” and introduces #[expect(clippy::…)] for expecting a lint to occur, warning if it doesn’t.[1] The official Rust 1.81.0 release notes also include “Stabilize #[expect] for lints (RFC 2383)”.[2] For context: the stabilization work corresponds to the “Let’s #[expect] some lints: Stabilize lint_reasons” PR, and that PR lists milestone 1.81.0.[3] Citations:
Add
📌 Proposed addition to `Cargo.toml` edition = "2021"
+rust-version = "1.81"🤖 Prompt for AI Agents |
||
| fn run_with_hooks<Req, Sleep, Capture, Validate, Copy, Save>( | ||
| mode: CaptureMode, | ||
| settings: &Settings, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reconsider ignoring
bun.lock.Lock files like
bun.lockensure that all developers and CI/CD pipelines use identical dependency versions, which is critical for reproducible builds. Ignoring it can lead to "works on my machine" issues and inconsistent behavior across environments.Best practice is to commit lock files to version control. If there's a specific reason to ignore it (e.g., it's generated by a local development tool and not part of the build process), please document that reasoning.
🔧 Proposed fix
🤖 Prompt for AI Agents