Olivier Sessink
2013-07-30 19:30:17 UTC
Olivier,
actually I was writing new code that would remove dead entries from
OpenRecent menu (the files that are no longer accesible).
Your fix seems to be working well- I tested my code with 8010 and found
no issues.
I am attaching the code I mentioned above. In the past we discussed
about more general approach of handling dead entries, however, it seems
this is not that easy to do. At first, project_open_from_file() and
doc_new_from_uri() does not return anything, so there is no way to
detect if file was opened sucessfully. Rewriting these functions is more
complicated than using access(), I think.
Second, project files are handled differently from simple files, and
there is no generic function to add or remove filename from stringlists...
Looking forward for Your comments.
Andrius
I think that is actually quite a hard problem to do it right. Becauseactually I was writing new code that would remove dead entries from
OpenRecent menu (the files that are no longer accesible).
Your fix seems to be working well- I tested my code with 8010 and found
no issues.
I am attaching the code I mentioned above. In the past we discussed
about more general approach of handling dead entries, however, it seems
this is not that easy to do. At first, project_open_from_file() and
doc_new_from_uri() does not return anything, so there is no way to
detect if file was opened sucessfully. Rewriting these functions is more
complicated than using access(), I think.
Second, project files are handled differently from simple files, and
there is no generic function to add or remove filename from stringlists...
Looking forward for Your comments.
Andrius
there might be temporary reasons why a file does not exist (for example
a network location that is not mounted - which is quite common for web
developers). Second, detecting if a file exist might be a very slow
operation. I update the Bluefish website over sftp:// for example, and
opening or saving a file easily takes a second or two (I'm in the
Netherlands, the server is somewhere on the US west coast). That is why
all file operations in file.c are all done in a background thread. So
detecting this should be done in a background thread too.
This is also why access() is not the right thing to use, because it will
not work for URL's, so existence of files over sftp:// or smb:// cannot
be detected. There is a g_file_....() alternative, but we should use the
asynchronous method (otherwise we might block the GUI for multiple seconds).
So perhaps the best approach would be to integrate this in the dialog
that the user gets when a file is loaded which cannot be found. If the
user then cancels the load, remove it from the recent list, if a user
reloads (because he realized that he forgot to mount the network drive),
don't remove it.
Does that sound like a good idea?
(cc-ing the -dev list)
Olivier
--
Bluefish website http://bluefish.openoffice.nl/
Blog http://oli4444.wordpress.com/
Bluefish website http://bluefish.openoffice.nl/
Blog http://oli4444.wordpress.com/