add 'flag management' (#330453)
* include/DialogManageFlags.h, include/GParted_Core.h, include/Makefile.am, include/Utils.h, include/Win_GParted.h, src/DialogManageFlags.cc, src/GParted_Core.cc, src/Makefile.am, src/Win_GParted.cc: add 'flag management' (#330453)
This commit is contained in:
parent
70bfe578d4
commit
f5ea37e310
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2006-03-31 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||||
|
|
||||||
|
* include/DialogManageFlags.h,
|
||||||
|
include/GParted_Core.h,
|
||||||
|
include/Makefile.am,
|
||||||
|
include/Utils.h,
|
||||||
|
include/Win_GParted.h,
|
||||||
|
src/DialogManageFlags.cc,
|
||||||
|
src/GParted_Core.cc,
|
||||||
|
src/Makefile.am,
|
||||||
|
src/Win_GParted.cc: add 'flag management' (#330453)
|
||||||
|
|
||||||
2006-03-29 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
2006-03-29 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||||
|
|
||||||
* include/Partition.h,
|
* include/Partition.h,
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
/* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef DIALOG_MANAGE_FLAGS
|
||||||
|
#define DIALOG_MANAGE_FLAGS
|
||||||
|
|
||||||
|
#include "../include/Partition.h"
|
||||||
|
|
||||||
|
#include <gtkmm/dialog.h>
|
||||||
|
#include <gtkmm/treeview.h>
|
||||||
|
#include <gtkmm/liststore.h>
|
||||||
|
|
||||||
|
namespace GParted
|
||||||
|
{
|
||||||
|
|
||||||
|
class DialogManageFlags : public Gtk::Dialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DialogManageFlags( const Partition & partition ) ;
|
||||||
|
|
||||||
|
sigc::signal< std::map<Glib::ustring, bool>, const Partition & > signal_get_flags ;
|
||||||
|
sigc::signal< bool, const Partition &, const Glib::ustring &, bool > signal_toggle_flag ;
|
||||||
|
|
||||||
|
bool any_change ;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void on_show() ;
|
||||||
|
|
||||||
|
void load_flags() ;
|
||||||
|
void on_flag_toggled( const Glib::ustring & path ) ;
|
||||||
|
|
||||||
|
|
||||||
|
Gtk::TreeView treeview_flags ;
|
||||||
|
Gtk::TreeRow row ;
|
||||||
|
|
||||||
|
Glib::RefPtr<Gtk::ListStore> liststore_flags ;
|
||||||
|
|
||||||
|
struct treeview_flags_Columns : public Gtk::TreeModelColumnRecord
|
||||||
|
{
|
||||||
|
Gtk::TreeModelColumn<Glib::ustring> flag ;
|
||||||
|
Gtk::TreeModelColumn<bool> status ;
|
||||||
|
|
||||||
|
treeview_flags_Columns()
|
||||||
|
{
|
||||||
|
add( flag ) ;
|
||||||
|
add( status ) ;
|
||||||
|
}
|
||||||
|
} ;
|
||||||
|
treeview_flags_Columns treeview_flags_columns ;
|
||||||
|
|
||||||
|
Partition partition ;
|
||||||
|
};
|
||||||
|
|
||||||
|
} //GParted
|
||||||
|
|
||||||
|
|
||||||
|
#endif //DIALOG_MANAGE_FLAGS
|
|
@ -70,6 +70,8 @@ public:
|
||||||
const FS & get_fs( GParted::FILESYSTEM filesystem ) const ;
|
const FS & get_fs( GParted::FILESYSTEM filesystem ) const ;
|
||||||
std::vector<Glib::ustring> get_disklabeltypes() ;
|
std::vector<Glib::ustring> get_disklabeltypes() ;
|
||||||
std::vector<Glib::ustring> get_all_mountpoints() ;
|
std::vector<Glib::ustring> get_all_mountpoints() ;
|
||||||
|
std::map<Glib::ustring, bool> get_available_flags( const Partition & partition ) ;
|
||||||
|
bool toggle_flag( const Partition & partition, const Glib::ustring & flag, bool state ) ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GParted::FILESYSTEM get_filesystem() ;
|
GParted::FILESYSTEM get_filesystem() ;
|
||||||
|
|
|
@ -10,6 +10,7 @@ EXTRA_DIST = \
|
||||||
Dialog_Partition_New.h \
|
Dialog_Partition_New.h \
|
||||||
Dialog_Partition_Resize_Move.h \
|
Dialog_Partition_Resize_Move.h \
|
||||||
Dialog_Progress.h \
|
Dialog_Progress.h \
|
||||||
|
DialogManageFlags.h \
|
||||||
DrawingAreaVisualDisk.h \
|
DrawingAreaVisualDisk.h \
|
||||||
FileSystem.h \
|
FileSystem.h \
|
||||||
Frame_Resizer_Base.h \
|
Frame_Resizer_Base.h \
|
||||||
|
|
|
@ -75,7 +75,7 @@ enum SIZE_UNIT
|
||||||
UNIT_KIB = 2,
|
UNIT_KIB = 2,
|
||||||
UNIT_MIB = 3,
|
UNIT_MIB = 3,
|
||||||
UNIT_GIB = 4,
|
UNIT_GIB = 4,
|
||||||
UNIT_TIB = 5,
|
UNIT_TIB = 5
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
//struct to store filesysteminformation
|
//struct to store filesysteminformation
|
||||||
|
|
|
@ -96,9 +96,12 @@ private:
|
||||||
void allow_toggle_swap_mount_state( bool b ) {
|
void allow_toggle_swap_mount_state( bool b ) {
|
||||||
menu_partition .items()[ 10 ] .set_sensitive( b ); }
|
menu_partition .items()[ 10 ] .set_sensitive( b ); }
|
||||||
|
|
||||||
void allow_info( bool b ) {
|
void allow_manage_flags( bool b ) {
|
||||||
menu_partition .items()[ 13 ] .set_sensitive( b ) ; }
|
menu_partition .items()[ 13 ] .set_sensitive( b ) ; }
|
||||||
|
|
||||||
|
void allow_info( bool b ) {
|
||||||
|
menu_partition .items()[ 15 ] .set_sensitive( b ); }
|
||||||
|
|
||||||
void allow_undo( bool b ) {
|
void allow_undo( bool b ) {
|
||||||
toolbar_main .get_nth_item( 8 ) ->set_sensitive( b );
|
toolbar_main .get_nth_item( 8 ) ->set_sensitive( b );
|
||||||
static_cast<Gtk::CheckMenuItem *>( & menubar_main .items()[ 1 ] .get_submenu() ->items()[ 0 ] )
|
static_cast<Gtk::CheckMenuItem *>( & menubar_main .items()[ 1 ] .get_submenu() ->items()[ 0 ] )
|
||||||
|
@ -148,6 +151,7 @@ private:
|
||||||
void toggle_swap_mount_state() ;
|
void toggle_swap_mount_state() ;
|
||||||
void activate_mount_partition( unsigned int index ) ;
|
void activate_mount_partition( unsigned int index ) ;
|
||||||
void activate_disklabel() ;
|
void activate_disklabel() ;
|
||||||
|
void activate_manage_flags() ;
|
||||||
|
|
||||||
void activate_undo();
|
void activate_undo();
|
||||||
void remove_operation( int index = -1, bool remove_all = false ) ;
|
void remove_operation( int index = -1, bool remove_all = false ) ;
|
||||||
|
|
|
@ -0,0 +1,97 @@
|
||||||
|
/* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../include/DialogManageFlags.h"
|
||||||
|
|
||||||
|
#include <gtkmm/main.h>
|
||||||
|
#include <gtkmm/stock.h>
|
||||||
|
|
||||||
|
namespace GParted
|
||||||
|
{
|
||||||
|
|
||||||
|
DialogManageFlags::DialogManageFlags( const Partition & partition )
|
||||||
|
{
|
||||||
|
any_change = false ;
|
||||||
|
|
||||||
|
set_title( String::ucompose( _("Manage flags on %1"), partition .get_path() ) );
|
||||||
|
set_has_separator( false ) ;
|
||||||
|
set_size_request( 300, -1 ) ;
|
||||||
|
set_resizable( false );
|
||||||
|
|
||||||
|
Glib::ustring str_temp = "<span weight=\"bold\" size=\"larger\">" ;
|
||||||
|
str_temp += String::ucompose( _("Manage flags on %1"), partition .get_path() ) ;
|
||||||
|
str_temp += "</span>\n" ;
|
||||||
|
get_vbox() ->pack_start( * Utils::mk_label( str_temp ), Gtk::PACK_SHRINK );
|
||||||
|
|
||||||
|
//setup treeview
|
||||||
|
liststore_flags = Gtk::ListStore::create( treeview_flags_columns ) ;
|
||||||
|
treeview_flags .set_model( liststore_flags ) ;
|
||||||
|
treeview_flags .set_headers_visible( false ) ;
|
||||||
|
|
||||||
|
treeview_flags .append_column( "", treeview_flags_columns .status ) ;
|
||||||
|
treeview_flags .append_column( "", treeview_flags_columns .flag ) ;
|
||||||
|
static_cast<Gtk::CellRendererToggle *>( treeview_flags .get_column_cell_renderer( 0 ) )
|
||||||
|
->property_activatable() = true ;
|
||||||
|
static_cast<Gtk::CellRendererToggle *>( treeview_flags .get_column_cell_renderer( 0 ) )
|
||||||
|
->signal_toggled() .connect( sigc::mem_fun( *this, &DialogManageFlags::on_flag_toggled ) ) ;
|
||||||
|
|
||||||
|
get_vbox() ->pack_start( treeview_flags, Gtk::PACK_SHRINK ) ;
|
||||||
|
|
||||||
|
this ->partition = partition ;
|
||||||
|
|
||||||
|
add_button( Gtk::Stock::CLOSE, Gtk::RESPONSE_OK ) ->grab_focus() ;
|
||||||
|
|
||||||
|
show_all_children() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogManageFlags::on_show()
|
||||||
|
{
|
||||||
|
Dialog::on_show() ;
|
||||||
|
|
||||||
|
while ( Gtk::Main::events_pending() )
|
||||||
|
Gtk::Main::iteration() ;
|
||||||
|
|
||||||
|
load_flags() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogManageFlags::load_flags()
|
||||||
|
{
|
||||||
|
liststore_flags ->clear() ;
|
||||||
|
|
||||||
|
std::map<Glib::ustring, bool> flag_info = signal_get_flags .emit( partition ) ;
|
||||||
|
|
||||||
|
for ( std::map<Glib::ustring, bool>::iterator iter = flag_info .begin() ; iter != flag_info .end() ; ++iter )
|
||||||
|
{
|
||||||
|
row = *( liststore_flags ->append() ) ;
|
||||||
|
row[ treeview_flags_columns .flag ] = iter ->first ;
|
||||||
|
row[ treeview_flags_columns .status ] = iter ->second ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogManageFlags::on_flag_toggled( const Glib::ustring & path )
|
||||||
|
{
|
||||||
|
any_change = true ;
|
||||||
|
|
||||||
|
row = *( liststore_flags ->get_iter( path ) ) ;
|
||||||
|
row[ treeview_flags_columns .status ] = ! row[ treeview_flags_columns .status ] ;
|
||||||
|
|
||||||
|
signal_toggle_flag .emit( partition, row[ treeview_flags_columns .flag ], row[ treeview_flags_columns .status ] ) ;
|
||||||
|
|
||||||
|
load_flags() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
}//GParted
|
|
@ -801,6 +801,62 @@ std::vector<Glib::ustring> GParted_Core::get_all_mountpoints()
|
||||||
return mountpoints ;
|
return mountpoints ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::map<Glib::ustring, bool> GParted_Core::get_available_flags( const Partition & partition )
|
||||||
|
{
|
||||||
|
std::map<Glib::ustring, bool> flag_info ;
|
||||||
|
|
||||||
|
if ( open_device_and_disk( partition .device_path ) )
|
||||||
|
{
|
||||||
|
lp_partition = NULL ;
|
||||||
|
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 ) ;
|
||||||
|
|
||||||
|
if ( lp_partition )
|
||||||
|
{
|
||||||
|
for ( unsigned int t = 0 ; t < flags .size() ; t++ )
|
||||||
|
if ( ped_partition_is_flag_available( lp_partition, flags[ t ] ) )
|
||||||
|
flag_info[ ped_partition_flag_get_name( flags[ t ] ) ] =
|
||||||
|
ped_partition_get_flag( lp_partition, flags[ t ] ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
close_device_and_disk() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
return flag_info ;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GParted_Core::toggle_flag( const Partition & partition, const Glib::ustring & flag, bool state )
|
||||||
|
{
|
||||||
|
bool succes = false ;
|
||||||
|
|
||||||
|
if ( open_device_and_disk( partition .device_path ) )
|
||||||
|
{
|
||||||
|
lp_partition = NULL ;
|
||||||
|
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 ) ;
|
||||||
|
|
||||||
|
if ( lp_partition )
|
||||||
|
{
|
||||||
|
PedPartitionFlag lp_flag = ped_partition_flag_get_by_name( flag .c_str() ) ;
|
||||||
|
|
||||||
|
if ( lp_flag > 0 && ped_partition_set_flag( lp_partition, lp_flag, state ) )
|
||||||
|
succes = commit() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
close_device_and_disk() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
return succes ;
|
||||||
|
}
|
||||||
|
|
||||||
void GParted_Core::LP_Set_Used_Sectors( Partition & partition )
|
void GParted_Core::LP_Set_Used_Sectors( Partition & partition )
|
||||||
{
|
{
|
||||||
PedFileSystem *fs = NULL;
|
PedFileSystem *fs = NULL;
|
||||||
|
@ -1104,7 +1160,8 @@ bool GParted_Core::resize_normal_using_libparted( const Partition & partition_ol
|
||||||
void GParted_Core::set_flags( Partition & partition )
|
void GParted_Core::set_flags( Partition & partition )
|
||||||
{
|
{
|
||||||
for ( unsigned int t = 0 ; t < flags .size() ; t++ )
|
for ( unsigned int t = 0 ; t < flags .size() ; t++ )
|
||||||
if ( ped_partition_get_flag( lp_partition, flags[ t ] ) )
|
if ( ped_partition_is_flag_available( lp_partition, flags[ t ] ) &&
|
||||||
|
ped_partition_get_flag( lp_partition, flags[ t ] ) )
|
||||||
partition .flags .push_back( ped_partition_flag_get_name( flags[ t ] ) ) ;
|
partition .flags .push_back( ped_partition_flag_get_name( flags[ t ] ) ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ gparted_SOURCES = \
|
||||||
Dialog_Partition_New.cc \
|
Dialog_Partition_New.cc \
|
||||||
Dialog_Partition_Resize_Move.cc \
|
Dialog_Partition_Resize_Move.cc \
|
||||||
Dialog_Progress.cc \
|
Dialog_Progress.cc \
|
||||||
|
DialogManageFlags.cc \
|
||||||
DrawingAreaVisualDisk.cc \
|
DrawingAreaVisualDisk.cc \
|
||||||
FileSystem.cc \
|
FileSystem.cc \
|
||||||
Frame_Resizer_Base.cc \
|
Frame_Resizer_Base.cc \
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "../include/Dialog_Partition_Copy.h"
|
#include "../include/Dialog_Partition_Copy.h"
|
||||||
#include "../include/Dialog_Partition_New.h"
|
#include "../include/Dialog_Partition_New.h"
|
||||||
#include "../include/Dialog_Partition_Info.h"
|
#include "../include/Dialog_Partition_Info.h"
|
||||||
|
#include "../include/DialogManageFlags.h"
|
||||||
#include "../include/OperationCopy.h"
|
#include "../include/OperationCopy.h"
|
||||||
#include "../include/OperationCreate.h"
|
#include "../include/OperationCreate.h"
|
||||||
#include "../include/OperationDelete.h"
|
#include "../include/OperationDelete.h"
|
||||||
|
@ -264,6 +265,12 @@ void Win_GParted::init_partition_menu()
|
||||||
|
|
||||||
menu_partition .items() .push_back( Gtk::Menu_Helpers::SeparatorElem() ) ;
|
menu_partition .items() .push_back( Gtk::Menu_Helpers::SeparatorElem() ) ;
|
||||||
|
|
||||||
|
menu_partition .items() .push_back(
|
||||||
|
Gtk::Menu_Helpers::MenuElem( _("manage flags"),
|
||||||
|
sigc::mem_fun( *this, &Win_GParted::activate_manage_flags ) ) );
|
||||||
|
|
||||||
|
menu_partition .items() .push_back( Gtk::Menu_Helpers::SeparatorElem() ) ;
|
||||||
|
|
||||||
menu_partition .items() .push_back(
|
menu_partition .items() .push_back(
|
||||||
Gtk::Menu_Helpers::StockMenuElem( Gtk::Stock::DIALOG_INFO,
|
Gtk::Menu_Helpers::StockMenuElem( Gtk::Stock::DIALOG_INFO,
|
||||||
sigc::mem_fun(*this, &Win_GParted::activate_info) ) );
|
sigc::mem_fun(*this, &Win_GParted::activate_info) ) );
|
||||||
|
@ -724,7 +731,7 @@ void Win_GParted::set_valid_operations()
|
||||||
{
|
{
|
||||||
allow_new( false ); allow_delete( false ); allow_resize( false ); allow_copy( false );
|
allow_new( false ); allow_delete( false ); allow_resize( false ); allow_copy( false );
|
||||||
allow_paste( false ); allow_format( false ); allow_toggle_swap_mount_state( false ) ;
|
allow_paste( false ); allow_format( false ); allow_toggle_swap_mount_state( false ) ;
|
||||||
allow_info( false ) ;
|
allow_manage_flags( false ) ; allow_info( false ) ;
|
||||||
|
|
||||||
dynamic_cast<Gtk::Label*>(menu_partition .items()[ 10 ] .get_child() ) ->set_label( _("unmount") ) ;
|
dynamic_cast<Gtk::Label*>(menu_partition .items()[ 10 ] .get_child() ) ->set_label( _("unmount") ) ;
|
||||||
menu_partition .items()[ 10 ] .show() ;
|
menu_partition .items()[ 10 ] .show() ;
|
||||||
|
@ -737,6 +744,10 @@ void Win_GParted::set_valid_operations()
|
||||||
//if there's something, there's some info ;)
|
//if there's something, there's some info ;)
|
||||||
allow_info( true ) ;
|
allow_info( true ) ;
|
||||||
|
|
||||||
|
//flag managing..
|
||||||
|
if ( selected_partition .type != GParted::TYPE_UNALLOCATED && selected_partition .status == GParted::STAT_REAL )
|
||||||
|
allow_manage_flags( true ) ;
|
||||||
|
|
||||||
//deal with swap...
|
//deal with swap...
|
||||||
if ( selected_partition .filesystem == GParted::FS_LINUX_SWAP )
|
if ( selected_partition .filesystem == GParted::FS_LINUX_SWAP )
|
||||||
{
|
{
|
||||||
|
@ -1659,6 +1670,23 @@ void Win_GParted::activate_disklabel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Win_GParted::activate_manage_flags()
|
||||||
|
{
|
||||||
|
DialogManageFlags dialog( selected_partition ) ;
|
||||||
|
dialog .set_transient_for( *this ) ;
|
||||||
|
|
||||||
|
dialog .signal_get_flags .connect(
|
||||||
|
sigc::mem_fun( &gparted_core, &GParted_Core::get_available_flags ) ) ;
|
||||||
|
dialog .signal_toggle_flag .connect(
|
||||||
|
sigc::mem_fun( &gparted_core, &GParted_Core::toggle_flag ) ) ;
|
||||||
|
|
||||||
|
dialog .run() ;
|
||||||
|
dialog .hide() ;
|
||||||
|
|
||||||
|
if ( dialog .any_change )
|
||||||
|
menu_gparted_refresh_devices() ;
|
||||||
|
}
|
||||||
|
|
||||||
void Win_GParted::activate_undo()
|
void Win_GParted::activate_undo()
|
||||||
{
|
{
|
||||||
//when undoing an creation it's safe to decrease the newcount by one
|
//when undoing an creation it's safe to decrease the newcount by one
|
||||||
|
|
Loading…
Reference in New Issue