show greyed-out mountpoint of unmounted partitions in the treeview as an

* include/GParted_Core.h,
  include/TreeView_Detail.h,
  src/GParted_Core.cc,
  src/TreeView_Detail.cc: show greyed-out mountpoint of unmounted
  partitions in the treeview as an improved way to identify
  partitions. (#333027)
* src/Win_GParted.cc: cleanups
This commit is contained in:
Bart Hakvoort 2006-03-07 11:55:27 +00:00
parent 6dfa289c0e
commit b179990dc9
6 changed files with 72 additions and 37 deletions

View File

@ -1,3 +1,13 @@
2006-03-06 Bart Hakvoort <hakvoort@cvs.gnome.org>
* include/GParted_Core.h,
include/TreeView_Detail.h,
src/GParted_Core.cc,
src/TreeView_Detail.cc: show greyed-out mountpoint of unmounted
partitions in the treeview as an improved way to identify
partitions. (#333027)
* src/Win_GParted.cc: cleanups
2006-03-06 Bart Hakvoort <hakvoort@cvs.gnome.org> 2006-03-06 Bart Hakvoort <hakvoort@cvs.gnome.org>
* include/TreeView_Detail.h, * include/TreeView_Detail.h,

View File

@ -73,7 +73,8 @@ private:
GParted::FILESYSTEM get_filesystem() ; GParted::FILESYSTEM get_filesystem() ;
bool check_device_path( const Glib::ustring & device_path ) ; bool check_device_path( const Glib::ustring & device_path ) ;
void set_device_partitions( Device & device ) ; void set_device_partitions( Device & device ) ;
void read_mountpoints_from_file( const Glib::ustring & filename ) ; void read_mountpoints_from_file( const Glib::ustring & filename,
std::map< Glib::ustring, std::vector<Glib::ustring> > & map ) ;
void init_maps() ; void init_maps() ;
void set_mountpoints( std::vector<Partition> & partitions ) ; void set_mountpoints( std::vector<Partition> & partitions ) ;
void set_short_paths( std::vector<Partition> & partitions ) ; void set_short_paths( std::vector<Partition> & partitions ) ;
@ -120,6 +121,7 @@ private:
bool probe_devices ; bool probe_devices ;
std::map< Glib::ustring, std::vector<Glib::ustring> > mount_info ; std::map< Glib::ustring, std::vector<Glib::ustring> > mount_info ;
std::map< Glib::ustring, std::vector<Glib::ustring> > fstab_info ;
std::map< Glib::ustring, Glib::ustring > short_paths ; std::map< Glib::ustring, Glib::ustring > short_paths ;
std::map< Glib::ustring, Glib::ustring >::iterator iter ; std::map< Glib::ustring, Glib::ustring >::iterator iter ;
std::map< Glib::ustring, std::vector<Glib::ustring> >::iterator iter_mp ; std::map< Glib::ustring, std::vector<Glib::ustring> >::iterator iter_mp ;

View File

@ -72,6 +72,7 @@ private:
Gtk::TreeModelColumn<Glib::ustring> unused; Gtk::TreeModelColumn<Glib::ustring> unused;
Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > color; Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > color;
Gtk::TreeModelColumn<Glib::ustring> text_color; Gtk::TreeModelColumn<Glib::ustring> text_color;
Gtk::TreeModelColumn<Glib::ustring> mount_text_color;
Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > status_icon; Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > status_icon;
Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > error_icon; Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > error_icon;
Gtk::TreeModelColumn<Glib::ustring> flags; Gtk::TreeModelColumn<Glib::ustring> flags;
@ -80,8 +81,8 @@ private:
treeview_detail_Columns() treeview_detail_Columns()
{ {
add( path ); add( filesystem ); add( mountpoint ) ; add( path ); add( filesystem ); add( mountpoint ) ;
add( size ); add( used ); add( unused ); add( size ); add( used ); add( unused ); add( color );
add( color ); add( text_color ); add( status_icon ); add( text_color ); add( mount_text_color ); add( status_icon );
add( error_icon ) ; add( flags ); add( partition ); add( error_icon ) ; add( flags ); add( partition );
} }
}; };

View File

@ -149,10 +149,7 @@ void GParted_Core::get_devices( std::vector<Device> & devices )
set_device_partitions( temp_device ) ; set_device_partitions( temp_device ) ;
set_short_paths( temp_device .partitions ) ; set_short_paths( temp_device .partitions ) ;
set_mountpoints( temp_device .partitions ) ;
if ( temp_device .highest_busy )
set_mountpoints( temp_device .partitions ) ;
set_used_sectors( temp_device .partitions ) ; set_used_sectors( temp_device .partitions ) ;
if ( temp_device .highest_busy ) if ( temp_device .highest_busy )
@ -178,9 +175,11 @@ void GParted_Core::get_devices( std::vector<Device> & devices )
//clear leftover information... //clear leftover information...
//NOTE that we cannot clear mountinfo since it might be needed in get_all_mountpoints() //NOTE that we cannot clear mountinfo since it might be needed in get_all_mountpoints()
short_paths .clear() ; short_paths .clear() ;
fstab_info .clear() ;
} }
void GParted_Core::read_mountpoints_from_file( const Glib::ustring & filename ) void GParted_Core::read_mountpoints_from_file( const Glib::ustring & filename,
std::map< Glib::ustring, std::vector<Glib::ustring> > & map )
{ {
std::string line ; std::string line ;
char node[255], mountpoint[255] ; char node[255], mountpoint[255] ;
@ -200,7 +199,7 @@ void GParted_Core::read_mountpoints_from_file( const Glib::ustring & filename )
if ( index < line .length() ) if ( index < line .length() )
line .replace( index, 4, " " ) ; line .replace( index, 4, " " ) ;
mount_info[ node ] .push_back( line ) ; map[ node ] .push_back( line ) ;
} }
file .close() ; file .close() ;
@ -211,11 +210,13 @@ void GParted_Core::init_maps()
{ {
short_paths .clear() ; short_paths .clear() ;
mount_info .clear() ; mount_info .clear() ;
fstab_info .clear() ;
read_mountpoints_from_file( "/proc/mounts" ) ; read_mountpoints_from_file( "/proc/mounts", mount_info ) ;
read_mountpoints_from_file( "/etc/mtab" ) ; read_mountpoints_from_file( "/etc/mtab", mount_info ) ;
read_mountpoints_from_file( "/etc/fstab", fstab_info ) ;
//sort the mountpoints and remove duplicates.. //sort the mountpoints and remove duplicates.. (no need to do this for fstab_info)
for ( iter_mp = mount_info .begin() ; iter_mp != mount_info .end() ; ++iter_mp ) for ( iter_mp = mount_info .begin() ; iter_mp != mount_info .end() ; ++iter_mp )
{ {
std::sort( iter_mp ->second .begin(), iter_mp ->second .end() ) ; std::sort( iter_mp ->second .begin(), iter_mp ->second .end() ) ;
@ -382,9 +383,11 @@ void GParted_Core::set_mountpoints( std::vector<Partition> & partitions )
{ {
for ( unsigned int t = 0 ; t < partitions .size() ; t++ ) for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
{ {
if ( partitions[ t ] .busy && partitions[ t ] .filesystem != GParted::FS_LINUX_SWAP ) if ( ( partitions[ t ] .type == GParted::TYPE_PRIMARY ||
partitions[ t ] .type == GParted::TYPE_LOGICAL ) &&
partitions[ t ] .filesystem != GParted::FS_LINUX_SWAP )
{ {
if ( partitions[ t ] .type == GParted::TYPE_PRIMARY || partitions[ t ] .type == GParted::TYPE_LOGICAL ) if ( partitions[ t ] .busy )
{ {
iter_mp = mount_info .find( partitions[ t ] .partition ); iter_mp = mount_info .find( partitions[ t ] .partition );
if ( iter_mp != mount_info .end() ) if ( iter_mp != mount_info .end() )
@ -392,9 +395,15 @@ void GParted_Core::set_mountpoints( std::vector<Partition> & partitions )
else else
partitions[ t ] .error = _("Unable to find mountpoint") ; partitions[ t ] .error = _("Unable to find mountpoint") ;
} }
else if ( partitions[ t ] .type == GParted::TYPE_EXTENDED ) else
set_mountpoints( partitions[ t ] .logicals ) ; {
iter_mp = fstab_info .find( partitions[ t ] .partition );
if ( iter_mp != fstab_info .end() )
partitions[ t ] .mountpoints = iter_mp ->second ;
}
} }
else if ( partitions[ t ] .type == GParted::TYPE_EXTENDED )
set_mountpoints( partitions[ t ] .logicals ) ;
} }
} }
@ -440,11 +449,11 @@ void GParted_Core::set_used_sectors( std::vector<Partition> & partitions )
{ {
if ( partitions[ t ] .mountpoints .size() > 0 ) if ( partitions[ t ] .mountpoints .size() > 0 )
{ {
if ( statvfs( partitions[ t ] .mountpoints .back() .c_str(), &sfs ) == 0 ) if ( statvfs( partitions[ t ] .mountpoints .front() .c_str(), &sfs ) == 0 )
partitions[ t ] .Set_Unused( sfs .f_bfree * (sfs .f_bsize / 512) ) ; partitions[ t ] .Set_Unused( sfs .f_bfree * (sfs .f_bsize / 512) ) ;
else else
partitions[ t ] .error = partitions[ t ] .error =
"statvfs (" + partitions[ t ] .mountpoints .back() + "): " + Glib::strerror( errno ); "statvfs (" + partitions[ t ] .mountpoints .front() + "): " + Glib::strerror( errno );
} }
} }
else else

View File

@ -43,15 +43,17 @@ TreeView_Detail::TreeView_Detail()
get_column( 0 ) ->pack_start( treeview_detail_columns .error_icon, false ); get_column( 0 ) ->pack_start( treeview_detail_columns .error_icon, false );
get_column( 0 ) ->pack_start( treeview_detail_columns .status_icon, false ); get_column( 0 ) ->pack_start( treeview_detail_columns .status_icon, false );
//filesystem text //PARTITION
get_column( 1 ) ->pack_start( treeview_detail_columns .filesystem, true );
//colored text in Partition column //colored text in Partition column
Gtk::CellRendererText *cell_renderer_text = Gtk::CellRendererText *cell_renderer_text =
dynamic_cast<Gtk::CellRendererText*>( get_column( 0 ) ->get_first_cell_renderer() ); dynamic_cast<Gtk::CellRendererText*>( get_column( 0 ) ->get_first_cell_renderer() );
get_column( 0 ) ->add_attribute( cell_renderer_text ->property_foreground(), get_column( 0 ) ->add_attribute( cell_renderer_text ->property_foreground(),
treeview_detail_columns .text_color ); treeview_detail_columns .text_color );
//FILESYSTEM
//filesystem text
get_column( 1 ) ->pack_start( treeview_detail_columns .filesystem, true );
//colored text in Filesystem column //colored text in Filesystem column
std::vector<Gtk::CellRenderer*> renderers = get_column( 1 ) ->get_cell_renderers() ; std::vector<Gtk::CellRenderer*> renderers = get_column( 1 ) ->get_cell_renderers() ;
cell_renderer_text = dynamic_cast<Gtk::CellRendererText*>( renderers .back() ) ; cell_renderer_text = dynamic_cast<Gtk::CellRendererText*>( renderers .back() ) ;
@ -61,6 +63,12 @@ TreeView_Detail::TreeView_Detail()
//pixbuf and text are both left aligned //pixbuf and text are both left aligned
get_column( 1 ) ->get_first_cell_renderer() ->property_xalign() = Gtk::ALIGN_LEFT ; get_column( 1 ) ->get_first_cell_renderer() ->property_xalign() = Gtk::ALIGN_LEFT ;
cell_renderer_text ->property_xalign() = Gtk::ALIGN_LEFT ; cell_renderer_text ->property_xalign() = Gtk::ALIGN_LEFT ;
//MOUNTPOINT
//colored text in mountpoint column
cell_renderer_text = dynamic_cast<Gtk::CellRendererText*>( get_column( 2 ) ->get_first_cell_renderer() );
get_column( 2 ) ->add_attribute( cell_renderer_text ->property_foreground(),
treeview_detail_columns .mount_text_color );
//set alignment of numeric columns to right //set alignment of numeric columns to right
for( short t = 3 ; t < 6 ; t++ ) for( short t = 3 ; t < 6 ; t++ )
@ -163,8 +171,8 @@ void TreeView_Detail::create_row( const Gtk::TreeRow & treerow, const Partition
Utils::Get_Filesystem_String( partition .filesystem ) ; Utils::Get_Filesystem_String( partition .filesystem ) ;
//mountpoint //mountpoint
treerow[ treeview_detail_columns .mountpoint ] = treerow[ treeview_detail_columns .mount_text_color ] = partition .busy ? "black" : "darkgrey" ;
Glib::build_path( ", ", partition .mountpoints ) ; treerow[ treeview_detail_columns .mountpoint ] = Glib::build_path( ", ", partition .mountpoints ) ;
//size //size
treerow[ treeview_detail_columns .size ] = Utils::format_size( partition .get_length() ) ; treerow[ treeview_detail_columns .size ] = Utils::format_size( partition .get_length() ) ;

View File

@ -69,9 +69,12 @@ Win_GParted::Win_GParted( const std::vector<Glib::ustring> & user_devices )
vbox_main.pack_start( hbox_toolbar, Gtk::PACK_SHRINK ); vbox_main.pack_start( hbox_toolbar, Gtk::PACK_SHRINK );
//frame_visualdisk... ( contains the visual represenation of the disks ) //frame_visualdisk... ( contains the visual represenation of the disks )
frame_visualdisk .signal_partition_selected .connect( sigc::mem_fun( this, &Win_GParted::on_partition_selected ) ) ; frame_visualdisk .signal_partition_selected .connect(
frame_visualdisk .signal_partition_activated .connect( sigc::mem_fun( this, &Win_GParted::on_partition_activated ) ) ; sigc::mem_fun( this, &Win_GParted::on_partition_selected ) ) ;
frame_visualdisk .signal_popup_menu .connect( sigc::mem_fun( this, &Win_GParted::on_partition_popup_menu ) ); frame_visualdisk .signal_partition_activated .connect(
sigc::mem_fun( this, &Win_GParted::on_partition_activated ) ) ;
frame_visualdisk .signal_popup_menu .connect(
sigc::mem_fun( this, &Win_GParted::on_partition_popup_menu ) );
vbox_main .pack_start( frame_visualdisk, Gtk::PACK_SHRINK ) ; vbox_main .pack_start( frame_visualdisk, Gtk::PACK_SHRINK ) ;
//hpaned_main (NOTE: added to vpaned_main) //hpaned_main (NOTE: added to vpaned_main)
@ -1113,38 +1116,39 @@ void Win_GParted::activate_resize()
dialog .set_transient_for( *this ) ; dialog .set_transient_for( *this ) ;
if ( dialog .run( ) == Gtk::RESPONSE_OK ) if ( dialog .run() == Gtk::RESPONSE_OK )
{ {
dialog .hide( ) ;//i want to be sure the dialog is gone _before_ operationslist shows up (only matters if first operation) dialog .hide() ;
//if selected_partition is NEW we simply remove the NEW operation from the list and add it again with the new size and position ( unless it's an EXTENDED ) //if selected_partition is NEW we simply remove the NEW operation from the list and add
if ( selected_partition .status == GParted::STAT_NEW && selected_partition.type != GParted::TYPE_EXTENDED ) //it again with the new size and position ( unless it's an EXTENDED )
if ( selected_partition .status == GParted::STAT_NEW && selected_partition .type != GParted::TYPE_EXTENDED )
{ {
//remove operation which creates this partition //remove operation which creates this partition
for ( unsigned int t = 0 ; t < operations .size( ) ; t++ ) for ( unsigned int t = 0 ; t < operations .size() ; t++ )
{ {
if ( operations[ t ] .partition_new .partition == selected_partition .partition ) if ( operations[ t ] .partition_new .partition == selected_partition .partition )
{ {
operations.erase( operations .begin( ) + t ) ; operations.erase( operations .begin() + t ) ;
//And add the new partition to the end of the operations list //And add the new partition to the end of the operations list
Add_Operation( GParted::CREATE, dialog .Get_New_Partition( ) ); Add_Operation( GParted::CREATE, dialog .Get_New_Partition() );
break; break;
} }
} }
} }
else//normal move/resize on existing partition else//normal move/resize on existing partition
Add_Operation( GParted::RESIZE_MOVE, dialog .Get_New_Partition( ) ); Add_Operation( GParted::RESIZE_MOVE, dialog .Get_New_Partition() );
} }
} }
void Win_GParted::activate_copy( ) void Win_GParted::activate_copy()
{ {
copied_partition = selected_partition ; copied_partition = selected_partition ;
} }
void Win_GParted::activate_paste( ) void Win_GParted::activate_paste()
{ {
if ( ! max_amount_prim_reached() ) if ( ! max_amount_prim_reached() )
{ {
@ -1184,7 +1188,8 @@ void Win_GParted::activate_new()
if ( dialog .run() == Gtk::RESPONSE_OK ) if ( dialog .run() == Gtk::RESPONSE_OK )
{ {
dialog .hide() ;//make sure the dialog is gone _before_ operationslist shows up (only matters if first operation) dialog .hide() ;
new_count++ ; new_count++ ;
Add_Operation( GParted::CREATE, dialog .Get_New_Partition() ); Add_Operation( GParted::CREATE, dialog .Get_New_Partition() );
} }