aboutsummaryrefslogtreecommitdiff
path: root/src/actions-live.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/actions-live.cpp')
-rw-r--r--src/actions-live.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/actions-live.cpp b/src/actions-live.cpp
index f510ed1..97b12db 100644
--- a/src/actions-live.cpp
+++ b/src/actions-live.cpp
@@ -74,6 +74,30 @@ void LiveActions::open_desktop_settings()
g_free (path);
}
+bool LiveActions::can_open_planner() const
+{
+ static bool inited = false;
+ static bool have_calendar = false;
+
+ if (G_UNLIKELY(!inited))
+ {
+ inited = true;
+
+ auto all = g_app_info_get_all_for_type ("text/calendar");
+ for(auto l=all; !have_calendar && l!=nullptr; l=l->next)
+ {
+ auto app_info = static_cast<GAppInfo*>(l->data);
+
+ if (!g_strcmp0("evolution.desktop", g_app_info_get_id(app_info)))
+ have_calendar = true;
+ }
+
+ g_list_free_full(all, (GDestroyNotify)g_object_unref);
+ }
+
+ return have_calendar;
+}
+
void LiveActions::open_planner()
{
execute_command("evolution -c calendar");
@@ -91,13 +115,15 @@ void LiveActions::open_phone_clock_app()
void LiveActions::open_planner_at(const DateTime& dt)
{
- auto cmd = dt.format("evolution \"calendar:///?startdate=%Y%m%d\"");
+ const auto day_begins = dt.add_full(0, 0, 0, -dt.hour(), -dt.minute(), -dt.seconds());
+ const auto gmt = day_begins.to_timezone("UTC");
+ auto cmd = gmt.format("evolution \"calendar:///?startdate=%Y%m%dT%H%M%SZ\"");
execute_command(cmd.c_str());
}
void LiveActions::open_appointment(const std::string& uid)
{
- for(const auto& appt : state()->planner->upcoming.get())
+ for(const auto& appt : state()->calendar_upcoming->appointments().get())
{
if(appt.uid != uid)
continue;
@@ -156,7 +182,7 @@ on_datetime1_proxy_ready (GObject * object G_GNUC_UNUSED,
GError * err = nullptr;
auto proxy = g_dbus_proxy_new_for_bus_finish(res, &err);
- if (err != NULL)
+ if (err != nullptr)
{
if (!g_error_matches(err, G_IO_ERROR, G_IO_ERROR_CANCELLED))
g_warning("Could not grab DBus proxy for timedated: %s", err->message);