qdot / systray-rs

Allows rust applications to show a platform specific system tray icon and menu.
BSD 3-Clause "New" or "Revised" License
170 stars 66 forks source link

Cross-platform set_icon_from_resource? #12

Open qdot opened 7 years ago

qdot commented 7 years ago

On windows, we can set an icon via a resource name. On linux, we can use set_icon_from_stock or themes. Not sure what the situation on mac is. Is there a way to unify all of these under the same generic function?

daniel-abramov commented 7 years ago

I think we can do something similar to what I've done when I worked on set_icon_from_buffer() for Windows. Since resource topic is something that is not unified across platforms, we can use include_bytes!(), this gives us some sort of "crossplatform resources" I guess. In this case the only thing we have to support is a function which accepts the icon as a slice (perhaps &'static [u8]). I implemented the similar function on Windows already (you've merged it recently), yesterday I implemented the same thing for Mac in my fork.

qdot commented 7 years ago

Ok. I'll see if there's something available in gtk that would accept that kind of argument too. You familiar with anything @jonhoo? The Go systray thing I was cribbing off of takes a blob, saves to it /tmp, and opens that file, which seems hacky.

jonhoo commented 7 years ago

Closest I can think of is gtk_status_icon_set_from_pixbuf, but like everything else relating to tray icons this has been deprecated in 3.14 :(