[Vala] Problem connecting signals from Glade to my code



Hey guys,

I have a problem connecting my code with GUI that I designed in Glade. The
problem that I keep stumbling upon is that I'm getting Gtk-WARNING **: Could not
find signal handler.

My code:

public class AssistantDirectoryHistory : AssistantOperation {
        [CCode (instance_pos = -1)]
        public void on_restorebutton_clicked(Gtk.Button source) {
                source.label = "clicked restore btn";
        }

        public Gtk.Widget make_listfiles_page() {
                        var page = new Gtk.Table(1, 1, false);
                        var builder = new Gtk.Builder();
                        builder.add_from_file("deja-dup/listfiles.ui");
                        builder.connect_signals(this);
                        var window = builder.get_object("viewport") as Gtk.Widget;
                        window.reparent(page);
                        return page;
        }

        /* Some other code that adds this Widget to a page in Gtk.Assistant */
}

On a friendly tip from #vala I tried greping the AssistantDirectoryHistory.c for
on_restorebutton_clicked and found that C function for this is:

$ grep on_restorebutton_clicked deja-dup/AssistantDirectoryHistory.c
void assistant_directory_history_on_restorebutton_clicked (GtkButton* source,
AssistantDirectoryHistory* self);
void assistant_directory_history_on_restorebutton_clicked (GtkButton* source,
AssistantDirectoryHistory* self) {

and set handler for clicked event to
assistant_directory_history_on_restorebutton_clicked (also tired
on_restorebutton_clicked and
deja_dup_app_assistant_directory_history_on_restorebutton_clicked) but I keep
getting the same error.

Since then I tried isolating the problem into a stand-alone app with the
following code and it works without any problems.

using GLib;

public class AssistantDirectoryHistory {
        [CCode (instance_pos = -1)]
        public void on_restorebutton_clicked(Gtk.Button source) {
                source.label = "luuulz";
        }

        Gtk.Window make_listfiles_page() {
                var topwindow = new Gtk.Window (Gtk.WindowType.TOPLEVEL);       
                var builder = new Gtk.Builder();
                builder.add_from_file("listfiles.ui");
                builder.connect_signals(this);
                var window = builder.get_object("viewport") as Gtk.Viewport;
                window.reparent(topwindow);
                return topwindow;
        }

        public void run() {
                var window = this.make_listfiles_page();
                window.show_all();
                Gtk.main();
        }
}

int main(string[] args) {
        Gtk.init(ref args);
        var adh = new AssistantDirectoryHistory();
        adh.run();
        return 0;
}

I also think I have all the CFLAGS that I need (--pkg gtk+-2.0 and --pkg
gmodule-2.0).

Any ideas why am I getting this error? Could the mere inheritance from another
class cause this problem (because that is the biggest change that I can see
compared to the stand-alone app)? Am I maybe missing some other namespace issue
and should I somehow tell Glade about it?




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]