emit proper signals for several events. cleanups..
* include/TreeView_Detail.h, src/TreeView_Detail.cc, include/VBox_VisualDisk.h, src/VBox_VisualDisk.cc, include/Win_GParted.h, src/Win_GParted.cc: emit proper signals for several events. * include/Partition.h, src/Partition.cc: cleanups..
This commit is contained in:
parent
adc76a7686
commit
7ef6e3e5c8
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2005-12-24 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||||
|
|
||||||
|
* include/TreeView_Detail.h,
|
||||||
|
src/TreeView_Detail.cc,
|
||||||
|
include/VBox_VisualDisk.h,
|
||||||
|
src/VBox_VisualDisk.cc,
|
||||||
|
include/Win_GParted.h,
|
||||||
|
src/Win_GParted.cc: emit proper signals for several events.
|
||||||
|
* include/Partition.h,
|
||||||
|
src/Partition.cc: cleanups..
|
||||||
|
|
||||||
2005-12-22 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
2005-12-22 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||||
|
|
||||||
* include/Partition.h,
|
* include/Partition.h,
|
||||||
|
|
|
@ -51,21 +51,21 @@ enum PartitionStatus {
|
||||||
class Partition
|
class Partition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Partition( ) ;
|
Partition() ;
|
||||||
~Partition( ) ;
|
~Partition() ;
|
||||||
|
|
||||||
void Reset( ) ;
|
void Reset() ;
|
||||||
|
|
||||||
//simple Set-functions. only for convenience, since most members are public
|
//simple Set-functions. only for convenience, since most members are public
|
||||||
void Set( const Glib::ustring & device_path,
|
void Set( const Glib::ustring & device_path,
|
||||||
const Glib::ustring & partition,
|
const Glib::ustring & partition,
|
||||||
const int partition_number,
|
int partition_number,
|
||||||
const PartitionType type,
|
PartitionType type,
|
||||||
const FILESYSTEM filesystem,
|
FILESYSTEM filesystem,
|
||||||
const Sector & sector_start,
|
Sector sector_start,
|
||||||
const Sector & sector_end,
|
Sector sector_end,
|
||||||
const bool inside_extended,
|
bool inside_extended,
|
||||||
const bool busy ) ;
|
bool busy ) ;
|
||||||
|
|
||||||
void Set_Unused( Sector sectors_unused ) ;
|
void Set_Unused( Sector sectors_unused ) ;
|
||||||
|
|
||||||
|
@ -74,11 +74,11 @@ public:
|
||||||
//update partition number (used when a logical partition is deleted)
|
//update partition number (used when a logical partition is deleted)
|
||||||
void Update_Number( int new_number );
|
void Update_Number( int new_number );
|
||||||
|
|
||||||
const long Get_Length_MB( ) const ;
|
long Get_Length_MB() const ;
|
||||||
const long Get_Used_MB( ) const ;
|
long Get_Used_MB() const ;
|
||||||
const long Get_Unused_MB( ) const ;
|
long Get_Unused_MB() const ;
|
||||||
|
|
||||||
bool operator==( const Partition & partition ) ;
|
bool operator==( const Partition & partition ) const ;
|
||||||
|
|
||||||
//some public members
|
//some public members
|
||||||
Glib::ustring partition;//the symbolic path (e.g. /dev/hda1 )
|
Glib::ustring partition;//the symbolic path (e.g. /dev/hda1 )
|
||||||
|
@ -92,7 +92,7 @@ public:
|
||||||
Sector sectors_used;
|
Sector sectors_used;
|
||||||
Sector sectors_unused;
|
Sector sectors_unused;
|
||||||
Gdk::Color color;
|
Gdk::Color color;
|
||||||
bool inside_extended;//used to check wether partition resides inside extended partition or not.
|
bool inside_extended;
|
||||||
bool busy;
|
bool busy;
|
||||||
Glib::ustring error;
|
Glib::ustring error;
|
||||||
Glib::ustring flags;
|
Glib::ustring flags;
|
||||||
|
|
|
@ -35,26 +35,32 @@ namespace GParted
|
||||||
class TreeView_Detail : public Gtk::TreeView
|
class TreeView_Detail : public Gtk::TreeView
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TreeView_Detail( );
|
TreeView_Detail();
|
||||||
void Load_Partitions( const std::vector<Partition> & partitions ) ;
|
void load_partitions( const std::vector<Partition> & partitions ) ;
|
||||||
void Set_Selected( const Partition & partition );
|
void set_selected( const Partition & partition );
|
||||||
void Clear( ) ;
|
void clear() ;
|
||||||
|
|
||||||
//signals for interclass communication
|
//signals for interclass communication
|
||||||
sigc::signal<void, GdkEventButton *, const Partition & > signal_mouse_click;
|
sigc::signal< void, const Partition &, bool > signal_partition_selected ;
|
||||||
|
sigc::signal< void > signal_partition_activated ;
|
||||||
|
sigc::signal< void, unsigned int, unsigned int > signal_popup_menu ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Create_Row( const Gtk::TreeRow & treerow, const Partition & partition );
|
bool set_selected( Gtk::TreeModel::Children rows, const Partition & partition, bool inside_extended = false ) ;
|
||||||
|
void create_row( const Gtk::TreeRow & treerow, const Partition & partition );
|
||||||
|
|
||||||
//overridden signal
|
//(overridden) signals
|
||||||
virtual bool on_button_press_event(GdkEventButton *);
|
bool on_button_press_event( GdkEventButton * event );
|
||||||
|
void on_row_activated( const Gtk::TreeModel::Path & path, Gtk::TreeViewColumn * column ) ;
|
||||||
|
void on_selection_changed() ;
|
||||||
|
|
||||||
Gtk::TreeRow row, childrow;
|
Gtk::TreeRow row, childrow;
|
||||||
Gtk::TreeIter iter, iter_child;
|
|
||||||
|
|
||||||
Glib::RefPtr<Gtk::TreeStore> treestore_detail;
|
Glib::RefPtr<Gtk::TreeStore> treestore_detail;
|
||||||
Glib::RefPtr<Gtk::TreeSelection> treeselection;
|
Glib::RefPtr<Gtk::TreeSelection> treeselection;
|
||||||
|
|
||||||
|
bool block ;
|
||||||
|
|
||||||
//columns for this treeview
|
//columns for this treeview
|
||||||
struct treeview_detail_Columns : public Gtk::TreeModelColumnRecord
|
struct treeview_detail_Columns : public Gtk::TreeModelColumnRecord
|
||||||
{
|
{
|
||||||
|
@ -79,8 +85,6 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
treeview_detail_Columns treeview_detail_columns;
|
treeview_detail_Columns treeview_detail_columns;
|
||||||
Partition partition_temp ; //used in Set_Selected to make the check a bit more readable
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} //GParted
|
} //GParted
|
||||||
|
|
|
@ -39,7 +39,9 @@ public:
|
||||||
void clear() ;
|
void clear() ;
|
||||||
|
|
||||||
//public signal for interclass communication
|
//public signal for interclass communication
|
||||||
sigc::signal<void, GdkEventButton *, const Partition &> signal_mouse_click;
|
sigc::signal< void, const Partition &, bool > signal_partition_selected ;
|
||||||
|
sigc::signal< void > signal_partition_activated ;
|
||||||
|
sigc::signal< void, unsigned int, unsigned int > signal_popup_menu ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct visual_partition ;
|
struct visual_partition ;
|
||||||
|
|
|
@ -131,7 +131,10 @@ private:
|
||||||
void menu_help_contents( );
|
void menu_help_contents( );
|
||||||
void menu_help_about( );
|
void menu_help_about( );
|
||||||
|
|
||||||
void mouse_click( GdkEventButton*, const Partition & );
|
void on_partition_selected( const Partition & partition, bool src_is_treeview ) ;
|
||||||
|
void on_partition_activated() ;
|
||||||
|
void on_partition_popup_menu( unsigned int button, unsigned int time ) ;
|
||||||
|
|
||||||
bool max_amount_prim_reached( ) ;
|
bool max_amount_prim_reached( ) ;
|
||||||
|
|
||||||
void activate_resize( );
|
void activate_resize( );
|
||||||
|
|
|
@ -20,12 +20,12 @@
|
||||||
namespace GParted
|
namespace GParted
|
||||||
{
|
{
|
||||||
|
|
||||||
Partition::Partition( )
|
Partition::Partition()
|
||||||
{
|
{
|
||||||
Reset( ) ;
|
Reset() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Partition::Reset( )
|
void Partition::Reset()
|
||||||
{
|
{
|
||||||
partition = error = flags = mountpoint = "" ;
|
partition = error = flags = mountpoint = "" ;
|
||||||
status = GParted::STAT_REAL ;
|
status = GParted::STAT_REAL ;
|
||||||
|
@ -34,18 +34,18 @@ void Partition::Reset( )
|
||||||
partition_number = sector_start = sector_end = sectors_used = sectors_unused = -1;
|
partition_number = sector_start = sector_end = sectors_used = sectors_unused = -1;
|
||||||
color .set( "black" ) ;
|
color .set( "black" ) ;
|
||||||
inside_extended = busy = false ;
|
inside_extended = busy = false ;
|
||||||
logicals .clear( ) ;
|
logicals .clear() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Partition::Set( const Glib::ustring & device_path,
|
void Partition::Set( const Glib::ustring & device_path,
|
||||||
const Glib::ustring & partition,
|
const Glib::ustring & partition,
|
||||||
const int partition_number,
|
int partition_number,
|
||||||
const PartitionType type,
|
PartitionType type,
|
||||||
const FILESYSTEM filesystem,
|
FILESYSTEM filesystem,
|
||||||
const Sector & sector_start,
|
Sector sector_start,
|
||||||
const Sector & sector_end,
|
Sector sector_end,
|
||||||
const bool inside_extended,
|
bool inside_extended,
|
||||||
const bool busy )
|
bool busy )
|
||||||
{
|
{
|
||||||
this ->device_path = device_path ;
|
this ->device_path = device_path ;
|
||||||
this ->partition = partition;
|
this ->partition = partition;
|
||||||
|
@ -90,29 +90,29 @@ void Partition::Update_Number( int new_number )
|
||||||
this ->partition = device_path + Utils::num_to_str( partition_number ) ;
|
this ->partition = device_path + Utils::num_to_str( partition_number ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
const long Partition::Get_Length_MB( ) const
|
long Partition::Get_Length_MB() const
|
||||||
{
|
{
|
||||||
return Utils::Sector_To_MB( sector_end - sector_start ) ;
|
return Utils::Sector_To_MB( sector_end - sector_start ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
const long Partition::Get_Used_MB( ) const
|
long Partition::Get_Used_MB() const
|
||||||
{
|
{
|
||||||
return Utils::Sector_To_MB( this ->sectors_used ) ;
|
return Utils::Sector_To_MB( this ->sectors_used ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
const long Partition::Get_Unused_MB( ) const
|
long Partition::Get_Unused_MB() const
|
||||||
{
|
{
|
||||||
return Get_Length_MB( ) - Get_Used_MB( ) ;
|
return Get_Length_MB() - Get_Used_MB( ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Partition::operator==( const Partition & partition )
|
bool Partition::operator==( const Partition & partition ) const
|
||||||
{
|
{
|
||||||
return this ->partition_number == partition .partition_number &&
|
return this ->partition_number == partition .partition_number &&
|
||||||
this ->sector_start == partition .sector_start &&
|
this ->sector_start == partition .sector_start &&
|
||||||
this ->type == partition .type ;
|
this ->type == partition .type ;
|
||||||
}
|
}
|
||||||
|
|
||||||
Partition::~Partition( )
|
Partition::~Partition()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,106 +22,100 @@ namespace GParted
|
||||||
|
|
||||||
TreeView_Detail::TreeView_Detail( )
|
TreeView_Detail::TreeView_Detail( )
|
||||||
{
|
{
|
||||||
treestore_detail = Gtk::TreeStore::create( treeview_detail_columns );
|
block = false ;
|
||||||
this ->set_model( treestore_detail );
|
|
||||||
this ->set_rules_hint( true );
|
treestore_detail = Gtk::TreeStore::create( treeview_detail_columns );
|
||||||
this ->treeselection = this ->get_selection();
|
set_model( treestore_detail );
|
||||||
|
set_rules_hint( true );
|
||||||
//append columns
|
treeselection = get_selection();
|
||||||
this->append_column( _("Partition"), treeview_detail_columns .partition );
|
treeselection ->signal_changed() .connect( sigc::mem_fun( *this, &TreeView_Detail::on_selection_changed ) );
|
||||||
this->append_column( _("Filesystem"), treeview_detail_columns .color );
|
|
||||||
this->append_column( _("Size(MB)"), treeview_detail_columns .size );
|
//append columns
|
||||||
this->append_column( _("Used(MB)"), treeview_detail_columns .used );
|
append_column( _("Partition"), treeview_detail_columns .partition );
|
||||||
this->append_column( _("Unused(MB)"), treeview_detail_columns .unused );
|
append_column( _("Filesystem"), treeview_detail_columns .color );
|
||||||
this->append_column( _("Flags"), treeview_detail_columns .flags );
|
append_column( _("Size(MB)"), treeview_detail_columns .size );
|
||||||
|
append_column( _("Used(MB)"), treeview_detail_columns .used );
|
||||||
|
append_column( _("Unused(MB)"), treeview_detail_columns .unused );
|
||||||
|
append_column( _("Flags"), treeview_detail_columns .flags );
|
||||||
|
|
||||||
|
|
||||||
//status_icon
|
//status_icon
|
||||||
this ->get_column( 0 ) ->pack_start( treeview_detail_columns.status_icon, false );
|
get_column( 0 ) ->pack_start( treeview_detail_columns.status_icon, false );
|
||||||
|
|
||||||
//filesystem text
|
//filesystem text
|
||||||
this ->get_column( 1 ) ->pack_start( treeview_detail_columns .filesystem, true );
|
get_column( 1 ) ->pack_start( treeview_detail_columns .filesystem, true );
|
||||||
|
|
||||||
//colored text in Partition column
|
//colored text in Partition column
|
||||||
Gtk::CellRendererText *cell_renderer_text = dynamic_cast<Gtk::CellRendererText*>( this->get_column( 0 ) ->get_first_cell_renderer( ) );
|
Gtk::CellRendererText *cell_renderer_text = dynamic_cast<Gtk::CellRendererText*>( get_column( 0 ) ->get_first_cell_renderer( ) );
|
||||||
this->get_column( 0 ) ->add_attribute( cell_renderer_text ->property_foreground(), treeview_detail_columns .text_color );
|
get_column( 0 ) ->add_attribute( cell_renderer_text ->property_foreground(), treeview_detail_columns .text_color );
|
||||||
|
|
||||||
//colored text in Filesystem column
|
//colored text in Filesystem column
|
||||||
std::vector<Gtk::CellRenderer *> renderers = this ->get_column( 1 ) ->get_cell_renderers() ;
|
std::vector<Gtk::CellRenderer *> renderers = get_column( 1 ) ->get_cell_renderers() ;
|
||||||
cell_renderer_text = dynamic_cast<Gtk::CellRendererText*>( renderers .back() ) ;
|
cell_renderer_text = dynamic_cast<Gtk::CellRendererText*>( renderers .back() ) ;
|
||||||
this ->get_column( 1 ) ->add_attribute( cell_renderer_text ->property_foreground(), treeview_detail_columns .text_color );
|
get_column( 1 ) ->add_attribute( cell_renderer_text ->property_foreground(), treeview_detail_columns .text_color );
|
||||||
|
|
||||||
//set alignment of numeric columns to right
|
//set alignment of numeric columns to right
|
||||||
for( short t = 2 ; t < 5 ; t++ )
|
for( short t = 2 ; t < 5 ; t++ )
|
||||||
dynamic_cast<Gtk::CellRendererText*>( this ->get_column( t ) ->get_first_cell_renderer() ) ->property_xalign() = 1 ;
|
dynamic_cast<Gtk::CellRendererText*>( get_column( t ) ->get_first_cell_renderer() ) ->property_xalign() = 1 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TreeView_Detail::Load_Partitions( const std::vector<Partition> & partitions )
|
void TreeView_Detail::load_partitions( const std::vector<Partition> & partitions )
|
||||||
{
|
{
|
||||||
treestore_detail ->clear( ) ;
|
treestore_detail ->clear() ;
|
||||||
|
|
||||||
for ( unsigned int i = 0 ; i < partitions .size( ) ; i++ )
|
for ( unsigned int i = 0 ; i < partitions .size() ; i++ )
|
||||||
{
|
{
|
||||||
row = *( treestore_detail ->append( ) );
|
row = *( treestore_detail ->append() );
|
||||||
Create_Row( row, partitions[ i ] );
|
create_row( row, partitions[ i ] );
|
||||||
|
|
||||||
if ( partitions[ i ] .type == GParted::TYPE_EXTENDED )
|
if ( partitions[ i ] .type == GParted::TYPE_EXTENDED )
|
||||||
{
|
{
|
||||||
for ( unsigned int t = 0 ; t < partitions[ i ] .logicals .size( ) ; t++ )
|
for ( unsigned int t = 0 ; t < partitions[ i ] .logicals .size() ; t++ )
|
||||||
{
|
{
|
||||||
childrow = *( treestore_detail ->append( row.children( ) ) );
|
childrow = *( treestore_detail ->append( row.children() ) );
|
||||||
Create_Row( childrow, partitions[ i ] .logicals[ t ] );
|
create_row( childrow, partitions[ i ] .logicals[ t ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//show logical partitions ( if any )
|
//show logical partitions ( if any )
|
||||||
this ->expand_all( );
|
expand_all();
|
||||||
|
|
||||||
this ->columns_autosize( );
|
columns_autosize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TreeView_Detail::Set_Selected( const Partition & partition )
|
void TreeView_Detail::set_selected( const Partition & partition )
|
||||||
{
|
{
|
||||||
//look for appropiate row
|
block = true ;
|
||||||
for( iter = treestore_detail ->children() .begin() ; iter != treestore_detail ->children() .end() ; iter++ )
|
set_selected( treestore_detail ->children(), partition ) ;
|
||||||
|
block = false ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TreeView_Detail::clear()
|
||||||
|
{
|
||||||
|
treestore_detail ->clear() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TreeView_Detail::set_selected( Gtk::TreeModel::Children rows, const Partition & partition, bool inside_extended )
|
||||||
|
{
|
||||||
|
for ( unsigned int t = 0 ; t < rows .size() ; t++ )
|
||||||
{
|
{
|
||||||
row = *iter;
|
if ( static_cast<Partition>( rows[ t ] [ treeview_detail_columns .partition_struct ] ) == partition )
|
||||||
partition_temp = row[ treeview_detail_columns.partition_struct ] ;
|
|
||||||
//primary's
|
|
||||||
if ( partition .sector_start >= partition_temp .sector_start &&
|
|
||||||
partition .sector_end <=partition_temp .sector_end &&
|
|
||||||
partition.inside_extended == partition_temp.inside_extended )
|
|
||||||
{
|
{
|
||||||
this ->set_cursor( static_cast <Gtk::TreePath> ( row ) );
|
if ( inside_extended )
|
||||||
return;
|
expand_all() ;
|
||||||
|
|
||||||
|
set_cursor( static_cast<Gtk::TreePath>( rows[ t ] ) ) ;
|
||||||
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//logicals
|
if ( rows[ t ] .children() .size() > 0 && set_selected( rows[ t ] .children(), partition, true ) )
|
||||||
if ( row .children() .size( ) > 0 ) //this is the row with the extended partition, search it's childrows...
|
return true ;
|
||||||
for( iter_child = row .children() .begin() ; iter_child != row.children() .end() ; iter_child++ )
|
|
||||||
{
|
|
||||||
childrow = *iter_child;
|
|
||||||
partition_temp = childrow[ treeview_detail_columns.partition_struct ] ;
|
|
||||||
|
|
||||||
if ( partition .sector_start >= partition_temp .sector_start && partition .sector_end <= partition_temp .sector_end )
|
|
||||||
{
|
|
||||||
this ->expand_all();
|
|
||||||
this ->set_cursor( static_cast <Gtk::TreePath> ( childrow ) );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TreeView_Detail::Clear( )
|
void TreeView_Detail::create_row( const Gtk::TreeRow & treerow, const Partition & partition )
|
||||||
{
|
|
||||||
treestore_detail ->clear( ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TreeView_Detail::Create_Row( const Gtk::TreeRow & treerow, const Partition & partition )
|
|
||||||
{
|
{
|
||||||
//hereby i assume these 2 are mutual exclusive. is this wise?? Time (and bugreports) will tell :)
|
//hereby i assume these 2 are mutual exclusive. is this wise?? Time (and bugreports) will tell :)
|
||||||
if ( partition .busy )
|
if ( partition .busy )
|
||||||
|
@ -132,24 +126,20 @@ void TreeView_Detail::Create_Row( const Gtk::TreeRow & treerow, const Partition
|
||||||
treerow[ treeview_detail_columns .partition ] = partition .partition;
|
treerow[ treeview_detail_columns .partition ] = partition .partition;
|
||||||
treerow[ treeview_detail_columns .color ] = Utils::get_color_as_pixbuf( partition .filesystem, 16, 16 ) ;
|
treerow[ treeview_detail_columns .color ] = Utils::get_color_as_pixbuf( partition .filesystem, 16, 16 ) ;
|
||||||
|
|
||||||
treerow[ treeview_detail_columns .text_color ] = ( partition .type == GParted::TYPE_UNALLOCATED ) ? "darkgrey" : "black" ;
|
treerow[ treeview_detail_columns .text_color ] = partition .type == GParted::TYPE_UNALLOCATED ? "darkgrey" : "black" ;
|
||||||
treerow[ treeview_detail_columns .filesystem ] = Utils::Get_Filesystem_String( partition .filesystem ) ;
|
treerow[ treeview_detail_columns .filesystem ] = Utils::Get_Filesystem_String( partition .filesystem ) ;
|
||||||
|
|
||||||
//size
|
//size
|
||||||
treerow[ treeview_detail_columns .size ] = Utils::num_to_str( partition .Get_Length_MB( ) ) ;
|
treerow[ treeview_detail_columns .size ] = Utils::num_to_str( partition .Get_Length_MB() ) ;
|
||||||
|
|
||||||
//used
|
//used
|
||||||
if ( partition .sectors_used != -1 )
|
treerow[ treeview_detail_columns .used ] =
|
||||||
treerow[ treeview_detail_columns .used ] = Utils::num_to_str( partition .Get_Used_MB( ) ) ;
|
partition .sectors_used == -1 ? "---" : Utils::num_to_str( partition .Get_Used_MB() ) ;
|
||||||
else
|
|
||||||
treerow[ treeview_detail_columns .used ] = "---" ;
|
|
||||||
|
|
||||||
//unused
|
//unused
|
||||||
if ( partition .sectors_unused != -1 )
|
treerow[ treeview_detail_columns .unused ] =
|
||||||
treerow[ treeview_detail_columns .unused ] = Utils::num_to_str( partition .Get_Unused_MB( ) ) ;
|
partition .sectors_unused == -1 ? "---" : Utils::num_to_str( partition .Get_Unused_MB() ) ;
|
||||||
else
|
|
||||||
treerow[ treeview_detail_columns .unused ] = "---" ;
|
|
||||||
|
|
||||||
//flags
|
//flags
|
||||||
treerow[ treeview_detail_columns .flags ] = " " + partition .flags ;
|
treerow[ treeview_detail_columns .flags ] = " " + partition .flags ;
|
||||||
|
|
||||||
|
@ -157,20 +147,33 @@ void TreeView_Detail::Create_Row( const Gtk::TreeRow & treerow, const Partition
|
||||||
treerow[ treeview_detail_columns .partition_struct ] = partition;
|
treerow[ treeview_detail_columns .partition_struct ] = partition;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TreeView_Detail::on_button_press_event( GdkEventButton* event )
|
bool TreeView_Detail::on_button_press_event( GdkEventButton * event )
|
||||||
{
|
{
|
||||||
//Call base class, to allow normal handling,
|
//Call base class, to allow normal handling,
|
||||||
bool return_value = TreeView::on_button_press_event( event );
|
bool handled = Gtk::TreeView::on_button_press_event( event ) ;
|
||||||
|
|
||||||
iter = treeselection ->get_selected( );
|
//right-click
|
||||||
|
if ( event ->button == 3 )
|
||||||
if ( *iter != 0 )
|
signal_popup_menu .emit( event ->button, event ->time ) ;
|
||||||
{
|
|
||||||
row = *iter;
|
return handled ;
|
||||||
signal_mouse_click .emit( event, row[ treeview_detail_columns .partition_struct ] );
|
|
||||||
}
|
|
||||||
|
|
||||||
return return_value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TreeView_Detail::on_row_activated( const Gtk::TreeModel::Path & path, Gtk::TreeViewColumn * column )
|
||||||
|
{
|
||||||
|
//Call base class, to allow normal handling,
|
||||||
|
Gtk::TreeView::on_row_activated( path, column ) ;
|
||||||
|
|
||||||
|
signal_partition_activated .emit() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TreeView_Detail::on_selection_changed()
|
||||||
|
{
|
||||||
|
if ( ! block && treeselection ->get_selected() != 0 )
|
||||||
|
{
|
||||||
|
row = (Gtk::TreeRow) * treeselection ->get_selected() ;
|
||||||
|
signal_partition_selected .emit( row[ treeview_detail_columns .partition_struct ], true ) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} //GParted
|
} //GParted
|
||||||
|
|
|
@ -414,8 +414,15 @@ bool VBox_VisualDisk::drawingarea_on_expose( GdkEventExpose * event )
|
||||||
|
|
||||||
bool VBox_VisualDisk::on_drawingarea_button_press( GdkEventButton * event )
|
bool VBox_VisualDisk::on_drawingarea_button_press( GdkEventButton * event )
|
||||||
{
|
{
|
||||||
if ( set_selected( visual_partitions, static_cast<int>( event ->x ), static_cast<int>( event ->y ) ) )
|
set_selected( visual_partitions, static_cast<int>( event ->x ), static_cast<int>( event ->y ) ) ;
|
||||||
signal_mouse_click .emit( event, selected_vp .partition );
|
draw_partitions( visual_partitions ) ;
|
||||||
|
|
||||||
|
signal_partition_selected .emit( selected_vp .partition, false ) ;
|
||||||
|
|
||||||
|
if ( event ->type == GDK_2BUTTON_PRESS )
|
||||||
|
signal_partition_activated .emit() ;
|
||||||
|
else if ( event ->button == 3 )
|
||||||
|
signal_popup_menu .emit( event ->button, event ->time ) ;
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,9 @@ Win_GParted::Win_GParted( )
|
||||||
vbox_main.pack_start( hbox_toolbar, Gtk::PACK_SHRINK );
|
vbox_main.pack_start( hbox_toolbar, Gtk::PACK_SHRINK );
|
||||||
|
|
||||||
//vbox_visual_disk... ( contains the visual represenation of the disks )
|
//vbox_visual_disk... ( contains the visual represenation of the disks )
|
||||||
vbox_visual_disk .signal_mouse_click.connect( sigc::mem_fun( this, &Win_GParted::mouse_click ) ) ;
|
vbox_visual_disk .signal_partition_selected .connect( sigc::mem_fun( this, &Win_GParted::on_partition_selected ) ) ;
|
||||||
|
vbox_visual_disk .signal_partition_activated .connect( sigc::mem_fun( this, &Win_GParted::on_partition_activated ) ) ;
|
||||||
|
vbox_visual_disk .signal_popup_menu .connect( sigc::mem_fun( this, &Win_GParted::on_partition_popup_menu ) );
|
||||||
vbox_main .pack_start( vbox_visual_disk, Gtk::PACK_SHRINK ) ;
|
vbox_main .pack_start( vbox_visual_disk, Gtk::PACK_SHRINK ) ;
|
||||||
|
|
||||||
//hpaned_main (NOTE: added to vpaned_main)
|
//hpaned_main (NOTE: added to vpaned_main)
|
||||||
|
@ -341,8 +343,10 @@ void Win_GParted::init_hpaned_main( )
|
||||||
scrollwindow ->set_shadow_type( Gtk::SHADOW_ETCHED_IN );
|
scrollwindow ->set_shadow_type( Gtk::SHADOW_ETCHED_IN );
|
||||||
scrollwindow ->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC );
|
scrollwindow ->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC );
|
||||||
|
|
||||||
//connect signal and add treeview_detail
|
//connect signals and add treeview_detail
|
||||||
treeview_detail .signal_mouse_click .connect( sigc::mem_fun( this, &Win_GParted::mouse_click ) );
|
treeview_detail .signal_partition_selected .connect( sigc::mem_fun( this, &Win_GParted::on_partition_selected ) );
|
||||||
|
treeview_detail .signal_partition_activated .connect( sigc::mem_fun( this, &Win_GParted::on_partition_activated ) );
|
||||||
|
treeview_detail .signal_popup_menu .connect( sigc::mem_fun( this, &Win_GParted::on_partition_popup_menu ) );
|
||||||
scrollwindow ->add( treeview_detail );
|
scrollwindow ->add( treeview_detail );
|
||||||
hpaned_main.pack2( *scrollwindow, true, true );
|
hpaned_main.pack2( *scrollwindow, true, true );
|
||||||
}
|
}
|
||||||
|
@ -532,7 +536,7 @@ void Win_GParted::Refresh_Visual( )
|
||||||
vbox_visual_disk .load_partitions( partitions, devices[ current_device ] .length ) ;
|
vbox_visual_disk .load_partitions( partitions, devices[ current_device ] .length ) ;
|
||||||
|
|
||||||
//treeview details
|
//treeview details
|
||||||
treeview_detail .Load_Partitions( partitions ) ;
|
treeview_detail .load_partitions( partitions ) ;
|
||||||
|
|
||||||
//no partition can be selected after a refresh..
|
//no partition can be selected after a refresh..
|
||||||
selected_partition .Reset() ;
|
selected_partition .Reset() ;
|
||||||
|
@ -752,7 +756,7 @@ void Win_GParted::menu_gparted_refresh_devices( )
|
||||||
Fill_Label_Device_Info( true ) ;
|
Fill_Label_Device_Info( true ) ;
|
||||||
|
|
||||||
vbox_visual_disk .clear() ;
|
vbox_visual_disk .clear() ;
|
||||||
treeview_detail .Clear() ;
|
treeview_detail .clear() ;
|
||||||
|
|
||||||
//hmzz, this is really paranoid, but i think it's the right thing to do ;)
|
//hmzz, this is really paranoid, but i think it's the right thing to do ;)
|
||||||
liststore_operations ->clear( ) ;
|
liststore_operations ->clear( ) ;
|
||||||
|
@ -869,26 +873,27 @@ void Win_GParted::menu_help_about( )
|
||||||
dialog .run( ) ;
|
dialog .run( ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Win_GParted::mouse_click( GdkEventButton *event, const Partition & partition )
|
void Win_GParted::on_partition_selected( const Partition & partition, bool src_is_treeview )
|
||||||
{
|
{
|
||||||
selected_partition = partition;
|
selected_partition = partition;
|
||||||
|
|
||||||
Set_Valid_Operations( ) ;
|
Set_Valid_Operations() ;
|
||||||
|
|
||||||
treeview_detail .Set_Selected( partition );
|
if ( src_is_treeview )
|
||||||
|
vbox_visual_disk .set_selected( partition ) ;
|
||||||
vbox_visual_disk .set_selected( partition ) ;
|
else
|
||||||
|
treeview_detail .set_selected( partition ) ;
|
||||||
if ( event ->type == GDK_2BUTTON_PRESS && ! pulse )
|
}
|
||||||
activate_info( ) ;
|
|
||||||
else if ( event ->button == 3 ) //right-click
|
void Win_GParted::on_partition_activated()
|
||||||
{
|
{
|
||||||
//prepare convert menu
|
if ( ! pulse )
|
||||||
if ( selected_partition .type != GParted::TYPE_UNALLOCATED )
|
activate_info() ;
|
||||||
Set_Valid_Convert_Filesystems( ) ;
|
}
|
||||||
|
|
||||||
menu_partition .popup( event ->button, event ->time );
|
void Win_GParted::on_partition_popup_menu( unsigned int button, unsigned int time )
|
||||||
}
|
{
|
||||||
|
menu_partition .popup( button, time );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Win_GParted::max_amount_prim_reached( )
|
bool Win_GParted::max_amount_prim_reached( )
|
||||||
|
|
Loading…
Reference in New Issue