Pass by pointer in the signal_partition_selected callbacks (#750168)

Change from passing a reference to the selected partition, to passing a
pointer to the selected partition in the signal_partition_selected
callbacks between the disk graphic, partition list and core GUI modules.

This is an enabler for the following patches.

Bug 750168 - Reduce the amount of copying of partition objects
This commit is contained in:
Mike Fleetwood 2015-05-16 17:06:22 +01:00 committed by Curtis Gedak
parent 545b75d957
commit c430acf52a
6 changed files with 32 additions and 29 deletions

View file

@ -31,11 +31,11 @@ public:
~DrawingAreaVisualDisk();
void load_partitions( const std::vector<Partition> & partitions, Sector device_length );
void set_selected( const Partition & partition ) ;
void set_selected( const Partition * partition_ptr );
void clear() ;
//public signals for interclass communication
sigc::signal< void, const Partition &, bool > signal_partition_selected ;
// Public signals for interclass communication
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 ;
@ -57,7 +57,7 @@ private:
void draw_partitions( const std::vector<visual_partition> & visual_partitions ) ;
void set_selected( const std::vector<visual_partition> & visual_partitions, int x, int y ) ;
void set_selected( const std::vector<visual_partition> & visual_partitions, const Partition & partition ) ;
void set_selected( const std::vector<visual_partition> & visual_partitions, const Partition * partition_ptr );
int spreadout_leftover_px( std::vector<visual_partition> & visual_partitions, int pixels ) ;
void free_colors( std::vector<visual_partition> & visual_partitions ) ;

View file

@ -36,11 +36,11 @@ class TreeView_Detail : public Gtk::TreeView
public:
TreeView_Detail();
void load_partitions( const std::vector<Partition> & partitions ) ;
void set_selected( const Partition & partition );
void set_selected( const Partition * partition_ptr );
void clear() ;
//signals for interclass communication
sigc::signal< void, const Partition &, bool > signal_partition_selected ;
// Signals for interclass communication
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 ;
@ -50,7 +50,8 @@ private:
bool & labels,
bool & names,
const Gtk::TreeRow & parent_row = Gtk::TreeRow() );
bool set_selected( Gtk::TreeModel::Children rows, const Partition & partition, bool inside_extended = false ) ;
bool set_selected( Gtk::TreeModel::Children rows,
const Partition * partition_ptr, bool inside_extended = false );
void create_row( const Gtk::TreeRow & treerow, const Partition & partition );
//(overridden) signals

View file

@ -151,7 +151,7 @@ private:
void menu_help_contents();
void menu_help_about();
void on_partition_selected( const Partition & partition, bool src_is_treeview ) ;
void on_partition_selected( const Partition * partition_ptr, bool src_is_treeview );
void on_partition_activated() ;
void on_partition_popup_menu( unsigned int button, unsigned int time ) ;

View file

@ -57,10 +57,10 @@ void DrawingAreaVisualDisk::load_partitions( const std::vector<Partition> & part
queue_resize() ;
}
void DrawingAreaVisualDisk::set_selected( const Partition & partition )
void DrawingAreaVisualDisk::set_selected( const Partition * partition_ptr )
{
selected_vp = NULL ;
set_selected( visual_partitions, partition ) ;
set_selected( visual_partitions, partition_ptr );
queue_draw() ;
}
@ -307,14 +307,14 @@ void DrawingAreaVisualDisk::set_selected( const std::vector<visual_partition> &
}
void DrawingAreaVisualDisk::set_selected( const std::vector<visual_partition> & visual_partitions,
const Partition & partition )
const Partition * partition_ptr )
{
for ( unsigned int t = 0 ; t < visual_partitions .size() && ! selected_vp ; t++ )
{
if ( visual_partitions[ t ] .logicals .size() > 0 )
set_selected( visual_partitions[ t ] .logicals, partition ) ;
set_selected( visual_partitions[t].logicals, partition_ptr );
if ( ! selected_vp && visual_partitions[ t ] .partition == partition )
if ( ! selected_vp && visual_partitions[t].partition == *partition_ptr )
selected_vp = & visual_partitions[ t ] ;
}
}
@ -361,7 +361,7 @@ bool DrawingAreaVisualDisk::on_button_press_event( GdkEventButton * event )
if ( selected_vp )
{
signal_partition_selected .emit( selected_vp ->partition, false ) ;
signal_partition_selected.emit( & selected_vp->partition, false );
if ( event ->type == GDK_2BUTTON_PRESS )
signal_partition_activated .emit() ;

View file

@ -99,10 +99,10 @@ void TreeView_Detail::load_partitions( const std::vector<Partition> & partitions
expand_all() ;
}
void TreeView_Detail::set_selected( const Partition & partition )
void TreeView_Detail::set_selected( const Partition * partition_ptr )
{
block = true ;
set_selected( treestore_detail ->children(), partition ) ;
set_selected( treestore_detail->children(), partition_ptr );
block = false ;
}
@ -137,11 +137,12 @@ void TreeView_Detail::load_partitions( const std::vector<Partition> & partitions
}
}
bool TreeView_Detail::set_selected( Gtk::TreeModel::Children rows, const Partition & partition, bool inside_extended )
bool TreeView_Detail::set_selected( Gtk::TreeModel::Children rows,
const Partition * partition_ptr, bool inside_extended )
{
for ( unsigned int t = 0 ; t < rows .size() ; t++ )
{
if ( static_cast<Partition>( rows[ t ] [ treeview_detail_columns .partition ] ) == partition )
if ( static_cast<Partition>( rows[t][treeview_detail_columns.partition] ) == *partition_ptr )
{
if ( inside_extended )
expand_all() ;
@ -150,7 +151,7 @@ bool TreeView_Detail::set_selected( Gtk::TreeModel::Children rows, const Partiti
return true ;
}
if ( set_selected( rows[ t ] .children(), partition, true ) )
if ( set_selected( rows[t].children(), partition_ptr, true ) )
return true ;
}
@ -240,7 +241,8 @@ void TreeView_Detail::on_selection_changed()
if ( ! block && treeselection ->get_selected() != 0 )
{
Gtk::TreeRow row = static_cast<Gtk::TreeRow>( * treeselection ->get_selected() ) ;
signal_partition_selected .emit( row[ treeview_detail_columns .partition ], true ) ;
Partition selected_partition = row[treeview_detail_columns.partition];
signal_partition_selected.emit( & selected_partition, true );
}
}

View file

@ -914,8 +914,8 @@ void Win_GParted::Refresh_Visual()
{
// Flashing redraw work around. Inform visuals of selection of the
// largest unallocated partition after drawing those visuals above.
drawingarea_visualdisk .set_selected( selected_partition ) ;
treeview_detail .set_selected( selected_partition ) ;
drawingarea_visualdisk.set_selected( & selected_partition );
treeview_detail.set_selected( & selected_partition );
// Process Gtk events to draw selection
while ( Gtk::Main::events_pending() )
@ -1551,16 +1551,16 @@ void Win_GParted::menu_help_about()
dialog .run() ;
}
void Win_GParted::on_partition_selected( const Partition & partition, bool src_is_treeview )
void Win_GParted::on_partition_selected( const Partition * partition_ptr, bool src_is_treeview )
{
selected_partition = partition;
selected_partition = * partition_ptr;
set_valid_operations() ;
if ( src_is_treeview )
drawingarea_visualdisk .set_selected( partition ) ;
drawingarea_visualdisk.set_selected( partition_ptr );
else
treeview_detail .set_selected( partition ) ;
treeview_detail.set_selected( partition_ptr );
}
void Win_GParted::on_partition_activated()