Ошибка Vala: имя `set_revealed 'не существует в контексте` Gtk.InfoBar' - PullRequest
0 голосов
/ 30 августа 2018

Я добавил Gtk.InfoBar к своему интерфейсу, и все выглядит хорошо. В Glade я могу переключить Infobar на Revealed и наоборот.

На valadoc.org Документация set_revealed указана в разрешенных методах.

публичная пустота set_revealed (выявлено bool)

Устанавливает свойство GtkInfoBar: открыл для раскрытия.

Но когда я строю свой проект, я получаю error: The name 'set_revealed' does not exist in the context of'Gtk.InfoBar'

Что я делаю не так?

Вот мой код:

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 ();
        }
    }
}

Полный код вы можете найти на github.com

1 Ответ

0 голосов
/ 30 августа 2018

Кажется, вы импортируете старую версию Gtk +. Ваши window.ui состояния <requires lib="gtk+" version="3.16"/>.

set_revealed доступно от [ Version ( since = "3.22.29" ) ], хотя.

Кажется, вам придется обновить.

Source@valadoc.org

...