RE: Getting the size of a Gtk::TreeView



Vladislav Grinchenko reply to me directly! Here is the answer :
> Instead, connect to signal_size_allocate and get your width

So i've done the following:

void callback( 	Gdk::Rectangle& not_used , 
			Gtk::TreeView& tree , 
 			Gtk::ScrolledWindow& scroll )
{
    Gtk::TreeViewColumn* col1 = tree.get_column( 0 );
    ...
    int width = col1->get_width() + col2->get_width() ...

    scroll.set_size_request( width );
}


somewhere else you must connect the callback function:

m_scrolled_window.signal_size_allocate().connect(
    sigc::bind<Gtk::TreeView&,Gtk::ScrolledWindow&>( sigc::ptr_fun( &callback )
									, m_tree_view
									, m_scrolled_window ));

And it's working fine.
But I think you can do something better with mem_fun( *this , ... )


Regards
Laurent Marzullo



-----Original Message-----
From: Surya Kiran Gullapalli [mailto:skg fluent co in]
Sent: Friday, February 11, 2005 2:12 PM
To: Laurent Marzullo
Cc: GTK--
Subject: Re: Getting the size of a Gtk::TreeView


Hi I was also trying to do the same thing, But could not succeed.

Any ideas on how to do this ?



Hello,

I'm trying to make a druid with Gnome::UI::Druid.

My second page for the druid hold a list containing information concerning
CORBA Server:

+----------------------------+----------+------+----------------------+
|Name                        | Activate | Mode | Data                 |
+----------------------------+----------+------+----------------------+
...
...
+---+------------------------+----------+------+----------------------+

This list is inside a scrolled window. But the scrolled window 'cut'
the list in the middle of the 'Activate' Column

                                  |
+--------------------------+------|
|Name                      | Activ|
                                  |

                                  ^
                                  |
                  Border of the   |
                 ScrolledWindow --+

So I'm trying to resize the ScrolledWindow by calculating the size of the
first 3 columns size('Ok') + size('Name') + size('Activate') But it does not
seem to work !

Here What I do:

m_scrolled_window.add( m_tree_view );
m_scrolled_window.set_policy( Gtk::POLICY_AUTOMATIC ,
Gtk::POLICY_AUTOMATIC );

pack_start( m_scrolled_window , Gtk::PACK_EXPAND_WIDGET , 5 );
m_ref_tree_model = Gtk::ListStore::create( m_model_column );
m_tree_view.set_model( m_ref_tree_model );

ok = Gdk::Pixbuf::create_from_file( "server-ok.png" );
unknown = Gdk::Pixbuf::create_from_file( "server-unknown.png" );
not_ok = Gdk::Pixbuf::create_from_file( "server-not-ok.png" );

Gtk::TreeView::Column* = Gtk::manage( new Gtk::TreeView::Column( "Name" ) );
col->pack_start( m_model_columns.m_icon );
col->pack_start( m_model_columns.m_name );
m_tree_view.append_column( *col );

m_tree_view.append_column( "Activate" , m_model_columns.m_activate );
m_tree_view.append_column( "Mode"     , m_model_columns.m_mode );
m_tree_view.append_column( "Data"     , m_model_columns.m_data );

// Populating the row of the list
CORBA::Server::iterator	itr = CORBA::Server::begin();
while ( itr != CORBA::Server::end() )
{
    Gtk::TreeModel::Row row = *(m_ref_tree_model->append());
    row[m_model_columns.m_icon = unknown;
    row[m_model_columns.m_name = (*itr)->name();
    ...
}

// Here I'm trying to get the size of the 3 first columns
Gtk::TreeViewColumn* col1 = m_tree_view.get_column(0);
Gtk::TreeViewColumn* col2 = m_tree_view.get_column(1);
Gtk::TreeViewColumn* col3 = m_tree_view.get_column(2);
int width = col1->get_width() + col2->get_width() + col3->get_width();
m_scolled_window->set_size_request( width , 50 );

// But here the 'width' variable is 0

Could someone help me please ?

Thanks
Laurent Marzullo

_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Surya Kiran Gullapalli 
Sr. Development Engineer
Fluent India Pvt. Ltd.,
Pune 




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