diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/actions-live.cpp | 8 | ||||
-rw-r--r-- | src/actions.cpp | 29 | ||||
-rw-r--r-- | src/menu.cpp | 7 |
3 files changed, 24 insertions, 20 deletions
diff --git a/src/actions-live.cpp b/src/actions-live.cpp index 4fe2f39..231fb33 100644 --- a/src/actions-live.cpp +++ b/src/actions-live.cpp @@ -127,9 +127,9 @@ void LiveActions::desktop_open_alarm_app() execute_command("evolution -c calendar"); } -void LiveActions::desktop_open_appointment(const Appointment& appt) +void LiveActions::desktop_open_appointment(const Appointment&, const DateTime& date) { - desktop_open_calendar_app(appt.begin); + desktop_open_calendar_app(date); } void LiveActions::desktop_open_calendar_app(const DateTime& dt) @@ -148,7 +148,7 @@ void LiveActions::phone_open_alarm_app() dispatch_url("appid://com.ubuntu.clock/clock/current-user-version"); } -void LiveActions::phone_open_appointment(const Appointment& appt) +void LiveActions::phone_open_appointment(const Appointment& appt, const DateTime& date) { if (!appt.activation_url.empty()) @@ -163,7 +163,7 @@ void LiveActions::phone_open_appointment(const Appointment& appt) case Appointment::EVENT: default: - phone_open_calendar_app(appt.begin); + phone_open_calendar_app(date); break; } } diff --git a/src/actions.cpp b/src/actions.cpp index 93629a0..ea68d3e 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -48,13 +48,8 @@ DateTime datetime_from_timet_variant(GVariant* v) return DateTime::NowLocal(); } -bool lookup_appointment_by_uid_variant(const std::shared_ptr<State>& state, GVariant* vuid, Appointment& setme) +bool lookup_appointment_by_uid(const std::shared_ptr<State>& state, const gchar* uid, Appointment& setme) { - g_return_val_if_fail(vuid != nullptr, false); - g_return_val_if_fail(g_variant_type_equal(G_VARIANT_TYPE_STRING,g_variant_get_type(vuid)), false); - const auto uid = g_variant_get_string(vuid, nullptr); - g_return_val_if_fail(uid && *uid, false); - for(const auto& appt : state->calendar_upcoming->appointments().get()) { if (appt.uid == uid) @@ -67,12 +62,15 @@ bool lookup_appointment_by_uid_variant(const std::shared_ptr<State>& state, GVar return false; } -void on_desktop_appointment_activated (GSimpleAction*, GVariant *vuid, gpointer gself) +void on_desktop_appointment_activated (GSimpleAction*, GVariant *vdata, gpointer gself) { auto self = static_cast<Actions*>(gself); Appointment appt; - if (lookup_appointment_by_uid_variant(self->state(), vuid, appt)) - self->desktop_open_appointment(appt); + const gchar* uid = nullptr; + gint64 time = 0; + g_variant_get(vdata, "(&sx)", &uid, &time); + if (lookup_appointment_by_uid(self->state(), uid, appt)) + self->desktop_open_appointment(appt, DateTime::Local(time)); } void on_desktop_alarm_activated (GSimpleAction*, GVariant*, gpointer gself) { @@ -88,12 +86,15 @@ void on_desktop_settings_activated (GSimpleAction*, GVariant*, gpointer gself) static_cast<Actions*>(gself)->desktop_open_settings_app(); } -void on_phone_appointment_activated (GSimpleAction*, GVariant *vuid, gpointer gself) +void on_phone_appointment_activated (GSimpleAction*, GVariant *vdata, gpointer gself) { auto self = static_cast<Actions*>(gself); Appointment appt; - if (lookup_appointment_by_uid_variant(self->state(), vuid, appt)) - self->phone_open_appointment(appt); + const gchar* uid = nullptr; + gint64 time = 0; + g_variant_get(vdata, "(&sx)", &uid, &time); + if (lookup_appointment_by_uid(self->state(), uid, appt)) + self->phone_open_appointment(appt, DateTime::Local(time)); } void on_phone_alarm_activated (GSimpleAction*, GVariant*, gpointer gself) { @@ -198,12 +199,12 @@ Actions::Actions(const std::shared_ptr<State>& state): { GActionEntry entries[] = { - { "desktop.open-appointment", on_desktop_appointment_activated, "s", nullptr }, + { "desktop.open-appointment", on_desktop_appointment_activated, "(sx)", nullptr }, { "desktop.open-alarm-app", on_desktop_alarm_activated }, { "desktop.open-calendar-app", on_desktop_calendar_activated, "x", nullptr }, { "desktop.open-settings-app", on_desktop_settings_activated }, - { "phone.open-appointment", on_phone_appointment_activated, "s", nullptr }, + { "phone.open-appointment", on_phone_appointment_activated, "(sx)", nullptr }, { "phone.open-alarm-app", on_phone_alarm_activated }, { "phone.open-calendar-app", on_phone_calendar_activated, "x", nullptr }, { "phone.open-settings-app", on_phone_settings_activated }, diff --git a/src/menu.cpp b/src/menu.cpp index 0cd3f9b..b1ac75c 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -414,9 +414,12 @@ private: if (!appt.color.empty()) g_menu_item_set_attribute (menu_item, "x-ayatana-color", "s", appt.color.c_str()); - if (action_name != nullptr) + if (action_name != nullptr) { g_menu_item_set_action_and_target_value (menu_item, action_name, - g_variant_new_string (appt.uid.c_str())); + g_variant_new ("(sx)", + appt.uid.c_str(), + unix_time)); + } g_menu_append_item (menu, menu_item); g_object_unref (menu_item); |