[gtkmm] Derived widgets and C object constructor



Hi!

I'm trying to do something similar to glademm's get_widget_derived() as per the example code below, but my implementation of any on_XXX() virtual function is not called.

Can someone explain to me why this is so? And perhaps even what I can do to fix it?

Cheers,
--
Christer Palm

---------------------------------------------------------------------

#include <gtkmm.h>
#include <iostream>
#include <gtk/gtkdialog.h>

class MyDialog : public Gtk::Dialog
{
    private:
        void on_response(int response_id) {
            std::cout << "on_response()" << std::endl;
        }
        void on_show() {
            std::cout << "on_show()" << std::endl;
        }

    public:
        MyDialog(GtkDialog* base) : Gtk::Dialog(base) {
            std::cout << "title: " << get_title() << std::endl;
        }
};

int main(int argc, char *argv[])
{
    Gtk::Main gtkmain(argc, argv);
    GtkDialog* base = GTK_DIALOG(gtk_dialog_new());
    gtk_window_set_title(GTK_WINDOW(base), "Hello world");
    MyDialog* my_dialog = new MyDialog(base);
    std::cout << "dialog created" << std::endl;
    int rc = my_dialog->run();
    std::cout << "my_dialog->run() returned " << rc << std::endl;
    return 0;
}




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]