Re: Connecting DrawingArea signal w/ gtkmm 3



On Mon, Dec 16, 2013 at 2:37 PM, Ken Bass <daytooner gmail com> wrote:

I have a gtkmm app (gui built with glade). It has several buttons, and one
DrawingArea widget.

I use the builder's "create_from_file" to load the gui, get pointers to
the widgets, and then (try to) connect signals through
widget->signal_xxx().connect(). This works fine for the buttons, but I
can't get it to work for the DrawingArea.




Oops, spoke (wrote) too soon.

Got it to finally work after messing around trying to interpret the
function templates and tweaking my syntax. FWIW, here is what I got:

the signal handler:

bool CMy_GUI::on_draw_display(const Cairo::RefPtr<Cairo::Context>& cr)
{
    ...
    return true;
}

and to set up the signal connection:

    pbuilder->get_widget("drawingarea", mp_da);
    mp_da->signal_draw().connect(sigc::mem_fun(*this,
&CMy_GUI::on_draw_display));

This process works quite well, although it needs manual intervention (get
the widget from the builder by name, make the signal connection, etc.).
Some amount of automation might be nice, though. For this app, I have over
20 push buttons - many using the same signal handler - and a few other
widgets as well. Coding for these can become tedious. Yet, to have glade to
visually design the layout is a big plus, and by far overcomes the tedium.


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