Search code examples
clinuxgtkgtk3

Gtk. Can't get HdyClamp object through GtkBuilder in C


I have the following HdyClamp declaration in a .ui file. HdyClamp is defined in the libhandy api. see here

 .......

 <object class="HdyClamp" id="cl">
            <property name="visible">True</property>
            <property name="can-focus">False</property>
            <child>
 .......

Since HdyClamp is also a GtkWidget, I thought I should be able to get this object through GtkBuilder and store it in a GtkWidget object. Here is the code.

 GtkWidget * clamp = GTK_WIDGET(gtk_builder_get_object(builder, "cl"));

Where builder is a GtkBuilder object associated with the .ui file. The result is that clamp is NULL after that line which means gtk_builder_get_object() failed to return the HdyClamp object with the given ID cl. I am really not sure why this happens and would greatly appreciate the help.


Solution

  • The issue is fixed, see the comments under the post.