summaryrefslogtreecommitdiffstats
blob: 1532459e8aad2b6d6232e530beeb0a49da1d5453 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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();
}