Measure and Size_allocate virtual function for custom widget

,

Hi everybody, I’m trying to implement a custom widget that needs functionalities that are like the one set in
the read_more gtk_demos widget example, but I’m having issues with it.
I’m trying to get my head around the measure and allocate widget_class virtual functions, so I’ve just added them in my class, and set widget_class->measure = my_widget_measure, widget_class->size_allocate = my_widget_allocate. Inside these functions, I’ve put some code to check their behavior as I’m resizing my window so at first I’ve just put g_print(“allocate\n”) in “the allocate function” and g_print(“measure\n”) in the measure function. I was expecting the program to print measure and/or allocate as I was resizing my window, like it did when I modified the read_more.c code to do that, but nothing was printed.
So I thought that it was because my functions were lacking some code, like gtk_widget_measure
and a gtk_widget_size_allocate, to really implement them. I decided to do that, but unfortunately it didn’t change anything.
And now I’m stuck, because these functions doesn’t seem to work even if they should produce at least a crash or some errors, but nothing happens which is worse in a way.
Here you can find the source code gread/gread-introduction.c at dev · Xalares/gread · GitHub in question.
Thanks for your time !

I’ve partially solved my problem, my custom size_allocate method is not used because I use a layout manager. Now I need a way to use the layout manager’s size_allocate virtual method.

You can’t “use” the allocate() virtual function of a layout manager: you can only implement it. If you are using an existing LayoutManager then you don’t have access to its implementation; you will need to create your custom LayoutManager class, and then assign an instance of that class to your widget.