fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design
https://fyne.io/
Other
25.1k stars 1.4k forks source link

Add global menu support on Linux/BSD #2574

Open Jacalz opened 3 years ago

Jacalz commented 3 years ago

Is your feature request related to a problem? Please describe:

The native menu support on macOS is taking shape nicely as is a very clean solution for making sure that the menus take up no extra vertical space (as opposed to having them in the application). This is unfortunately not currently supported by Fyne on Linux/BSD in various desktop environments.

Is it possible to construct a solution with the existing API?

I think it would theoretically be better way to implement API wise as it wouldn't need to expose any new APIs. The problem could however surface depending on how the global menu support in Qt/GTK desktop environments is hooked up. We can't add it if it requires depending upon those toolkits.

Describe the solution you'd like to see:

I would have preferred to have this available on the most prominent desktops. Gnome doesn't have any support for this as far as I know, at least not without extensions. However, I know KDE has native support an dI think the same goes for Mate and possibly others.

probonopd commented 3 years ago

A global menu bar is front and center in helloSystem. In the course of putting it together, we found documentation pretty much non-existent and bits and pieces scattered around in various projects here and there. So we started to collect information about this topic here, possibly it can serve as a starting point for your investigations.

probonopd commented 3 years ago

We can't add it if it requires depending upon those toolkits.

Luckily, you don't need to depend on Qt or Gtk if you want to support global menus for applications written in those toolkits.

Basically you have two options:

Jacalz commented 3 years ago

Thanks for all of the hints and information @probonopd. Using D-bus is probably the best solution then, given that we already use it for notifications.

probonopd commented 3 years ago

https://github.com/helloSystem/Menu/tree/actionsearch/src/appmenu has relevant source code for importing appplication menus via D-Bus into the global menu bar.

https://code.launchpad.net/libdbusmenu-qt may also be relevant.

andydotxyz commented 3 years ago

On a Fyne ticket I think we will be exporting rather than importing. I guess the key element is determining if a global menu is available somehow.

Luckily, you don't need to depend on Qt or Gtk if you want to support global menus for applications written in those toolkits.

I think that's the wrong end of the equation - this ticket is about Fyne apps showing their menu in a global bar.

probonopd commented 3 years ago

Need to do the equivalent of this bash snippet:

  RESULT=$(dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListNames | grep AppMenu)
  if [ "${RESULT}" != "" ] ; then
    ... # Export menu on D-Bus