From 8ae5ebb2e6d91e2671851e25659e19a90925d65c Mon Sep 17 00:00:00 2001 From: Bart Hakvoort Date: Wed, 29 Sep 2004 12:33:40 +0000 Subject: [PATCH] several (mostly) i18n related fixes/cleanups --- ChangeLog | 10 ++++ include/Dialog_Partition_Info.h | 1 - include/Partition.h | 20 ++++++- include/Win_GParted.h | 3 +- src/Dialog_Partition_Info.cc | 8 --- src/Win_GParted.cc | 98 ++++++++++++++++++++++----------- 6 files changed, 96 insertions(+), 44 deletions(-) diff --git a/ChangeLog b/ChangeLog index b502214f..63754819 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2004-09-29 Bart Hakvoort + + * include/Dialog_Partition_Info.h, + src/Dialog_Partition_Info: removed Gtk::Label * mk_label( const Glib::ustring & text ) + * include/Partition.h: added inline Gtk::Label * mk_label( const Glib::ustring & text ) + and inline Glib::ustring num_to_str( Sector number ) + * include/Win_GParted.h, + src/Win_GParted.cc: fixed aligment problems with some languages in harddisk-info + + 2004-09-29 Bart Hakvoort * src/VBox_VisualDisk.cc, diff --git a/include/Dialog_Partition_Info.h b/include/Dialog_Partition_Info.h index 62da510d..a01fd325 100644 --- a/include/Dialog_Partition_Info.h +++ b/include/Dialog_Partition_Info.h @@ -48,7 +48,6 @@ private: void init_drawingarea() ; void Display_Info(); void Find_Status() ; - Gtk::Label * mk_label( const Glib::ustring & text ) ; //signalhandlers void drawingarea_on_realize( ); diff --git a/include/Partition.h b/include/Partition.h index 65b1d57e..56e7c0c1 100644 --- a/include/Partition.h +++ b/include/Partition.h @@ -24,6 +24,7 @@ #include "../include/i18n.h" +#include #include #include @@ -37,9 +38,9 @@ namespace GParted { - typedef long long Sector;//one day this won't be sufficient, oh how i dream of that day... :-P +//------------global used convenience functions---------------------------- inline long Sector_To_MB( Sector sectors ) { return (long) ( (double) sectors * 512/1024/1024 +0.5) ; @@ -54,6 +55,23 @@ inline Sector Abs( Sector sectors ) { return sectors < 0 ? sectors - 2*sectors : sectors ; } + +inline Gtk::Label * mk_label( const Glib::ustring & text ) +{ + Gtk::Label * label = manage( new Gtk::Label() ) ; + label ->set_markup( text ) ; + label ->set_alignment( Gtk::ALIGN_LEFT ) ; + return label ; +} + +inline Glib::ustring num_to_str( Sector number ) +{ + std::ostringstream os; + os .imbue(std::locale("")); + os << number ; + return os .str() ; +} +//---------------------------------------------------------------------------------------------- enum PartitionType { diff --git a/include/Win_GParted.h b/include/Win_GParted.h index 6ad2d8d1..c7e3bdc6 100644 --- a/include/Win_GParted.h +++ b/include/Win_GParted.h @@ -158,7 +158,7 @@ private: //usefull variables which are used by many different functions... - sigc::connection s2,s3;//usefull for disconnecting and destroying a connection ( see optionmenu_devices_changed() and activate_apply() ) + sigc::connection s2,s3;//used for disconnecting and destroying a connection ( see optionmenu_devices_changed() and activate_apply() ) std::ostringstream os;//for int to string conversions bool any_logic,any_extended;//used in some checks (e.g. see optionmenu_devices_changed() unsigned short highest_logic_busy,primary_count, new_count;//primary_count checks for max. of 4 pimary partitions, @@ -167,6 +167,7 @@ private: GParted::Device *temp_device; std::vector str_devices, filesystems; + std::vector device_info; //stuff for progress overview Dialog_Progress *dialog_progress; diff --git a/src/Dialog_Partition_Info.cc b/src/Dialog_Partition_Info.cc index 10885008..ae76dc0e 100644 --- a/src/Dialog_Partition_Info.cc +++ b/src/Dialog_Partition_Info.cc @@ -270,14 +270,6 @@ void Dialog_Partition_Info::Find_Status() os << String::ucompose( _("Mounted on %1"), "/") ; } -Gtk::Label * Dialog_Partition_Info::mk_label( const Glib::ustring & text ) -{ - label = manage( new Gtk::Label() ) ; - label ->set_markup( text ) ; - label ->set_alignment( Gtk::ALIGN_LEFT ) ; - return label ; -} - Dialog_Partition_Info::~Dialog_Partition_Info() { this ->get_colormap() ->free_colors( color_used, 1 ) ; diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc index ec048796..8afb896b 100644 --- a/src/Win_GParted.cc +++ b/src/Win_GParted.cc @@ -210,6 +210,7 @@ void Win_GParted::init_convert_menu() void Win_GParted::init_device_info() { vbox_info.set_spacing( 5 ); + int top =0, bottom = 1; //title label = manage( new Gtk::Label() ) ; @@ -217,35 +218,68 @@ void Win_GParted::init_device_info() label ->set_markup( " " + (Glib::ustring) _( "Harddisk Information" ) + ":" ) ; vbox_info .pack_start( *label, Gtk::PACK_SHRINK ); - //global device info + //GENERAL DEVICE INFO table = manage( new Gtk::Table() ) ; - table ->set_col_spacings(10 ) ; - label = manage( new Gtk::Label() ) ; - os << " " << _("Model:") << "\n " << _("Size:") << "\n " << _("Path:") << "\n " ; + table ->set_col_spacings( 10 ) ; - //only show realpath if it's different from the short path...(hereby i assume if one device has a realpath, they all have. i guess this makes sense) + //model + table ->attach( * mk_label( " " + (Glib::ustring) _( "Model:" ) + "" ) , 0,1,top, bottom ,Gtk::FILL); + device_info .push_back( mk_label( "" ) ) ; + table ->attach( * device_info .back(), 1,2, top++, bottom++, Gtk::FILL); + + //size + table ->attach( * mk_label( " " + (Glib::ustring) _( "Size:" ) + "" ) , 0,1,top, bottom ,Gtk::FILL); + device_info .push_back( mk_label( "" ) ) ; + table ->attach( * device_info .back(), 1,2, top++, bottom++, Gtk::FILL); + + //path + table ->attach( * mk_label( " " + (Glib::ustring) _( "Path:" ) + "" ) , 0,1,top, bottom ,Gtk::FILL); + device_info .push_back( mk_label( "" ) ) ; + table ->attach( * device_info .back(), 1,2, top++, bottom++, Gtk::FILL); + + //only show realpath if it's different from the short path if ( devices[ current_device ] ->Get_Path() != devices[ current_device ] ->Get_RealPath() ) - os << _("Real Path:") << "\n " ; + { + table ->attach( * mk_label( " " + (Glib::ustring) _( "Real Path:" ) + "" ) , 0,1,top, bottom ,Gtk::FILL); + device_info .push_back( mk_label( "" ) ) ; + table ->attach( * device_info .back(), 1,2, top++, bottom++, Gtk::FILL); + } - os << "" ; - label ->set_markup( os.str() ) ; os.str("") ; - table ->attach( *label, 0,1,0,1,Gtk::SHRINK); - - label_device_info1 .set_selectable( true ) ; - table ->attach( label_device_info1, 1,2,0,1,Gtk::SHRINK); vbox_info .pack_start( *table, Gtk::PACK_SHRINK ); - //detailed device info + //DETAILED DEVICE INFO + top =0; bottom = 1; table = manage( new Gtk::Table() ) ; table ->set_col_spacings(10 ) ; - label = manage( new Gtk::Label() ) ; - os << " " << _("DiskType:") << "\n " << _("Heads:") << "\n " << _("Sectors/Track:") << "\n " << _("Cylinders:") << "\n "<< _("Total Sectors:") ; - os << "" ; - label ->set_markup( os.str() ) ; os.str("") ; - table ->attach( *label, 0,1,0,1,Gtk::SHRINK); - label_device_info2 .set_selectable( true ) ; - table ->attach( label_device_info2, 1,2,0,1,Gtk::SHRINK); + //one blank line + table ->attach( * mk_label( "" ), 1,2, top++, bottom++,Gtk::FILL); + + //disktype + table ->attach( * mk_label( " " + (Glib::ustring) _( "DiskType:" ) + "" ) , 0,1,top, bottom ,Gtk::FILL); + device_info .push_back( mk_label( "" ) ) ; + table ->attach( * device_info .back(), 1,2, top++, bottom++, Gtk::FILL); + + //heads + table ->attach( * mk_label( " " + (Glib::ustring) _( "Heads:" ) + "" ) , 0,1,top, bottom ,Gtk::FILL); + device_info .push_back( mk_label( "" ) ) ; + table ->attach( * device_info .back(), 1,2, top++, bottom++, Gtk::FILL); + + //sectors/track + table ->attach( * mk_label( " " + (Glib::ustring) _( "Sectors/Track:" ) + "" ) , 0,1,top, bottom ,Gtk::FILL); + device_info .push_back( mk_label( "" ) ) ; + table ->attach( * device_info .back(), 1,2, top++, bottom++, Gtk::FILL); + + //cylinders + table ->attach( * mk_label( " " + (Glib::ustring) _( "Cylinders:" ) + "" ) , 0,1,top, bottom ,Gtk::FILL); + device_info .push_back( mk_label( "" ) ) ; + table ->attach( * device_info .back(), 1,2, top++, bottom++, Gtk::FILL); + + //total sectors + table ->attach( * mk_label( " " + (Glib::ustring) _( "Total Sectors:" ) + "" ) , 0,1,top, bottom ,Gtk::FILL); + device_info .push_back( mk_label( "" ) ) ; + table ->attach( * device_info .back(), 1,2, top++, bottom++, Gtk::FILL); + vbox_info .pack_start( *table, Gtk::PACK_SHRINK ); } @@ -365,25 +399,23 @@ void Win_GParted::Find_Devices() void Win_GParted::Fill_Label_Device_Info( ) { + short t=0; + //global info... - os << devices[ current_device ] ->Get_Model() << "\n" ; - os << Sector_To_MB( devices[ current_device ] ->Get_Length() ) << " MB\n" ; - os << devices[ current_device ] ->Get_Path() << "\n" ; + device_info[ t++ ] ->set_text( devices[ current_device ] ->Get_Model() ) ; + device_info[ t++ ] ->set_text( String::ucompose( _("%1 MB"), Sector_To_MB( devices[ current_device ] ->Get_Length() ) ) ) ; + device_info[ t++ ] ->set_text( devices[ current_device ] ->Get_Path() ) ; //only show realpath if it's diffent from the short path... if ( devices[ current_device ] ->Get_Path() != devices[ current_device ] ->Get_RealPath() ) - os << devices[ current_device ] ->Get_RealPath() << "\n" ; - - label_device_info1.set_text( os.str() ) ; os.str("") ; + device_info[ t++ ] ->set_text( devices[ current_device ] ->Get_RealPath() ) ; //detailed info - os << devices[ current_device ] ->Get_DiskType() << "\n" ; - os << devices[ current_device ] ->Get_Heads() << "\n" ; - os << devices[ current_device ] ->Get_Sectors() << "\n" ; - os << devices[ current_device ] ->Get_Cylinders() << "\n" ; - os << devices[ current_device ] ->Get_Length() ; - - label_device_info2.set_text( os.str() ) ; os.str("") ; + device_info[ t++ ] ->set_text( devices[ current_device ] ->Get_DiskType() ) ; + device_info[ t++ ] ->set_text( num_to_str( devices[ current_device ] ->Get_Heads() ) ); + device_info[ t++ ] ->set_text( num_to_str( devices[ current_device ] ->Get_Sectors() ) ); + device_info[ t++ ] ->set_text( num_to_str( devices[ current_device ] ->Get_Cylinders() ) ); + device_info[ t++ ] ->set_text( num_to_str( devices[ current_device ] ->Get_Length() ) ); } bool Win_GParted::on_delete_event(GdkEventAny *event)