rnote
rnote copied to clipboard
Add basic file context menu for the workspace browser
The file browser needs a basic context menu to manipulate the files. It doesn't need to be as extensive as nautilus, but I think at least "open", "rename", "delete", "duplicate" should be implemented.
The UI for it should similar to spots context menu, meaning as a menu button in the list item (for stylus users).
Inspiration for the implementation can be taken from here: https://gitlab.gnome.org/World/Fragments/-/commit/af6c4f25645340638dacccac03d9a31af2fa348a (MenuButton with PopoverMenu and a MenuModel).
The gio::File's can be exctracted from the listitem with an expression, just like its already done for the titles.
added an initial context menu in 1ce7befe7d4a147fa55ecda8d2a78754862e2467 . More actions will be added to it over time. (Easy to do, if someone wants to help)
a wild pikachu appeared
I'd like to claim this and try to fix that issue
~~One question for this: I'd like to use rust-analyzer
but when forking your repo, the piet
and piet-gpu
dirs are empty, do you have an idea how I can fix that? Are you using rust-analyzer
as well? How did you set it up?~~
Welp, taking a look into the BUILDING.md` solved the issue, just needed to do:
git submodule update --init --recursive
and rust-analyzer
is ready to go now
One question to this @flxzt what should happen if you press duplicate
on a directory? Should it duplicate all files and subdirectories in this directory as well or just the selected directory?
@TornaxO7 Thanks for working on it! Imo it should duplicate everything inside it, just like a copy paste in any file browser.
Thinking about it I believe what also would be nice for the integrated file browser is a button somewhere to create an additional folder. It would complete a minimal feature set for workspace management inside the app.
@TornaxO7 Thanks for working on it! Imo it should duplicate everything inside it, just like a copy paste in any file browser.
is it fine for you to use copy_dir
for directories?
Looks unmaintained and the disclaimer makes me not want to include it. fs_extra looks better in that regard. Another thing, I think there should be an indication of ~~progress~~ business. Check these methods for starting, finishing or aborting the progress pulse bar
Looks unmaintained and the disclaimer makes me not want to include it. fs_extra looks better in that regard. Another thing, I think there should be an indication of ~progress~ business. Check these methods for starting, finishing or aborting the progress pulse bar
Ehm, do you have any tips how I can do the progress bar? Because currently I'm a little bit stuck here. Now I'd do something like the following:
fn copy_dir_progress(&self, process_info: TransitProcess) -> TransitProcessResult {
let status = {
let status = process_info.copied_bytes / process_info.total_bytes;
status as f64
};
// this line is added
self.imp().canvas_progressbar.set_fraction(status);
TransitProcessResult::ContinueOrAbort
}
but I'm getting different errors like:
error[E0599]: no method named `imp` found for reference `&workspacebrowser::filerow::FileRow` in t
he current scope
--> rnote-ui/src/workspacebrowser/filerow/actions/duplicate.rs:41:14
|
41 | self.imp().canvas_progressbar.set_fraction(status);
| ^^^ method not found in `&workspacebrowser::filerow::FileRow`
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
1 | use libadwaita::subclass::prelude::ObjectSubclassIsExt;
|
but if I can't add this use
from the help information as libadwaita
can't be accessed there.
Adding
use gtk4::subclass::prelude::ObjectSubclassIsExt;
gives me the following instead:
error[E0609]: no field `canvas_progressbar` on type `&workspacebrowser::filerow::imp::FileRow`
--> rnote-ui/src/workspacebrowser/filerow/actions/duplicate.rs:42:20
|
42 | self.imp().canvas_progressbar.set_fraction(status);
| ^^^^^^^^^^^^^^^^^^ unknown field
|
= note: available fields are: `current_file`, `drag_source`, `action_group`, `file_image`, `fil
e_label` ... and 3 others
do you have any tips?
You'd need to pass the appwindow to the actions and call these methods from there. An example: the save document action.
If you want to indicate progress going from 0% (fraction 0.0) to 100% (fraction 1.0) I think we could add a method (e.g. set_fraction_canvas_progressbar()
to appwindow that removes the timeout source (that drives the pulsing) and sets the given fraction. And when the duplication was successful, finish with finish_canvas_progressbar()
or if it failed abort with abort_canvas_progressbar()
.
Regarding why you can't import libadwaita
: it is renamed to adw
for shortness (see: https://github.com/flxzt/rnote/blob/main/rnote-ui/Cargo.toml#L29) . When importing something from preludes, usually I then just import everything with use adw::prelude::*