bar can now toggle bluetooth power and discovery
This commit is contained in:
@@ -3,12 +3,14 @@
|
||||
#include <vector>
|
||||
|
||||
#include "bar/bar.hpp"
|
||||
#include "glibmm/refptr.h"
|
||||
#include "gtkmm/application.h"
|
||||
#include "services/bluetooth.hpp"
|
||||
#include "services/hyprland.hpp"
|
||||
#include "services/notifications.hpp"
|
||||
#include "services/tray.hpp"
|
||||
|
||||
#include "glibmm/refptr.h"
|
||||
#include "gtkmm/application.h"
|
||||
|
||||
class App {
|
||||
public:
|
||||
App();
|
||||
@@ -21,6 +23,7 @@ class App {
|
||||
HyprlandService hyprlandService;
|
||||
NotificationService notificationService;
|
||||
TrayService trayService;
|
||||
BluetoothService bluetoothService;
|
||||
|
||||
void setupServices();
|
||||
};
|
||||
@@ -2,9 +2,12 @@
|
||||
|
||||
#include <gtk4-layer-shell/gtk4-layer-shell.h>
|
||||
#include <gtkmm.h>
|
||||
|
||||
#include "icons.hpp"
|
||||
#include "services/bluetooth.hpp"
|
||||
#include "services/hyprland.hpp"
|
||||
#include "services/tray.hpp"
|
||||
#include "widgets/bluetooth.hpp"
|
||||
#include "widgets/clock.hpp"
|
||||
#include "widgets/date.hpp"
|
||||
#include "widgets/tray.hpp"
|
||||
@@ -14,7 +17,7 @@
|
||||
|
||||
class Bar : public Gtk::Window {
|
||||
public:
|
||||
Bar(GdkMonitor *monitor, HyprlandService &hyprlandService, TrayService &trayService, int monitorId);
|
||||
Bar(GdkMonitor *monitor, HyprlandService &hyprlandService, TrayService &trayService, BluetoothService &bluetoothService, int monitorId);
|
||||
|
||||
protected:
|
||||
Gtk::CenterBox main_box{};
|
||||
@@ -30,11 +33,13 @@ class Bar : public Gtk::Window {
|
||||
WebWidget homeAssistant{ICON_HOME, "Home Assistant", "https://home.rivercry.com"};
|
||||
|
||||
WorkspaceIndicator *workspaceIndicator = nullptr;
|
||||
TrayWidget *trayWidget = nullptr;
|
||||
VolumeWidget *volumeWidget = nullptr;
|
||||
TrayWidget *trayWidget = nullptr;
|
||||
VolumeWidget *volumeWidget = nullptr;
|
||||
BluetoothWidget *bluetoothWidget = nullptr;
|
||||
|
||||
TrayService &trayService;
|
||||
HyprlandService &hyprlandService;
|
||||
BluetoothService &bluetoothService;
|
||||
|
||||
void setup_ui();
|
||||
void setup_left_box();
|
||||
|
||||
@@ -2,18 +2,17 @@
|
||||
|
||||
#include <gtkmm/button.h>
|
||||
#include <gtkmm/popover.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
class Popover: public Gtk::Button {
|
||||
public:
|
||||
class Popover : public Gtk::Button {
|
||||
public:
|
||||
Popover(std::string icon, std::string name);
|
||||
~Popover() override;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void on_toggle_window();
|
||||
Gtk::Popover* popover = nullptr;
|
||||
void set_popover_child(Gtk::Widget& child) {
|
||||
Gtk::Popover *popover = nullptr;
|
||||
void set_popover_child(Gtk::Widget &child) {
|
||||
gtk_popover_set_child(popover->gobj(), child.gobj());
|
||||
}
|
||||
};
|
||||
@@ -1,20 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "gtkmm/box.h"
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "gtkmm/box.h"
|
||||
|
||||
class TodoEntry : public Gtk::Box {
|
||||
public:
|
||||
TodoEntry(int id, std::string text, sigc::signal<void(int)> signal_dismissed);
|
||||
public:
|
||||
TodoEntry(int id, std::string text, sigc::signal<void(int)> signal_dismissed, sigc::signal<void(int, std::string)> signal_edited);
|
||||
~TodoEntry() override;
|
||||
|
||||
int get_id() const { return id; }
|
||||
std::string get_text() const { return text; }
|
||||
private:
|
||||
|
||||
private:
|
||||
int id;
|
||||
std::string text;
|
||||
sigc::signal<void(int)> signal_dismissed;
|
||||
sigc::signal<void(int, std::string)> signal_edited;
|
||||
|
||||
void on_dismiss_clicked();
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
class IUpdatable {
|
||||
public:
|
||||
virtual ~IUpdatable() = default;
|
||||
public:
|
||||
virtual ~IUpdatable() = default;
|
||||
virtual bool onUpdate() = 0;
|
||||
};
|
||||
35
include/services/bluetooth.hpp
Normal file
35
include/services/bluetooth.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "sigc++/signal.h"
|
||||
|
||||
class BluetoothService {
|
||||
public:
|
||||
BluetoothService();
|
||||
|
||||
sigc::signal<void(bool)> powerStateChangedSignal;
|
||||
sigc::signal<void(bool)> isDiscoveringChangedSignal;
|
||||
|
||||
bool getPowerState();
|
||||
void setPowerState(bool state);
|
||||
|
||||
bool getIsDiscovering();
|
||||
void setIsDiscovering(bool state);
|
||||
|
||||
private:
|
||||
GDBusProxy *adapter_proxy = nullptr;
|
||||
bool powerState = false;
|
||||
bool isDiscovering = false;
|
||||
|
||||
void onPropertyChanged(GDBusProxy *proxy,
|
||||
GVariant *changed_properties,
|
||||
const gchar *const *invalidated_properties,
|
||||
gpointer user_data);
|
||||
|
||||
static void onPropertyChangedStatic(GDBusProxy *proxy,
|
||||
GVariant *changed_properties,
|
||||
const gchar *const *invalidated_properties,
|
||||
gpointer user_data);
|
||||
};
|
||||
@@ -3,18 +3,18 @@
|
||||
#include <gio/gio.h>
|
||||
|
||||
class NotificationService {
|
||||
public:
|
||||
public:
|
||||
void intialize();
|
||||
|
||||
NotificationService() = default;
|
||||
~NotificationService();
|
||||
|
||||
guint32 allocateNotificationId(guint32 replacesId);
|
||||
GDBusConnection* getConnection() const { return connection; }
|
||||
GDBusConnection *getConnection() const { return connection; }
|
||||
|
||||
private:
|
||||
GDBusConnection* connection = nullptr;
|
||||
guint registrationId = 0;
|
||||
GDBusNodeInfo* nodeInfo = nullptr;
|
||||
guint32 nextNotificationId = 1;
|
||||
private:
|
||||
GDBusConnection *connection = nullptr;
|
||||
guint registrationId = 0;
|
||||
GDBusNodeInfo *nodeInfo = nullptr;
|
||||
guint32 nextNotificationId = 1;
|
||||
};
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "components/todoEntry.hpp"
|
||||
#include "services/todoAdapter.hpp"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
class TodoService {
|
||||
public:
|
||||
|
||||
@@ -12,10 +12,10 @@ class ITodoAdapter {
|
||||
public:
|
||||
virtual ~ITodoAdapter() = default;
|
||||
|
||||
virtual bool init() = 0;
|
||||
virtual bool init() = 0;
|
||||
virtual std::vector<TodoRecord> listTodos() = 0;
|
||||
|
||||
virtual int addTodo(const std::string &text) = 0;
|
||||
virtual bool removeTodo(int id) = 0;
|
||||
virtual int addTodo(const std::string &text) = 0;
|
||||
virtual bool removeTodo(int id) = 0;
|
||||
virtual bool updateTodo(int id, const std::string &text) = 0;
|
||||
};
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include <gdkmm/memorytexture.h>
|
||||
#include <gio/gio.h>
|
||||
#include <giomm/actiongroup.h>
|
||||
#include <giomm/dbusconnection.h>
|
||||
#include <giomm/init.h>
|
||||
#include <giomm/menumodel.h>
|
||||
#include <glibmm/bytes.h>
|
||||
#include <glibmm/refptr.h>
|
||||
#include <sigc++/sigc++.h>
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <sigc++/sigc++.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -49,8 +48,8 @@ class TrayService {
|
||||
struct MenuNode {
|
||||
int id = 0;
|
||||
std::string label;
|
||||
bool enabled = true;
|
||||
bool visible = true;
|
||||
bool enabled = true;
|
||||
bool visible = true;
|
||||
bool separator = false;
|
||||
std::vector<MenuNode> children;
|
||||
};
|
||||
@@ -65,7 +64,7 @@ class TrayService {
|
||||
struct TrackedItem {
|
||||
Item publicData;
|
||||
guint signalSubscriptionId = 0;
|
||||
guint ownerWatchId = 0;
|
||||
guint ownerWatchId = 0;
|
||||
Glib::RefPtr<Gio::MenuModel> menuModel;
|
||||
Glib::RefPtr<Gio::ActionGroup> menuActions;
|
||||
};
|
||||
@@ -74,9 +73,9 @@ class TrayService {
|
||||
Glib::RefPtr<Gio::DBus::NodeInfo> nodeInfo;
|
||||
Gio::DBus::InterfaceVTable vtable;
|
||||
|
||||
guint nameOwnerId = 0;
|
||||
guint nameOwnerId = 0;
|
||||
guint registrationId = 0;
|
||||
bool hostRegistered = false;
|
||||
bool hostRegistered = false;
|
||||
|
||||
std::map<std::string, std::unique_ptr<TrackedItem>> items;
|
||||
|
||||
|
||||
31
include/widgets/bluetooth.hpp
Normal file
31
include/widgets/bluetooth.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtkmm/box.h>
|
||||
|
||||
#include "components/popover.hpp"
|
||||
|
||||
#include "gtkmm/button.h"
|
||||
|
||||
class BluetoothWidget : public Popover {
|
||||
public:
|
||||
BluetoothWidget(std::string icon, std::string title);
|
||||
|
||||
void setPowerState(bool state);
|
||||
void setIsDiscovering(bool state);
|
||||
|
||||
sigc::signal<void(bool)> powerStateChangedSignal;
|
||||
sigc::signal<void(bool)> isDiscoveringChangedSignal;
|
||||
|
||||
void update();
|
||||
private:
|
||||
bool isPowered = false;
|
||||
bool isDiscovering = false;
|
||||
|
||||
Gtk::Box container;
|
||||
Gtk::Box statusArea;
|
||||
|
||||
Gtk::Box *deviceList = nullptr;
|
||||
|
||||
Gtk::Button *scanButton = nullptr;
|
||||
Gtk::Button *toggleButton = nullptr;
|
||||
};
|
||||
@@ -1,19 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "components/popover.hpp"
|
||||
#include "services/todo.hpp"
|
||||
#include <string>
|
||||
|
||||
class TodoPopover : public Popover {
|
||||
|
||||
public:
|
||||
public:
|
||||
TodoPopover(std::string icon, std::string title);
|
||||
|
||||
void update();
|
||||
private:
|
||||
|
||||
private:
|
||||
std::string name;
|
||||
TodoService* todoService = nullptr;
|
||||
TodoService *todoService = nullptr;
|
||||
Gtk::Box container;
|
||||
Gtk::Box inputArea;
|
||||
Gtk::Box* todoList = nullptr;
|
||||
Gtk::Box *todoList = nullptr;
|
||||
};
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <gtkmm/image.h>
|
||||
#include <gtkmm/picture.h>
|
||||
#include <gtkmm/popovermenu.h>
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -37,8 +36,8 @@ class TrayIconWidget : public Gtk::Button {
|
||||
Glib::RefPtr<Gio::MenuModel> menuModel;
|
||||
sigc::connection menuChangedConnection;
|
||||
bool menuPopupPending = false;
|
||||
double pendingX = 0.0;
|
||||
double pendingY = 0.0;
|
||||
double pendingX = 0.0;
|
||||
double pendingY = 0.0;
|
||||
|
||||
void on_primary_released(int n_press, double x, double y);
|
||||
void on_secondary_released(int n_press, double x, double y);
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "components/popover.hpp"
|
||||
#include <gtkmm/button.h>
|
||||
#include <gtkmm/popover.h>
|
||||
|
||||
#include "components/popover.hpp"
|
||||
|
||||
class WebWidget : public Popover {
|
||||
public:
|
||||
public:
|
||||
WebWidget(std::string icon, std::string title, std::string url);
|
||||
private:
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtkmm/box.h>
|
||||
#include <gtkmm/label.h>
|
||||
#include <gtkmm/gestureclick.h>
|
||||
#include <gtkmm/label.h>
|
||||
#include <sigc++/connection.h>
|
||||
|
||||
#include "services/hyprland.hpp"
|
||||
@@ -18,7 +18,7 @@ class WorkspaceIndicator : public Gtk::Box {
|
||||
sigc::connection workspaceConnection;
|
||||
sigc::connection monitorConnection;
|
||||
std::map<int, Gtk::Label *> workspaceLabels;
|
||||
std::map<int, Glib::RefPtr<Gtk::GestureClick>> workspaceGestures;
|
||||
std::map<int, Glib::RefPtr<Gtk::GestureClick>> workspaceGestures;
|
||||
|
||||
void rebuild();
|
||||
void on_workspace_update();
|
||||
|
||||
Reference in New Issue
Block a user