Vala error: The name `set_revealed' does not exist in the context of `Gtk.InfoBar'

Viewed 574

I added a Gtk.InfoBar to my ui and everthing looks OK. In Glade I can switch the Infobar to Revealed and vice versa.

On the valadoc.org Dokumentation set_revealedis listed in the allowed methods.

public void set_revealed (bool revealed)

Sets the GtkInfoBar:revealed property to revealed.

But when I'm building my Project I recive error: The name 'set_revealed' does not exist in the context of'Gtk.InfoBar'

What am I doing wrong?

Here's my code:

namespace Zeiterfassunggtk {
    [GtkTemplate (ui = "/org/gnome/Zeiterfassunggtk/window.ui")]
    public class Window : Gtk.ApplicationWindow {
        [GtkChild]
        Gtk.TreeView treeview1 = new Gtk.TreeView ();
        [GtkChild]
        Gtk.Button refreshbutton;
        [GtkChild]
        Gtk.MenuButton menubutton;
        [GtkChild]
        Gtk.Button menubuttonrefresh;
        [GtkChild]
        Gtk.Button menubuttonsave;
        [GtkChild]
        Gtk.Button menubuttonquit;
        [GtkChild]
        Gtk.InfoBar infobar1;
        [GtkChild]
        Gtk.Label infobar1label;

        Gtk.TreeIter iter;
        Gtk.ListStore liststore1 = new Gtk.ListStore (3, typeof (string), typeof (string), typeof (string));

        private void setup_treeview (Gtk.TreeView treeview1) {
            treeview1.set_model (liststore1);

            treeview1.insert_column_with_attributes (-1, "Name", new Gtk.CellRendererText (), "text", 0, null);
            treeview1.insert_column_with_attributes (-1, "Job", new Gtk.CellRendererText (), "text", 1, null);
            treeview1.insert_column_with_attributes (-1, "Time", new Gtk.CellRendererText (), "text", 2, null);

            liststore1.append (out iter);
            liststore1.set (iter, 0, "Gerald", 1, "Job1", 2, "2018-01-01 18:23", -1);
        }

        void refresh () {
            liststore1.append (out iter);
            liststore1.set (iter, 0, "Gerald", 1, "Job1", 2, "2018-01-01 18:23", -1);
            //infobar1.set_revealed (true);
        }

        void save () {
            liststore1.append (out iter);
            liststore1.set (iter, 0, "Gerald", 1, "Job2", 2, "2018-01-01 24:00", -1);
        }

        public Window (Gtk.Application app) {
            Object (application: app);

            this.maximize ();

            this.setup_treeview (treeview1);

            infobar1.set_revealed (false);

            refreshbutton.clicked.connect (this.refresh);
            menubuttonrefresh.clicked.connect (this.refresh);
            menubuttonsave.clicked.connect (this.save);

            menubuttonquit.clicked.connect (app.quit);

            this.show_all ();
        }
    }
}

You can find the full code at github.com

1 Answers

It seems you are importing an older Version of Gtk+. Your window.ui states <requires lib="gtk+" version="3.16"/>.

set_revealed is available from [ Version ( since = "3.22.29" ) ] though.

Seems you'll have to update.

Source@valadoc.org

Related