GtkBuilder: gtk_widget_show_all: assertion `GTK_IS_WIDGET (widget)' failed



Hi,

This is my first attempt to use Gtk (version 2.12.11). So I used Glade
to create my GUI and used GtkBuilder and Vala as programming language.

For the moment, I only tried a very simple thing: show the main window
using GtkBuilder. The code is as follows:

public class Main
{

  private static MailBrowser app;

  public static int main (string[] args)
  {
    Gtk.init (ref args);
    
    app = new MailBrowser();
    app.run();

    return 0;
  }
}



public class MailBrowser {

  private Gtk.Builder builder;
  private Gtk.Widget  main_window;

  construct {
    try {
      builder = new Gtk.Builder();
      builder.add_from_file("MailBrowser.ui");
      main_window = (Gtk.Widget) builder.get_object("main_window");
      main_window.destroy += Gtk.main_quit;
    } catch (GLib.Error err) {
      var msg = new Gtk.MessageDialog (
        null, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.CANCEL, 
        "Failed to load UI\n" + err.message);
      msg.run();
      Gtk.main_quit();
    }
  }
  
  public void show_all(){
    main_window.show_all();
  }
  
  public void run(){
    show_all();
    Gtk.main();
  }

}




Compilation runs fine, but when I execute the program I get:


(MailBrowser:9851): Gtk-CRITICAL **: gtk_widget_show_all: assertion `GTK_IS_WIDGET (widget)' failed


Then, nothing happens. I suppose the program is waiting for the main
window to be closed, but since the above error prevert the main window
to be shown, nothing happens.
Ctrl-C quits the program.


I don't think there is a problem in my xml ui description file. it
looks like:

<?xml version="1.0"?>
<interface>
  <requires lib="gtk+" version="2.12"/>
  <object class="GtkWindow" id="main_window">
    <child>
      <!-- .. -->
    </child>
  </object>
</interface>


Is there a solution?

Thanks.

Mildred

-- 
Mildred Ki'Lya
╭───────── mildred593@online.fr ──────────
│ Jabber, GoogleTalk: <mildred jabber fr>
│ Site: <http://ki.lya.online.fr>              GPG ID: 9A7D 2E2B
│ Fingerprint: 197C A7E6 645B 4299 6D37 684B 6F9D A8D6 9A7D 2E2B


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