-2

How do you display GTK3 ScrollBar stepper buttons in Vala?

this.bar = new Scrollbar (Orientation.VERTICAL, adj);

Switching on the stepper buttons in C + GTK3 is easy, it is the default. The usual Vala documentation tells you how to set the increment for the buttons but not how to display the buttons. Googling for an answer returns zero for every combination of keyword from the Vala + GTK3 documentation and for every combination of C + GTK3.

The following code produces a scroll bar in C. The buttons are on by default.

scroller = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, scroller_adjustment);

1 Answers1

1

Switching on the stepper buttons in C + GTK3 is easy.

In that case, providing (or linking to) an example of what you mean would have been helpful. It's generally trivial to port from C to Vala if you understand Vala, but not providing it means people who aren't familiar with that particular part of GTK+ have to look up documentation to answer (and possibly get it wrong).

The usual Vala documentation tells you how to set the increment for the buttons but not how to display the buttons.

Assuming that the "usual Vala documentation" is Valadoc, the Vala documentation is the same as the C documentation. The C documentation is also used as the basis for the documentation for other languages, so if you have good ideas for improving it I'm sure the GTK+ people would love a patch.

Anyways, assuming that what you want to do is set the "has-forward-stepper" and "has-backward-stepper" properties to true, you would do something like:

this.bar.has_forward_stepper = true;
this.bar.has_backward_stepper = true;

I'd say this is substantially easier than in C where you would have to use something like g_object_set(self->bar, "has-forward-stepper", true, "has-backward-stepper", true, NULL) where lots of stuff can go wrong (there is no type safety, you could forget the sentinel, etc.). However, if you prefer, you can do it in Vala just like you would in C:

this.bar.set ("has-forward-stepper", true, "has-backward-stepper", true);

Note that, like the C version, there is no type safety. However, Vala will automatically add the NULL sentinel for you.

GTK is neutered by Vala.

You were complaining in the last question I saw from you about how hard Vala was, too. Just like this question, that one had an answer which was much simpler than C. Maybe instead of whining on SO you should either actually learn Vala, stop using it, or at the very least hold off on the snarky douchebaggery until you find something that is actually difficult in Vala instead of something which has a trivial answer that you're simply unaware of.

nemequ
  • 16,623
  • 1
  • 43
  • 62
  • A google for vala scrollbar produces http://references.valadoc.org/#!api=gtk+-3.0/Gtk.Scrollbar. The page mentions steppers but not has_forward_stepper or any other way to switch on steppers. A google for vala scrollbar stepper produces only this question and the previously mentioned deficient valadoc page. A google for c scrollbar stepper produces https://developer.gnome.org/gtk3/stable/GtkScrollbar.html which lists six style properties including has_forward_stepper. Therefore the documentation is not the same. –  Mar 31 '16 at 08:43
  • The compiler produces: error: The name `has_forward_stepper' does not exist in the context of `Gtk.Scrollbar' this.bar.has_forward_stepper = true; –  Mar 31 '16 at 08:48
  • The compiler accepted the following line without error but the stepper buttons did not appear. this.bar.set ("has-forward-stepper", true, "has-backward-stepper", true); –  Mar 31 '16 at 08:53