From 18013dbb911de3d71ad679f697490f161ec19a34 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 22 Mar 2014 02:25:50 -0500 Subject: make the phone and desktop actions more consistent with each other; eg, 'indicator.desktop.open-calendar-app' + 'indicator.phone.open-calendar-app' --- src/actions-live.cpp | 53 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 20 deletions(-) (limited to 'src/actions-live.cpp') diff --git a/src/actions-live.cpp b/src/actions-live.cpp index 97b12db..068abe7 100644 --- a/src/actions-live.cpp +++ b/src/actions-live.cpp @@ -51,6 +51,7 @@ void LiveActions::execute_command(const std::string& cmdstr) void LiveActions::dispatch_url(const std::string& url) { + g_debug("Dispatching url '%s'", url.c_str()); url_dispatch_send(url.c_str(), nullptr, nullptr); } @@ -58,7 +59,7 @@ void LiveActions::dispatch_url(const std::string& url) **** ***/ -void LiveActions::open_desktop_settings() +void LiveActions::desktop_open_settings_app() { auto path = g_find_program_in_path("unity-control-center"); @@ -74,7 +75,7 @@ void LiveActions::open_desktop_settings() g_free (path); } -bool LiveActions::can_open_planner() const +bool LiveActions::desktop_has_calendar_app() const { static bool inited = false; static bool have_calendar = false; @@ -98,22 +99,17 @@ bool LiveActions::can_open_planner() const return have_calendar; } -void LiveActions::open_planner() +void LiveActions::desktop_open_alarm_app() { execute_command("evolution -c calendar"); } -void LiveActions::open_phone_settings() +void LiveActions::desktop_open_appointment(const Appointment& appt) { - dispatch_url("settings:///system/time-date"); -} - -void LiveActions::open_phone_clock_app() -{ - dispatch_url("appid://com.ubuntu.clock/clock/current-user-version"); + desktop_open_calendar_app(appt.begin); } -void LiveActions::open_planner_at(const DateTime& dt) +void LiveActions::desktop_open_calendar_app(const DateTime& dt) { const auto day_begins = dt.add_full(0, 0, 0, -dt.hour(), -dt.minute(), -dt.seconds()); const auto gmt = day_begins.to_timezone("UTC"); @@ -121,17 +117,34 @@ void LiveActions::open_planner_at(const DateTime& dt) execute_command(cmd.c_str()); } -void LiveActions::open_appointment(const std::string& uid) +/*** +**** +***/ + +void LiveActions::phone_open_alarm_app() { - for(const auto& appt : state()->calendar_upcoming->appointments().get()) - { - if(appt.uid != uid) - continue; + dispatch_url("appid://com.ubuntu.clock/clock/current-user-version"); +} - if (!appt.url.empty()) - dispatch_url(appt.url); - break; - } +void LiveActions::phone_open_appointment(const Appointment& appt) +{ + if (!appt.url.empty()) + dispatch_url(appt.url); + else if (appt.has_alarms) + phone_open_alarm_app(); + else + phone_open_calendar_app(DateTime::NowLocal()); +} + +void LiveActions::phone_open_calendar_app(const DateTime&) +{ + // does calendar app have a mechanism for specifying dates? + dispatch_url("appid://com.ubuntu.calendar/calendar/current-user-version"); +} + +void LiveActions::phone_open_settings_app() +{ + dispatch_url("settings:///system/time-date"); } /*** -- cgit v1.2.3