From a6422822a9b9a18bae705e56f2b53ee0b61ff1dc Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Thu, 28 Apr 2016 11:56:11 -0300 Subject: Detect desktop to launch applications. --- src/actions.cpp | 64 ++++++++++++++++++--------------------------------------- 1 file changed, 20 insertions(+), 44 deletions(-) (limited to 'src/actions.cpp') diff --git a/src/actions.cpp b/src/actions.cpp index ea68d3e..315340a 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -62,7 +62,7 @@ bool lookup_appointment_by_uid(const std::shared_ptr& state, const gchar* return false; } -void on_desktop_appointment_activated (GSimpleAction*, GVariant *vdata, gpointer gself) +void on_appointment_activated (GSimpleAction*, GVariant *vdata, gpointer gself) { auto self = static_cast(gself); Appointment appt; @@ -70,44 +70,20 @@ void on_desktop_appointment_activated (GSimpleAction*, GVariant *vdata, gpointer 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)); + self->open_appointment(appt, DateTime::Local(time)); } -void on_desktop_alarm_activated (GSimpleAction*, GVariant*, gpointer gself) +void on_alarm_activated (GSimpleAction*, GVariant*, gpointer gself) { - static_cast(gself)->desktop_open_alarm_app(); + static_cast(gself)->open_alarm_app(); } -void on_desktop_calendar_activated (GSimpleAction*, GVariant* vt, gpointer gself) +void on_calendar_activated (GSimpleAction*, GVariant* vt, gpointer gself) { const auto dt = datetime_from_timet_variant(vt); - static_cast(gself)->desktop_open_calendar_app(dt); + static_cast(gself)->open_calendar_app(dt); } -void on_desktop_settings_activated (GSimpleAction*, GVariant*, gpointer gself) +void on_settings_activated (GSimpleAction*, GVariant*, gpointer gself) { - static_cast(gself)->desktop_open_settings_app(); -} - -void on_phone_appointment_activated (GSimpleAction*, GVariant *vdata, gpointer gself) -{ - auto self = static_cast(gself); - 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) -{ - static_cast(gself)->phone_open_alarm_app(); -} -void on_phone_calendar_activated (GSimpleAction*, GVariant* vt, gpointer gself) -{ - const auto dt = datetime_from_timet_variant(vt); - static_cast(gself)->phone_open_calendar_app(dt); -} -void on_phone_settings_activated (GSimpleAction*, GVariant*, gpointer gself) -{ - static_cast(gself)->phone_open_settings_app(); + static_cast(gself)->open_settings_app(); } void on_set_location(GSimpleAction * /*action*/, @@ -135,9 +111,9 @@ void on_calendar_active_changed(GSimpleAction * /*action*/, } } -void on_calendar_activated(GSimpleAction * /*action*/, - GVariant * state, - gpointer gself) +void on_calendar_date_activated(GSimpleAction * /*action*/, + GVariant * state, + gpointer gself) { const time_t t = g_variant_get_int64(state); @@ -199,15 +175,15 @@ Actions::Actions(const std::shared_ptr& state): { GActionEntry entries[] = { - { "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 }, + { "desktop.open-appointment", on_appointment_activated, "(sx)", nullptr }, + { "desktop.open-alarm-app", on_alarm_activated }, + { "desktop.open-calendar-app", on_calendar_activated, "x", nullptr }, + { "desktop.open-settings-app", on_settings_activated }, - { "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 }, + { "phone.open-appointment", on_appointment_activated, "(sx)", nullptr }, + { "phone.open-alarm-app", on_alarm_activated }, + { "phone.open-calendar-app", on_calendar_activated, "x", nullptr }, + { "phone.open-settings-app", on_settings_activated }, { "calendar-active", nullptr, nullptr, "false", on_calendar_active_changed }, { "set-location", on_set_location, "s" } @@ -241,7 +217,7 @@ Actions::Actions(const std::shared_ptr& state): v = create_calendar_state(state); a = g_simple_action_new_stateful("calendar", G_VARIANT_TYPE_INT64, v); g_action_map_add_action(gam, G_ACTION(a)); - g_signal_connect(a, "activate", G_CALLBACK(on_calendar_activated), this); + g_signal_connect(a, "activate", G_CALLBACK(on_calendar_date_activated), this); g_object_unref(a); /// -- cgit v1.2.3