Results 1 to 2 of 2

Thread: GTK+ removing container contents without destroying it

  1. #1
    Join Date
    Apr 2007
    Beans
    116

    GTK+ removing container contents without destroying it

    Im trying to write an app whereby the contents of a vbox is changed whilst the program is running.

    Ive written a set of functions which displays 'pages' of widgets in the vbox.

    The first time each function is called it works fine, but the second time each one is called nothing is displayed. I can only assume its because when

    gtk_container_remove (GTK_CONTAINER (rightpanescrollview),gtk_bin_get_child(GTK_BIN(ri ghtpanescrollview))); is called, the contents are destroyed even though Ive called gtk_widget_ref(generalpage) which I thought prevented that.

    The complete, relativly short function is as follows:

    Code:
    void showGeneralPage()
    {
    	g_print("Showing General Page\n");
    	if (generalpageinitialised==false)  //first time this func is called read widgets from glade
    	{
    		generalpage= glade_xml_get_widget(generalpagexml,"mainvbox");
    		glade_xml_signal_autoconnect(generalpagexml);
    		generalpageinitialised=true;
    		gtk_widget_ref(generalpage);
    		
    	}
    
    
    	if (pagedisplayed!="INIT") //will be INIT if no previous page was shown -app is just starting up
    	{
    	    
    	    //remove previous 'page'
    	  
    	    gtk_container_remove (GTK_CONTAINER (rightpanescrollview),gtk_bin_get_child(GTK_BIN(rightpanescrollview)));
    	  
    	}
    	
            pagedisplayed = "General";
    
    	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(rightpanescrollview),GTK_WIDGET(generalpage));
    	
    	gtk_widget_show_all(GTK_WIDGET(generalpage));
    }
    As I say the first time this function is called it shows fine. Second time, nothing.

  2. #2
    Join Date
    May 2007
    Location
    Bolton, UK
    Beans
    668
    Distro
    Xubuntu 13.04 Raring Ringtail

    Re: GTK+ removing container contents without destroying it

    Could you not use the hide_all function and show_all function for re-displaying them?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •