From 4e57356c34ceb22f8b90cb0c80ec384c07b6939e Mon Sep 17 00:00:00 2001 From: Bart Hakvoort Date: Sat, 18 Mar 2006 21:38:19 +0000 Subject: [PATCH] another change to highlighting of selected partition. deal properly with * include/DrawingAreaVisualDisk.h, src/DrawingAreaVisualDisk.cc: another change to highlighting of selected partition. * include/Partition.h, src/Win_GParted.cc: deal properly with just formatted partitions * src/Operation.cc: added FIXME --- ChangeLog | 9 +++ include/DrawingAreaVisualDisk.h | 1 - include/Partition.h | 7 +- src/DrawingAreaVisualDisk.cc | 121 +++++++------------------------- src/Operation.cc | 7 ++ src/Win_GParted.cc | 3 +- 6 files changed, 48 insertions(+), 100 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3640f738..f348a515 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-03-18 Bart Hakvoort + + * include/DrawingAreaVisualDisk.h, + src/DrawingAreaVisualDisk.cc: another change to highlighting of + selected partition. + * include/Partition.h, + src/Win_GParted.cc: deal properly with just formatted partitions + * src/Operation.cc: added FIXME + 2006-03-17 Bart Hakvoort * src/GParted_Core.cc: moved comment to correct position diff --git a/include/DrawingAreaVisualDisk.h b/include/DrawingAreaVisualDisk.h index a7cf78e4..60d13d72 100644 --- a/include/DrawingAreaVisualDisk.h +++ b/include/DrawingAreaVisualDisk.h @@ -55,7 +55,6 @@ private: void calc_text( std::vector & visual_partitions ) ; void draw_partition( const visual_partition & vp ) ; - void draw_selection_effects( const visual_partition & vp ) ; void draw_partitions( const std::vector & visual_partitions ) ; bool set_selected( std::vector & visual_partitions, int x, int y ) ; diff --git a/include/Partition.h b/include/Partition.h index 5fa10449..0d2d9487 100644 --- a/include/Partition.h +++ b/include/Partition.h @@ -37,9 +37,10 @@ enum PartitionType { }; enum PartitionStatus { - STAT_REAL = 1, - STAT_NEW = 2, - STAT_COPY = 3 + STAT_REAL = 0, + STAT_NEW = 1, + STAT_COPY = 2, + STAT_FORMATTED = 3 }; diff --git a/src/DrawingAreaVisualDisk.cc b/src/DrawingAreaVisualDisk.cc index 743e340d..7472bda8 100644 --- a/src/DrawingAreaVisualDisk.cc +++ b/src/DrawingAreaVisualDisk.cc @@ -18,10 +18,9 @@ #include "../include/DrawingAreaVisualDisk.h" #define MAIN_BORDER 5 -#define BORDER 6 +#define BORDER 4 #define SEP 5 #define HEIGHT 70 + 2 * MAIN_BORDER -#define SHADOW 4 namespace GParted { @@ -30,13 +29,13 @@ DrawingAreaVisualDisk::DrawingAreaVisualDisk() { //set and allocated some standard colors color_used .set( Utils::Get_Color( GParted::FS_USED ) ); - this ->get_colormap() ->alloc_color( color_used ) ; + get_colormap() ->alloc_color( color_used ) ; color_unused .set( Utils::Get_Color( GParted::FS_UNUSED ) ); - this ->get_colormap() ->alloc_color( color_unused ) ; + get_colormap() ->alloc_color( color_unused ) ; color_text .set( "black" ); - this ->get_colormap() ->alloc_color( color_text ) ; + get_colormap() ->alloc_color( color_text ) ; set_events( Gdk::BUTTON_PRESS_MASK ); @@ -96,12 +95,12 @@ void DrawingAreaVisualDisk::set_static_data( const std::vector & part partitions[ t ] .sectors_used / static_cast( partitions[ t ] .get_length() ) ; visual_partitions .back() .color = partitions[ t ] .color; - this ->get_colormap() ->alloc_color( visual_partitions .back() .color ); + get_colormap() ->alloc_color( visual_partitions .back() .color ); if ( partitions[ t ] .type == GParted::TYPE_EXTENDED ) set_static_data( partitions[ t ] .logicals, visual_partitions .back() .logicals, - partitions[ t ] .sector_end - partitions[ t ] .sector_start ) ; + partitions[ t ] .get_length() ) ; else visual_partitions .back() .pango_layout = create_pango_layout( partitions[ t ] .get_path() + "\n" + Utils::format_size( partitions[ t ] .get_length() ) ) ; @@ -248,100 +247,28 @@ void DrawingAreaVisualDisk::draw_partition( const visual_partition & vp ) vp .y_text, vp .pango_layout ) ; } -} - -void DrawingAreaVisualDisk::draw_selection_effects( const visual_partition & vp ) -{ - gc ->set_foreground( color_text ); - - //bottom shadow - get_window() ->draw_rectangle( gc, - true, - vp .x_start + SHADOW, - vp .y_start + vp .height, - vp .length, - SHADOW ) ; - - //righthand shadow - get_window() ->draw_rectangle( gc, - true, - vp .x_start + vp .length, - vp .y_start + SHADOW, - SHADOW, - vp .height ) ; - - - //if selected contains logicals we need to add more shadows and color - if ( vp .logicals .size() > 0 ) + + //selection + if ( vp .selected ) { - //inner shadows - for ( unsigned int t = 0 ; t < vp .logicals .size() ; t++ ) - { - //top shadows - get_window() ->draw_rectangle( gc, - true, - vp .logicals[ t ] .x_start - SHADOW, - vp .logicals[ t ] .y_start - SHADOW, - vp .logicals[ t ] .length, - SHADOW ) ; - - //lefthand shadows - get_window() ->draw_rectangle( gc, - true, - vp .logicals[ t ] .x_start - SHADOW, - vp .logicals[ t ] .y_start, - SHADOW, - vp .logicals[ t ] .height - SHADOW ) ; - } - - //create extra 'extended' to create the illusion of floating above the logicals - gc ->set_foreground( vp .color ); - - //bottomline.. + gc ->set_foreground( color_used ) ; get_window() ->draw_rectangle( gc, - true, - vp .x_start + BORDER + SHADOW, - vp .y_start + vp .height - BORDER, - vp .length - BORDER * 2, - SHADOW ) ; - - //small rectangles on the righthandside of each logical.. - for ( unsigned int t = 0 ; t < vp .logicals .size() ; t++ ) - get_window() ->draw_rectangle( gc, - true, - vp .logicals[ t ] .x_start + vp .logicals[ t ] .length - SHADOW, - vp .logicals[ t ] .y_start, - SHADOW, - vp .logicals[ t ] .height - SHADOW ) ; + false, + vp .x_start + BORDER/2 , + vp .y_start + BORDER/2 , + vp .length - BORDER, + vp .height - BORDER ) ; } } void DrawingAreaVisualDisk::draw_partitions( const std::vector & visual_partitions ) { - visual_partition vp ; for ( unsigned int t = 0 ; t < visual_partitions .size() ; t++ ) { - vp = visual_partitions[ t ] ; + draw_partition( visual_partitions[ t ] ) ; - if ( vp .selected ) - { - vp .x_start -= SHADOW ; - vp .y_start -= SHADOW ; - vp .x_used_start -= SHADOW ; - vp .x_unused_start -= SHADOW ; - vp .y_used_unused_start -= SHADOW ; - - vp .x_text -= SHADOW ; - vp .y_text -= SHADOW ; - } - - draw_partition( vp ) ; - - if ( vp .logicals .size() > 0 ) - draw_partitions( vp .logicals ) ; - - if ( vp .selected ) - draw_selection_effects( vp ) ; + if ( visual_partitions[ t ] .logicals .size() > 0 ) + draw_partitions( visual_partitions[ t ] .logicals ) ; } } @@ -392,6 +319,10 @@ void DrawingAreaVisualDisk::on_realize() Gtk::DrawingArea::on_realize() ; gc = Gdk::GC::create( get_window() ); + gc ->set_line_attributes( 2, + Gdk::LINE_ON_OFF_DASH, + Gdk::CAP_BUTT, + Gdk::JOIN_MITER ) ; } bool DrawingAreaVisualDisk::on_expose_event( GdkEventExpose * event ) @@ -487,7 +418,7 @@ void DrawingAreaVisualDisk::free_colors( std::vector & visual_ { for ( unsigned int t = 0 ; t < visual_partitions .size() ; t++ ) { - this ->get_colormap() ->free_colors( visual_partitions[ t ] .color, 1 ) ; + get_colormap() ->free_colors( visual_partitions[ t ] .color, 1 ) ; if ( visual_partitions[ t ] .logicals .size() > 0 ) free_colors( visual_partitions[ t ] .logicals ) ; @@ -499,9 +430,9 @@ DrawingAreaVisualDisk::~DrawingAreaVisualDisk() clear() ; //free the allocated colors - this ->get_colormap() ->free_colors( color_used, 1 ) ; - this ->get_colormap() ->free_colors( color_unused, 1 ) ; - this ->get_colormap() ->free_colors( color_text, 1 ) ; + get_colormap() ->free_colors( color_used, 1 ) ; + get_colormap() ->free_colors( color_unused, 1 ) ; + get_colormap() ->free_colors( color_text, 1 ) ; } } //GParted diff --git a/src/Operation.cc b/src/Operation.cc index f57768ad..b8c3be17 100644 --- a/src/Operation.cc +++ b/src/Operation.cc @@ -258,6 +258,13 @@ void Operation::Apply_Delete_To_Visual( std::vector & partitions ) void Operation::Apply_Create_To_Visual( std::vector & partitions ) { + //FIXME (segfault): gdb bt suggest this function. steps to reproduce on 'voyager': + //-shrink /dev/hda5 + //-create a small partition in the middle of the new unallocated space + //-grow /dev/hda5 again + //-grow the new partition + //perform steps in sequence without applying + if ( ! partition_original .inside_extended ) { partitions[ Get_Index_Original( partitions ) ] = partition_new ; diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc index 3baa93b2..bbbf798f 100644 --- a/src/Win_GParted.cc +++ b/src/Win_GParted.cc @@ -1355,7 +1355,8 @@ void Win_GParted::activate_format( GParted::FILESYSTEM new_fs ) selected_partition .sector_end, selected_partition .inside_extended, false ) ; - + + part_temp .status = GParted::STAT_FORMATTED ; //if selected_partition is NEW we simply remove the NEW operation from the list and //add it again with the new filesystem