:get_tmp_dir() instead of hardcoding it as '/tmp' :find_program_in_path()

* use Glib::get_tmp_dir() instead of hardcoding it as '/tmp'
* use Glib::find_program_in_path() instead af a system/which combi
* display current device in windowtitle
This commit is contained in:
Bart Hakvoort 2006-01-24 12:31:58 +00:00
parent adb71887af
commit 591a8f3db0
16 changed files with 93 additions and 74 deletions

View File

@ -1,3 +1,9 @@
2006-01-24 Bart Hakvoort <hakvoort@cvs.gnome.org>
* use Glib::get_tmp_dir() instead of hardcoding it as '/tmp'
* use Glib::find_program_in_path() instead af a system/which combi
* display current device in windowtitle
2006-01-22 Bart Hakvoort <hakvoort@cvs.gnome.org>
* correct partitiontype of destination is now set while copying

View File

@ -44,6 +44,8 @@ private:
void update_operation_details( const Gtk::TreeRow & treerow, const OperationDetails & operation_details ) ;
void on_signal_show() ;
void thread_apply_operation( Operation * operation ) ;
void on_response( int response_id ) ;
Gtk::Label label_current ;
Gtk::ProgressBar progressbar_all, progressbar_current ;

View File

@ -25,7 +25,6 @@
#include "../include/Dialog_Partition_Info.h"
#include "../include/Dialog_Partition_New.h"
#include "../include/Operation.h"
#include "../include/Dialog_Progress.h"
#include "../include/Dialog_Partition_Resize_Move.h"
#include "../include/Dialog_Partition_Copy.h"
#include "../include/GParted_Core.h"
@ -41,6 +40,8 @@
#include <gtkmm/statusbar.h>
#include <gtkmm/liststore.h>
#include <gtkmm/combobox.h>
#include <gtkmm/progressbar.h>
#include <gtkmm/scrolledwindow.h>
#include <unistd.h> //should be included by gtkmm headers. but decided to include it anyway after getting some bugreports..

View File

@ -88,7 +88,7 @@ Dialog_Progress::Dialog_Progress( const std::vector<Operation> & operations )
expander_details .set_use_markup( true ) ;
expander_details .add( scrolledwindow ) ;
this ->get_vbox() ->pack_start( expander_details, Gtk::PACK_EXPAND_WIDGET );
this ->get_vbox() ->pack_start( expander_details, Gtk::PACK_SHRINK ) ;
this ->get_vbox() ->set_spacing( 5 ) ;
this ->add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_NONE ) ;
@ -233,6 +233,19 @@ void Dialog_Progress::thread_apply_operation( Operation * operation )
pulse = false ;
}
void Dialog_Progress::on_response( int response_id )
{
if ( pulse && ( response_id == Gtk::RESPONSE_DELETE_EVENT || response_id == Gtk::RESPONSE_CANCEL ) )
{
//FIXME i guess this is the best place to implement the cancel. there are 2 ways to trigger this:
//press the 'cancel' button
//close the dialog by pressing the cross
std::cout << "CANCEL!! yet to be implemented... ;)" << std::endl ;
}
Gtk::Dialog::on_response( response_id ) ;
}
Dialog_Progress::~Dialog_Progress()
{
}

View File

@ -16,6 +16,7 @@
*/
#include "../include/Win_GParted.h"
#include "../include/Dialog_Progress.h"
#include <gtkmm/aboutdialog.h>
#include <gtkmm/messagedialog.h>
@ -741,6 +742,7 @@ void Win_GParted::combo_devices_changed( )
{
//set new current device
current_device = combo_devices .get_active_row_number() ;
this ->set_title( String::ucompose( _("%1 - GParted"), devices[ current_device ] .path ) );
//refresh label_device_info
Fill_Label_Device_Info( );
@ -761,7 +763,7 @@ void Win_GParted::menu_gparted_refresh_devices( )
thread = Glib::Thread::create( sigc::mem_fun( *this, &Win_GParted::thread_refresh_devices ), true ) ;
show_pulsebar( _("Scanning all devices...") ) ;
//check if current_device is still available (think about hotpluggable stuff like usbdevices)
if ( current_device >= devices .size() )
current_device = 0 ;
@ -803,6 +805,7 @@ void Win_GParted::menu_gparted_refresh_devices( )
//if no devices were detected we disable some stuff and show a message in the statusbar
if ( devices .empty() )
{
this ->set_title( _("GParted") );
combo_devices .hide() ;
menubar_main .items()[ 1 ] .set_sensitive( false ) ;

View File

@ -23,19 +23,19 @@ namespace GParted
FS ext2::get_filesystem_support( )
{
FS fs ;
fs .filesystem = GParted::FS_EXT2 ;
if ( ! system( "which dumpe2fs 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "dumpe2fs" ) .empty() )
fs .read = GParted::FS::EXTERNAL ;
if ( ! system( "which mkfs.ext2 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "mkfs.ext2" ) .empty() )
fs .create = GParted::FS::EXTERNAL ;
if ( ! system( "which e2fsck 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "e2fsck" ) .empty() )
fs .check = GParted::FS::EXTERNAL ;
//resizing is a delicate process ...
if ( ! system( "which resize2fs 1>/dev/null 2>/dev/null" ) && fs .check )
if ( ! Glib::find_program_in_path( "resize2fs" ) .empty() && fs .check )
{
fs .grow = GParted::FS::EXTERNAL ;
@ -43,7 +43,7 @@ FS ext2::get_filesystem_support( )
fs .shrink = GParted::FS::EXTERNAL ;
}
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) && fs .grow )
if ( ! Glib::find_program_in_path( "dd" ) .empty() && fs .grow )
fs .copy = GParted::FS::EXTERNAL ;
return fs ;

View File

@ -24,19 +24,19 @@ namespace GParted
FS ext3::get_filesystem_support( )
{
FS fs ;
fs .filesystem = GParted::FS_EXT3 ;
if ( ! system( "which dumpe2fs 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "dumpe2fs" ) .empty() )
fs .read = GParted::FS::EXTERNAL ;
if ( ! system( "which mkfs.ext3 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "mkfs.ext3" ) .empty() )
fs .create = GParted::FS::EXTERNAL ;
if ( ! system( "which e2fsck 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "e2fsck" ) .empty() )
fs .check = GParted::FS::EXTERNAL ;
//resizing is a delicate process ...
if ( ! system( "which resize2fs 1>/dev/null 2>/dev/null" ) && fs .check )
if ( ! Glib::find_program_in_path( "resize2fs" ) .empty() && fs .check )
{
fs .grow = GParted::FS::EXTERNAL ;
@ -44,9 +44,9 @@ FS ext3::get_filesystem_support( )
fs .shrink = GParted::FS::EXTERNAL ;
}
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) && fs .grow )
if ( ! Glib::find_program_in_path( "dd" ) .empty() && fs .grow )
fs .copy = GParted::FS::EXTERNAL ;
return fs ;
}

View File

@ -24,14 +24,13 @@ namespace GParted
FS fat16::get_filesystem_support( )
{
FS fs ;
fs .filesystem = GParted::FS_FAT16 ;
//find out if we can create fat16 filesystems
if ( ! system( "which mkdosfs 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "mkdosfs" ) .empty() )
fs .create = GParted::FS::EXTERNAL ;
if ( ! system( "which dosfsck 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "dosfsck" ) .empty() )
{
fs .check = GParted::FS::EXTERNAL ;
fs .read = GParted::FS::EXTERNAL ;
@ -42,7 +41,7 @@ FS fat16::get_filesystem_support( )
fs .shrink = GParted::FS::LIBPARTED ;
fs .move = GParted::FS::LIBPARTED ;
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "dd" ) .empty() )
fs .copy = GParted::FS::EXTERNAL ;
fs .MIN = 16 ;

View File

@ -24,14 +24,13 @@ namespace GParted
FS fat32::get_filesystem_support( )
{
FS fs ;
fs .filesystem = GParted::FS_FAT32 ;
//find out if we can create fat32 filesystems
if ( ! system( "which mkdosfs 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "mkdosfs" ) .empty() )
fs .create = GParted::FS::EXTERNAL ;
if ( ! system( "which dosfsck 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "dosfsck" ) .empty() )
{
fs .check = GParted::FS::EXTERNAL ;
fs .read = GParted::FS::EXTERNAL ;
@ -42,9 +41,9 @@ FS fat32::get_filesystem_support( )
fs .shrink = GParted::FS::LIBPARTED ;
fs .move = GParted::FS::LIBPARTED ;
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "dd" ) .empty() )
fs .copy = GParted::FS::EXTERNAL ;
fs .MIN = 32 ; //smaller fs'es will cause windows scandisk to fail..
return fs ;

View File

@ -21,18 +21,18 @@
namespace GParted
{
FS hfs::get_filesystem_support( )
FS hfs::get_filesystem_support()
{
FS fs ;
fs .filesystem = GParted::FS_HFS ;
fs .read = GParted::FS::LIBPARTED; //provided by libparted
if ( ! system( "which hformat 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "hformat" ) .empty() )
fs .create = GParted::FS::EXTERNAL ;
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "dd" ) .empty() )
fs .copy = GParted::FS::EXTERNAL ;
fs .MAX = 2048 ;

View File

@ -23,24 +23,22 @@
namespace GParted
{
FS jfs::get_filesystem_support( )
FS jfs::get_filesystem_support()
{
FS fs ;
fs .filesystem = GParted::FS_JFS ;
if ( ! system( "which jfs_debugfs 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "jfs_debugfs" ) .empty() )
fs .read = GParted::FS::EXTERNAL ;
if ( ! system( "which mkfs.jfs 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "mkfs.jfs" ) .empty() )
fs .create = GParted::FS::EXTERNAL ;
if ( ! system( "which jfs_fsck 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "jfs_fsck" ) .empty() )
fs .check = GParted::FS::EXTERNAL ;
//resizing of jfs requires jfs support in the kernel
std::ifstream input( "/proc/filesystems" ) ;
if ( input )
{
Glib::ustring line ;
@ -52,10 +50,10 @@ FS jfs::get_filesystem_support( )
break ;
}
input .close( ) ;
input .close() ;
}
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) && fs .grow )
if ( ! Glib::find_program_in_path( "dd" ) .empty() && fs .grow )
fs .copy = GParted::FS::EXTERNAL ;
fs .MIN = 16 ;
@ -68,7 +66,7 @@ void jfs::Set_Used_Sectors( Partition & partition )
argv .push_back( "sh" ) ;
argv .push_back( "-c" ) ;
argv .push_back( "echo dm | jfs_debugfs " + partition .partition ) ;
if ( ! execute_command( argv, output ) )
{
//blocksize
@ -120,7 +118,7 @@ bool jfs::Resize( const Partition & partition_new,
bool return_value = false ;
Glib::ustring error ;
Glib::ustring TEMP_MP = "/tmp/gparted_tmp_jfs_mountpoint" ;
Glib::ustring TEMP_MP = Glib::get_tmp_dir() + "/gparted_tmp_jfs_mountpoint" ;
//create mountpoint...
operation_details .back() .sub_details .push_back(

View File

@ -21,13 +21,12 @@
namespace GParted
{
FS linux_swap::get_filesystem_support( )
FS linux_swap::get_filesystem_support()
{
FS fs ;
fs .filesystem = GParted::FS_LINUX_SWAP ;
if ( ! system( "which mkswap 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "mkswap" ) .empty() )
{
fs .create = GParted::FS::EXTERNAL ;
fs .grow = GParted::FS::EXTERNAL ;
@ -35,7 +34,7 @@ FS linux_swap::get_filesystem_support( )
fs .move = GParted::FS::EXTERNAL ;
}
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "dd" ) .empty() )
fs .copy = GParted::FS::EXTERNAL ;
return fs ;

View File

@ -24,19 +24,19 @@ namespace GParted
FS ntfs::get_filesystem_support( )
{
FS fs ;
fs .filesystem = GParted::FS_NTFS ;
if ( ! system( "which ntfscluster 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "ntfscluster" ) .empty() )
fs .read = GParted::FS::EXTERNAL ;
if ( ! system( "which mkntfs 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "mkntfs" ) .empty() )
fs .create = GParted::FS::EXTERNAL ;
if ( ! system( "which ntfsfix 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "ntfsfix" ) .empty() )
fs .check = GParted::FS::EXTERNAL ;
//resizing is a delicate process ...
if ( ! system( "which ntfsresize 1>/dev/null 2>/dev/null" ) && fs .check )
if ( ! Glib::find_program_in_path( "ntfsresize" ) .empty() && fs .check )
{
fs .grow = GParted::FS::EXTERNAL ;
@ -45,7 +45,7 @@ FS ntfs::get_filesystem_support( )
}
//we need ntfsresize to set correct used/unused after cloning
if ( ! system( "which ntfsclone 1>/dev/null 2>/dev/null" ) && fs .grow )
if ( ! Glib::find_program_in_path( "ntfsclone" ) .empty() && fs .grow )
fs .copy = GParted::FS::EXTERNAL ;
return fs ;

View File

@ -21,25 +21,24 @@
namespace GParted
{
FS reiser4::get_filesystem_support( )
FS reiser4::get_filesystem_support()
{
FS fs ;
fs .filesystem = GParted::FS_REISER4 ;
if ( ! system( "which debugfs.reiser4 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "debugfs.reiser4" ) .empty() )
fs .read = GParted::FS::EXTERNAL ;
if ( ! system( "which mkfs.reiser4 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "mkfs.reiser4" ) .empty() )
fs .create = GParted::FS::EXTERNAL ;
if ( ! system( "which fsck.reiser4 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "fsck.reiser4" ) .empty() )
fs .check = GParted::FS::EXTERNAL ;
/*
* IT SEEMS RESIZE AND COPY AREN'T IMPLEMENTED YET IN THE TOOLS...
* SEE http://marc.theaimsgroup.com/?t=109883161600003&r=1&w=2 for more information.. (it seems NameSys is getting commercial? :| )
*/
* SEE http://marc.theaimsgroup.com/?t=109883161600003&r=1&w=2 for more information..
*/
return fs ;
}

View File

@ -21,23 +21,22 @@
namespace GParted
{
FS reiserfs::get_filesystem_support( )
FS reiserfs::get_filesystem_support()
{
FS fs ;
fs .filesystem = GParted::FS_REISERFS ;
if ( ! system( "which debugreiserfs 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "debugreiserfs" ) .empty() )
fs .read = GParted::FS::EXTERNAL ;
if ( ! system( "which mkreiserfs 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "mkreiserfs" ) .empty() )
fs .create = GParted::FS::EXTERNAL ;
if ( ! system( "which reiserfsck 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "reiserfsck" ) .empty() )
fs .check = GParted::FS::EXTERNAL ;
//resizing is a delicate process ...
if ( ! system( "which resize_reiserfs 1>/dev/null 2>/dev/null" ) && fs .check )
if ( ! Glib::find_program_in_path( "resize_reiserfs" ) .empty() && fs .check )
{
fs .grow = GParted::FS::EXTERNAL ;
@ -46,7 +45,7 @@ FS reiserfs::get_filesystem_support( )
}
//we need to call resize_reiserfs after a copy to get proper used/unused
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) && fs .grow )
if ( ! Glib::find_program_in_path( "dd" ) .empty() && fs .grow )
fs .copy = GParted::FS::EXTERNAL ;
fs .MIN = 32 ;

View File

@ -26,20 +26,19 @@ namespace GParted
FS xfs::get_filesystem_support( )
{
FS fs ;
fs .filesystem = GParted::FS_XFS ;
if ( ! system( "which xfs_db 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "xfs_db" ) .empty() )
fs .read = GParted::FS::EXTERNAL ;
if ( ! system( "which mkfs.xfs 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "mkfs.xfs" ) .empty() )
fs .create = GParted::FS::EXTERNAL ;
if ( ! system( "which xfs_repair 1>/dev/null 2>/dev/null" ) )
if ( ! Glib::find_program_in_path( "xfs_repair" ) .empty() )
fs .check = GParted::FS::EXTERNAL ;
//resizing of xfs requires xfs_growfs, xfs_repair and xfs support in the kernel
if ( ! system( "which xfs_growfs 1>/dev/null 2>/dev/null" ) && fs .check )
if ( ! Glib::find_program_in_path( "xfs_growfs" ) .empty() && fs .check )
{
Glib::ustring line ;
std::ifstream input( "/proc/filesystems" ) ;
@ -53,7 +52,9 @@ FS xfs::get_filesystem_support( )
input .close( ) ;
}
if ( ! system( "which xfsdump xfsrestore 1>/dev/null 2>/dev/null" ) && fs .check && fs .create )
if ( ! Glib::find_program_in_path( "xfsdump" ) .empty() &&
! Glib::find_program_in_path( "xfsrestore" ) .empty() &&
fs .check && fs .create )
fs .copy = GParted::FS::EXTERNAL ;
fs .MIN = 32 ;//official minsize = 16MB, but the smallest xfs_repair can handle is 32MB...
@ -70,7 +71,7 @@ void xfs::Set_Used_Sectors( Partition & partition )
argv .push_back( "-c print fdblocks" ) ;
argv .push_back( "-r" ) ;
argv .push_back( partition .partition ) ;
if ( ! execute_command( argv, output ) )
{
//blocksize
@ -119,7 +120,7 @@ bool xfs::Resize( const Partition & partition_new,
bool return_value = false ;
Glib::ustring error ;
Glib::ustring TEMP_MP = "/tmp/gparted_tmp_xfs_mountpoint" ;
Glib::ustring TEMP_MP = Glib::get_tmp_dir() + "/gparted_tmp_xfs_mountpoint" ;
//create mountpoint...
operation_details .back() .sub_details .push_back(
@ -209,8 +210,8 @@ bool xfs::Copy( const Glib::ustring & src_part_path,
bool return_value = false ;
Glib::ustring error ;
Glib::ustring SRC = "/tmp/gparted_tmp_xfs_src_mountpoint" ;
Glib::ustring DST = "/tmp/gparted_tmp_xfs_dest_mountpoint" ;
Glib::ustring SRC = Glib::get_tmp_dir() + "/gparted_tmp_xfs_src_mountpoint" ;
Glib::ustring DST = Glib::get_tmp_dir() + "/gparted_tmp_xfs_dest_mountpoint" ;
//create xfs filesystem on destination..
Partition partition ;