mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
feat(WIP): tray
feat(wip): tray feat(wip): tray feat(WIP): gdbus feat(WIP): tray
This commit is contained in:
@ -2,14 +2,10 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <wordexp.h>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <wayland-client.h>
|
||||
|
||||
#include <gdk/gdkwayland.h>
|
||||
|
||||
#include "bar.hpp"
|
||||
|
||||
namespace waybar {
|
||||
@ -30,14 +26,14 @@ class Client {
|
||||
struct wl_seat *seat = nullptr;
|
||||
std::vector<std::unique_ptr<Bar>> bars;
|
||||
|
||||
private:
|
||||
void bindInterfaces();
|
||||
auto setupCss();
|
||||
private:
|
||||
void bindInterfaces();
|
||||
auto setupCss();
|
||||
|
||||
static void handleGlobal(void *data, struct wl_registry *registry,
|
||||
uint32_t name, const char *interface, uint32_t version);
|
||||
static void handleGlobalRemove(void *data,
|
||||
struct wl_registry *registry, uint32_t name);
|
||||
static void handleGlobal(void *data, struct wl_registry *registry,
|
||||
uint32_t name, const char *interface, uint32_t version);
|
||||
static void handleGlobalRemove(void *data,
|
||||
struct wl_registry *registry, uint32_t name);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "modules/battery.hpp"
|
||||
#include "modules/memory.hpp"
|
||||
#include "modules/cpu.hpp"
|
||||
#include "modules/sni/tray.hpp"
|
||||
#ifdef HAVE_LIBNL
|
||||
#include "modules/network.hpp"
|
||||
#endif
|
||||
|
38
include/modules/sni/snh.hpp
Normal file
38
include/modules/sni/snh.hpp
Normal file
@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <dbus-status-notifier-watcher.h>
|
||||
#include "modules/sni/sni.hpp"
|
||||
|
||||
namespace waybar::modules::SNI {
|
||||
|
||||
class Host {
|
||||
public:
|
||||
Host(Glib::Dispatcher&);
|
||||
~Host();
|
||||
std::vector<Item> items;
|
||||
private:
|
||||
static void busAcquired(GDBusConnection*, const gchar*, gpointer);
|
||||
static void nameAppeared(GDBusConnection*, const gchar*, const gchar*,
|
||||
gpointer);
|
||||
static void nameVanished(GDBusConnection*, const gchar*, gpointer);
|
||||
static void proxyReady(GObject*, GAsyncResult*, gpointer);
|
||||
static void registerHost(GObject*, GAsyncResult*, gpointer);
|
||||
static void itemRegistered(SnOrgKdeStatusNotifierWatcher*, const gchar*,
|
||||
gpointer);
|
||||
static void itemUnregistered(SnOrgKdeStatusNotifierWatcher*, const gchar*,
|
||||
gpointer);
|
||||
|
||||
void getBusNameAndObjectPath(const gchar*, gchar**, gchar**);
|
||||
void addRegisteredItem(const gchar* service);
|
||||
|
||||
uint32_t bus_name_id_;
|
||||
uint32_t watcher_id_;
|
||||
std::string bus_name_;
|
||||
std::string object_path_;
|
||||
Glib::Dispatcher& dp_;
|
||||
GCancellable* cancellable_ = nullptr;
|
||||
SnOrgKdeStatusNotifierWatcher* watcher_ = nullptr;
|
||||
};
|
||||
|
||||
}
|
41
include/modules/sni/sni.hpp
Normal file
41
include/modules/sni/sni.hpp
Normal file
@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <dbus-status-notifier-item.h>
|
||||
|
||||
namespace waybar::modules::SNI {
|
||||
|
||||
class Item {
|
||||
public:
|
||||
Item(std::string, std::string, Glib::Dispatcher&);
|
||||
~Item();
|
||||
int icon_size;
|
||||
int effective_icon_size;
|
||||
Gtk::Image* image;
|
||||
std::string category;
|
||||
std::string id;
|
||||
std::string status;
|
||||
|
||||
std::string title;
|
||||
int32_t window_id;
|
||||
std::string icon_name;
|
||||
std::string overlay_icon_name;
|
||||
std::string attention_icon_name;
|
||||
std::string attention_movie_name;
|
||||
std::string icon_theme_path;
|
||||
std::string menu;
|
||||
bool item_is_menu;
|
||||
private:
|
||||
static void proxyReady(GObject* obj, GAsyncResult* res, gpointer data);
|
||||
static void getAll(GObject* obj, GAsyncResult* res, gpointer data);
|
||||
|
||||
void updateImage();
|
||||
Glib::RefPtr<Gdk::Pixbuf> getIconByName(std::string name, int size);
|
||||
std::string bus_name_;
|
||||
std::string object_path_;
|
||||
Glib::Dispatcher& dp_;
|
||||
GCancellable* cancellable_ = nullptr;
|
||||
SnOrgKdeStatusNotifierItem* proxy_ = nullptr;
|
||||
};
|
||||
|
||||
}
|
47
include/modules/sni/snw.hpp
Normal file
47
include/modules/sni/snw.hpp
Normal file
@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <dbus-status-notifier-watcher.h>
|
||||
|
||||
namespace waybar::modules::SNI {
|
||||
|
||||
typedef enum {
|
||||
GF_WATCH_TYPE_HOST,
|
||||
GF_WATCH_TYPE_ITEM
|
||||
} GfWatchType;
|
||||
|
||||
typedef struct {
|
||||
GfWatchType type;
|
||||
gchar* service;
|
||||
gchar* bus_name;
|
||||
gchar* object_path;
|
||||
guint watch_id;
|
||||
} GfWatch;
|
||||
|
||||
class Watcher {
|
||||
public:
|
||||
Watcher();
|
||||
~Watcher();
|
||||
private:
|
||||
static void busAcquired(GDBusConnection*, const gchar*, gpointer);
|
||||
static gboolean handleRegisterHost(Watcher*,
|
||||
GDBusMethodInvocation*, const gchar*);
|
||||
static gboolean handleRegisterItem(Watcher*,
|
||||
GDBusMethodInvocation*, const gchar*);
|
||||
static GfWatch* gfWatchFind(GSList* list, const gchar* bus_name,
|
||||
const gchar* object_path);
|
||||
static GfWatch* gfWatchNew(GfWatchType type,
|
||||
const gchar* service, const gchar* bus_name, const gchar* object_path);
|
||||
static void nameVanished(GDBusConnection* connection, const char* name,
|
||||
gpointer data);
|
||||
|
||||
void updateRegisteredItems(SnOrgKdeStatusNotifierWatcher* obj);
|
||||
|
||||
uint32_t bus_name_id_;
|
||||
uint32_t watcher_id_;
|
||||
GSList* hosts_ = nullptr;
|
||||
GSList* items_ = nullptr;
|
||||
SnOrgKdeStatusNotifierWatcher *watcher_ = nullptr;
|
||||
};
|
||||
|
||||
}
|
25
include/modules/sni/tray.hpp
Normal file
25
include/modules/sni/tray.hpp
Normal file
@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <thread>
|
||||
#include "util/json.hpp"
|
||||
#include "IModule.hpp"
|
||||
#include "modules/sni/snw.hpp"
|
||||
#include "modules/sni/snh.hpp"
|
||||
|
||||
namespace waybar::modules::SNI {
|
||||
|
||||
class Tray : public IModule {
|
||||
public:
|
||||
Tray(const Json::Value&);
|
||||
auto update() -> void;
|
||||
operator Gtk::Widget &();
|
||||
private:
|
||||
std::thread thread_;
|
||||
const Json::Value& config_;
|
||||
Gtk::Box box_;
|
||||
SNI::Watcher watcher_ ;
|
||||
SNI::Host host_;
|
||||
};
|
||||
|
||||
}
|
Reference in New Issue
Block a user