summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Slimber/MenuletController.cpp')
-rw-r--r--Slimber/MenuletController.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/Slimber/MenuletController.cpp b/Slimber/MenuletController.cpp
new file mode 100644
index 0000000..1532459
--- /dev/null
+++ b/Slimber/MenuletController.cpp
@@ -0,0 +1,51 @@
+#include "Slimber/MenuletController.h"
+
+#include "Swiften/Base/foreach.h"
+#include "Swiften/Base/String.h"
+#include "Slimber/Menulet.h"
+
+#include <iostream>
+
+using namespace Swift;
+
+MenuletController::MenuletController(Menulet* menulet) :
+ menulet(menulet), xmppStatus(Offline) {
+ menulet->onRestartClicked.connect(boost::ref(onRestartRequested));
+ update();
+}
+
+MenuletController::~MenuletController() {
+}
+
+void MenuletController::setXMPPStatus(const String& message, Status status) {
+ xmppStatus = status;
+ xmppStatusMessage = message;
+ update();
+}
+
+void MenuletController::setUserNames(const std::vector<String>& users) {
+ linkLocalUsers = users;
+ update();
+}
+
+void MenuletController::update() {
+ menulet->clear();
+ if (linkLocalUsers.empty()) {
+ menulet->setIcon("UsersOffline");
+ menulet->addItem("No online users");
+ }
+ else {
+ menulet->setIcon("UsersOnline");
+ menulet->addItem("Online users:");
+ foreach(const String& user, linkLocalUsers) {
+ menulet->addItem(String(" ") + user);
+ }
+ }
+ menulet->addSeparator();
+ menulet->addItem(xmppStatusMessage, (xmppStatus == Online ? "Online" : "Offline"));
+ menulet->addSeparator();
+ menulet->addAboutItem();
+ menulet->addSeparator();
+ menulet->addRestartItem();
+ menulet->addExitItem();
+}