jjk-jacky / statusnotifier

Library to use KDE's StatusNotifierItem via GObject
Other
25 stars 8 forks source link

Split Gtk usage into separate library #20

Open TingPing opened 5 years ago

TingPing commented 5 years ago

The fact the main library links to Gtk is quite problematic considering there are 3 versions of Gtk out there (2, 3, 4) that cannot be in the same process. If this were split out it could work against all versions at the same time.

jjk-jacky commented 5 years ago

Not sure what you mean, unless you're enabling dbus-menu it doesn't link to GTK at all. GTK3 is only needed when enabling dbus-menu (or for the example), that's it.

TingPing commented 5 years ago

Yes that is what I mean. If a package enables that option it cannot work in a Gtk2 or Gtk4 application. It would be best to have parallel libraries so it always works.

On a side note I was looking into replacing libdbusmenu-gtk usage (because its garbage and a dead library) so maybe we can do that if you are OK with removing that API.

jjk-jacky commented 5 years ago

Well, supporting multiple versions of GTK, I'm not entirely sure exactly what it would entail but it feels like adding lots of complexity for something that might not even been really used... so I'm not too inclined to do so.

As for libdbusmenu, dropping/replacing the dependency is one thing, dropping support for the feature using a menu is another. And, considering is was asked for specifically, it is likely in use, I don't see a good reason to drop it.

TingPing commented 5 years ago

Well, supporting multiple versions of GTK, I'm not entirely sure exactly what it would entail but it feels like adding lots of complexity for something that might not even been really used... so I'm not too inclined to do so.

Well I need to use it with Gtk2 and the day Gtk4 becomes used it means your library isn't even possible to use. Obviously this library isn't widely adopted so I can't point to a use in the wild.

As for libdbusmenu, dropping/replacing the dependency is one thing, dropping support for the feature using a menu is another. And, considering is was asked for specifically, it is likely in use, I don't see a good reason to drop it.

Sorry I didn't give enough details but I wanted to add an API to pass a GMenu and export a dbusmenu ourselves (admittedly non-trivial). The GtkMenu functionality can still exist for those who really want it but again that would be its own library so the main lib only uses Gio.

jjk-jacky commented 5 years ago

Well I need to use it with Gtk2 and the day Gtk4 becomes used it means your library isn't even possible to use. Obviously this library

But you might already be able to use it with gtk2 fine unless you enable libdbusmenu support, no?

As for gtk4, no this library can't be used with a toolkit that isn't yet released, how odd. ;P And again, so long as you don't use dbusmenu support it will probably be usable from gtk4 just fine...

Which leaves us to:

Sorry I didn't give enough details but I wanted to add an API to pass a GMenu and export a dbusmenu ourselves (admittedly non-trivial). The GtkMenu functionality can still exist for those who really want it but again that would be its own library so the main lib only uses Gio.

So if you want to send a patch to rewrite the menu over dbus feature so that it doesn't require dbusmenu/isn't tied to any gtk version, that's great.

The API in statusnotifier needs not to be changed, it would just need a different implementation is all. (It doesn't even deal with GtkMenu at all but simply GObject.)

Actually, I think currently statusnotifier does require gdk3, so that might be an issue to use it from a gtk2 app. But it's easy enough to get rid of that and simply use cairo/gdk-pixbuf, so it really doesn't matter which version of gtk your app links against.

Leading us back to, it's only adding the dbusmenu support that ties to a specific gtk version currently, by means of libdbusmenu. So the real solution here would indeed be to rewrite that part and make it so that it doesn't. As said, statusnotifier's API really only deals with GObject, even though the doc talks about GtkWidget. But I think it could be ok to change that to a GMenuModel instead.

TingPing commented 5 years ago

But you might already be able to use it with gtk2 fine unless you enable libdbusmenu support, no?

In the short term where I bundle this, yes that is fine. In the long term where we assume this is a system provided library it will very likely be built with it and there is nothing an application can do other than crash.

As for gtk4, no this library can't be used with a toolkit that isn't yet released, how odd. ;P And again, so long as you don't use dbusmenu support it will probably be usable from gtk4 just fine...

... Obviously it will release one day and that day the apps that move will just crash.

jjk-jacky commented 5 years ago

Well, yeah, as said before when dbus menu support is enabled we depend on gtk3, so yes statusnotifier then requires/links gtk3 and cannot be used from e.g. gtk2 app indeed.

And as said before, I think indeed the way to fix this would be to rewrite the dbus menu feature, so that it is done without the dependency on libdbusmenu, and instead use only GIO (i.e. GMenuModel). That way it should work with app using gtk2, gtk3 or even gtk4 in the future.