Hi, I have strange problem with gtk+. I create 3 boxes with a label and an image for 3 buttons(and save their pointers in a Gui class to retrieve later if needed) absolutely equally but only the first one (Start button) is really displayed the rest 2 are not, I have checked their pointers and they are 0 in the third file(where the boxes are attached to the buttons, but in the second where the boxes are created(in constructor) the boxes' pointers are correct), so I get errors like: (crysotherm:6727): Gtk-CRITICAL **: gtk_widget_show: assertion `GTK_IS_WIDGET (widget)' failed (crysotherm:6727): Gtk-CRITICAL **: gtk_container_add: assertion `GTK_IS_WIDGET (widget)' failed while trying to attached those boxes to the newly created buttons (see: //simulation_page.cpp). I did use g_object_ref(); to keep the pointers to the boxes after creation, since they are not immidietly attached to a container, but only the first of them seems to remain... What do I do wrong? // gui.h #ifndef GUI_H #define GUI_H #include <gtk/gtk.h> class Gui { public: Gui(); ~Gui(); void buildGui(void *sPtr); GtkWidget *getRecordButtonBox(); GtkWidget *getStartButtonBox(); GtkWidget *getStopButtonBox(); GtkWidget *getScreenshotButtonBox(); private: GtkWidget *start_button_box; GtkWidget *stop_button_box; GtkWidget *record_button_box; GtkWidget *screenshot_button_box; GtkWidget *png_label_box(gchar *png_filename, gchar *label_text); }; #endif // GUI_H // gui.cpp: static gboolean delete_callback(GtkWidget *widget, GtkWidget *event, gpointer data) { gtk_main_quit (); return FALSE; } Gui::Gui() { start_button_box = png_label_box("gui/icons/player_play.png", "Start"); g_object_ref(start_button_box); stop_button_box = png_label_box("gui/icons/player_stop.png", "Stop"); g_object_ref(stop_button_box); record_button_box = png_label_box("gui/icons/player_record.png", "Record"); g_object_ref(record_button_box); screenshot_button_box = png_label_box("gui/icons/applets-screenshooter.png", "Screenshot"); g_object_ref(screenshot_button_box); } Gui::~Gui() { gtk_widget_destroy(start_button_box); gtk_widget_destroy(stop_button_box); gtk_widget_destroy(record_button_box); gtk_widget_destroy(screenshot_button_box); } void Gui::buildGui(void *sPtr) { Surgery *s = (Surgery *) sPtr; GtkWidget *window; GtkWidget *notebook; window = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(delete_callback), NULL); gtk_container_set_border_width(GTK_CONTAINER(window), 10); notebook = gtk_notebook_new(); gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_TOP); gtk_container_add(GTK_CONTAINER (window), notebook); createSimulationPage(notebook, s); createParametersPage(notebook, s); createRecordPage(notebook, s); createAboutPage(notebook); gtk_widget_show (notebook); gtk_widget_show(window); gtk_main(); } GtkWidget *Gui::getStartButtonBox() {return start_button_box;} GtkWidget *Gui::getStopButtonBox() {return stop_button_box;} GtkWidget *Gui::getRecordButtonBox() {return record_button_box;} GtkWidget *Gui::getScreenshotButtonBox() {return screenshot_button_box;} GtkWidget *Gui::png_label_box(gchar *png_filename, gchar *label_text) { GtkWidget *box; GtkWidget *label; GtkWidget *image; /* Create box for image and label */ box = gtk_hbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (box), 2); /* Now on to the image stuff */ image = gtk_image_new_from_file (png_filename); /* Create a label for the button */ label = gtk_label_new (label_text); /* Pack the image and label into the box */ gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 3); gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 3); gtk_widget_show (image); gtk_widget_show (label); return box; } // simulation_page.cpp, displaying buttons: // this one works toggle_button = gtk_toggle_button_new(); gtk_widget_show (s->getGui()->getStartButtonBox()); gtk_container_add (GTK_CONTAINER (toggle_button), s->getGui()->getStartButtonBox()); gtk_widget_show (toggle_button); gtk_box_pack_start (GTK_BOX (boxV), toggle_button, TRUE, FALSE, 20); g_signal_connect (G_OBJECT (toggle_button), "clicked", G_CALLBACK (start_button_callback), (gpointer) s); // this one doesn't work toggle_button = gtk_toggle_button_new(); gtk_widget_show (s->getGui()->getRecordButtonBox()); gtk_container_add (GTK_CONTAINER (toggle_button), s->getGui()->getRecordButtonBox()); gtk_widget_show (toggle_button); gtk_box_pack_start (GTK_BOX (boxV), toggle_button, TRUE, FALSE, 0); g_signal_connect (G_OBJECT (toggle_button), "clicked", G_CALLBACK (record_button_callback), (gpointer) s); // this one doesn't work button = gtk_button_new(); gtk_widget_show(s->getGui()->getScreenshotButtonBox()); gtk_container_add(GTK_CONTAINER (button), s->getGui()->getScreenshotButtonBox()); gtk_widget_show(button); gtk_box_pack_start(GTK_BOX (boxV), button, TRUE, FALSE, 0); _______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list