Commit Graph
3546 Commits
Author SHA1 Message Date
Georges Basile Stavracas Neto 0c510d6709 month-view: Ignore events outside current range
The month view looks specially awful when switching between
dates, since it doesn't implicitly filter the ranges it's
displaying.

Ignore events outside the current month range, since they'll
be removed anyway by the timeline.
2020-04-16 16:16:49 -03:00
Georges Basile Stavracas Neto d2da70fb28 range: Properly compare ranges
The behavior of gcal_range_compare(), and the 'position' argument
of gcal_range_calculate_overlap(), should be the same. However,
because we were comparing the end dates in the wrong order, they
didn't match.

Fix that by properly comparing the end of the ranges.
2020-04-16 16:15:34 -03:00
Georges Basile Stavracas Neto a790f30176 timeline: Add sentinel events to the queue
Moving to have one subscriber per event made us face an interesting
problem: when removing an event, there may be no subscribers that
contain this event, in which case we never queue any REMOVE_EVENT
and the range tree isn't updated.

Add sentinel events (that update the range tree) and subscriber events
(that update subscribers, but not the range tree).
2020-04-16 16:10:33 -03:00
Georges Basile Stavracas Neto 494bd187d8 timeline: Cancel additions and removals
When we add an event to the queue, and later remove it, if the
event is still in the queue, we can just cancel both out and
save the timeline some processing time.
2020-04-16 15:11:53 -03:00
Georges Basile Stavracas Neto 61815ddccf timeline: Trivial code cleanup 2020-04-16 13:47:09 -03:00
Georges Basile Stavracas Neto 381ae0046a timeline: Protect against NULL arrays 2020-04-15 20:49:47 -03:00
Georges Basile Stavracas Neto 3073b6b6d8 timeline: Also queue remove events 2020-04-15 20:35:17 -03:00
Georges Basile Stavracas Neto b5cdc0bd38 timeline: Only diff when ranges intersect
When the old and the new range of the subscribers don't
overlap entirely, we can't use the regular diff algorithm.
It fails quite spectacularly.

Do a full cleanup when ranges don't overlap.
2020-04-15 20:35:04 -03:00
Georges Basile Stavracas Neto a1a4804315 timeline: Only modify event tree once
Now that we queue one event per subscriber, we need to
make sure to update the range tree only once.
2020-04-15 19:16:00 -03:00
Georges Basile Stavracas Neto 678d0acc00 timeline: Remove subscriber from range tree as well
update_range() does not remove any subscriber. They must be
removed manually.
2020-04-15 18:49:36 -03:00
Georges Basile Stavracas Neto e9812b2f28 timeline: Don't try to use removed subscribers
Because the timeline is essentially asynchronous, it may
try and process events after their subscribers were removed.

Protect against that.

Fixes https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/576
2020-04-15 18:49:36 -03:00
Georges Basile Stavracas Neto db668a0b90 timeline: Queue one event per subscriber
Right now, GcalTimeline queues one event per N subscribers. Queue
one event per subscriber instead.
2020-04-15 18:49:36 -03:00
Michael Catanzaro 60c3c26ad6 timeline: fix leak of timeline source
g_source_destroy doesn't free memory, just removes the source from its
main context. We have to do both. (g_source_unref() might call
g_source_destroy() if it has the last ref, but if something else has
another ref, then disaster could result if we don't call it manually.)
2020-04-15 21:18:16 +00:00
Clarissa Borges f1d20126dc event: Add more range test cases
More examples of possible dates for events were added to the test cases.
Superset, subset, intersection and no overlap cases are covered.
2020-04-14 17:56:12 -03:00
Michael Catanzaro a3e9af23dc source-discoverer: add support for webcal:// URIs
We can implement webcal:// by simply rewriting the URI to https://.
Amazing!

Fixes #564
2020-04-14 15:16:24 -05:00
Georges Basile Stavracas Neto 98e6ac28e7 event: Remove unused method
Comparing ranges is so easy now that we don't need this
helper anymore.
2020-04-14 19:08:06 +00:00
Georges Basile Stavracas Neto fd32492053 timeline, calendar-monitor: Remove useless event range checks
GcalRange is now smart enough to compare correctly with other ranges.
2020-04-14 19:08:06 +00:00
Georges Basile Stavracas Neto d4a6cd0e61 timeline: Process events in batches
A batch size of 5 doesn't seem to impact the mainloop
any more than a batch of size 1, but it reduces the
amount of time spinning the loop quite considerably.
2020-04-14 19:08:06 +00:00
Georges Basile Stavracas Neto 16c156914a calendar-monitor: Use GcalRange 2020-04-14 19:08:06 +00:00
Georges Basile Stavracas Neto f3c3bbf5ab event: Use GcalRange in public API 2020-04-14 19:08:06 +00:00
Georges Basile Stavracas Neto 12fd607d56 utils: Make date comparison follow time comparison semantics
Right now, comparing dates with gcal_date_time_compare_date() gives
the exact opposite result of when comparing using g_date_time_compare().

As shown by this patch, this was a source of *many* bugs.
2020-04-14 19:08:06 +00:00
Georges Basile Stavracas Neto bed8e10609 range-tree: Add print utility
Useful for debugging
2020-04-14 19:08:05 +00:00
Georges Basile Stavracas Neto 3efbc2436c range-tree: Use GcalRange 2020-04-14 19:08:05 +00:00
Georges Basile Stavracas Neto b97c4a27e0 range-tree: Cleanup header 2020-04-14 19:08:05 +00:00
Georges Basile Stavracas Neto 923e3b7b71 project: Move range tree to core/ 2020-04-14 19:08:05 +00:00
Georges Basile Stavracas Neto 0935a67558 event: Add helper API to return a GcalRange 2020-04-14 19:08:05 +00:00
Georges Basile Stavracas Neto d9733aee27 event: Simplify some code 2020-04-14 19:08:05 +00:00
Georges Basile Stavracas Neto dbfebc85fa Introduce GcalRange
GcalRange is a new structure that represents a time range. It is
always inclusive at the start, and exclusive at the end.
2020-04-14 19:08:05 +00:00
Matej Urbančič 6091a14a44 Updated Slovenian translation 2020-04-10 22:16:55 +02:00
Justin van Steijn eedbfdc177 Update Dutch translation 2020-04-06 18:22:19 +00:00
Dušan Kazik ca04f15a8d Update Slovak translation
(cherry picked from commit 43d9466ccd08df2e3cc214f0ecc353c08db1dbcc)
2020-04-05 11:02:10 +00:00
Michael Catanzaro 2bf6cfe289 Avoid critical on startup when a calendar is broken
This is a workaround for evolution-data-server#205. Depending on the
resolution of that bug, this might even be the correct fix.
2020-04-02 15:59:32 -05:00
Michael Catanzaro 26897f89a2 Revert "new-calendar-page: add support for webcal:// links"
This reverts commit 8520e1819c
2020-04-02 15:30:35 +00:00
Michael Catanzaro 8520e1819c new-calendar-page: add support for webcal:// links
Turns out, all we have to do is rewrite the URL to https://. I'm
surprised this works, but I don't see any problems with it. I tested
subscribing to webcal://www.gnome.org/start/unstable/schedule.ics.

See also: #481
2020-04-02 03:09:06 +00:00
Michael Catanzaro 7a3db413e9 new-calendar-page: properly track state of URL entry and Add button
Currently, when the user enters an invalid URL -- a URL that does not
pass SoupURI's URI format validation -- then we set the error style
class on the URL entry to turn the border of the entry red. For example,
if I try to enter "dog" then GNOME Calendar catches this and flags the
entry as red.

But there are some problems.

First of all, GNOME Calendar doesn't do anything to prevent users from
entering URLs that are syntatically valid but not usable as calendars.
The code knows whether the URL was successfully parsed as a calendar
file, it just doesn't do anything with this information. So there is no
red warning if I try to use https://example.com as a calendar, even
though the dialog knows that it didn't work.

Secondly, GNOME Calendar allows pressing the Add button even if the URL
entry contains invalid input, but only if the Calendar Name has been
entered. The dialog thinks: "if I have a name, but not a valid URL, then
the user wants to create a new, empty local calendar!" But this is not
right. If the user has typed anything in the URL entry, then the goal is
to import a new calendar, not to create a new one.

This commit changes set_url_entry_error() into update_url_entry_state(),
and gives it responsibility for updating the add button sensitivity and
URL entry pulsing in addition to the URL entry style class, solving both
of the above problems.

As a side effect, this also closes a race window where the Add button
remains sensitive for half a second after typing new text in the URL entry.
At this point, we don't yet know whether the URL is valid, because we
wait half a second before validating the URL, so we shouldn't allow the
user to activate the Add button during this race window.

Fixes #481
2020-04-02 03:09:06 +00:00
Michael Catanzaro bba6c60c32 new-calendar-page: improve URI validity check
This check passes if the URI is empty. Normally this callback only runs
when there is text in the URL entry, but there is a race window where
the user could delete it first. (Passing NULL to a SoupURI creates an
invalid non-NULL empty URI that can be filled in later.)
2020-04-02 03:09:06 +00:00
Georges Basile Stavracas Neto aaab4af282 timeline: Respond well to subscriber removal 2020-04-01 23:10:01 -03:00
Georges Basile Stavracas Neto fa0173e174 window: Remove subscribers on destroy 2020-04-01 23:10:01 -03:00
Georges Basile Stavracas Neto e4debb9912 views: Free GDateTimes with g_date_time_unref() 2020-04-01 23:10:01 -03:00
Georges Basile Stavracas Neto 93542e8853 timeline: Add already cached events to new subscribers 2020-04-01 23:10:01 -03:00
Georges Basile Stavracas Neto 6586c8738c calendars-page: Add already connected calendars on startup
Fixes https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/479
2020-04-01 23:10:01 -03:00
Michael Catanzaro 164ec8620b calendar-monitor: Fix critical in finalize
self->thread can be NULL if gcal_calendar_monitor_set_range() was never
called prior to finalize. This is fine, so just check for NULL here
using g_clear_pointer().
2020-04-02 01:54:33 +00:00
Michael Catanzaro e816657116 calendar-monitor: fix unused variable warning
Fixes:

[43/52] Compiling C object 'src/25a6634@@gcal-private@sta/core_gcal-calendar-monitor.c.o'
../../../../Projects/gnome-calendar/src/core/gcal-calendar-monitor.c: In function ‘on_client_view_objects_added_cb’:
../../../../Projects/gnome-calendar/src/core/gcal-calendar-monitor.c:402:16: warning: variable ‘old_size’ set but not used [-Wunused-but-set-variable]
  402 |           gint old_size;
      |                ^~~~~~~~
2020-04-01 20:30:06 -05:00
Georges Basile Stavracas Neto d606bafd15 calendar-monitor: Properly cleanup ECalComponents
Unfortunately, they do not have autoptr functions.
2020-04-01 21:08:21 -03:00
Georges Basile Stavracas Neto 19fc8138ba week-header: Use g_date_time_compare()
It is incorrect to use the date-only comparison here. Use the appropriate
GDateTime API and fix a truckload of issues.

Fixes https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/546
2020-04-01 21:06:51 -03:00
Georges Basile Stavracas Neto b703f5746d week-header: Rename a variable
"event_start" and "event_end" clearly communicate they're the
start and end datetimes of the event. I'm dumb, so I need the
code to tell me what's it about easily.
2020-04-01 21:06:51 -03:00
Georges Basile Stavracas Neto a65a370317 time-zone-monitor: Clear GTimeZone with g_time_zone_unref
GTimeZone is not an object, and it cannot be cleared with g_clear_object().
2020-04-01 21:06:51 -03:00
Georges Basile Stavracas Neto c77e4ecfb5 year-view: Small code cleanup
Merge update_date() with gcal_year_view_set_date(), and
tidy up the code style a bit.
2020-04-01 21:06:51 -03:00
Georges Basile Stavracas Neto cfa4b56a05 timeline: Implement processing changes in idle 2020-04-01 21:06:51 -03:00
Georges Basile Stavracas Neto f052cb6589 event-widget: Remove idle on destroy
Finalize may be too late for us, since a widget
may be destroyed long before it's finalized.

Remove the idle timer on destroy then.
2020-04-01 21:06:51 -03:00