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]