-
-
Notifications
You must be signed in to change notification settings - Fork 118
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
Add gio::FileEnumerator, gio::FileMonitor, gio::Vfs subclasses #1676
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: fbrouille <[email protected]>
Very interesting, thanks! OOC, what are you planning to implement with this? |
gio/src/subclass/file_enumerator.rs
Outdated
unsafe impl Send for MyFileEnumerator {} | ||
unsafe impl Sync for MyFileEnumerator {} |
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.
These are implemented automatically if possible. Are they not, and why are they required here?
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.
Removed. It was old code while implementing the tests.
gio/src/subclass/file_monitor.rs
Outdated
|
||
impl MyFileMonitor { | ||
pub async fn tick(&self) { | ||
std::thread::sleep(std::time::Duration::from_millis(10)); |
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.
As this is an async function it should probably use an async sleep mechanism. glib::timeout_future()
for example
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.
Done
self.parent_is_active() | ||
} | ||
|
||
fn get_file_for_path(&self, path: &GString) -> File { |
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.
You probably also need to implement the required pieces to implement gio::File
for this to be useful, or not?
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.
Done.
Initially i through I would have to implement 70+ methods of gio::File
, but finally only few ones are required for tests of gio::Vfs subclass
, so it is ok.
Just shortly looked over it, will do a proper review one of these days but generally it looks correct. |
94aacc1
to
bbfa6db
Compare
self.parent_is_active() | ||
} | ||
|
||
fn get_file_for_path(&self, path: &GString) -> File { |
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.
should it take a GString or a PathBuf?
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.
path
parameter in VfsExt::file_for_path
is a &str
, so I think it should be a &str
.
Another alternative is to change path
parameter in VfsExt::file_for_path
and in gio::VfsImpl::get_file_for_path
to impl AsRef<std::path::Path>
as in gio::File::for_path
.
What do you think ?
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.
We should fix the annotation upstream for VfsExt::file_for_path then
Signed-off-by: fbrouille <[email protected]>
Signed-off-by: fbrouille <[email protected]>
Signed-off-by: fbrouille <[email protected]>
bbfa6db
to
ce47c8b
Compare
OOC I'm planning to implement some nautilus extension in Rust (very challenging 😅) |
} | ||
} | ||
|
||
unsafe impl IsImplementable<MyFile> for File { |
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.
Can you split this into subclass/file.rs even if it only implements a small subset of the vfuncs, the rest can be added later.
Allow custom implementation of gio::Vfs, gio::File, gio::FileEnumerator and gio::FileMonitor