gtk_box_pack: assertion `child->parent == NULL



Hi I am trying to put Gtk::menu to Gtk:Vbox container, when I run it, I get
exception throw with msg "(main:14565): Gtk-CRITICAL **: gtk_box_pack:
assertion `child->parent == NULL' failed"
And here is my code:
/* 
 * File:   newfile.hpp
 * Author: cppguy
 *
 * Created on 10 February 2011, 06:44
 */

#ifndef NEWFILE_HPP
#define	NEWFILE_HPP
#include "gtkmm-2.4/gtkmm/window.h"
#include <gtkmm-2.4/gtkmm/menu.h>
#include <gtkmm-2.4/gtkmm/label.h>
#include "gtkmm/scale.h"
#include "gtkmm/box.h"

class window:public Gtk::Window{
private:
    Gtk::Menu menu1;
    Gtk::Label label1;
    Gtk::HScale hscale1;
    Gtk::HBox hbox1;
    Gtk::VBox vbox1;
public:
    window();
    ~window();
    void on_menu_posission(Gtk::PositionType);

};



#endif	/* NEWFILE_HPP */

#include <gtkmm-2.4/gtkmm/action.h>
#include <gtkmm-2.4/gtkmm/adjustment.h>

#include "newfile.hpp"
#include "gtkmm/menuitem.h"

window::window():
        label1("Pasirinkite is saraso: "),
        hscale1(0.0,10.0,0.5),
        hbox1(false,5),
        vbox1(false,5)
{
    set_title("Menu");
    Gtk::MenuItem* item=Gtk::manage(new Gtk::MenuItem("Apatinis"));
    item->signal_activate().connect(sigc::bind(sigc::mem_fun(*this,
            &window::on_menu_posission),Gtk::POS_BOTTOM));
    menu1.append(*item);

    item=Gtk::manage(new Gtk::MenuItem("Virsutinis"));
    item->signal_activate().connect(sigc::bind(sigc::mem_fun(*this,
            &window::on_menu_posission),Gtk::POS_TOP));
    menu1.append(*item);

    add(hbox1);

    hbox1.set_border_width(10);
    vbox1.set_border_width(5);
    hbox1.pack_start(vbox1);
    vbox1.pack_start(label1);
    vbox1.pack_start(hscale1);
    hbox1.pack_start(menu1);

    
    show_all_children();
}
window::~window(){}
void window::on_menu_posission(Gtk::PositionType pos){
    hscale1.set_value_pos(pos);
}
/* 
 * File:   main.cpp
 * Author: cppguy
 *
 * Created on 10 February 2011, 06:40
 */

#include <cstdlib>
#include "gtkmm/main.h"
#include "newfile.hpp"

using namespace std;

/*
 * 
 */
int main(int argc, char** argv) {
    Gtk::Main m(argc,argv);
    window win;
    Gtk::Main::run(win);
    
    return 0;
}


-- 
View this message in context: http://old.nabble.com/gtk_box_pack%3A-assertion-%60child-%3Eparent-%3D%3D-NULL-tp30894766p30894766.html
Sent from the Gtkmm mailing list archive at Nabble.com.



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