added get_length() from now on values >=1024MB are displayed in GB's
* include/Partition.h, src/Partition.cc: added get_length() * include/Utils.h, src/Utils.cc, src/Dialog_Partition_Info.cc, src/Operation.cc, src/TreeView_Detail.cc, src/VBox_VisualDisk.cc, src/Win_GParted.cc: from now on values >=1024MB are displayed in GB's (#319840)
This commit is contained in:
parent
06925f41a8
commit
2a972b06b8
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2006-01-04 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* include/Partition.h,
|
||||
src/Partition.cc: added get_length()
|
||||
* include/Utils.h,
|
||||
src/Utils.cc,
|
||||
src/Dialog_Partition_Info.cc,
|
||||
src/Operation.cc,
|
||||
src/TreeView_Detail.cc,
|
||||
src/VBox_VisualDisk.cc,
|
||||
src/Win_GParted.cc: from now on values >=1024MB are displayed in
|
||||
GB's (#319840)
|
||||
|
||||
2006-01-03 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* src/Win_GParted.cc: replaced 'can not' with 'cannot' (#325570)
|
||||
|
|
|
@ -25,11 +25,6 @@
|
|||
|
||||
#include "../include/Utils.h"
|
||||
|
||||
#include <gdkmm/colormap.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
|
||||
namespace GParted
|
||||
{
|
||||
|
||||
|
@ -77,6 +72,7 @@ public:
|
|||
long Get_Length_MB() const ;
|
||||
long Get_Used_MB() const ;
|
||||
long Get_Unused_MB() const ;
|
||||
Sector get_length() const ;
|
||||
|
||||
bool operator==( const Partition & partition ) const ;
|
||||
|
||||
|
|
|
@ -114,6 +114,7 @@ public:
|
|||
unsigned long flags = 0,
|
||||
const Glib::ustring & data = "" ) ;
|
||||
static bool unmount( const Glib::ustring & node, const Glib::ustring & mountpoint, Glib::ustring & error ) ;
|
||||
static Glib::ustring format_size( Sector size ) ;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -134,21 +134,22 @@ void Dialog_Partition_Info::Display_Info( )
|
|||
|
||||
//size
|
||||
table ->attach( * Utils::mk_label( "<b>" + (Glib::ustring) _( "Size:" ) + "</b>" ), 0,1,top, bottom,Gtk::FILL);
|
||||
table ->attach( * Utils::mk_label( String::ucompose( _("%1 MB"), this ->partition .Get_Length_MB( ) ) ), 1, 2, top++, bottom++,Gtk::FILL );
|
||||
table ->attach( * Utils::mk_label( Utils::format_size( this ->partition .get_length() ) ), 1, 2, top++, bottom++,Gtk::FILL );
|
||||
|
||||
if ( partition.sectors_used != -1 )
|
||||
{
|
||||
//calculate relative diskusage
|
||||
int percent_used = Utils::Round( static_cast<double>(partition .Get_Used_MB( ) ) / partition .Get_Length_MB( ) *100 ) ;
|
||||
int percent_used =
|
||||
Utils::Round( static_cast<double>(partition .Get_Used_MB() ) / partition .Get_Length_MB() *100 ) ;
|
||||
|
||||
//used
|
||||
table ->attach( * Utils::mk_label( "<b>" + (Glib::ustring) _( "Used:" ) + "</b>" ), 0,1, top, bottom,Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( String::ucompose( _("%1 MB"), this ->partition .Get_Used_MB( ) ) ), 1, 2, top, bottom, Gtk::FILL ) ;
|
||||
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 ) ;
|
||||
|
||||
//unused
|
||||
table ->attach( * Utils::mk_label( "<b>" + (Glib::ustring) _( "Unused:" ) + "</b>" ), 0,1, top, bottom,Gtk::FILL);
|
||||
table ->attach( * Utils::mk_label( String::ucompose( _("%1 MB"), this ->partition .Get_Unused_MB( ) ) ), 1, 2, 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 ) ;
|
||||
}
|
||||
|
||||
|
|
|
@ -135,11 +135,14 @@ void Operation::Apply_Operation_To_Visual( std::vector<Partition> & partitions )
|
|||
{
|
||||
switch ( operationtype )
|
||||
{
|
||||
case DELETE : Apply_Delete_To_Visual( partitions ) ; break ;
|
||||
case RESIZE_MOVE: Apply_Resize_Move_To_Visual( partitions ); break ;
|
||||
case DELETE : Apply_Delete_To_Visual( partitions ) ;
|
||||
break ;
|
||||
case RESIZE_MOVE: Apply_Resize_Move_To_Visual( partitions ) ;
|
||||
break ;
|
||||
case CREATE :
|
||||
case FORMAT :
|
||||
case COPY : Apply_Create_To_Visual( partitions ); break ;
|
||||
case COPY : Apply_Create_To_Visual( partitions ) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,17 +54,18 @@ void Partition::Set( const Glib::ustring & device_path,
|
|||
this ->filesystem = filesystem;
|
||||
this ->sector_start = sector_start;
|
||||
this ->sector_end = sector_end;
|
||||
this ->color.set( Utils::Get_Color( filesystem ) );
|
||||
this ->inside_extended = inside_extended;
|
||||
this ->busy = busy;
|
||||
|
||||
this ->color.set( Utils::Get_Color( filesystem ) );
|
||||
}
|
||||
|
||||
void Partition::Set_Unused( Sector sectors_unused )
|
||||
{
|
||||
if ( sectors_unused < ( sector_end - sector_start ) )
|
||||
if ( sectors_unused < get_length() )
|
||||
{
|
||||
this ->sectors_unused = sectors_unused ;
|
||||
this ->sectors_used = ( sectors_unused == -1 ) ? -1 : ( sector_end - sector_start) - sectors_unused ;
|
||||
this ->sectors_used = ( sectors_unused == -1 ) ? -1 : get_length() - sectors_unused ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,6 +106,11 @@ long Partition::Get_Unused_MB() const
|
|||
return Get_Length_MB() - Get_Used_MB( ) ;
|
||||
}
|
||||
|
||||
Sector Partition::get_length() const
|
||||
{
|
||||
return sector_end - sector_start + 1 ;
|
||||
}
|
||||
|
||||
bool Partition::operator==( const Partition & partition ) const
|
||||
{
|
||||
return this ->partition_number == partition .partition_number &&
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "../include/TreeView_Detail.h"
|
||||
#include "../include/TreeView_Detail.h"
|
||||
|
||||
namespace GParted
|
||||
{
|
||||
|
@ -33,9 +33,9 @@ TreeView_Detail::TreeView_Detail( )
|
|||
//append columns
|
||||
append_column( _("Partition"), treeview_detail_columns .partition );
|
||||
append_column( _("Filesystem"), treeview_detail_columns .color );
|
||||
append_column( _("Size(MB)"), treeview_detail_columns .size );
|
||||
append_column( _("Used(MB)"), treeview_detail_columns .used );
|
||||
append_column( _("Unused(MB)"), treeview_detail_columns .unused );
|
||||
append_column( _("Size"), treeview_detail_columns .size );
|
||||
append_column( _("Used"), treeview_detail_columns .used );
|
||||
append_column( _("Unused"), treeview_detail_columns .unused );
|
||||
append_column( _("Flags"), treeview_detail_columns .flags );
|
||||
|
||||
//status_icon
|
||||
|
@ -63,6 +63,13 @@ TreeView_Detail::TreeView_Detail( )
|
|||
//set alignment of numeric columns to right
|
||||
for( short t = 2 ; t < 5 ; t++ )
|
||||
get_column_cell_renderer( t ) ->property_xalign() = 1 ;
|
||||
|
||||
//expand columns and centeralign the headertext
|
||||
for( short t = 2 ; t < 6 ; t++ )
|
||||
{
|
||||
get_column( t ) ->set_expand( true ) ;
|
||||
get_column( t ) ->set_alignment( 0.5 ) ;
|
||||
}
|
||||
}
|
||||
|
||||
void TreeView_Detail::load_partitions( const std::vector<Partition> & partitions )
|
||||
|
@ -133,19 +140,22 @@ void TreeView_Detail::create_row( const Gtk::TreeRow & treerow, const Partition
|
|||
treerow[ treeview_detail_columns .partition ] = partition .partition;
|
||||
treerow[ treeview_detail_columns .color ] = Utils::get_color_as_pixbuf( partition .filesystem, 16, 16 ) ;
|
||||
|
||||
treerow[ treeview_detail_columns .text_color ] = partition .type == GParted::TYPE_UNALLOCATED ? "darkgrey" : "black" ;
|
||||
treerow[ treeview_detail_columns .filesystem ] = Utils::Get_Filesystem_String( partition .filesystem ) ;
|
||||
treerow[ treeview_detail_columns .text_color ] =
|
||||
partition .type == GParted::TYPE_UNALLOCATED ? "darkgrey" : "black" ;
|
||||
|
||||
treerow[ treeview_detail_columns .filesystem ] =
|
||||
Utils::Get_Filesystem_String( partition .filesystem ) ;
|
||||
|
||||
//size
|
||||
treerow[ treeview_detail_columns .size ] = Utils::num_to_str( partition .Get_Length_MB() ) ;
|
||||
treerow[ treeview_detail_columns .size ] = Utils::format_size( partition .get_length() ) ;
|
||||
|
||||
//used
|
||||
treerow[ treeview_detail_columns .used ] =
|
||||
partition .sectors_used == -1 ? "---" : Utils::num_to_str( partition .Get_Used_MB() ) ;
|
||||
partition .sectors_used == -1 ? "---" : Utils::format_size( partition .sectors_used ) ;
|
||||
|
||||
//unused
|
||||
treerow[ treeview_detail_columns .unused ] =
|
||||
partition .sectors_unused == -1 ? "---" : Utils::num_to_str( partition .Get_Unused_MB() ) ;
|
||||
partition .sectors_unused == -1 ? "---" : Utils::format_size( partition .sectors_unused ) ;
|
||||
|
||||
//flags
|
||||
treerow[ treeview_detail_columns .flags ] = " " + partition .flags ;
|
||||
|
|
20
src/Utils.cc
20
src/Utils.cc
|
@ -20,6 +20,7 @@
|
|||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <cerrno>
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
namespace GParted
|
||||
|
@ -238,4 +239,23 @@ bool Utils::unmount( const Glib::ustring & node, const Glib::ustring & mountpoin
|
|||
return false ;
|
||||
}
|
||||
|
||||
Glib::ustring Utils::format_size( Sector size )
|
||||
{
|
||||
size *= 512 ;
|
||||
std::stringstream ss ;
|
||||
ss .imbue( std::locale( "" ) ) ;
|
||||
ss << std::setiosflags( std::ios::fixed ) << std::setprecision( 2 ) ;
|
||||
|
||||
if ( size < 1073741824 )
|
||||
{
|
||||
ss << static_cast<double>( size / 1048567.0 ) ;
|
||||
return String::ucompose( _("%1 MB"), ss .str() ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
ss << static_cast<double>( size / 1073741824.0 ) ;
|
||||
return String::ucompose( _("%1 GB"), ss .str() ) ;
|
||||
}
|
||||
}
|
||||
|
||||
} //GParted..
|
||||
|
|
|
@ -125,7 +125,7 @@ void VBox_VisualDisk::set_static_data( const std::vector<Partition> & partitions
|
|||
partitions[ t ] .sector_end - partitions[ t ] .sector_start ) ;
|
||||
else
|
||||
visual_partitions .back() .pango_layout = drawingarea .create_pango_layout(
|
||||
partitions[ t ] .partition + "\n" + String::ucompose( _("%1 MB"), partitions[ t ] .Get_Length_MB() ) ) ;
|
||||
partitions[ t ] .partition + "\n" + Utils::format_size( partitions[ t ] .get_length() ) ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -414,8 +414,7 @@ void Win_GParted::refresh_combo_devices()
|
|||
treerow[ treeview_devices_columns .icon ] =
|
||||
render_icon( Gtk::Stock::HARDDISK, Gtk::ICON_SIZE_LARGE_TOOLBAR ) ;
|
||||
treerow[ treeview_devices_columns .device ] = devices[ i ] .path ;
|
||||
treerow[ treeview_devices_columns .size ] =
|
||||
"(" + String::ucompose( _("%1 MB"), Utils::Sector_To_MB( devices[ i ] .length ) ) + ")" ;
|
||||
treerow[ treeview_devices_columns .size ] = "(" + Utils::format_size( devices[ i ] .length ) + ")" ;
|
||||
}
|
||||
|
||||
combo_devices .set_active( current_device ) ;
|
||||
|
@ -471,7 +470,7 @@ void Win_GParted::Fill_Label_Device_Info( bool clear )
|
|||
|
||||
//global info...
|
||||
device_info[ t++ ] ->set_text( devices[ current_device ] .model ) ;
|
||||
device_info[ t++ ] ->set_text( String::ucompose( _("%1 MB"), Utils::Sector_To_MB( devices[ current_device ] .length ) ) ) ;
|
||||
device_info[ t++ ] ->set_text( Utils::format_size( devices[ current_device ] .length ) ) ;
|
||||
device_info[ t++ ] ->set_text( devices[ current_device ] .path ) ;
|
||||
device_info[ t++ ] ->set_text( devices[ current_device ] .realpath ) ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue