Building a Vala Gtk Object Using Builder Content

It would be ideal to be able to create a new widget that the linker uses to load its contents, for example.

public class MyDialog : Dialog
  {
    public MyDialog
      {
        Gtk.Builder builder = new Gtk.Builder ();
        builder.add_from_file ("dialog.ui");
        this = builder.get_object ("my_dialog") as Gtk.Widget;
      }
    }

Obviously, this will not work because it this =is an invalid destination, but I am wondering if there is a way to set the contents of the widget using those that were loaded from the constructor.

In the meantime, I replaced this = ...with

var content = get_content_area ();
var dialog = builder.get_object ("my_dialog") as Gtk.Widget;
var _content = (dialog as Dialog).get_content_area ();
_content.reparent (content);

which works, but it will still make sense to me to download it directly.

Thank.

+5
source share
3 answers

, . ++ Gtk.Builder , , , ++ .

+1

, - , Vala 0.22 , . Glade , Vala, , , Gtk.Builder .

http://blogs.gnome.org/tvb/2013/05/29/composite-templates-lands-in-vala/

+3

. , , (.. Gtk.Dialog) Glade , . / Vala.

, , Glade 3.15 , Box, Grid . , .

+2
source

All Articles