| 1 | /* |
| 2 | * LegacyClonk |
| 3 | * |
| 4 | * Copyright (c) 2021, The LegacyClonk Team and contributors |
| 5 | * |
| 6 | * Distributed under the terms of the ISC license; see accompanying file |
| 7 | * "COPYING" for details. |
| 8 | * |
| 9 | * "Clonk" is a registered trademark of Matthes Bender, used with permission. |
| 10 | * See accompanying file "TRADEMARK" for details. |
| 11 | * |
| 12 | * To redistribute this file separately, substitute the full license texts |
| 13 | * for the above references. |
| 14 | */ |
| 15 | |
| 16 | #pragma once |
| 17 | |
| 18 | #include "C4Toast.h" |
| 19 | |
| 20 | #include <string> |
| 21 | #include <vector> |
| 22 | |
| 23 | #include <libnotify/notify.h> |
| 24 | |
| 25 | class C4ToastSystemLibNotify : public C4ToastSystem |
| 26 | { |
| 27 | public: |
| 28 | C4ToastSystemLibNotify(); |
| 29 | ~C4ToastSystemLibNotify() override; |
| 30 | |
| 31 | public: |
| 32 | std::unique_ptr<C4Toast> CreateToast() override; |
| 33 | }; |
| 34 | |
| 35 | class C4ToastLibNotify: public C4Toast |
| 36 | { |
| 37 | private: |
| 38 | struct UserData |
| 39 | { |
| 40 | C4ToastLibNotify *const toast; |
| 41 | const size_t index; |
| 42 | }; |
| 43 | |
| 44 | public: |
| 45 | C4ToastLibNotify(); |
| 46 | ~C4ToastLibNotify(); |
| 47 | |
| 48 | public: |
| 49 | void AddAction(std::string_view action) override; |
| 50 | void SetExpiration(std::uint32_t expiration) override; |
| 51 | void SetText(std::string_view text) override; |
| 52 | void SetTitle(std::string_view title) override; |
| 53 | |
| 54 | void Show() override; |
| 55 | void Hide() override; |
| 56 | |
| 57 | private: |
| 58 | static void Activated(NotifyNotification *, char *, gpointer userData); |
| 59 | static void OnAction(NotifyNotification *, char *, gpointer userData); |
| 60 | static void Dismissed(NotifyNotification *, gpointer userData); |
| 61 | |
| 62 | private: |
| 63 | NotifyNotification *notification; |
| 64 | std::vector<std::string> actions; |
| 65 | std::string title; |
| 66 | std::string text; |
| 67 | gulong signalClose; |
| 68 | }; |
| 69 | |