mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Merge branch 'tray-gdbus' of github.com:topisani/Waybar into tray-gdbus
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtkmm.h>
|
||||
|
||||
#include <tuple>
|
||||
#include <dbus-status-notifier-watcher.h>
|
||||
#include "modules/sni/sni.hpp"
|
||||
|
||||
@ -8,8 +10,7 @@ namespace waybar::modules::SNI {
|
||||
|
||||
class Host {
|
||||
public:
|
||||
Host(Glib::Dispatcher&);
|
||||
~Host();
|
||||
Host(Glib::Dispatcher*);
|
||||
std::vector<Item> items;
|
||||
private:
|
||||
static void busAcquired(GDBusConnection*, const gchar*, gpointer);
|
||||
@ -23,14 +24,14 @@ class Host {
|
||||
static void itemUnregistered(SnOrgKdeStatusNotifierWatcher*, const gchar*,
|
||||
gpointer);
|
||||
|
||||
void getBusNameAndObjectPath(const gchar*, gchar**, gchar**);
|
||||
std::tuple<std::string, std::string> getBusNameAndObjectPath(const 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_;
|
||||
Glib::Dispatcher* dp_;
|
||||
GCancellable* cancellable_ = nullptr;
|
||||
SnOrgKdeStatusNotifierWatcher* watcher_ = nullptr;
|
||||
};
|
||||
|
@ -1,42 +1,51 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <dbus-status-notifier-item.h>
|
||||
#include <gtkmm.h>
|
||||
|
||||
namespace waybar::modules::SNI {
|
||||
|
||||
class Item {
|
||||
public:
|
||||
Item(std::string, std::string, Glib::Dispatcher&);
|
||||
~Item();
|
||||
int icon_size;
|
||||
int effective_icon_size;
|
||||
Gtk::Widget* widget = nullptr;
|
||||
Gtk::Image* image = nullptr;
|
||||
std::string category;
|
||||
std::string id;
|
||||
std::string status;
|
||||
public:
|
||||
Item(std::string, std::string, Glib::Dispatcher *);
|
||||
|
||||
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);
|
||||
std::string bus_name;
|
||||
std::string object_path;
|
||||
Gtk::EventBox event_box;
|
||||
|
||||
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;
|
||||
int icon_size;
|
||||
int effective_icon_size;
|
||||
Gtk::Image *image;
|
||||
Gtk::Menu *gtk_menu = nullptr;
|
||||
std::string category;
|
||||
std::string id;
|
||||
std::string status;
|
||||
|
||||
std::string title;
|
||||
int32_t window_id;
|
||||
std::string icon_name;
|
||||
Glib::RefPtr<Gdk::Pixbuf> icon_pixmap;
|
||||
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);
|
||||
static void handleActivate(GObject *, GAsyncResult *, gpointer);
|
||||
static void handleSecondaryActivate(GObject *, GAsyncResult *, gpointer);
|
||||
|
||||
void updateImage();
|
||||
Glib::RefPtr<Gdk::Pixbuf> extractPixBuf(GVariant *variant);
|
||||
Glib::RefPtr<Gdk::Pixbuf> getIconByName(std::string name, int size);
|
||||
bool handleClick(GdkEventButton *const & /*ev*/);
|
||||
|
||||
Glib::Dispatcher *dp_;
|
||||
GCancellable *cancellable_ = nullptr;
|
||||
SnOrgKdeStatusNotifierItem *proxy_ = nullptr;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace waybar::modules::SNI
|
||||
|
@ -1,47 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <dbus-status-notifier-watcher.h>
|
||||
#include <gtkmm.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);
|
||||
public:
|
||||
Watcher();
|
||||
~Watcher();
|
||||
|
||||
void updateRegisteredItems(SnOrgKdeStatusNotifierWatcher* obj);
|
||||
private:
|
||||
typedef enum { GF_WATCH_TYPE_HOST, GF_WATCH_TYPE_ITEM } GfWatchType;
|
||||
|
||||
uint32_t bus_name_id_;
|
||||
uint32_t watcher_id_;
|
||||
GSList* hosts_ = nullptr;
|
||||
GSList* items_ = nullptr;
|
||||
SnOrgKdeStatusNotifierWatcher *watcher_ = nullptr;
|
||||
typedef struct {
|
||||
GfWatchType type;
|
||||
Watcher *watcher;
|
||||
gchar *service;
|
||||
gchar *bus_name;
|
||||
gchar *object_path;
|
||||
guint watch_id;
|
||||
} GfWatch;
|
||||
|
||||
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, const gchar *, const gchar *,
|
||||
const gchar *, Watcher *);
|
||||
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;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace waybar::modules::SNI
|
||||
|
Reference in New Issue
Block a user