Merge branch 'master' into spotify

This commit is contained in:
Alex 2018-11-24 18:11:48 +01:00 committed by GitHub
commit 5356d25a9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 113 additions and 115 deletions

View File

@ -7,7 +7,7 @@ namespace waybar {
class ALabel : public IModule { class ALabel : public IModule {
public: public:
ALabel(const Json::Value&, const std::string format); ALabel(const Json::Value&, const std::string format, uint16_t interval = 0);
virtual ~ALabel() = default; virtual ~ALabel() = default;
virtual auto update() -> void; virtual auto update() -> void;
virtual std::string getIcon(uint16_t, const std::string& alt = ""); virtual std::string getIcon(uint16_t, const std::string& alt = "");
@ -19,6 +19,7 @@ class ALabel : public IModule {
const Json::Value& config_; const Json::Value& config_;
std::string format_; std::string format_;
std::mutex mutex_; std::mutex mutex_;
const std::chrono::seconds interval_;
private: private:
bool handleToggle(GdkEventButton* const& ev); bool handleToggle(GdkEventButton* const& ev);

View File

@ -29,6 +29,7 @@ class Client {
private: private:
void bindInterfaces(); void bindInterfaces();
auto setupCss(); auto setupCss();
const std::string getValidPath(std::vector<std::string> paths);
static void handleGlobal(void *data, struct wl_registry *registry, static void handleGlobal(void *data, struct wl_registry *registry,
uint32_t name, const char *interface, uint32_t version); uint32_t name, const char *interface, uint32_t version);

View File

@ -30,8 +30,8 @@ class Battery : public ALabel {
static inline const fs::path data_dir_ = "/sys/class/power_supply/"; static inline const fs::path data_dir_ = "/sys/class/power_supply/";
void worker(); void worker();
std::tuple<uint16_t, std::string> getInfos(); const std::tuple<uint8_t, std::string> getInfos() const;
std::string getState(uint16_t); const std::string getState(uint8_t) const;
util::SleeperThread thread_; util::SleeperThread thread_;
util::SleeperThread thread_timer_; util::SleeperThread thread_timer_;

View File

@ -34,8 +34,8 @@ class Host {
GCancellable* cancellable_ = nullptr; GCancellable* cancellable_ = nullptr;
SnWatcher* watcher_ = nullptr; SnWatcher* watcher_ = nullptr;
const Json::Value &config_; const Json::Value &config_;
std::function<void(std::unique_ptr<Item>&)> on_add_; const std::function<void(std::unique_ptr<Item>&)> on_add_;
std::function<void(std::unique_ptr<Item>&)> on_remove_; const std::function<void(std::unique_ptr<Item>&)> on_remove_;
}; };
} }

View File

@ -8,7 +8,7 @@ namespace waybar::modules::SNI {
class Watcher { class Watcher {
public: public:
Watcher(); Watcher();
~Watcher(); ~Watcher() = default;
private: private:
typedef enum { GF_WATCH_TYPE_HOST, GF_WATCH_TYPE_ITEM } GfWatchType; typedef enum { GF_WATCH_TYPE_HOST, GF_WATCH_TYPE_ITEM } GfWatchType;
@ -22,7 +22,7 @@ private:
guint watch_id; guint watch_id;
} GfWatch; } GfWatch;
static void busAcquired(GDBusConnection *, const gchar *, gpointer); void busAcquired(const Glib::RefPtr<Gio::DBus::Connection>&, Glib::ustring);
static gboolean handleRegisterHost(Watcher *, GDBusMethodInvocation *, static gboolean handleRegisterHost(Watcher *, GDBusMethodInvocation *,
const gchar *); const gchar *);
static gboolean handleRegisterItem(Watcher *, GDBusMethodInvocation *, static gboolean handleRegisterItem(Watcher *, GDBusMethodInvocation *,

View File

@ -1,6 +1,6 @@
project( project(
'waybar', 'cpp', 'c', 'waybar', 'cpp', 'c',
version: '0.2.1', version: '0.2.2',
license: 'MIT', license: 'MIT',
default_options : [ default_options : [
'cpp_std=c++17', 'cpp_std=c++17',

View File

@ -3,10 +3,11 @@
#include <iostream> #include <iostream>
waybar::ALabel::ALabel(const Json::Value& config, const std::string format) waybar::ALabel::ALabel(const Json::Value& config, const std::string format, uint16_t interval)
: config_(config), : config_(config),
format_(config_["format"].isString() ? config_["format"].asString() : format), format_(config_["format"].isString() ? config_["format"].asString() : format),
default_format_(format_) interval_(std::chrono::seconds(config_["interval"].isUInt()
? config_["interval"].asUInt() : interval)), default_format_(format_)
{ {
event_box_.add(label_); event_box_.add(label_);
if (config_["max-length"].isUInt()) { if (config_["max-length"].isUInt()) {
@ -20,17 +21,12 @@ waybar::ALabel::ALabel(const Json::Value& config, const std::string format)
} }
// configure events' user commands // configure events' user commands
if (config_["on-click"].isString()) { if (config_["on-click"].isString() || config_["on-click-right"].isString()) {
event_box_.add_events(Gdk::BUTTON_PRESS_MASK); event_box_.add_events(Gdk::BUTTON_PRESS_MASK);
event_box_.signal_button_press_event().connect( event_box_.signal_button_press_event().connect(
sigc::mem_fun(*this, &ALabel::handleToggle)); sigc::mem_fun(*this, &ALabel::handleToggle));
} }
if (config_["on-scroll-up"].isString()) { if (config_["on-scroll-up"].isString() || config_["on-scroll-down"].isString()) {
event_box_.add_events(Gdk::SCROLL_MASK);
event_box_.signal_scroll_event().connect(
sigc::mem_fun(*this, &ALabel::handleScroll));
}
if (config_["on-scroll-down"].isString()) {
event_box_.add_events(Gdk::SCROLL_MASK); event_box_.add_events(Gdk::SCROLL_MASK);
event_box_.signal_scroll_event().connect( event_box_.signal_scroll_event().connect(
sigc::mem_fun(*this, &ALabel::handleScroll)); sigc::mem_fun(*this, &ALabel::handleScroll));
@ -44,6 +40,8 @@ auto waybar::ALabel::update() -> void {
bool waybar::ALabel::handleToggle(GdkEventButton* const& e) { bool waybar::ALabel::handleToggle(GdkEventButton* const& e) {
if (config_["on-click"].isString() && e->button == 1) { if (config_["on-click"].isString() && e->button == 1) {
waybar::util::command::forkExec(config_["on-click"].asString()); waybar::util::command::forkExec(config_["on-click"].asString());
} else if (config_["on-click-right"].isString() && e->button == 3) {
waybar::util::command::forkExec(config_["on-click-right"].asString());
} else { } else {
alt = !alt; alt = !alt;
if (alt) { if (alt) {

View File

@ -184,7 +184,13 @@ void waybar::Bar::getModules(const Factory& factory, const std::string& pos)
if (pos == "modules-right") { if (pos == "modules-right") {
modules_right_.emplace_back(module); modules_right_.emplace_back(module);
} }
module->dp.connect([module] { module->update(); }); module->dp.connect([module, &name] {
try {
module->update();
} catch (const std::exception& e) {
std::cerr << name.asString() + ": " + e.what() << std::endl;
}
});
} catch (const std::exception& e) { } catch (const std::exception& e) {
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
} }

View File

@ -12,38 +12,43 @@ waybar::Client::Client(int argc, char* argv[])
throw std::runtime_error("Bar need to run under Wayland"); throw std::runtime_error("Bar need to run under Wayland");
} }
wl_display = gdk_wayland_display_get_wl_display(gdk_display->gobj()); wl_display = gdk_wayland_display_get_wl_display(gdk_display->gobj());
auto getFirstValidPath = [] (std::vector<std::string> possiblePaths) {
wordexp_t p;
for (const std::string &path: possiblePaths) { config_file = getValidPath({
if (wordexp(path.c_str(), &p, 0) == 0) {
if (access(*p.we_wordv, F_OK) == 0) {
std::string result = *p.we_wordv;
wordfree(&p);
return result;
}
wordfree(&p);
}
}
return std::string();
};
config_file = getFirstValidPath({
"$XDG_CONFIG_HOME/waybar/config", "$XDG_CONFIG_HOME/waybar/config",
"$HOME/waybar/config", "$HOME/waybar/config",
"/etc/xdg/waybar/config", "/etc/xdg/waybar/config",
"./resources/config", "./resources/config",
}); });
css_file = getFirstValidPath({ css_file = getValidPath({
"$XDG_CONFIG_HOME/waybar/style.css", "$XDG_CONFIG_HOME/waybar/style.css",
"$HOME/waybar/style.css", "$HOME/waybar/style.css",
"/etc/xdg/waybar/style.css", "/etc/xdg/waybar/style.css",
"./resources/style.css", "./resources/style.css",
}); });
if (css_file.empty() || config_file.empty()) {
throw std::runtime_error("Missing required resources files");
}
std::cout << "Resources files: " + config_file + ", " + css_file << std::endl; std::cout << "Resources files: " + config_file + ", " + css_file << std::endl;
} }
const std::string waybar::Client::getValidPath(std::vector<std::string> paths)
{
wordexp_t p;
for (const std::string &path: paths) {
if (wordexp(path.c_str(), &p, 0) == 0) {
if (access(*p.we_wordv, F_OK) == 0) {
std::string result = *p.we_wordv;
wordfree(&p);
return result;
}
wordfree(&p);
}
}
return std::string();
}
void waybar::Client::handleGlobal(void *data, struct wl_registry *registry, void waybar::Client::handleGlobal(void *data, struct wl_registry *registry,
uint32_t name, const char *interface, uint32_t version) uint32_t name, const char *interface, uint32_t version)
{ {

View File

@ -15,7 +15,7 @@ int main(int argc, char* argv[])
waybar::client = &c; waybar::client = &c;
std::signal(SIGUSR1, [] (int /*signal*/) { std::signal(SIGUSR1, [] (int /*signal*/) {
for (auto& bar : waybar::client->bars) { for (auto& bar : waybar::client->bars) {
(*bar).toggle(); bar->toggle();
} }
}); });

View File

@ -1,7 +1,7 @@
#include "modules/battery.hpp" #include "modules/battery.hpp"
waybar::modules::Battery::Battery(const Json::Value& config) waybar::modules::Battery::Battery(const Json::Value& config)
: ALabel(config, "{capacity}%") : ALabel(config, "{capacity}%", 60)
{ {
try { try {
if (config_["bat"].isString()) { if (config_["bat"].isString()) {
@ -46,9 +46,8 @@ void waybar::modules::Battery::worker()
{ {
// Trigger first values // Trigger first values
update(); update();
uint32_t interval = config_["interval"].isUInt() ? config_["interval"].asUInt() : 60; thread_timer_ = [this] {
thread_timer_ = [this, interval] { thread_.sleep_for(interval_);
thread_.sleep_for(chrono::seconds(interval));
dp.emit(); dp.emit();
}; };
thread_ = [this] { thread_ = [this] {
@ -63,7 +62,7 @@ void waybar::modules::Battery::worker()
}; };
} }
std::tuple<uint16_t, std::string> waybar::modules::Battery::getInfos() const std::tuple<uint8_t, std::string> waybar::modules::Battery::getInfos() const
{ {
try { try {
uint16_t total = 0; uint16_t total = 0;
@ -86,10 +85,10 @@ std::tuple<uint16_t, std::string> waybar::modules::Battery::getInfos()
} }
} }
std::string waybar::modules::Battery::getState(uint16_t capacity) const std::string waybar::modules::Battery::getState(uint8_t capacity) const
{ {
// Get current state // Get current state
std::vector<std::pair<std::string, uint16_t>> states; std::vector<std::pair<std::string, uint8_t>> states;
if (config_["states"].isObject()) { if (config_["states"].isObject()) {
for (auto it = config_["states"].begin(); it != config_["states"].end(); ++it) { for (auto it = config_["states"].begin(); it != config_["states"].end(); ++it) {
if (it->isUInt() && it.key().isString()) { if (it->isUInt() && it.key().isString()) {
@ -101,16 +100,16 @@ std::string waybar::modules::Battery::getState(uint16_t capacity)
std::sort(states.begin(), states.end(), [](auto &a, auto &b) { std::sort(states.begin(), states.end(), [](auto &a, auto &b) {
return a.second < b.second; return a.second < b.second;
}); });
std::string validState = ""; std::string valid_state;
for (auto state : states) { for (auto const& state : states) {
if (capacity <= state.second && validState.empty()) { if (capacity <= state.second && valid_state.empty()) {
label_.get_style_context()->add_class(state.first); label_.get_style_context()->add_class(state.first);
validState = state.first; valid_state = state.first;
} else { } else {
label_.get_style_context()->remove_class(state.first); label_.get_style_context()->remove_class(state.first);
} }
} }
return validState; return valid_state;
} }
auto waybar::modules::Battery::update() -> void auto waybar::modules::Battery::update() -> void

View File

@ -1,16 +1,17 @@
#include "modules/clock.hpp" #include "modules/clock.hpp"
waybar::modules::Clock::Clock(const Json::Value& config) waybar::modules::Clock::Clock(const Json::Value& config)
: ALabel(config, "{:%H:%M}") : ALabel(config, "{:%H:%M}", 60)
{ {
label_.set_name("clock"); label_.set_name("clock");
uint32_t interval = config_["interval"].isUInt() ? config_["interval"].asUInt() : 60; thread_ = [this] {
thread_ = [this, interval] {
auto now = waybar::chrono::clock::now(); auto now = waybar::chrono::clock::now();
dp.emit(); dp.emit();
auto timeout = std::chrono::floor<std::chrono::seconds>(now auto timeout = std::chrono::floor<std::chrono::seconds>(now + interval_);
+ std::chrono::seconds(interval)); auto time_s = std::chrono::time_point_cast<std::chrono::seconds>(timeout);
thread_.sleep_until(timeout); auto sub_m =
std::chrono::duration_cast<std::chrono::seconds>(time_s.time_since_epoch()).count() % 60;
thread_.sleep_until(timeout - std::chrono::seconds(sub_m - 1));
}; };
} }

View File

@ -1,28 +1,23 @@
#include "modules/cpu.hpp" #include "modules/cpu.hpp"
waybar::modules::Cpu::Cpu(const Json::Value& config) waybar::modules::Cpu::Cpu(const Json::Value& config)
: ALabel(config, "{usage}%") : ALabel(config, "{usage}%", 10)
{ {
label_.set_name("cpu"); label_.set_name("cpu");
uint32_t interval = config_["interval"].isUInt() ? config_["interval"].asUInt() : 10; thread_ = [this] {
thread_ = [this, interval] {
dp.emit(); dp.emit();
thread_.sleep_for(chrono::seconds(interval)); thread_.sleep_for(interval_);
}; };
} }
auto waybar::modules::Cpu::update() -> void auto waybar::modules::Cpu::update() -> void
{ {
try { // TODO: as creating dynamic fmt::arg arrays is buggy we have to calc both
// TODO: as creating dynamic fmt::arg arrays is buggy we have to calc both auto cpu_load = getCpuLoad();
auto cpu_load = getCpuLoad(); auto [cpu_usage, tooltip] = getCpuUsage();
auto [cpu_usage, tooltip] = getCpuUsage(); label_.set_tooltip_text(tooltip);
label_.set_tooltip_text(tooltip); label_.set_markup(fmt::format(format_,
label_.set_markup(fmt::format(format_, fmt::arg("load", cpu_load), fmt::arg("usage", cpu_usage)));
fmt::arg("load", cpu_load), fmt::arg("usage", cpu_usage)));
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
}
} }
uint16_t waybar::modules::Cpu::getCpuLoad() uint16_t waybar::modules::Cpu::getCpuLoad()

View File

@ -4,20 +4,20 @@ waybar::modules::Custom::Custom(const std::string name,
const Json::Value& config) const Json::Value& config)
: ALabel(config, "{}"), name_(name) : ALabel(config, "{}"), name_(name)
{ {
if (!config_["exec"].isString()) { if (config_["exec"].isString()) {
throw std::runtime_error(name_ + " has no exec path."); if (interval_.count() > 0) {
} delayWorker();
if (config_["interval"].isUInt()) { } else {
delayWorker(); continuousWorker();
}
} else { } else {
continuousWorker(); update();
} }
} }
void waybar::modules::Custom::delayWorker() void waybar::modules::Custom::delayWorker()
{ {
auto interval = config_["interval"].asUInt(); thread_ = [this] {
thread_ = [this, interval] {
bool can_update = true; bool can_update = true;
if (config_["exec-if"].isString()) { if (config_["exec-if"].isString()) {
auto res = waybar::util::command::exec(config_["exec-if"].asString()); auto res = waybar::util::command::exec(config_["exec-if"].asString());
@ -31,7 +31,7 @@ void waybar::modules::Custom::delayWorker()
output_ = waybar::util::command::exec(config_["exec"].asString()); output_ = waybar::util::command::exec(config_["exec"].asString());
dp.emit(); dp.emit();
} }
thread_.sleep_for(chrono::seconds(interval)); thread_.sleep_for(interval_);
}; };
} }
@ -67,7 +67,7 @@ void waybar::modules::Custom::continuousWorker()
auto waybar::modules::Custom::update() -> void auto waybar::modules::Custom::update() -> void
{ {
// Hide label if output is empty // Hide label if output is empty
if (output_.out.empty() || output_.exit_code != 0) { if (config_["exec"].isString() && (output_.out.empty() || output_.exit_code != 0)) {
label_.hide(); label_.hide();
label_.set_name(""); label_.set_name("");
} else { } else {
@ -133,4 +133,4 @@ void waybar::modules::Custom::parseOutputJson()
class_ = parsed["class"].asString(); class_ = parsed["class"].asString();
break; break;
} }
} }

View File

@ -1,12 +1,11 @@
#include "modules/memory.hpp" #include "modules/memory.hpp"
waybar::modules::Memory::Memory(const Json::Value& config) waybar::modules::Memory::Memory(const Json::Value& config)
: ALabel(config, "{}%") : ALabel(config, "{}%", 30)
{ {
uint32_t interval = config_["interval"].isUInt() ? config_["interval"].asUInt() : 30; thread_ = [this] {
thread_ = [this, interval] {
dp.emit(); dp.emit();
thread_.sleep_for(chrono::seconds(interval)); thread_.sleep_for(interval_);
}; };
} }

View File

@ -1,7 +1,7 @@
#include "modules/network.hpp" #include "modules/network.hpp"
waybar::modules::Network::Network(const Json::Value& config) waybar::modules::Network::Network(const Json::Value& config)
: ALabel(config, "{ifname}"), family_(AF_INET), : ALabel(config, "{ifname}", 60), family_(AF_INET),
signal_strength_dbm_(0), signal_strength_(0) signal_strength_dbm_(0), signal_strength_(0)
{ {
sock_fd_ = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); sock_fd_ = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
@ -47,8 +47,10 @@ void waybar::modules::Network::worker()
{ {
thread_ = [this] { thread_ = [this] {
char buf[4096]; char buf[4096];
uint64_t len = netlinkResponse(sock_fd_, buf, sizeof(buf), auto len = netlinkResponse(sock_fd_, buf, sizeof(buf), RTMGRP_LINK | RTMGRP_IPV4_IFADDR);
RTMGRP_LINK | RTMGRP_IPV4_IFADDR); if (len == 0) {
return;
}
bool need_update = false; bool need_update = false;
for (auto nh = reinterpret_cast<struct nlmsghdr *>(buf); NLMSG_OK(nh, len); for (auto nh = reinterpret_cast<struct nlmsghdr *>(buf); NLMSG_OK(nh, len);
nh = NLMSG_NEXT(nh, len)) { nh = NLMSG_NEXT(nh, len)) {
@ -81,13 +83,14 @@ void waybar::modules::Network::worker()
} }
} }
if (need_update) { if (need_update) {
getInfo(); if (ifid_ > 0) {
getInfo();
}
dp.emit(); dp.emit();
} }
}; };
uint32_t interval = config_["interval"].isUInt() ? config_["interval"].asUInt() : 60; thread_timer_ = [this] {
thread_timer_ = [this, interval] { thread_.sleep_for(interval_);
thread_.sleep_for(std::chrono::seconds(interval));
if (ifid_ > 0) { if (ifid_ > 0) {
getInfo(); getInfo();
dp.emit(); dp.emit();
@ -320,13 +323,12 @@ int waybar::modules::Network::netlinkRequest(int fd, void *req,
int waybar::modules::Network::netlinkResponse(int fd, void *resp, int waybar::modules::Network::netlinkResponse(int fd, void *resp,
uint32_t resplen, uint32_t groups) uint32_t resplen, uint32_t groups)
{ {
int ret;
struct sockaddr_nl sa = {}; struct sockaddr_nl sa = {};
sa.nl_family = AF_NETLINK; sa.nl_family = AF_NETLINK;
sa.nl_groups = groups; sa.nl_groups = groups;
struct iovec iov = { resp, resplen }; struct iovec iov = { resp, resplen };
struct msghdr msg = { &sa, sizeof(sa), &iov, 1, nullptr, 0, 0 }; struct msghdr msg = { &sa, sizeof(sa), &iov, 1, nullptr, 0, 0 };
ret = recvmsg(fd, &msg, 0); auto ret = recvmsg(fd, &msg, 0);
if (msg.msg_flags & MSG_TRUNC) { if (msg.msg_flags & MSG_TRUNC) {
return -1; return -1;
} }
@ -421,7 +423,7 @@ auto waybar::modules::Network::getInfo() -> void
{ {
struct nl_msg* nl_msg = nlmsg_alloc(); struct nl_msg* nl_msg = nlmsg_alloc();
if (nl_msg == nullptr) { if (nl_msg == nullptr) {
nl_socket_free(sk_); nlmsg_free(nl_msg);
return; return;
} }
if (genlmsg_put(nl_msg, NL_AUTO_PORT, NL_AUTO_SEQ, nl80211_id_, 0, NLM_F_DUMP, if (genlmsg_put(nl_msg, NL_AUTO_PORT, NL_AUTO_SEQ, nl80211_id_, 0, NLM_F_DUMP,

View File

@ -5,37 +5,28 @@
using namespace waybar::modules::SNI; using namespace waybar::modules::SNI;
Watcher::Watcher() Watcher::Watcher()
{ : bus_name_id_(Gio::DBus::own_name(Gio::DBus::BusType::BUS_TYPE_SESSION,
GBusNameOwnerFlags flags = static_cast<GBusNameOwnerFlags>( "org.kde.StatusNotifierWatcher", sigc::mem_fun(*this, &Watcher::busAcquired),
G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT Gio::DBus::SlotNameAcquired(), Gio::DBus::SlotNameLost(),
| G_BUS_NAME_OWNER_FLAGS_REPLACE); Gio::DBus::BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT | Gio::DBus::BUS_NAME_OWNER_FLAGS_REPLACE)),
bus_name_id_ = g_bus_own_name(G_BUS_TYPE_SESSION, watcher_(sn_watcher_skeleton_new())
"org.kde.StatusNotifierWatcher", flags,
&Watcher::busAcquired, nullptr, nullptr, this, nullptr);
watcher_ = sn_watcher_skeleton_new();
sn_watcher_set_protocol_version(watcher_, 1);
}
Watcher::~Watcher()
{ {
} }
void Watcher::busAcquired(GDBusConnection* connection, const gchar* name, void Watcher::busAcquired(const Glib::RefPtr<Gio::DBus::Connection>& conn, Glib::ustring name)
gpointer data)
{ {
GError* error = nullptr; GError* error = nullptr;
auto host = static_cast<SNI::Watcher*>(data); g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(watcher_),
g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(host->watcher_), conn->gobj(), "/StatusNotifierWatcher", &error);
connection, "/StatusNotifierWatcher", &error);
if (error != nullptr) { if (error != nullptr) {
std::cerr << error->message << std::endl; std::cerr << error->message << std::endl;
g_error_free(error); g_error_free(error);
return; return;
} }
g_signal_connect_swapped(host->watcher_, "handle-register-item", g_signal_connect_swapped(watcher_, "handle-register-item",
G_CALLBACK(&Watcher::handleRegisterItem), data); G_CALLBACK(&Watcher::handleRegisterItem), this);
g_signal_connect_swapped(host->watcher_, "handle-register-host", g_signal_connect_swapped(watcher_, "handle-register-host",
G_CALLBACK(&Watcher::handleRegisterHost), data); G_CALLBACK(&Watcher::handleRegisterHost), this);
} }
gboolean Watcher::handleRegisterHost(Watcher* obj, gboolean Watcher::handleRegisterHost(Watcher* obj,