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

More examples needed #12

Open
renich opened this issue Jul 17, 2013 · 6 comments
Open

More examples needed #12

renich opened this issue Jul 17, 2013 · 6 comments

Comments

@renich
Copy link
Contributor

renich commented Jul 17, 2013

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.

@patrickhno
Copy link

+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")

@mvz
Copy link
Owner

mvz commented Apr 17, 2014

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.

@aanno
Copy link

aanno commented Jan 6, 2015

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:

  • No inheritance from the gtk3 widgets, at least not the (easy) way that is done in ruby-gnome2. I've sawn the remark on derived types at gir_ffi but for me the present state looks like a blocker. Perhaps I could give a helping hand with this but at the moment I'm not sure how archive better inheritance support.
  • No support for Gdk::Pixbuf (at least not in this namespace). This is critical, as most more complex examples use some sort of images and/or icons, hence Pixbuf is always involved. I guess you could get some support with plain gir_ffi but I haven't fiddle it out yet. Some advice would be welcome.

@aanno
Copy link

aanno commented Jan 6, 2015

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


GirFFI.setup :GdkPixbuf
a.logo = GdkPixbuf::Pixbuf.new_from_file("gnome-logo-icon.png")

I'm starting to see some elegance in the gir stuff of Gtk for foreign language bindings 😏.

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.

@aanno
Copy link

aanno commented Jan 14, 2015

It turns out that there is already a tool chain that could read from GIR and could extract some documentation.


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

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.

@mvz
Copy link
Owner

mvz commented Jan 14, 2015

Yes, ideally this would be the tool to use. Best if it can produce Ruby-specific output.

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

4 participants