Bug 35844 - [PATCH] validate.c: require all possible main categories to be present at once
Summary: [PATCH] validate.c: require all possible main categories to be present at once
Status: RESOLVED FIXED
Alias: None
Product: desktop-file-utils
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Vincent Untz
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-31 11:46 UTC by Igor Vlasenko
Modified: 2012-10-11 13:30 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Attachments
validate.c: do not require all possible main categories to be present (5.12 KB, application/octet-stream)
2011-03-31 11:46 UTC, Igor Vlasenko
Details
second version (w/o Science) (1.84 KB, patch)
2011-05-19 09:05 UTC, Igor Vlasenko
Details | Splinter Review
TextTools; should require either Office; or Utility;. (816 bytes, patch)
2011-05-19 09:42 UTC, Igor Vlasenko
Details | Splinter Review
no-main-category.patch (1.73 KB, patch)
2012-09-12 10:47 UTC, Michael
Details | Splinter Review
no-main-category.patch (1.04 KB, patch)
2012-09-12 11:05 UTC, Michael
Details | Splinter Review
related-categories.patch (16.11 KB, patch)
2012-09-12 15:31 UTC, Michael
Details | Splinter Review

Description Igor Vlasenko 2011-03-31 11:46:21 UTC
Created attachment 45098 [details]
validate.c: do not require all possible main categories to be present

According to standard, "The Related Categories column
lists one or more categories that are suggested to be used in conjunction
with the Additional Category. Note that at least one Main Category must
be included ...". But there are many categories where desktop-file-validate requires all possible Main Categories to be present.
(see attached patch or git commit (link below) for the list of affected categories.

The standart allows multiple Main Categories, but clearly specifies that
it is optional: "__If__ multiple Main Categories are included ..."
    
like, Education;Music; is clearly different from AudioVideo;Music;
and both forms should be allowed because they go to the different menus.

Example:
warn    sylpheed-3.1.0-alt1.x86_64      desktop-file-validate utility exited abnormally with the following message(s): /usr/share/applications/sylpheed.desktop: error: (will be fatal in the future): value "Email" in key "Categories" in group "Desktop Entry" requires another category to be present among the following categories: Office;Network;
whereas sylpheed's Categories=GTK;Network;Email;News;
and many more.

proposed patch is attached and also can be merged from
http://git.altlinux.org/people/viy/packages/?p=desktop-file-utils-xdg.git;a=commit;h=9e35a53b52aeba3e709fec16cfc3a52eb5f2bce7
Comment 1 Igor Vlasenko 2011-05-19 09:05:51 UTC
Created attachment 46910 [details] [review]
second version (w/o Science)

First patch contained a bug about Science (Science is not a main Category)
so the proposed path is now for "Email", "Music", and "ProjectManagement"  only.
Comment 2 Igor Vlasenko 2011-05-19 09:42:57 UTC
Created attachment 46914 [details] [review]
TextTools; should require either Office; or Utility;.

on a related note, "Dictionary" requires TextTools;Office;
but not TextTools;Utility.

but TextTools; requires Utility.
to resolve this, TextTools; should require either Office; or Utility;.
Comment 3 Vincent Untz 2011-12-15 05:58:12 UTC
Comment on attachment 46910 [details] [review]
second version (w/o Science)

Review of attachment 46910 [details] [review]:
-----------------------------------------------------------------

My understanding of the related categories in the spec is that "Office;TextTools" is different from "Office or TextTools". That's why it's implemented this way.

Now, the spec might be using ";" where "or" should be used, and we should fix that first. The Music example is a good one where it sounds wrong.
Comment 4 Vincent Untz 2011-12-15 05:59:10 UTC
(In reply to comment #2)
> Created attachment 46914 [details] [review] [review]
> TextTools; should require either Office; or Utility;.
> 
> on a related note, "Dictionary" requires TextTools;Office;
> but not TextTools;Utility.
> 
> but TextTools; requires Utility.
> to resolve this, TextTools; should require either Office; or Utility;.

Let's fix the spec first :-)
Comment 5 Igor Vlasenko 2011-12-15 11:41:57 UTC
(In reply to comment #4)
> Let's fix the spec first :-)

Completely agree.

Yet I'm a novice here at freedesktop.org, 
I do not know where to ask about the spec changes :(
Could you give me some directions?
Comment 6 Ulrich Müller 2012-08-01 10:00:55 UTC
Another example where desktop-file-validate outputs a false positive is the desktop entry of GNU Emacs 24.1 which has "Development;TextEditor;" as categories.

$ desktop-file-validate emacs.desktop 
emacs.desktop: error: (will be fatal in the future): value "TextEditor" in key "Categories" in group "Desktop Entry" requires another category to be present among the following categories: Utility

The description of "Utility" is "Small utility application, 'Accessories'" which doesn't look right for Emacs.

The spec actuall says: "The Related Categories column lists one or more categories that are *suggested* to be used in conjunction with the Additional Category." Suggested doesn't mean required.
Comment 7 Michael 2012-09-03 15:17:17 UTC
What's required to get this moving? Happy to help.
Comment 8 Vincent Untz 2012-09-03 16:38:09 UTC
(In reply to comment #6)
> The spec actuall says: "The Related Categories column lists one or more
> categories that are *suggested* to be used in conjunction with the Additional
> Category." Suggested doesn't mean required.

Yes, that's something we fixed recently in the spec, and that we need to handle in desktop-file-utils.

I think we'll still have a warning if a main category is not present, as there's no guarantee the desktop file will appear where it should in the menus. A warning is no error, so I guess that'd be fine.
Comment 9 Michael 2012-09-12 10:47:42 UTC
Created attachment 67042 [details] [review]
no-main-category.patch

Here's a small patch that drops "does not contain a registered main category" errors, as per the updated spec.
Comment 10 Michael 2012-09-12 11:05:12 UTC
Created attachment 67044 [details] [review]
no-main-category.patch

Updated patch to turn lack of main category into a warning, wrt comment #8.
Comment 11 Michael 2012-09-12 15:31:41 UTC
Created attachment 67054 [details] [review]
related-categories.patch

This additional patch drops related category validation (since they are now optional), while retaining validation of "Category1;Category2" (compare with "Category1 or Category 2).
Comment 12 Vincent Untz 2012-10-03 11:04:56 UTC
Thanks for your patches, Michael. I've pushed some that are similar, but a bit different:

 - for the first one, we output a hint instead of a warning (hints are new, so nothing you could do)

 - for the second one, there are actually still cases where a category requires another (Audio requires AudioVideo). So this had to work another way; I added some hint for the related categories, also.

Keeping the bug open for the initial comment (see my comment 3).
Comment 13 Vincent Untz 2012-10-03 14:22:08 UTC
(In reply to comment #12)
> Keeping the bug open for the initial comment (see my comment 3).

Patch for the spec posted: http://lists.freedesktop.org/archives/xdg/2012-October/012526.html
Comment 14 Vincent Untz 2012-10-11 13:30:26 UTC
Spec change pushed, and fixed to desktop-file-utils pushed too.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.