Is there a way to force a label to never try to re-size when the text changes?
The problem I'm trying to solve is that on my system re-sizing and re-drawing the 500+ widgets in my application takes on the order of 300-400ms. All the widgets are in the widget hierarchy of the displayed window under the top level window with different views stored in a Gtk::Stack. I have several data readouts that need to be updated about about 4Hz.
My frustration is that the minimum size of the label never approaches the allocated size. Even so, the minimum size change triggers recalculation of every widget in the hierarchy.
I tried switching from a label to a text view per this discussion on the gnome mailing list with no luck. I've included an example of how things shift around as the scale moves. Is there any way to fix the size of the left widget that prevents total windows redraws at it changes size?
#include <gtkmm.h>
int main( int argc, char* argv[]) {
Glib::RefPtr<Gtk::Application> app =
Gtk::Application::create( argc, argv, "test" );
Gtk::Window window;
Gtk::Box box;
Gtk::TextView left;
Gtk::Label right( "right" );
Glib::RefPtr<Gtk::Adjustment> adjustment =
Gtk::Adjustment::create( 0.0, 0.0, 10.0 );
Gtk::Scale scale( adjustment, Gtk::Orientation::ORIENTATION_VERTICAL );
scale.set_draw_value( false );
window.set_size_request(200, 200);
window.add( box );
box.pack_start( left, true, true );
box.pack_start( right, true, true );
box.pack_start( scale );
adjustment->signal_value_changed().connect( [&]() {
Glib::ustring str;
for( int i = 0; i <= (int)adjustment->get_value(); i++ ) {
str += "X";
}
left.get_buffer()->set_text( str );
} );
window.show_all();
return app->run( window );
}