mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
b8322c4b4b
The AButton class is designed as full a substitute to ALabel. The GtkButton attribute 'button_' is initialized with a label. This label can the be referenced by the subsequent inheritors of AButton instead of the GtkLabel attribute 'label_' of ALabel. For convenience a GtkLabel* 'label_' attribute is added to AButton. If the button cannot be clicked it is disabled, effectively acting like its label predecessor. GtkButton seems to catch one-click mouse events regardless of the flags set on it. Therefore, 'signal_pressed' is connected to a function creating a fake GdkEventButton* and calling 'handleToggle' (for details on this possible bug in GTK see: https://stackoverflow.com/questions/45334911 ) In accordance with other GtkButtons (i.e. the sway/workspace ones) set_relief(Gtk::RELIEF_NONE) is called on the 'button_' instance.
55 lines
1.4 KiB
C++
55 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <fmt/format.h>
|
|
#include <pulse/pulseaudio.h>
|
|
#include <pulse/volume.h>
|
|
|
|
#include <algorithm>
|
|
#include <array>
|
|
|
|
#include "AButton.hpp"
|
|
|
|
namespace waybar::modules {
|
|
|
|
class Pulseaudio : public AButton {
|
|
public:
|
|
Pulseaudio(const std::string&, const Json::Value&);
|
|
~Pulseaudio();
|
|
auto update() -> void;
|
|
|
|
private:
|
|
static void subscribeCb(pa_context*, pa_subscription_event_type_t, uint32_t, void*);
|
|
static void contextStateCb(pa_context*, void*);
|
|
static void sinkInfoCb(pa_context*, const pa_sink_info*, int, void*);
|
|
static void sourceInfoCb(pa_context*, const pa_source_info* i, int, void* data);
|
|
static void serverInfoCb(pa_context*, const pa_server_info*, void*);
|
|
static void volumeModifyCb(pa_context*, int, void*);
|
|
|
|
bool handleScroll(GdkEventScroll* e);
|
|
const std::vector<std::string> getPulseIcon() const;
|
|
|
|
pa_threaded_mainloop* mainloop_;
|
|
pa_mainloop_api* mainloop_api_;
|
|
pa_context* context_;
|
|
// SINK
|
|
uint32_t sink_idx_{0};
|
|
uint16_t volume_;
|
|
pa_cvolume pa_volume_;
|
|
bool muted_;
|
|
std::string port_name_;
|
|
std::string form_factor_;
|
|
std::string desc_;
|
|
std::string monitor_;
|
|
std::string current_sink_name_;
|
|
bool current_sink_running_;
|
|
// SOURCE
|
|
uint32_t source_idx_{0};
|
|
uint16_t source_volume_;
|
|
bool source_muted_;
|
|
std::string source_port_name_;
|
|
std::string source_desc_;
|
|
std::string default_source_name_;
|
|
};
|
|
|
|
} // namespace waybar::modules
|