removed all stringstreams from the project (they were possibly responsible

* removed all stringstreams from the project (they were possibly responsible for rare chrashes in certain locales)
This commit is contained in:
Bart Hakvoort 2004-10-02 09:39:16 +00:00
parent d0b49ea63b
commit 72f91cbc39
17 changed files with 216 additions and 203 deletions

View File

@ -1,3 +1,8 @@
2004-10-0i2 Bart Hakvoort <gparted@users.sf.net>
* removed all stringstreams from the project (they were possibly responsible for rare chrashes in certain locales)
Note that i left 1 in include/Partition.h, this one is needed for int-->string conversions and won't pose a thread.
2004-10-01 Bart Hakvoort <gparted@users.sf.net> 2004-10-01 Bart Hakvoort <gparted@users.sf.net>
* almost all files: cosmetics (mostly tabfixes) * almost all files: cosmetics (mostly tabfixes)

View File

@ -101,7 +101,6 @@ private:
std::vector <PedPartitionFlag> flags; std::vector <PedPartitionFlag> flags;
Glib::ustring temp, error ; //error may contain an errormessage for an specific partition ( see Get_Used_Sectors() ) Glib::ustring temp, error ; //error may contain an errormessage for an specific partition ( see Get_Used_Sectors() )
std::ostringstream os;
Partition partition_temp ; Partition partition_temp ;
}; };

View File

@ -36,7 +36,7 @@ class Dialog_Base_Partition : public Gtk::Dialog
{ {
public: public:
Dialog_Base_Partition( ) ; Dialog_Base_Partition( ) ;
~Dialog_Base_Partition() ; ~Dialog_Base_Partition() ;
void Set_Resizer( bool extended ) ; void Set_Resizer( bool extended ) ;
@ -63,22 +63,21 @@ protected:
Partition selected_partition ; Partition selected_partition ;
Sector START; //the first sector of the first relevant partition ( this is either current or current -1 ) needed in Get_Resized_Partition() Sector START; //the first sector of the first relevant partition ( this is either current or current -1 ) needed in Get_Resized_Partition()
Sector total_length ; //total amount of sectors ( this can be up to 3 partitions... Sector total_length ; //total amount of sectors ( this can be up to 3 partitions...)
Gtk::HBox hbox_main; Gtk::HBox hbox_main ;
Gtk::Label label_minmax ; Gtk::Label label_minmax ;
Gtk::SpinButton spinbutton_before, spinbutton_size, spinbutton_after; Gtk::SpinButton spinbutton_before, spinbutton_size, spinbutton_after;
//used to enable/disable OKbutton... //used to enable/disable OKbutton...
int ORIG_BEFORE,ORIG_SIZE, ORIG_AFTER ; int ORIG_BEFORE, ORIG_SIZE, ORIG_AFTER ;
//signal handlers //signal handlers
void on_signal_move( int, int ); void on_signal_move( int, int );
void on_signal_resize( int, int, Frame_Resizer_Base::ArrowType ); void on_signal_resize( int, int, Frame_Resizer_Base::ArrowType );
void on_spinbutton_value_changed( SPINBUTTON ) ; void on_spinbutton_value_changed( SPINBUTTON ) ;
bool fixed_start, GRIP; bool fixed_start, GRIP;
std::ostringstream os;
double before_value ; double before_value ;
int x_start, x_end ; int x_start, x_end ;
@ -92,7 +91,6 @@ private:
Gtk::Tooltips tooltips; Gtk::Tooltips tooltips;
Gtk::Button button_resize_move ; Gtk::Button button_resize_move ;
Gtk::Image *image_temp ; Gtk::Image *image_temp ;
}; };
} //GParted } //GParted

View File

@ -47,7 +47,7 @@ public:
private: private:
void init_drawingarea() ; void init_drawingarea() ;
void Display_Info(); void Display_Info();
void Find_Status() ; Glib::ustring Find_Status() ;
//signalhandlers //signalhandlers
void drawingarea_on_realize( ); void drawingarea_on_realize( );
@ -68,7 +68,6 @@ private:
Gdk::Color color_partition, color_used, color_unused, color_text ; Gdk::Color color_partition, color_used, color_unused, color_text ;
int used,unused ; int used,unused ;
std::ostringstream os, os_percent;
}; };

View File

@ -48,7 +48,6 @@ private:
Gtk::ProgressBar progressbar_all, progressbar_current ; Gtk::ProgressBar progressbar_all, progressbar_current ;
double fraction; double fraction;
std::ostringstream os;
int count_operations, current_operation_number; int count_operations, current_operation_number;
char c_buf[ 1024 ] ; //used by sprintf, which is needed for i18n char c_buf[ 1024 ] ; //used by sprintf, which is needed for i18n
}; };

View File

@ -90,7 +90,7 @@ private:
Gdk::Color color_used, color_unused, color_text; Gdk::Color color_used, color_unused, color_text;
std::ostringstream os;//for int to string conversions Glib::ustring str_temp ;
int temp,selected_partition; int temp,selected_partition;
Gtk::Entry *entry_temp; Gtk::Entry *entry_temp;
Gtk::Label *label_temp; Gtk::Label *label_temp;

View File

@ -150,20 +150,21 @@ private:
{ {
Gtk::TreeModelColumn<int> operation_number; Gtk::TreeModelColumn<int> operation_number;
Gtk::TreeModelColumn<Glib::ustring> operation_description; Gtk::TreeModelColumn<Glib::ustring> operation_description;
Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > operation_icon; Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > operation_icon;
treeview_operations_Columns() { add( operation_number ); add( operation_description );add(operation_icon);} treeview_operations_Columns() { add( operation_number ); add( operation_description ); add(operation_icon);}
}; };
treeview_operations_Columns treeview_operations_columns; treeview_operations_Columns treeview_operations_columns;
//usefull variables which are used by many different functions... //usefull variables which are used by many different functions...
sigc::connection s2,s3;//used 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() 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, unsigned short highest_logic_busy ;//highest_logic_busy contains the number of the highest logical which is busy ( 0 if none is busy)
//new_count keeps track of the new created partitions, unsigned short primary_count ;//primary_count checks for max. of 4 pimary partitions
//highest_logic_busy contains the number of the highest logical which is busy ( 0 if none is busy) unsigned short new_count;//new_count keeps track of the new created partitions
Glib::ustring str_temp ; //mostly used for constructing dialogmessages
GParted::Device *temp_device; GParted::Device *temp_device;
std::vector <Glib::ustring> str_devices, filesystems; std::vector <Glib::ustring> str_devices, filesystems;

View File

@ -143,13 +143,15 @@ Device::Device( const Glib::ustring & device_path )
void Device::Read_Disk_Layout() void Device::Read_Disk_Layout()
{ {
Glib::ustring part_path ;
//clear partitions //clear partitions
this ->device_partitions .clear () ; this ->device_partitions .clear () ;
c_partition = ped_disk_next_partition ( disk, NULL) ; c_partition = ped_disk_next_partition ( disk, NULL) ;
while ( c_partition ) while ( c_partition )
{ {
os << this ->path << c_partition ->num ; part_path = this ->path + num_to_str( c_partition ->num ) ;
switch( c_partition ->type ) switch( c_partition ->type )
{ {
@ -159,7 +161,7 @@ void Device::Read_Disk_Layout()
else else
{temp = "unknown" ; this ->error = (Glib::ustring) _( "Unable to detect filesystem! Possible reasons are:" ) + "\n-" + (Glib::ustring) _( "The filesystem is damaged" ) + "\n-" + (Glib::ustring) _( "The filesystem is unknown to libparted" ) + "\n-" + (Glib::ustring) _( "There is no filesystem available (unformatted)" ) ; } {temp = "unknown" ; this ->error = (Glib::ustring) _( "Unable to detect filesystem! Possible reasons are:" ) + "\n-" + (Glib::ustring) _( "The filesystem is damaged" ) + "\n-" + (Glib::ustring) _( "The filesystem is unknown to libparted" ) + "\n-" + (Glib::ustring) _( "There is no filesystem available (unformatted)" ) ; }
partition_temp.Set( os.str(),c_partition ->num , GParted::PRIMARY, temp, c_partition ->geom .start, c_partition ->geom .end, Get_Used_Sectors( c_partition , os.str() ) , false, ped_partition_is_busy( c_partition ) ); partition_temp.Set( part_path,c_partition ->num , GParted::PRIMARY, temp, c_partition ->geom .start, c_partition ->geom .end, Get_Used_Sectors( c_partition , part_path ) , false, ped_partition_is_busy( c_partition ) );
partition_temp .flags = Get_Flags( c_partition ) ; partition_temp .flags = Get_Flags( c_partition ) ;
partition_temp .error = this ->error ; partition_temp .error = this ->error ;
@ -172,7 +174,7 @@ void Device::Read_Disk_Layout()
else else
{temp = "unknown" ; this ->error = (Glib::ustring) _( "Unable to detect filesystem! Possible reasons are:" ) + "\n-" + (Glib::ustring) _( "The filesystem is damaged" ) + "\n-" + (Glib::ustring) _( "The filesystem is unknown to libparted" ) + "\n-" + (Glib::ustring) _( "There is no filesystem available (unformatted)" ) ; } {temp = "unknown" ; this ->error = (Glib::ustring) _( "Unable to detect filesystem! Possible reasons are:" ) + "\n-" + (Glib::ustring) _( "The filesystem is damaged" ) + "\n-" + (Glib::ustring) _( "The filesystem is unknown to libparted" ) + "\n-" + (Glib::ustring) _( "There is no filesystem available (unformatted)" ) ; }
partition_temp.Set( os.str(), c_partition ->num, GParted::LOGICAL, temp, c_partition ->geom .start, c_partition ->geom .end, Get_Used_Sectors( c_partition , os.str() ) , true, ped_partition_is_busy( c_partition ) ); partition_temp.Set( part_path, c_partition ->num, GParted::LOGICAL, temp, c_partition ->geom .start, c_partition ->geom .end, Get_Used_Sectors( c_partition , part_path ) , true, ped_partition_is_busy( c_partition ) );
partition_temp .flags = Get_Flags( c_partition ) ; partition_temp .flags = Get_Flags( c_partition ) ;
partition_temp .error = this ->error ; partition_temp .error = this ->error ;
@ -180,7 +182,7 @@ void Device::Read_Disk_Layout()
break; break;
//EXTENDED //EXTENDED
case 2: partition_temp.Set( os.str(), c_partition ->num, GParted::EXTENDED, "extended", c_partition ->geom .start, c_partition ->geom .end , -1, false, ped_partition_is_busy( c_partition ) ); case 2: partition_temp.Set( part_path, c_partition ->num, GParted::EXTENDED, "extended", c_partition ->geom .start, c_partition ->geom .end , -1, false, ped_partition_is_busy( c_partition ) );
partition_temp .flags = Get_Flags( c_partition ) ; partition_temp .flags = Get_Flags( c_partition ) ;
partition_temp .error = this ->error ; partition_temp .error = this ->error ;
@ -207,7 +209,7 @@ void Device::Read_Disk_Layout()
} }
//reset stuff.. //reset stuff..
this ->error = ""; error_message = ""; os.str(""); this ->error = error_message = "" ;
//next partition (if any) //next partition (if any)
c_partition = ped_disk_next_partition ( disk, c_partition ) ; c_partition = ped_disk_next_partition ( disk, c_partition ) ;

View File

@ -26,8 +26,8 @@ Dialog_Base_Partition::Dialog_Base_Partition( )
frame_resizer_base = NULL; frame_resizer_base = NULL;
GRIP = false ; GRIP = false ;
this -> fixed_start = false ; this ->fixed_start = false ;
this -> set_resizable( false ); this ->set_resizable( false );
//pack resizer hbox //pack resizer hbox
this ->get_vbox() ->pack_start( hbox_resizer, Gtk::PACK_SHRINK ); this ->get_vbox() ->pack_start( hbox_resizer, Gtk::PACK_SHRINK );
@ -52,29 +52,29 @@ Dialog_Base_Partition::Dialog_Base_Partition( )
//add spinbutton_before //add spinbutton_before
label_temp = manage( new Gtk::Label( (Glib::ustring) _( "Free Space Preceding (MB) :") + " \t" ) ) ; label_temp = manage( new Gtk::Label( (Glib::ustring) _( "Free Space Preceding (MB) :") + " \t" ) ) ;
table_resize.attach( *label_temp, 0,1,0,1,Gtk::SHRINK); table_resize.attach( *label_temp, 0, 1, 0, 1, Gtk::SHRINK);
spinbutton_before .set_numeric( true ); spinbutton_before .set_numeric( true );
spinbutton_before .set_increments( 1, 100 ); spinbutton_before .set_increments( 1, 100 );
table_resize.attach( spinbutton_before, 1,2,0,1,Gtk::FILL); table_resize.attach( spinbutton_before, 1, 2, 0, 1, Gtk::FILL);
//add spinbutton_size //add spinbutton_size
label_temp = manage( new Gtk::Label( _( "New Size (MB) :") ) ) ; label_temp = manage( new Gtk::Label( _( "New Size (MB) :") ) ) ;
label_temp ->set_alignment( Gtk::ALIGN_LEFT ); label_temp ->set_alignment( Gtk::ALIGN_LEFT );
table_resize.attach( *label_temp, 0,1,1,2 ); table_resize.attach( *label_temp, 0, 1, 1, 2 );
spinbutton_size .set_numeric( true ); spinbutton_size .set_numeric( true );
spinbutton_size .set_increments( 1, 100 ); spinbutton_size .set_increments( 1, 100 );
table_resize.attach( spinbutton_size, 1,2,1,2,Gtk::FILL); table_resize.attach( spinbutton_size, 1, 2, 1, 2, Gtk::FILL);
//add spinbutton_after //add spinbutton_after
label_temp = manage( new Gtk::Label( _( "Free Space Following (MB) :") ) ) ; label_temp = manage( new Gtk::Label( _( "Free Space Following (MB) :") ) ) ;
label_temp ->set_alignment( Gtk::ALIGN_LEFT ); label_temp ->set_alignment( Gtk::ALIGN_LEFT );
table_resize.attach( *label_temp, 0,1,2,3 ) ; table_resize.attach( *label_temp, 0, 1, 2, 3 ) ;
spinbutton_after .set_numeric( true ); spinbutton_after .set_numeric( true );
spinbutton_after .set_increments( 1, 100 ); spinbutton_after .set_increments( 1, 100 );
table_resize.attach( spinbutton_after, 1,2,2,3,Gtk::FILL); table_resize.attach( spinbutton_after, 1, 2, 2, 3, Gtk::FILL);
if ( ! fixed_start ) if ( ! fixed_start )
@ -93,7 +93,7 @@ Dialog_Base_Partition::Dialog_Base_Partition( )
label_temp ->set_alignment( Gtk::ALIGN_LEFT ) ; label_temp ->set_alignment( Gtk::ALIGN_LEFT ) ;
this ->get_vbox() ->pack_start( *label_temp, Gtk::PACK_SHRINK ); this ->get_vbox() ->pack_start( *label_temp, Gtk::PACK_SHRINK );
this ->get_vbox() ->pack_start( *( manage( new Gtk::Label( "") ) ), Gtk::PACK_SHRINK ); //filler :-P this ->get_vbox() ->pack_start( *( manage( new Gtk::Label( "") ) ), Gtk::PACK_SHRINK ); //filler :-P
this->add_button( Gtk::Stock::CANCEL,Gtk::RESPONSE_CANCEL ); this->add_button( Gtk::Stock::CANCEL,Gtk::RESPONSE_CANCEL );
this ->show_all_children() ; this ->show_all_children() ;
@ -103,11 +103,11 @@ void Dialog_Base_Partition::Set_Resizer( bool extended )
{ {
if ( extended ) if ( extended )
{ {
frame_resizer_base = new Frame_Resizer_Extended( ) ; frame_resizer_base = new Frame_Resizer_Extended( ) ;
} }
else else
{ {
frame_resizer_base = new Frame_Resizer_Base( ) ; frame_resizer_base = new Frame_Resizer_Base( ) ;
frame_resizer_base ->signal_move .connect ( sigc::mem_fun( this, &Dialog_Base_Partition::on_signal_move) ); frame_resizer_base ->signal_move .connect ( sigc::mem_fun( this, &Dialog_Base_Partition::on_signal_move) );
} }
@ -293,7 +293,7 @@ void Dialog_Base_Partition::on_spinbutton_value_changed( SPINBUTTON spinbutton
if ( ! fixed_start ) if ( ! fixed_start )
frame_resizer_base ->set_x_start( (int) (spinbutton_before .get_value() / MB_PER_PIXEL + 0.5) ) ; frame_resizer_base ->set_x_start( (int) (spinbutton_before .get_value() / MB_PER_PIXEL + 0.5) ) ;
frame_resizer_base ->set_x_end( (int) ( 500 - ( (double) spinbutton_after .get_value() / MB_PER_PIXEL ) + 0.5 ) ) ; frame_resizer_base ->set_x_end( (int) ( 500 - ( (double) spinbutton_after .get_value() / MB_PER_PIXEL ) + 0.5 ) ) ;
this ->x_start = frame_resizer_base ->get_x_start() ; this ->x_start = frame_resizer_base ->get_x_start() ;
this ->x_end = frame_resizer_base ->get_x_end() ; this ->x_end = frame_resizer_base ->get_x_end() ;

View File

@ -43,11 +43,11 @@ void Dialog_Partition_Copy::Set_Data( Partition & selected_partition, Partition
//now calculate proportional length of partition //now calculate proportional length of partition
frame_resizer_base ->set_x_start( 0 ) ; frame_resizer_base ->set_x_start( 0 ) ;
frame_resizer_base ->set_x_end( ( Round( (double) (copied_partition.sector_end - copied_partition.sector_start) / ( (double)total_length/500) )) ) ; frame_resizer_base ->set_x_end( ( Round( (double) (copied_partition.sector_end - copied_partition.sector_start) / ( (double)total_length/500) )) ) ;
frame_resizer_base ->set_used( frame_resizer_base ->get_x_end() ) ; frame_resizer_base ->set_used( frame_resizer_base ->get_x_end() ) ;
//set values of spinbutton_before //set values of spinbutton_before
spinbutton_before .set_range( 0, TOTAL_MB - copied_partition .Get_Length_MB() -1 ) ;//mind the -1 !! spinbutton_before .set_range( 0, TOTAL_MB - copied_partition .Get_Length_MB() -1 ) ;//mind the -1 !!
spinbutton_before .set_value( 0 ) ; spinbutton_before .set_value( 0 ) ;
//set values of spinbutton_size (check for fat16 maxsize of 1023 MB) //set values of spinbutton_size (check for fat16 maxsize of 1023 MB)
@ -58,20 +58,20 @@ void Dialog_Partition_Copy::Set_Data( Partition & selected_partition, Partition
UPPER = TOTAL_MB; UPPER = TOTAL_MB;
spinbutton_size .set_range( copied_partition .Get_Length_MB() +1, UPPER ) ; spinbutton_size .set_range( copied_partition .Get_Length_MB() +1, UPPER ) ;
spinbutton_size .set_value( copied_partition .Get_Length_MB() ) ; spinbutton_size .set_value( copied_partition .Get_Length_MB() ) ;
//set values of spinbutton_after //set values of spinbutton_after
spinbutton_after .set_range( 0, TOTAL_MB - copied_partition .Get_Length_MB() -1 ) ; spinbutton_after .set_range( 0, TOTAL_MB - copied_partition .Get_Length_MB() -1 ) ;
spinbutton_after .set_value( TOTAL_MB - copied_partition .Get_Length_MB() ) ; spinbutton_after .set_value( TOTAL_MB - copied_partition .Get_Length_MB() ) ;
//set contents of label_minmax //set contents of label_minmax
os << String::ucompose( _("Minimum Size: %1 MB"), copied_partition .Get_Length_MB() +1 ) << "\t\t" ; Glib::ustring str_temp = String::ucompose( _("Minimum Size: %1 MB"), copied_partition .Get_Length_MB() +1 ) + "\t\t" ;
os << String::ucompose( _("Maximum Size: %1 MB"), Sector_To_MB( total_length ) ) ; str_temp += String::ucompose( _("Maximum Size: %1 MB"), Sector_To_MB( total_length ) ) ;
label_minmax.set_text( os.str() ) ; os.str("") ; label_minmax.set_text( str_temp ) ;
//set global selected_partition (see Dialog_Base_Partition::Get_New_Partition ) //set global selected_partition (see Dialog_Base_Partition::Get_New_Partition )
this ->selected_partition = copied_partition ; this ->selected_partition = copied_partition ;
this ->selected_partition .inside_extended = selected_partition .inside_extended ; this ->selected_partition .inside_extended = selected_partition .inside_extended ;
selected_partition .inside_extended ? this ->selected_partition .type = GParted::LOGICAL : this ->selected_partition .type = GParted::PRIMARY ; selected_partition .inside_extended ? this ->selected_partition .type = GParted::LOGICAL : this ->selected_partition .type = GParted::PRIMARY ;
GRIP = false ; GRIP = false ;

View File

@ -110,21 +110,20 @@ void Dialog_Partition_Info::init_drawingarea()
//calculate proportional width of used and unused //calculate proportional width of used and unused
used = unused = 0 ; used = unused = 0 ;
used = (int ) ( ( (375 - BORDER *2) / ( (double) (partition.sector_end - partition.sector_start) / partition.sectors_used ) )+0.5 ) ; used = (int) ( ( (375 - BORDER *2) / ( (double) (partition.sector_end - partition.sector_start) / partition.sectors_used ) )+0.5 ) ;
unused = 375 - used - (BORDER *2) ; unused = 375 - used - (BORDER *2) ;
//allocate some colors //allocate some colors
color_used.set( "#F8F8BA" ); this ->get_colormap() ->alloc_color( color_used ) ; color_used.set( "#F8F8BA" ); this ->get_colormap() ->alloc_color( color_used ) ;
partition .type == GParted::EXTENDED ? color_unused.set( "darkgrey" ) : color_unused.set( "white" ) ; partition .type == GParted::EXTENDED ? color_unused.set( "darkgrey" ) : color_unused.set( "white" ) ;
this ->get_colormap() ->alloc_color( color_unused ) ; this ->get_colormap() ->alloc_color( color_unused ) ;
color_text.set( "black" ); this ->get_colormap() ->alloc_color( color_text ) ; color_text.set( "black" ); this ->get_colormap() ->alloc_color( color_text ) ;
color_partition = partition.color ; this ->get_colormap() ->alloc_color( color_partition ) ; color_partition = partition.color ; this ->get_colormap() ->alloc_color( color_partition ) ;
//set text of pangolayout //set text of pangolayout
os << partition .partition <<"\n" << String::ucompose( _("%1 MB"), partition .Get_Length_MB() ) ; pango_layout = drawingarea .create_pango_layout ( partition .partition + "\n" + String::ucompose( _("%1 MB"), partition .Get_Length_MB() ) ) ;
pango_layout = drawingarea .create_pango_layout ( os.str() ) ;os.str("");
} }
@ -148,19 +147,17 @@ void Dialog_Partition_Info::Display_Info()
if ( partition.sectors_used != -1 ) if ( partition.sectors_used != -1 )
{ {
//calculate relative diskusage //calculate relative diskusage
int percent_used =(int) ( (double) partition.Get_Used_MB() / partition .Get_Length_MB() *100 +0.5 ) ; int percent_used = (int) ( (double) partition.Get_Used_MB() / partition .Get_Length_MB() *100 +0.5 ) ;
//used //used
table ->attach( * mk_label( "<b>" + (Glib::ustring) _( "Used:" ) + "</b>" ), 0,1, top, bottom,Gtk::FILL); table ->attach( * mk_label( "<b>" + (Glib::ustring) _( "Used:" ) + "</b>" ), 0,1, top, bottom,Gtk::FILL);
table ->attach( * mk_label( String::ucompose( _("%1 MB"), this ->partition .Get_Used_MB() ) ) , 1,2, top, bottom,Gtk::FILL); table ->attach( * mk_label( String::ucompose( _("%1 MB"), this ->partition .Get_Used_MB() ) ) , 1,2, top, bottom,Gtk::FILL);
os << percent_used ; table ->attach( * mk_label( "\t\t\t( " + num_to_str( percent_used ) + "% )"), 1,2, top++, bottom++,Gtk::FILL);
table ->attach( * mk_label( "\t\t\t( " + os.str() + "% )"), 1,2, top++, bottom++,Gtk::FILL); os.str("") ;
//unused //unused
table ->attach( * mk_label( "<b>" + (Glib::ustring) _( "Unused:" ) + "</b>" ), 0,1, top, bottom,Gtk::FILL); table ->attach( * mk_label( "<b>" + (Glib::ustring) _( "Unused:" ) + "</b>" ), 0,1, top, bottom,Gtk::FILL);
table ->attach( * mk_label( String::ucompose( _("%1 MB"), this ->partition .Get_Unused_MB() ) ) , 1,2, top, bottom,Gtk::FILL); table ->attach( * mk_label( String::ucompose( _("%1 MB"), this ->partition .Get_Unused_MB() ) ) , 1,2, top, bottom,Gtk::FILL);
os << 100 - percent_used ; table ->attach( * mk_label( "\t\t\t( " + num_to_str( 100 - percent_used ) + "% )"), 1,2, top++, bottom++,Gtk::FILL);
table ->attach( * mk_label( "\t\t\t( " + os.str() + "% )"), 1,2, top++, bottom++,Gtk::FILL); os.str("") ;
} }
//flags //flags
@ -191,52 +188,43 @@ void Dialog_Partition_Info::Display_Info()
} }
//status //status
Glib::ustring str_temp ;
table ->attach( * mk_label( "<b>" + (Glib::ustring) _( "Status:" ) + "</b>" ), 0,1, top, bottom,Gtk::FILL); table ->attach( * mk_label( "<b>" + (Glib::ustring) _( "Status:" ) + "</b>" ), 0,1, top, bottom,Gtk::FILL);
if ( partition.busy ) if ( partition.busy )
Find_Status() ; str_temp = Find_Status() ;
else if ( partition.type == GParted::EXTENDED ) else if ( partition.type == GParted::EXTENDED )
os << (Glib::ustring) _("Not busy (There are no mounted logical partitions)" ) ; str_temp = _("Not busy (There are no mounted logical partitions)" ) ;
else if ( partition.filesystem == "linux-swap" ) else if ( partition.filesystem == "linux-swap" )
os << (Glib::ustring) _("Not active" ) ; str_temp = _("Not active" ) ;
else else
os << (Glib::ustring) _("Not mounted" ) ; str_temp = _("Not mounted" ) ;
table ->attach( * mk_label( os.str() ), 1,2, top++, bottom++,Gtk::FILL); os.str( "") ; table ->attach( * mk_label( str_temp ), 1,2, top++, bottom++,Gtk::FILL);
} }
//one blank line //one blank line
table ->attach( * mk_label( "" ), 1,2, top++, bottom++,Gtk::FILL); table ->attach( * mk_label( "" ), 1, 2, top++, bottom++, Gtk::FILL);
//first sector //first sector
table ->attach( * mk_label( "<b>" + (Glib::ustring) _( "First Sector:" ) + "</b>" ), 0,1, top, bottom,Gtk::FILL); table ->attach( * mk_label( "<b>" + (Glib::ustring) _( "First Sector:" ) + "</b>" ), 0, 1, top, bottom, Gtk::FILL);
os << partition.sector_start ; table ->attach( * mk_label( num_to_str( partition.sector_start ) ), 1,2, top++, bottom++,Gtk::FILL);
table ->attach( * mk_label( os.str() ), 1,2, top++, bottom++,Gtk::FILL); os.str( "") ;
//last sector //last sector
table ->attach( * mk_label( "<b>" + (Glib::ustring) _( "Last Sector:" ) + "</b>" ), 0,1, top, bottom,Gtk::FILL); table ->attach( * mk_label( "<b>" + (Glib::ustring) _( "Last Sector:" ) + "</b>" ), 0,1, top, bottom,Gtk::FILL);
os << partition.sector_end ; table ->attach( * mk_label( num_to_str( partition.sector_end ) ), 1,2, top++, bottom++,Gtk::FILL);
table ->attach( * mk_label( os.str() ), 1,2, top++, bottom++,Gtk::FILL); os.str( "") ;
//total sectors //total sectors
table ->attach( * mk_label( "<b>" + (Glib::ustring) _( "Total Sectors:" ) + "</b>" ), 0,1, top, bottom,Gtk::FILL); table ->attach( * mk_label( "<b>" + (Glib::ustring) _( "Total Sectors:" ) + "</b>" ), 0,1, top, bottom,Gtk::FILL);
os << partition.sector_end - partition.sector_start ; table ->attach( * mk_label( num_to_str( partition.sector_end - partition.sector_start ) ), 1,2, top++, bottom++,Gtk::FILL);
table ->attach( * mk_label( os.str() ), 1,2, top++, bottom++,Gtk::FILL); os.str( "") ;
} }
void Dialog_Partition_Info::Find_Status() Glib::ustring Dialog_Partition_Info::Find_Status()
{ {
if ( partition.type == GParted::EXTENDED ) if ( partition.type == GParted::EXTENDED )
{ return _("Busy (At least one logical partition is mounted)" ) ;
os << _("Busy (At least one logical partition is mounted)" ) ; else if ( partition.filesystem == "linux-swap" )
return ; return _("Active") ;
}
if ( partition.filesystem == "linux-swap" )
{
os << _("Active") ;
return ;
}
//try to find the mountpoint in /proc/mounts //try to find the mountpoint in /proc/mounts
//get realpath //get realpath
@ -250,13 +238,14 @@ void Dialog_Partition_Info::Find_Status()
while ( getline( file_mounts, line ) ) while ( getline( file_mounts, line ) )
{ {
realpath( line.substr( 0, line.find( ' ' ) ) .c_str() , real_path ); realpath( line.substr( 0, line.find( ' ' ) ) .c_str(), real_path );
if ( partition_real_path == real_path ) if ( partition_real_path == real_path )
{ {
mountpoint = line.substr( line.find( ' ' ) +1, line .length() ) ; //this is so cool =)
mountpoint = line.substr( line.find( ' ' ) +1, line .length() ) ;
mountpoint = mountpoint .substr( 0, mountpoint .find( ' ' ) ) ;
os << String::ucompose( _("Mounted on %1"), mountpoint .substr( 0, mountpoint .find( ' ' ) ) ) ;
break ; break ;
} }
@ -266,8 +255,11 @@ void Dialog_Partition_Info::Find_Status()
file_mounts .close() ; file_mounts .close() ;
//sometimes rootdevices are not listed as paths. I'll take a guess and just enter / here...( we'll look into this when complaints start coming in :P ) //sometimes rootdevices are not listed as paths. I'll take a guess and just enter / here...( we'll look into this when complaints start coming in :P )
if ( mountpoint.empty() ) if ( mountpoint .empty() )
os << String::ucompose( _("Mounted on %1"), "/") ; mountpoint = "/" ;
return String::ucompose( _("Mounted on %1"), mountpoint ) ;
} }
Dialog_Partition_Info::~Dialog_Partition_Info() Dialog_Partition_Info::~Dialog_Partition_Info()

View File

@ -108,9 +108,9 @@ void Dialog_Partition_New::Set_Data( const Partition & partition, bool any_exten
GRIP = false ; GRIP = false ;
//set contents of label_minmax //set contents of label_minmax
os << String::ucompose( _("Minimum Size: %1 MB"), 1 ) << "\t\t" ; Glib::ustring str_temp = String::ucompose( _("Minimum Size: %1 MB"), 1 ) +"\t\t" ;
os << String::ucompose( _("Maximum Size: %1 MB"), TOTAL_MB ) ; str_temp += String::ucompose( _("Maximum Size: %1 MB"), TOTAL_MB ) ;
label_minmax.set_text( os.str() ) ; os.str("") ; label_minmax.set_text( str_temp ) ;
this ->show_all_children() ; this ->show_all_children() ;
} }
@ -128,7 +128,7 @@ Partition Dialog_Partition_New::Get_New_Partition()
case 2 : part_type = GParted::EXTENDED; break; case 2 : part_type = GParted::EXTENDED; break;
} }
new_start = START + (Sector) (spinbutton_before .get_value() * MEGABYTE) ; new_start = START + (Sector) (spinbutton_before .get_value() * MEGABYTE) ;
new_end = new_start + (Sector) (spinbutton_size .get_value() * MEGABYTE) ; new_end = new_start + (Sector) (spinbutton_size .get_value() * MEGABYTE) ;
//due to loss of precision during calcs from Sector -> MB and back, it is possible the new partition thinks it's bigger then it can be. Here we try to solve this. //due to loss of precision during calcs from Sector -> MB and back, it is possible the new partition thinks it's bigger then it can be. Here we try to solve this.
@ -137,9 +137,8 @@ Partition Dialog_Partition_New::Get_New_Partition()
if ( new_end > selected_partition.sector_end ) if ( new_end > selected_partition.sector_end )
new_end = selected_partition.sector_end ; new_end = selected_partition.sector_end ;
os << String::ucompose( _("New Partition #%1"), new_count ) ;
part_temp .status = GParted::STAT_NEW ; part_temp .status = GParted::STAT_NEW ;
part_temp .Set( os.str(), new_count, part_type , filesystems[ optionmenu_filesystem.get_history() ], new_start, new_end, -1, selected_partition.inside_extended, false) ; os.str("") ; part_temp .Set( String::ucompose( _("New Partition #%1"), new_count ), new_count, part_type , filesystems[ optionmenu_filesystem.get_history() ], new_start, new_end, -1, selected_partition.inside_extended, false) ;
//grow new partition a bit if freespaces are < 1 MB //grow new partition a bit if freespaces are < 1 MB
if ( (part_temp.sector_start - selected_partition.sector_start) < MEGABYTE ) if ( (part_temp.sector_start - selected_partition.sector_start) < MEGABYTE )
@ -182,13 +181,13 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
switch ( optionmenu_filesystem .get_history() ) switch ( optionmenu_filesystem .get_history() )
{ {
case 1 : MIN = 32 ; case 1 : MIN = 32 ;
TOTAL_MB > 1023 ? MAX = 1023 : MAX = TOTAL_MB ; TOTAL_MB > 1023 ? MAX = 1023 : MAX = TOTAL_MB ;
break; break;
case 2 : MIN = 256 ; case 2 : MIN = 256 ;
MAX = TOTAL_MB ; MAX = TOTAL_MB ;
break; break;
default : MIN = 1 ; default : MIN = 1 ;
MAX = TOTAL_MB ; MAX = TOTAL_MB ;
} }
spinbutton_before .set_range( 0, TOTAL_MB - MIN ) ; spinbutton_before .set_range( 0, TOTAL_MB - MIN ) ;
@ -196,9 +195,9 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
spinbutton_after .set_range( 0, TOTAL_MB - MIN ) ; spinbutton_after .set_range( 0, TOTAL_MB - MIN ) ;
//set contents of label_minmax //set contents of label_minmax
os << String::ucompose( _("Minimum Size: %1 MB"), MIN ) << "\t\t" ; Glib::ustring str_temp = String::ucompose( _("Minimum Size: %1 MB"), MIN ) + "\t\t" ;
os << String::ucompose( _("Maximum Size: %1 MB"), MAX ) ; str_temp += String::ucompose( _("Maximum Size: %1 MB"), MAX ) ;
label_minmax.set_text( os.str() ) ; os.str("") ; label_minmax.set_text( str_temp ) ;
} }

View File

@ -49,8 +49,8 @@ void Dialog_Partition_Resize_Move::Set_Data( const Partition & selected_partitio
this ->x_end = frame_resizer_base ->get_x_end() ; this ->x_end = frame_resizer_base ->get_x_end() ;
//store the original values //store the original values
ORIG_BEFORE = spinbutton_before .get_value_as_int() ; ORIG_BEFORE = spinbutton_before .get_value_as_int() ;
ORIG_SIZE = spinbutton_size .get_value_as_int() ; ORIG_SIZE = spinbutton_size .get_value_as_int() ;
ORIG_AFTER = spinbutton_after .get_value_as_int() ; ORIG_AFTER = spinbutton_after .get_value_as_int() ;
GRIP = false ; GRIP = false ;
@ -111,7 +111,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector <Partit
if ( ! fixed_start ) if ( ! fixed_start )
{ {
spinbutton_before .set_range( 0, Sector_To_MB(total_length - selected_partition.sectors_used) -1 ) ;//mind the -1 !! spinbutton_before .set_range( 0, Sector_To_MB(total_length - selected_partition.sectors_used) -1 ) ;//mind the -1 !!
spinbutton_before .set_value( Sector_To_MB( previous ) ) ; spinbutton_before .set_value( Sector_To_MB( previous ) ) ;
} }
//set values of spinbutton_size //set values of spinbutton_size
@ -133,13 +133,13 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector <Partit
spinbutton_size .set_value( selected_partition .Get_Length_MB() ) ; spinbutton_size .set_value( selected_partition .Get_Length_MB() ) ;
//set values of spinbutton_after //set values of spinbutton_after
spinbutton_after .set_range( 0, Sector_To_MB( total_length ) - LOWER ) ; spinbutton_after .set_range( 0, Sector_To_MB( total_length ) - LOWER ) ;
spinbutton_after .set_value( Sector_To_MB( next ) ) ; spinbutton_after .set_value( Sector_To_MB( next ) ) ;
//set contents of label_minmax //set contents of label_minmax
os << String::ucompose( _("Minimum Size: %1 MB"), LOWER ) << "\t\t" ; Glib::ustring str_temp = String::ucompose( _("Minimum Size: %1 MB"), LOWER ) + "\t\t" ;
os << String::ucompose( _("Maximum Size: %1 MB"), Sector_To_MB( total_length ) ) ; str_temp += String::ucompose( _("Maximum Size: %1 MB"), Sector_To_MB( total_length ) ) ;
label_minmax.set_text( os.str() ) ; os.str("") ; label_minmax.set_text( str_temp ) ;
} }
@ -225,9 +225,9 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector <Part
spinbutton_after .set_value( Sector_To_MB( next ) ) ; spinbutton_after .set_value( Sector_To_MB( next ) ) ;
//set contents of label_minmax //set contents of label_minmax
os << String::ucompose( _("Minimum Size: %1 MB"), Sector_To_MB( used ) +1 ) << "\t\t" ; Glib::ustring str_temp = String::ucompose( _("Minimum Size: %1 MB"), Sector_To_MB( used ) +1 ) + "\t\t" ;
os << String::ucompose( _("Maximum Size: %1 MB"), Sector_To_MB( total_length ) ) ; str_temp += String::ucompose( _("Maximum Size: %1 MB"), Sector_To_MB( total_length ) ) ;
label_minmax.set_text( os.str() ) ; os.str("") ; label_minmax.set_text( str_temp ) ;
} }

View File

@ -27,17 +27,19 @@ Dialog_Progress::Dialog_Progress( int count_operations, const Glib::ustring & fi
this ->count_operations = count_operations ; this ->count_operations = count_operations ;
current_operation_number = 0; current_operation_number = 0;
fraction =(double) 1 / count_operations ; fraction = (double) 1 / count_operations ;
fraction -= 1E-8 ; //minus 1E-8 is to prevent fraction from ever reaching >=1, it needs to be 0.0 < fraction < 1.0 fraction -= 1E-8 ; //minus 1E-8 is to prevent fraction from ever reaching >=1, it needs to be 0.0 < fraction < 1.0
label_temp = manage( new Gtk::Label() ) ; label_temp = manage( new Gtk::Label() ) ;
label_temp ->set_alignment( Gtk::ALIGN_LEFT ); label_temp ->set_alignment( Gtk::ALIGN_LEFT );
os << "<span weight=\"bold\" size=\"larger\">" << _( "Applying pending operations" ) << "</span>\n\n" ; Glib::ustring str_temp = "<span weight=\"bold\" size=\"larger\">" ;
os << _("Applying all listed operations.") ; str_temp += _( "Applying pending operations" ) ;
os << "\n"; str_temp += "</span>\n\n" ;
os << _("Clicking Cancel will prevent the next operations from being applied.") ; str_temp += _("Applying all listed operations.") ;
os << "\n"; str_temp += "\n";
label_temp ->set_markup( os.str() ) ; os.str("") ; str_temp += _("Clicking Cancel will prevent the next operations from being applied.") ;
str_temp += "\n";
label_temp ->set_markup( str_temp ) ;
this->get_vbox() ->pack_start( *label_temp, Gtk::PACK_SHRINK ); this->get_vbox() ->pack_start( *label_temp, Gtk::PACK_SHRINK );
progressbar_current.set_text( _("initializing...") ); progressbar_current.set_text( _("initializing...") );

View File

@ -53,8 +53,7 @@ void Partition::Set( const Glib::ustring & partition,
void Partition::Set_Unallocated( Sector sector_start, Sector sector_end, bool inside_extended ) void Partition::Set_Unallocated( Sector sector_start, Sector sector_end, bool inside_extended )
{ {
this ->Set( _("Unallocated"), -1, GParted::UNALLOCATED, "unallocated", sector_start, sector_end , -1, inside_extended, false); this ->Set( _("Unallocated"), -1, GParted::UNALLOCATED, "unallocated", sector_start, sector_end , -1, inside_extended, false);
this ->error = "" ; this ->error = this ->flags = "" ;
this ->flags = "" ;
this ->status = GParted::STAT_REAL ; this ->status = GParted::STAT_REAL ;
} }
@ -93,10 +92,8 @@ void Partition::Update_Number( int new_number )
{ //of course this fails when we have devicenames with numbers over 99 { //of course this fails when we have devicenames with numbers over 99
partition_number >= 10 ? partition = partition.substr( 0, partition.length() -2 ) : partition = partition.substr( 0, partition.length() -1 ) ; partition_number >= 10 ? partition = partition.substr( 0, partition.length() -2 ) : partition = partition.substr( 0, partition.length() -1 ) ;
partition_number = new_number; this ->partition_number = new_number;
std::ostringstream os; this ->partition += num_to_str( partition_number ) ;
os << new_number;
partition += os.str();
} }
long Partition::Get_Length_MB( ) long Partition::Get_Length_MB( )

View File

@ -26,9 +26,7 @@ VBox_VisualDisk::VBox_VisualDisk( const std::vector<Partition> & partitions, con
this ->device_length = device_length ; this ->device_length = device_length ;
selected_partition = -1; selected_partition = -1;
//set locale for this stream to standard. this prevent weird locals from f*cking up my conversions :^)
os.imbue(std::locale(""));
//create frame which contains the visual disk //create frame which contains the visual disk
frame_disk_legend = manage( new Gtk::Frame() ) ; frame_disk_legend = manage( new Gtk::Frame() ) ;
frame_disk_legend ->set_shadow_type(Gtk::SHADOW_ETCHED_OUT); frame_disk_legend ->set_shadow_type(Gtk::SHADOW_ETCHED_OUT);
@ -45,17 +43,17 @@ VBox_VisualDisk::VBox_VisualDisk( const std::vector<Partition> & partitions, con
//set and allocated some standard colors //set and allocated some standard colors
color_used.set( "#F8F8BA" ); this ->get_colormap() ->alloc_color( color_used ) ;//bleach yellow ;) color_used.set( "#F8F8BA" ); this ->get_colormap() ->alloc_color( color_used ) ;//bleach yellow ;)
color_unused.set( "white" ); this ->get_colormap() ->alloc_color( color_unused ) ; color_unused.set( "white" ); this ->get_colormap() ->alloc_color( color_unused ) ;
color_text.set( "black" ); this ->get_colormap() ->alloc_color( color_text ) ; color_text.set( "black" ); this ->get_colormap() ->alloc_color( color_text ) ;
//since disksegments have minimal sizes ( unallocated 15 and partitions 20 pixels ) i do some checking to prevent the visual disk from growing to much //since disksegments have minimal sizes ( unallocated 15 and partitions 20 pixels ) i do some checking to prevent the visual disk from growing to much
Sector sectors_per_pixel = Round( (double) device_length / 750 ) ; Sector sectors_per_pixel = Round( (double) device_length / 750 ) ;
double width, extra_pixels = 0 ; double width, extra_pixels = 0 ;
for ( unsigned int t=0; t<partitions.size() ; t++ ) for ( unsigned int t=0; t<partitions.size() ; t++ )
{ {
width = (double) (partitions[ t ].sector_end - partitions[ t ].sector_start) / sectors_per_pixel ; width = (double) (partitions[ t ] .sector_end - partitions[ t ] .sector_start) / sectors_per_pixel ;
if ( (partitions[ t ] .type == GParted::PRIMARY || partitions[ t ] .type == GParted::LOGICAL) && width < 20 ) if ( (partitions[ t ] .type == GParted::PRIMARY || partitions[ t ] .type == GParted::LOGICAL) && width < 20 )
extra_pixels += (20 - width) ; extra_pixels += (20 - width) ;
@ -66,7 +64,7 @@ VBox_VisualDisk::VBox_VisualDisk( const std::vector<Partition> & partitions, con
//draw visual disk and its legend //draw visual disk and its legend
Build_Visual_Disk( 750 - Round( extra_pixels ) ) ; Build_Visual_Disk( 750 - Round( extra_pixels ) ) ;
Build_Legend( ) ; Build_Legend( ) ;
} }
@ -74,7 +72,7 @@ void VBox_VisualDisk::Build_Visual_Disk( int SCREEN_WIDTH )
{ {
//since there is a 5 pixel space between every partition.... ( extended adds 2 *5 more, but that doesn't matter that much. //since there is a 5 pixel space between every partition.... ( extended adds 2 *5 more, but that doesn't matter that much.
//NOTE that a part < 20 will also grow to 20, so length in pixels may vary across different devices.. //NOTE that a part < 20 will also grow to 20, so length in pixels may vary across different devices..
SCREEN_WIDTH -= ( (partitions.size() -1) *5 ) ; SCREEN_WIDTH -= ( (partitions .size() -1) *5 ) ;
//create hbox_disk and add to frame //create hbox_disk and add to frame
hbox_disk = manage( new Gtk::HBox() ) ; hbox_disk = manage( new Gtk::HBox() ) ;
@ -108,51 +106,55 @@ void VBox_VisualDisk::Build_Visual_Disk( int SCREEN_WIDTH )
continue; continue;
} }
visual_partitions.back() ->length = (int) (SCREEN_WIDTH / (double) ( device_length / (double) ( partitions[i].sector_end - partitions[i].sector_start) ) ); visual_partitions.back() ->length = (int) (SCREEN_WIDTH / (double) ( device_length / (double) ( partitions[i].sector_end - partitions[i].sector_start) ) );
if ( visual_partitions.back() ->length < 20 )//we need a min. size. Otherwise some small partitions wouldn't be visible if ( visual_partitions.back() ->length < 20 )//we need a min. size. Otherwise some small partitions wouldn't be visible
partitions[i].type == GParted::UNALLOCATED ? visual_partitions.back() ->length = 15 : visual_partitions.back() ->length = 20 ; partitions[i] .type == GParted::UNALLOCATED ? visual_partitions.back() ->length = 15 : visual_partitions.back() ->length = 20 ;
if ( partitions[i].inside_extended ) if ( partitions[i].inside_extended )
{ visual_partitions.back() ->height = 34 ; visual_partitions.back() ->text_y = 10 ; } { visual_partitions.back() ->height = 34 ; visual_partitions.back() ->text_y = 10 ; }
else else
{ visual_partitions.back() ->height = 44 ;visual_partitions.back() ->text_y = 15 ; } { visual_partitions.back() ->height = 44 ;visual_partitions.back() ->text_y = 15 ; }
if ( partitions[i].type == GParted::UNALLOCATED ) if ( partitions[i].type == GParted::UNALLOCATED )
visual_partitions.back() ->used = -1; visual_partitions.back() ->used = -1;
else else
visual_partitions.back() ->used = (int) ( (visual_partitions.back() ->length - (BORDER *2)) / (double) ( ( partitions[i].sector_end - partitions[i].sector_start) / (double)partitions[i].sectors_used ) ) ; visual_partitions.back() ->used = (int) ( (visual_partitions.back() ->length - (BORDER *2)) / (double) ( ( partitions[i].sector_end - partitions[i].sector_start) / (double)partitions[i].sectors_used ) ) ;
visual_partitions.back() ->color_fs = partitions[i].color; visual_partitions.back() ->color_fs = partitions[i].color;
this ->get_colormap() ->alloc_color(visual_partitions.back() ->color_fs); this ->get_colormap() ->alloc_color(visual_partitions.back() ->color_fs);
visual_partitions.back() ->drawingarea = manage( new Gtk::DrawingArea() ) ; visual_partitions.back() ->drawingarea = manage( new Gtk::DrawingArea() ) ;
visual_partitions.back() ->drawingarea ->set_size_request( visual_partitions.back() ->length+1 ,60 ); visual_partitions.back() ->drawingarea ->set_size_request( visual_partitions.back() ->length+1 ,60 );
visual_partitions.back() ->drawingarea ->set_events(Gdk::BUTTON_PRESS_MASK); visual_partitions.back() ->drawingarea ->set_events(Gdk::BUTTON_PRESS_MASK);
//connect signal handlers //connect signal handlers
visual_partitions.back() ->drawingarea ->signal_button_press_event().connect( sigc::bind<Partition>(sigc::mem_fun(*this, &VBox_VisualDisk::on_drawingarea_button_press), partitions[i] ) ); visual_partitions.back() ->drawingarea ->signal_button_press_event().connect( sigc::bind<Partition>(sigc::mem_fun(*this, &VBox_VisualDisk::on_drawingarea_button_press), partitions[i] ) );
visual_partitions.back() ->drawingarea->signal_realize().connect( sigc::bind<Visual_Partition *>(sigc::mem_fun(*this, &VBox_VisualDisk::drawingarea_on_realize), visual_partitions.back() ) ); visual_partitions.back() ->drawingarea ->signal_realize().connect( sigc::bind<Visual_Partition *>(sigc::mem_fun(*this, &VBox_VisualDisk::drawingarea_on_realize), visual_partitions.back() ) );
visual_partitions.back() ->drawingarea ->signal_expose_event().connect( sigc::bind<Visual_Partition *>(sigc::mem_fun(*this, &VBox_VisualDisk::drawingarea_on_expose), visual_partitions.back() )); visual_partitions.back() ->drawingarea ->signal_expose_event().connect( sigc::bind<Visual_Partition *>(sigc::mem_fun(*this, &VBox_VisualDisk::drawingarea_on_expose), visual_partitions.back() ));
//create pangolayout and see if it fits in the visual partition //create pangolayout and see if it fits in the visual partition
os << partitions[i].partition << "\n" << String::ucompose( _("%1 MB"), partitions[i] .Get_Length_MB() ) ; str_temp = partitions[i] .partition + "\n" + String::ucompose( _("%1 MB"), partitions[i] .Get_Length_MB() ) ;
visual_partitions.back() ->pango_layout = visual_partitions.back() ->drawingarea ->create_pango_layout ( os.str() ) ;os.str(""); visual_partitions.back() ->pango_layout = visual_partitions.back() ->drawingarea ->create_pango_layout ( str_temp ) ;
visual_partitions.back() ->pango_layout ->get_pixel_size( x, y ) ; visual_partitions.back() ->pango_layout ->get_pixel_size( x, y ) ;
if ( visual_partitions.back() ->length - BORDER * 2 -2 < x ) if ( visual_partitions.back() ->length - BORDER * 2 -2 < x )
visual_partitions.back() ->pango_layout ->set_text( "" ) ; visual_partitions.back() ->pango_layout ->set_text( "" ) ;
//tooltip //tooltip
if ( partitions[i].type != GParted::UNALLOCATED ) if ( partitions[i].type != GParted::UNALLOCATED )
os << partitions[i].filesystem << "\n" ; str_temp = partitions[i] .filesystem + "\n" ;
os << partitions[i].partition + "\n" + String::ucompose( _("%1 MB"), partitions[i] .Get_Length_MB() ) ; str_temp += partitions[i] .partition + "\n" + String::ucompose( _("%1 MB"), partitions[i] .Get_Length_MB() ) ;
tooltips.set_tip( *(visual_partitions.back() ->drawingarea) ,os.str() ) ; os.str(""); tooltips.set_tip( *(visual_partitions.back() ->drawingarea), str_temp ) ;
partitions[i].inside_extended ? hbox_extended ->pack_start( *(visual_partitions.back() ->drawingarea) , Gtk::PACK_SHRINK ) : hbox_disk ->pack_start( *(visual_partitions.back() ->drawingarea) , Gtk::PACK_SHRINK ) ; if ( partitions[i] .inside_extended )
hbox_extended ->pack_start( *(visual_partitions.back() ->drawingarea), Gtk::PACK_SHRINK ) ;
else
hbox_disk ->pack_start( *(visual_partitions.back() ->drawingarea), Gtk::PACK_SHRINK ) ;
} }
this ->show_all_children() ; this ->show_all_children() ;
} }

View File

@ -26,8 +26,7 @@ Win_GParted::Win_GParted( )
new_count = 1; new_count = 1;
current_device = source_device = 0 ; current_device = source_device = 0 ;
vbox_visual_disk = NULL; vbox_visual_disk = NULL;
os.imbue(std::locale(""));//set locale for this stream to standard
//locate all available devices and store them in devices vector //locate all available devices and store them in devices vector
Find_Devices() ; Find_Devices() ;
@ -527,10 +526,10 @@ void Win_GParted::Refresh_Visual( )
delete ( vbox_visual_disk ); delete ( vbox_visual_disk );
} }
vbox_visual_disk = new VBox_VisualDisk ( partitions, devices[ current_device ] ->Get_Length() ); vbox_visual_disk = new VBox_VisualDisk ( partitions, devices[ current_device ] ->Get_Length() );
s2 = vbox_visual_disk->signal_mouse_click.connect( sigc::mem_fun( this, &Win_GParted::mouse_click) ); s2 = vbox_visual_disk->signal_mouse_click.connect( sigc::mem_fun( this, &Win_GParted::mouse_click) );
hbox_visual.pack_start( *vbox_visual_disk, Gtk::PACK_EXPAND_PADDING ); hbox_visual.pack_start( *vbox_visual_disk, Gtk::PACK_EXPAND_PADDING );
hbox_visual .show_all_children(); hbox_visual .show_all_children();
//treeview details //treeview details
treeview_detail .Load_Partitions( partitions ) ; treeview_detail .Load_Partitions( partitions ) ;
@ -542,14 +541,14 @@ bool Win_GParted::Quit_Check_Operations()
{ {
if ( operations.size() ) if ( operations.size() )
{ {
os << "<span weight=\"bold\" size=\"larger\">" + (Glib::ustring) _( "Quit GParted?" ) + "</span>\n\n" ; str_temp = "<span weight=\"bold\" size=\"larger\">" + (Glib::ustring) _( "Quit GParted?" ) + "</span>\n\n" ;
if ( operations .size() != 1 ) if ( operations .size() != 1 )
os << String::ucompose( _("%1 operations are currently pending."), operations .size() ) ; str_temp += String::ucompose( _("%1 operations are currently pending."), operations .size() ) ;
else else
os << _("1 operation is currently pending."); str_temp += _("1 operation is currently pending.");
Gtk::MessageDialog dialog( *this, os.str() , true, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_NONE, true);os.str(""); Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_NONE, true);
dialog .add_button( Gtk::Stock::QUIT, Gtk::RESPONSE_CLOSE ); dialog .add_button( Gtk::Stock::QUIT, Gtk::RESPONSE_CLOSE );
dialog .add_button( Gtk::Stock::CANCEL,Gtk::RESPONSE_CANCEL ); dialog .add_button( Gtk::Stock::CANCEL,Gtk::RESPONSE_CANCEL );
@ -561,7 +560,7 @@ bool Win_GParted::Quit_Check_Operations()
void Win_GParted::Set_Valid_Operations() void Win_GParted::Set_Valid_Operations()
{ {
allow_new( false ); allow_delete( false ); allow_resize( false );allow_copy( false ); allow_paste( false ); allow_convert( false ); allow_new( false ); allow_delete( false ); allow_resize( false ); allow_copy( false ); allow_paste( false ); allow_convert( false );
//we can't perform any operation on a busy (mounted) filesystem //we can't perform any operation on a busy (mounted) filesystem
if ( selected_partition.busy ) if ( selected_partition.busy )
@ -721,8 +720,10 @@ void Win_GParted::menu_view_harddisk_info()
void Win_GParted::menu_help_contents() void Win_GParted::menu_help_contents()
{ {
os << _("Sorry, not yet implemented.") << "\n" << _( "Please visit http://gparted.sf.net for more information and support.") ; str_temp = _("Sorry, not yet implemented.") ;
Gtk::MessageDialog dialog( *this,os.str() ,false, Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK, true); os.str("") ; str_temp += "\n" ;
str_temp += _( "Please visit http://gparted.sf.net for more information and support.") ;
Gtk::MessageDialog dialog( *this, str_temp, false, Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK, true);
dialog.run(); dialog.run();
} }
@ -763,11 +764,13 @@ void Win_GParted::activate_resize()
//show warning when one tries to resize a fat16 filesystem //show warning when one tries to resize a fat16 filesystem
if ( selected_partition .filesystem == "fat16" ) if ( selected_partition .filesystem == "fat16" )
{ {
os << "<span weight=\"bold\" size=\"larger\">" ; str_temp = "<span weight=\"bold\" size=\"larger\">" ;
os << _( "Are you sure you want to resize/move this partition?" ) << "</span>\n\n" ; str_temp += _( "Are you sure you want to resize/move this partition?" ) ;
os << _( "Resizing a fat16 partition can be quite tricky! Especially growing such a partition is very error-prone. It is advisable to first convert the filesystem to fat32.") << "\n"; str_temp += "</span>\n\n" ;
str_temp += _( "Resizing a fat16 partition can be quite tricky! Especially growing such a partition is very error-prone. It is advisable to first convert the filesystem to fat32.") ;
str_temp += "\n";
Gtk::MessageDialog dialog( *this,os.str(), true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_CANCEL, true); os.str("") ; Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_CANCEL, true) ;
//pffff this whole mess only for this f*cked up filesystem :-( //pffff this whole mess only for this f*cked up filesystem :-(
Gtk::Button button_resize_move ; Gtk::Button button_resize_move ;
Gtk::HBox hbox_resize_move; Gtk::HBox hbox_resize_move;
@ -836,12 +839,12 @@ void Win_GParted::activate_paste()
//Display error if user tries to create more primary partitions than the partition table can hold. //Display error if user tries to create more primary partitions than the partition table can hold.
if ( ! selected_partition.inside_extended && primary_count >=devices[ current_device ] ->Get_Max_Amount_Of_Primary_Partitions() ) if ( ! selected_partition.inside_extended && primary_count >=devices[ current_device ] ->Get_Max_Amount_Of_Primary_Partitions() )
{ {
os << "<span weight=\"bold\" size=\"larger\">" ; str_temp = "<span weight=\"bold\" size=\"larger\">" ;
os << String::ucompose( _("It is not possible to create more than %1 primary partitions"), devices[ current_device ] ->Get_Max_Amount_Of_Primary_Partitions() ) ; str_temp += String::ucompose( _("It is not possible to create more than %1 primary partitions"), devices[ current_device ] ->Get_Max_Amount_Of_Primary_Partitions() ) ;
os << "</span>\n\n" ; str_temp += "</span>\n\n" ;
os << _( "If you want more partitions you should first create an extended partition. Such a partition can contain other partitions.") ; str_temp += _( "If you want more partitions you should first create an extended partition. Such a partition can contain other partitions.") ;
Gtk::MessageDialog dialog( *this, os.str() ,true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); os.str("") ; Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
dialog.run(); dialog.run();
return; return;
} }
@ -863,12 +866,12 @@ void Win_GParted::activate_new()
//Display error if user tries to create more primary partitions than the partition table can hold. //Display error if user tries to create more primary partitions than the partition table can hold.
if ( ! selected_partition.inside_extended && primary_count >= devices[ current_device ] ->Get_Max_Amount_Of_Primary_Partitions() ) if ( ! selected_partition.inside_extended && primary_count >= devices[ current_device ] ->Get_Max_Amount_Of_Primary_Partitions() )
{ {
os << "<span weight=\"bold\" size=\"larger\">" ; str_temp = "<span weight=\"bold\" size=\"larger\">" ;
os << String::ucompose( _("It is not possible to create more than %1 primary partitions"), devices[ current_device ] ->Get_Max_Amount_Of_Primary_Partitions() ) ; str_temp += String::ucompose( _("It is not possible to create more than %1 primary partitions"), devices[ current_device ] ->Get_Max_Amount_Of_Primary_Partitions() ) ;
os << "</span>\n\n" ; str_temp += "</span>\n\n" ;
os << _( "If you want more partitions you should first create an extended partition. Such a partition can contain other partitions.") ; str_temp += _( "If you want more partitions you should first create an extended partition. Such a partition can contain other partitions.") ;
Gtk::MessageDialog dialog( *this, os.str() ,true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); os.str("") ; Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
dialog.run(); dialog.run();
return; return;
} }
@ -879,7 +882,7 @@ void Win_GParted::activate_new()
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() ;//make sure the dialog is gone _before_ operationslist shows up (only matters if first operation)
new_count++; new_count++;
Add_Operation( GParted::CREATE, dialog.Get_New_Partition() ); Add_Operation( GParted::CREATE, dialog.Get_New_Partition() );
} }
@ -894,19 +897,25 @@ void Win_GParted::activate_delete()
//it seems best to check for this and prohibit deletion with some explanation to the user. //it seems best to check for this and prohibit deletion with some explanation to the user.
if ( selected_partition.type == GParted::LOGICAL && selected_partition .status != GParted::STAT_NEW && selected_partition.partition_number < highest_logic_busy ) if ( selected_partition.type == GParted::LOGICAL && selected_partition .status != GParted::STAT_NEW && selected_partition.partition_number < highest_logic_busy )
{ {
os << "<span weight=\"bold\" size=\"larger\">" << _( "Unable to delete partition!") << "</span>\n\n" ; str_temp = "<span weight=\"bold\" size=\"larger\">" ;
os << String::ucompose( _("Please unmount any logical partitions having a number higher than %1"), selected_partition.partition_number ) ; str_temp += _( "Unable to delete partition!") ;
Gtk::MessageDialog dialog( *this, os .str(), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); os.str(""); str_temp += "</span>\n\n" ;
str_temp += String::ucompose( _("Please unmount any logical partitions having a number higher than %1"), selected_partition.partition_number ) ;
Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
dialog.run() ; dialog.run() ;
return; return;
} }
os << "<span weight=\"bold\" size=\"larger\">" << String::ucompose( _( "Are you sure you want to delete %1 ?"), selected_partition.partition ) << "</span>" ; str_temp = "<span weight=\"bold\" size=\"larger\">" ;
str_temp += String::ucompose( _( "Are you sure you want to delete %1 ?"), selected_partition.partition ) + "</span>" ;
if ( selected_partition .partition == copied_partition .partition ) if ( selected_partition .partition == copied_partition .partition )
os << "\n\n" << _( "After deletion this partition is no longer available for copying.") ; {
str_temp += "\n\n" ;
str_temp += _( "After deletion this partition is no longer available for copying.") ;
}
Gtk::MessageDialog dialog( *this, os.str() ,true, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_NONE, true); os.str(""); Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_NONE, true);
/*TO TRANSLATORS: looks like Delete /dev/hda2 (ntfs, 2345 MB) */ /*TO TRANSLATORS: dialogtitle, looks like Delete /dev/hda2 (ntfs, 2345 MB) */
dialog .set_title( String::ucompose( _("Delete %1 (%2, %3 MB)"), selected_partition .partition, selected_partition .filesystem, selected_partition .Get_Length_MB() ) ); dialog .set_title( String::ucompose( _("Delete %1 (%2, %3 MB)"), selected_partition .partition, selected_partition .filesystem, selected_partition .Get_Length_MB() ) );
dialog.add_button( Gtk::Stock::CANCEL,Gtk::RESPONSE_CANCEL ); dialog.add_button( Gtk::Stock::CANCEL,Gtk::RESPONSE_CANCEL );
dialog.add_button( Gtk::Stock::DELETE, Gtk::RESPONSE_OK ); dialog.add_button( Gtk::Stock::DELETE, Gtk::RESPONSE_OK );
@ -968,11 +977,11 @@ void Win_GParted::activate_info()
void Win_GParted::activate_convert( const Glib::ustring & new_fs ) void Win_GParted::activate_convert( const Glib::ustring & new_fs )
{ {
//standard warning.. //standard warning..
os << "<span weight=\"bold\" size=\"larger\">" ; str_temp = "<span weight=\"bold\" size=\"larger\">" ;
os << String::ucompose( _("Are you sure you want to convert this filesystem to %1 ?"), new_fs ) << "</span>\n\n" ; str_temp += String::ucompose( _("Are you sure you want to convert this filesystem to %1 ?"), new_fs ) + "</span>\n\n" ;
os << String::ucompose( _("This operation will destroy all data on %1"), selected_partition .partition ) ; str_temp += String::ucompose( _("This operation will destroy all data on %1"), selected_partition .partition ) ;
Gtk::MessageDialog dialog( *this, os.str(), true, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_CANCEL, true); os.str(""); Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_CANCEL, true);
dialog. add_button( Gtk::Stock::CONVERT, Gtk::RESPONSE_OK ) ; dialog. add_button( Gtk::Stock::CONVERT, Gtk::RESPONSE_OK ) ;
dialog. show_all_children() ; dialog. show_all_children() ;
@ -985,18 +994,18 @@ void Win_GParted::activate_convert( const Glib::ustring & new_fs )
//check for the FAT limits... //check for the FAT limits...
if ( new_fs == "fat16" || new_fs == "fat32" ) if ( new_fs == "fat16" || new_fs == "fat32" )
{ {
Glib::ustring message ; str_temp = "" ;
if ( new_fs == "fat16" && selected_partition.Get_Length_MB() < 32 ) if ( new_fs == "fat16" && selected_partition.Get_Length_MB() < 32 )
message = (Glib::ustring) _("Can not convert this filesystem to fat16.") + "</span>\n\n" + (Glib::ustring) _( "A fat16 filesystem requires a partition of at least 32 MB.") ; str_temp = (Glib::ustring) _("Can not convert this filesystem to fat16.") + "</span>\n\n" + (Glib::ustring) _( "A fat16 filesystem requires a partition of at least 32 MB.") ;
else if ( new_fs == "fat16" && selected_partition.Get_Length_MB() > 1023 ) else if ( new_fs == "fat16" && selected_partition.Get_Length_MB() > 1023 )
message = (Glib::ustring) _("Can not convert this filesystem to fat16.") + "</span>\n\n" + (Glib::ustring) _( "A partition with a fat16 filesystem has a maximum size of 1023 MB."); str_temp = (Glib::ustring) _("Can not convert this filesystem to fat16.") + "</span>\n\n" + (Glib::ustring) _( "A partition with a fat16 filesystem has a maximum size of 1023 MB.");
else if ( new_fs == "fat32" && selected_partition.Get_Length_MB() < 256 ) else if ( new_fs == "fat32" && selected_partition.Get_Length_MB() < 256 )
message = (Glib::ustring) _("Can not convert this filesystem to fat32.") + "</span>\n\n" + (Glib::ustring) _( "A fat32 filesystem requires a partition of at least 256 MB."); str_temp = (Glib::ustring) _("Can not convert this filesystem to fat32.") + "</span>\n\n" + (Glib::ustring) _( "A fat32 filesystem requires a partition of at least 256 MB.");
if ( message != "" ) if ( ! str_temp .empty() )
{ {
Gtk::MessageDialog dialog( *this, "<span weight=\"bold\" size=\"larger\">" + message ,true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); Gtk::MessageDialog dialog( *this, "<span weight=\"bold\" size=\"larger\">" + str_temp ,true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
dialog.run() ; dialog.run() ;
return ; return ;
} }
@ -1047,7 +1056,12 @@ void Win_GParted::activate_undo()
void Win_GParted::activate_apply() void Win_GParted::activate_apply()
{ {
Gtk::MessageDialog dialog( *this, "<span weight=\"bold\" size=\"larger\">" + (Glib::ustring) _( "Are you sure you want to apply the pending operations?" ) + "</span>\n\n" + (Glib::ustring) _( "It is recommended to backup valueable data before proceeding.") ,true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE, true); str_temp = "<span weight=\"bold\" size=\"larger\">" ;
str_temp += _( "Are you sure you want to apply the pending operations?" ) ;
str_temp += "</span>\n\n" ;
str_temp += _( "It is recommended to backup valueable data before proceeding.") ;
Gtk::MessageDialog dialog( *this, str_temp,true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE, true);
dialog.set_title( _( "Apply operations to harddisk" ) ); dialog.set_title( _( "Apply operations to harddisk" ) );
dialog.add_button( Gtk::Stock::CANCEL,Gtk::RESPONSE_CANCEL ); dialog.add_button( Gtk::Stock::CANCEL,Gtk::RESPONSE_CANCEL );
@ -1083,18 +1097,22 @@ void Win_GParted::activate_apply()
//show warning if necessary //show warning if necessary
if ( devicenames .size() ) if ( devicenames .size() )
{ {
os << "<span weight=\"bold\" size=\"larger\">" ; str_temp = "<span weight=\"bold\" size=\"larger\">" ;
/*TO TRANSLATORS: after the colon (:) a list of devices will be shown */ /*TO TRANSLATORS: after the colon (:) a list of devices will be shown */
os << _("The kernel was unable to re-read the partition table on :") << "\n"; str_temp += _("The kernel was unable to re-read the partition table on :") ;
str_temp += "\n";
for (unsigned int t=0; t<devicenames .size(); t++ ) for (unsigned int t=0; t<devicenames .size(); t++ )
os << "- " << devicenames[ t ] << "\n"; str_temp += "- " + devicenames[ t ] + "\n";
os << "</span>\n\n" << _( "This means Linux won't know anything about the modifications you made until you reboot.") << "\n\n" ;
str_temp += "</span>\n\n" ;
str_temp += _( "This means Linux won't know anything about the modifications you made until you reboot.") ;
str_temp += "\n\n" ;
if ( devicenames .size() > 1 ) if ( devicenames .size() > 1 )
os << _( "You should reboot your computer before doing anything with these devices.") ; str_temp += _( "You should reboot your computer before doing anything with these devices.") ;
else else
os << _( "You should reboot your computer before doing anything with this device.") ; str_temp += _( "You should reboot your computer before doing anything with this device.") ;
Gtk::MessageDialog dialog( *this, os.str() ,true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true); os.str("") ; Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true);
dialog.run() ; dialog.run() ;
} }