From 7e4efd3c2e8dd300948e1434bb360d98f1dcc2ac Mon Sep 17 00:00:00 2001 From: Bart Hakvoort Date: Wed, 7 Dec 2005 11:21:27 +0000 Subject: [PATCH] rewrote quite some stuff to use an enum to indentify filesystems instead * rewrote quite some stuff to use an enum to indentify filesystems instead of stringcomparisons. --- ChangeLog | 5 + include/FileSystem.h | 6 +- include/GParted_Core.h | 6 +- include/Partition.h | 14 +-- include/Utils.h | 109 ++++++++++++------- include/VBox_VisualDisk.h | 2 +- include/Win_GParted.h | 2 +- include/ext2.h | 4 +- include/ext3.h | 4 +- include/fat16.h | 4 +- include/fat32.h | 4 +- include/hfs.h | 4 +- include/hfsplus.h | 4 +- include/jfs.h | 4 +- include/linux_swap.h | 4 +- include/ntfs.h | 4 +- include/reiser4.h | 4 +- include/reiserfs.h | 6 +- include/xfs.h | 4 +- src/Dialog_Filesystems.cc | 2 +- src/Dialog_Partition_Copy.cc | 4 +- src/Dialog_Partition_Info.cc | 20 ++-- src/Dialog_Partition_New.cc | 29 ++--- src/Dialog_Partition_Resize_Move.cc | 14 +-- src/GParted_Core.cc | 159 ++++++++++++++++------------ src/Operation.cc | 112 +++++++++++--------- src/Partition.cc | 9 +- src/TreeView_Detail.cc | 6 +- src/VBox_VisualDisk.cc | 43 ++++---- src/Win_GParted.cc | 55 +++++----- src/ext2.cc | 2 +- src/ext3.cc | 2 +- src/fat16.cc | 2 +- src/fat32.cc | 2 +- src/hfs.cc | 2 +- src/hfsplus.cc | 2 +- src/jfs.cc | 2 +- src/linux_swap.cc | 2 +- src/ntfs.cc | 2 +- src/reiser4.cc | 2 +- src/reiserfs.cc | 2 +- src/xfs.cc | 2 +- 42 files changed, 380 insertions(+), 291 deletions(-) diff --git a/ChangeLog b/ChangeLog index c5c0d27a..ddc07683 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-12-07 Bart Hakvoort + + * rewrote quite some stuff to use an enum to indentify filesystems + instead of stringcomparisons. + 2005-11-29 Bart Hakvoort * src/jfs.cc: fixed 'broken pipe' warning * src/fat16.cc, diff --git a/include/FileSystem.h b/include/FileSystem.h index f16b7059..49180865 100644 --- a/include/FileSystem.h +++ b/include/FileSystem.h @@ -16,8 +16,8 @@ */ -#ifndef FILESYSTEM -#define FILESYSTEM +#ifndef DEFINE_FILESYSTEM +#define DEFINE_FILESYSTEM #include "../include/Partition.h" @@ -59,4 +59,4 @@ private: } //GParted -#endif //FILESYSTEM +#endif //DEFINE_FILESYSTEM diff --git a/include/GParted_Core.h b/include/GParted_Core.h index 6ac18e4c..60be6b55 100644 --- a/include/GParted_Core.h +++ b/include/GParted_Core.h @@ -60,12 +60,12 @@ public: bool Set_Disklabel( const Glib::ustring & device_path, const Glib::ustring & disklabel ) ; const std::vector & get_filesystems( ) const ; - const FS & get_fs( const Glib::ustring & filesystem ) const ; + const FS & get_fs( GParted::FILESYSTEM filesystem ) const ; Glib::RefPtr get_textbuffer( ) ; std::vector get_disklabeltypes( ) ; private: - Glib::ustring Get_Filesystem( ) ; //temporary function.. asa new checks ripple through in libparted i'll remove it. + GParted::FILESYSTEM Get_Filesystem( ) ; //temporary function.. asa new checks ripple through in libparted i'll remove it. void set_device_partitions( Device & device ) ; void Insert_Unallocated( std::vector & partitions, Sector start, Sector end, bool inside_extended ) ; Glib::ustring get_sym_path( const Glib::ustring & real_path ) ; @@ -77,7 +77,7 @@ private: bool Resize_Normal_Using_Libparted( const Glib::ustring & device_path, const Partition & partition_old, const Partition & partition_new ) ; void Show_Error( Glib::ustring message ) ; - void set_proper_filesystem( const Glib::ustring & filesystem ) ; + void set_proper_filesystem( const FILESYSTEM & filesystem ) ; bool set_partition_type( const Glib::ustring & device_path, const Partition & partition ) ; bool wait_for_node( const Glib::ustring & node ) ; diff --git a/include/Partition.h b/include/Partition.h index 7455e8b0..acf0564e 100644 --- a/include/Partition.h +++ b/include/Partition.h @@ -24,7 +24,6 @@ #define PARTITION #include "../include/Utils.h" -#include "../include/i18n.h" #include @@ -34,11 +33,12 @@ namespace GParted { + enum PartitionType { - PRIMARY = 0, - LOGICAL = 1, - EXTENDED = 2, - UNALLOCATED = 3 + TYPE_PRIMARY = 0, + TYPE_LOGICAL = 1, + TYPE_EXTENDED = 2, + TYPE_UNALLOCATED = 3 }; enum PartitionStatus { @@ -60,7 +60,7 @@ public: void Set( const Glib::ustring & partition, const int partition_number, const PartitionType type, - const Glib::ustring & filesystem, + const FILESYSTEM filesystem, const Sector & sector_start, const Sector & sector_end, const bool inside_extended, @@ -82,7 +82,7 @@ public: int partition_number; PartitionType type;// UNALLOCATED, PRIMARY, LOGICAL, etc... PartitionStatus status; //STAT_REAL, STAT_NEW, etc.. - Glib::ustring filesystem;// ext2, ext3, ntfs, etc.... + FILESYSTEM filesystem ; Sector sector_start; Sector sector_end; Sector sectors_used; diff --git a/include/Utils.h b/include/Utils.h index 619b1b6b..081fd486 100644 --- a/include/Utils.h +++ b/include/Utils.h @@ -24,6 +24,8 @@ #ifndef UTILS #define UTILS +#include "../include/i18n.h" + #include #include @@ -37,8 +39,28 @@ typedef long long Sector; #define MEGABYTE 2048 //try it: 2048 * 512 / 1024 /1024 == 1 :P +enum FILESYSTEM +{ + FS_UNALLOCATED = 0, + FS_UNKNOWN = 1, + FS_UNFORMATTED = 2, + FS_EXTENDED = 3, + FS_EXT2 = 4, + FS_EXT3 = 5, + FS_LINUX_SWAP = 6, + FS_FAT16 = 7, + FS_FAT32 = 8, + FS_NTFS = 9, + FS_REISERFS = 10, + FS_REISER4 = 11, + FS_XFS = 12, + FS_JFS = 13, + FS_HFS = 14, + FS_HFSPLUS = 15, + FS_UFS = 16 +}; -//struct to store filesystems +//struct to store filesysteminformation struct FS { enum Support @@ -48,7 +70,7 @@ struct FS EXTERNAL = 2 }; - Glib::ustring filesystem ; + FILESYSTEM filesystem ; Support read ; //can we get the amount of used sectors? Support create ; Support grow ; @@ -70,7 +92,7 @@ struct FS //globally used convenience functions inline long Round( double double_value ) { - return static_cast ( double_value + 0.5 ) ; + return static_cast( double_value + 0.5 ) ; } inline long Sector_To_MB( Sector sectors ) @@ -107,42 +129,57 @@ inline Glib::ustring num_to_str( Sector number, bool use_C_locale = false ) } //use http://developer.gnome.org/projects/gup/hig/2.0/design.html#Palette as a starting point.. -inline Glib::ustring Get_Color( const Glib::ustring & filesystem ) +inline Glib::ustring Get_Color( FILESYSTEM filesystem ) { - //blue teints - if ( filesystem == "ext2" ) return "#9DB8D2" ; - else if ( filesystem == "ext3" ) return "#7590AE" ; - - //redbrown - else if ( filesystem == "linux-swap" ) return "#C1665A" ; - - //greenisch stuff.. - else if ( filesystem == "fat16" ) return "green" ; - else if ( filesystem == "fat32" ) return "#18D918" ; - else if ( filesystem == "ntfs" ) return "#42E5AC" ; - - //purple something.. - else if ( filesystem == "reiserfs" ) return "#ADA7C8" ; - else if ( filesystem == "reiser4" ) return "#887FA3" ; - - //darkyellow - else if ( filesystem == "xfs" ) return "#EED680" ; - - else if ( filesystem == "jfs" ) return "#E0C39E" ; - - else if ( filesystem == "hfs" ) return "#E0B6AF" ; - else if ( filesystem == "hfs+" ) return "#C0A39E" ; - - else if ( filesystem == "ufs" ) return "#D1940C" ; - - //darkgrey and ligthblue - else if ( filesystem == "---" ) return "darkgrey"; - else if ( filesystem == "extended" ) return "#7DFCFE" ; - - //unknown filesystem ( damaged, unknown or simply no filesystem ) - else return "black"; + switch( filesystem ) + { + case FS_UNALLOCATED : return "darkgrey" ; + case FS_UNKNOWN : return "black" ; + case FS_UNFORMATTED : return "black" ; + case FS_EXTENDED : return "#7DFCFE" ; + case FS_EXT2 : return "#9DB8D2" ; + case FS_EXT3 : return "#7590AE" ; + case FS_LINUX_SWAP : return "#C1665A" ; + case FS_FAT16 : return "green" ; + case FS_FAT32 : return "#18D918" ; + case FS_NTFS : return "#42E5AC" ; + case FS_REISERFS : return "#ADA7C8" ; + case FS_REISER4 : return "#887FA3" ; + case FS_XFS : return "#EED680" ; + case FS_JFS : return "#E0C39E" ; + case FS_HFS : return "#E0B6AF" ; + case FS_HFSPLUS : return "#C0A39E" ; + case FS_UFS : return "#D1940C" ; + + default : return "black" ; + } } +inline Glib::ustring Get_Filesystem_String( FILESYSTEM filesystem ) +{ + switch( filesystem ) + { + case FS_UNALLOCATED : return _("unallocated") ; + case FS_UNKNOWN : return _("unknown") ; + case FS_UNFORMATTED : return _("unformatted") ; + case FS_EXTENDED : return "extended" ; + case FS_EXT2 : return "ext2" ; + case FS_EXT3 : return "ext3" ; + case FS_LINUX_SWAP : return "linux-swap" ; + case FS_FAT16 : return "fat16" ; + case FS_FAT32 : return "fat32" ; + case FS_NTFS : return "ntfs" ; + case FS_REISERFS : return "reiserfs" ; + case FS_REISER4 : return "reiser4" ; + case FS_XFS : return "xfs" ; + case FS_JFS : return "jfs" ; + case FS_HFS : return "hfs" ; + case FS_HFSPLUS : return "hfs+" ; + case FS_UFS : return "ufs" ; + + default : return "" ; + } +} }//GParted diff --git a/include/VBox_VisualDisk.h b/include/VBox_VisualDisk.h index c0ab9487..1191c0e2 100644 --- a/include/VBox_VisualDisk.h +++ b/include/VBox_VisualDisk.h @@ -65,7 +65,7 @@ public: private: void Build_Visual_Disk( ) ; //i still dream of some fully resizeable visualdisk.... void Create_Visual_Partition( const Partition & partition ) ; - void Prepare_Legend( std::vector & legend, const std::vector & partitions ) ; + void Prepare_Legend( std::vector & legend, const std::vector & partitions ) ; void Build_Legend( ) ; //signal handlers diff --git a/include/Win_GParted.h b/include/Win_GParted.h index eb57e124..681b88f1 100644 --- a/include/Win_GParted.h +++ b/include/Win_GParted.h @@ -141,7 +141,7 @@ private: void activate_new( ); void activate_delete( ); void activate_info( ); - void activate_convert( const Glib::ustring & new_fs ); + void activate_convert( GParted::FILESYSTEM new_fs ); void activate_unmount( ) ; void activate_disklabel( ) ; diff --git a/include/ext2.h b/include/ext2.h index 9271056c..85e88f85 100644 --- a/include/ext2.h +++ b/include/ext2.h @@ -16,8 +16,8 @@ */ -#ifndef EXT2 -#define EXT2 +#ifndef DEFINE_EXT2 +#define DEFINE_EXT2 #include "../include/FileSystem.h" diff --git a/include/ext3.h b/include/ext3.h index ce645284..a025a37f 100644 --- a/include/ext3.h +++ b/include/ext3.h @@ -16,8 +16,8 @@ */ -#ifndef EXT3 -#define EXT3 +#ifndef DEFINE_EXT3 +#define DEFINE_EXT3 #include "../include/FileSystem.h" diff --git a/include/fat16.h b/include/fat16.h index 8da90a65..9b501923 100644 --- a/include/fat16.h +++ b/include/fat16.h @@ -16,8 +16,8 @@ */ -#ifndef FAT16 -#define FAT16 +#ifndef DEFINE_FAT16 +#define DEFINE_FAT16 #include "../include/FileSystem.h" diff --git a/include/fat32.h b/include/fat32.h index 62ffe656..2ad20d68 100644 --- a/include/fat32.h +++ b/include/fat32.h @@ -16,8 +16,8 @@ */ -#ifndef FAT32 -#define FAT32 +#ifndef DEFINE_FAT32 +#define DEFINE_FAT32 #include "../include/FileSystem.h" diff --git a/include/hfs.h b/include/hfs.h index 40445693..13b355f4 100644 --- a/include/hfs.h +++ b/include/hfs.h @@ -16,8 +16,8 @@ */ -#ifndef HFS -#define HFS +#ifndef DEFINE_HFS +#define DEFINE_HFS #include "../include/FileSystem.h" diff --git a/include/hfsplus.h b/include/hfsplus.h index 30bd3742..154ee4bd 100644 --- a/include/hfsplus.h +++ b/include/hfsplus.h @@ -16,8 +16,8 @@ */ -#ifndef HFSPLUS -#define HFSPLUS +#ifndef DEFINE_HFSPLUS +#define DEFINE_HFSPLUS #include "../include/FileSystem.h" diff --git a/include/jfs.h b/include/jfs.h index 7f5023a3..f82c7909 100644 --- a/include/jfs.h +++ b/include/jfs.h @@ -16,8 +16,8 @@ */ -#ifndef JFS -#define JFS +#ifndef DEFINE_JFS +#define DEFINE_JFS #include "../include/FileSystem.h" diff --git a/include/linux_swap.h b/include/linux_swap.h index b1a8e08f..14d26047 100644 --- a/include/linux_swap.h +++ b/include/linux_swap.h @@ -16,8 +16,8 @@ */ -#ifndef LINUX_SWAP -#define LINUX_SWAP +#ifndef DEFINE_LINUX_SWAP +#define DEFINE_LINUX_SWAP #include "../include/FileSystem.h" diff --git a/include/ntfs.h b/include/ntfs.h index 1c8cbe39..aea0ea01 100644 --- a/include/ntfs.h +++ b/include/ntfs.h @@ -16,8 +16,8 @@ */ -#ifndef NTFS -#define NTFS +#ifndef DEFINE_NTFS +#define DEFINE_NTFS #include "../include/FileSystem.h" diff --git a/include/reiser4.h b/include/reiser4.h index 07fcd5a0..5934b3f1 100644 --- a/include/reiser4.h +++ b/include/reiser4.h @@ -16,8 +16,8 @@ */ -#ifndef REISER4 -#define REISER4 +#ifndef DEFINE_REISER4 +#define DEFINE_REISER4 #include "../include/FileSystem.h" diff --git a/include/reiserfs.h b/include/reiserfs.h index 3c40ab79..d3eb88a2 100644 --- a/include/reiserfs.h +++ b/include/reiserfs.h @@ -16,13 +16,11 @@ */ -#ifndef REISERFS -#define REISERFS +#ifndef DEFINE_REISERFS +#define DEFINE_REISERFS #include "../include/FileSystem.h" -#include - namespace GParted { diff --git a/include/xfs.h b/include/xfs.h index e47f96e8..3fec231b 100644 --- a/include/xfs.h +++ b/include/xfs.h @@ -16,8 +16,8 @@ */ -#ifndef XFS -#define XFS +#ifndef DEFINE_XFS +#define DEFINE_XFS #include "../include/FileSystem.h" diff --git a/src/Dialog_Filesystems.cc b/src/Dialog_Filesystems.cc index 9b3f9e2c..6f385f61 100644 --- a/src/Dialog_Filesystems.cc +++ b/src/Dialog_Filesystems.cc @@ -54,7 +54,7 @@ void Dialog_Filesystems::Load_Filesystems( const std::vector< FS > & FILESYSTEMS void Dialog_Filesystems::Show_Filesystem( const FS & fs ) { treerow = *( liststore_filesystems ->append( ) ); - treerow[ treeview_filesystems_columns .filesystem ] = fs .filesystem ; + treerow[ treeview_filesystems_columns .filesystem ] = Get_Filesystem_String( fs .filesystem ) ; treerow[ treeview_filesystems_columns .create ] = render_icon( fs .create ? Gtk::Stock::APPLY : Gtk::Stock::CANCEL, Gtk::ICON_SIZE_LARGE_TOOLBAR); diff --git a/src/Dialog_Partition_Copy.cc b/src/Dialog_Partition_Copy.cc index abb300dd..85f1e5c3 100644 --- a/src/Dialog_Partition_Copy.cc +++ b/src/Dialog_Partition_Copy.cc @@ -53,7 +53,7 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons fs .MAX = ( ! fs .MAX || fs .MAX > TOTAL_MB ) ? TOTAL_MB : fs .MAX -= BUF ; - if ( fs .filesystem == "xfs" ) //bit hackisch, but most effective, since it's a unique situation + if ( fs .filesystem == GParted::FS_XFS ) //bit hackisch, but most effective, since it's a unique situation fs .MIN = copied_partition .Get_Used_MB( ) + (BUF * 2) ; else fs .MIN = COPIED_LENGTH_MB +1 ; @@ -80,7 +80,7 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons //set global selected_partition (see Dialog_Base_Partition::Get_New_Partition ) this ->selected_partition = copied_partition ; this ->selected_partition .inside_extended = selected_partition .inside_extended ; - this ->selected_partition .type = selected_partition .inside_extended ? GParted::LOGICAL : GParted::PRIMARY ; + this ->selected_partition .type = selected_partition .inside_extended ? GParted::TYPE_LOGICAL : GParted::TYPE_PRIMARY ; } Partition Dialog_Partition_Copy::Get_New_Partition( ) diff --git a/src/Dialog_Partition_Info.cc b/src/Dialog_Partition_Info.cc index 339a8045..2b6e9c5f 100644 --- a/src/Dialog_Partition_Info.cc +++ b/src/Dialog_Partition_Info.cc @@ -67,7 +67,7 @@ void Dialog_Partition_Info::drawingarea_on_realize( ) bool Dialog_Partition_Info::drawingarea_on_expose( GdkEventExpose *ev ) { - if ( partition .type != GParted::UNALLOCATED ) + if ( partition .type != GParted::TYPE_UNALLOCATED ) { //used gc ->set_foreground( color_used ); @@ -109,7 +109,7 @@ void Dialog_Partition_Info::init_drawingarea( ) //allocate some colors 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::TYPE_EXTENDED ? color_unused .set( "darkgrey" ) : color_unused .set( "white" ) ; this ->get_colormap( ) ->alloc_color( color_unused ) ; color_text .set( "black" ); this ->get_colormap( ) ->alloc_color( color_text ) ; @@ -130,7 +130,7 @@ void Dialog_Partition_Info::Display_Info( ) //filesystem table ->attach( * mk_label( "" + (Glib::ustring) _( "Filesystem:" ) + "" ) , 0, 1, top, bottom, Gtk::FILL ); - table ->attach( * mk_label( partition .filesystem ), 1, 2, top++, bottom++, Gtk::FILL); + table ->attach( * mk_label( Get_Filesystem_String( partition .filesystem ) ), 1, 2, top++, bottom++, Gtk::FILL ); //size table ->attach( * mk_label( "" + (Glib::ustring) _( "Size:" ) + "" ), 0,1,top, bottom,Gtk::FILL); @@ -139,7 +139,7 @@ void Dialog_Partition_Info::Display_Info( ) if ( partition.sectors_used != -1 ) { //calculate relative diskusage - int percent_used = Round( static_cast (partition .Get_Used_MB( ) ) / partition .Get_Length_MB( ) *100 ) ; + int percent_used = Round( static_cast(partition .Get_Used_MB( ) ) / partition .Get_Length_MB( ) *100 ) ; //used table ->attach( * mk_label( "" + (Glib::ustring) _( "Used:" ) + "" ), 0,1, top, bottom,Gtk::FILL ) ; @@ -153,7 +153,7 @@ void Dialog_Partition_Info::Display_Info( ) } //flags - if ( partition.type != GParted::UNALLOCATED ) + if ( partition.type != GParted::TYPE_UNALLOCATED ) { table ->attach( * mk_label( "" + (Glib::ustring) _( "Flags:" ) + "" ), 0, 1, top, bottom, Gtk::FILL ) ; table ->attach( * mk_label( partition .flags ), 1, 2, top++, bottom++, Gtk::FILL ) ; @@ -162,7 +162,7 @@ void Dialog_Partition_Info::Display_Info( ) //one blank line table ->attach( * mk_label( "" ), 1, 2, top++, bottom++, Gtk::FILL ) ; - if ( partition .type != GParted::UNALLOCATED && partition .status != GParted::STAT_NEW ) + if ( partition .type != GParted::TYPE_UNALLOCATED && partition .status != GParted::STAT_NEW ) { //path table ->attach( * mk_label( "" + (Glib::ustring) _( "Path:" ) + "" ), 0, 1, top, bottom, Gtk::FILL ) ; @@ -184,9 +184,9 @@ void Dialog_Partition_Info::Display_Info( ) table ->attach( * mk_label( "" + (Glib::ustring) _( "Status:" ) + "" ), 0,1, top, bottom, Gtk::FILL) ; if ( partition.busy ) str_temp = Find_Status( ) ; - else if ( partition.type == GParted::EXTENDED ) + else if ( partition.type == GParted::TYPE_EXTENDED ) str_temp = _("Not busy (There are no mounted logical partitions)" ) ; - else if ( partition.filesystem == "linux-swap" ) + else if ( partition.filesystem == GParted::FS_LINUX_SWAP ) str_temp = _("Not active" ) ; else str_temp = _("Not mounted" ) ; @@ -212,9 +212,9 @@ void Dialog_Partition_Info::Display_Info( ) Glib::ustring Dialog_Partition_Info::Find_Status( ) { - if ( partition .type == GParted::EXTENDED ) + if ( partition .type == GParted::TYPE_EXTENDED ) return _("Busy (At least one logical partition is mounted)" ) ; - else if ( partition .filesystem == "linux-swap" ) + else if ( partition .filesystem == FS_LINUX_SWAP ) return _("Active") ; //try to find the mountpoint in /proc/mounts diff --git a/src/Dialog_Partition_New.cc b/src/Dialog_Partition_New.cc index 2dc0ab3f..e22fc491 100644 --- a/src/Dialog_Partition_New.cc +++ b/src/Dialog_Partition_New.cc @@ -31,16 +31,17 @@ Dialog_Partition_New::Dialog_Partition_New( ) frame_resizer_base ->set_used( 0 ) ; } -void Dialog_Partition_New::Set_Data( const Partition & partition, bool any_extended, unsigned short new_count, const std::vector & FILESYSTEMS, bool only_unformatted, int cylinder_size ) +void Dialog_Partition_New::Set_Data( const Partition & partition, bool any_extended, unsigned short new_count, const std::vector & FILESYSTEMS, bool only_unformatted, int cylinder_size ) { this ->new_count = new_count; this ->selected_partition = partition; this ->cylinder_size = cylinder_size ; this ->FILESYSTEMS = FILESYSTEMS ; - this ->FILESYSTEMS .back( ) .filesystem = _("Unformatted") ; + this ->FILESYSTEMS .back( ) .filesystem = GParted::FS_UNFORMATTED ; this ->FILESYSTEMS .back( ) .create = GParted::FS::LIBPARTED ; - FS fs_tmp ; fs_tmp .filesystem = "extended" ; + FS fs_tmp ; + fs_tmp .filesystem = GParted::FS_EXTENDED ; this ->FILESYSTEMS .push_back( fs_tmp ) ; //add table with selection menu's... @@ -109,14 +110,16 @@ void Dialog_Partition_New::Set_Data( const Partition & partition, bool any_exten Partition Dialog_Partition_New::Get_New_Partition() { Partition part_temp ; - PartitionType part_type = GParted::UNALLOCATED; //paranoia ;P + PartitionType part_type ; Sector new_start, new_end; switch ( optionmenu_type .get_history( ) ) { - case 0: part_type = GParted::PRIMARY; break; - case 1: part_type = GParted::LOGICAL; break; - case 2: part_type = GParted::EXTENDED; break; + case 0 : part_type = GParted::TYPE_PRIMARY; break; + case 1 : part_type = GParted::TYPE_LOGICAL; break; + case 2 : part_type = GParted::TYPE_EXTENDED; break; + + default : part_type = GParted::TYPE_UNALLOCATED ; } new_start = START + (Sector) (spinbutton_before .get_value( ) * MEGABYTE) ; @@ -142,7 +145,7 @@ Partition Dialog_Partition_New::Get_New_Partition() part_temp.sector_end = selected_partition.sector_end ; //if new is extended... - if ( part_temp .type == GParted::EXTENDED ) + if ( part_temp .type == GParted::TYPE_EXTENDED ) { Partition UNALLOCATED ; UNALLOCATED .Set_Unallocated( part_temp .sector_start, part_temp .sector_end, true ) ; @@ -157,13 +160,13 @@ void Dialog_Partition_New::optionmenu_changed( bool type ) //optionmenu_type if ( type ) { - if ( optionmenu_type .get_history( ) == GParted::EXTENDED && menu_filesystem .items( ) .size( ) < FILESYSTEMS .size( ) ) + if ( optionmenu_type .get_history( ) == GParted::TYPE_EXTENDED && menu_filesystem .items( ) .size( ) < FILESYSTEMS .size( ) ) { - menu_filesystem .items( ) .push_back( Gtk::Menu_Helpers::MenuElem( "extended" ) ) ; + menu_filesystem .items( ) .push_back( Gtk::Menu_Helpers::MenuElem( Get_Filesystem_String( GParted::FS_EXTENDED ) ) ) ; optionmenu_filesystem .set_history( menu_filesystem .items( ) .size( ) -1 ) ; optionmenu_filesystem .set_sensitive( false ) ; } - else if ( optionmenu_type .get_history( ) != GParted::EXTENDED && menu_filesystem .items( ) .size( ) == FILESYSTEMS .size( ) ) + else if ( optionmenu_type .get_history( ) != GParted::TYPE_EXTENDED && menu_filesystem .items( ) .size( ) == FILESYSTEMS .size( ) ) { menu_filesystem .items( ) .remove( menu_filesystem .items( ) .back( ) ) ; optionmenu_filesystem .set_sensitive( true ) ; @@ -183,7 +186,7 @@ void Dialog_Partition_New::optionmenu_changed( bool type ) fs .MAX = ( fs .MAX && ( fs .MAX - cylinder_size ) < TOTAL_MB ) ? fs .MAX - cylinder_size : TOTAL_MB ; - frame_resizer_base ->set_size_limits( static_cast (fs .MIN / MB_PER_PIXEL), static_cast (fs .MAX / MB_PER_PIXEL) +1 ) ; + frame_resizer_base ->set_size_limits( static_cast(fs .MIN / MB_PER_PIXEL), static_cast(fs .MAX / MB_PER_PIXEL) +1 ) ; //set new spinbutton ranges spinbutton_before .set_range( 0, TOTAL_MB - fs .MIN ) ; @@ -211,7 +214,7 @@ void Dialog_Partition_New::Build_Filesystems_Menu( bool only_unformatted ) //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( ) .push_back( Gtk::Menu_Helpers::MenuElem( Get_Filesystem_String( FILESYSTEMS[ t ] .filesystem ) ) ) ; menu_filesystem .items( )[ t ] .set_sensitive( ! only_unformatted && FILESYSTEMS[ t ] .create && this ->selected_partition .Get_Length_MB() >= FILESYSTEMS[ t ] .MIN ) ; } diff --git a/src/Dialog_Partition_Resize_Move.cc b/src/Dialog_Partition_Resize_Move.cc index ea253344..5c0cdda7 100644 --- a/src/Dialog_Partition_Resize_Move.cc +++ b/src/Dialog_Partition_Resize_Move.cc @@ -33,7 +33,7 @@ void Dialog_Partition_Resize_Move::Set_Data( const Partition & selected_partitio this ->selected_partition = selected_partition ; - if ( selected_partition .type == GParted::EXTENDED ) + if ( selected_partition .type == GParted::TYPE_EXTENDED ) { Set_Resizer( true ) ; Resize_Move_Extended( partitions ) ; @@ -87,7 +87,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector = 1 && partitions[t -1].type == GParted::UNALLOCATED && ! this ->fixed_start ) + if ( t >= 1 && partitions[t -1].type == GParted::TYPE_UNALLOCATED && ! this ->fixed_start ) { previous = partitions[t -1] .sector_end - partitions[t -1] .sector_start ; START = partitions[t -1] .sector_start ; @@ -95,7 +95,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector 0 && partitions[t -1].type == GParted::UNALLOCATED ) + if ( t > 0 && partitions[t -1].type == GParted::TYPE_UNALLOCATED ) { previous = partitions[t -1].sector_end - partitions[t -1].sector_start ; START = partitions[t -1].sector_start ; @@ -166,7 +166,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector & devices ) } } -Glib::ustring GParted_Core::Get_Filesystem( ) +GParted::FILESYSTEM GParted_Core::Get_Filesystem( ) { //standard libparted filesystems.. - if ( lp_partition ->fs_type ) - return lp_partition ->fs_type ->name ; + if ( lp_partition && lp_partition ->fs_type ) + { + if ( static_cast( lp_partition ->fs_type ->name ) == "extended" ) + return GParted::FS_EXTENDED ; + else if ( static_cast( lp_partition ->fs_type ->name ) == "ext2" ) + return GParted::FS_EXT2 ; + else if ( static_cast( lp_partition ->fs_type ->name ) == "ext3" ) + return GParted::FS_EXT3 ; + else if ( static_cast( lp_partition ->fs_type ->name ) == "linux-swap" ) + return GParted::FS_LINUX_SWAP ; + else if ( static_cast( lp_partition ->fs_type ->name ) == "fat16" ) + return GParted::FS_FAT16 ; + else if ( static_cast( lp_partition ->fs_type ->name ) == "fat32" ) + return GParted::FS_FAT32 ; + else if ( static_cast( lp_partition ->fs_type ->name ) == "ntfs" ) + return GParted::FS_NTFS ; + else if ( static_cast( lp_partition ->fs_type ->name ) == "reiserfs" ) + return GParted::FS_REISERFS ; + else if ( static_cast( lp_partition ->fs_type ->name ) == "xfs" ) + return GParted::FS_XFS ; + else if ( static_cast( lp_partition ->fs_type ->name ) == "jfs" ) + return GParted::FS_JFS ; + else if ( static_cast( lp_partition ->fs_type ->name ) == "hfs" ) + return GParted::FS_HFS ; + else if ( static_cast( lp_partition ->fs_type ->name ) == "hfs+" ) + return GParted::FS_HFSPLUS ; + else if ( static_cast( lp_partition ->fs_type ->name ) == "ufs" ) + return GParted::FS_UFS ; + } + //other filesystems libparted couldn't detect (i've send patches for these filesystems to the parted guys) char buf[512] ; ped_device_open( lp_device ); //reiser4 - ped_geometry_read ( & lp_partition ->geom, buf, 128, 1) ; - strcpy( buf, strcmp( buf, "ReIsEr4" ) == 0 ? "reiser4" : "" ) ; - + ped_geometry_read( & lp_partition ->geom, buf, 128, 1 ) ; ped_device_close( lp_device ); - if ( strlen( buf ) ) - return buf ; + + if ( static_cast( buf ) == "ReIsEr4" ) + return GParted::FS_REISER4 ; //no filesystem found.... partition_temp .error = _( "Unable to detect filesystem! Possible reasons are:" ) ; @@ -167,8 +194,8 @@ Glib::ustring GParted_Core::Get_Filesystem( ) partition_temp .error += _( "The filesystem is unknown to libparted" ) ; partition_temp .error += "\n-"; partition_temp .error += _( "There is no filesystem available (unformatted)" ) ; - - return _("unknown") ; + + return GParted::FS_UNKNOWN ; } void GParted_Core::set_device_partitions( Device & device ) @@ -189,13 +216,13 @@ void GParted_Core::set_device_partitions( Device & device ) case PED_PARTITION_LOGICAL: partition_temp .Set( device .path + num_to_str( lp_partition ->num ), lp_partition ->num, - lp_partition ->type == 0 ? GParted::PRIMARY : GParted::LOGICAL , + lp_partition ->type == 0 ? GParted::TYPE_PRIMARY : GParted::TYPE_LOGICAL, Get_Filesystem( ), lp_partition ->geom .start, lp_partition ->geom .end, lp_partition ->type, ped_partition_is_busy( lp_partition ) ); - if ( partition_temp .filesystem != "linux-swap" ) + if ( partition_temp .filesystem != GParted::FS_LINUX_SWAP ) { Set_Used_Sectors( partition_temp ) ; @@ -218,8 +245,8 @@ void GParted_Core::set_device_partitions( Device & device ) case PED_PARTITION_EXTENDED: partition_temp.Set( device .path + num_to_str( lp_partition ->num ), lp_partition ->num , - GParted::EXTENDED , - "extended" , + GParted::TYPE_EXTENDED , + GParted::FS_EXTENDED , lp_partition ->geom .start , lp_partition ->geom .end , false , @@ -229,7 +256,8 @@ void GParted_Core::set_device_partitions( Device & device ) EXT_INDEX = device .device_partitions .size ( ) ; break ; - default: break; + default: + break; } //if there's an end, there's a partition ;) @@ -242,7 +270,7 @@ void GParted_Core::set_device_partitions( Device & device ) } //next partition (if any) - lp_partition = ped_disk_next_partition ( lp_disk, lp_partition ) ; + lp_partition = ped_disk_next_partition( lp_disk, lp_partition ) ; } if ( EXT_INDEX > -1 ) @@ -358,7 +386,7 @@ void GParted_Core::Apply_Operation_To_Disk( Operation & operation ) bool GParted_Core::Create( const Device & device, Partition & new_partition ) { - if ( new_partition .type == GParted::EXTENDED ) + if ( new_partition .type == GParted::TYPE_EXTENDED ) return Create_Empty_Partition( device .path, new_partition ) ; else if ( Create_Empty_Partition( device .path, new_partition, ( new_partition .Get_Length_MB( ) - device .cylsize ) < get_fs( new_partition .filesystem ) .MIN ) > 0 ) @@ -400,7 +428,7 @@ bool GParted_Core::Delete( const Glib::ustring & device_path, const Partition & if ( open_device_and_disk( device_path ) ) { - if ( partition .type == GParted::EXTENDED ) + if ( partition .type == GParted::TYPE_EXTENDED ) lp_partition = ped_disk_extended_partition( lp_disk ) ; else lp_partition = ped_disk_get_partition_by_sector( lp_disk, (partition .sector_end + partition .sector_start) / 2 ) ; @@ -415,7 +443,7 @@ bool GParted_Core::Delete( const Glib::ustring & device_path, const Partition & bool GParted_Core::Resize( const Device & device, const Partition & partition_old, const Partition & partition_new ) { - if ( partition_old .type == GParted::EXTENDED ) + if ( partition_old .type == GParted::TYPE_EXTENDED ) return Resize_Container_Partition( device .path, partition_old, partition_new, false ) ; //lazy check (only grow). it's possbile one day this should be separated in checks for grow,shrink,move .. @@ -492,7 +520,7 @@ const std::vector & GParted_Core::get_filesystems( ) const return FILESYSTEMS ; } -const FS & GParted_Core::get_fs( const Glib::ustring & filesystem ) const +const FS & GParted_Core::get_fs( GParted::FILESYSTEM filesystem ) const { for ( unsigned int t = 0 ; t < FILESYSTEMS .size( ) ; t++ ) if ( FILESYSTEMS[ t ] .filesystem == filesystem ) @@ -554,7 +582,7 @@ Glib::ustring GParted_Core::get_sym_path( const Glib::ustring & real_path ) void GParted_Core::Set_Used_Sectors( Partition & partition ) { //because 'unknown' is translated we need to call get_fs instead of using partition .filesystem directly - if ( get_fs( partition .filesystem ) .filesystem == "unknown" ) + if ( get_fs( partition .filesystem ) .filesystem == GParted::FS_UNKNOWN ) partition .Set_Unused( -1 ) ; else if ( partition .busy ) @@ -573,12 +601,16 @@ void GParted_Core::Set_Used_Sectors( Partition & partition ) else switch( get_fs( partition .filesystem ) .read ) { - case GParted::FS::EXTERNAL : set_proper_filesystem( partition .filesystem ) ; - p_filesystem ->Set_Used_Sectors( partition ) ; - break ; - case GParted::FS::LIBPARTED : LP_Set_Used_Sectors( partition ) ; - break ; - case GParted::FS::NONE : break ; + case GParted::FS::EXTERNAL : + set_proper_filesystem( partition .filesystem ) ; + p_filesystem ->Set_Used_Sectors( partition ) ; + break ; + case GParted::FS::LIBPARTED : + LP_Set_Used_Sectors( partition ) ; + break ; + + default: + partition .Set_Unused( -1 ) ; } } @@ -595,12 +627,12 @@ void GParted_Core::LP_Set_Used_Sectors( Partition & partition ) if ( fs ) { - constraint = ped_file_system_get_resize_constraint ( fs ) ; + constraint = ped_file_system_get_resize_constraint( fs ) ; if ( constraint ) { partition .Set_Unused( (partition .sector_end - partition .sector_start) - constraint ->min_size ) ; - ped_constraint_destroy ( constraint ); + ped_constraint_destroy( constraint ); } ped_file_system_close( fs ) ; @@ -622,10 +654,18 @@ int GParted_Core::Create_Empty_Partition( const Glib::ustring & device_path, Par //create new partition switch ( new_partition .type ) { - case 0 : type = PED_PARTITION_NORMAL; break ; - case 1 : type = PED_PARTITION_LOGICAL; break ; - case 2 : type = PED_PARTITION_EXTENDED; break ; - default : type = PED_PARTITION_FREESPACE; break ; //will never happen ;) + case GParted::TYPE_PRIMARY: + type = PED_PARTITION_NORMAL ; + break ; + case GParted::TYPE_LOGICAL: + type = PED_PARTITION_LOGICAL ; + break ; + case GParted::TYPE_EXTENDED: + type = PED_PARTITION_EXTENDED ; + break ; + + default : + type = PED_PARTITION_FREESPACE; } c_part = ped_partition_new( lp_disk, type, NULL, new_partition .sector_start, new_partition .sector_end ) ; @@ -670,7 +710,7 @@ bool GParted_Core::Resize_Container_Partition( const Glib::ustring & device_path if ( open_device_and_disk( device_path ) ) { - if ( partition_old .type == GParted::EXTENDED ) + if ( partition_old .type == GParted::TYPE_EXTENDED ) lp_partition = ped_disk_extended_partition( lp_disk ) ; else lp_partition = ped_disk_get_partition_by_sector( lp_disk, (partition_old .sector_end + partition_old .sector_start) / 2 ) ; @@ -763,40 +803,29 @@ void GParted_Core::Show_Error( Glib::ustring message ) gdk_threads_leave( ); } -void GParted_Core::set_proper_filesystem( const Glib::ustring & filesystem ) +void GParted_Core::set_proper_filesystem( const FILESYSTEM & filesystem ) { - //ugly, stupid, *aaargh* :-) - if ( ! p_filesystem ) delete p_filesystem ; - if ( filesystem == "ext2" ) - p_filesystem = new ext2( ) ; - else if ( filesystem == "ext3" ) - p_filesystem = new ext3( ) ; - else if ( filesystem == "fat16" ) - p_filesystem = new fat16( ) ; - else if ( filesystem == "fat32" ) - p_filesystem = new fat32( ) ; - else if ( filesystem == "hfs" ) - p_filesystem = new hfs( ) ; - else if ( filesystem == "hfs+" ) - p_filesystem = new hfsplus( ) ; - else if ( filesystem == "jfs" ) - p_filesystem = new jfs( ) ; - else if ( filesystem == "linux-swap" ) - p_filesystem = new linux_swap( ) ; - else if ( filesystem == "reiser4" ) - p_filesystem = new reiser4( ) ; - else if ( filesystem == "reiserfs" ) - p_filesystem = new reiserfs( ) ; - else if ( filesystem == "ntfs" ) - p_filesystem = new ntfs( ) ; - else if ( filesystem == "xfs" ) - p_filesystem = new xfs( ) ; - else - p_filesystem = NULL ; + switch( filesystem ) + { + case FS_EXT2 : p_filesystem = new ext2() ; break ; + case FS_EXT3 : p_filesystem = new ext3() ; break ; + case FS_LINUX_SWAP : p_filesystem = new linux_swap() ; break ; + case FS_FAT16 : p_filesystem = new fat16() ; break ; + case FS_FAT32 : p_filesystem = new fat32() ; break ; + case FS_NTFS : p_filesystem = new ntfs() ; break ; + case FS_REISERFS : p_filesystem = new reiserfs() ; break ; + case FS_REISER4 : p_filesystem = new reiser4() ; break ; + case FS_XFS : p_filesystem = new xfs() ; break ; + case FS_JFS : p_filesystem = new jfs() ; break ; + case FS_HFS : p_filesystem = new hfs() ; break ; + case FS_HFSPLUS : p_filesystem = new hfsplus() ; break ; + default : p_filesystem = NULL ; + } + if ( p_filesystem ) p_filesystem ->textbuffer = textbuffer ; } @@ -808,7 +837,7 @@ bool GParted_Core::set_partition_type( const Glib::ustring & device_path, const if ( open_device_and_disk( device_path ) ) { - PedFileSystemType * fs_type = ped_file_system_type_get( partition .filesystem .c_str() ) ; + PedFileSystemType * fs_type = ped_file_system_type_get( Get_Filesystem_String( partition .filesystem ) .c_str() ) ; //default is Linux (83) if ( ! fs_type ) diff --git a/src/Operation.cc b/src/Operation.cc index 138bbe7d..c0ba01f6 100644 --- a/src/Operation.cc +++ b/src/Operation.cc @@ -42,52 +42,64 @@ Glib::ustring Operation::Get_String( ) switch ( operationtype ) { - case DELETE : if (partition_original.type == GParted::LOGICAL) - temp = _("Logical Partition") ; - else - temp = partition_original .partition ; + case DELETE : + if (partition_original.type == GParted::TYPE_LOGICAL) + temp = _("Logical Partition") ; + else + temp = partition_original .partition ; - /*TO TRANSLATORS: looks like Delete /dev/hda2 (ntfs, 2345 MB) from /dev/hda */ - return String::ucompose( _("Delete %1 (%2, %3 MB) from %4"), temp, partition_original .filesystem, partition_original .Get_Length_MB( ), device .path ) ; + /*TO TRANSLATORS: looks like Delete /dev/hda2 (ntfs, 2345 MB) from /dev/hda */ + return String::ucompose( _("Delete %1 (%2, %3 MB) from %4"), temp, partition_original .filesystem, partition_original .Get_Length_MB( ), device .path ) ; - case CREATE : switch( partition_new.type ) - { - case GParted::PRIMARY : temp = _("Primary Partition"); break; - case GParted::LOGICAL : temp = _("Logical Partition") ; break; - case GParted::EXTENDED : temp = _("Extended Partition"); break; - default : break; - } - /*TO TRANSLATORS: looks like Create Logical Partition #1 (ntfs, 2345 MB) on /dev/hda */ - return String::ucompose( _("Create %1 #%2 (%3, %4 MB) on %5"), temp, partition_new.partition_number, partition_new.filesystem , partition_new .Get_Length_MB( ), device .path ) ; - case RESIZE_MOVE: //if startsector has changed >= 1 MB we consider it a move - diff = std::abs( partition_new .sector_start - partition_original .sector_start ) ; - if ( diff >= MEGABYTE ) - { - if ( partition_new .sector_start > partition_original .sector_start ) - temp = String::ucompose( _("Move %1 forward by %2 MB"), partition_new.partition, Sector_To_MB( diff ) ) ; - else - temp = String::ucompose( _("Move %1 backward by %2 MB"), partition_new.partition, Sector_To_MB( diff ) ) ; - } + case CREATE : + switch( partition_new.type ) + { + case GParted::TYPE_PRIMARY : temp = _("Primary Partition"); break; + case GParted::TYPE_LOGICAL : temp = _("Logical Partition") ; break; + case GParted::TYPE_EXTENDED : temp = _("Extended Partition"); break; + + default : break; + } + /*TO TRANSLATORS: looks like Create Logical Partition #1 (ntfs, 2345 MB) on /dev/hda */ + return String::ucompose( _("Create %1 #%2 (%3, %4 MB) on %5"), temp, partition_new.partition_number, partition_new.filesystem , partition_new .Get_Length_MB( ), device .path ) ; + + case RESIZE_MOVE: + //if startsector has changed >= 1 MB we consider it a move + diff = std::abs( partition_new .sector_start - partition_original .sector_start ) ; + if ( diff >= MEGABYTE ) + { + if ( partition_new .sector_start > partition_original .sector_start ) + temp = String::ucompose( _("Move %1 forward by %2 MB"), partition_new.partition, Sector_To_MB( diff ) ) ; + else + temp = String::ucompose( _("Move %1 backward by %2 MB"), partition_new.partition, Sector_To_MB( diff ) ) ; + } - //check if size has changed ( we only consider changes >= 1 MB ) - diff = std::abs( (partition_original .sector_end - partition_original .sector_start) - (partition_new .sector_end - partition_new .sector_start) ) ; + //check if size has changed ( we only consider changes >= 1 MB ) + diff = std::abs( (partition_original .sector_end - partition_original .sector_start) - (partition_new .sector_end - partition_new .sector_start) ) ; - if ( diff >= MEGABYTE ) - { - if ( temp .empty( ) ) - temp = String::ucompose( _("Resize %1 from %2 MB to %3 MB"), partition_new.partition, partition_original .Get_Length_MB(), partition_new .Get_Length_MB() ) ; - else - temp += " " + String::ucompose( _("and Resize %1 from %2 MB to %3 MB"), partition_new.partition, partition_original .Get_Length_MB(), partition_new .Get_Length_MB() ) ; - } - if ( temp .empty( ) ) - temp = _("Sorry, changes are too small to make sense"); + if ( diff >= MEGABYTE ) + { + if ( temp .empty( ) ) + temp = String::ucompose( _("Resize %1 from %2 MB to %3 MB"), partition_new.partition, partition_original .Get_Length_MB(), partition_new .Get_Length_MB() ) ; + else + temp += " " + String::ucompose( _("and Resize %1 from %2 MB to %3 MB"), partition_new.partition, partition_original .Get_Length_MB(), partition_new .Get_Length_MB() ) ; + } + + if ( temp .empty( ) ) + temp = _("Sorry, changes are too small to make sense"); - return temp; - case CONVERT : /*TO TRANSLATORS: looks like Convert /dev/hda4 from ntfs to linux-swap */ - return String::ucompose( _( "Convert %1 from %2 to %3"), partition_original .partition, partition_original .filesystem, partition_new .filesystem ) ; - case COPY : /*TO TRANSLATORS: looks like Copy /dev/hda4 to /dev/hdd (start at 2500 MB) */ - return String::ucompose( _("Copy %1 to %2 (start at %3 MB)"), partition_new .partition, device .path, Sector_To_MB( partition_new .sector_start ) ) ; - default : return ""; + return temp; + + case CONVERT : + /*TO TRANSLATORS: looks like Convert /dev/hda4 from ntfs to linux-swap */ + return String::ucompose( _( "Convert %1 from %2 to %3"), partition_original .partition, partition_original .filesystem, partition_new .filesystem ) ; + + case COPY : + /*TO TRANSLATORS: looks like Copy /dev/hda4 to /dev/hdd (start at 2500 MB) */ + return String::ucompose( _("Copy %1 to %2 (start at %3 MB)"), partition_new .partition, device .path, Sector_To_MB( partition_new .sector_start ) ) ; + + default : + return ""; } } @@ -151,15 +163,15 @@ void Operation::Insert_Unallocated( std::vector & partitions, Sector int Operation::Get_Index_Original( std::vector & partitions ) { - for ( int t = 0 ; t < static_cast ( partitions .size( ) ) ; t++ ) + for ( int t = 0 ; t < static_cast( partitions .size( ) ) ; t++ ) if ( partition_original .sector_start >= partitions[ t ] .sector_start && partition_original .sector_end <= partitions[ t ] .sector_end ) { //remove unallocated space preceding the original partition - if ( t -1 >= 0 && partitions[ t -1 ] .type == GParted::UNALLOCATED ) + if ( t -1 >= 0 && partitions[ t -1 ] .type == GParted::TYPE_UNALLOCATED ) partitions .erase( partitions .begin( ) + --t ); //remove unallocated space following the original partition - if ( t +1 < static_cast ( partitions .size( ) ) && partitions[ t +1 ] .type == GParted::UNALLOCATED ) + if ( t +1 < static_cast( partitions .size( ) ) && partitions[ t +1 ] .type == GParted::TYPE_UNALLOCATED ) partitions .erase( partitions .begin( ) + t +1 ); return t ; @@ -179,7 +191,7 @@ void Operation::Apply_Delete_To_Visual( std::vector & partitions ) else { unsigned int ext = 0 ; - while ( ext < partitions .size( ) && partitions[ ext ] .type != GParted::EXTENDED ) ext++ ; + while ( ext < partitions .size( ) && partitions[ ext ] .type != GParted::TYPE_EXTENDED ) ext++ ; partitions[ ext ] .logicals .erase( partitions[ ext ] .logicals .begin( ) + Get_Index_Original( partitions[ ext ] .logicals ) ); @@ -205,7 +217,7 @@ void Operation::Apply_Create_To_Visual( std::vector & partitions ) else { unsigned int ext = 0 ; - while ( ext < partitions .size( ) && partitions[ ext ] .type != GParted::EXTENDED ) ext++ ; + while ( ext < partitions .size( ) && partitions[ ext ] .type != GParted::TYPE_EXTENDED ) ext++ ; partitions[ ext ] .logicals[ Get_Index_Original( partitions[ ext ] .logicals ) ] = partition_new ; Insert_Unallocated( partitions[ ext ] .logicals, partitions[ ext ] .sector_start, partitions[ ext ] .sector_end, true ) ; @@ -214,7 +226,7 @@ void Operation::Apply_Create_To_Visual( std::vector & partitions ) void Operation::Apply_Resize_Move_To_Visual( std::vector & partitions) { - if ( partition_original .type == GParted::EXTENDED ) + if ( partition_original .type == GParted::TYPE_EXTENDED ) Apply_Resize_Move_Extended_To_Visual( partitions ) ; else Apply_Create_To_Visual( partitions ) ; @@ -231,12 +243,12 @@ void Operation::Apply_Resize_Move_Extended_To_Visual( std::vector & p //stuff INSIDE extended partition ext = 0 ; - while ( ext < partitions .size( ) && partitions[ ext ] .type != GParted::EXTENDED ) ext++ ; + while ( ext < partitions .size( ) && partitions[ ext ] .type != GParted::TYPE_EXTENDED ) ext++ ; - if ( partitions[ ext ] .logicals .size( ) && partitions[ ext ] .logicals .front( ) .type == GParted::UNALLOCATED ) + if ( partitions[ ext ] .logicals .size( ) && partitions[ ext ] .logicals .front( ) .type == GParted::TYPE_UNALLOCATED ) partitions[ ext ] .logicals .erase( partitions[ ext ] .logicals .begin( ) ) ; - if ( partitions[ ext ] .logicals .size( ) && partitions[ ext ] .logicals .back( ) .type == GParted::UNALLOCATED ) + if ( partitions[ ext ] .logicals .size( ) && partitions[ ext ] .logicals .back( ) .type == GParted::TYPE_UNALLOCATED ) partitions[ ext ] .logicals .erase( partitions[ ext ] .logicals .end( ) -1 ) ; Insert_Unallocated( partitions[ ext ] .logicals, partitions[ ext ] .sector_start, partitions[ ext ] .sector_end, true ) ; diff --git a/src/Partition.cc b/src/Partition.cc index f1290ee2..0edd8a59 100644 --- a/src/Partition.cc +++ b/src/Partition.cc @@ -27,9 +27,10 @@ Partition::Partition( ) void Partition::Reset( ) { - partition = filesystem = error = flags = "" ; + partition = error = flags = "" ; status = GParted::STAT_REAL ; - type = GParted::UNALLOCATED ; + type = GParted::TYPE_UNALLOCATED ; + filesystem = GParted::FS_UNALLOCATED ; partition_number = sector_start = sector_end = sectors_used = sectors_unused = -1; color .set( "black" ) ; inside_extended = busy = false ; @@ -39,7 +40,7 @@ void Partition::Reset( ) void Partition::Set( const Glib::ustring & partition, const int partition_number, const PartitionType type, - const Glib::ustring & filesystem, + const FILESYSTEM filesystem, const Sector & sector_start, const Sector & sector_end, const bool inside_extended, @@ -67,7 +68,7 @@ void Partition::Set_Unused( Sector sectors_unused ) void Partition::Set_Unallocated( Sector sector_start, Sector sector_end, bool inside_extended ) { - this ->Set( _("Unallocated"), -1, GParted::UNALLOCATED, "---", sector_start, sector_end , inside_extended, false ); + this ->Set( Get_Filesystem_String( GParted::FS_UNALLOCATED ), -1, GParted::TYPE_UNALLOCATED, GParted::FS_UNALLOCATED, sector_start, sector_end, inside_extended, false ); this ->error = this ->flags = "" ; this ->status = GParted::STAT_REAL ; } diff --git a/src/TreeView_Detail.cc b/src/TreeView_Detail.cc index d9d8e24d..deaac9ac 100644 --- a/src/TreeView_Detail.cc +++ b/src/TreeView_Detail.cc @@ -79,7 +79,7 @@ void TreeView_Detail::Load_Partitions( const std::vector & partitions row = *( treestore_detail ->append( ) ); Create_Row( row, partitions[ i ] ); - if ( partitions[ i ] .type == GParted::EXTENDED ) + if ( partitions[ i ] .type == GParted::TYPE_EXTENDED ) { for ( unsigned int t = 0 ; t < partitions[ i ] .logicals .size( ) ; t++ ) { @@ -146,8 +146,8 @@ void TreeView_Detail::Create_Row( const Gtk::TreeRow & treerow, const Partition treerow[ treeview_detail_columns .partition ] = partition .partition; treerow[ treeview_detail_columns .color ] = Get_Color( partition .filesystem ) ; - treerow[ treeview_detail_columns .text_color ] = ( partition .type == GParted::UNALLOCATED ) ? "darkgrey" : "black" ; - treerow[ treeview_detail_columns .type ] = partition .filesystem ; + treerow[ treeview_detail_columns .text_color ] = ( partition .type == GParted::TYPE_UNALLOCATED ) ? "darkgrey" : "black" ; + treerow[ treeview_detail_columns .type ] = Get_Filesystem_String( partition .filesystem ) ; treerow[ treeview_detail_columns .type_square ] = "██" ; //size diff --git a/src/VBox_VisualDisk.cc b/src/VBox_VisualDisk.cc index 35624bf6..a7aa1d45 100644 --- a/src/VBox_VisualDisk.cc +++ b/src/VBox_VisualDisk.cc @@ -54,9 +54,9 @@ VBox_VisualDisk::VBox_VisualDisk( const std::vector & partitions, con { double width = static_cast (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::TYPE_PRIMARY || partitions[ t ] .type == GParted::TYPE_LOGICAL) && width < 20 ) extra_pixels += (20 - width) ; - else if ( partitions[ t ] .type == GParted::UNALLOCATED && width < 15 ) + else if ( partitions[ t ] .type == GParted::TYPE_UNALLOCATED && width < 15 ) extra_pixels += (15 - width) ; } @@ -84,7 +84,7 @@ void VBox_VisualDisk::Build_Visual_Disk( ) { Create_Visual_Partition( partitions[ i ] ) ; - if ( partitions[ i ].type != GParted::EXTENDED ) + if ( partitions[ i ].type != GParted::TYPE_EXTENDED ) hbox_disk ->pack_start( *( visual_partitions .back( ) ->drawingarea ), Gtk::PACK_SHRINK ) ; } @@ -100,7 +100,7 @@ void VBox_VisualDisk::Create_Visual_Partition( const Partition & partition ) visual_partitions .back( ) ->index = visual_partitions .size( ) -1 ; // <---- BELACHELIJK!! DOE DAAR IETS AAN!!! visual_partitions .back( ) ->sector_start = partition .sector_start ; - if ( partition .type == GParted::EXTENDED ) + if ( partition .type == GParted::TYPE_EXTENDED ) { visual_partitions.back( ) ->drawingarea = NULL ;//it's just a dummy ;-) ( see Set_Selected() ) visual_partitions.back( ) ->length = 0 ; //keeps total_length clean @@ -124,9 +124,9 @@ void VBox_VisualDisk::Create_Visual_Partition( const Partition & partition ) return ; } - visual_partitions .back( ) ->length = static_cast ( SCREEN_WIDTH / ( device_length / static_cast (partition .sector_end - partition .sector_start) ) ); + visual_partitions .back( ) ->length = static_cast ( SCREEN_WIDTH / ( device_length / static_cast(partition .sector_end - partition .sector_start) ) ); if ( visual_partitions .back( ) ->length < 20 )//we need a min. size. Otherwise some small partitions wouldn't be visible - visual_partitions .back( ) ->length = ( partition .type == GParted::UNALLOCATED ) ? 15 : 20 ; + visual_partitions .back( ) ->length = ( partition .type == GParted::TYPE_UNALLOCATED ) ? 15 : 20 ; if ( partition .inside_extended ) { @@ -139,10 +139,10 @@ void VBox_VisualDisk::Create_Visual_Partition( const Partition & partition ) visual_partitions .back( ) ->text_y = 15 ; } - if ( partition .type == GParted::UNALLOCATED ) + if ( partition .type == GParted::TYPE_UNALLOCATED ) visual_partitions .back( ) ->used = -1; else - visual_partitions .back( ) ->used = static_cast ( (visual_partitions .back( ) ->length - (BORDER *2)) / ( static_cast (partition .sector_end - partition .sector_start) / partition .sectors_used ) ); + visual_partitions .back( ) ->used = static_cast( (visual_partitions .back( ) ->length - (BORDER *2)) / ( static_cast(partition .sector_end - partition .sector_start) / partition .sectors_used ) ); visual_partitions.back( ) ->color_fs = partition .color; this ->get_colormap( ) ->alloc_color( visual_partitions .back( ) ->color_fs ); @@ -156,7 +156,7 @@ void VBox_VisualDisk::Create_Visual_Partition( const Partition & partition ) visual_partitions .back( ) ->drawingarea ->signal_realize( ) .connect( sigc::bind(sigc::mem_fun(*this, &VBox_VisualDisk::drawingarea_on_realize), visual_partitions .back( ) ) ); visual_partitions .back( ) ->drawingarea ->signal_expose_event( ) .connect( sigc::bind(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 str_temp = partition .partition + "\n" + String::ucompose( _("%1 MB"), partition .Get_Length_MB( ) ) ; visual_partitions .back( ) ->pango_layout = visual_partitions .back( ) ->drawingarea ->create_pango_layout ( str_temp ) ; @@ -166,22 +166,22 @@ void VBox_VisualDisk::Create_Visual_Partition( const Partition & partition ) //tooltip str_temp = "" ; - if ( partition .type != GParted::UNALLOCATED ) - str_temp = partition .filesystem + "\n" ; + if ( partition .type != GParted::TYPE_UNALLOCATED ) + str_temp = Get_Filesystem_String( partition .filesystem ) + "\n" ; str_temp += partition .partition + "\n" + String::ucompose( _("%1 MB"), partition .Get_Length_MB( ) ) ; tooltips .set_tip( *( visual_partitions.back( ) ->drawingarea ), str_temp ) ; } -void VBox_VisualDisk::Prepare_Legend( std::vector & legend, const std::vector & partitions ) +void VBox_VisualDisk::Prepare_Legend( std::vector & legend, const std::vector & partitions ) { for ( unsigned int t = 0 ; t < partitions .size( ) ; t++ ) { if ( std::find( legend .begin( ), legend .end( ), partitions[ t ] .filesystem ) == legend .end( ) ) - legend .push_back( partitions[ t ] .filesystem ); + legend .push_back( partitions[ t ] .filesystem ); - if ( partitions[ t ] .type == GParted::EXTENDED ) - Prepare_Legend( legend, partitions[ t ] .logicals ) ; + if ( partitions[ t ] .type == GParted::TYPE_EXTENDED ) + Prepare_Legend( legend, partitions[ t ] .logicals ) ; } } @@ -196,13 +196,13 @@ void VBox_VisualDisk::Build_Legend( ) frame_disk_legend ->add( *hbox_legend ) ; this ->pack_start( hbox_legend_main ); - std::vector legend ; + std::vector legend ; Prepare_Legend( legend, partitions ) ; bool hide_used_unused = true; for ( unsigned int t = 0 ; t < legend .size( ) ; t++ ) { - if ( legend[ t ] != "---" && legend[ t ] != "extended" && legend[ t ] != "linux-swap" ) + if ( legend[ t ] != GParted::FS_UNALLOCATED && legend[ t ] != GParted::FS_EXTENDED && legend[ t ] != GParted::FS_LINUX_SWAP ) hide_used_unused = false ; if ( t ) @@ -212,13 +212,13 @@ void VBox_VisualDisk::Build_Legend( ) hbox_legend ->pack_start( * mk_label( "██ ", false, false, false, Get_Color( legend[ t ] ) ), Gtk::PACK_SHRINK ); - if ( legend[ t ] == "---" ) + if ( legend[ t ] == GParted::FS_UNALLOCATED ) { - str_temp = _("unallocated") ; + str_temp = Get_Filesystem_String( GParted::FS_UNALLOCATED ) ;//_("unallocated") ; hbox_legend ->pack_start( * mk_label( str_temp + " " ), Gtk::PACK_SHRINK ); } else - hbox_legend ->pack_start( * mk_label( legend[ t ] + " " ), Gtk::PACK_SHRINK ); + hbox_legend ->pack_start( * mk_label( Get_Filesystem_String( legend[ t ] ) + " " ), Gtk::PACK_SHRINK ); } //if there are any partitions add used/unused @@ -248,7 +248,7 @@ void VBox_VisualDisk::Set_Selected( const Partition & partition ) if ( temp >= 0 ) //prevent segfault at firsttime selection drawingarea_on_expose( NULL, visual_partitions[ temp ] ) ; - if ( partition.type == GParted::EXTENDED ) + if ( partition.type == GParted::TYPE_EXTENDED ) return; //extended can not be selected in visualdisk (yet ) //now set new selected one @@ -271,7 +271,6 @@ void VBox_VisualDisk::drawingarea_on_realize( Visual_Partition* vp ) //eventmasks necessary for tooltips vp ->drawingarea ->add_events( Gdk::ENTER_NOTIFY_MASK ); vp ->drawingarea ->add_events( Gdk::LEAVE_NOTIFY_MASK ); - } bool VBox_VisualDisk::drawingarea_on_expose( GdkEventExpose * ev, Visual_Partition* vp ) diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc index ea39284b..ee79c3cb 100644 --- a/src/Win_GParted.cc +++ b/src/Win_GParted.cc @@ -208,11 +208,11 @@ void Win_GParted::init_convert_menu() hbox ->pack_start( *entry, Gtk::PACK_SHRINK ); //the label... - hbox ->pack_start( * mk_label( " " + gparted_core .get_filesystems( )[ t ] .filesystem ), Gtk::PACK_SHRINK ); + hbox ->pack_start( * mk_label( " " + Get_Filesystem_String( 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(sigc::mem_fun(*this, &Win_GParted::activate_convert), gparted_core .get_filesystems( )[ t ] .filesystem ) ) ; + menu_convert.items( ) .back( ) .signal_activate( ) .connect( sigc::bind(sigc::mem_fun(*this, &Win_GParted::activate_convert), gparted_core .get_filesystems( )[ t ] .filesystem ) ) ; } menu_convert.show_all_children() ; @@ -513,13 +513,18 @@ void Win_GParted::Refresh_Visual( ) switch ( partitions[ t ] .type ) { - case GParted::PRIMARY : primary_count++; - break; - case GParted::EXTENDED : any_extended = true; - primary_count++; - any_logic = partitions[ t ] .logicals .size( ) -1 ; - break; - default : break; + case GParted::TYPE_PRIMARY : + primary_count++; + break; + + case GParted::TYPE_EXTENDED : + any_extended = true; + primary_count++; + any_logic = partitions[ t ] .logicals .size( ) -1 ; + break; + + default : + break; } } @@ -580,14 +585,14 @@ void Win_GParted::Set_Valid_Operations( ) //only unmount is allowed if ( selected_partition .busy ) { - if ( selected_partition .filesystem != "linux-swap" && selected_partition .type != GParted::EXTENDED ) + if ( selected_partition .filesystem != GParted::FS_LINUX_SWAP && selected_partition .type != GParted::TYPE_EXTENDED ) allow_unmount( true ) ; return; } //UNALLOCATED - if ( selected_partition .type == GParted::UNALLOCATED ) + if ( selected_partition .type == GParted::TYPE_UNALLOCATED ) { allow_new( true ); @@ -595,7 +600,7 @@ void Win_GParted::Set_Valid_Operations( ) if ( ! copied_partition .partition .empty( ) && ! devices[ current_device ] .readonly ) { if ( (copied_partition .Get_Length_MB( ) + devices[ current_device ] .cylsize) < selected_partition .Get_Length_MB( ) || - (copied_partition .filesystem == "xfs" && (copied_partition .Get_Used_MB( ) + devices[ current_device ] .cylsize) < selected_partition .Get_Length_MB( ) ) + (copied_partition .filesystem == GParted::FS_XFS && (copied_partition .Get_Used_MB( ) + devices[ current_device ] .cylsize) < selected_partition .Get_Length_MB( ) ) ) allow_paste( true ) ; } @@ -604,7 +609,7 @@ void Win_GParted::Set_Valid_Operations( ) } //EXTENDED - if ( selected_partition .type == GParted::EXTENDED ) + if ( selected_partition .type == GParted::TYPE_EXTENDED ) { if ( ! any_logic ) //deletion is only allowed when there are no logical partitions inside. allow_delete( true ) ; @@ -616,7 +621,7 @@ void Win_GParted::Set_Valid_Operations( ) } //PRIMARY and LOGICAL - if ( selected_partition .type == GParted::PRIMARY || selected_partition .type == GParted::LOGICAL ) + if ( selected_partition .type == GParted::TYPE_PRIMARY || selected_partition .type == GParted::TYPE_LOGICAL ) { fs = gparted_core .get_fs( selected_partition .filesystem ) ; @@ -892,7 +897,7 @@ void Win_GParted::mouse_click( GdkEventButton *event, const Partition & partitio else if ( event ->button == 3 ) //right-click { //prepare convert menu - if ( selected_partition .type != GParted::UNALLOCATED ) + if ( selected_partition .type != GParted::TYPE_UNALLOCATED ) Set_Valid_Convert_Filesystems( ) ; menu_partition .popup( event ->button, event ->time ); @@ -920,7 +925,7 @@ bool Win_GParted::max_amount_prim_reached( ) void Win_GParted::activate_resize( ) { //show warning when one tries to resize a fat16 filesystem - if ( selected_partition .filesystem == "fat16" ) + if ( selected_partition .filesystem == GParted::FS_FAT16 ) { str_temp = "" ; str_temp += _( "Are you sure you want to resize/move this partition?" ) ; @@ -954,10 +959,10 @@ void Win_GParted::activate_resize( ) Dialog_Partition_Resize_Move dialog( gparted_core .get_fs( selected_partition .filesystem ), devices[ current_device ] .cylsize ) ; - if ( selected_partition .type == GParted::LOGICAL ) + if ( selected_partition .type == GParted::TYPE_LOGICAL ) { unsigned int ext = 0 ; - while ( ext < partitions .size( ) && partitions[ ext ] .type != GParted::EXTENDED ) ext++ ; + while ( ext < partitions .size( ) && partitions[ ext ] .type != GParted::TYPE_EXTENDED ) ext++ ; dialog .Set_Data( selected_partition, partitions[ ext ] .logicals ); } else @@ -970,7 +975,7 @@ void Win_GParted::activate_resize( ) dialog .hide( ) ;//i want to be sure the dialog is gone _before_ operationslist shows up (only matters if first operation) //if selected_partition is NEW we simply remove the NEW operation from the list and add it again with the new size and position ( unless it's an EXTENDED ) - if ( selected_partition .status == GParted::STAT_NEW && selected_partition.type != GParted::EXTENDED ) + if ( selected_partition .status == GParted::STAT_NEW && selected_partition.type != GParted::TYPE_EXTENDED ) { //remove operation which creates this partition for ( unsigned int t = 0 ; t < operations .size( ) ; t++ ) @@ -1041,7 +1046,7 @@ void Win_GParted::activate_delete( ) //e.g. consider /dev/hda5 /dev/hda6 /dev/hda7. Now after removal of /dev/hda6, /dev/hda7 is renumbered to /dev/hda6 //the new situation is now /dev/hda5 /dev/hda6. If /dev/hda7 was mounted the OS cannot find /dev/hda7 anymore and the results aren't that pretty //it seems best to check for this and prohibit deletion with some explanation to the user. - if ( selected_partition .type == GParted::LOGICAL && + if ( selected_partition .type == GParted::TYPE_LOGICAL && selected_partition .status != GParted::STAT_NEW && selected_partition .partition_number < devices [ current_device ] .highest_busy ) { @@ -1111,11 +1116,11 @@ void Win_GParted::activate_info( ) dialog .run( ); } -void Win_GParted::activate_convert( const Glib::ustring & new_fs ) +void Win_GParted::activate_convert( GParted::FILESYSTEM new_fs ) { //standard warning.. str_temp = "" ; - str_temp += String::ucompose( _("Are you sure you want to convert this filesystem to %1?"), new_fs ) + "\n\n" ; + str_temp += String::ucompose( _("Are you sure you want to convert this filesystem to %1?"), Get_Filesystem_String( new_fs ) ) + "\n\n" ; str_temp += String::ucompose( _("This operation will destroy all data on %1"), selected_partition .partition ) ; Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_CANCEL, true ); @@ -1134,13 +1139,13 @@ void Win_GParted::activate_convert( const Glib::ustring & new_fs ) if ( selected_partition .Get_Length_MB( ) < fs .MIN || ( fs .MAX && selected_partition .Get_Length_MB( ) > fs .MAX ) ) { str_temp = "" ; - str_temp += String::ucompose( _("Can not convert this filesystem to %1."), new_fs ) ; + str_temp += String::ucompose( _("Can not convert this filesystem to %1."), Get_Filesystem_String( new_fs ) ) ; str_temp += "\n\n" ; if ( selected_partition .Get_Length_MB( ) < fs .MIN ) - str_temp += String::ucompose( _( "A %1 filesystem requires a partition of at least %2 MB."), new_fs, fs .MIN ) ; + str_temp += String::ucompose( _( "A %1 filesystem requires a partition of at least %2 MB."), Get_Filesystem_String( new_fs ), fs .MIN ) ; else - str_temp += String::ucompose( _( "A partition with a %1 filesystem has a maximum size of %2 MB."), new_fs, fs .MAX ) ; + str_temp += String::ucompose( _( "A partition with a %1 filesystem has a maximum size of %2 MB."), Get_Filesystem_String( new_fs ), fs .MAX ) ; Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true ); diff --git a/src/ext2.cc b/src/ext2.cc index 6fe84162..83e51708 100644 --- a/src/ext2.cc +++ b/src/ext2.cc @@ -25,7 +25,7 @@ FS ext2::get_filesystem_support( ) { FS fs ; - fs .filesystem = "ext2" ; + fs .filesystem = GParted::FS_EXT2 ; if ( ! system( "which dumpe2fs 1>/dev/null 2>/dev/null" ) ) fs .read = GParted::FS::EXTERNAL ; diff --git a/src/ext3.cc b/src/ext3.cc index 3a19b5e8..c5eaddb9 100644 --- a/src/ext3.cc +++ b/src/ext3.cc @@ -25,7 +25,7 @@ FS ext3::get_filesystem_support( ) { FS fs ; - fs .filesystem = "ext3" ; + fs .filesystem = GParted::FS_EXT3 ; if ( ! system( "which dumpe2fs 1>/dev/null 2>/dev/null" ) ) fs .read = GParted::FS::EXTERNAL ; diff --git a/src/fat16.cc b/src/fat16.cc index fee9f80d..db06d436 100644 --- a/src/fat16.cc +++ b/src/fat16.cc @@ -25,7 +25,7 @@ FS fat16::get_filesystem_support( ) { FS fs ; - fs .filesystem = "fat16" ; + fs .filesystem = GParted::FS_FAT16 ; //find out if we can create fat16 filesystems if ( ! system( "which mkdosfs 1>/dev/null 2>/dev/null" ) ) diff --git a/src/fat32.cc b/src/fat32.cc index 4371a6ee..d463180d 100644 --- a/src/fat32.cc +++ b/src/fat32.cc @@ -25,7 +25,7 @@ FS fat32::get_filesystem_support( ) { FS fs ; - fs .filesystem = "fat32" ; + fs .filesystem = GParted::FS_FAT32 ; //find out if we can create fat32 filesystems if ( ! system( "which mkdosfs 1>/dev/null 2>/dev/null" ) ) diff --git a/src/hfs.cc b/src/hfs.cc index b8d00f9c..4cea50bf 100644 --- a/src/hfs.cc +++ b/src/hfs.cc @@ -25,7 +25,7 @@ FS hfs::get_filesystem_support( ) { FS fs ; - fs .filesystem = "hfs" ; + fs .filesystem = GParted::FS_HFS ; fs .read = GParted::FS::LIBPARTED; //provided by libparted diff --git a/src/hfsplus.cc b/src/hfsplus.cc index 8ccbb383..3ad5a685 100644 --- a/src/hfsplus.cc +++ b/src/hfsplus.cc @@ -25,7 +25,7 @@ FS hfsplus::get_filesystem_support( ) { FS fs ; - fs .filesystem = "hfs+" ; + fs .filesystem = GParted::FS_HFSPLUS ; fs .read = GParted::FS::LIBPARTED ; //provided by libparted diff --git a/src/jfs.cc b/src/jfs.cc index 4e65101a..ab6930de 100644 --- a/src/jfs.cc +++ b/src/jfs.cc @@ -25,7 +25,7 @@ FS jfs::get_filesystem_support( ) { FS fs ; - fs .filesystem = "jfs" ; + fs .filesystem = GParted::FS_JFS ; if ( ! system( "which jfs_debugfs 1>/dev/null 2>/dev/null" ) ) fs .read = GParted::FS::EXTERNAL ; diff --git a/src/linux_swap.cc b/src/linux_swap.cc index f94c0ca4..555b7c2f 100644 --- a/src/linux_swap.cc +++ b/src/linux_swap.cc @@ -25,7 +25,7 @@ FS linux_swap::get_filesystem_support( ) { FS fs ; - fs .filesystem = "linux-swap" ; + fs .filesystem = GParted::FS_LINUX_SWAP ; if ( ! system( "which mkswap 1>/dev/null 2>/dev/null" ) ) { diff --git a/src/ntfs.cc b/src/ntfs.cc index f9e4e6a0..ca19df53 100644 --- a/src/ntfs.cc +++ b/src/ntfs.cc @@ -25,7 +25,7 @@ FS ntfs::get_filesystem_support( ) { FS fs ; - fs .filesystem = "ntfs" ; + fs .filesystem = GParted::FS_NTFS ; if ( ! system( "which ntfscluster 1>/dev/null 2>/dev/null" ) ) fs .read = GParted::FS::EXTERNAL ; diff --git a/src/reiser4.cc b/src/reiser4.cc index d4c46d25..eed097b3 100644 --- a/src/reiser4.cc +++ b/src/reiser4.cc @@ -25,7 +25,7 @@ FS reiser4::get_filesystem_support( ) { FS fs ; - fs .filesystem = "reiser4" ; + fs .filesystem = GParted::FS_REISER4 ; if ( ! system( "which debugfs.reiser4 1>/dev/null 2>/dev/null" ) ) fs .read = GParted::FS::EXTERNAL ; diff --git a/src/reiserfs.cc b/src/reiserfs.cc index e8ba9d85..6b153163 100644 --- a/src/reiserfs.cc +++ b/src/reiserfs.cc @@ -25,7 +25,7 @@ FS reiserfs::get_filesystem_support( ) { FS fs ; - fs .filesystem = "reiserfs" ; + fs .filesystem = GParted::FS_REISERFS ; if ( ! system( "which debugreiserfs 1>/dev/null 2>/dev/null" ) ) fs .read = GParted::FS::EXTERNAL ; diff --git a/src/xfs.cc b/src/xfs.cc index ac31c1de..e89f98b4 100644 --- a/src/xfs.cc +++ b/src/xfs.cc @@ -25,7 +25,7 @@ FS xfs::get_filesystem_support( ) { FS fs ; - fs .filesystem = "xfs" ; + fs .filesystem = GParted::FS_XFS ; if ( ! system( "which xfs_db 1>/dev/null 2>/dev/null" ) ) fs .read = GParted::FS::EXTERNAL ;