Merge lp://qastaging/~osomon/unity-2d/preferred-applications into lp://qastaging/unity-2d/3.0

Proposed by Olivier Tilloy
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 497
Merged at revision: 505
Proposed branch: lp://qastaging/~osomon/unity-2d/preferred-applications
Merge into: lp://qastaging/unity-2d/3.0
Diff against target: 124 lines (+42/-7)
3 files modified
launcher/UnityApplications/launcherapplication.cpp (+9/-2)
places/Home.qml (+3/-4)
places/HomeButtonApplication.qml (+30/-1)
To merge this branch: bzr merge lp://qastaging/~osomon/unity-2d/preferred-applications
Reviewer Review Type Date Requested Status
Aurélien Gâteau (community) Approve
Review via email: mp+55509@code.qastaging.launchpad.net

Commit message

[dash] Show preferred applications in the home screen.
If an application cannot be found, do not show it.

Description of the change

Note to the reviewer: the implementation differs from the one in Unity on the following two points:

 - the default e-mail client is the one actually configured via gnome-default-applications-properties, unlike Unity which takes the value of /desktop/gnome/applications/calendar/exec, which I think is plain wrong

 - I didn’t implement a whitelist fallback mechanism like Unity does: if the preferred application configured via gnome-default-applications-properties is not found, then it’s simply not displayed in the dash home screen, where Unity would have a hardcoded list of fallback web browsers, e-mail clients, image viewers and music players

To post a comment you must log in.
Revision history for this message
Aurélien Gâteau (agateau) wrote :

Works well, except if one tries to set KDE applications as defaults. See the end of the review for details.

Some questions, suggestions first:

# LauncherApplication::setDesktopFile()
- Should the if newDesktopFile != oldDesktopFile be something like this instead?

"""
if (newDesktopFile == oldDesktopFile) {
    return;
}
Q_EMIT desktopFileChanged(newDesktopFile);
"""

- Not really related to this MR but g_object_unref(m_appInfo) should be called before creating a new GDesktopAppInfo.

# places/HomeButtonApplication.qml

- Having both desktopFile and desktop_file is quite confusing. application.desktop_file should be renamed to application.desktopFile and code inside it should use parent.desktopFile to disambiguate.

# Problem with KDE applications

Assuming desktopFile == binaryName + ".desktop" makes it unpractical to set KDE applications as default. To set a KDE4 application as default I have to prefix its name with "kde4-" in gnome-default-application-properties.

The reason behind this is that KDE4 desktop files are all installed in /usr/share/applications/kde4, meaning their desktop file id is "kde4-$app.desktop" (see http://standards.freedesktop.org/menu-spec/1.0/go01.html#term-desktop-file-id ).

review: Needs Fixing
Revision history for this message
Olivier Tilloy (osomon) wrote :

> # LauncherApplication::setDesktopFile()
> - Should the if newDesktopFile != oldDesktopFile be something like this
> instead?
>
> """
> if (newDesktopFile == oldDesktopFile) {
> return;
> }
> Q_EMIT desktopFileChanged(newDesktopFile);
> """

For some reason which I still need to investigate, applying this change seems to break the update of icons for newly created web favorites.

> - Not really related to this MR but g_object_unref(m_appInfo) should be called
> before creating a new GDesktopAppInfo.

I believe you fixed this one already, in a separate merge request.

> # places/HomeButtonApplication.qml
>
> - Having both desktopFile and desktop_file is quite confusing.
> application.desktop_file should be renamed to application.desktopFile and code
> inside it should use parent.desktopFile to disambiguate.

This is a more general problem with naming consistency of the properties of some classes, particularly LauncherApplication. 'desktop_file' should be renamed 'desktopFile' indeed, but I don’t think it’s a good idea to do this change here and now. Renaming should be performed in a separate branch and fix all the properties, not just this one.
I tried to make the code more explicit by using parent.desktopFile nevertheless, but this doesn’t seem to work: 'parent' is undefined in this block of code…

> # Problem with KDE applications
>
> Assuming desktopFile == binaryName + ".desktop" makes it unpractical to set
> KDE applications as default. To set a KDE4 application as default I have to
> prefix its name with "kde4-" in gnome-default-application-properties.
>
> The reason behind this is that KDE4 desktop files are all installed in
> /usr/share/applications/kde4, meaning their desktop file id is
> "kde4-$app.desktop" (see http://standards.freedesktop.org/menu-
> spec/1.0/go01.html#term-desktop-file-id ).

We have a more general issue with KDE4 applications throughout unity-2d’s applications. I know this solution is far from perfect, but it’s a cheap one that doesn’t involve writing custom C++ code to infer the correct desktop file from the path of an executable. It’s also the way it’s done in Unity, meaning Unity will fail to display KDE4 applications too. I can definitely give it a try, if we think the effort is worth the benefit. Do we?

Revision history for this message
Olivier Tilloy (osomon) wrote :

> > # LauncherApplication::setDesktopFile()
> > - Should the if newDesktopFile != oldDesktopFile be something like this
> > instead?
> >
> > """
> > if (newDesktopFile == oldDesktopFile) {
> > return;
> > }
> > Q_EMIT desktopFileChanged(newDesktopFile);
> > """
>
> For some reason which I still need to investigate, applying this change seems
> to break the update of icons for newly created web favorites.

I figured it out: the desktop files are monitored for changes, and whenever the contents of a file changes, setDesktopFile(…) is called with the same filename. As the contents have changed, some properties of the applications may have changed, which is why we should not return early if newDesktopFile == oldDesktopFile.

Revision history for this message
Aurélien Gâteau (agateau) wrote :

> > > # LauncherApplication::setDesktopFile()
> > > - Should the if newDesktopFile != oldDesktopFile be something like this
> > > instead?
> > >
> > > """
> > > if (newDesktopFile == oldDesktopFile) {
> > > return;
> > > }
> > > Q_EMIT desktopFileChanged(newDesktopFile);
> > > """
> >
> > For some reason which I still need to investigate, applying this change
> seems
> > to break the update of icons for newly created web favorites.
>
> I figured it out: the desktop files are monitored for changes, and whenever
> the contents of a file changes, setDesktopFile(…) is called with the same
> filename. As the contents have changed, some properties of the applications
> may have changed, which is why we should not return early if newDesktopFile ==
> oldDesktopFile.

Not really happy we can't fix support for KDE applications, but having
configurable default applications is better than hardcoded applications, even
if not all applications are supported. Let's merge your branch.

Can you just add a comment to the code with your explanation about
desktopFileChanged() and file a report about support for KDE applications?

Please mark the MR approved when you're done.

review: Approve
497. By Olivier Tilloy

Add a comment to explain why we don’t return immediatly if (newDesktopFile == oldDesktopFile).

Revision history for this message
Olivier Tilloy (osomon) wrote :

Thanks for the review Aurélien (and sorry about the lack of support for KDE4 applications…).

I added the comment you requested.
I also filed bug #750081 to track the issue with KDE4 applications.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches