refactor(tray): use Gio::DBus bindings in SNI Item class

This commit is contained in:
Aleksei Bavshin
2019-03-27 19:56:19 -07:00
parent 842e8501f9
commit 82fcee33b3
2 changed files with 98 additions and 105 deletions

View File

@ -2,12 +2,14 @@
#include <dbus-status-notifier-item.h>
#include <glibmm/refptr.h>
#include <giomm/dbusproxy.h>
#include <gtkmm/eventbox.h>
#include <gtkmm/image.h>
#include <gtkmm/icontheme.h>
#include <gtkmm/menu.h>
#include <json/json.h>
#include <libdbusmenu-gtk/dbusmenu-gtk.h>
#include <sigc++/trackable.h>
#ifdef FILESYSTEM_EXPERIMENTAL
#include <experimental/filesystem>
#else
@ -16,7 +18,7 @@
namespace waybar::modules::SNI {
class Item {
class Item : public sigc::trackable {
public:
Item(std::string, std::string, const Json::Value&);
~Item() = default;
@ -46,8 +48,8 @@ public:
bool item_is_menu;
private:
static void proxyReady(GObject *obj, GAsyncResult *res, gpointer data);
static void getAll(GObject *obj, GAsyncResult *res, gpointer data);
void proxyReady(Glib::RefPtr<Gio::AsyncResult>& result);
void setProperty(const Glib::ustring& name, Glib::VariantBase& value);
void updateImage();
Glib::RefPtr<Gdk::Pixbuf> extractPixBuf(GVariant *variant);
@ -56,8 +58,8 @@ private:
bool makeMenu(GdkEventButton *const &ev);
bool handleClick(GdkEventButton *const & /*ev*/);
GCancellable *cancellable_ = nullptr;
SnItem *proxy_ = nullptr;
Glib::RefPtr<Gio::Cancellable> cancellable_;
Glib::RefPtr<Gio::DBus::Proxy> proxy_;
};
} // namespace waybar::modules::SNI