overloaded == and != cleanups
* include/Device.h, src/Device.cc: overloaded == and != * src/Win_GParted.cc: cleanups
This commit is contained in:
parent
ebad1f133b
commit
1906a3ece8
|
@ -1,3 +1,9 @@
|
||||||
|
2006-03-15 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||||
|
|
||||||
|
* include/Device.h,
|
||||||
|
src/Device.cc: overloaded == and !=
|
||||||
|
* src/Win_GParted.cc: cleanups
|
||||||
|
|
||||||
2006-03-15 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
2006-03-15 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||||
|
|
||||||
* src/Dialog_Partition_Info.cc,
|
* src/Dialog_Partition_Info.cc,
|
||||||
|
|
|
@ -32,8 +32,11 @@ public:
|
||||||
|
|
||||||
void add_path( const Glib::ustring & path, bool clear_paths = false ) ;
|
void add_path( const Glib::ustring & path, bool clear_paths = false ) ;
|
||||||
void add_paths( const std::vector<Glib::ustring> & paths, bool clear_paths = false ) ;
|
void add_paths( const std::vector<Glib::ustring> & paths, bool clear_paths = false ) ;
|
||||||
Glib::ustring get_path() ;
|
Glib::ustring get_path() const ;
|
||||||
std::vector<Glib::ustring> get_paths() ;
|
std::vector<Glib::ustring> get_paths() const ;
|
||||||
|
|
||||||
|
bool operator==( const Device & device ) const ;
|
||||||
|
bool operator!=( const Device & device ) const ;
|
||||||
|
|
||||||
void Reset() ;
|
void Reset() ;
|
||||||
std::vector<Partition> partitions ;
|
std::vector<Partition> partitions ;
|
||||||
|
|
|
@ -56,7 +56,7 @@ void Device::add_paths( const std::vector<Glib::ustring> & paths, bool clear_pat
|
||||||
sort_paths_and_remove_duplicates() ;
|
sort_paths_and_remove_duplicates() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::ustring Device::get_path()
|
Glib::ustring Device::get_path() const
|
||||||
{
|
{
|
||||||
if ( paths .size() > 0 )
|
if ( paths .size() > 0 )
|
||||||
return paths .front() ;
|
return paths .front() ;
|
||||||
|
@ -64,11 +64,21 @@ Glib::ustring Device::get_path()
|
||||||
return "" ;
|
return "" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Glib::ustring> Device::get_paths()
|
std::vector<Glib::ustring> Device::get_paths() const
|
||||||
{
|
{
|
||||||
return paths ;
|
return paths ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Device::operator==( const Device & device ) const
|
||||||
|
{
|
||||||
|
return this ->get_path() == device .get_path() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Device::operator!=( const Device & device ) const
|
||||||
|
{
|
||||||
|
return ! ( *this == device ) ;
|
||||||
|
}
|
||||||
|
|
||||||
void Device::sort_paths_and_remove_duplicates()
|
void Device::sort_paths_and_remove_duplicates()
|
||||||
{
|
{
|
||||||
//remove duplicates
|
//remove duplicates
|
||||||
|
|
|
@ -572,8 +572,8 @@ void Win_GParted::Refresh_Visual()
|
||||||
|
|
||||||
//make all operations visible
|
//make all operations visible
|
||||||
for ( unsigned int t = 0 ; t < operations .size(); t++ )
|
for ( unsigned int t = 0 ; t < operations .size(); t++ )
|
||||||
{ //FIXME: overload == operator for Device and use that instead of this..
|
{
|
||||||
if ( operations[ t ] .device .get_path() == devices[ current_device ] .get_path() )
|
if ( operations[ t ] .device == devices[ current_device ] )
|
||||||
operations[ t ] .Apply_Operation_To_Visual( partitions ) ;
|
operations[ t ] .Apply_Operation_To_Visual( partitions ) ;
|
||||||
|
|
||||||
treerow = *( liststore_operations ->append() );
|
treerow = *( liststore_operations ->append() );
|
||||||
|
@ -857,7 +857,7 @@ void Win_GParted::thread_refresh_devices()
|
||||||
pulse = false ;
|
pulse = false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Win_GParted::menu_gparted_refresh_devices( )
|
void Win_GParted::menu_gparted_refresh_devices()
|
||||||
{
|
{
|
||||||
pulse = true ;
|
pulse = true ;
|
||||||
thread = Glib::Thread::create( sigc::mem_fun( *this, &Win_GParted::thread_refresh_devices ), true ) ;
|
thread = Glib::Thread::create( sigc::mem_fun( *this, &Win_GParted::thread_refresh_devices ), true ) ;
|
||||||
|
@ -869,17 +869,17 @@ void Win_GParted::menu_gparted_refresh_devices( )
|
||||||
current_device = 0 ;
|
current_device = 0 ;
|
||||||
|
|
||||||
//show read-only warning if necessary
|
//show read-only warning if necessary
|
||||||
Glib::ustring readonly_paths ;
|
std::vector<Glib::ustring> readonly_paths ;
|
||||||
//FIXME: push relevant devices in vector en construct error using Glib::build_path
|
|
||||||
for ( unsigned int t = 0 ; t < devices .size() ; t++ )
|
for ( unsigned int t = 0 ; t < devices .size() ; t++ )
|
||||||
if ( devices[ t ] .readonly )
|
if ( devices[ t ] .readonly )
|
||||||
readonly_paths += "\n- " + devices[ t ] .get_path() ;
|
readonly_paths .push_back( "\n- " + devices[ t ] .get_path() ) ;
|
||||||
|
|
||||||
if ( ! readonly_paths .empty() )
|
if ( readonly_paths .size() > 0 )
|
||||||
{
|
{
|
||||||
Gtk::MessageDialog dialog(
|
Gtk::MessageDialog dialog(
|
||||||
*this,
|
*this,
|
||||||
_("The kernel is unable to re-read the partitiontables on the following devices:") + readonly_paths,
|
_("The kernel is unable to re-read the partitiontables on the following devices:") +
|
||||||
|
Glib::build_path( "", readonly_paths ),
|
||||||
false,
|
false,
|
||||||
Gtk::MESSAGE_WARNING,
|
Gtk::MESSAGE_WARNING,
|
||||||
Gtk::BUTTONS_OK,
|
Gtk::BUTTONS_OK,
|
||||||
|
@ -893,10 +893,11 @@ void Win_GParted::menu_gparted_refresh_devices( )
|
||||||
//see if there are any pending operations on non-existent devices
|
//see if there are any pending operations on non-existent devices
|
||||||
//NOTE that this isn't 100% foolproof since some stuff (e.g. sourcedevice of copy) may slip through.
|
//NOTE that this isn't 100% foolproof since some stuff (e.g. sourcedevice of copy) may slip through.
|
||||||
//but anyone who removes the sourcedevice before applying the operations gets what he/she deserves :-)
|
//but anyone who removes the sourcedevice before applying the operations gets what he/she deserves :-)
|
||||||
|
//FIXME: this actually sucks ;) see if we can use STL predicates here..
|
||||||
unsigned int i ;
|
unsigned int i ;
|
||||||
for ( unsigned int t = 0 ; t < operations .size() ; t++ )
|
for ( unsigned int t = 0 ; t < operations .size() ; t++ )
|
||||||
{//FIXME same as above, use Device::==
|
{
|
||||||
for ( i = 0 ; i < devices .size() && devices[ i ] .get_path() != operations[ t ] .device .get_path() ; i++ ) {}
|
for ( i = 0 ; i < devices .size() && devices[ i ] != operations[ t ] .device ; i++ ) {}
|
||||||
|
|
||||||
if ( i >= devices .size() )
|
if ( i >= devices .size() )
|
||||||
operations .erase( operations .begin() + t-- ) ;//decrease t bij one..
|
operations .erase( operations .begin() + t-- ) ;//decrease t bij one..
|
||||||
|
@ -1105,10 +1106,10 @@ bool Win_GParted::max_amount_prim_reached()
|
||||||
void Win_GParted::activate_resize()
|
void Win_GParted::activate_resize()
|
||||||
{
|
{
|
||||||
std::vector<Partition> partitions = devices[ current_device ] .partitions ;
|
std::vector<Partition> partitions = devices[ current_device ] .partitions ;
|
||||||
//FIXME use DEvice::==
|
|
||||||
if ( operations .size() )
|
if ( operations .size() )
|
||||||
for (unsigned int t = 0 ; t < operations .size() ; t++ )
|
for (unsigned int t = 0 ; t < operations .size() ; t++ )
|
||||||
if ( operations[ t ] .device .get_path() == devices[ current_device ] .get_path() )
|
if ( operations[ t ] .device == devices[ current_device ] )
|
||||||
operations[ t ] .Apply_Operation_To_Visual( partitions ) ;
|
operations[ t ] .Apply_Operation_To_Visual( partitions ) ;
|
||||||
|
|
||||||
Dialog_Partition_Resize_Move dialog( gparted_core .get_fs( selected_partition .filesystem ),
|
Dialog_Partition_Resize_Move dialog( gparted_core .get_fs( selected_partition .filesystem ),
|
||||||
|
|
Loading…
Reference in New Issue