Ruby GNOME GUIs - ruby

With the recent release of GNOME 3 and Ubuntu moving to Unity, what toolkit should rubyists be using to develop their apps? I know that there are bindings to GTK2, are these still ok to use?

It is still OK to use the GTK 2 bindings - GTK 2 and 3 will be installed in parallel on most desktop distributions for several years yet. That said, you should keep in mind while you're writing your application that you should update it to GTK 3 when those bindings become prevalent. Take a look at the differences between GTK 2 and 3 and don't write code that will be hard to port when the time comes.

Take a look at visualruby. It uses GTK2, which has been around for a while, so its stable. Its specifically designed for making ruby GUIs:
http://visualruby.net

I've heard good things about ruby shoes although never tried it myself. Maybe you should check it out?

Related

Does QtRuby work with Qt 5?

Everything I can find online about QtRuby uses Qt 4, but the current version of Qt is 5. Is this simply a matter of documentation not catching up with reality, where Qt 5 would work just fine with QtRuby?
If you assert that this is the case (that Qt5 is unsupported) then please backup your assertion with evidence.
QtRuby
Qtruby and korundum are not maintained for years now. To get a maintained version of qtruby, install qtbindings as ruby gem.
Qtbindings home page: https://github.com/ryanmelt/qtbindings/
Also see https://github.com/ryanmelt/qtbindings/issues/131 for a discussion about supporting Qt5.
Ruby-QML
Ruby-qml is a QML / Qt Quick wrapper for Ruby. It provides bindings between QML and Ruby and enables you to use Qt5 Quick-based GUI from Ruby.
The bindings provided by Ruby-QML are much leaner in comparison to QtRuby. In particular there is no direct access to the Qt classes' methods. That might first seem to be a a disadvantage when coming from QtRuby.
When learning to use use Ruby-QML, it turns out quickly that the advantages outweigh the limitations:
QML and JS greatly complement to describe and model the static and dynamic aspects of the UI
The user community of QML/JS is huge. It is so much easier to find examples or help to solve QML/JS issues, than it was within the tiny QT/Ruby community.
The examples on Ruby-qml are pretty much complete to demonstrate the constructs needed to get started.
JS may be used as flexible 'glue logic' between Ruby and Qt.
QtRuby only supports Qt 4 for the time being. Hopefully, it will change soon, but this seems to be the reality at the time of writing this.
The last release happened two and half a years ago as the time of writing this. That can be seen here:
http://rubyforge.org/projects/korundum/
As you can see, that is also a Qt 4 release as its name says: qt4-qtruby-2.2.0.
That information is also getting from their outdated KDE Wiki in here:
http://techbase.kde.org/Development/Languages/Ruby
If this is still not enough proof, you can look into the code yourself to see it is not actually binding Qt 5 classes added in that major Qt variant.
Here is a quick ls after decompressing the latest tarball:
lpapp ~/Downloads/qt4-qtruby-2.2.0/qtruby/src/lib $ ls
CMakeLists.txt Qt Qt.rb Qt3.rb Qt4.rb

Ruby GUI support on OSX Mavericks (Not Shoes or Ruby Motion) plus OSX app package support

This has been asked many times. Some of the answers are pretty old now. I have looked around everywhere for 2 things.This the last resort before I give up. Looking for:
Bindings that will enable GUI programming using Ruby (not Shoes) using Mavericks. I have found plenty bindings but with no activity for the past 3 or 4 years, with the exception of RubyMotion which seems very expensive while not taking advantage of Xcode features / does not have an IDE.
Way to package app for users as a regular OSX app so the user does not have to install anything by hand on OSX (if mutiplatform even better to target Windows too)
I have fallen in love with Ruby but without a means to tackle the above will be difficult to deploy for users, while I am not interested in Rails.
Feels like Rails popularity has in effect killed Ruby by putting it into a niche when it could be so much more.
Any new news on either of these 2 fronts or everything is abandoned / dead ?
Should I move on with Python / Objective-C ? (Which I like both but enjoy Ruby more)
I succesfully compiled scripts with tk, green shoes and gosu as a GUI to an executable with ocra but only have experience doing so on windows. If you want an actual, cross platform GUI try the java swing framework with jruby, here an example.
If you deploy a JAR or an executable nu further installations are needed.
I suppose you use MRI ruby now, the step to jruby is not so difficult.
require 'java'
# With the 'require' above, we can now refer to things that are part of the
# standard Java platform via their full paths.
frame = javax.swing.JFrame.new("Window") # Creating a Java JFrame
label = javax.swing.JLabel.new("Hello")
# We can transparently call Java methods on Java objects, just as if they were defined in Ruby.
frame.getContentPane.add(label) # Invoking the Java method 'getContentPane'.
frame.setDefaultCloseOperation(javax.swing.JFrame::EXIT_ON_CLOSE)
frame.pack
frame.setVisible(true)
RubyMotion is the best alternative. But if don't want to spend the money you should be able to use macruby.
Here are some resources
http://blog.phusion.nl/2010/03/12/creating-our-very-first-mac-application-with-ruby-how-exciting/
I must say that using macruby for a big project might not be a good idea. You should expect stuff breaking and few support. As of 2015, the [MacRuby page on GitHub][3] says that the project is in an indefinite hiatus due to the changes made by Apple in the Objective C garbage collection support that MacRuby depends on. They suggest using RubyMotion.
RubyMotion seems to be really good for what you want but for development the lack of a IDE is really a huge downside. Also from my experience rubymotion only comes handy if you already know the cocoa framework really well.
So my recommendation is for you to test rubymotion if you can. They give your money back in the first 30 days if you only want to try it out. So if you have the money give it a try.
If you are new to osx development and only want to develop for osx I think you should go with objective-c. The language is not that bad and you will get the best development environment available for it for free.

Ruby bindings for GTK+ 3?

I’ve spent some time learning Ruby, and I wanted to move over to some GUI programming. GNOME 3 is the environment most appealing to me at the moment, so I thought I would have a look at GTK+ 3. However, the GTK+ 3 documentation’s Getting Started examples in C were quite off-putting. Are there less scary Ruby bindings (and Hello World examples) available?
Edit: The GTK+ Language Bindings overview does not leave much room for hope.
After a quick chat on #ruby on freenode I learned that there are bindings for GTK+ 3 that are actively developmented:
https://github.com/mvz/ruby-gir-ffi
The project is still young. I'm looking forward to diving in and seeing what I can do too. Here's an introduction by the author: http://www.matijs.net/blog/2011/05/10/girffi-an-introduction
Right now there are gtk3 bindings. In fact there is a rubygem for gtk3. Just do:
$gem install gtk3
Ruby-GNOME2
Supports GTK+ 3 from version 1.2, released in January 2013.
Currently the Ruby Gnome project is only on GTK 2 but work has begun on GTK3 bindings. Take a look at this post on the Ruby Gnome2 forum: http://www.ruby-forum.com/topic/2715042#new (5th one down).
The project website has plenty of tutorials: http://ruby-gnome2.sourceforge.jp/
Installing it is pretty simple on Ubuntu:
sudo apt-get install libgtk2.0-dev
gem install gtk2
I'd start with this and move to GTK3 when there are stable bindings.
Ruby GIR bindings is interesting and I'll be keeping an eye on this but I don't think it'll be as simple to use as Ruby Gnome 2.
I don't know the situation around GNOME 3, sorry. But I do know the situation around KDE and QtRuby. Next stable release of KDE (in July) will contain updated version of QtRuby (it's in active development for now). You could try to start from now, but as for me, well, I'm waiting for the new version because of lack of some features, that I personally need.
There are some helpful IRC channels at Freenode, where you can ask for help: #qtruby, #kde-ruby, #kde-bindings.
Right now the main ruby-gnome project has no GTK 3 bindings.
The problem is lack of manpower.

Learning GUI programming with GTK+2 or GTK+3?

I am new to GUI programming, and I haven't found yet what library is best for my purpose (i want to make desktop environment applications, eg. docks, panels, desklets etc.)
I have started learning basics of GTK, mainly using PyGtk. Most tutorials i found on line are for GTK+2.0. Recently however, GTK+3 has been released. So i am a bit unsure as to what that means for my learning curve:
Should i learn using GTK+3 and forget about GTK+2?
Does using one or the other really makes a difference from the point of view of coding?
Are there PyGTK bindings for GTK+3 already?
Is there any available tutorial for GTK+3?
Since i'm new to this, i'm throwing myself into it blindly, but a bit of guidance may be wiser. So if you have any, you're welcome :)
Definitely go with GTK 3. The 10-minute tutorials on http://developer.gnome.org/ use GTK 3 and are an excellent introduction to programming with GTK in several languages, including Python. In the coming months you will probably see more tutorials appear for GTK 3, and in the meantime, you will still be able to get most tutorials for GTK 2 to work with a minimum of fuss. The basics aren't all that different.
Although late, I would like to share this information in the hope that it will be useful for anyone who have this doubt in future.
As ptomato said, GTK+ 3 is the way to go and much of the GTK+2 knowledge is applicable to GTK+3 also. PyGObject is the way to go with GTK+3, not PyGTK. See: PyGTK, GObject, and GNOME 3 to get an overall idea about this new change.
To know what differs and how to cope up with these changes, see:
Migrating from GTK+ 2.x to GTK+ 3
Porting Documentation
About the tutorials, following ones will be of helpful:
The Python GTK+ 3 Tutorial
GNOME Developer Platform Demos
Screen-casts by daniel g. siegel
GTK+ 3 Reference Manual

What graphical toolkits exist with "good" Ruby bindings?

I want to create a tool with Ruby which works with all 3 of the major OSes (Windows, Linux, Mac OS X). What choices do I have for toolkits where the bindings for Ruby is "good"? By good I mean not just quick direct mapping of the C/C++ API onto Ruby, for instance using blocks where appropriate and other Ruby features.
I would say QTRuby (so bindings for QT) seem to be the most advanced and also quite cross platform without requiring some pre-installed virtual machine - like in the case of Ruby (JRuby Java Swing Bridge - another very good solution if the user already has Swing know-how)
Until recently, pretty much the best options were Swing and SWT. And you know that there is something seriously wrong if Swing is your best option. But now, there's also WPF.
All three, Swing, SWT and WPF work great on Windows, OSX, Linux and probably a dozen others.
For OS X I would say MacRuby - http://www.macruby.org/ because of HotCocoa http://www.macruby.org/hotcocoa.html
By far the most thoroughly supported is Tk (Ruby/Tk: http://ruby-doc.org/docs/ProgrammingRuby/html/ext_tk.html), and it'll run on just about anything. Down side is, it isn't very pretty.
Here's another good guide for using Ruby/Tk: _http://www.tutorialspoint.com/ruby/ruby_tk_guide.htm
If you're looking for something a little nicer looking, try gtk(2): _http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk

Resources