enabled support for reiserfs
This commit is contained in:
parent
36e3736b2f
commit
18b47725f8
|
@ -1,3 +1,9 @@
|
|||
2004-10-06 Bart Hakvoort <gparted@users.sf.net>
|
||||
|
||||
* lots of files =) : enabled support for reiserfs, also made filesystemsupport more 'pluggable' so it's easier to
|
||||
add support for other filesystems in the future.
|
||||
* include/Utils.h: new file containing much used functions and variables.
|
||||
|
||||
2004-10-06 Francisco Javier F. Serrador <serrador@cvs.gnome.org>
|
||||
|
||||
* configure.in (ALL_LINGUAS): Added "es" (Spanish).
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
|
||||
#include <fstream>
|
||||
|
||||
|
||||
namespace GParted
|
||||
{
|
||||
|
||||
|
@ -47,7 +48,7 @@ class Device
|
|||
|
||||
public:
|
||||
Device() ;
|
||||
Device( const Glib::ustring & device_path);
|
||||
Device( const Glib::ustring & device_path, std::vector<FS> *filesystems );
|
||||
~Device() ;
|
||||
//this function creates a fresh list with al the partitions and free spaces
|
||||
void Read_Disk_Layout() ;
|
||||
|
@ -76,6 +77,7 @@ public:
|
|||
private:
|
||||
//make a try to get the amount of used sectors on a filesystem ( see comments in implementation )
|
||||
Sector Get_Used_Sectors( PedPartition *c_partition, const Glib::ustring & sym_path );
|
||||
//bool Supported( const Glib::ustring & filesystem ) ;
|
||||
|
||||
Glib::ustring Get_Flags( PedPartition *c_partition ) ;
|
||||
|
||||
|
@ -84,6 +86,7 @@ private:
|
|||
bool Resize_Extended( const Partition & partition, PedTimer *timer) ;
|
||||
|
||||
std::vector<Partition> device_partitions ;
|
||||
std::vector<FS> * FILESYSTEMS ;
|
||||
Sector length;
|
||||
long heads ;
|
||||
long sectors ;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
//my guess is, it's best to keep the amount of info minimal and wait for users requests
|
||||
|
||||
#include "../include/Partition.h"
|
||||
#include "../include/i18n.h"
|
||||
|
||||
#include <gtkmm/dialog.h>
|
||||
#include <gtkmm/stock.h>
|
||||
|
|
|
@ -30,19 +30,17 @@ class Dialog_Partition_New : public Dialog_Base_Partition
|
|||
{
|
||||
public:
|
||||
Dialog_Partition_New() ;
|
||||
void Set_Data( const Partition & partition, bool any_extended, unsigned short new_count );
|
||||
void Set_Data( const Partition & partition, bool any_extended, unsigned short new_count, const std::vector <FS> & FILESYSTEMS );
|
||||
Partition Get_New_Partition() ;//overridden function
|
||||
|
||||
private:
|
||||
void Build_Filesystems_Menu() ;
|
||||
//bool Check_Restrictions() ;
|
||||
|
||||
Gtk::Table table_create;
|
||||
Gtk::OptionMenu optionmenu_type, optionmenu_filesystem;
|
||||
Gtk::Label label_type,label_filesystem,label_start,label_size;
|
||||
Gtk::Menu menu_type, menu_filesystem;
|
||||
|
||||
std::vector <Glib::ustring> filesystems ;
|
||||
std::vector<FS> FILESYSTEMS ;
|
||||
|
||||
//signal handlers
|
||||
void optionmenu_changed( bool );
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
#include <gtkmm/stock.h>
|
||||
#include <gtkmm/label.h>
|
||||
|
||||
//compose library, dedicated to the translators :P
|
||||
#include "../compose/ucompose.hpp"
|
||||
|
||||
class Dialog_Progress : public Gtk::Dialog
|
||||
{
|
||||
|
@ -47,7 +45,6 @@ private:
|
|||
|
||||
double fraction;
|
||||
int count_operations, current_operation_number;
|
||||
char c_buf[ 1024 ] ; //used by sprintf, which is needed for i18n
|
||||
};
|
||||
|
||||
#endif //DIALOG_PARTITION_PROGRESS
|
||||
|
|
|
@ -23,57 +23,16 @@
|
|||
#ifndef PARTITION
|
||||
#define PARTITION
|
||||
|
||||
#include "../include/Utils.h"
|
||||
#include "../include/i18n.h"
|
||||
|
||||
#include <gtkmm/label.h>
|
||||
#include <glibmm/ustring.h>
|
||||
#include <gdkmm/colormap.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
|
||||
//compose library, dedicated to the translators :P
|
||||
#include "../compose/ucompose.hpp"
|
||||
|
||||
#define MEGABYTE 2048 //try it: 2048 * 512 / 1024 /1024 == 1 :P
|
||||
|
||||
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) ;
|
||||
}
|
||||
|
||||
inline long Round( double double_value )
|
||||
{
|
||||
return (long) ( double_value + 0.5) ;
|
||||
}
|
||||
|
||||
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 {
|
||||
PRIMARY = 0,
|
||||
|
@ -88,22 +47,7 @@ enum PartitionStatus {
|
|||
STAT_COPY = 3
|
||||
};
|
||||
|
||||
/*
|
||||
enum FileSystem {
|
||||
ext2 = 0,
|
||||
ext3 = 1,
|
||||
linux_swap = 2,
|
||||
reiserfs = 3,
|
||||
hfs = 4,
|
||||
jfs = 5,
|
||||
hp_ufs = 6,
|
||||
sun_ufs = 7,
|
||||
xfs = 8,
|
||||
fat16 = 9,
|
||||
fat32 = 10,
|
||||
ntfs = 11
|
||||
};
|
||||
*/
|
||||
|
||||
class Partition
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
/* Copyright (C) 2004 Bart
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* 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
|
||||
#define UTILS
|
||||
|
||||
#include <gtkmm/label.h>
|
||||
#include <glibmm/ustring.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
namespace GParted
|
||||
{
|
||||
|
||||
typedef long long Sector;
|
||||
|
||||
#define MEGABYTE 2048 //try it: 2048 * 512 / 1024 /1024 == 1 :P
|
||||
|
||||
|
||||
//struct to store filesystems
|
||||
struct FS
|
||||
{
|
||||
Glib::ustring filesystem ;
|
||||
bool supported ; //open/resize/copy
|
||||
bool create ; //create (duh =) )
|
||||
};
|
||||
|
||||
//globally used convenience functions
|
||||
inline long Sector_To_MB( Sector sectors )
|
||||
{
|
||||
return (long) ( (double) sectors * 512/1024/1024 +0.5) ;
|
||||
}
|
||||
|
||||
inline long Round( double double_value )
|
||||
{
|
||||
return (long) ( double_value + 0.5) ;
|
||||
}
|
||||
|
||||
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() ;
|
||||
}
|
||||
|
||||
inline bool Supported( const Glib::ustring & filesystem, std::vector<FS> *FILESYSTEMS )
|
||||
{
|
||||
for (unsigned int t=0 ; t < FILESYSTEMS ->size() ; t++ )
|
||||
if ( (*FILESYSTEMS)[ t ] .filesystem == filesystem && (*FILESYSTEMS)[ t ] .supported )
|
||||
return true ;
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}//GParted
|
||||
|
||||
#endif //UTILS
|
|
@ -41,7 +41,7 @@
|
|||
#include <gtkmm/liststore.h>
|
||||
#include <gtkmm/scrolledwindow.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <dlfcn.h>
|
||||
|
||||
namespace GParted
|
||||
{
|
||||
|
@ -60,6 +60,7 @@ private:
|
|||
void init_operationslist() ;
|
||||
void init_hpaned_main() ;
|
||||
|
||||
void Find_Supported_Filesystems() ;
|
||||
void Find_Devices() ;
|
||||
|
||||
//Fill txtview_device_info_buffer with some information about the selected device
|
||||
|
@ -167,8 +168,9 @@ private:
|
|||
|
||||
|
||||
GParted::Device *temp_device ;
|
||||
std::vector <Glib::ustring> str_devices, filesystems;
|
||||
std::vector <Glib::ustring> str_devices ;
|
||||
std::vector <Gtk::Label *> device_info ;
|
||||
std::vector <FS> FILESYSTEMS ;
|
||||
|
||||
//stuff for progress overview
|
||||
Dialog_Progress *dialog_progress;
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
|
||||
#ifdef ENABLE_NLS
|
||||
#include <glibmm/i18n.h>
|
||||
|
||||
//compose library, dedicated to the translators :P
|
||||
#include "../compose/ucompose.hpp"
|
||||
#endif /* ENABLE_NLS */
|
||||
|
||||
#endif /* I18N */
|
||||
|
|
|
@ -49,7 +49,7 @@ Glib::ustring get_sym_path( const Glib::ustring & real_path )
|
|||
return real_path;
|
||||
}
|
||||
|
||||
//AFAIK it's not possible to use a C++ memberfunction as a callback for a C libary function (if you know otherwise, PLEASE contact me
|
||||
//AFAIK it's not possible to use a C++ memberfunction as a callback for a C libary function (if you know otherwise, PLEASE contact me)
|
||||
Glib::ustring error_message;
|
||||
bool show_libparted_message = true ;
|
||||
PedExceptionOption PedException_Handler (PedException* ex)
|
||||
|
@ -114,10 +114,12 @@ Device::Device()
|
|||
{
|
||||
}
|
||||
|
||||
Device::Device( const Glib::ustring & device_path )
|
||||
Device::Device( const Glib::ustring & device_path, std::vector<FS> *filesystems )
|
||||
{
|
||||
ped_exception_set_handler( PedException_Handler ) ;
|
||||
|
||||
this ->FILESYSTEMS = filesystems ;
|
||||
|
||||
this ->realpath = device_path ; //this one is used by open_device_and_disk
|
||||
|
||||
this ->length = 0;//lazy check.. if something goes wrong while reading the device, length will stay zero and i will know it ( see Win_GParted::Find_Devices )
|
||||
|
@ -420,7 +422,7 @@ bool Device::Commit()
|
|||
{
|
||||
bool return_value = ped_disk_commit_to_dev( disk ) ;
|
||||
|
||||
//i don't want this annoying "warning couldn't reread blabla" message all the time. I throw one myself if necessary )
|
||||
//i don't want this annoying "warning couldn't reread blabla" message all the time. (I throw one myself if necessary)
|
||||
ped_exception_fetch_all() ;
|
||||
ped_disk_commit_to_os( disk ) ;
|
||||
ped_exception_leave_all() ;
|
||||
|
@ -513,12 +515,21 @@ Sector Device::Get_Used_Sectors( PedPartition *c_partition, const Glib::ustring
|
|||
|
||||
//METHOD #1
|
||||
//the getused method doesn't work on mounted partitions and for some filesystems ( i *guess* this is called check by andrew )
|
||||
if ( ! ped_partition_is_busy( c_partition ) && (Glib::ustring) c_partition ->fs_type ->name != "ntfs" )
|
||||
if ( ! ped_partition_is_busy( c_partition ) && Supported( c_partition ->fs_type ->name, FILESYSTEMS ) )
|
||||
{
|
||||
PedFileSystem *fs = NULL;
|
||||
PedConstraint *constraint = NULL;
|
||||
|
||||
fs = ped_file_system_open( & c_partition ->geom ); //opening a filesystem is *SLOOOWW* :-(
|
||||
//prevent messagebox from showing up, but stores the error in "error"
|
||||
if ( show_libparted_message )
|
||||
{
|
||||
show_libparted_message = false ;
|
||||
fs = ped_file_system_open( & c_partition ->geom );
|
||||
show_libparted_message = true ;
|
||||
}
|
||||
else
|
||||
fs = ped_file_system_open( & c_partition ->geom );
|
||||
|
||||
|
||||
if ( fs )
|
||||
{
|
||||
|
@ -533,7 +544,7 @@ Sector Device::Get_Used_Sectors( PedPartition *c_partition, const Glib::ustring
|
|||
}
|
||||
|
||||
//METHOD #2
|
||||
//this ony works for mounted ( and therefore known to the OS ) filesystems. My method is quite crude, keep in mind it's only temporarely ;-)
|
||||
//this ony works for mounted ( and therefore known to the OS ) filesystems. My method is quite crude, keep in mind it's only temporary ;-)
|
||||
Glib::ustring buf;
|
||||
system( ("df -k --sync " + sym_path + " | grep " + sym_path + " > /tmp/.tmp_gparted").c_str() );
|
||||
std::ifstream file_input( "/tmp/.tmp_gparted" );
|
||||
|
@ -552,6 +563,15 @@ Sector Device::Get_Used_Sectors( PedPartition *c_partition, const Glib::ustring
|
|||
return -1 ; //all methods were unsuccesfull
|
||||
|
||||
}
|
||||
/*
|
||||
bool Device::Supported( const Glib::ustring & filesystem )
|
||||
{
|
||||
for (unsigned int t=0 ; t < FILESYSTEMS ->size() ; t++ )
|
||||
if ( (*FILESYSTEMS)[ t ] .filesystem == filesystem && (*FILESYSTEMS)[ t ] .supported )
|
||||
return true ;
|
||||
|
||||
return false ;
|
||||
}*/
|
||||
|
||||
Glib::ustring Device::Get_Flags( PedPartition *c_partition )
|
||||
{
|
||||
|
|
|
@ -35,13 +35,16 @@ Dialog_Partition_New::Dialog_Partition_New( )
|
|||
frame_resizer_base ->set_x_start( 0 ) ;
|
||||
frame_resizer_base ->set_x_end( 500 ) ;
|
||||
frame_resizer_base ->set_used( 0 ) ;
|
||||
|
||||
}
|
||||
|
||||
void Dialog_Partition_New::Set_Data( const Partition & partition, bool any_extended, unsigned short new_count )
|
||||
void Dialog_Partition_New::Set_Data( const Partition & partition, bool any_extended, unsigned short new_count, const std::vector <FS> & FILESYSTEMS )
|
||||
{
|
||||
this ->new_count = new_count;
|
||||
this ->selected_partition = partition;
|
||||
this ->FILESYSTEMS = FILESYSTEMS ;
|
||||
|
||||
FS fs ; fs.filesystem = "extended" ;
|
||||
this ->FILESYSTEMS .push_back( fs ) ;
|
||||
|
||||
//add table with selection menu;s...
|
||||
table_create .set_border_width( 10 ) ;
|
||||
|
@ -49,9 +52,7 @@ void Dialog_Partition_New::Set_Data( const Partition & partition, bool any_exten
|
|||
hbox_main .pack_start( table_create, Gtk::PACK_SHRINK );
|
||||
|
||||
/*TO TRANSLATORS: used as label for a list of choices. Create as: <optionmenu with choices> */
|
||||
label_type.set_text( (Glib::ustring) _("Create as:") + "\t" );
|
||||
label_type .set_alignment( Gtk::ALIGN_LEFT ) ;
|
||||
table_create.attach( label_type, 0,1,0,1,Gtk::FILL);
|
||||
table_create.attach( * mk_label( (Glib::ustring) _("Create as:") + "\t" ), 0, 1, 0, 1, Gtk::FILL);
|
||||
|
||||
//fill partitiontype menu
|
||||
menu_type.items().push_back(Gtk::Menu_Helpers::MenuElem( _("Primary Partition") ) ) ;
|
||||
|
@ -68,7 +69,8 @@ void Dialog_Partition_New::Set_Data( const Partition & partition, bool any_exten
|
|||
else
|
||||
{
|
||||
menu_type.items()[1] .set_sensitive( false );
|
||||
if ( any_extended ) menu_type.items()[2] . set_sensitive( false );
|
||||
if ( any_extended )
|
||||
menu_type.items()[2] .set_sensitive( false );
|
||||
}
|
||||
|
||||
optionmenu_type.set_menu( menu_type );
|
||||
|
@ -77,9 +79,7 @@ void Dialog_Partition_New::Set_Data( const Partition & partition, bool any_exten
|
|||
table_create.attach( optionmenu_type, 1,2,0,1,Gtk::FILL);
|
||||
|
||||
//filesystems to choose from
|
||||
label_filesystem.set_text( (Glib::ustring) _("Filesystem:") + "\t" );
|
||||
label_filesystem .set_alignment( Gtk::ALIGN_LEFT ) ;
|
||||
table_create.attach( label_filesystem, 0,1,1,2,Gtk::FILL);
|
||||
table_create.attach( * mk_label( (Glib::ustring) _("Filesystem:") + "\t" ), 0,1,1,2,Gtk::FILL);
|
||||
|
||||
Build_Filesystems_Menu() ;
|
||||
|
||||
|
@ -136,7 +136,7 @@ Partition Dialog_Partition_New::Get_New_Partition()
|
|||
new_end = selected_partition.sector_end ;
|
||||
|
||||
part_temp .status = GParted::STAT_NEW ;
|
||||
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) ;
|
||||
part_temp .Set( String::ucompose( _("New Partition #%1"), new_count ), new_count, part_type , FILESYSTEMS[ optionmenu_filesystem.get_history() ] .filesystem, new_start, new_end, -1, selected_partition.inside_extended, false) ;
|
||||
|
||||
//grow new partition a bit if freespaces are < 1 MB
|
||||
if ( (part_temp.sector_start - selected_partition.sector_start) < MEGABYTE )
|
||||
|
@ -157,10 +157,10 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
|
|||
if (optionmenu_type.get_history() == GParted::EXTENDED )
|
||||
{
|
||||
menu_filesystem.items().push_back(Gtk::Menu_Helpers::MenuElem( "extended") ) ;
|
||||
optionmenu_filesystem.set_history( 5 ) ;
|
||||
optionmenu_filesystem.set_history( 6 ) ;
|
||||
optionmenu_filesystem.set_sensitive( false );
|
||||
}
|
||||
else if ( menu_filesystem.items() .size() > 5 )
|
||||
else if ( menu_filesystem.items() .size() > 6 )
|
||||
{
|
||||
menu_filesystem.items() .remove( menu_filesystem.items() .back() );
|
||||
optionmenu_filesystem.set_sensitive( true );
|
||||
|
@ -172,16 +172,21 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
|
|||
//optionmenu_filesystem
|
||||
if ( ! type )
|
||||
{
|
||||
selected_partition .filesystem = filesystems[ optionmenu_filesystem .get_history() ] ; //needed vor upper limit check (see also Dialog_Base_Partition::on_signal_resize )
|
||||
//needed vor upper limit check (see also Dialog_Base_Partition::on_signal_resize )
|
||||
//BART: i don't understand previous sentence, but i think this one's needed for correct color..
|
||||
selected_partition .filesystem = FILESYSTEMS[ optionmenu_filesystem .get_history() ] .filesystem ;
|
||||
|
||||
//set new spinbutton ranges
|
||||
long MIN, MAX;
|
||||
switch ( optionmenu_filesystem .get_history() )
|
||||
{
|
||||
case 1 : MIN = 32 ;
|
||||
case 2: MIN = 32 ;
|
||||
TOTAL_MB > 1023 ? MAX = 1023 : MAX = TOTAL_MB ;
|
||||
break;
|
||||
case 2 : MIN = 256 ;
|
||||
case 3: MIN = 256 ;
|
||||
MAX = TOTAL_MB ;
|
||||
break;
|
||||
case 5: MIN = 40 ;
|
||||
MAX = TOTAL_MB ;
|
||||
break;
|
||||
default: MIN = 1 ;
|
||||
|
@ -204,7 +209,7 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
|
|||
frame_resizer_base ->override_default_rgb_unused_color( color_temp );
|
||||
|
||||
//partitioncolor..
|
||||
color_temp .set( selected_partition .Get_Color( filesystems[ optionmenu_filesystem.get_history() ] ) ) ;
|
||||
color_temp .set( selected_partition .Get_Color( FILESYSTEMS[ optionmenu_filesystem.get_history() ] .filesystem ) ) ;
|
||||
frame_resizer_base ->set_rgb_partition_color( color_temp ) ;
|
||||
|
||||
frame_resizer_base ->Draw_Partition() ;
|
||||
|
@ -212,27 +217,24 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
|
|||
|
||||
void Dialog_Partition_New::Build_Filesystems_Menu()
|
||||
{
|
||||
//those filesystems can be created by libparted (NOTE: to create reiserfs you need libreiserfs, i'll look into that later )
|
||||
filesystems.push_back( "ext2" );
|
||||
filesystems.push_back( "fat16" );
|
||||
filesystems.push_back( "fat32" );
|
||||
filesystems.push_back( "linux-swap" );
|
||||
filesystems.push_back( "reiserfs" ); //libreiserfs needed
|
||||
filesystems.push_back( "extended" ); //convenient ;)
|
||||
//fill the filesystem menu with the filesystems (except for extended)
|
||||
for ( unsigned int t=0 ; t < FILESYSTEMS .size() -1 ; t++ )
|
||||
{
|
||||
menu_filesystem .items() .push_back( Gtk::Menu_Helpers::MenuElem( FILESYSTEMS[ t ] .filesystem ) ) ;
|
||||
menu_filesystem .items()[ t ] .set_sensitive( FILESYSTEMS[ t ] .create ) ;
|
||||
}
|
||||
|
||||
//fill the filesystem menu with those filesystems (except for extended)
|
||||
for ( unsigned int t=0; t< filesystems.size() -1 ; t++ )
|
||||
menu_filesystem.items().push_back(Gtk::Menu_Helpers::MenuElem( filesystems[t] ) ) ;
|
||||
|
||||
//check if selected unallocated is big enough for fat fs'es
|
||||
//check if selected unallocated is big enough for fs'es with min. size
|
||||
//fat16
|
||||
if ( this ->selected_partition .Get_Length_MB() < 32 )
|
||||
menu_filesystem.items()[ 1 ] .set_sensitive( false ) ;
|
||||
if ( this ->selected_partition .Get_Length_MB() < 256 )
|
||||
menu_filesystem .items()[ 2 ] .set_sensitive( false ) ;
|
||||
|
||||
|
||||
//disable reiserfs for the time being...
|
||||
menu_filesystem.items()[ 4 ] .set_sensitive( false ) ;
|
||||
//fat32
|
||||
if ( this ->selected_partition .Get_Length_MB() < 256 )
|
||||
menu_filesystem .items()[ 3 ] .set_sensitive( false ) ;
|
||||
//reiserfs
|
||||
if ( this ->selected_partition .Get_Length_MB() < 40 )
|
||||
menu_filesystem .items()[ 5 ] .set_sensitive( false ) ;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,9 @@ Win_GParted::Win_GParted( )
|
|||
current_device = source_device = 0 ;
|
||||
vbox_visual_disk = NULL;
|
||||
|
||||
//store filesystems in vector and find out if their respective libs are installed
|
||||
Find_Supported_Filesystems() ;
|
||||
|
||||
//locate all available devices and store them in devices vector
|
||||
Find_Devices() ;
|
||||
|
||||
|
@ -170,17 +173,9 @@ void Win_GParted::init_popupmenu()
|
|||
|
||||
void Win_GParted::init_convert_menu()
|
||||
{
|
||||
filesystems.push_back( "ext2" );
|
||||
filesystems.push_back( "fat16" );
|
||||
filesystems.push_back( "fat32" );
|
||||
filesystems.push_back( "linux-swap" );
|
||||
filesystems.push_back( "reiserfs" );
|
||||
|
||||
for ( unsigned int t=0;t < filesystems.size() ;t++ )
|
||||
for ( unsigned int t=0;t < FILESYSTEMS .size() ;t++ )
|
||||
{
|
||||
if ( filesystems[ t ] != selected_partition .filesystem )
|
||||
{
|
||||
color .set( selected_partition .Get_Color( filesystems[ t ] ) );
|
||||
color .set( selected_partition .Get_Color( FILESYSTEMS[ t ] .filesystem ) );
|
||||
hbox = manage( new Gtk::HBox() );
|
||||
|
||||
//the colored square
|
||||
|
@ -191,16 +186,11 @@ void Win_GParted::init_convert_menu()
|
|||
hbox ->pack_start( *entry, Gtk::PACK_SHRINK );
|
||||
|
||||
//the label...
|
||||
label = manage( new Gtk::Label( " " + filesystems[ t ] ) );
|
||||
label ->set_alignment( Gtk::ALIGN_LEFT );
|
||||
|
||||
hbox ->pack_start( *label, Gtk::PACK_SHRINK );
|
||||
hbox ->pack_start( * mk_label( " " + 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), filesystems[ t ] ) ) ;
|
||||
|
||||
}
|
||||
menu_convert.items() .back() .signal_activate() .connect( sigc::bind<Glib::ustring>(sigc::mem_fun(*this, &Win_GParted::activate_convert), FILESYSTEMS[ t ] .filesystem ) ) ;
|
||||
}
|
||||
|
||||
menu_convert.show_all_children() ;
|
||||
|
@ -345,6 +335,33 @@ void Win_GParted::init_hpaned_main()
|
|||
hpaned_main.pack2( *scrollwindow, true,true );
|
||||
}
|
||||
|
||||
void Win_GParted::Find_Supported_Filesystems()
|
||||
{
|
||||
FS fs;
|
||||
static void * test_handle = NULL ;
|
||||
|
||||
//built-in filesystems
|
||||
fs .supported = true ;
|
||||
fs .create = true ;
|
||||
|
||||
fs .filesystem = "ext2" ; FILESYSTEMS .push_back( fs ) ;
|
||||
fs .filesystem = "ext3" ; FILESYSTEMS .push_back( fs ) ; FILESYSTEMS .back() .create = false ;
|
||||
fs .filesystem = "fat16" ; FILESYSTEMS .push_back( fs ) ;
|
||||
fs .filesystem = "fat32" ; FILESYSTEMS .push_back( fs ) ;
|
||||
fs .filesystem = "linux-swap" ; FILESYSTEMS .push_back( fs ) ;
|
||||
|
||||
//optional filesystems (depends if fitting libary is installed)
|
||||
fs .supported = fs .create = false ;
|
||||
|
||||
fs .filesystem = "reiserfs" ; FILESYSTEMS .push_back( fs ) ;
|
||||
if ( (test_handle = dlopen("libreiserfs.so", RTLD_NOW)) )
|
||||
{
|
||||
FILESYSTEMS .back() .supported = FILESYSTEMS .back() .create = true ;
|
||||
dlclose( test_handle ) ;
|
||||
test_handle = NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
void Win_GParted::Find_Devices()
|
||||
{
|
||||
for ( unsigned int t=0;t<devices.size() ; t++ )
|
||||
|
@ -366,7 +383,7 @@ void Win_GParted::Find_Devices()
|
|||
|
||||
for ( unsigned int t=0;t<str_devices.size() ; t++ )
|
||||
{
|
||||
temp_device = new GParted::Device( str_devices[t] );
|
||||
temp_device = new GParted::Device( str_devices[t], &FILESYSTEMS );
|
||||
temp_device ->Get_Length() > 0 ? devices.push_back( temp_device ) : delete temp_device ;
|
||||
}
|
||||
|
||||
|
@ -593,12 +610,7 @@ void Win_GParted::Set_Valid_Operations()
|
|||
allow_convert( true ) ;
|
||||
|
||||
//find out if resizing/moving and copying is possible
|
||||
if ( selected_partition.filesystem == "ext2" ||
|
||||
selected_partition.filesystem == "ext3" ||
|
||||
selected_partition.filesystem == "fat16" ||
|
||||
selected_partition.filesystem == "fat32" ||
|
||||
selected_partition.filesystem == "linux-swap"
|
||||
)
|
||||
if ( Supported( selected_partition .filesystem, &FILESYSTEMS ) )
|
||||
{
|
||||
allow_resize( true ) ;
|
||||
|
||||
|
@ -625,10 +637,13 @@ 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<filesystems .size() ; t++ )
|
||||
filesystems[ t ] == selected_partition .filesystem ? menu_convert.items()[ t ] .set_sensitive( false ) : menu_convert.items()[ t ] .set_sensitive( true ) ;
|
||||
|
||||
menu_convert.items() .back() .set_sensitive( false ) ; //disable reiserfs for the time being...
|
||||
for ( unsigned int t=0;t<FILESYSTEMS .size() ; t++ )
|
||||
{
|
||||
if ( FILESYSTEMS[ t ] .filesystem == selected_partition .filesystem || ! FILESYSTEMS[ t ] .create )
|
||||
menu_convert .items()[ t ] .set_sensitive( false ) ;
|
||||
else
|
||||
menu_convert .items()[ t ] .set_sensitive( true ) ;
|
||||
}
|
||||
}
|
||||
|
||||
void Win_GParted::close_operationslist()
|
||||
|
@ -877,7 +892,7 @@ void Win_GParted::activate_new()
|
|||
}
|
||||
|
||||
Dialog_Partition_New dialog;
|
||||
dialog.Set_Data( selected_partition, any_extended, new_count ) ;
|
||||
dialog.Set_Data( selected_partition, any_extended, new_count, FILESYSTEMS ) ;
|
||||
dialog.set_transient_for( *this );
|
||||
|
||||
if ( dialog.run() == Gtk::RESPONSE_OK )
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "../include/Win_GParted.h"
|
||||
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
//initialize thread system
|
||||
|
@ -42,3 +43,5 @@ int main( int argc, char *argv[] )
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue