Hi all, On Fedora 33, derived widgets does not seem to be constructed properly by Gtk::Builder::get_widget_derived(). The reason I think so is that the overridden methods are not called for these widgets. Apart from that everything seems normal. No error message or anything.
I attached a sample code with a very simple case to replicate this problem. on_button_press_event() is never called for the derived widget. I have also noticed that if a dummy instance of the derived widget is created separately (using another constructor) before calling Gkt::Builder::add_from_string(), then the widget created by Builder also works normally. Please note that this may not occur on all distributions. e.g. I know that it does not occur on Arch Linux. Does anybody know if this a Fedora 33 specific issue or is it due to a recent update in Gtkmm that is only affecting Fedora for now?
#include <iostream> #include <gtkmm.h> class TVDerived : public Gtk::TextView { public: TVDerived() {} TVDerived( BaseObjectType* obj, const Glib::RefPtr< Gtk::Builder >& ) : Gtk::TextView( obj ) {} ~TVDerived() {} protected: bool on_button_press_event( GdkEventButton* event ) override { std::cout << "on button press event" << std::endl; return Gtk::TextView::on_button_press_event( event ); } }; class ExampleWindow : public Gtk::Window { public: ExampleWindow() { set_title( "get_widget_derived() Issue" ); set_default_size( 400, 200 ); const Glib::ustring ui_def = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\ <interface>\ <object class=\"GtkTextView\" id=\"tvd\">\ <property name=\"visible\">True</property>\ <property name=\"can-focus\">True</property>\ <property name=\"monospace\">True</property>\ </object>\ </interface>"; //TVDerived dummy; // solves the problem when uncommented auto refBuilder = Gtk::Builder::create(); try { refBuilder->add_from_string( ui_def ); } catch( ... ) { std::cout << "Glade Error! " << std::endl; return; } refBuilder->get_widget_derived( "tvd", m_TextView ); add( *m_TextView ); show_all_children(); } virtual ~ExampleWindow() {} protected: TVDerived* m_TextView; }; int main( int argc, char *argv[] ) { auto app = Gtk::Application::create( argc, argv, "org.gtkmm.example" ); ExampleWindow window; return app->run(window); }
_______________________________________________ gtkmm-list mailing list gtkmm-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtkmm-list