Waybar/include/modules/sni/item.hpp

72 lines
2.3 KiB
C++
Raw Normal View History

#pragma once
#include <dbus-status-notifier-item.h>
#include <giomm/dbusproxy.h>
#include <glibmm/refptr.h>
#include <gtkmm/eventbox.h>
#include <gtkmm/icontheme.h>
#include <gtkmm/image.h>
#include <gtkmm/menu.h>
2018-10-26 12:53:39 +00:00
#include <json/json.h>
#include <libdbusmenu-gtk/dbusmenu-gtk.h>
#include <sigc++/trackable.h>
#ifdef FILESYSTEM_EXPERIMENTAL
2018-11-22 14:47:23 +00:00
#include <experimental/filesystem>
#else
2018-11-22 14:47:23 +00:00
#include <filesystem>
#endif
namespace waybar::modules::SNI {
class Item : public sigc::trackable {
public:
2019-04-24 10:37:24 +00:00
Item(const std::string&, const std::string&, const Json::Value&);
2018-11-22 14:47:23 +00:00
~Item() = default;
std::string bus_name;
std::string object_path;
2019-04-18 15:52:00 +00:00
int icon_size;
int effective_icon_size;
Gtk::Image image;
2018-11-22 14:47:23 +00:00
Gtk::EventBox event_box;
2019-04-18 15:52:00 +00:00
std::string category;
std::string id;
std::string status;
2019-04-18 15:52:00 +00:00
std::string title;
int32_t window_id;
std::string icon_name;
Glib::RefPtr<Gdk::Pixbuf> icon_pixmap;
2019-04-11 13:20:39 +00:00
Glib::RefPtr<Gtk::IconTheme> icon_theme;
2019-04-18 15:52:00 +00:00
std::string overlay_icon_name;
std::string attention_icon_name;
std::string attention_movie_name;
std::string icon_theme_path;
std::string menu;
DbusmenuGtkMenu* dbus_menu = nullptr;
Gtk::Menu* gtk_menu = nullptr;
bool item_is_menu;
private:
void proxyReady(Glib::RefPtr<Gio::AsyncResult>& result);
void setProperty(const Glib::ustring& name, Glib::VariantBase& value);
void getUpdatedProperties();
void processUpdatedProperties(Glib::RefPtr<Gio::AsyncResult>& result);
void onSignal(const Glib::ustring& sender_name, const Glib::ustring& signal_name,
const Glib::VariantContainerBase& arguments);
2019-04-18 15:52:00 +00:00
void updateImage();
Glib::RefPtr<Gdk::Pixbuf> extractPixBuf(GVariant* variant);
2019-04-24 10:37:24 +00:00
Glib::RefPtr<Gdk::Pixbuf> getIconByName(const std::string& name, int size);
2019-04-18 15:52:00 +00:00
static void onMenuDestroyed(Item* self);
bool makeMenu(GdkEventButton* const& ev);
bool handleClick(GdkEventButton* const& /*ev*/);
Glib::RefPtr<Gio::Cancellable> cancellable_;
Glib::RefPtr<Gio::DBus::Proxy> proxy_;
2019-04-18 15:52:00 +00:00
bool update_pending_;
};
} // namespace waybar::modules::SNI