diff --git a/ChangeLog b/ChangeLog index b0bbbb46..d3d88d8f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-03-15 Bart Hakvoort + + * src/Dialog_Partition_Info.cc, + src/DrawingAreaVisualDisk.cc: cleanups + 2006-03-15 Bart Hakvoort * include/Partition.h, diff --git a/src/Dialog_Partition_Info.cc b/src/Dialog_Partition_Info.cc index d13cfc25..d0327d1e 100644 --- a/src/Dialog_Partition_Info.cc +++ b/src/Dialog_Partition_Info.cc @@ -28,24 +28,25 @@ Dialog_Partition_Info::Dialog_Partition_Info( const Partition & partition ) this ->set_has_separator( false ) ; /*TO TRANSLATORS: dialogtitle, looks like Information about /dev/hda3 */ - this ->set_title( String::ucompose( _( "Information about %1"), partition .get_path() ) ); + this ->set_title( String::ucompose( _("Information about %1"), partition .get_path() ) ); - init_drawingarea( ) ; + init_drawingarea() ; //add label for detail and fill with relevant info - Display_Info( ) ; + Display_Info() ; //display error (if any) if ( partition .error != "" ) { - frame = manage( new Gtk::Frame( ) ); + frame = manage( new Gtk::Frame() ); frame ->set_border_width( 10 ); image = manage( new Gtk::Image( Gtk::Stock::DIALOG_WARNING, Gtk::ICON_SIZE_BUTTON ) ); - hbox = manage( new Gtk::HBox( ) ); + hbox = manage( new Gtk::HBox() ); hbox ->pack_start( *image, Gtk::PACK_SHRINK ) ; - hbox ->pack_start( * Utils::mk_label( " " + (Glib::ustring) _( "Warning:" ) + " " ), Gtk::PACK_SHRINK ) ; + hbox ->pack_start( * Utils::mk_label( " " + static_cast(_( "Warning:") ) + " " ), + Gtk::PACK_SHRINK ) ; frame ->set_label_widget( *hbox ) ; frame ->add( * Utils::mk_label( "" + partition.error + "", true, true, true ) ) ; @@ -54,14 +55,14 @@ Dialog_Partition_Info::Dialog_Partition_Info( const Partition & partition ) } this ->add_button( Gtk::Stock::CLOSE, Gtk::RESPONSE_OK ) ; - this ->show_all_children( ) ; + this ->show_all_children() ; } -void Dialog_Partition_Info::drawingarea_on_realize( ) +void Dialog_Partition_Info::drawingarea_on_realize() { - gc = Gdk::GC::create( drawingarea .get_window( ) ) ; + gc = Gdk::GC::create( drawingarea .get_window() ) ; - drawingarea .get_window( ) ->set_background( color_partition ) ; + drawingarea .get_window() ->set_background( color_partition ) ; } bool Dialog_Partition_Info::drawingarea_on_expose( GdkEventExpose *ev ) @@ -84,26 +85,27 @@ bool Dialog_Partition_Info::drawingarea_on_expose( GdkEventExpose *ev ) return true; } -void Dialog_Partition_Info::init_drawingarea( ) +void Dialog_Partition_Info::init_drawingarea() { drawingarea .set_size_request( 400, 60 ) ; - drawingarea .signal_realize( ).connect( sigc::mem_fun(*this, &Dialog_Partition_Info::drawingarea_on_realize) ) ; - drawingarea .signal_expose_event( ).connect( sigc::mem_fun(*this, &Dialog_Partition_Info::drawingarea_on_expose) ) ; + drawingarea .signal_realize().connect( sigc::mem_fun(*this, &Dialog_Partition_Info::drawingarea_on_realize) ) ; + drawingarea .signal_expose_event().connect( sigc::mem_fun(*this, &Dialog_Partition_Info::drawingarea_on_expose) ) ; - frame = manage( new Gtk::Frame( ) ) ; + frame = manage( new Gtk::Frame() ) ; frame ->add( drawingarea ) ; frame ->set_shadow_type( Gtk::SHADOW_ETCHED_OUT ) ; frame ->set_border_width( 10 ) ; - hbox = manage( new Gtk::HBox( ) ) ; + hbox = manage( new Gtk::HBox() ) ; hbox ->pack_start( *frame, Gtk::PACK_EXPAND_PADDING ) ; - this ->get_vbox( ) ->pack_start( *hbox, Gtk::PACK_SHRINK ) ; + this ->get_vbox() ->pack_start( *hbox, Gtk::PACK_SHRINK ) ; //calculate proportional width of used and unused used = unused = 0 ; - //FIXME: use Partition::get_length().. - used = Utils::Round( (400 - BORDER *2) / ( static_cast(partition .sector_end - partition .sector_start) / partition .sectors_used ) ) ; + used = Utils::Round( + (400 - BORDER *2) / ( static_cast( partition .get_length() ) / partition .sectors_used ) ) ; + unused = 400 - used - BORDER *2 ; //allocate some colors @@ -124,22 +126,34 @@ void Dialog_Partition_Info::init_drawingarea( ) partition .get_path() + "\n" + Utils::format_size( partition .get_length() ) ) ; } -void Dialog_Partition_Info::Display_Info( ) +void Dialog_Partition_Info::Display_Info() { - int top =0, bottom = 1; + int top = 0, bottom = 1 ; - table = manage( new Gtk::Table( ) ) ; + table = manage( new Gtk::Table() ) ; table ->set_border_width( 5 ) ; table ->set_col_spacings(10 ) ; - this ->get_vbox( ) ->pack_start( *table, Gtk::PACK_SHRINK ) ; + this ->get_vbox() ->pack_start( *table, Gtk::PACK_SHRINK ) ; //filesystem - table ->attach( * Utils::mk_label( "" + (Glib::ustring) _( "Filesystem:" ) + "" ) , 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( "" + static_cast( _("Filesystem:") ) + "" ), + 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( "" + (Glib::ustring) _( "Size:" ) + "" ), 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( "" + static_cast( _("Size:") ) + "" ), + 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( partition .get_length() ) * 100 ) ; //used - table ->attach( * Utils::mk_label( "" + (Glib::ustring) _( "Used:" ) + "" ), 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( "" + static_cast( _("Used:") ) + "" ), + 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( "" + (Glib::ustring) _( "Unused:" ) + "" ), 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( "" + static_cast( _("Unused:") ) + "" ), + 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( "" + (Glib::ustring) _( "Flags:" ) + "" ), 0, 1, top, bottom, Gtk::FILL ) ; + table ->attach( * Utils::mk_label( "" + static_cast( _("Flags:") ) + "" ), + 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( "" + (Glib::ustring) _( "Path:" ) + "" ), + table ->attach( * Utils::mk_label( "" + static_cast( _("Path:") ) + "" ), 0, 1, top, bottom, Gtk::FILL ) ; @@ -185,14 +220,14 @@ void Dialog_Partition_Info::Display_Info( ) //status Glib::ustring str_temp ; - table ->attach( * Utils::mk_label( "" + (Glib::ustring) _( "Status:" ) + "" ), + table ->attach( * Utils::mk_label( "" + static_cast( _("Status:") ) + "" ), 0, 1, top, bottom, - Gtk::FILL) ; + Gtk::FILL ) ; if ( partition .busy ) { if ( partition .type == GParted::TYPE_EXTENDED ) - str_temp = _("Busy (At least one logical partition is mounted)" ) ; + str_temp = _("Busy (At least one logical partition is mounted)") ; else if ( partition .filesystem == FS_LINUX_SWAP ) str_temp = _("Active") ; else if ( partition .get_mountpoints() .size() ) @@ -200,11 +235,11 @@ void Dialog_Partition_Info::Display_Info( ) Glib::build_path( ", ", partition .get_mountpoints() ) ) ; } else if ( partition.type == GParted::TYPE_EXTENDED ) - str_temp = _("Not busy (There are no mounted logical partitions)" ) ; + str_temp = _("Not busy (There are no mounted logical partitions)") ; else if ( partition.filesystem == GParted::FS_LINUX_SWAP ) - str_temp = _("Not active" ) ; + str_temp = _("Not active") ; else - str_temp = _("Not mounted" ) ; + str_temp = _("Not mounted") ; table ->attach( * Utils::mk_label( str_temp ), 1, 2, 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( "" + (Glib::ustring) _( "First Sector:" ) + "" ), 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( "" + static_cast( _("First Sector:") ) + "" ), + 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( "" + (Glib::ustring) _( "Last Sector:" ) + "" ), 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( "" + static_cast( _("Last Sector:") ) + "" ), + 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( "" + (Glib::ustring) _( "Total Sectors:" ) + "" ), 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( "" + static_cast( _("Total Sectors:") ) + "" ), + 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() diff --git a/src/DrawingAreaVisualDisk.cc b/src/DrawingAreaVisualDisk.cc index 6525da22..743e340d 100644 --- a/src/DrawingAreaVisualDisk.cc +++ b/src/DrawingAreaVisualDisk.cc @@ -82,25 +82,18 @@ void DrawingAreaVisualDisk::set_static_data( const std::vector & part std::vector & 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( length ) ; + visual_partitions .back() .fraction = partitions[ t ] .get_length() / static_cast( 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( p_length ) ; + partitions[ t ] .sectors_used / static_cast( partitions[ t ] .get_length() ) ; visual_partitions .back() .color = partitions[ t ] .color; this ->get_colormap() ->alloc_color( visual_partitions .back() .color ); @@ -111,7 +104,7 @@ void DrawingAreaVisualDisk::set_static_data( const std::vector & part partitions[ t ] .sector_end - partitions[ t ] .sector_start ) ; else visual_partitions .back() .pango_layout = create_pango_layout( - partitions[ t ] .get_path() + "\n" + Utils::format_size( partitions[ t ] .get_length() ) ) ; + partitions[ t ] .get_path() + "\n" + Utils::format_size( partitions[ t ] .get_length() ) ) ; } }