Mapping colors to categories (proof-of-concept)
The single biggest issue I had with Google Calendar and Thunderbird was the lack of support for event colors. In this proof-of-concept I approach this issue the following way:
- I create Thunderbird categories "Google Color 01", "Google Color 02", ..., "Google Color 11" and assign these the respective colors from Google.
- When downloading an event that has a color, it is assigned the respective Thunderbird group.
- When uploading an event that has one of the "Google Color x" categories set, this category is removed and the Google color set instead.
This allows users on Thunderbird to both see and change the colors of events.
Future
If you are interested in integrating this code, please tell me which features you would like to see. Some ideas of mine:
-
This feature should be opt-in so users don't get 11 new categories they don't want.
-
I don't think the new categories can be automatically removed when the addon is uninstalled. This feature is not strictly necessary in my eyes, but if you have any ideas how to do that I'd love to hear them.
-
I have written a
userChrome.cssto make the color box more apparent and get the layout to be more in line with Google, which could become another opt-in feature:
Click to expand css code
@namespace html url("http://www.w3.org/1999/xhtml"); .calendar-category-box { width: 100% !important; inset-block: 0px !important; inset-inline-start: 5px !important; inset-inline-end: 0px !important; } .item-time-label { color: white; font-weight: 700 !important; } .event-name-label { color: white; font-weight: 600 !important; } calendar-month-day-box-item[selected="true"] > .item-time-label { color: #000 !important; font-weight: 750 !important; } calendar-month-day-box-item[selected="true"] > .event-name-label { color: #000 !important; font-weight: 650 !important; }
Glad you are looking in to this! Ideally, we can find a way for Thunderbird to provide ephemeral categories, that don't show up globally but are available on a per-provider basis. In lieu of that, having an opt-in setting in the provider to include these colors sounds reasonable to me.
The userChrome.css changes, while they are a nice improvement, I don't think should be part of the provider. If you feel this is an improvement not just for the Provider, you can file a bug with the changes in core, I believe here: https://searchfox.org/comm-central/source/calendar/base/themes/common/calendar-views.css
You should be able to clear the categories on uninstall, see here: https://github.com/kewisch/gdata-provider/blob/legacy/src/api/gdata.js#L62 which is called on uninstall. It might make sense to place it into the UI unregister here: https://github.com/kewisch/gdata-provider/blob/legacy/src/legacy/modules/gdataUI.jsm#L69
Thank you for the response! One further question: Does it make sense to implement this feature in the legacy branch, or would it be better to wait until there is a stable release on the main branch?
I am struggling with two issues right now, which may come down to my lack of experience with developing Thunderbird addons.
- How do you execute code from the
.jsmfiles when the addon preferences are being changed? Is there some kind of event, can you add a listener somewhere? This could be used to create/delete the 11 color groups. Right now, the addon must be reloaded or Thunderbird restarted for the change to take effect. - Is there a way to force Thunderbird to throw out its cached calendar contents and reload it from the internet? This is necessary when the colors have been enabled or disabled. Merely restarting Thunderbird is not enough, as the cached entries lack the necessary color data.
Any input would be appreciated.
I am struggling with two issues right now, which may come down to my lack of experience with developing Thunderbird addons.
- How do you execute code from the
.jsmfiles when the addon preferences are being changed? Is there some kind of event, can you add a listener somewhere? This could be used to create/delete the 11 color groups. Right now, the addon must be reloaded or Thunderbird restarted for the change to take effect.
You can use ChromeUtils.import() to import a jsm file. If you want to execute things on a calendar, I'd recommend getting calendars through the calendar manager.
- Is there a way to force Thunderbird to throw out its cached calendar contents and reload it from the internet? This is necessary when the colors have been enabled or disabled. Merely restarting Thunderbird is not enough, as the cached entries lack the necessary color data. There is a
resetLog()method you can call to reset the changelog. See https://searchfox.org/comm-central/source/calendar/base/public/calIChangeLog.idl#134
You can use cal.getCalendarManager().getCalendars() to get all the calendars, filter by gdata, then call it on the calendar. Note that for cached calendars (like gdata), there is a wrapper layer on top when you access the calendar this way.
Thank you for your input!
You can use ChromeUtils.import() to import a jsm file.
While that did not work in options.js, I eventually figured out that you can add a listener for changed settings, which was good enough.
You can use
cal.getCalendarManager().getCalendars()to get all the calendars, filter by gdata, then call it on the calendar.
After some attempts I had success with cal.manager.wrappedJSObject.getCalendars(). Thanks for pointing me in the right direction!
As far as I am concerned, this pull request is feature complete, though it needs a thorough review and more testing. Is there anything else you would like to see?