moved inline Get_FS from Utils.h to GParted_Core, saves a few K in exe

* src/GParted_Core.cc,
  src/Win_GParted.cc,
  include/Utils.h,
  include/GParted_Core.h: moved inline Get_FS from Utils.h to GParted_Core, saves a few K in exe size ;)
This commit is contained in:
Bart Hakvoort 2004-12-25 21:40:18 +00:00
parent 019d15a18b
commit 2ed3e0e8c4
5 changed files with 40 additions and 36 deletions

View File

@ -1,3 +1,10 @@
2004-12-25 Bart Hakvoort <gparted@users.sf.net>
* src/GParted_Core.cc,
src/Win_GParted.cc,
include/Utils.h,
include/GParted_Core.h: moved inline Get_FS from Utils.h to GParted_Core, saves a few K in exe size ;)
2004-12-23 Bart Hakvoort <gparted@users.sf.net>
* src/GParted_Core.cc: removed sorting of detected devices. I figured we didn't need it anymore now 'deep_scan' is removed.

View File

@ -57,7 +57,8 @@ public:
bool Set_Disklabel( const Glib::ustring & device_path, const Glib::ustring & disklabel ) ;
const std::vector<FS> & get_fs( ) const ;
const std::vector<FS> & get_filesystems( ) const ;
const FS & get_fs( const Glib::ustring & filesystem ) const ;
Glib::RefPtr<Gtk::TextBuffer> get_textbuffer( ) ;
private:

View File

@ -19,7 +19,6 @@
/* UTILS
* Some stuff i need in a lot of places so i dropped in all together in one file.
* If you think this approach sucks, dont tell me, i know =)
*/
#ifndef UTILS
@ -92,7 +91,7 @@ inline Gtk::Label * mk_label( const Glib::ustring & text, bool use_markup = true
if ( text_color != "black" )
{
Gdk::Color color( text_color ) ;
label ->modify_fg( label ->get_state(), color ) ;
label ->modify_fg( label ->get_state( ), color ) ;
}
return label ;
@ -101,20 +100,9 @@ inline Gtk::Label * mk_label( const Glib::ustring & text, bool use_markup = true
inline Glib::ustring num_to_str( Sector number )
{
std::ostringstream os;
os .imbue( std::locale("") );
os .imbue( std::locale( "" ) );
os << number ;
return os .str() ;
}
inline FS Get_FS( const Glib::ustring & filesystem, const std::vector<FS> & FILESYSTEMS )
{
unsigned int t = 0 ;
for ( t = 0 ; t < FILESYSTEMS .size( ) ; t++ )
if ( FILESYSTEMS[ t ] .filesystem == filesystem )
return FILESYSTEMS[ t ] ;
return FILESYSTEMS .back( ) ;
return os .str( ) ;
}
//use http://developer.gnome.org/projects/gup/hig/2.0/design.html#Palette as a starting point..

View File

@ -330,7 +330,7 @@ bool GParted_Core::Create( const Glib::ustring & device_path, Partition & new_pa
if ( new_partition .type == GParted::EXTENDED )
return Create_Empty_Partition( device_path, new_partition ) ;
else if ( Create_Empty_Partition( device_path, new_partition, ( new_partition .Get_Length_MB( ) - Get_Cylinder_Size( device_path ) ) < Get_FS( new_partition .filesystem, FILESYSTEMS ) .MIN ) > 0 )
else if ( Create_Empty_Partition( device_path, new_partition, ( new_partition .Get_Length_MB( ) - Get_Cylinder_Size( device_path ) ) < get_fs( new_partition .filesystem ) .MIN ) > 0 )
{
set_proper_filesystem( new_partition .filesystem ) ;
@ -462,11 +462,20 @@ bool GParted_Core::Set_Disklabel( const Glib::ustring & device_path, const Glib:
return return_value ;
}
const std::vector<FS> & GParted_Core::get_fs( ) const
const std::vector<FS> & GParted_Core::get_filesystems( ) const
{
return FILESYSTEMS ;
}
const FS & GParted_Core::get_fs( const Glib::ustring & filesystem ) const
{
for ( unsigned int t = 0 ; t < FILESYSTEMS .size( ) ; t++ )
if ( FILESYSTEMS[ t ] .filesystem == filesystem )
return FILESYSTEMS[ t ] ;
return FILESYSTEMS .back( ) ;
}
Glib::RefPtr<Gtk::TextBuffer> GParted_Core::get_textbuffer( )
{
return textbuffer ;
@ -504,8 +513,8 @@ Glib::ustring GParted_Core::get_sym_path( const Glib::ustring & real_path )
void GParted_Core::Set_Used_Sectors( Partition & partition )
{
//if ( partition .filesystem == "unknown" )
if ( Get_FS( partition .filesystem, FILESYSTEMS ) .filesystem == "unknown" )
//because 'unknown' is translated we need to call get_fs instead of using partition .filesystem directly
if ( get_fs( partition .filesystem ) .filesystem == "unknown" )
partition .Set_Unused( -1 ) ;
else if ( partition .busy )
@ -522,7 +531,7 @@ void GParted_Core::Set_Used_Sectors( Partition & partition )
system( "rm -f /tmp/.tmp_gparted" );
}
else if ( Get_FS( partition .filesystem, FILESYSTEMS ) .read )
else if ( get_fs( partition .filesystem ) .read )
{
set_proper_filesystem( partition .filesystem ) ;

View File

@ -179,9 +179,9 @@ void Win_GParted::init_popupmenu()
void Win_GParted::init_convert_menu()
{
for ( unsigned int t=0; t < gparted_core .get_fs( ) .size( ) -1 ; t++ )
for ( unsigned int t=0; t < gparted_core .get_filesystems( ) .size( ) -1 ; t++ )
{
color .set( Get_Color( gparted_core .get_fs( )[ t ] .filesystem ) );
color .set( Get_Color( gparted_core .get_filesystems( )[ t ] .filesystem ) );
hbox = manage( new Gtk::HBox( ) );
//the colored square
@ -192,11 +192,11 @@ void Win_GParted::init_convert_menu()
hbox ->pack_start( *entry, Gtk::PACK_SHRINK );
//the label...
hbox ->pack_start( * mk_label( " " + gparted_core .get_fs( )[ t ] .filesystem ), Gtk::PACK_SHRINK );
hbox ->pack_start( * mk_label( " " + gparted_core .get_filesystems( )[ t ] .filesystem ), Gtk::PACK_SHRINK );
menu_item = manage( new Gtk::MenuItem( *hbox ) ) ;
menu_convert.items( ) .push_back( *menu_item );
menu_convert.items( ) .back( ) .signal_activate( ) .connect( sigc::bind<Glib::ustring>(sigc::mem_fun(*this, &Win_GParted::activate_convert), gparted_core .get_fs( )[ t ] .filesystem ) ) ;
menu_convert.items( ) .back( ) .signal_activate( ) .connect( sigc::bind<Glib::ustring>(sigc::mem_fun(*this, &Win_GParted::activate_convert), gparted_core .get_filesystems( )[ t ] .filesystem ) ) ;
}
menu_convert.show_all_children() ;
@ -591,7 +591,7 @@ void Win_GParted::Set_Valid_Operations()
//PRIMARY and LOGICAL
if ( selected_partition .type == GParted::PRIMARY || selected_partition .type == GParted::LOGICAL )
{
fs = Get_FS( selected_partition .filesystem, gparted_core .get_fs( ) ) ;
fs = gparted_core .get_fs( selected_partition .filesystem ) ;
allow_delete( true ) ;
allow_convert( true ) ;
@ -611,9 +611,9 @@ void Win_GParted::Set_Valid_Operations()
void Win_GParted::Set_Valid_Convert_Filesystems()
{
//disable conversion to the same filesystem
for ( unsigned int t = 0 ; t < gparted_core .get_fs( ) .size( ) -1 ; t++ )
for ( unsigned int t = 0 ; t < gparted_core .get_filesystems( ) .size( ) -1 ; t++ )
{
if ( gparted_core .get_fs( )[ t ] .filesystem == selected_partition .filesystem || ! gparted_core .get_fs( )[ t ] .create )
if ( gparted_core .get_filesystems( )[ t ] .filesystem == selected_partition .filesystem || ! gparted_core .get_filesystems( )[ t ] .create )
menu_convert .items( )[ t ] .set_sensitive( false ) ;
else
menu_convert .items( )[ t ] .set_sensitive( true ) ;
@ -710,11 +710,11 @@ void Win_GParted::menu_gparted_filesystems( )
Dialog_Filesystems dialog ;
dialog .set_transient_for( *this ) ;
dialog .Load_Filesystems( gparted_core .get_fs( ) ) ;
dialog .Load_Filesystems( gparted_core .get_filesystems( ) ) ;
while ( dialog .run( ) == Gtk::RESPONSE_OK )
{
gparted_core .find_supported_filesystems( ) ;
dialog .Load_Filesystems( gparted_core .get_fs( ) ) ;
dialog .Load_Filesystems( gparted_core .get_filesystems( ) ) ;
}
}
@ -848,8 +848,7 @@ void Win_GParted::activate_resize()
if ( operations[ t ] .device_path == devices[ current_device ] .path )
operations[ t ] .Apply_Operation_To_Visual( partitions ) ;
Dialog_Partition_Resize_Move dialog( Get_FS( selected_partition .filesystem, gparted_core .get_fs( ) ), devices[ current_device ] .heads * devices[ current_device ] .sectors ) ;
Dialog_Partition_Resize_Move dialog( gparted_core .get_fs( selected_partition .filesystem ), devices[ current_device ] .heads * devices[ current_device ] .sectors ) ;
if ( selected_partition .type == GParted::LOGICAL )
{
@ -897,7 +896,7 @@ void Win_GParted::activate_paste()
{
if ( ! max_amount_prim_reached( ) )
{
Dialog_Partition_Copy dialog( Get_FS( copied_partition .filesystem, gparted_core .get_fs( ) ), devices[ current_device ] .heads * devices[ current_device ] .sectors ) ;
Dialog_Partition_Copy dialog( gparted_core .get_fs( selected_partition .filesystem ), devices[ current_device ] .heads * devices[ current_device ] .sectors ) ;
copied_partition .error .clear( ) ; //we don't need the errors of the source partition.
dialog .Set_Data( selected_partition, copied_partition ) ;
dialog .set_transient_for( *this );
@ -939,7 +938,7 @@ void Win_GParted::activate_new()
if ( cylinder_size < 1 )
cylinder_size = 1 ;
dialog .Set_Data( selected_partition, any_extended, new_count, gparted_core .get_fs( ), devices [ current_device ] .readonly, cylinder_size ) ;
dialog .Set_Data( selected_partition, any_extended, new_count, gparted_core .get_filesystems( ), devices [ current_device ] .readonly, cylinder_size ) ;
dialog .set_transient_for( *this );
if ( dialog .run( ) == Gtk::RESPONSE_OK )
@ -1051,7 +1050,7 @@ void Win_GParted::activate_convert( const Glib::ustring & new_fs )
dialog .hide( ) ;//i want to be sure the dialog is gone _before_ operationslist shows up (only matters if first operation)
//check for some limits...
fs = Get_FS( new_fs, gparted_core .get_fs( ) ) ;
fs = gparted_core .get_fs( selected_partition .filesystem ) ;
if ( selected_partition .Get_Length_MB( ) < fs .MIN || ( fs .MAX && selected_partition .Get_Length_MB( ) > fs .MAX ) )
{
@ -1072,7 +1071,7 @@ void Win_GParted::activate_convert( const Glib::ustring & new_fs )
//ok we made it :P lets create an fitting partition object
Partition part_temp;
part_temp .Set( selected_partition .partition, selected_partition .partition_number, selected_partition .type, new_fs, selected_partition .sector_start, selected_partition .sector_end, /*-1,*/ selected_partition .inside_extended, false ) ;
part_temp .Set( selected_partition .partition, selected_partition .partition_number, selected_partition .type, new_fs, selected_partition .sector_start, selected_partition .sector_end, selected_partition .inside_extended, false ) ;
//if selected_partition is NEW we simply remove the NEW operation from the list and add it again with the new filesystem