After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 697725 - "Open Calendar" doesn't do anything when no calendar application is installed
"Open Calendar" doesn't do anything when no calendar application is installed
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: calendar
3.8.x
Other Linux
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
3.8.1 ?
: 697301 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-04-10 14:55 UTC by Lionel Landwerlin
Modified: 2013-05-16 21:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Do not show "Open Calendar" when no calendar app is installed (1.90 KB, patch)
2013-04-10 14:56 UTC, Lionel Landwerlin
reviewed Details | Review
Do not show "Open Calendar" when no calendar app is installed v2 (2.57 KB, patch)
2013-04-10 15:11 UTC, Lionel Landwerlin
reviewed Details | Review
Do not show "Open Calendar" when no calendar app is installed v3 (2.95 KB, patch)
2013-04-10 16:12 UTC, Lionel Landwerlin
reviewed Details | Review
Do not show "Open Calendar" when no calendar app is installed v4 (3.20 KB, patch)
2013-04-13 00:41 UTC, Lionel Landwerlin
reviewed Details | Review
Do not show "Open Calendar" when no calendar app is installed v5 (3.04 KB, patch)
2013-04-13 01:01 UTC, Lionel Landwerlin
accepted-commit_now Details | Review
Do not show "Open Calendar" when no calendar app is installed v6 (3.05 KB, patch)
2013-05-06 14:08 UTC, Lionel Landwerlin
committed Details | Review

Description Lionel Landwerlin 2013-04-10 14:55:16 UTC
There is actually 2 problems here.
First when you have no calendar application, the "Open Calendar" button button in the calendar UI doesn't do anything.
Second the method we use to figure out the calendar application is a bit broken, we call :
 Gio.AppInfo.get_default_for_type('text/calendar', false);
This method finds the first associated application with every mimetype of the mime tree, which means it first tries with 'text/calendar' and if nothing is found, it tries with 'text/'. So if you don't have a calendar application installed but you have gedit, the shell is going to spawn gedit.

Attached a patch to hide the button in case there is no calendar application and also use Gio.AppInfo.get_recommended_for_type() instead of Gio.AppInfo.get_default_for_type().
Comment 1 Lionel Landwerlin 2013-04-10 14:56:29 UTC
Created attachment 241172 [details] [review]
Do not show "Open Calendar" when no calendar app is installed
Comment 2 Giovanni Campagna 2013-04-10 14:59:53 UTC
Review of attachment 241172 [details] [review]:

::: js/ui/dateMenu.js
@@ +164,3 @@
     _updateEventsVisibility: function() {
         let visible = this._eventSource.hasCalendars;
+        this._openCalendarItem.actor.visible = this._getCalendarApp() != null;

&& visible
Also, this is probably worth caching until installed-changed fires.
Comment 3 Lionel Landwerlin 2013-04-10 15:11:16 UTC
Created attachment 241174 [details] [review]
Do not show "Open Calendar" when no calendar app is installed v2

Updated patch to reflect your suggestion.
Though I still see "Open Clocks" even though I don't have gnome-clocks installed.
Might be a bug somewhere else...
Comment 4 Giovanni Campagna 2013-04-10 15:21:30 UTC
Review of attachment 241174 [details] [review]:

Uhm... You didn't add caching (so every call to _getCalendarApp() hits the disk), and you didn't fix the '&& visible' bit.
Comment 5 Lionel Landwerlin 2013-04-10 16:12:34 UTC
Created attachment 241183 [details] [review]
Do not show "Open Calendar" when no calendar app is installed v3
Comment 6 Jasper St. Pierre (not reading bugmail) 2013-04-10 16:20:57 UTC
Review of attachment 241183 [details] [review]:

You need to connect to AppSystem's installed-changed and invalidate the cache.

::: js/ui/dateMenu.js
@@ +159,3 @@
     _appInstalledChanged: function() {
+        this._openClocksItem.actor.visible = this._getClockApp() !== null;
+        this._openCalendarItem.actor.visible = this._getCalendarApp() !== null

Hm, it seems this is an existing bug. This should call this._updateEventsVisibility().

@@ +164,3 @@
     _updateEventsVisibility: function() {
         let visible = this._eventSource.hasCalendars;
+        this._openCalendarItem.actor.visible = this._getCachedCalendarApp() != null;

You still ignore "visible" here. This needs to be:

    this._openCalendarItem.actor.visible = visible && this._getCachedCalendarApp() != null;

@@ +227,3 @@
+    },
+
+    _getCachedCalendarApp: function() {

This is a bit unorthodox. We usually would do:

    _getCalendarApp: function() {
        if (this._calendarApp !== undefined)
            return this._calendarApp;

        let apps = Gio.AppInfo.get_recommended_for_type('text/calendar');
        if (apps && (apps.length > 0))
            this._calendarApp = apps[0];
        else
            this._calendarApp = null;
        return this._calendarApp;
    },

And then do this._calendarApp = undefined; in installed-changed to invalidate the cache.
Comment 7 Lionel Landwerlin 2013-04-13 00:41:16 UTC
Created attachment 241426 [details] [review]
Do not show "Open Calendar" when no calendar app is installed v4
Comment 8 Jasper St. Pierre (not reading bugmail) 2013-04-13 00:53:41 UTC
Review of attachment 241426 [details] [review]:

::: js/ui/dateMenu.js
@@ +239,3 @@
 
+        let app = this._getCalendarApp();
+        if (app) {

What is this for? You can click on the "Open Calendar" item when there's no app? Isn't it supposed to be invisible?
Comment 9 Lionel Landwerlin 2013-04-13 01:01:44 UTC
Created attachment 241428 [details] [review]
Do not show "Open Calendar" when no calendar app is installed v5

Fair. Thanks for the careful reviews.
Comment 10 Lionel Landwerlin 2013-05-06 14:08:50 UTC
Created attachment 243385 [details] [review]
 Do not show "Open Calendar" when no calendar app is installed v6

Rebase on top of gnome-3-8 branch
Comment 11 Jasper St. Pierre (not reading bugmail) 2013-05-06 14:48:53 UTC
Review of attachment 241428 [details] [review]:

ACK.
Comment 12 Jasper St. Pierre (not reading bugmail) 2013-05-06 14:49:30 UTC
Review of attachment 243385 [details] [review]:

++
Comment 13 Lionel Landwerlin 2013-05-06 15:06:13 UTC
Pushed to 3.8 and master.
Comment 14 Jeremy Bicha 2013-05-16 21:50:47 UTC
*** Bug 697301 has been marked as a duplicate of this bug. ***