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