GNOME Bugzilla – Bug 697725
"Open Calendar" doesn't do anything when no calendar application is installed
Last modified: 2013-05-16 21:50:47 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().
Created attachment 241172 [details] [review] Do not show "Open Calendar" when no calendar app is installed
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.
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...
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.
Created attachment 241183 [details] [review] Do not show "Open Calendar" when no calendar app is installed v3
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.
Created attachment 241426 [details] [review] Do not show "Open Calendar" when no calendar app is installed v4
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?
Created attachment 241428 [details] [review] Do not show "Open Calendar" when no calendar app is installed v5 Fair. Thanks for the careful reviews.
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
Review of attachment 241428 [details] [review]: ACK.
Review of attachment 243385 [details] [review]: ++
Pushed to 3.8 and master.
*** Bug 697301 has been marked as a duplicate of this bug. ***