From 067c1154aa7fc4afb1f3dd1d9e0c112b2c284573 Mon Sep 17 00:00:00 2001 From: Bart Hakvoort Date: Sun, 7 Nov 2004 13:13:11 +0000 Subject: [PATCH] make use of reference arguments instead of return values in some * include/Operation.h, src/Operation.cc: make use of reference arguments instead of return values in some functions. Also fixed a small bug with deletion of a virtual (new) logical partition. * include/VBox_VisualDisk.h, src/VBox_VisualDisk.cc: logical filesystems weren't shown in the legend, fixed. * src/Frame_Resizer_Base.cc: fixed small bug with custom cursors. * src/TreeView_Detail.cc: removed obsolete, already commented code. * src/Win_GParted.cc: make use of reference arguments instead of return values in some functions. (see Operation) --- ChangeLog | 11 +++++++++ include/Operation.h | 2 +- include/VBox_VisualDisk.h | 3 ++- src/Frame_Resizer_Base.cc | 2 +- src/Operation.cc | 11 +++++---- src/TreeView_Detail.cc | 15 ----------- src/VBox_VisualDisk.cc | 52 ++++++++++++++++++++++----------------- src/Win_GParted.cc | 4 +-- 8 files changed, 52 insertions(+), 48 deletions(-) diff --git a/ChangeLog b/ChangeLog index 399cdcaa..d71d26b2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2004-11-07 Bart Hakvoort + + * include/Operation.h, + src/Operation.cc: make use of reference arguments instead of return values in some functions. + Also fixed a small bug with deletion of a virtual (new) logical partition. + * include/VBox_VisualDisk.h, + src/VBox_VisualDisk.cc: logical filesystems weren't shown in the legend, fixed. + * src/Frame_Resizer_Base.cc: fixed small bug with custom cursors. + * src/TreeView_Detail.cc: removed obsolete, already commented code. + * src/Win_GParted.cc: make use of reference arguments instead of return values in some functions. (see Operation) + 2004-11-06 Bart Hakvoort * include/Win_GParted.h, diff --git a/include/Operation.h b/include/Operation.h index 03d5c8cf..aa82d68d 100644 --- a/include/Operation.h +++ b/include/Operation.h @@ -43,7 +43,7 @@ public: //this one can be a little confusing, it *DOES NOT* change any visual representation. It only applies the operation to the list with partitions. //this new list can be used to change the visual representation. For real writing to disk, see Apply_To_Disk() - std::vector Apply_Operation_To_Visual( std::vector & partitions ); + void Apply_Operation_To_Visual( std::vector & partitions ); void Apply_To_Disk( PedTimer * timer ); diff --git a/include/VBox_VisualDisk.h b/include/VBox_VisualDisk.h index 4f2d8fbb..f579971c 100644 --- a/include/VBox_VisualDisk.h +++ b/include/VBox_VisualDisk.h @@ -64,7 +64,8 @@ public: private: void Build_Visual_Disk( ) ; //i still dream of some fully resizeable visualdisk.... - void Create_Visual_Partition( Partition & partition ) ; + void Create_Visual_Partition( Partition & partition ) ; + void Prepare_Legend( std::vector & legend, const std::vector & partitions ) ; void Build_Legend( ) ; //signal handlers diff --git a/src/Frame_Resizer_Base.cc b/src/Frame_Resizer_Base.cc index 701cc437..a4f13943 100644 --- a/src/Frame_Resizer_Base.cc +++ b/src/Frame_Resizer_Base.cc @@ -210,7 +210,7 @@ bool Frame_Resizer_Base::drawingarea_on_button_release_event( GdkEventButton *ev bool Frame_Resizer_Base::drawingarea_on_leave_notify( GdkEventCrossing *ev ) { - if ( ! GRIP_LEFT && ! GRIP_RIGHT && ! GRIP_MOVE && (ev ->y > 50 - BORDER || ev ->y < BORDER) ) + if ( ev ->mode != GDK_CROSSING_GRAB && ! GRIP_LEFT && ! GRIP_RIGHT && ! GRIP_MOVE ) drawingarea .get_parent_window() ->set_cursor( *cursor_normal ) ; return true; diff --git a/src/Operation.cc b/src/Operation.cc index 9c25fa5a..f8f13f4d 100644 --- a/src/Operation.cc +++ b/src/Operation.cc @@ -99,7 +99,7 @@ Glib::ustring Operation::Get_String( ) } -std::vector Operation::Apply_Operation_To_Visual( std::vector & partitions ) +void Operation::Apply_Operation_To_Visual( std::vector & partitions ) { switch ( operationtype ) { @@ -109,8 +109,6 @@ std::vector Operation::Apply_Operation_To_Visual( std::vector & partitions void Operation::Apply_Resize_Move_Extended_To_Visual( std::vector & partitions ) { //stuff OUTSIDE extended partition - partitions[ Get_Index_Original( partitions ) ] = partition_new ; + unsigned int ext = Get_Index_Original( partitions ) ; + partitions[ ext ] .sector_start = partition_new .sector_start ; + partitions[ ext ] .sector_end = partition_new .sector_end ; + Insert_Unallocated( partitions, 0, device ->Get_Length( ) -1 ) ; //stuff INSIDE extended partition - unsigned int ext = 0 ; + ext = 0 ; while ( ext < partitions .size( ) && partitions[ ext ] .type != GParted::EXTENDED ) ext++ ; if ( partitions[ ext ] .logicals .size( ) && partitions[ ext ] .logicals .front( ) .type == GParted::UNALLOCATED ) diff --git a/src/TreeView_Detail.cc b/src/TreeView_Detail.cc index 02b34445..b227b21c 100644 --- a/src/TreeView_Detail.cc +++ b/src/TreeView_Detail.cc @@ -74,21 +74,6 @@ void TreeView_Detail::Load_Partitions( std::vector & partitions ) { treestore_detail ->clear() ; -/* for ( unsigned int i=0;iappend()); - Create_Row( row, partitions[i] ); - } - else - { - childrow = *(treestore_detail->append( row.children() )); - Create_Row( childrow, partitions[i] ); - } - } -*/ - for ( unsigned int i=0;iappend()); diff --git a/src/VBox_VisualDisk.cc b/src/VBox_VisualDisk.cc index 381d8f92..b0711484 100644 --- a/src/VBox_VisualDisk.cc +++ b/src/VBox_VisualDisk.cc @@ -170,48 +170,54 @@ void VBox_VisualDisk::Create_Visual_Partition( Partition & partition ) tooltips.set_tip( *(visual_partitions.back() ->drawingarea), str_temp ) ; } +void VBox_VisualDisk::Prepare_Legend( std::vector & legend, const std::vector & partitions ) +{ + for ( unsigned int t = 0 ; t < partitions .size( ) ; t++ ) + { + if ( std::find( legend .begin( ), legend .end( ), partitions[ t ] .filesystem ) == legend .end( ) ) + legend .push_back( partitions[ t ] .filesystem ); + + if ( partitions[ t ] .type == GParted::EXTENDED ) + Prepare_Legend( legend, partitions[ t ] .logicals ) ; + } +} void VBox_VisualDisk::Build_Legend( ) { //add the hboxes and frame_legenda - frame_disk_legend = manage( new Gtk::Frame() ) ; + frame_disk_legend = manage( new Gtk::Frame( ) ) ; hbox_legend_main.pack_start( *frame_disk_legend, Gtk::PACK_EXPAND_PADDING ); - hbox_legend = manage( new Gtk::HBox() ); + hbox_legend = manage( new Gtk::HBox ( ) ); frame_disk_legend ->add( *hbox_legend ) ; this ->pack_start( hbox_legend_main ); - std::vector legende; + std::vector legend ; + Prepare_Legend( legend, partitions ) ; + bool hide_used_unused = true; - - for ( unsigned int i=0;ipack_start( * mk_label( " " ), Gtk::PACK_SHRINK ); - else - hbox_legend ->pack_start( * mk_label( " " ), Gtk::PACK_SHRINK ); - - hbox_legend ->pack_start( * mk_label( "██ ", false, false, false, Get_Color( partitions[i] .filesystem ) ), Gtk::PACK_SHRINK ); - hbox_legend ->pack_start( * mk_label( partitions[i] .filesystem + " " ), Gtk::PACK_SHRINK ); - - //make sure this color isn't added to the legend again. - legende .push_back( partitions[i] .filesystem ); - } + + if ( t ) + hbox_legend ->pack_start( * mk_label( " " ), Gtk::PACK_SHRINK ); + else + hbox_legend ->pack_start( * mk_label( " " ), Gtk::PACK_SHRINK ); + hbox_legend ->pack_start( * mk_label( "██ ", false, false, false, Get_Color( legend[ t ] ) ), Gtk::PACK_SHRINK ); + hbox_legend ->pack_start( * mk_label( legend[ t ] + " " ), Gtk::PACK_SHRINK ); } //if there are any partitions add used/unused if ( ! hide_used_unused ) { - frame_disk_legend = manage( new Gtk::Frame() ) ; - hbox_legend_main.pack_start( *frame_disk_legend, Gtk::PACK_EXPAND_PADDING ); + frame_disk_legend = manage( new Gtk::Frame( ) ) ; + hbox_legend_main .pack_start( *frame_disk_legend, Gtk::PACK_EXPAND_PADDING ); - hbox_legend = manage( new Gtk::HBox() ); + hbox_legend = manage( new Gtk::HBox( ) ); frame_disk_legend ->add( *hbox_legend ); hbox_legend ->pack_start( * mk_label( " ██ ", false, false, false, "#F8F8BA" ), Gtk::PACK_SHRINK ); diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc index b712dea3..a4d166ad 100644 --- a/src/Win_GParted.cc +++ b/src/Win_GParted.cc @@ -509,7 +509,7 @@ void Win_GParted::Refresh_Visual( ) for ( unsigned int t = 0 ; t < operations .size( ); t++ ) { if ( operations[ t ] .device ->Get_Path( ) == devices[ current_device ] ->Get_Path( ) ) - partitions = operations[ t ] .Apply_Operation_To_Visual( partitions ) ; + operations[ t ] .Apply_Operation_To_Visual( partitions ) ; treerow = *(liststore_operations ->append( )); treerow[ treeview_operations_columns .operation_number ] = t +1; @@ -883,7 +883,7 @@ void Win_GParted::activate_resize() if ( operations.size() ) for (unsigned int t=0;tGet_Path( ) == devices[ current_device ] ->Get_Path( ) ) - partitions = operations[t].Apply_Operation_To_Visual( partitions ) ; + operations[ t ] .Apply_Operation_To_Visual( partitions ) ; Dialog_Partition_Resize_Move dialog;