mirror of
https://github.com/rad4day/Waybar.git
synced 2025-07-13 22:52:30 +02:00
Added tooltips
This commit is contained in:
@ -12,12 +12,15 @@
|
||||
#include "gtkmm/revealer.h"
|
||||
#include "util/pipewire/privacy_node_info.hpp"
|
||||
|
||||
using waybar::util::PipewireBackend::PrivacyNodeInfo;
|
||||
using waybar::util::PipewireBackend::PrivacyNodeType;
|
||||
|
||||
namespace waybar::modules::privacy {
|
||||
|
||||
class PrivacyItem : public Gtk::Revealer {
|
||||
public:
|
||||
PrivacyItem(const Json::Value&, enum util::PipewireBackend::PrivacyNodeType privacy_type_,
|
||||
const std::string& pos);
|
||||
PrivacyItem(const Json::Value &config_, enum PrivacyNodeType privacy_type_,
|
||||
std::list<PrivacyNodeInfo *> *nodes, const std::string &pos);
|
||||
|
||||
bool is_enabled();
|
||||
|
||||
@ -26,9 +29,10 @@ class PrivacyItem : public Gtk::Revealer {
|
||||
void set_icon_size(uint size);
|
||||
|
||||
private:
|
||||
enum util::PipewireBackend::PrivacyNodeType privacy_type;
|
||||
enum PrivacyNodeType privacy_type;
|
||||
std::list<PrivacyNodeInfo *> *nodes;
|
||||
|
||||
std::mutex mutex_;
|
||||
Gtk::Box tooltip_window;
|
||||
|
||||
bool init = false;
|
||||
bool in_use = false;
|
||||
@ -37,12 +41,15 @@ class PrivacyItem : public Gtk::Revealer {
|
||||
// Config
|
||||
bool enabled = true;
|
||||
std::string iconName = "image-missing-symbolic";
|
||||
bool tooltip = true;
|
||||
uint tooltipIconSize = 24;
|
||||
|
||||
Gtk::Box box_;
|
||||
Gtk::Image icon_;
|
||||
|
||||
void on_child_revealed_changed();
|
||||
void on_map_changed();
|
||||
void update_tooltip();
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::privacy
|
||||
|
@ -30,7 +30,7 @@ class PipewireBackend {
|
||||
|
||||
sigc::signal<void> privacy_nodes_changed_signal_event;
|
||||
|
||||
std::unordered_map<uint32_t, PrivacyNodeInfo*> privacy_nodes;
|
||||
std::unordered_map<uint32_t, PrivacyNodeInfo> privacy_nodes;
|
||||
|
||||
static std::shared_ptr<PipewireBackend> getInstance();
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "util/gtk_icon.hpp"
|
||||
|
||||
namespace waybar::util::PipewireBackend {
|
||||
|
||||
enum PrivacyNodeType {
|
||||
@ -22,15 +24,44 @@ class PrivacyNodeInfo {
|
||||
std::string media_class;
|
||||
std::string media_name;
|
||||
std::string node_name;
|
||||
std::string application_name;
|
||||
|
||||
std::string pipewire_access_portal_app_id;
|
||||
std::string application_icon_name;
|
||||
|
||||
struct spa_hook node_listener;
|
||||
|
||||
bool changed = false;
|
||||
|
||||
void* data;
|
||||
void *data;
|
||||
|
||||
PrivacyNodeInfo(uint32_t id_, void* data_) : id(id_), data(data_) {}
|
||||
PrivacyNodeInfo(uint32_t id_, void *data_) : id(id_), data(data_) {}
|
||||
|
||||
~PrivacyNodeInfo() { spa_hook_remove(&node_listener); }
|
||||
|
||||
std::string get_name() {
|
||||
const std::vector<std::string *> names{&application_name, &node_name};
|
||||
std::string name = "Unknown Application";
|
||||
for (auto &name_ : names) {
|
||||
if (name_ != nullptr && name_->length() > 0) {
|
||||
name = *name_;
|
||||
name[0] = toupper(name[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
std::string get_icon_name() {
|
||||
const std::vector<std::string *> names{&application_icon_name, &pipewire_access_portal_app_id,
|
||||
&application_name, &node_name};
|
||||
std::string name = "application-x-executable-symbolic";
|
||||
for (auto &name_ : names) {
|
||||
if (name_ != nullptr && name_->length() > 0 && DefaultGtkIconThemeWrapper::has_icon(*name_)) {
|
||||
return *name_;
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
};
|
||||
} // namespace waybar::util::PipewireBackend
|
||||
|
Reference in New Issue
Block a user