GNOME Bugzilla – Bug 770017
0 byte files should be recognized based on their .extension only
Last modified: 2021-06-18 15:50:36 UTC
My use case was with csv and Calc: When you create an empty.csv file, **it prevents you from using real csv editor** because an empty.csv will have type "plain text document (text/plain)", and only gedit-like editors will be suggested and not spreadsheet-like editors. Right now it will suggest a LibreOffice Writer as "default editor" to empty.csv Expected behaviour is to suggest Libre Calc for empty.csv and not text-based editors real.csv: 1,2,3 a,b,c empty.csv: (0 bytes) Details: Idea it that popular formats doc, xlsx, csv should be always provided with their associated programs regardless of file actual contens. 0 byte files should be provided with programs based on file extension. I also suggest to add a type "empty/empty" or "empty" file format to untie association with 0 byte "text/plain" files. Please forward this request to the right place it is Ubuntu specific.
xdg-mime query filetype empty.csv #1 text/plain xdg-mime query filetype real.csv #2 text/csv
Have you tried pressing “View All Applications”?
(In reply to acroq3 from comment #0) > **it prevents you from using real csv editor** I installed LibreOffice just for this and the application chooser does not /prevent/ me from doing anything. I can get a list of all applications by pressing the button I mentioned in the previous comment. > Idea it that popular formats doc, xlsx, csv should be always provided with > their associated programs regardless of file actual contens. > > 0 byte files should be provided with programs based on file extension. Applications do not handle files by extension per the desktop entry specification. > I also suggest to add a type "empty/empty" or "empty" file format to untie > association with 0 byte "text/plain" files. There is no such standard type.
(In reply to Ernestas Kulik from comment #3) > (In reply to acroq3 from comment #0) > > **it prevents you from using real csv editor** > I installed LibreOffice just for this and the application chooser does not > /prevent/ me from doing anything. I can get a list of all applications by > pressing the button I mentioned in the previous comment. > My mistake, it prevents you from using Calc as "default application" instead of "all applications". Yes, latter is possible, but you can't double click an empty.csv to open spreadsheet-like editor (and some other system will open empty.csv with Calc as default program). > > Idea it that popular formats doc, xlsx, csv should be always provided with > > their associated programs regardless of file actual contens. > > > > 0 byte files should be provided with programs based on file extension. > > Applications do not handle files by extension per the desktop entry > specification. Looks like it's time to extend "desktop entry specification" format, does my use case make sense now?
(In reply to Ernestas Kulik from comment #3) > (In reply to acroq3 from comment #0) > > I also suggest to add a type "empty/empty" or "empty" file format to untie > > association with 0 byte "text/plain" files. > > There is no such standard type. True, we can a file a respective request to a committee, right? If it is necessary at all... Mime types with vendor prefixes are common, but I don't know about gnome policies and procedures about "types".
Created attachment 333496 [details] [review] mime-actions: guess content type when opening empty files Currently, empty files are treated as text/plain. This can result in less efficient workflows. This commit makes the code guess the type for empty files.
A little something I threw together. A thing to note is that thumbnailing should probably be changed as well, as empty files have the text file thumbnail.
Created attachment 333543 [details] [review] file: infer content type from extension for empty files Currently, all empty files are treated as text/plain. This can result in less efficient workflows (e.g. when creating files from templates and trying to open them quickly with their type handler). This commit makes the code guess the type for empty files from their extension.
Created attachment 333544 [details] [review] file: infer content type from extension for empty files Currently, all empty files are treated as text/plain. This can result in less efficient workflows (e.g. when creating files from templates and trying to open them quickly with their type handler). This commit makes the code guess the type for empty files from their extension.
Review of attachment 333544 [details] [review]: As said on IRC, let's look into glib first, this looks like a can of worms and glib tries to not do that on pourpose. (Also I review some code before, so I will let it here just out of curiosity) ::: src/nautilus-file.c @@ +2448,3 @@ } + mime_type_uncertain = FALSE; This looks like something to do inside the if(){} @@ +2449,3 @@ + mime_type_uncertain = FALSE; + mime_type = NULL; dito @@ +2466,3 @@ + } + + g_clear_pointer (&mime_type, g_free); This looks like it's an "else" from the previous branch right? if (size == 0) else
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version of Files (nautilus), then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new ticket at https://gitlab.gnome.org/GNOME/nautilus/-/issues/ Thank you for your understanding and your help.