Commit graph

39 commits

Author SHA1 Message Date
scorpion-26
bc0281ca53 Rewrite large parts of SNI
This is the fix for https://github.com/scorpion-26/gBar/issues/79, but
blown out of proportions, because various things kept breaking

- Original fix: Add/Remove items instead of cleaning everything
  everytime something changes. If the dbus-menu was open, it was
  referencing the old widget causing issues. The new method keeps the
  original GtkDrawingArea and only replace the buffer/tooltip
- Create dbus-menu on widget creation instead of on click. This was
  actually the fix for
  https://github.com/scorpion-26/gBar/pull/12#issuecomment-1529143790.
  The css has also been updated, making the popup finally look good.
- With the new item refreshing theme KeePassXC kept deadlocking when the
  properties changed. To fix it, the dbus properties are now queried
  asynchronously via 'GetAll'
2024-03-18 02:26:09 +01:00
scorpion-26
097c3d97e7 Remove stb submodule
Since 37b0896 stb_image isn't used anymore and recently the nix CI also
broke because of the hacky way the include directory is determined. This
is now fixed. One side effect of this is, that gBar no longer needs to
be cloned recursively.
2024-03-13 01:44:36 +01:00
scorpion-26
fbf25048ff Don't create SNI item, when no icon is found
KeePassXC would call ItemPropertyChanged on exit and simultaneously
vanish its dbus presence. This causes all dbus property queries to fail.
2024-02-16 20:37:04 +01:00
scorpion-26
a868f3e8e5 Fix crash when dbusmenu was double freed
Apparently gtk_menu_detach unrefs the menu
2024-02-16 20:36:15 +01:00
scorpion-26
4ed6c06449 Fix dbusmenu leak
The menu that was created for the sni context menu was never destroyed.
Instead of creating a new menu each time, the existing menu is recycled
and destroyed when the item is.
2024-02-16 20:03:34 +01:00
scorpion-26
438024c626 Fix use-after-free in SNI
gtk_icon_theme_load_icon returns a pixbuf which is not owned by us, and
therefore g_free shouldn't be called. When reloading an icon, this pixbuf
was reused by the icon theme even though we just free'd it.

Fixes: https://github.com/scorpion-26/gBar/issues/74
2023-12-14 23:54:07 +01:00
scorpion-26
0e8634a227 Implement ability to disable certain SNI icons
Implements https://github.com/scorpion-26/gBar/issues/69 (nice)
2023-12-03 22:52:37 +01:00
scorpion-26
37b0896d6d Allow overriding of SNI icons
This adds a config option to override the name of the icons displayed.
This also removes the frankenstein monster of the icon location
querying, which was a giant mess and not even remotely close to being
compliant with the XDG spec. Instead we use the much simpler Gtk API
which has the added benefit of properly supporting themes.

The SNI filter also now work for items without a set tooltip (e.g. steam).
For these items the object name is matched instead.

Implements https://github.com/scorpion-26/gBar/issues/63
2023-12-03 22:52:37 +01:00
Christoph
56c53c49cd
Add more css classes(#72)
This PR adds classes to every widget. 

Introduces a breaking change for the lock-button, which needs to be
added to the style.css manually if you're using a custom one.

Every widget gets a "widget" class as well as a specific one like an id.
In the future, names/ids should be used for that.
Also cleaned up the sensors a little as well as the related CSS.

Fixes #70.
2023-11-30 12:53:30 +01:00
scorpion-26
4b3679b550 Cleanup commented out g_variant_unref calls
They were bogus and the added comment explains why they're not needed
in this case
2023-11-05 22:10:02 +01:00
scorpion-26
2420574c70 SNI: Allow svgs as icons
To facilitate that, Texture now accepts GdkPixbuf instead of raw
uint8_t[], because we can't convert svgs into uint8_t[] easily without
the use of GdkPixbuf.
2023-11-05 22:03:50 +01:00
scorpion-26
6c8f57238a Add option to have right-side up icons and text
The margins are still not perfect, but it at least acceptable.
SensorTooltips is required, as the sensor texts break due to being
right-side up.

Implements https://github.com/scorpion-26/gBar/issues/48
2023-11-01 00:34:33 +01:00
scorpion-26
996a6611ad Add options for reordering widget layout.
Partially implements https://github.com/scorpion-26/gBar/issues/48 and https://github.com/scorpion-26/gBar/issues/20
2023-10-21 18:32:51 +02:00
scorpion-26
aee06ab49d SNI: Properly unsubscribe from item reload signal
I think not unsubscribing is the root cause of the mysterious calling of
ItemPropertyChanged from random names/object paths.
2023-08-24 00:09:05 +02:00
scorpion-26
383f25dbe1 SNI: Fix pixmap
g_variant_iter_n_children apparently returns 1 instead of 3 (array =
child, but I don't know).
I inverted the statement, because for empty property, it hasn't any
children.
2023-08-23 23:18:50 +02:00
scorpion-26
15ed9bfc66 SNI: Disallow watcher replacement
Should help against losing the name constantly, if another bar is
opened.
2023-08-23 15:29:13 +02:00
scorpion-26
a15bb1e17e SNI: Gracefully handle empty IconPixmap
An empty pixmap caused extreme flickering.
https://github.com/scorpion-26/gBar/issues/38
2023-08-22 22:30:38 +02:00
scorpion-26
ec478dec9c SNI: Fix crash with ToolTip of type String
TeamViewer exposes ToolTip as String (which is not compliant to the spec).
This caused gBar to crash, since we assume, that the tooltip variant is
always a container (struct), which glibc doesn't like.

We now fallback to g_variant_get_string if it is not according to spec

Fixes https://github.com/scorpion-26/gBar/issues/37
2023-08-22 15:17:18 +02:00
scorpion-26
3bac707bf5 Fix compiler warnings 2023-07-28 19:11:13 +02:00
scorpion-26
4a52bb744a SNI: Flush before querying item properties
Some apps have a tendency to deadlock after registration (notably
KeePassXC). Now we flush before querying the item properties, so any
pending answer should have left the bus, hopefully avoiding the deadlock
2023-07-28 18:58:00 +02:00
scorpion-26
a7862a4242 SNI: Remove callback for erased items
Should fix DBusNameVanished spam as found in https://github.com/scorpion-26/gBar/issues/29
2023-07-28 18:56:51 +02:00
scorpion-26
09ec1bfab6 SNI: Sort items
Reloading/adding new items causes jumps in the item order. Sorting
should stabilize the order
2023-07-26 14:04:36 +02:00
scorpion-26
884d3f1324 SNI: Only reload a given senderName once
Fix for: https://github.com/scorpion-26/gBar/issues/26
2023-07-26 14:03:52 +02:00
scorpion-26
39cf17c30f SNI: Use our object path for ItemPropertyChanged
ItemPropertyChanged is called multiple times per actual icon change.
senderName is the same, objectPath is the same, but our registered name
for the callback differs.
We can't use the provided name for item searching, since that *can*
differ from the one we registered with (Looking at you, Discord. Discord
registers with org.kde.StatusNotifierItem-*, but calls back with :*.*)
Since then the object path will sometimes be wrong for the name, we just
use the one from the icon we originally registered with. This causes
multiple icons to reload though

Potential fix for https://github.com/scorpion-26/gBar/issues/26
2023-07-26 13:37:11 +02:00
scorpion-26
fe7b02b10c SNI: Honor XDG_DATA_DIRS as icon directory
Also don't crash in Utils::FindFileWithName when directory doesn't exist

Potential fix for https://github.com/scorpion-26/gBar/issues/25
2023-07-25 01:47:17 +02:00
scorpion-26
abd3774c7d Fix SNI angle for top bar 2023-07-21 01:29:25 +02:00
scorpion-26
f78758c4ee SNI: Allow bar rotation
Texture was also rewritten, so it doesn't need the SNIPaddingTop hack as much
anymore
2023-07-21 01:08:38 +02:00
scorpion-26
18f3e123ed SNI: Allow IconPath to be empty
Fixes network-manager-applet
2023-07-04 12:21:19 +02:00
scorpion-26
e9c9d3abb1 SNI: Add Icon positioning config options 2023-05-04 16:14:18 +02:00
scorpion-26
79e78826e0 SNI: Only add to clientsToQuery once 2023-05-04 15:04:06 +02:00
scorpion-26
31e070a3da SNI: Add config 2023-05-04 13:57:50 +02:00
scorpion-26
b7a92e50d9 SNI: Add context menu
Since it uses a 13 year old library, it is broken. The popup size is
hard-fixed at 200x200, with looks really ugly with non-transparent
background.
2023-05-04 13:57:50 +02:00
scorpion-26
40115befdd SNI: Improve logging 2023-05-04 13:57:50 +02:00
scorpion-26
25912c7e35 SNI: Add tooltip 2023-05-04 13:57:50 +02:00
scorpion-26
6bd5a450b1 SNI: Implement changing properties 2023-05-04 13:57:50 +02:00
scorpion-26
b50ecb0f6c SNI: Fix freeze when connecting to Qt SNI apps
Qt waits until the callback to RegisterItem is done. Thus, we can't
query the item and need to defer it
2023-05-04 13:57:50 +02:00
scorpion-26
a02bce9b91 SNI: Remove items on bus name vanish 2023-05-04 13:57:50 +02:00
scorpion-26
d4ffac395b SNI: Proper alignment for the icons 2023-05-04 13:57:50 +02:00
scorpion-26
1241d7c87c SNI: Initial proof of concept
Implements a rough outline of the SNI (StatusNotifierItem) d-bus
protocol for tray icons.

Note: This is currently *very* WIP

Full implementation will close https://github.com/scorpion-26/gBar/issues/5
2023-05-04 13:57:50 +02:00