#include "command.h" #include "gui.h" namespace { std::string trim(const std::string &s) { size_t left = 0; while (left < s.size() && isspace(s[left])) left++; size_t right = s.size() - 1; while (right >= left && isspace(s[right])) right--; return s.substr(left, right - left + 1); } } namespace gui { void showNotification(const std::string &message) { runCommand({"zenity", "--notification", "--text", message}); } std::optional promptText(const std::string &message) { auto result = readCommand({"zenity", "--entry", "--text", message}); if (result.first == 0) return result.second; else return std::nullopt; } std::optional chooseList(const std::string &message, const std::string &header, const std::vector &options) { std::vector args{ "zenity", "--list", "--text", message, "--column", header }; args.insert(args.end(), options.begin(), options.end()); auto result = readCommand(args); if (result.first == 0) return trim(result.second); else return std::nullopt; } }