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 ) ;
|
||||
|
||||
|
@ -83,7 +85,8 @@ private:
|
|||
void close_device_and_disk() ;
|
||||
bool Resize_Extended( const Partition & partition, PedTimer *timer) ;
|
||||
|
||||
std::vector<Partition> device_partitions;
|
||||
std::vector<Partition> device_partitions ;
|
||||
std::vector<FS> * FILESYSTEMS ;
|
||||
Sector length;
|
||||
long heads ;
|
||||
long sectors ;
|
||||
|
|
|
@ -37,10 +37,10 @@ class Dialog_Base_Partition : public Gtk::Dialog
|
|||
public:
|
||||
|
||||
Dialog_Base_Partition( ) ;
|
||||
~Dialog_Base_Partition() ;
|
||||
~Dialog_Base_Partition( ) ;
|
||||
|
||||
void Set_Resizer( bool extended ) ;
|
||||
Partition Get_New_Partition() ;
|
||||
Partition Get_New_Partition( ) ;
|
||||
|
||||
protected:
|
||||
enum SPINBUTTON {
|
||||
|
@ -77,7 +77,7 @@ protected:
|
|||
void on_signal_resize( int, int, Frame_Resizer_Base::ArrowType );
|
||||
void on_spinbutton_value_changed( SPINBUTTON ) ;
|
||||
|
||||
bool fixed_start, GRIP;
|
||||
bool fixed_start, GRIP ;
|
||||
double before_value ;
|
||||
int x_start, x_end ;
|
||||
|
||||
|
|
|
@ -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,25 +30,23 @@ 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 );
|
||||
|
||||
Gdk::Color color_temp;
|
||||
unsigned short new_count ;
|
||||
unsigned short new_count ;
|
||||
};
|
||||
|
||||
} //GParted
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
@ -49,7 +49,7 @@ namespace GParted
|
|||
class Win_GParted : public Gtk::Window
|
||||
{
|
||||
public:
|
||||
Win_GParted( );
|
||||
Win_GParted( );
|
||||
|
||||
private:
|
||||
void init_menubar() ;
|
||||
|
@ -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
|
||||
|
@ -166,9 +167,10 @@ private:
|
|||
Glib::ustring str_temp ; //mostly used for constructing dialogmessages
|
||||
|
||||
|
||||
GParted::Device *temp_device;
|
||||
std::vector <Glib::ustring> str_devices, filesystems;
|
||||
std::vector <Gtk::Label *> device_info;
|
||||
GParted::Device *temp_device ;
|
||||
std::vector <Glib::ustring> str_devices ;
|
||||
std::vector <Gtk::Label *> device_info ;
|
||||
std::vector <FS> FILESYSTEMS ;
|
||||
|
||||
//stuff for progress overview
|
||||
Dialog_Progress *dialog_progress;
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
#ifndef I18N
|
||||
#define I18N
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
#include <glibmm/i18n.h>
|
||||
#endif /* ENABLE_NLS */
|
||||
#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 )
|
||||
|
@ -224,7 +226,7 @@ bool Device::Delete_Partition( const Partition & partition )
|
|||
else
|
||||
c_partition = ped_disk_get_partition_by_sector( disk, (partition .sector_end + partition .sector_start) / 2 ) ;
|
||||
|
||||
if ( ! ped_disk_delete_partition( disk, c_partition ) )
|
||||
if ( ! ped_disk_delete_partition( disk, c_partition ) )
|
||||
return false;
|
||||
|
||||
return Commit() ;
|
||||
|
@ -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() ;
|
||||
|
@ -498,7 +500,7 @@ Sector Device::Get_Used_Sectors( PedPartition *c_partition, const Glib::ustring
|
|||
* questionable.
|
||||
* - first i try geometry.get_used() in libpartedpp, i implemented this function to check the minimal size when resizing a partition. Disadvantage
|
||||
* of this method is the fact it won't work on mounted filesystems. Besides that, its SLOW
|
||||
* - if the former method fails ( result is -1 ) i'll try to read the output from the df command ( df -k --sync <partition path> )
|
||||
* - if the former method fails ( result is -1 ) i'll try to read the output from the df command ( df -k --sync <partition path> )
|
||||
* - if this fails the filesystem on the partition is ( more or less ) unknown to the operating system and therefore the unused sectors cannot be calcualted
|
||||
* - as soon as i have my internetconnection back i should ask people with more experience on this stuff for advice !
|
||||
*/
|
||||
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
namespace GParted
|
||||
{
|
||||
|
||||
Dialog_Partition_New::Dialog_Partition_New( )
|
||||
Dialog_Partition_New::Dialog_Partition_New( )
|
||||
{
|
||||
/*TO TRANSLATORS: dialogtitle */
|
||||
this ->set_title( _("Create new Partition") ) ;
|
||||
|
@ -33,15 +33,18 @@ Dialog_Partition_New::Dialog_Partition_New( )
|
|||
|
||||
//set the resizer..
|
||||
frame_resizer_base ->set_x_start( 0 ) ;
|
||||
frame_resizer_base ->set_x_end( 500 ) ;
|
||||
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 ->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") ) ) ;
|
||||
|
@ -61,14 +62,15 @@ void Dialog_Partition_New::Set_Data( const Partition & partition, bool any_exten
|
|||
//determine which PartitionType is allowed
|
||||
if ( partition.inside_extended )
|
||||
{
|
||||
menu_type.items()[0] . set_sensitive( false );
|
||||
menu_type.items()[2] . set_sensitive( false );
|
||||
menu_type.items()[0] .set_sensitive( false );
|
||||
menu_type.items()[2] .set_sensitive( false );
|
||||
menu_type.set_active( 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
menu_type.items()[1] . set_sensitive( false );
|
||||
if ( any_extended ) menu_type.items()[2] . set_sensitive( false );
|
||||
menu_type.items()[1] .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() ;
|
||||
|
||||
|
@ -91,7 +91,7 @@ void Dialog_Partition_New::Set_Data( const Partition & partition, bool any_exten
|
|||
START = partition.sector_start ;
|
||||
total_length = partition.sector_end - partition.sector_start ;
|
||||
TOTAL_MB = this ->selected_partition .Get_Length_MB() ;
|
||||
MB_PER_PIXEL = (double) TOTAL_MB / 500 ;
|
||||
MB_PER_PIXEL = (double) TOTAL_MB / 500 ;
|
||||
|
||||
//set spinbuttons
|
||||
GRIP = true ; //prevents on spinbutton_changed from getting activated prematurely
|
||||
|
@ -102,7 +102,7 @@ void Dialog_Partition_New::Set_Data( const Partition & partition, bool any_exten
|
|||
spinbutton_size .set_range( 1, TOTAL_MB ) ;
|
||||
spinbutton_size .set_value( TOTAL_MB ) ;
|
||||
|
||||
spinbutton_after .set_range( 0, TOTAL_MB -1 ) ;//mind the -1 !!
|
||||
spinbutton_after .set_range( 0, TOTAL_MB -1 ) ;//mind the -1 !!
|
||||
spinbutton_after .set_value( 0 ) ;
|
||||
|
||||
GRIP = false ;
|
||||
|
@ -121,9 +121,9 @@ Partition Dialog_Partition_New::Get_New_Partition()
|
|||
|
||||
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::PRIMARY; break;
|
||||
case 1: part_type = GParted::LOGICAL; break;
|
||||
case 2: part_type = GParted::EXTENDED; break;
|
||||
}
|
||||
|
||||
new_start = START + (Sector) (spinbutton_before .get_value() * MEGABYTE) ;
|
||||
|
@ -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 )
|
||||
|
@ -149,7 +149,7 @@ Partition Dialog_Partition_New::Get_New_Partition()
|
|||
|
||||
|
||||
|
||||
void Dialog_Partition_New::optionmenu_changed( bool type )
|
||||
void Dialog_Partition_New::optionmenu_changed( bool type )
|
||||
{
|
||||
//optionmenu_type
|
||||
if ( type )
|
||||
|
@ -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,19 +172,24 @@ 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;
|
||||
default : MIN = 1 ;
|
||||
case 5: MIN = 40 ;
|
||||
MAX = TOTAL_MB ;
|
||||
break;
|
||||
default: MIN = 1 ;
|
||||
MAX = TOTAL_MB ;
|
||||
}
|
||||
|
||||
|
@ -200,11 +205,11 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
|
|||
|
||||
//set fitting resizer colors
|
||||
//backgroundcolor..
|
||||
optionmenu_type.get_history() == 2 ? color_temp .set( "darkgrey" ) : color_temp .set( "white" ) ;
|
||||
optionmenu_type.get_history() == 2 ? color_temp .set( "darkgrey" ) : color_temp .set( "white" ) ;
|
||||
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 ) ;
|
||||
menu_filesystem .items()[ 2 ] .set_sensitive( false ) ;
|
||||
//fat32
|
||||
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 ) ;
|
||||
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,37 +173,24 @@ 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 ] ) );
|
||||
hbox = manage( new Gtk::HBox() );
|
||||
color .set( selected_partition .Get_Color( FILESYSTEMS[ t ] .filesystem ) );
|
||||
hbox = manage( new Gtk::HBox() );
|
||||
|
||||
//the colored square
|
||||
entry = manage ( new Gtk::Entry() );
|
||||
entry->set_sensitive( false );
|
||||
entry->set_size_request( 12,12);
|
||||
entry->modify_base( entry->get_state(), color );
|
||||
hbox ->pack_start( *entry, Gtk::PACK_SHRINK );
|
||||
//the colored square
|
||||
entry = manage ( new Gtk::Entry() );
|
||||
entry->set_sensitive( false );
|
||||
entry->set_size_request( 12, 12 );
|
||||
entry->modify_base( entry->get_state(), color );
|
||||
hbox ->pack_start( *entry, Gtk::PACK_SHRINK );
|
||||
|
||||
//the label...
|
||||
label = manage( new Gtk::Label( " " + filesystems[ t ] ) );
|
||||
label ->set_alignment( Gtk::ALIGN_LEFT );
|
||||
//the label...
|
||||
hbox ->pack_start( * mk_label( " " + FILESYSTEMS[ t ] .filesystem ), Gtk::PACK_SHRINK );
|
||||
|
||||
hbox ->pack_start( *label, 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_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 ] .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++ )
|
||||
|
@ -358,16 +375,16 @@ void Win_GParted::Find_Devices()
|
|||
//construct a list of device objects
|
||||
PedDevice *device = ped_device_get_next (NULL);
|
||||
|
||||
while ( device )
|
||||
while ( device )
|
||||
{
|
||||
str_devices.push_back( device ->path ) ;
|
||||
str_devices.push_back( device ->path ) ;
|
||||
device = ped_device_get_next (device) ;
|
||||
}
|
||||
|
||||
for ( unsigned int t=0;t<str_devices.size() ; t++ )
|
||||
{
|
||||
temp_device = new GParted::Device( str_devices[t] );
|
||||
temp_device ->Get_Length() > 0 ? devices.push_back( temp_device ) : delete temp_device ;
|
||||
temp_device = new GParted::Device( str_devices[t], &FILESYSTEMS );
|
||||
temp_device ->Get_Length() > 0 ? devices.push_back( temp_device ) : delete temp_device ;
|
||||
}
|
||||
|
||||
str_devices.clear() ;
|
||||
|
@ -380,13 +397,13 @@ void Win_GParted::Find_Devices()
|
|||
|
||||
//the image...
|
||||
image = manage( new Gtk::Image( "/usr/share/icons/gnome/24x24/devices/gnome-dev-harddisk.png" ) );
|
||||
hbox ->pack_start( *image, Gtk::PACK_SHRINK );
|
||||
hbox ->pack_start( *image, Gtk::PACK_SHRINK );
|
||||
|
||||
//the label...
|
||||
label = manage( new Gtk::Label( " " + devices[i] ->Get_Path() + "\t(" + String::ucompose( _("%1 MB"), Sector_To_MB( devices[i] ->Get_Length() ) ) + ")" ) ) ;
|
||||
|
||||
label ->set_alignment( Gtk::ALIGN_LEFT );
|
||||
hbox ->pack_start( *label, Gtk::PACK_SHRINK );
|
||||
label ->set_alignment( Gtk::ALIGN_LEFT );
|
||||
hbox ->pack_start( *label, Gtk::PACK_SHRINK );
|
||||
|
||||
menu_item = manage( new Gtk::MenuItem( *hbox ) ) ;
|
||||
menu_devices .items().push_back( *menu_item );
|
||||
|
@ -454,7 +471,7 @@ void Win_GParted::Add_Operation( OperationType operationtype, const Partition &
|
|||
|
||||
void Win_GParted::Refresh_Visual( )
|
||||
{
|
||||
std::vector<Partition> partitions = devices[current_device] ->Get_Partitions() ;
|
||||
std::vector<Partition> partitions = devices[current_device] ->Get_Partitions() ;
|
||||
liststore_operations ->clear();
|
||||
|
||||
//make all operations visible
|
||||
|
@ -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 )
|
||||
|
@ -1025,7 +1040,7 @@ void Win_GParted::activate_convert( const Glib::ustring & new_fs )
|
|||
{
|
||||
if ( operations[t] .partition_new .partition == selected_partition .partition )
|
||||
{
|
||||
operations.erase( operations .begin() + t ) ;
|
||||
operations.erase( operations .begin() +t ) ;
|
||||
|
||||
//And add the new partition to the end of the operations list (NOTE: in this case we set status to STAT_NEW)
|
||||
part_temp .status = STAT_NEW ;
|
||||
|
@ -1043,7 +1058,7 @@ void Win_GParted::activate_undo()
|
|||
{
|
||||
//when undoing an creation it's safe to decrease the newcount by one
|
||||
if ( operations.back() .operationtype == GParted::CREATE )
|
||||
new_count -- ;
|
||||
new_count-- ;
|
||||
|
||||
operations.erase( operations.end() );
|
||||
|
||||
|
@ -1134,7 +1149,7 @@ void Win_GParted::activate_apply()
|
|||
Dialog_Progress *dp;
|
||||
Glib::Dispatcher dispatcher_current_operation;
|
||||
|
||||
void progress_callback(PedTimer * timer, void *context )
|
||||
void progress_callback(PedTimer * timer, void *context )
|
||||
{
|
||||
if ( time(NULL) - timer ->start > 0 )
|
||||
{
|
||||
|
|
|
@ -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