Open renich opened 11 years ago
+100 Yeah, I've spent the last hour trying to show a simple dialog with no success.
I can't imagine anyone actually using this gem, as it's impossible to read out of the code how to use it without spending some stamina on it.
This is as close as I got on an hour, and still no success. I which I knew why the provided examples can actually send arguments to the initialisers - its not allowed on Gtk::MessageDialog.
dialog = Gtk::MessageDialog.new(self, 0, Gtk::MessageType[:info], Gtk::ButtonsType[:ok], "This is an INFO MessageDialog")
I agree more examples are needed. I'll see what I can do :-).
That said, the problem with Gtk::MessageDialog is that gobject-introspection doesn't handle its methods. This means that .new
falls back to the parent implementation (in this case, Gtk::Dialog.new). In general, any function that uses varargs in C is deemed 'unintrospectable' by gobject-introspection, and needs some hand-written wrapper. This is exactly what gir_ffi-gtk
is for (otherwise, GirFFi alone would be able to handle it). I've opened issue #13 to add overrides for Gtk::MessageDialog.
One final remark: You don't need to pass enums as Gtk::MessageType[:info]
. Just using the symbol will do.
For a hobby I need some gtk3 support for rubinius and the rubinius people suggested to have a try on gir_ffi-gtk (instead of ruby-gnome2).
As I trying to get started, I forked in order to include the 'sample' directory from ruby-gnome2 in a sample_of_gtk3 branch.
It was startling easy to 'convert' a few of the examples in the misc directory to gir_ffi-gtk (and the example even WORK with rubinius, which is gorgeous compared to ruby-gnome2 on rubinius).
That said, I still feel that the project is in its infancy because nothing from the more complex stuff works. The major blockers seems to be:
After many more trying, I was able to get some of the Pixbuf stuff running (sample/misc/aboutdialog.rb). It seems to be as easy as
I'm starting to see some elegance in the gir stuff of Gtk for foreign language bindings :smirk:.
GirFFI.setup :GdkPixbuf
a.logo = GdkPixbuf::Pixbuf.new_from_file("gnome-logo-icon.png")
Perhaps a (command line) tool that could dump info about the Repository objects would come in handy, especially for novice (like me). Ideally, the tool should be able to emit (pseudo) ruby code to see what attributes and methods there are, how many arguments (and of which type) they expect etc. I even think this could compensate for the missing examples and/or documentation.
I also had a try on sample/misc/treeview.rb. However, I found it extremely hard to even construct a TreeStore, and hence didn't arrived at anything. Even with the Gtk documentation, I have no idea what are the (ruby mapped) types of arguments to pass to the constructor/new method.
It turns out that there is already a tool chain that could read from GIR and could extract some documentation.
There are some more details about this at http://mathematicalcoffee.blogspot.ch/2012/09/developing-gnome-shell-extensions_6.html .
However, sometimes the GIR information is not appropriate. Cairo of the example above is such a case.
g-ir-generate /usr/lib/girepository-1.0/cairo-1.0.typelib >cairo.xml
g-ir-doc-tool -o cairo-folder cairo.xml
yelp-build html cairo-folder
Yes, ideally this would be the tool to use. Best if it can produce Ruby-specific output.
Hello,
IMHO, the examples are awesome; but too few.
I've requested collaboration around google+; specifically, in the ruby, gnome and gtk+ communities.
Having a full text editor or some sample app that shows how to use it would be awesome, if you ask me.