Re: Removing Widgets From Gtk::Table



I'll be damned.

#m4 macros are scary.

I think I found a patch. I submitted it to bugzilla to the bug opened by Steven.

Cheers,
Paul


Murray Cumming wrote:

Murray Cumming wrote:

I've had a similar problem.  IIRC, I fixed it by removing things from
the
Gtk::Table object directly, via Gtk::Table::remove, rather than from
the
auxiliary Table_Helpers::TableList one.  Try it.


That did the trick, thanks!

Having said that though, does that mean that the
Table_Helpers::TableList interface just doesn't work?


All API is meant to work.



Or was it just
never intended to be used in the manner I was attempting (using the
Table_Helpers::TableList::iterator to remove specific widgets from a
table).



Probably, yes. A very simple compileable test case would be helpful.


I'm gonna disagree on this one.  After doing a couple minutes of
reading, I don't think that child modifications are meant to be done on
the list returned by children.  Very few api's that I know of present
live lists like that.

If that part of the API can not work then it should be documented as
broken, and deprecated. A bug report would help us to figure that out.


Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com

#include <gtkmm.h>

class TableTest : public Gtk::Window
{
	public:
		TableTest() : Gtk::Window()
		{
			set_size_request( 300, 300 ) ;
			set_title( "Table Test" ) ;

			Gtk::VBox* main = Gtk::manage( new Gtk::VBox() ) ;

			_table = Gtk::manage( new Gtk::Table( 1, 1, true ) ) ;
			Gtk::Button* b = Gtk::manage( new Gtk::Button( "Delete Me" ) ) ;
			b->signal_clicked().connect( sigc::mem_fun( *this, &TableTest::iter_delete ) ) ;
			_table->attach( *b, 0, 1, 0, 1 ) ;
			main->pack_start( *_table, Gtk::PACK_EXPAND_WIDGET, 0 ) ;

			Gtk::Label* lbl = Gtk::manage( new Gtk::Label( "Delete me too." ) ) ;
			_hbox = Gtk::manage( new Gtk::HBox() ) ;
			_hbox->pack_start( *lbl, Gtk::PACK_EXPAND_WIDGET, 0 ) ;
			main->pack_start( *_hbox, Gtk::PACK_EXPAND_WIDGET, 0 ) ;

			add( *main ) ;

			show_all_children() ;
		}

		void
		iter_delete()
		{
			Gtk::Table_Helpers::TableList tlist = _table->children() ;
			Gtk::Table_Helpers::TableList::iterator titer = tlist.begin() ;
			tlist.erase( titer ) ;

			Gtk::Box_Helpers::BoxList blist = _hbox->children() ;
			Gtk::Box_Helpers::BoxList::iterator biter = blist.begin() ;
			blist.erase( biter ) ;
		}

		virtual
		~TableTest() {}

	private:
		Gtk::Table*		_table ;
		Gtk::HBox*		_hbox ;
} ;

int main( int argc, char* argv[] )
{
	Gtk::Main kit( &argc, &argv ) ;
	TableTest tt ;
	kit.run( tt ) ;
} ;





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