Re: Reparent command problem



Don't reparent anything. You shall not replace the message area with your own box, you shall add your grid to the existing box.

    Gtk::Label *label1 = Gtk::manage(new Gtk::Label("some text"));
    Gtk::Label *label2 = Gtk::manage(new Gtk::Label("some more text"));

    Gtk::Grid *grid = Gtk::manage(new Gtk::Grid);
    Gtk::Box *vbox = dialog.get_message_area();

    vbox->add(*grid);
    grid->attach(*label1,0,2,1,1);
    grid->attach(*label2,1,2,2,1);

2014-04-03 11:31, mike lear skrev:
Hello,
    I am a newcomer to Gtkmm and this mailing list, I have a question
regarding the use of the reparent command using gtkmm-3.
I am attempting to add several text labels to the MessageDialog. I wish
to position these labels below the dialog-secondary text using a grid
to achieve this. The following snippet of code works but gives the
following warning.
Gtk-WARNING **: Attempting to add a widget with type GtkBox to a container
of type gtkmm__GtkWindow, but the widget is already inside a container of
type GtkBox, please use gtk_widget_reparent()

I understand that the format for the reparent function is
 gtk_widget_reparent(original widget,new widget);

I am trying to reparent the MessageDialog's vertical box with my new one
Every attempt I have made so far has failed...

//Snippet of my code
// The true in Messagedialog is becuse the Message string contains pango markup
Gtk::MessageDialog dialog(*this,Message->c_str(),true,Gtk::MESSAGE_INFO,Gtk::BUTTONS_CLOSE);

    // some text labels that I wish to add to the MessageDialog
    Gtk::Label *label1 = Gtk::manage(new Gtk::Label("some text"));
    Gtk::Label *label2 = Gtk::manage(new Gtk::Label("some more text"));

    // then the box and grid I wish to add
      Gtk::Grid *grid = Gtk::manage(new Gtk::Grid);
     Gtk::Box *vbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL, 0));

    vbox = dialog.get_message_area(); // make vbox the new message area

    // The next line of code is where I have the problem.
    gtk_widget_reparent(???,???);   //What do I place here ?

    add(*vbox);                       // add the new vbox
    vbox->add(*grid);                 // then the grid
    grid->attach(*label,0,2,1,1);     // finally position the labels
    grid->attach(*label,1,2,2,1);

dialog.set_secondary_text("secondary text");

     vbox->show_all();                 // display it
dialog.run();

I would appreciate any pointers on how I can achieve this.
Thank you.




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