add tray icons
This commit is contained in:
53
include/widgets/tray.hpp
Normal file
53
include/widgets/tray.hpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtkmm/box.h>
|
||||
#include <gtkmm/button.h>
|
||||
#include <gtkmm/gestureclick.h>
|
||||
#include <gtkmm/picture.h>
|
||||
#include <gtkmm/image.h>
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "services/tray.hpp"
|
||||
|
||||
class TrayIconWidget : public Gtk::Button
|
||||
{
|
||||
public:
|
||||
TrayIconWidget(TrayService &service, std::string id);
|
||||
|
||||
void update(const TrayService::Item &item);
|
||||
|
||||
private:
|
||||
TrayService &m_service;
|
||||
std::string m_id;
|
||||
Gtk::Box m_container;
|
||||
Gtk::Picture m_picture;
|
||||
Gtk::Image m_image;
|
||||
Glib::RefPtr<Gtk::GestureClick> m_secondaryGesture;
|
||||
|
||||
void on_primary_clicked();
|
||||
void on_secondary_released(int n_press, double x, double y);
|
||||
};
|
||||
|
||||
class TrayWidget : public Gtk::Box
|
||||
{
|
||||
public:
|
||||
explicit TrayWidget(TrayService &service);
|
||||
~TrayWidget() override;
|
||||
|
||||
private:
|
||||
TrayService &m_service;
|
||||
std::map<std::string, std::unique_ptr<TrayIconWidget>> m_icons;
|
||||
|
||||
sigc::connection m_addConnection;
|
||||
sigc::connection m_removeConnection;
|
||||
sigc::connection m_updateConnection;
|
||||
|
||||
void on_item_added(const TrayService::Item &item);
|
||||
void on_item_removed(const std::string &id);
|
||||
void on_item_updated(const TrayService::Item &item);
|
||||
|
||||
void rebuild_existing();
|
||||
};
|
||||
Reference in New Issue
Block a user