Re: How to Add Custom gtkmm Widget to Glade



I finally got the Glade program to display the picture I want.

So in the constructor of my widget I add this code (the code is similar to the custom widget example in gtkmm documentation):

//-----------------------------------------------------------------
        GtkWidgetClass *klass;

        klass = GTK_WIDGET_CLASS(G_OBJECT_GET_CLASS(gobj()));
        klass->draw = pintando_c;
//----------------------------------------------------------------- 

the pintando_c function is:

//--------------------------------------------------------------------
extern "C" gboolean  pintando_c(GtkWidget *ok, cairo_t * d)
{
  Gtk::Widget *p = Glib::wrap(ok);
  casilla *k = dynamic_cast<casilla *>(p);
  Cairo::Context j(d);
  Cairo::RefPtr<Cairo::Context> jj= j.create(j.get_target());
  k->on_draw(jj);

}
//-------------------------------------------------------------------

like on_draw function is private, I need to declare pintando_c funtion like a friend function of my widget class.

I'm so happy... BUT now I have a problem with properties, When I use Gtk::Builder::getwidget() no property changed in glade file (with glade) is reflected in the program.

Thanks in advance and sorry for my english


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