Add support for vertical bars in privacy module
This commit is contained in:
@ -13,7 +13,7 @@ namespace waybar::modules::privacy {
|
|||||||
|
|
||||||
class Privacy : public AModule {
|
class Privacy : public AModule {
|
||||||
public:
|
public:
|
||||||
Privacy(const std::string &, const Json::Value &, const std::string &pos);
|
Privacy(const std::string &, const Json::Value &, Gtk::Orientation, const std::string &pos);
|
||||||
auto update() -> void override;
|
auto update() -> void override;
|
||||||
|
|
||||||
void onPrivacyNodesChanged();
|
void onPrivacyNodesChanged();
|
||||||
|
@ -17,8 +17,8 @@ namespace waybar::modules::privacy {
|
|||||||
class PrivacyItem : public Gtk::Revealer {
|
class PrivacyItem : public Gtk::Revealer {
|
||||||
public:
|
public:
|
||||||
PrivacyItem(const Json::Value &config_, enum PrivacyNodeType privacy_type_,
|
PrivacyItem(const Json::Value &config_, enum PrivacyNodeType privacy_type_,
|
||||||
std::list<PrivacyNodeInfo *> *nodes, const std::string &pos, const uint icon_size,
|
std::list<PrivacyNodeInfo *> *nodes, Gtk::Orientation orientation,
|
||||||
const uint transition_duration);
|
const std::string &pos, const uint icon_size, const uint transition_duration);
|
||||||
|
|
||||||
enum PrivacyNodeType privacy_type;
|
enum PrivacyNodeType privacy_type;
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name,
|
|||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_PIPEWIRE
|
#ifdef HAVE_PIPEWIRE
|
||||||
if (ref == "privacy") {
|
if (ref == "privacy") {
|
||||||
return new waybar::modules::privacy::Privacy(id, config_[name], pos);
|
return new waybar::modules::privacy::Privacy(id, config_[name], bar_.orientation, pos);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_MPRIS
|
#ifdef HAVE_MPRIS
|
||||||
|
@ -15,13 +15,14 @@ using util::PipewireBackend::PRIVACY_NODE_TYPE_AUDIO_OUTPUT;
|
|||||||
using util::PipewireBackend::PRIVACY_NODE_TYPE_NONE;
|
using util::PipewireBackend::PRIVACY_NODE_TYPE_NONE;
|
||||||
using util::PipewireBackend::PRIVACY_NODE_TYPE_VIDEO_INPUT;
|
using util::PipewireBackend::PRIVACY_NODE_TYPE_VIDEO_INPUT;
|
||||||
|
|
||||||
Privacy::Privacy(const std::string& id, const Json::Value& config, const std::string& pos)
|
Privacy::Privacy(const std::string& id, const Json::Value& config, Gtk::Orientation orientation,
|
||||||
|
const std::string& pos)
|
||||||
: AModule(config, "privacy", id),
|
: AModule(config, "privacy", id),
|
||||||
nodes_screenshare(),
|
nodes_screenshare(),
|
||||||
nodes_audio_in(),
|
nodes_audio_in(),
|
||||||
nodes_audio_out(),
|
nodes_audio_out(),
|
||||||
visibility_conn(),
|
visibility_conn(),
|
||||||
box_(Gtk::ORIENTATION_HORIZONTAL, 0) {
|
box_(orientation, 0) {
|
||||||
box_.set_name(name_);
|
box_.set_name(name_);
|
||||||
|
|
||||||
event_box_.add(box_);
|
event_box_.add(box_);
|
||||||
@ -67,8 +68,8 @@ Privacy::Privacy(const std::string& id, const Json::Value& config, const std::st
|
|||||||
auto iter = typeMap.find(type);
|
auto iter = typeMap.find(type);
|
||||||
if (iter != typeMap.end()) {
|
if (iter != typeMap.end()) {
|
||||||
auto& [nodePtr, nodeType] = iter->second;
|
auto& [nodePtr, nodeType] = iter->second;
|
||||||
auto* item = Gtk::make_managed<PrivacyItem>(module, nodeType, nodePtr, pos, iconSize,
|
auto* item = Gtk::make_managed<PrivacyItem>(module, nodeType, nodePtr, orientation, pos,
|
||||||
transition_duration);
|
iconSize, transition_duration);
|
||||||
box_.add(*item);
|
box_.add(*item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,9 @@
|
|||||||
namespace waybar::modules::privacy {
|
namespace waybar::modules::privacy {
|
||||||
|
|
||||||
PrivacyItem::PrivacyItem(const Json::Value &config_, enum PrivacyNodeType privacy_type_,
|
PrivacyItem::PrivacyItem(const Json::Value &config_, enum PrivacyNodeType privacy_type_,
|
||||||
std::list<PrivacyNodeInfo *> *nodes_, const std::string &pos,
|
std::list<PrivacyNodeInfo *> *nodes_, Gtk::Orientation orientation,
|
||||||
const uint icon_size, const uint transition_duration)
|
const std::string &pos, const uint icon_size,
|
||||||
|
const uint transition_duration)
|
||||||
: Gtk::Revealer(),
|
: Gtk::Revealer(),
|
||||||
privacy_type(privacy_type_),
|
privacy_type(privacy_type_),
|
||||||
nodes(nodes_),
|
nodes(nodes_),
|
||||||
@ -40,16 +41,24 @@ PrivacyItem::PrivacyItem(const Json::Value &config_, enum PrivacyNodeType privac
|
|||||||
|
|
||||||
// Set the reveal transition to not look weird when sliding in
|
// Set the reveal transition to not look weird when sliding in
|
||||||
if (pos == "modules-left") {
|
if (pos == "modules-left") {
|
||||||
set_transition_type(Gtk::REVEALER_TRANSITION_TYPE_SLIDE_RIGHT);
|
set_transition_type(orientation == Gtk::ORIENTATION_HORIZONTAL
|
||||||
|
? Gtk::REVEALER_TRANSITION_TYPE_SLIDE_RIGHT
|
||||||
|
: Gtk::REVEALER_TRANSITION_TYPE_SLIDE_DOWN);
|
||||||
} else if (pos == "modules-center") {
|
} else if (pos == "modules-center") {
|
||||||
set_transition_type(Gtk::REVEALER_TRANSITION_TYPE_CROSSFADE);
|
set_transition_type(Gtk::REVEALER_TRANSITION_TYPE_CROSSFADE);
|
||||||
} else if (pos == "modules-right") {
|
} else if (pos == "modules-right") {
|
||||||
set_transition_type(Gtk::REVEALER_TRANSITION_TYPE_SLIDE_LEFT);
|
set_transition_type(orientation == Gtk::ORIENTATION_HORIZONTAL
|
||||||
|
? Gtk::REVEALER_TRANSITION_TYPE_SLIDE_LEFT
|
||||||
|
: Gtk::REVEALER_TRANSITION_TYPE_SLIDE_UP);
|
||||||
}
|
}
|
||||||
set_transition_duration(transition_duration);
|
set_transition_duration(transition_duration);
|
||||||
|
|
||||||
box_.set_name("privacy-item");
|
box_.set_name("privacy-item");
|
||||||
box_.add(icon_);
|
|
||||||
|
// We use `set_center_widget` instead of `add` to make sure the icon is
|
||||||
|
// centered even if the orientation is vertical
|
||||||
|
box_.set_center_widget(icon_);
|
||||||
|
|
||||||
icon_.set_pixel_size(icon_size);
|
icon_.set_pixel_size(icon_size);
|
||||||
add(box_);
|
add(box_);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user