From bb7b522ef52b240718f33f37b577bacc4fea2db6 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Mon, 18 Apr 2016 23:42:53 -0300 Subject: Post message on messaging menu if the notification get timeout. --- data/CMakeLists.txt | 7 ++++++- data/ayatana-indicator-datetime.desktop.in | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'data') diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index c460586..14d36b8 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -32,6 +32,7 @@ if (${SYSTEMD_FOUND}) # build it set (pkglibexecdir "${CMAKE_INSTALL_FULL_PKGLIBEXECDIR}") + set (messaging_menu_icon "${CMAKE_INSTALL_FULL_DATAROOTDIR}/icons/suru/actions/scalable/appointment.svg") configure_file ("${SYSTEMD_USER_FILE_IN}" "${SYSTEMD_USER_FILE}") # install it @@ -55,7 +56,11 @@ set (XDG_AUTOSTART_FILE_IN "${CMAKE_CURRENT_SOURCE_DIR}/${XDG_AUTOSTART_NAME}.in set (pkglibexecdir "${CMAKE_INSTALL_FULL_PKGLIBEXECDIR}") configure_file ("${XDG_AUTOSTART_FILE_IN}" "${XDG_AUTOSTART_FILE}") -# install it +# install desktop file used by messaging-menu +install (FILES "${XDG_AUTOSTART_FILE}" + DESTINATION "${CMAKE_INSTALL_FULL_DATAROOTDIR}/applications/") + +# install XDG autostart install (FILES "${XDG_AUTOSTART_FILE}" DESTINATION "${XDG_AUTOSTART_DIR}") diff --git a/data/ayatana-indicator-datetime.desktop.in b/data/ayatana-indicator-datetime.desktop.in index 70df0d7..6d27166 100644 --- a/data/ayatana-indicator-datetime.desktop.in +++ b/data/ayatana-indicator-datetime.desktop.in @@ -6,3 +6,4 @@ OnlyShowIn=MATE;Unity;XFCE;Pantheon; NoDisplay=true StartupNotify=false Terminal=false +Icon=@messaging_menu_icon@ -- cgit v1.2.3 From 04588f8bff4156dae76d8ef03d1bbd58fca9fdb7 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Tue, 26 Apr 2016 21:43:03 -0300 Subject: Update notifications to use the new calendar icon. --- data/CMakeLists.txt | 2 +- src/snap.cpp | 2 +- tests/test-notification.cpp | 2 +- tests/test-sound.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'data') diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 14d36b8..6bbc246 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -32,7 +32,7 @@ if (${SYSTEMD_FOUND}) # build it set (pkglibexecdir "${CMAKE_INSTALL_FULL_PKGLIBEXECDIR}") - set (messaging_menu_icon "${CMAKE_INSTALL_FULL_DATAROOTDIR}/icons/suru/actions/scalable/appointment.svg") + set (messaging_menu_icon "${CMAKE_INSTALL_FULL_DATAROOTDIR}/icons/suru/actions/scalable/calendar.svg") configure_file ("${SYSTEMD_USER_FILE_IN}" "${SYSTEMD_USER_FILE}") # install it diff --git a/src/snap.cpp b/src/snap.cpp index 217b6df..1e7dd5e 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -124,7 +124,7 @@ public: const auto minutes = std::chrono::minutes(m_settings->alarm_duration.get()); ain::Builder b; b.set_body (appointment.summary); - b.set_icon_name (appointment.is_ubuntu_alarm() ? "alarm-clock" : "appointment"); + b.set_icon_name (appointment.is_ubuntu_alarm() ? "alarm-clock" : "calendar"); b.add_hint (ain::Builder::HINT_NONSHAPED_ICON); b.set_start_time (appointment.begin.to_unix()); diff --git a/tests/test-notification.cpp b/tests/test-notification.cpp index b951cee..d660982 100644 --- a/tests/test-notification.cpp +++ b/tests/test-notification.cpp @@ -63,7 +63,7 @@ TEST_F(NotificationFixture,Notification) bool expected_notify_called; bool expected_vibrate_called; } test_appts[] = { - { appt, "appointment", "Event", true, true }, + { appt, "calendar", "Event", true, true }, { ualarm, "alarm-clock", "Alarm", true, true } }; diff --git a/tests/test-sound.cpp b/tests/test-sound.cpp index 469b085..013c388 100644 --- a/tests/test-sound.cpp +++ b/tests/test-sound.cpp @@ -85,7 +85,7 @@ TEST_F(NotificationFixture, InteractiveDuration) // confirm that the icon passed to Notify was "alarm-clock" g_variant_get_child (params, 2, "&s", &str); - ASSERT_STREQ("appointment", str); + ASSERT_STREQ("calendar", str); // confirm that the hints passed to Notify included a timeout matching duration_minutes int32_t i32; -- cgit v1.2.3 From 02ea97a63928c5da4ca1882d34ae61076b06c945 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Wed, 27 Apr 2016 14:01:28 -0300 Subject: Use calendar app icon. --- CMakeLists.txt | 9 +++++++++ data/CMakeLists.txt | 5 ----- src/notifications.cpp | 41 +++++++++++++++++++++++++++++++++++++---- src/snap.cpp | 11 +++++++---- 4 files changed, 53 insertions(+), 13 deletions(-) (limited to 'data') diff --git a/CMakeLists.txt b/CMakeLists.txt index 33781a0..5dbc921 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,6 +80,15 @@ if(URLDISPATCHER_FOUND) add_definitions( -DHAS_URLDISPATCHER ) endif() +# lomiri-app-launch + +pkg_check_modules(LOMIRIAPPLAUNCH lomiri-app-launch>=0) +include_directories(${LOMIRIAPPLAUNCH_INCLUDE_DIRS}) + +if(LOMIRIAPPLAUNCH_FOUND) + add_definitions( -DHAS_LOMIRIAPPLAUNCH ) +endif() + if(EXISTS "/usr/share/accountsservice/interfaces/com.ubuntu.touch.AccountsService.Sound.xml") set (HAVE_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS ON) add_definitions ( -DHAS_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS ) diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 6bbc246..d7ab10f 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -32,7 +32,6 @@ if (${SYSTEMD_FOUND}) # build it set (pkglibexecdir "${CMAKE_INSTALL_FULL_PKGLIBEXECDIR}") - set (messaging_menu_icon "${CMAKE_INSTALL_FULL_DATAROOTDIR}/icons/suru/actions/scalable/calendar.svg") configure_file ("${SYSTEMD_USER_FILE_IN}" "${SYSTEMD_USER_FILE}") # install it @@ -56,10 +55,6 @@ set (XDG_AUTOSTART_FILE_IN "${CMAKE_CURRENT_SOURCE_DIR}/${XDG_AUTOSTART_NAME}.in set (pkglibexecdir "${CMAKE_INSTALL_FULL_PKGLIBEXECDIR}") configure_file ("${XDG_AUTOSTART_FILE_IN}" "${XDG_AUTOSTART_FILE}") -# install desktop file used by messaging-menu -install (FILES "${XDG_AUTOSTART_FILE}" - DESTINATION "${CMAKE_INSTALL_FULL_DATAROOTDIR}/applications/") - # install XDG autostart install (FILES "${XDG_AUTOSTART_FILE}" DESTINATION "${XDG_AUTOSTART_DIR}") diff --git a/src/notifications.cpp b/src/notifications.cpp index f59a421..dc42534 100644 --- a/src/notifications.cpp +++ b/src/notifications.cpp @@ -24,9 +24,14 @@ #include #include +#ifdef HAS_LOMIRIAPPLAUNCH +#include +#endif #include +#include + #include #include #include @@ -145,7 +150,7 @@ class Engine::Impl public: Impl(const std::string& app_name): - m_messaging_app(messaging_menu_app_new(DATETIME_INDICATOR_DESKTOP_FILE), g_object_unref), + m_messaging_app(messaging_menu_app_new(calendar_app_id().c_str()), g_object_unref), m_app_name(app_name) { if (!notify_init(app_name.c_str())) @@ -282,11 +287,15 @@ public: uuid_unparse(message_uuid, uuid_buf); const std::string message_id(uuid_buf); - GIcon *icon = g_themed_icon_new(data.m_icon_name.c_str()); + // use full icon path name, "calendar-app" does not work with themed icons + auto icon_file = g_file_new_for_path(calendar_app_icon().c_str()); + // messaging_menu_message_new: will take control of icon object + GIcon *icon = g_file_icon_new(icon_file); + g_object_unref(icon_file); // check if source exists if (!messaging_menu_app_has_source(m_messaging_app.get(), m_app_name.c_str())) - messaging_menu_app_append_source(m_messaging_app.get(), m_app_name.c_str(), icon, "Calendar"); + messaging_menu_app_append_source(m_messaging_app.get(), m_app_name.c_str(), nullptr, "Calendar"); auto msg = messaging_menu_message_new(message_id.c_str(), icon, @@ -294,7 +303,6 @@ public: nullptr, data.m_body.c_str(), data.m_start_time * G_USEC_PER_SEC); // secs -> microsecs - g_object_unref(icon); if (msg) { std::shared_ptr msg_data(new messaging_menu_data{message_id, data.m_missed_click_callback, this}); @@ -427,6 +435,31 @@ private: m_notifications.erase(it); } + static std::string calendar_app_id() + { + #ifdef HAS_LOMIRIAPPLAUNCH + auto app_id = lomiri::app_launch::AppID::discover("com.lomiri.calendar"); + return std::string(app_id) + ".desktop"; + #else + return ""; + #endif + } + + static std::string calendar_app_icon() + { + auto app_desktop = g_desktop_app_info_new(calendar_app_id().c_str()); + if (app_desktop != nullptr) { + auto icon_name = g_desktop_app_info_get_string(app_desktop, "Icon"); + g_object_unref(app_desktop); + std::string result(icon_name); + g_free(icon_name); + return result; + } else { + g_warning("Fail to get calendar icon"); + return std::string(); + } + } + /*** **** ***/ diff --git a/src/snap.cpp b/src/snap.cpp index 1e7dd5e..60005f3 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -124,7 +124,7 @@ public: const auto minutes = std::chrono::minutes(m_settings->alarm_duration.get()); ain::Builder b; b.set_body (appointment.summary); - b.set_icon_name (appointment.is_ubuntu_alarm() ? "alarm-clock" : "calendar"); + b.set_icon_name (appointment.is_ubuntu_alarm() ? "alarm-clock" : "calendar-app"); b.add_hint (ain::Builder::HINT_NONSHAPED_ICON); b.set_start_time (appointment.begin.to_unix()); @@ -171,9 +171,12 @@ public: ok(appointment, alarm); }); - b.set_missed_click_callback([appointment, alarm, ok](){ - ok(appointment, alarm); - }); + //TODO: we need to extend it to support alarms appoitments + if (!appointment.is_ubuntu_alarm()) { + b.set_missed_click_callback([appointment, alarm, ok](){ + ok(appointment, alarm); + }); + } const auto key = m_engine->show(b); if (key) -- cgit v1.2.3