-
-
Notifications
You must be signed in to change notification settings - Fork 732
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from Alexays/tray-gdbus
Tray beta
- Loading branch information
Showing
24 changed files
with
1,024 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
#include <gtkmm.h> | ||
|
||
#include <tuple> | ||
#include <dbus-status-notifier-watcher.h> | ||
#include "modules/sni/sni.hpp" | ||
|
||
namespace waybar::modules::SNI { | ||
|
||
class Host { | ||
public: | ||
Host(Glib::Dispatcher*); | ||
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); | ||
|
||
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_; | ||
GCancellable* cancellable_ = nullptr; | ||
SnOrgKdeStatusNotifierWatcher* watcher_ = nullptr; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#pragma once | ||
|
||
#include <dbus-status-notifier-item.h> | ||
#include <gtkmm.h> | ||
|
||
namespace waybar::modules::SNI { | ||
|
||
class Item { | ||
public: | ||
Item(std::string, std::string, Glib::Dispatcher *); | ||
|
||
std::string bus_name; | ||
std::string object_path; | ||
Gtk::EventBox event_box; | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#pragma once | ||
|
||
#include <gtkmm.h> | ||
#include <dbus-status-notifier-watcher.h> | ||
|
||
namespace waybar::modules::SNI { | ||
|
||
class Watcher { | ||
public: | ||
Watcher(); | ||
~Watcher(); | ||
|
||
private: | ||
typedef enum { GF_WATCH_TYPE_HOST, GF_WATCH_TYPE_ITEM } GfWatchType; | ||
|
||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" | ||
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> | ||
<node> | ||
<interface name="com.canonical.dbusmenu"> | ||
<!-- Properties --> | ||
<property name="Version" type="u" access="read" /> | ||
<property name="TextDirection" type="s" access="read" /> | ||
<property name="Status" type="s" access="read" /> | ||
<property name="IconThemePath" type="as" access="read" /> | ||
|
||
<!-- Functions --> | ||
<method name="GetLayout"> | ||
<arg type="i" name="parentId" direction="in" /> | ||
<arg type="i" name="recursionDepth" direction="in" /> | ||
<arg type="as" name="propertyNames" direction="in" /> | ||
<arg type="u" name="revision" direction="out" /> | ||
<arg type="(ia{sv}av)" name="layout" direction="out" /> | ||
</method> | ||
|
||
<method name="GetGroupProperties"> | ||
<arg type="ai" name="ids" direction="in" /> | ||
<arg type="as" name="propertyNames" direction="in" /> | ||
<arg type="a(ia{sv})" name="properties" direction="out" /> | ||
</method> | ||
|
||
<method name="GetProperty"> | ||
<arg type="i" name="id" direction="in" /> | ||
<arg type="s" name="name" direction="in" /> | ||
<arg type="v" name="value" direction="out" /> | ||
</method> | ||
|
||
<method name="Event"> | ||
<arg type="i" name="id" direction="in" /> | ||
<arg type="s" name="eventId" direction="in" /> | ||
<arg type="v" name="data" direction="in" /> | ||
<arg type="u" name="timestamp" direction="in" /> | ||
</method> | ||
|
||
<method name="EventGroup"> | ||
<arg type="a(isvu)" name="events" direction="in" /> | ||
<arg type="ai" name="idErrors" direction="out" /> | ||
</method> | ||
|
||
<method name="AboutToShow"> | ||
<arg type="i" name="id" direction="in" /> | ||
<arg type="b" name="needUpdate" direction="out" /> | ||
</method> | ||
|
||
<method name="AboutToShowGroup"> | ||
<arg type="ai" name="ids" direction="in" /> | ||
<arg type="ai" name="updatesNeeded" direction="out" /> | ||
<arg type="ai" name="idErrors" direction="out" /> | ||
</method> | ||
|
||
<!-- Signals --> | ||
<signal name="ItemsPropertiesUpdated"> | ||
<arg type="a(ia{sv})" name="updatedProps" direction="out" /> | ||
<arg type="a(ias)" name="removedProps" direction="out" /> | ||
</signal> | ||
<signal name="LayoutUpdated"> | ||
<arg type="u" name="revision" direction="out" /> | ||
<arg type="i" name="parent" direction="out" /> | ||
</signal> | ||
<signal name="ItemActivationRequested"> | ||
<arg type="i" name="id" direction="out" /> | ||
<arg type="u" name="timestamp" direction="out" /> | ||
</signal> | ||
</interface> | ||
</node> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" | ||
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> | ||
<node> | ||
<interface name="org.kde.StatusNotifierItem"> | ||
<property name="Category" type="s" access="read"/> | ||
<property name="Id" type="s" access="read"/> | ||
<property name="Title" type="s" access="read"/> | ||
<property name="Status" type="s" access="read"/> | ||
<property name="WindowId" type="i" access="read"/> | ||
<property name="Menu" type="o" access="read" /> | ||
|
||
<!-- main icon --> | ||
<!-- names are preferred over pixmaps --> | ||
<property name="IconName" type="s" access="read" /> | ||
<property name="IconThemePath" type="s" access="read" /> | ||
|
||
<!-- struct containing width, height and image data--> | ||
<!-- implementation has been dropped as of now --> | ||
<property name="IconPixmap" type="a(iiay)" access="read" /> | ||
|
||
<!-- not used in ayatana code, no test case so far --> | ||
<property name="OverlayIconName" type="s" access="read"/> | ||
<property name="OverlayIconPixmap" type="a(iiay)" access="read" /> | ||
|
||
<!-- Requesting attention icon --> | ||
<property name="AttentionIconName" type="s" access="read"/> | ||
|
||
<!--same definition as image--> | ||
<property name="AttentionIconPixmap" type="a(iiay)" access="read" /> | ||
|
||
<!-- tooltip data --> | ||
<!-- unimplemented as of now --> | ||
<!--(iiay) is an image--> | ||
<property name="ToolTip" type="(sa(iiay)ss)" access="read" /> | ||
|
||
|
||
<!-- interaction: actually, we do not use them. --> | ||
<method name="Activate"> | ||
<arg name="x" type="i" direction="in"/> | ||
<arg name="y" type="i" direction="in"/> | ||
</method> | ||
<method name="SecondaryActivate"> | ||
<arg name="x" type="i" direction="in"/> | ||
<arg name="y" type="i" direction="in"/> | ||
</method> | ||
<method name="Scroll"> | ||
<arg name="delta" type="i" direction="in"/> | ||
<arg name="dir" type="s" direction="in"/> | ||
</method> | ||
|
||
<!-- Signals: the client wants to change something in the status--> | ||
<signal name="NewTitle"></signal> | ||
<signal name="NewIcon"></signal> | ||
<signal name="NewIconThemePath"> | ||
<arg type="s" name="icon_theme_path" direction="out" /> | ||
</signal> | ||
<signal name="NewAttentionIcon"></signal> | ||
<signal name="NewOverlayIcon"></signal> | ||
<signal name="NewToolTip"></signal> | ||
<signal name="NewStatus"> | ||
<arg name="status" type="s" /> | ||
</signal> | ||
|
||
<!-- ayatana labels --> | ||
<!-- These are commented out because GDBusProxy would otherwise require them, | ||
but they are not available for KDE indicators | ||
--> | ||
<!--<signal name="XAyatanaNewLabel"> | ||
<arg type="s" name="label" direction="out" /> | ||
<arg type="s" name="guide" direction="out" /> | ||
</signal> | ||
<property name="XAyatanaLabel" type="s" access="read" /> | ||
<property name="XAyatanaLabelGuide" type="s" access="read" />--> | ||
|
||
|
||
</interface> | ||
</node> |
Oops, something went wrong.