Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update RGtk2 to bind Gtk3 and/or Gtk4? #12

Open
davidcsterratt opened this issue Feb 14, 2023 · 4 comments
Open

Update RGtk2 to bind Gtk3 and/or Gtk4? #12

davidcsterratt opened this issue Feb 14, 2023 · 4 comments

Comments

@davidcsterratt
Copy link

I'd like to get my retistruct package back on CRAN, complete with its GUI, which uses RGtk2, and in particular the ggraphics() method to embed plots. Although I like the Gtk look and feel, I'm agnostic about how this can be done. From what I can see I can't use the gWidegets2tcltk package because Tcl/Tk can't embed graphics devices, and I'm not aware of other maintained GUI bindings for R at the moment.

I'm therefore coming back to RGtk2. From my investigations in #9 and on this thread on the r-package-devel it seems that for there to be a long term future for RGtk:

  1. It would have to be upgraded at least to Gtk3 and ultimately to Gtk4
  2. It would need to build on Windows with packages installed in RTools, which would need the help of CRAN maintainers
  3. It would need to be built on the Mac too, I supopose.

Re (1), it looks like there's been some progress in the 3.x branch.

Re (2) and (3), there were some positive indications from Tomas Kalibera that it might be possible.

So I'm wondering what the future plans are for RGtk2? As a maintainer of (probably much less complex) packages, I know that a significant amount of work would be required...

@lawremi
Copy link
Owner

lawremi commented Feb 16, 2023

I am curious about your use case for RGtk. Shiny made RGtk obsolete for the vast majority of use cases a decade ago.

The bindings to GTK+ are auto-generated based on an obsolete scheme-based representation of the GTK+ API that was generated by the PyGTK project. By the time I started working on RGtk2, they had already moved to a different approach, but I maintained the scheme-based "defs" format manually with every GTK+ release. I'm sure there are sweeping changes between the last GTK 2.x release and GTK 4.x, so it would be a huge amount of work to update those definitions.

The right way to generate GTK+ bindings these days is to use GObject Introspection. I wrote some code to parse the XML format a long time ago. However, I was blocked by an issue reported 14 years ago: there was no support for default argument values, a critical feature of RGtk2. However, I just checked the issue, and by an unbelievable coincidence, it was fixed just one month ago. While it will take some time for the API annotations to actually use that feature, one could in principle create a patch that would ideally but not necessarily be accepted upstream.

Of course, there are probably many changes to GTK+ 4 and the underlying libraries like GLib and GObject that will require significant updates to the manually written code surrounding the auto-generated bindings. Quite an undertaking, but I am happy to help as I can.

@davidcsterratt
Copy link
Author

davidcsterratt commented Feb 20, 2023

Thank you - that's very helpful.

Re the use case, I use a lot of the features of RGtk2, as indicated in the screenshot below:
image
Not apparent from this is that there's also interaction with the plot using identify().

I recall having a look at Shiny some time back, and thinking that it either wasn't possible to use it to create a similar interface, or wasn't worth putting in the effort, given that RGtk2 was reasonably easy to install.

If it's obvious from the above that Shiny won't work for this use case, please let me know. If Shiny might work, then I should definitely investigate that option further, as the upgrade to Gtk4 sounds potentially quite painful - and there's still some uncertainty about how easy it would be to get any upgraded package on CRAN.

@lawremi
Copy link
Owner

lawremi commented Feb 20, 2023

Shiny probably would work for your use case. It has a huge ecosystem of extensions and supporting packages; the web is the modern UI platform. Of course, it would mean a major rewrite of your interface code.

If I find the time/energy, I will look into GTK+ 4.

@lawremi
Copy link
Owner

lawremi commented Feb 24, 2023

Just a note that it turns out that the default value support recently added to GIR only applies to properties, not function arguments, so it's largely useless to us. I guess if we really wanted to do this, we would patch the GIR using XSLT (via the new xslt package). And yes, it's not clear CRAN would be very receptive to the package, because it has a lot of system dependencies, is quite heavy on its own, and has a small potential user base.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants