jun7 / rox-filer

ROX file manager
24 stars 6 forks source link

Close ROX-Filer window when directory no longer exists #173

Closed woodenshoe-wi closed 6 years ago

woodenshoe-wi commented 6 years ago

Equivalent to running rox -D <directory> when a filer window is notified that the directory it is showing no longer exists.

Probably requires dnotify or inotify support.

jun7 commented 6 years ago

Why don't you add a DirAction? Add a action and switch to filer_close_recursive in the update_display of filer.c is simple way I think.

But I also want to recover by moving to parent dir of the deleted dir. So I think just cut the alert box is good choice. At least in my fork, errored dirs have obvious look.

woodenshoe-wi commented 6 years ago

Why don't you add a DirAction? Add a action and switch to filer_close_recursive in the update_display of filer.c is simple way I think.

I knew that the filer window was getting notified about the missing directory because of the message in the title bar, so I was trying to trigger the removal from that point but it was difficult because it was in a callback function. There may be a better way to do this, is update_display a callback function? Or is it OK to use filer_close_recursive in a callback function? I guess I will have to do some more testing...

But I also want to recover by moving to parent dir of the deleted dir. So I think just cut the alert box is good choice. At least in my fork, errored dirs have obvious look.

The biggest reason for the change was to make ROX-filer handle directories that disappear because the file-system they were on was unmounted, without looking like something bad happened. If you don't want directories suddenly disappearing, maybe the original behavior would be best. Otherwise the filer window would keep trying parent directories until it got to the now empty mount point (which would still exist if it wasn't deleted).

If you still want the changes I can experiment with the other method you suggested when I have time, but that won't be today, maybe in a few days.

jun7 commented 6 years ago

is update_display a callback function?

Yes

Or is it OK to use filer_close_recursive in a callback function?

I don't know. Normally dir objects are never destroyed, so closing windows is Ok, only with the option o_purge_dir_cache I added may cause problems.

because the file-system they were on was unmounted

I hardly use mount. It annoys us? unmount action hasn't filer_close_recursive?

woodenshoe-wi commented 6 years ago

I made a commit that demonstrates the problem I was having. 5247d73 I think this was the first approach that I tried, but I couldn't figure out the problem I was having.

When I gave up I decided to try to duplicate the process that running rox -D <directory> used because that didn't result in a "Segmentation fault". That is how I ended up with the code in 2f5fde1

I hardly use mount. It annoys us? unmount action hasn't filer_close_recursive?

Yes, the unmount action of ROX-filer does close the directories.

Puppy Linux uses scripts that let you mount and unmount partitions by clicking on icons on the desktop. Currently the scripts use rox -D <directory> to close windows when they are unmounted, but one of the maintainers wants to add support for other file managers besides ROX-filer and is irritated by the need to use rox -D <directory> because apparently the -D flag has a different meaning to the other file managers.

jun7 commented 6 years ago

When I gave up I decided to try to duplicate the process that running rox -D

used because that didn't result in a "Segmentation fault". That is >how I ended up with the code in 2f5fde1

I found. Include filer.c and add g_idle_add((GSourceFunc)filer_close_recursive, g_strdup(dir->pathname)); is best. Since dir.c have to touch filer windows, why don't we just include it. It was only two lines thing.

As 4247d73, adding an option is needed though.

woodenshoe-wi commented 6 years ago

Thank you for figuring out a solution! That would have been my preferred way of doing it but I couldn't get it to work right.

For some reason I can't see commit 4247d73

I am assuming that the only change is

g_idle_add((GSourceFunc)filer_close_recursive, g_strdup(dir->pathname));

replaces

path = g_strdup(filer_window->real_path);
filer_close_recursive(path); //eats path

in update_display (plus adding the option handling)?

jun7 commented 6 years ago

4247d73

Ah sorry. it is just typo of 5247d73

replaces in update_display

No. I mean just call filer_close_recursive via g_idle_add from dir.c. I noticed that using that callback system(update_display) is nonsense because we have to add a lot of code to do it, but the changes have to be are just 2 lines.

It looks not polite, may be I have to consider more though small code is good too for correction when we find better way.

BTW Do you know whether there are still systems only support dnotify or not? I think dir.c is simple without the dnotify.

woodenshoe-wi commented 6 years ago

OK, how is fe7d883 This seems almost too easy after all the trouble I was having on my own.

BTW Do you know whether there are still systems only support dnotify or not? I think dir.c is simple without the dnotify.

I think the oldest kernel currently supported by the Puppy Linux "kernel-kit" build system is 3.14 with both

CONFIG_DNOTIFY=y
CONFIG_INOTIFY_USER=y

of course people might still be using older operating systems, but if ROX-filer requires newer versions of glib or GTK it might not compile on these systems anyway.

jun7 commented 6 years ago

OK, how is fe7d883

It is OK.

I think the oldest kernel currently supported by the Puppy Linux "kernel-kit" build system is 3.14 with both

Thank you. I will remove the dnotify's code.