Re: Using Gtk::Builder with a doubly-derived widget

Kjell Ahlstedt via gtkmm-list <[email protected]> Sat, 4 Jul 2020 12:09:48 +0200
Newsgroups gmane.comp.gnome.gtkmm
Message-ID <[email protected]>
A subject line would be fine.

Do you intend to create a GtimerController widget from the gtimer.glade 
file? Something like

    GtimerController *gtimer = nullptr;
    refFileBuilder->get_widget_derived("m_main_window", gtimer);

I would try

GtimerController::GtimerController(BaseObjectType* cobject, const 
Glib::RefPtr<Gtk::Builder> &builder)
    : GtimerGui(cobject, builder)
    {
    }

I haven't tested anything like that, but I think it will work.

Kjell

On 2020-07-04 01:48, Liomar da Hora via gtkmm-list wrote:
> Hello
> I'm creating an app with gtkmm using Gtk :: Builder according to the 
> book and I can make the app work.
> I am now intending to derive this class which is already derived from 
> Gtk :: ApplicationWindow.
> How do I start the constructor of the base class it has 
> (BaseObjectType * cobject, and const Glib :: RefPtr <Gtk :: Builder> & 
> builder) in the derived class?
>
> Ex:
> ###### example.h ######
>
> class GtimerGui : public Gtk::ApplicationWindow
> {
> public:
> GtimerGui(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& 
> builder);
>  ~GtimerGui();
> Gtk::ApplicationWindow *main_window;
> Glib::RefPtr<Gtk::Builder> sp_FileBuilder;
> };
>
> ###### example.cpp ######
>
> GtimerGui::GtimerGui(BaseObjectType* cobject, const 
> Glib::RefPtr<Gtk::Builder> &builder)
> : Gtk::ApplicationWindow(cobject), sp_FileBuilder(builder)
> {
> }
>
> GtimerGui::~GtimerGui()
> {
> }
> ###### Main.cpp #######
>
> nt main (int argc, char *argv[])
> {
>    auto app = Gtk::Application::create (argc, argv, "liomar.org.example");
>    auto refFileBuilder = Gtk::Builder::create();
>    try
>    {
>  refFileBuilder->add_from_file("/home/suporte/Projeto_2019/GTimer/gtimer.glade");
>   }
>    catch(const Glib::FileError &ex)
>    {
>   std::cerr << "FileError: " << ex.what() << std::endl;
>
>    }
>    catch(const Glib::MarkupError& ex)
>    {
>   std::cerr << "MarkupError: " << ex.what() << std::endl;
>    }
>    catch(const Gtk::BuilderError& ex)
>    {
>   std::cerr << "BuilderError: " << ex.what() << std::endl;
>    }
>    GtimerGui *gtimer = nullptr;
>    refFileBuilder->get_widget_derived("m_main_window", gtimer);
>    if(gtimer)
>    {
>     app->run(*gtimer);
>     }
>    delete gtimer;
>    return 0;
> }
>
> ##### Derived_Class.h #####
> class GtimerController : public GtimerGui
> {
> public:
>  GtimerController();
>  ~GtimerController();
> };
>
> ##### Derived_Class.cpp ####
> GtimerController::GtimerController()
> {
> }
>
> GtimerController::~GtimerController()
> {
> }
>

_______________________________________________
gtkmm-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gtkmm-list