GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Fri Jul 25, 2014 8:36 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: GTK and Glade Help
PostPosted: Fri Aug 03, 2012 12:14 am 
Offline
Familiar Face

Joined: Fri Aug 03, 2012 12:06 am
Posts: 5
Hello,
I was wondering if anyone could help me with the strange error I am getting. I am trying out Glade and for some reason it is not working when I compile. Here is the error message:

Quote:
(gtk_demo_3:1735): Gtk-CRITICAL **: gtk_widget_show: assertion `GTK_IS_WIDGET (widget)' failed

Here is my C file:

Code:
#include <gtk/gtk.h>

void
on_window_destroy (GtkObject *object, gpointer user_data)
{
    gtk_main_quit();
}

int
main (int argc, char *argv[])
{
             GtkBuilder *builder;
             GtkWidget *window;

              gtk_init (&argc, &argv);

              builder = gtk_builder_new ();
              gtk_builder_add_from_file (builder, "test1.xml", NULL);

              window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
              gtk_builder_connect_signals (builder, NULL);
              g_object_unref (G_OBJECT (builder));

              gtk_widget_show (window);
              gtk_main ();
              return 0;
}


It compiles and runs perfectly but then outputs that error. Here is the Glade XML:

Code:
<?xml version="1.0"?>
<interface>
  <!-- interface-requires gtk+ 2.24 -->
  <!-- interface-naming-policy project-wide -->
  <object class="GtkWindow" id="window">
    <property name="can_focus">False</property>
    <property name="border_width">10</property>
    <property name="title" translatable="yes">GTK_DEMO_3</property>
    <property name="modal">True</property>
    <child>
      <object class="GtkVBox" id="vbox">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="homogeneous">True</property>
        <child>
          <object class="GtkImage" id="image">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="stock">gtk-bold</property>
            <property name="icon-size">6</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">False</property>
            <property name="position">0</property>
          </packing>
        </child>
        <child>
          <object class="GtkHBox" id="hbox">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="homogeneous">True</property>
            <child>
              <object class="GtkButton" id="Peripherals">
                <property name="label" translatable="yes">Peripherals</property>
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">True</property>
              </object>
              <packing>
                <property name="expand">True</property>
                <property name="fill">True</property>
                <property name="position">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkButton" id="Status">
                <property name="label" translatable="yes">Status</property>
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">True</property>
              </object>
              <packing>
                <property name="expand">True</property>
                <property name="fill">True</property>
                <property name="position">1</property>
              </packing>
            </child>
            <child>
              <object class="GtkButton" id="System">
                <property name="label" translatable="yes">System</property>
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">True</property>
              </object>
              <packing>
                <property name="expand">True</property>
                <property name="fill">True</property>
                <property name="position">2</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="expand">True</property>
            <property name="fill">True</property>
            <property name="position">1</property>
          </packing>
        </child>
      </object>
    </child>
  </object>
</interface>


Thank you!!


Top
 Profile  
 
 Post subject: Re: GTK and Glade Help
PostPosted: Fri Aug 03, 2012 8:17 am 
Offline
Never Seen the Sunlight

Joined: Wed Jul 23, 2008 10:31 am
Posts: 2406
Location: Slovenia
Hello and welcome to the GTK+ forums!

I cannot tell exactly what went wrong, but most accurate guess I can give you is that your interface is not getting loaded properly and window is actually NULL. Check your filenames and their code references and try again. If things still fail, replace last parameter of gtk_builder_add_from_file() with an actual GError pointer and check for errors.

Cheers,
Tadej


Top
 Profile  
 
 Post subject: Re: GTK and Glade Help
PostPosted: Thu Aug 09, 2012 5:27 pm 
Offline
Familiar Face

Joined: Fri Aug 03, 2012 12:06 am
Posts: 5
Thanks for the response. It turns out that the code was fine. The problem was that my testing script was not copying over the right XML file for GtkBuilder.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group