[gparted] Pass by pointer in the signal_partition_selected callbacks (#750168)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Pass by pointer in the signal_partition_selected callbacks (#750168)
- Date: Sat, 13 Jun 2015 16:10:58 +0000 (UTC)
commit c430acf52affb07d65cad78f598e31fb5f1c05ee
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Sat May 16 17:06:22 2015 +0100
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
include/DrawingAreaVisualDisk.h | 10 +++++-----
include/TreeView_Detail.h | 9 +++++----
include/Win_GParted.h | 2 +-
src/DrawingAreaVisualDisk.cc | 12 ++++++------
src/TreeView_Detail.cc | 14 ++++++++------
src/Win_GParted.cc | 14 +++++++-------
6 files changed, 32 insertions(+), 29 deletions(-)
---
diff --git a/include/DrawingAreaVisualDisk.h b/include/DrawingAreaVisualDisk.h
index 082bc8f..d7c7ca2 100644
--- a/include/DrawingAreaVisualDisk.h
+++ b/include/DrawingAreaVisualDisk.h
@@ -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,8 +57,8 @@ 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 ) ;
diff --git a/include/TreeView_Detail.h b/include/TreeView_Detail.h
index 24d1cb4..14e367d 100644
--- a/include/TreeView_Detail.h
+++ b/include/TreeView_Detail.h
@@ -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
diff --git a/include/Win_GParted.h b/include/Win_GParted.h
index 1d8d7e2..8029da8 100644
--- a/include/Win_GParted.h
+++ b/include/Win_GParted.h
@@ -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 ) ;
diff --git a/src/DrawingAreaVisualDisk.cc b/src/DrawingAreaVisualDisk.cc
index 6a81c5a..6be86f4 100644
--- a/src/DrawingAreaVisualDisk.cc
+++ b/src/DrawingAreaVisualDisk.cc
@@ -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() ;
diff --git a/src/TreeView_Detail.cc b/src/TreeView_Detail.cc
index 11ed160..2063508 100644
--- a/src/TreeView_Detail.cc
+++ b/src/TreeView_Detail.cc
@@ -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 );
}
}
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index 5a3454d..6983bb7 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -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()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]