waybar/include/modules/sni/item.hpp

60 lines
1.5 KiB
C++
Raw Normal View History

#pragma once
#include <dbus-status-notifier-item.h>
#include <gtkmm.h>
2018-10-26 14:53:39 +02:00
#include <json/json.h>
#include <libdbusmenu-gtk/dbusmenu-gtk.h>
#ifdef FILESYSTEM_EXPERIMENTAL
2018-11-22 15:47:23 +01:00
#include <experimental/filesystem>
#else
2018-11-22 15:47:23 +01:00
#include <filesystem>
#endif
namespace waybar::modules::SNI {
class Item {
public:
2018-11-22 15:47:23 +01:00
Item(std::string, std::string, const Json::Value&);
~Item() = default;
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;
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;
Gtk::Menu *gtk_menu = nullptr;
bool item_is_menu;
private:
static void proxyReady(GObject *obj, GAsyncResult *res, gpointer data);
static void getAll(GObject *obj, GAsyncResult *res, gpointer data);
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);
bool handleClick(GdkEventButton *const & /*ev*/);
GCancellable *cancellable_ = nullptr;
2018-10-26 10:05:54 +02:00
SnItem *proxy_ = nullptr;
};
} // namespace waybar::modules::SNI