diff options
author | Renato Araujo Oliveira Filho <renato.filho@canonical.com> | 2016-04-27 14:01:28 -0300 |
---|---|---|
committer | Robert Tari <robert@tari.in> | 2021-07-06 03:09:00 +0200 |
commit | ec226fce51ed4ba7f16c5f1d3f87c180c6335918 (patch) | |
tree | 4066098850f711df1cab75fec23e1dfc9ca140cb /src | |
parent | 0cfd764abbb319aa994788e993267d75bb955ccd (diff) | |
download | ayatana-indicator-datetime-ec226fce51ed4ba7f16c5f1d3f87c180c6335918.tar.gz ayatana-indicator-datetime-ec226fce51ed4ba7f16c5f1d3f87c180c6335918.tar.bz2 ayatana-indicator-datetime-ec226fce51ed4ba7f16c5f1d3f87c180c6335918.zip |
Use calendar app icon.
Diffstat (limited to 'src')
-rw-r--r-- | src/notifications.cpp | 41 | ||||
-rw-r--r-- | src/snap.cpp | 11 |
2 files changed, 44 insertions, 8 deletions
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 <messaging-menu/messaging-menu-app.h> #include <messaging-menu/messaging-menu-message.h> +#ifdef HAS_LOMIRIAPPLAUNCH +#include <liblomiri-app-launch/lomiri-app-launch/appid.h> +#endif #include <uuid/uuid.h> +#include <gio/gdesktopappinfo.h> + #include <map> #include <set> #include <string> @@ -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<messaging_menu_data> 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) |