no compile errors, fully functional workspace indicators
This commit is contained in:
@@ -1,72 +0,0 @@
|
||||
#include "widgets/bluetooth.hpp"
|
||||
#include "gtkmm/label.h"
|
||||
|
||||
|
||||
BluetoothWidget::BluetoothWidget() : Gtk::Box() {
|
||||
this->set_orientation(Gtk::Orientation::VERTICAL);
|
||||
this->add_css_class("bluetooth-popover-container");
|
||||
|
||||
this->statusArea.add_css_class("bluetooth-status-area");
|
||||
this->statusArea.set_hexpand(true);
|
||||
this->statusArea.set_halign(Gtk::Align::FILL);
|
||||
this->append(this->statusArea);
|
||||
|
||||
this->powerButton = Gtk::make_managed<Button>("\ue1a8");
|
||||
this->powerButton->set_tooltip_text("Turn Bluetooth Off");
|
||||
this->powerButton->signal_clicked().connect(sigc::mem_fun(*this, &BluetoothWidget::onPowerButtonClicked));
|
||||
this->powerButton->add_css_class("toggle-button");
|
||||
|
||||
this->scanButton = Gtk::make_managed<Button>("\ue1aa");
|
||||
this->scanButton->set_tooltip_text("Scan for Devices");
|
||||
this->scanButton->add_css_class("toggle-button");
|
||||
this->scanButton->signal_clicked().connect(sigc::mem_fun(*this, &BluetoothWidget::onScanButtonClicked));
|
||||
|
||||
this->statusArea.append(*this->powerButton);
|
||||
this->statusArea.append(*this->scanButton);
|
||||
}
|
||||
|
||||
void BluetoothWidget::onPowerButtonClicked() {
|
||||
onPowerStateButtonClickedSignal.emit();
|
||||
}
|
||||
|
||||
void BluetoothWidget::onScanButtonClicked() {
|
||||
onIsDiscoveringButtonClickedSignal.emit();
|
||||
}
|
||||
|
||||
void BluetoothWidget::toggleButton(Button *button, bool state) {
|
||||
if (state) {
|
||||
button->add_css_class("toggle-button-on");
|
||||
button->remove_css_class("toggle-button-off");
|
||||
} else {
|
||||
button->add_css_class("toggle-button-off");
|
||||
button->remove_css_class("toggle-button-on");
|
||||
}
|
||||
}
|
||||
|
||||
void BluetoothWidget::setPowerState(bool state) {
|
||||
this->isPowered = state;
|
||||
|
||||
this->scanButton->set_sensitive(state);
|
||||
|
||||
if (!state) {
|
||||
this->scanButton->add_css_class("toggle-button-disabled");
|
||||
// this->add_css_class("disabled-popover-icon");
|
||||
this->setIsDiscovering(false);
|
||||
} else {
|
||||
this->scanButton->remove_css_class("toggle-button-disabled");
|
||||
// this->remove_css_class("disabled-popover-icon");
|
||||
}
|
||||
|
||||
this->toggleButton(this->powerButton, state);
|
||||
}
|
||||
|
||||
void BluetoothWidget::setIsDiscovering(bool state) {
|
||||
this->isDiscovering = state;
|
||||
|
||||
this->toggleButton(this->scanButton, state);
|
||||
}
|
||||
|
||||
void BluetoothWidget::update() {
|
||||
setPowerState(isPowered);
|
||||
setIsDiscovering(isDiscovering);
|
||||
}
|
||||
@@ -5,20 +5,4 @@ ControlCenter::ControlCenter(std::string icon, std::string name)
|
||||
this->popover->set_size_request(200, -1);
|
||||
set_popover_child(this->container);
|
||||
|
||||
this->bluetoothWidget = Gtk::make_managed<BluetoothWidget>();
|
||||
this->container.append(*this->bluetoothWidget);
|
||||
|
||||
bluetoothService->powerStateChangedSignal.connect(
|
||||
sigc::mem_fun(*this->bluetoothWidget, &BluetoothWidget::setPowerState));
|
||||
|
||||
bluetoothWidget->onPowerStateButtonClickedSignal.connect(
|
||||
sigc::mem_fun(*this->bluetoothService, &BluetoothService::togglePowerState));
|
||||
|
||||
bluetoothWidget->setPowerState(bluetoothService->getPowerState());
|
||||
|
||||
bluetoothService->isDiscoveringChangedSignal.connect(
|
||||
sigc::mem_fun(*this->bluetoothWidget, &BluetoothWidget::setIsDiscovering));
|
||||
bluetoothWidget->onIsDiscoveringButtonClickedSignal.connect(
|
||||
sigc::mem_fun(*this->bluetoothService, &BluetoothService::toggleIsDiscovering));
|
||||
bluetoothWidget->setIsDiscovering(bluetoothService->getIsDiscovering());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user