[sigc] libsigc++ tutorial



Using Gtkmm - 2.22 on  Win7 with MinGW.

 

 

Well, this is what I have done so far, based on what I understand from the libsigc++ tutorial, what am I doing wrong?

 

class myEntry : virtual public Gtk::VBox {

private:

    Gtk::Entry* ntrTest;

    Gtk::Label* lblTest;

   

public:

   sigc::signal<void> signal_detected; //  gcc complains, if it is private??

    myEntry();

    virtual ~myEntry() {}

    bool notifyOutofFocus(GdkEventFocus* event);

};

myEntry::myEntry() {

    this->ntrTest = Gtk::manage(new Gtk::Entry());

    this->ntrTest->signal_focus_out_event().connect(sigc::mem_fun(*this, &jme::myEntry::notifyOutofFocus));

    this->lblTest = Gtk::manage(new Gtk::Label("test", Gtk::ALIGN_LEFT));

    this->pack_start(*lblTest);

    this->pack_start(*ntrTest);

}

bool myEntry::notifyOutofFocus(GdkEventFocus* event) {

        signal_detected.emit();

        return false;

}

class runner : public Gtk::Window {

private:

    Gtk::Button* btnapply;

    Gtk::Button* btnexit;

    Gtk::HBox* btnhb;

    Gtk::VBox* vb;

    jme::myEntry* mentry;

 

public:

    runner();

    ~runner() {}

    void apply() { /*do something*/    }

    void close() {  this->hide();   }

    bool warn_people();

 

};

bool runner::warn_people() {

    std::cout << "Warning people" << std::endl;

    return false;

}

runner::runner() {

    btnhb = Gtk::manage(new Gtk::HBox);

    vb = Gtk::manage(new Gtk::VBox);

    mentry = Gtk::manage(new jme::myEntry);

////////// >> compile time error !!

    mentry->signal_detected.connect( sigc::mem_fun(*this, &runner::warn_people) );

//////// <<< compile time error ends

    btnapply = Gtk::manage(new Gtk::Button(Gtk::Stock::APPLY));

    //btnapply->signal_clicked().connect( sigc::mem_fun(*this, &runner::apply));

 

    btnexit = Gtk::manage(new Gtk::Button(Gtk::Stock::CLOSE));

    btnexit->signal_clicked().connect(sigc::mem_fun(*this, &runner::close));

 

    vb->pack_start(*mentry);

    btnhb->pack_start(*btnapply);

    btnhb->pack_start(*btnexit);

    vb->pack_start(*btnhb);

 

    set_default_size(200, 50);

    this->add(*vb);

    this->show_all();

 

 

}

 

int main(int argc, char *argv[]) {

    Gtk::Main kit(argc, argv);

    runner jaime;

    Gtk::Main::run(jaime);

 

    return 0;

}

 

This e-mail is for the sole use of the intended recipient and may contain confidential or privileged information. Unauthorized use of its contents is prohibited. If you have received this e-mail in error, please notify sender immediately via return e-mail and then delete the original e-mail.

 



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