cleanups
* src/Dialog_Partition_Info.cc, src/DrawingAreaVisualDisk.cc: cleanups
This commit is contained in:
parent
9532c3cad1
commit
ebad1f133b
|
@ -1,3 +1,8 @@
|
|||
2006-03-15 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* src/Dialog_Partition_Info.cc,
|
||||
src/DrawingAreaVisualDisk.cc: cleanups
|
||||
|
||||
2006-03-15 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* include/Partition.h,
|
||||
|
|
|
@ -45,7 +45,8 @@ Dialog_Partition_Info::Dialog_Partition_Info( const Partition & partition )
|
|||
|
||||
hbox = manage( new Gtk::HBox() );
|
||||
hbox ->pack_start( *image, Gtk::PACK_SHRINK ) ;
|
||||
hbox ->pack_start( * Utils::mk_label( "<b> " + (Glib::ustring) _( "Warning:" ) + " </b>" ), Gtk::PACK_SHRINK ) ;
|
||||
hbox ->pack_start( * Utils::mk_label( "<b> " + static_cast<Glib::ustring>(_( "Warning:") ) + " </b>" ),
|
||||
Gtk::PACK_SHRINK ) ;
|
||||
|
||||
frame ->set_label_widget( *hbox ) ;
|
||||
frame ->add( * Utils::mk_label( "<i>" + partition.error + "</i>", true, true, true ) ) ;
|
||||
|
@ -102,8 +103,9 @@ void Dialog_Partition_Info::init_drawingarea( )
|
|||
|
||||
//calculate proportional width of used and unused
|
||||
used = unused = 0 ;
|
||||
//FIXME: use Partition::get_length()..
|
||||
used = Utils::Round( (400 - BORDER *2) / ( static_cast<double>(partition .sector_end - partition .sector_start) / partition .sectors_used ) ) ;
|
||||
used = Utils::Round(
|
||||
(400 - BORDER *2) / ( static_cast<double>( partition .get_length() ) / partition .sectors_used ) ) ;
|
||||
|
||||
unused = 400 - used - BORDER *2 ;
|
||||
|
||||
//allocate some colors
|
||||
|
@ -134,12 +136,24 @@ void Dialog_Partition_Info::Display_Info( )
|
|||
this ->get_vbox() ->pack_start( *table, Gtk::PACK_SHRINK ) ;
|
||||
|
||||
//filesystem
|
||||
table ->attach( * Utils::mk_label( "<b>" + (Glib::ustring) _( "Filesystem:" ) + "</b>" ) , 0, 1, top, bottom, Gtk::FILL );
|
||||
table ->attach( * Utils::mk_label( Utils::Get_Filesystem_String( partition .filesystem ) ), 1, 2, top++, bottom++, Gtk::FILL );
|
||||
table ->attach( * Utils::mk_label( "<b>" + static_cast<Glib::ustring>( _("Filesystem:") ) + "</b>" ),
|
||||
0, 1,
|
||||
top, bottom,
|
||||
Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( Utils::Get_Filesystem_String( partition .filesystem ) ),
|
||||
1, 2,
|
||||
top++, bottom++,
|
||||
Gtk::FILL ) ;
|
||||
|
||||
//size
|
||||
table ->attach( * Utils::mk_label( "<b>" + (Glib::ustring) _( "Size:" ) + "</b>" ), 0,1,top, bottom,Gtk::FILL);
|
||||
table ->attach( * Utils::mk_label( Utils::format_size( this ->partition .get_length() ) ), 1, 2, top++, bottom++,Gtk::FILL );
|
||||
table ->attach( * Utils::mk_label( "<b>" + static_cast<Glib::ustring>( _("Size:") ) + "</b>" ),
|
||||
0, 1,
|
||||
top, bottom,
|
||||
Gtk::FILL) ;
|
||||
table ->attach( * Utils::mk_label( Utils::format_size( partition .get_length() ) ),
|
||||
1, 2,
|
||||
top++, bottom++,
|
||||
Gtk::FILL ) ;
|
||||
|
||||
if ( partition.sectors_used != -1 )
|
||||
{
|
||||
|
@ -148,20 +162,41 @@ void Dialog_Partition_Info::Display_Info( )
|
|||
Utils::Round( partition .sectors_used / static_cast<double>( partition .get_length() ) * 100 ) ;
|
||||
|
||||
//used
|
||||
table ->attach( * Utils::mk_label( "<b>" + (Glib::ustring) _( "Used:" ) + "</b>" ), 0, 1, top, bottom, Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( Utils::format_size( this ->partition .sectors_used ) ), 1, 2, top, bottom, Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( "\t\t\t( " + Utils::num_to_str( percent_used ) + "% )"), 1, 2, top++, bottom++, Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( "<b>" + static_cast<Glib::ustring>( _("Used:") ) + "</b>" ),
|
||||
0, 1,
|
||||
top, bottom,
|
||||
Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( Utils::format_size( partition .sectors_used ) ),
|
||||
1, 2,
|
||||
top, bottom,
|
||||
Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( "\t\t\t( " + Utils::num_to_str( percent_used ) + "% )"),
|
||||
1, 2,
|
||||
top++, bottom++,
|
||||
Gtk::FILL ) ;
|
||||
|
||||
//unused
|
||||
table ->attach( * Utils::mk_label( "<b>" + (Glib::ustring) _( "Unused:" ) + "</b>" ), 0,1, top, bottom,Gtk::FILL);
|
||||
table ->attach( * Utils::mk_label( Utils::format_size( this ->partition .sectors_unused ) ), 1, 2, top, bottom, Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( "\t\t\t( " + Utils::num_to_str( 100 - percent_used ) + "% )"), 1, 2, top++, bottom++, Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( "<b>" + static_cast<Glib::ustring>( _("Unused:") ) + "</b>" ),
|
||||
0, 1,
|
||||
top, bottom,
|
||||
Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( Utils::format_size( partition .sectors_unused ) ),
|
||||
1, 2,
|
||||
top, bottom,
|
||||
Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( "\t\t\t( " + Utils::num_to_str( 100 - percent_used ) + "% )"),
|
||||
1, 2,
|
||||
top++, bottom++,
|
||||
Gtk::FILL ) ;
|
||||
}
|
||||
|
||||
//flags
|
||||
if ( partition.type != GParted::TYPE_UNALLOCATED )
|
||||
{
|
||||
table ->attach( * Utils::mk_label( "<b>" + (Glib::ustring) _( "Flags:" ) + "</b>" ), 0, 1, top, bottom, Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( "<b>" + static_cast<Glib::ustring>( _("Flags:") ) + "</b>" ),
|
||||
0, 1,
|
||||
top, bottom,
|
||||
Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( Glib::build_path( ", ", partition .flags ) ),
|
||||
1, 2,
|
||||
top++, bottom++,
|
||||
|
@ -174,7 +209,7 @@ void Dialog_Partition_Info::Display_Info( )
|
|||
if ( partition .type != GParted::TYPE_UNALLOCATED && partition .status != GParted::STAT_NEW )
|
||||
{
|
||||
//path
|
||||
table ->attach( * Utils::mk_label( "<b>" + (Glib::ustring) _( "Path:" ) + "</b>" ),
|
||||
table ->attach( * Utils::mk_label( "<b>" + static_cast<Glib::ustring>( _("Path:") ) + "</b>" ),
|
||||
0, 1,
|
||||
top, bottom,
|
||||
Gtk::FILL ) ;
|
||||
|
@ -185,7 +220,7 @@ void Dialog_Partition_Info::Display_Info( )
|
|||
|
||||
//status
|
||||
Glib::ustring str_temp ;
|
||||
table ->attach( * Utils::mk_label( "<b>" + (Glib::ustring) _( "Status:" ) + "</b>" ),
|
||||
table ->attach( * Utils::mk_label( "<b>" + static_cast<Glib::ustring>( _("Status:") ) + "</b>" ),
|
||||
0, 1,
|
||||
top, bottom,
|
||||
Gtk::FILL ) ;
|
||||
|
@ -213,17 +248,34 @@ void Dialog_Partition_Info::Display_Info( )
|
|||
table ->attach( * Utils::mk_label( "" ), 1, 2, top++, bottom++, Gtk::FILL ) ;
|
||||
|
||||
//first sector
|
||||
table ->attach( * Utils::mk_label( "<b>" + (Glib::ustring) _( "First Sector:" ) + "</b>" ), 0, 1, top, bottom, Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( Utils::num_to_str( partition.sector_start ) ), 1,2, top++, bottom++,Gtk::FILL);
|
||||
table ->attach( * Utils::mk_label( "<b>" + static_cast<Glib::ustring>( _("First Sector:") ) + "</b>" ),
|
||||
0, 1,
|
||||
top, bottom,
|
||||
Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( Utils::num_to_str( partition .sector_start ) ),
|
||||
1, 2,
|
||||
top++, bottom++,
|
||||
Gtk::FILL ) ;
|
||||
|
||||
//last sector
|
||||
table ->attach( * Utils::mk_label( "<b>" + (Glib::ustring) _( "Last Sector:" ) + "</b>" ), 0, 1, top, bottom, Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( Utils::num_to_str( partition.sector_end ) ), 1, 2, top++, bottom++, Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( "<b>" + static_cast<Glib::ustring>( _("Last Sector:") ) + "</b>" ),
|
||||
0, 1,
|
||||
top, bottom,
|
||||
Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( Utils::num_to_str( partition.sector_end ) ),
|
||||
1, 2,
|
||||
top++, bottom++,
|
||||
Gtk::FILL ) ;
|
||||
|
||||
//total sectors
|
||||
table ->attach( * Utils::mk_label( "<b>" + (Glib::ustring) _( "Total Sectors:" ) + "</b>" ), 0, 1, top, bottom, Gtk::FILL ) ;
|
||||
//FIXME: use Partition::get_length() here..
|
||||
table ->attach( * Utils::mk_label( Utils::num_to_str( partition .sector_end - partition .sector_start ) ), 1, 2, top++, bottom++, Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( "<b>" + static_cast<Glib::ustring>( _("Total Sectors:") ) + "</b>" ),
|
||||
0, 1,
|
||||
top, bottom,
|
||||
Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( Utils::num_to_str( partition .get_length() ) ),
|
||||
1, 2,
|
||||
top++, bottom++,
|
||||
Gtk::FILL ) ;
|
||||
}
|
||||
|
||||
Dialog_Partition_Info::~Dialog_Partition_Info()
|
||||
|
|
|
@ -82,25 +82,18 @@ void DrawingAreaVisualDisk::set_static_data( const std::vector<Partition> & part
|
|||
std::vector<visual_partition> & visual_partitions,
|
||||
Sector length )
|
||||
{
|
||||
Sector p_length ;
|
||||
visual_partition vp ;
|
||||
//FIXME: any particular reason why Partition::get_length() isn't used in this function?
|
||||
//i'm also not sure why we use 'vp' this way.. Lets either use it or drop it :)
|
||||
|
||||
for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
|
||||
{
|
||||
visual_partitions .push_back( vp ) ;
|
||||
visual_partitions .push_back( visual_partition() ) ;
|
||||
|
||||
visual_partitions .back() .partition = partitions[ t ] ;
|
||||
|
||||
p_length = partitions[ t ] .sector_end - partitions[ t ] .sector_start ;
|
||||
visual_partitions .back() .fraction = p_length / static_cast<double>( length ) ;
|
||||
visual_partitions .back() .fraction = partitions[ t ] .get_length() / static_cast<double>( length ) ;
|
||||
|
||||
if ( partitions[ t ] .type == GParted::TYPE_UNALLOCATED || partitions[ t ] .type == GParted::TYPE_EXTENDED )
|
||||
visual_partitions .back() .fraction_used = -1 ;
|
||||
else if ( partitions[ t ] .sectors_used > 0 )
|
||||
visual_partitions .back() .fraction_used =
|
||||
partitions[ t ] .sectors_used / static_cast<double>( p_length ) ;
|
||||
partitions[ t ] .sectors_used / static_cast<double>( partitions[ t ] .get_length() ) ;
|
||||
|
||||
visual_partitions .back() .color = partitions[ t ] .color;
|
||||
this ->get_colormap() ->alloc_color( visual_partitions .back() .color );
|
||||
|
|
Loading…
Reference in New Issue