trivial cleanups

* include/TreeView_Detail.h,
  src/TreeView_Detail.cc: trivial cleanups
This commit is contained in:
Bart Hakvoort 2006-09-16 15:00:25 +00:00
parent b84a88b557
commit 600e990a6e
3 changed files with 39 additions and 35 deletions

View File

@ -1,3 +1,8 @@
2006-09-16 Bart Hakvoort <hakvoort@cvs.gnome.org>
* include/TreeView_Detail.h,
src/TreeView_Detail.cc: trivial cleanups
2006-09-16 Bart Hakvoort <hakvoort@cvs.gnome.org> 2006-09-16 Bart Hakvoort <hakvoort@cvs.gnome.org>
* src/DialogFeatures.cc: higgiefied the dialog a bit (#353104) * src/DialogFeatures.cc: higgiefied the dialog a bit (#353104)

View File

@ -46,6 +46,10 @@ public:
sigc::signal< void, unsigned int, unsigned int > signal_popup_menu ; sigc::signal< void, unsigned int, unsigned int > signal_popup_menu ;
private: private:
void load_partitions( const std::vector<Partition> & partitions,
bool & mountpoints,
bool & labels,
const Gtk::TreeRow & parent_row = Gtk::TreeRow() ) ;
bool set_selected( Gtk::TreeModel::Children rows, const Partition & partition, bool inside_extended = false ) ; bool set_selected( Gtk::TreeModel::Children rows, const Partition & partition, bool inside_extended = false ) ;
void create_row( const Gtk::TreeRow & treerow, const Partition & partition ); void create_row( const Gtk::TreeRow & treerow, const Partition & partition );
@ -54,8 +58,6 @@ private:
void on_row_activated( const Gtk::TreeModel::Path & path, Gtk::TreeViewColumn * column ) ; void on_row_activated( const Gtk::TreeModel::Path & path, Gtk::TreeViewColumn * column ) ;
void on_selection_changed() ; void on_selection_changed() ;
Gtk::TreeRow row, childrow;
Glib::RefPtr<Gtk::TreeStore> treestore_detail; Glib::RefPtr<Gtk::TreeStore> treestore_detail;
Glib::RefPtr<Gtk::TreeSelection> treeselection; Glib::RefPtr<Gtk::TreeSelection> treeselection;

View File

@ -84,39 +84,14 @@ TreeView_Detail::TreeView_Detail()
} }
void TreeView_Detail::load_partitions( const std::vector<Partition> & partitions ) void TreeView_Detail::load_partitions( const std::vector<Partition> & partitions )
{//FIXME:rewrite this one to make use of recursivity instead of duplicating stuff {
bool mount_info = false, label = false ; bool mountpoints = false, labels = false ;
treestore_detail ->clear() ; treestore_detail ->clear() ;
for ( unsigned int i = 0 ; i < partitions .size() ; i++ ) load_partitions( partitions, mountpoints, labels ) ;
{
row = *( treestore_detail ->append() );
create_row( row, partitions[ i ] );
if ( partitions[ i ] .type == GParted::TYPE_EXTENDED )
{
for ( unsigned int t = 0 ; t < partitions[ i ] .logicals .size() ; t++ )
{
childrow = *( treestore_detail ->append( row.children() ) );
create_row( childrow, partitions[ i ] .logicals[ t ] );
if ( partitions[ i ] .logicals[ t ] .get_mountpoints() .size() )
mount_info = true ;
if ( ! partitions[ i ] .label .empty() )
label = true ;
}
}
if ( partitions[ i ] .get_mountpoints() .size() ) get_column( 2 ) ->set_visible( mountpoints ) ;
mount_info = true ; get_column( 3 ) ->set_visible( labels ) ;
if ( ! partitions[ i ] .label .empty() )
label = true ;
}
get_column( 2 ) ->set_visible( mount_info ) ;
get_column( 3 ) ->set_visible( label ) ;
columns_autosize(); columns_autosize();
expand_all() ; expand_all() ;
@ -134,6 +109,28 @@ void TreeView_Detail::clear()
treestore_detail ->clear() ; treestore_detail ->clear() ;
} }
void TreeView_Detail::load_partitions( const std::vector<Partition> & partitions,
bool & mountpoints,
bool & labels,
const Gtk::TreeRow & parent_row )
{
Gtk::TreeRow row ;
for ( unsigned int i = 0 ; i < partitions .size() ; i++ )
{
row = parent_row ? *( treestore_detail ->append( parent_row .children() ) ) : *( treestore_detail ->append() ) ;
create_row( row, partitions[ i ] );
if ( partitions[ i ] .type == GParted::TYPE_EXTENDED )
load_partitions( partitions[ i ] .logicals, mountpoints, labels, row ) ;
if ( partitions[ i ] .get_mountpoints() .size() )
mountpoints = true ;
if ( ! partitions[ i ] .label .empty() )
labels = true ;
}
}
bool TreeView_Detail::set_selected( Gtk::TreeModel::Children rows, const Partition & partition, bool inside_extended ) bool TreeView_Detail::set_selected( Gtk::TreeModel::Children rows, const Partition & partition, bool inside_extended )
{ {
for ( unsigned int t = 0 ; t < rows .size() ; t++ ) for ( unsigned int t = 0 ; t < rows .size() ; t++ )
@ -146,8 +143,8 @@ bool TreeView_Detail::set_selected( Gtk::TreeModel::Children rows, const Partiti
set_cursor( static_cast<Gtk::TreePath>( rows[ t ] ) ) ; set_cursor( static_cast<Gtk::TreePath>( rows[ t ] ) ) ;
return true ; return true ;
} }
if ( rows[ t ] .children() .size() > 0 && set_selected( rows[ t ] .children(), partition, true ) ) if ( set_selected( rows[ t ] .children(), partition, true ) )
return true ; return true ;
} }
@ -234,7 +231,7 @@ void TreeView_Detail::on_selection_changed()
{ {
if ( ! block && treeselection ->get_selected() != 0 ) if ( ! block && treeselection ->get_selected() != 0 )
{ {
row = static_cast<Gtk::TreeRow>( * treeselection ->get_selected() ) ; Gtk::TreeRow row = static_cast<Gtk::TreeRow>( * treeselection ->get_selected() ) ;
signal_partition_selected .emit( row[ treeview_detail_columns .partition ], true ) ; signal_partition_selected .emit( row[ treeview_detail_columns .partition ], true ) ;
} }
} }