0

I'm trying to create a Window with a HeaderBar, and in the HeaderBar there will be a Switch. But, the switch gets sized vertically, and gets distorted (non proportional), is there some fix?Switch on HeaderBar

0

You need to set its valign property to center:

Gtk.Switch toggle = new Gtk.Switch();
toggle.valign = Gtk.Align.CENTER;

Also, it's worth having a look at Granite.ModeSwitch

EDIT: I strongly recommend Alessandro Castellani's Vala Tutorials. It covers everithing you need to know to get you started.

  • I'm just starting programming in Vala and Gtk. I'm using valadoc documentation, but it lacks more deep examples and in some cases it does not show all properties and methods (like valign), you have to browse the class hierarchy, it takes some time. Some options are non intuitive, for instance, boxes have 3 extra parameters on pack_start() or pack_end() where you can set if the widget should fill or add extra padding. Thank you. – Edney Oct 10 at 20:48
  • Hey @Edney, glad I could help. Gtk.Switch inherits valign from the Gtk.Widget class. I just started playing with Vala almost a month ago, and yes, digging through the documentation sucks, but it's worth it, and it is a big part of the job :D. I also spend a lot of time on GitHub, looking at how other existing applications are built. But a good proper IDE would help a lot... – Vlad Pop Oct 10 at 21:58
  • Auto completion would help (lol), thanks again – Edney Oct 10 at 22:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.