overloaded operator == rewrote the graphical partitiondisplay. It now
* include/Partition.h, src/Partition.cc: overloaded operator == * include/VBox_VisualDisk.h, src/VBox_VisualDisk.cc: rewrote the graphical partitiondisplay. It now supports resizing and the extended partition is also selectable. see also #312656 * include/Win_GParted.h, src/Win_GParted.cc: use the new graphical partitiondisplay. * src/TreeView_Detail.cc: minor cleanups
This commit is contained in:
parent
afb93e5449
commit
adc76a7686
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2005-12-22 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* include/Partition.h,
|
||||
src/Partition.cc: overloaded operator ==
|
||||
* include/VBox_VisualDisk.h,
|
||||
src/VBox_VisualDisk.cc: rewrote the graphical partitiondisplay. It
|
||||
now supports resizing and the extended partition is also selectable.
|
||||
see also #312656
|
||||
* include/Win_GParted.h,
|
||||
src/Win_GParted.cc: use the new graphical partitiondisplay.
|
||||
* src/TreeView_Detail.cc: minor cleanups
|
||||
|
||||
2005-12-15 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* include/Dialog_Disklabel.h,
|
||||
|
|
|
@ -78,6 +78,8 @@ public:
|
|||
const long Get_Used_MB( ) const ;
|
||||
const long Get_Unused_MB( ) const ;
|
||||
|
||||
bool operator==( const Partition & partition ) ;
|
||||
|
||||
//some public members
|
||||
Glib::ustring partition;//the symbolic path (e.g. /dev/hda1 )
|
||||
Glib::ustring device_path ;
|
||||
|
|
|
@ -19,78 +19,111 @@
|
|||
#define VBOX_VISUALDISK
|
||||
|
||||
#include "../include/Partition.h"
|
||||
#include "../include/Device.h"
|
||||
|
||||
#include <gtkmm/box.h>
|
||||
#include <gtkmm/frame.h>
|
||||
#include <gtkmm/eventbox.h>
|
||||
#include <gtkmm/tooltips.h>
|
||||
#include <gtkmm/checkbutton.h>
|
||||
#include <gtkmm/drawingarea.h>
|
||||
#include <gtkmm/image.h>
|
||||
|
||||
#define BORDER 8
|
||||
|
||||
namespace GParted
|
||||
{
|
||||
|
||||
class VBox_VisualDisk : public Gtk::VBox
|
||||
{
|
||||
//struct which contains visual information about the partitions. This prevents recalculation of everything after an expose en therefore saves performance..
|
||||
struct Visual_Partition
|
||||
{
|
||||
//2 attributes used for selection ( see Set_Selected() an drawingarea_on_expose() for more info )
|
||||
Sector sector_start;
|
||||
int index;
|
||||
|
||||
int length; //pixels
|
||||
int used; //pixels
|
||||
int height; //pixels
|
||||
int text_y; //pixels
|
||||
Gdk::Color color_fs;
|
||||
Gtk::DrawingArea *drawingarea;
|
||||
Glib::RefPtr<Gdk::GC> gc;
|
||||
Glib::RefPtr<Pango::Layout> pango_layout;
|
||||
};
|
||||
|
||||
public:
|
||||
VBox_VisualDisk( const std::vector<Partition> & partitions, const Sector device_length );
|
||||
VBox_VisualDisk();
|
||||
~VBox_VisualDisk();
|
||||
void Set_Selected( const Partition & );
|
||||
|
||||
void load_partitions( const std::vector<Partition> & partitions, const Sector device_length );
|
||||
void set_selected( const Partition & partition ) ;
|
||||
void clear() ;
|
||||
|
||||
//public signal for interclass communication
|
||||
sigc::signal<void, GdkEventButton *, const Partition &> signal_mouse_click;
|
||||
|
||||
|
||||
private:
|
||||
void Build_Visual_Disk( ) ; //i still dream of some fully resizeable visualdisk....
|
||||
void Create_Visual_Partition( const Partition & partition ) ;
|
||||
void Prepare_Legend( std::vector<GParted::FILESYSTEM> & legend, const std::vector<Partition> & partitions ) ;
|
||||
void Build_Legend( ) ;
|
||||
struct visual_partition ;
|
||||
|
||||
//private functions
|
||||
int get_total_separator_px( const std::vector<Partition> & partitions ) ;
|
||||
|
||||
void set_static_data( const std::vector<Partition> & partitions, std::vector<visual_partition> & visual_partitions, Sector length ) ;
|
||||
int calc_length( std::vector<visual_partition> & visual_partitions, int length_px ) ;
|
||||
void calc_position_and_height( std::vector<visual_partition> & visual_partitions, int start, int border ) ;
|
||||
void calc_used_unused( std::vector<visual_partition> & visual_partitions ) ;
|
||||
void calc_text( std::vector<visual_partition> & visual_partitions ) ;
|
||||
|
||||
void build_legend( const std::vector<Partition> & partitions ) ;
|
||||
void prepare_legend( const std::vector<Partition> & partitions, std::vector<GParted::FILESYSTEM> & legend) ;
|
||||
Gtk::HBox * create_legend_item( GParted::FILESYSTEM fs ) ;
|
||||
|
||||
void draw_partitions( const std::vector<visual_partition> & visual_partitions ) ;
|
||||
|
||||
bool set_selected( std::vector<visual_partition> & visual_partitions, int x, int y ) ;
|
||||
void set_selected( std::vector<visual_partition> & visual_partitions, const Partition & partition ) ;
|
||||
|
||||
void free_colors( std::vector<visual_partition> & visual_partitions ) ;
|
||||
|
||||
//signalhandlers
|
||||
void drawingarea_on_realize( Visual_Partition * );
|
||||
bool drawingarea_on_expose( GdkEventExpose *, Visual_Partition* );
|
||||
bool on_drawingarea_button_press( GdkEventButton *, const Partition & );
|
||||
void drawingarea_on_realize();
|
||||
bool drawingarea_on_expose( GdkEventExpose * event );
|
||||
bool on_drawingarea_button_press( GdkEventButton * event );
|
||||
void on_resize( Gtk::Allocation & allocation ) ;
|
||||
|
||||
std::vector<Partition> partitions;
|
||||
Sector device_length;
|
||||
//variables
|
||||
struct visual_partition
|
||||
{
|
||||
double fraction ;
|
||||
double fraction_used ;
|
||||
|
||||
Gtk::Frame *frame_disk_legend ;
|
||||
Gtk::HBox hbox_disk_main, *hbox_disk, *hbox_extended, hbox_legend_main, *hbox_legend;
|
||||
Gtk::CheckButton checkbutton_filesystem;
|
||||
Gtk::Tooltips tooltips;
|
||||
Gtk::Image *image ;
|
||||
int x_start, length ;
|
||||
int y_start, height ;
|
||||
int x_used_start, used_length ;
|
||||
int x_unused_start, unused_length ;
|
||||
int y_used_unused_start, used_unused_height ;
|
||||
int x_text, y_text ;
|
||||
|
||||
Visual_Partition *visual_partition;
|
||||
std::vector <Visual_Partition *> visual_partitions;
|
||||
Gtk::EventBox * eventbox_extended;
|
||||
bool selected ;
|
||||
|
||||
Gdk::Color color ;
|
||||
Glib::RefPtr<Pango::Layout> pango_layout;
|
||||
|
||||
//real partition
|
||||
Partition partition ;
|
||||
|
||||
std::vector<visual_partition> logicals ;
|
||||
|
||||
visual_partition()
|
||||
{
|
||||
fraction = fraction_used =
|
||||
x_start = length =
|
||||
y_start = height =
|
||||
x_used_start = used_length =
|
||||
x_unused_start = unused_length =
|
||||
y_used_unused_start = used_unused_height =
|
||||
x_text = y_text = 0 ;
|
||||
|
||||
selected = false ;
|
||||
|
||||
pango_layout .clear() ;
|
||||
}
|
||||
|
||||
~visual_partition()
|
||||
{
|
||||
pango_layout .clear() ;
|
||||
logicals .clear() ;
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<visual_partition> visual_partitions ;
|
||||
visual_partition selected_vp ;
|
||||
int TOT_SEP, MIN_SIZE ;
|
||||
|
||||
Gtk::Frame *frame ;
|
||||
Gtk::DrawingArea drawingarea;
|
||||
Gtk::HBox hbox_legend ;
|
||||
Glib::RefPtr<Gdk::GC> gc;
|
||||
Gdk::Color color_used, color_unused, color_text;
|
||||
|
||||
|
||||
Glib::ustring str_temp ;
|
||||
int temp, selected_partition, SCREEN_WIDTH;
|
||||
};
|
||||
|
||||
} //GParted
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include <gtkmm/separatortoolitem.h>
|
||||
#include <gtkmm/menubar.h>
|
||||
#include <gtkmm/statusbar.h>
|
||||
#include <gtkmm/radiobutton.h>
|
||||
#include <gtkmm/liststore.h>
|
||||
|
||||
#include <unistd.h> //should be included by gtkmm headers. but decided to include it anyway after getting some bugreports..
|
||||
|
@ -159,7 +158,7 @@ private:
|
|||
Gtk::HPaned hpaned_main;
|
||||
Gtk::VPaned vpaned_main;
|
||||
Gtk::VBox vbox_main,vbox_info, *vbox;
|
||||
Gtk::HBox hbox_toolbar,hbox_visual, hbox_operations, *hbox;
|
||||
Gtk::HBox hbox_toolbar, hbox_operations, *hbox;
|
||||
Gtk::Toolbar toolbar_main;
|
||||
Gtk::MenuBar menubar_main;
|
||||
Gtk::OptionMenu optionmenu_devices;
|
||||
|
@ -175,7 +174,7 @@ private:
|
|||
Gtk::MenuItem *menu_item;
|
||||
Gtk::ProgressBar *pulsebar ;
|
||||
|
||||
VBox_VisualDisk *vbox_visual_disk;
|
||||
VBox_VisualDisk vbox_visual_disk;
|
||||
TreeView_Detail treeview_detail;
|
||||
|
||||
//operations list
|
||||
|
@ -189,7 +188,12 @@ private:
|
|||
Gtk::TreeModelColumn<Glib::ustring> operation_description;
|
||||
Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > operation_icon;
|
||||
|
||||
treeview_operations_Columns( ) { add( operation_number ); add( operation_description ); add( operation_icon ); }
|
||||
treeview_operations_Columns()
|
||||
{
|
||||
add( operation_number );
|
||||
add( operation_description );
|
||||
add( operation_icon );
|
||||
}
|
||||
};
|
||||
treeview_operations_Columns treeview_operations_columns;
|
||||
|
||||
|
|
|
@ -105,6 +105,13 @@ const long Partition::Get_Unused_MB( ) const
|
|||
return Get_Length_MB( ) - Get_Used_MB( ) ;
|
||||
}
|
||||
|
||||
bool Partition::operator==( const Partition & partition )
|
||||
{
|
||||
return this ->partition_number == partition .partition_number &&
|
||||
this ->sector_start == partition .sector_start &&
|
||||
this ->type == partition .type ;
|
||||
}
|
||||
|
||||
Partition::~Partition( )
|
||||
{
|
||||
}
|
||||
|
|
|
@ -17,163 +17,251 @@
|
|||
|
||||
#include "../include/VBox_VisualDisk.h"
|
||||
|
||||
#include <gtkmm/image.h>
|
||||
|
||||
#define BORDER 8
|
||||
#define SEP 5
|
||||
#define HEIGHT 70
|
||||
|
||||
namespace GParted
|
||||
{
|
||||
|
||||
VBox_VisualDisk::VBox_VisualDisk( const std::vector<Partition> & partitions, const Sector device_length )
|
||||
VBox_VisualDisk::VBox_VisualDisk()
|
||||
{
|
||||
this ->partitions = partitions ;
|
||||
this ->device_length = device_length ;
|
||||
|
||||
selected_partition = -1;
|
||||
|
||||
//create frame which contains the visual disk
|
||||
frame_disk_legend = manage( new Gtk::Frame( ) ) ;
|
||||
frame_disk_legend ->set_shadow_type( Gtk::SHADOW_ETCHED_OUT );
|
||||
hbox_disk_main .pack_start( *frame_disk_legend, Gtk::PACK_EXPAND_PADDING );
|
||||
|
||||
hbox_disk = NULL ;
|
||||
hbox_extended = NULL ;
|
||||
|
||||
this ->set_border_width( 10 );
|
||||
this ->set_spacing( 12 );
|
||||
this ->pack_start( hbox_disk_main, Gtk::PACK_SHRINK );
|
||||
this ->set_spacing( 5 );
|
||||
|
||||
//set and allocated some standard colors
|
||||
color_used .set( "#F8F8BA" ); this ->get_colormap( ) ->alloc_color( color_used ) ;//bleach yellow ;)
|
||||
color_unused .set( "white" ); this ->get_colormap( ) ->alloc_color( color_unused ) ;
|
||||
color_text .set( "black" ); this ->get_colormap( ) ->alloc_color( color_text ) ;
|
||||
color_used .set( Utils::Get_Color( GParted::FS_USED ) );
|
||||
this ->get_colormap() ->alloc_color( color_used ) ;
|
||||
|
||||
color_unused .set( Utils::Get_Color( GParted::FS_UNUSED ) );
|
||||
this ->get_colormap() ->alloc_color( color_unused ) ;
|
||||
|
||||
color_text .set( "black" );
|
||||
this ->get_colormap() ->alloc_color( color_text ) ;
|
||||
|
||||
//prepare drawingarea and frame and pack them
|
||||
drawingarea .set_events( Gdk::BUTTON_PRESS_MASK );
|
||||
|
||||
drawingarea .signal_realize() .connect( sigc::mem_fun(*this, &VBox_VisualDisk::drawingarea_on_realize) ) ;
|
||||
drawingarea .signal_expose_event() .connect( sigc::mem_fun(*this, &VBox_VisualDisk::drawingarea_on_expose) ) ;
|
||||
drawingarea .signal_button_press_event() .connect( sigc::mem_fun( *this, &VBox_VisualDisk::on_drawingarea_button_press) ) ;
|
||||
|
||||
drawingarea .set_size_request( -1, HEIGHT ) ;
|
||||
|
||||
frame = manage( new Gtk::Frame() ) ;
|
||||
frame ->add( drawingarea );
|
||||
frame ->set_shadow_type( Gtk::SHADOW_ETCHED_OUT ) ;
|
||||
this ->pack_start( *frame, Gtk::PACK_EXPAND_WIDGET ) ;
|
||||
|
||||
//pack hbox which holds the legend
|
||||
this ->pack_start( hbox_legend );
|
||||
}
|
||||
|
||||
void VBox_VisualDisk::load_partitions( const std::vector<Partition> & partitions, const Sector device_length )
|
||||
{
|
||||
clear() ;
|
||||
|
||||
TOT_SEP = get_total_separator_px( partitions ) ;
|
||||
set_static_data( partitions, visual_partitions, device_length ) ;
|
||||
|
||||
drawingarea .queue_resize() ;
|
||||
|
||||
build_legend( partitions ) ;
|
||||
}
|
||||
|
||||
void VBox_VisualDisk::set_selected( const Partition & partition )
|
||||
{
|
||||
set_selected( visual_partitions, partition ) ;
|
||||
|
||||
draw_partitions( visual_partitions ) ;
|
||||
}
|
||||
|
||||
void VBox_VisualDisk::clear()
|
||||
{
|
||||
free_colors( visual_partitions ) ;
|
||||
visual_partitions .clear() ;
|
||||
hbox_legend .children() .clear() ;
|
||||
|
||||
drawingarea .queue_resize() ;
|
||||
}
|
||||
|
||||
int VBox_VisualDisk::get_total_separator_px( const std::vector<Partition> & partitions )
|
||||
{
|
||||
for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
|
||||
if ( partitions[ t ] .type == GParted::TYPE_EXTENDED )
|
||||
return ( partitions[ t ] .logicals .size() -1 + partitions .size() -1 ) * SEP ;
|
||||
|
||||
|
||||
//since disksegments have minimal sizes ( unallocated 15 and partitions 20 pixels ) i do some checking to prevent the visual disk from growing to much
|
||||
Sector sectors_per_pixel = Utils::Round( device_length / 750.00 ) ;
|
||||
return ( partitions .size() -1 ) * SEP ;
|
||||
}
|
||||
|
||||
double extra_pixels = 0 ;
|
||||
void VBox_VisualDisk::set_static_data( const std::vector<Partition> & partitions, std::vector<visual_partition> & visual_partitions, Sector length )
|
||||
{
|
||||
Sector p_length ;
|
||||
visual_partition vp ;
|
||||
|
||||
for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
|
||||
{
|
||||
double width = static_cast<double> (partitions[ t ] .sector_end - partitions[ t ] .sector_start) / sectors_per_pixel ;
|
||||
visual_partitions .push_back( vp ) ;
|
||||
|
||||
if ( (partitions[ t ] .type == GParted::TYPE_PRIMARY || partitions[ t ] .type == GParted::TYPE_LOGICAL) && width < 20 )
|
||||
extra_pixels += (20 - width) ;
|
||||
else if ( partitions[ t ] .type == GParted::TYPE_UNALLOCATED && width < 15 )
|
||||
extra_pixels += (15 - width) ;
|
||||
visual_partitions .back() .partition = partitions[ t ] ;
|
||||
|
||||
p_length = partitions[ t ] .sector_end - partitions[ t ] .sector_start ;
|
||||
visual_partitions .back() .fraction = p_length / static_cast<double>( length ) ;
|
||||
|
||||
if ( partitions[ t ] .type == GParted::TYPE_UNALLOCATED || partitions[ t ] .type == GParted::TYPE_EXTENDED )
|
||||
visual_partitions .back() .fraction_used = -1 ;
|
||||
else if ( partitions[ t ] .sectors_used > 0 )
|
||||
visual_partitions .back() .fraction_used = partitions[ t ] .sectors_used / static_cast<double>( p_length ) ;
|
||||
|
||||
visual_partitions .back() .color = partitions[ t ] .color;
|
||||
this ->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 ) ;
|
||||
else
|
||||
visual_partitions .back() .pango_layout = drawingarea .create_pango_layout(
|
||||
partitions[ t ] .partition + "\n" + String::ucompose( _("%1 MB"), partitions[ t ] .Get_Length_MB() ) ) ;
|
||||
}
|
||||
}
|
||||
|
||||
//draw visual disk and its legend
|
||||
this ->SCREEN_WIDTH = 750 - Utils::Round( extra_pixels ) ;
|
||||
int VBox_VisualDisk::calc_length( std::vector<visual_partition> & visual_partitions, int length_px )
|
||||
{
|
||||
int calced_length = 0 ;
|
||||
|
||||
Build_Visual_Disk( ) ;
|
||||
Build_Legend( ) ;
|
||||
for ( int t = 0 ; t < static_cast<int>( visual_partitions .size() ) ; t++ )
|
||||
{
|
||||
visual_partitions[ t ] .length = Utils::Round( length_px * visual_partitions[ t ] .fraction ) ;
|
||||
|
||||
if ( visual_partitions[ t ] .logicals .size() > 0 )
|
||||
{
|
||||
int ext_length = calc_length( visual_partitions[ t ] .logicals, visual_partitions[ t ] .length - (2 * BORDER) ) ;
|
||||
|
||||
visual_partitions[ t ] .length = ext_length + (2 * BORDER) ;
|
||||
}
|
||||
else if ( visual_partitions[ t ] .length < MIN_SIZE )
|
||||
visual_partitions[ t ] .length = MIN_SIZE ;
|
||||
|
||||
calced_length += visual_partitions[ t ] .length ;
|
||||
}
|
||||
|
||||
void VBox_VisualDisk::Build_Visual_Disk( )
|
||||
{
|
||||
//since there is a 5 pixel space between every partition.... ( extended adds 2 *5 more, but that doesn't matter that much.
|
||||
//NOTE that a part < 20 will also grow to 20, so length in pixels may vary across different devices..
|
||||
this ->SCREEN_WIDTH -= ( (partitions .size( ) -1) *5 ) ;
|
||||
|
||||
//create hbox_disk and add to frame
|
||||
hbox_disk = manage( new Gtk::HBox( ) ) ;
|
||||
hbox_disk ->set_spacing( 5 );
|
||||
frame_disk_legend ->add( *hbox_disk );
|
||||
|
||||
|
||||
//walk through all partitions....
|
||||
for ( unsigned int i = 0 ; i < partitions .size( ) ; i++ )
|
||||
{
|
||||
Create_Visual_Partition( partitions[ i ] ) ;
|
||||
|
||||
if ( partitions[ i ].type != GParted::TYPE_EXTENDED )
|
||||
hbox_disk ->pack_start( *( visual_partitions .back( ) ->drawingarea ), Gtk::PACK_SHRINK ) ;
|
||||
return calced_length + (visual_partitions .size() - 1) * SEP ;
|
||||
}
|
||||
|
||||
this ->show_all_children( ) ;
|
||||
void VBox_VisualDisk::calc_position_and_height( std::vector<visual_partition> & visual_partitions, int start, int border )
|
||||
{
|
||||
for ( unsigned int t = 0 ; t < visual_partitions .size() ; t++ )
|
||||
{
|
||||
visual_partitions[ t ] .x_start = start ;
|
||||
visual_partitions[ t ] .y_start = border ;
|
||||
visual_partitions[ t ] .height = HEIGHT - ( border * 2 ) ;
|
||||
|
||||
if ( visual_partitions[ t ] .logicals .size() > 0 )
|
||||
calc_position_and_height( visual_partitions[ t ] .logicals,
|
||||
visual_partitions[ t ] .x_start + BORDER,
|
||||
BORDER ) ;
|
||||
|
||||
start += visual_partitions[ t ] .length + SEP ;
|
||||
}
|
||||
}
|
||||
|
||||
void VBox_VisualDisk::Create_Visual_Partition( const Partition & partition )
|
||||
void VBox_VisualDisk::calc_used_unused( std::vector<visual_partition> & visual_partitions )
|
||||
{
|
||||
int x,y;//for pango_layout check
|
||||
|
||||
visual_partition = new Visual_Partition( ) ;
|
||||
visual_partitions .push_back( visual_partition ) ;
|
||||
visual_partitions .back( ) ->index = visual_partitions .size( ) -1 ; // <---- BELACHELIJK!! DOE DAAR IETS AAN!!!
|
||||
visual_partitions .back( ) ->sector_start = partition .sector_start ;
|
||||
|
||||
if ( partition .type == GParted::TYPE_EXTENDED )
|
||||
for ( unsigned int t = 0 ; t < visual_partitions .size() ; t++ )
|
||||
{
|
||||
visual_partitions.back( ) ->drawingarea = NULL ;//it's just a dummy ;-) ( see Set_Selected() )
|
||||
visual_partitions.back( ) ->length = 0 ; //keeps total_length clean
|
||||
|
||||
eventbox_extended = manage( new Gtk::EventBox( ) ) ;
|
||||
eventbox_extended ->set_size_request( -1, 60 );
|
||||
eventbox_extended ->modify_bg( eventbox_extended ->get_state( ), partition .color );
|
||||
hbox_disk ->pack_start( *eventbox_extended, Gtk::PACK_SHRINK ) ;
|
||||
|
||||
hbox_extended = manage( new Gtk::HBox( ) ) ;
|
||||
hbox_extended ->set_border_width( 5 );
|
||||
hbox_extended ->set_spacing( 5 );
|
||||
eventbox_extended ->add( *hbox_extended ) ;
|
||||
|
||||
for ( unsigned int t = 0 ; t < partition .logicals .size( ) ; t++ )
|
||||
if ( visual_partitions[ t ] .fraction_used > -1 )
|
||||
{
|
||||
Create_Visual_Partition( partition .logicals[ t ] ) ;
|
||||
hbox_extended ->pack_start( *( visual_partitions .back( ) ->drawingarea ), Gtk::PACK_SHRINK ) ;
|
||||
//used
|
||||
visual_partitions[ t ] .x_used_start = visual_partitions[ t ] .x_start + BORDER ;
|
||||
|
||||
if ( visual_partitions[ t ] .fraction_used )
|
||||
visual_partitions[ t ] .used_length =
|
||||
Utils::Round( ( visual_partitions[ t ] .length - (2*BORDER) ) * visual_partitions[ t ] .fraction_used ) ;
|
||||
|
||||
//unused
|
||||
visual_partitions[ t ] .x_unused_start = visual_partitions[ t ] .x_used_start + visual_partitions[ t ] .used_length ;
|
||||
visual_partitions[ t ] .unused_length
|
||||
= visual_partitions[ t ] .length - (2 * BORDER) - visual_partitions[ t ] .used_length ;
|
||||
|
||||
//y position and height
|
||||
visual_partitions[ t ] .y_used_unused_start = visual_partitions[ t ] .y_start + BORDER ;
|
||||
visual_partitions[ t ] .used_unused_height = visual_partitions[ t ] .height - (2 * BORDER) ;
|
||||
}
|
||||
|
||||
return ;
|
||||
if ( visual_partitions[ t ] .logicals .size() > 0 )
|
||||
calc_used_unused( visual_partitions[ t ] .logicals ) ;
|
||||
}
|
||||
}
|
||||
|
||||
visual_partitions .back( ) ->length = static_cast<int> ( SCREEN_WIDTH / ( device_length / static_cast<double>(partition .sector_end - partition .sector_start) ) );
|
||||
if ( visual_partitions .back( ) ->length < 20 )//we need a min. size. Otherwise some small partitions wouldn't be visible
|
||||
visual_partitions .back( ) ->length = ( partition .type == GParted::TYPE_UNALLOCATED ) ? 15 : 20 ;
|
||||
|
||||
if ( partition .inside_extended )
|
||||
void VBox_VisualDisk::calc_text( std::vector<visual_partition> & visual_partitions )
|
||||
{
|
||||
visual_partitions .back( ) ->height = 34 ;
|
||||
visual_partitions .back( ) ->text_y = 9 ;
|
||||
int length, height ;
|
||||
|
||||
for ( unsigned int t = 0 ; t < visual_partitions .size() ; t++ )
|
||||
{
|
||||
if ( visual_partitions[ t ] .pango_layout )
|
||||
{
|
||||
//see if the text fits in the partition... (and if so, center the text..)
|
||||
visual_partitions[ t ] .pango_layout ->get_pixel_size( length, height ) ;
|
||||
if ( length < visual_partitions[ t ] .length - (2 * BORDER) - 2 )
|
||||
{
|
||||
visual_partitions[ t ] .x_text = visual_partitions[ t ] .x_start +
|
||||
Utils::Round( (visual_partitions[ t ] .length / 2) - (length / 2) ) ;
|
||||
|
||||
visual_partitions[ t ] .y_text = visual_partitions[ t ] .y_start +
|
||||
Utils::Round( (visual_partitions[ t ] .height / 2) - (height / 2) ) ;
|
||||
}
|
||||
else
|
||||
visual_partitions[ t ] .x_text = visual_partitions[ t ] .y_text = 0 ;
|
||||
}
|
||||
|
||||
if ( visual_partitions[ t ] .logicals .size() > 0 )
|
||||
calc_text( visual_partitions[ t ] .logicals ) ;
|
||||
}
|
||||
}
|
||||
|
||||
void VBox_VisualDisk::build_legend( const std::vector<Partition> & partitions )
|
||||
{
|
||||
visual_partitions .back( ) ->height = 44 ;
|
||||
visual_partitions .back( ) ->text_y = 15 ;
|
||||
std::vector<GParted::FILESYSTEM> legend ;
|
||||
prepare_legend( partitions, legend ) ;
|
||||
|
||||
frame = manage( new Gtk::Frame() ) ;
|
||||
hbox_legend .pack_start( *frame, Gtk::PACK_EXPAND_PADDING );
|
||||
|
||||
Gtk::HBox * hbox = manage( new Gtk::HBox( false, 15 ) );
|
||||
hbox ->set_border_width( 3 ) ;
|
||||
frame ->add( *hbox ) ;
|
||||
|
||||
bool hide_used_unused = true;
|
||||
for ( unsigned int t = 0 ; t < legend .size() ; t++ )
|
||||
{
|
||||
hbox ->pack_start( * create_legend_item( legend[ t ] ), Gtk::PACK_SHRINK ) ;
|
||||
|
||||
if ( legend[ t ] != GParted::FS_UNALLOCATED && legend[ t ] != GParted::FS_EXTENDED && legend[ t ] != GParted::FS_LINUX_SWAP )
|
||||
hide_used_unused = false ;
|
||||
}
|
||||
|
||||
if ( partition .type == GParted::TYPE_UNALLOCATED )
|
||||
visual_partitions .back( ) ->used = -1;
|
||||
else
|
||||
visual_partitions .back( ) ->used = static_cast<int>( (visual_partitions .back( ) ->length - (BORDER *2)) / ( static_cast<double>(partition .sector_end - partition .sector_start) / partition .sectors_used ) );
|
||||
if ( ! hide_used_unused )
|
||||
{
|
||||
frame = manage( new Gtk::Frame() ) ;
|
||||
hbox_legend .pack_start( *frame, Gtk::PACK_EXPAND_PADDING );
|
||||
|
||||
visual_partitions.back( ) ->color_fs = partition .color;
|
||||
this ->get_colormap( ) ->alloc_color( visual_partitions .back( ) ->color_fs );
|
||||
hbox = manage( new Gtk::HBox( false, 15 ) );
|
||||
hbox ->set_border_width( 3 ) ;
|
||||
frame ->add( *hbox ) ;
|
||||
|
||||
visual_partitions .back( ) ->drawingarea = manage( new Gtk::DrawingArea( ) ) ;
|
||||
visual_partitions .back( ) ->drawingarea ->set_size_request( visual_partitions .back( ) ->length +1, 60 );
|
||||
visual_partitions .back( ) ->drawingarea ->set_events( Gdk::BUTTON_PRESS_MASK );
|
||||
|
||||
//connect signal handlers
|
||||
visual_partitions .back( ) ->drawingarea ->signal_button_press_event( ) .connect( sigc::bind<Partition>(sigc::mem_fun(*this, &VBox_VisualDisk::on_drawingarea_button_press), partition ) );
|
||||
visual_partitions .back( ) ->drawingarea ->signal_realize( ) .connect( sigc::bind<Visual_Partition *>(sigc::mem_fun(*this, &VBox_VisualDisk::drawingarea_on_realize), visual_partitions .back( ) ) );
|
||||
visual_partitions .back( ) ->drawingarea ->signal_expose_event( ) .connect( sigc::bind<Visual_Partition *>(sigc::mem_fun(*this, &VBox_VisualDisk::drawingarea_on_expose), visual_partitions .back( ) ));
|
||||
|
||||
//create pangolayout and see if it fits in the visual partition
|
||||
str_temp = partition .partition + "\n" + String::ucompose( _("%1 MB"), partition .Get_Length_MB( ) ) ;
|
||||
visual_partitions .back( ) ->pango_layout = visual_partitions .back( ) ->drawingarea ->create_pango_layout ( str_temp ) ;
|
||||
|
||||
visual_partitions .back( ) ->pango_layout ->get_pixel_size( x, y ) ;
|
||||
if ( visual_partitions .back( ) ->length - BORDER * 2 -2 < x )
|
||||
visual_partitions .back( ) ->pango_layout ->set_text( "" ) ;
|
||||
|
||||
//tooltip
|
||||
str_temp = "" ;
|
||||
if ( partition .type != GParted::TYPE_UNALLOCATED )
|
||||
str_temp = Utils::Get_Filesystem_String( partition .filesystem ) + "\n" ;
|
||||
|
||||
str_temp += partition .partition + "\n" + String::ucompose( _("%1 MB"), partition .Get_Length_MB( ) ) ;
|
||||
tooltips .set_tip( *( visual_partitions.back( ) ->drawingarea ), str_temp ) ;
|
||||
hbox ->pack_start( * create_legend_item( GParted::FS_USED ), Gtk::PACK_SHRINK ) ;
|
||||
hbox ->pack_start( * create_legend_item( GParted::FS_UNUSED ), Gtk::PACK_SHRINK ) ;
|
||||
}
|
||||
|
||||
void VBox_VisualDisk::Prepare_Legend( std::vector<GParted::FILESYSTEM> & legend, const std::vector<Partition> & partitions )
|
||||
hbox_legend .show_all_children() ;
|
||||
}
|
||||
|
||||
void VBox_VisualDisk::prepare_legend( const std::vector<Partition> & partitions, std::vector<GParted::FILESYSTEM> & legend )
|
||||
{
|
||||
for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
|
||||
{
|
||||
|
@ -181,147 +269,196 @@ void VBox_VisualDisk::Prepare_Legend( std::vector<GParted::FILESYSTEM> & legend,
|
|||
legend .push_back( partitions[ t ] .filesystem );
|
||||
|
||||
if ( partitions[ t ] .type == GParted::TYPE_EXTENDED )
|
||||
Prepare_Legend( legend, partitions[ t ] .logicals ) ;
|
||||
prepare_legend( partitions[ t ] .logicals, legend ) ;
|
||||
}
|
||||
}
|
||||
|
||||
void VBox_VisualDisk::Build_Legend( )
|
||||
Gtk::HBox * VBox_VisualDisk::create_legend_item( GParted::FILESYSTEM fs )
|
||||
{
|
||||
//add the hboxes and frame_legenda
|
||||
frame_disk_legend = manage( new Gtk::Frame( ) ) ;
|
||||
hbox_legend_main .pack_start( *frame_disk_legend, Gtk::PACK_EXPAND_PADDING );
|
||||
Gtk::HBox * hbox = manage( new Gtk::HBox( false, 5 ) ) ;
|
||||
hbox ->pack_start( * manage( new Gtk::Image( Utils::get_color_as_pixbuf( fs, 16, 16 ) ) ), Gtk::PACK_SHRINK );
|
||||
|
||||
hbox_legend = manage( new Gtk::HBox( ) );
|
||||
hbox_legend ->set_border_width( 2 ) ;
|
||||
frame_disk_legend ->add( *hbox_legend ) ;
|
||||
this ->pack_start( hbox_legend_main );
|
||||
hbox ->pack_start( * Utils::mk_label( Utils::Get_Filesystem_String( fs ) ), Gtk::PACK_SHRINK );
|
||||
|
||||
std::vector<GParted::FILESYSTEM> legend ;
|
||||
Prepare_Legend( legend, partitions ) ;
|
||||
|
||||
bool hide_used_unused = true;
|
||||
hbox_legend ->pack_start( * Utils::mk_label( " " ), Gtk::PACK_SHRINK );
|
||||
for ( unsigned int t = 0 ; t < legend .size( ) ; t++ )
|
||||
{
|
||||
if ( legend[ t ] != GParted::FS_UNALLOCATED && legend[ t ] != GParted::FS_EXTENDED && legend[ t ] != GParted::FS_LINUX_SWAP )
|
||||
hide_used_unused = false ;
|
||||
|
||||
if ( t )
|
||||
hbox_legend ->pack_start( * Utils::mk_label( " " ), Gtk::PACK_SHRINK );
|
||||
|
||||
image = manage( new Gtk::Image( Utils::get_color_as_pixbuf( legend[ t ], 16, 16 ) ) ) ;
|
||||
hbox_legend ->pack_start( *image, Gtk::PACK_SHRINK );
|
||||
hbox_legend ->pack_start( * Utils::mk_label( " " ), Gtk::PACK_SHRINK );
|
||||
|
||||
hbox_legend ->pack_start( * Utils::mk_label( Utils::Get_Filesystem_String( legend[ t ] ) ), Gtk::PACK_SHRINK );
|
||||
}
|
||||
hbox_legend ->pack_start( * Utils::mk_label( " " ), 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 );
|
||||
|
||||
hbox_legend = manage( new Gtk::HBox( ) );
|
||||
hbox_legend ->set_border_width( 2 ) ;
|
||||
frame_disk_legend ->add( *hbox_legend );
|
||||
|
||||
hbox_legend ->pack_start( * Utils::mk_label( " " ), Gtk::PACK_SHRINK );
|
||||
|
||||
//used
|
||||
image = manage( new Gtk::Image( Utils::get_color_as_pixbuf( GParted::FS_USED, 16, 16 ) ) ) ;
|
||||
hbox_legend ->pack_start( *image, Gtk::PACK_SHRINK );
|
||||
hbox_legend ->pack_start( * Utils::mk_label( " " ), Gtk::PACK_SHRINK );
|
||||
hbox_legend ->pack_start( * Utils::mk_label( Utils::Get_Filesystem_String( GParted::FS_USED ) ), Gtk::PACK_SHRINK );
|
||||
|
||||
hbox_legend ->pack_start( * Utils::mk_label( " " ), Gtk::PACK_SHRINK );
|
||||
|
||||
//unused
|
||||
image = manage( new Gtk::Image( Utils::get_color_as_pixbuf( GParted::FS_UNUSED, 16, 16 ) ) ) ;
|
||||
hbox_legend ->pack_start( *image, Gtk::PACK_SHRINK );
|
||||
hbox_legend ->pack_start( * Utils::mk_label( " " ), Gtk::PACK_SHRINK );
|
||||
|
||||
hbox_legend ->pack_start( * Utils::mk_label( Utils::Get_Filesystem_String( GParted::FS_UNUSED ) ), Gtk::PACK_SHRINK );
|
||||
|
||||
hbox_legend ->pack_start( * Utils::mk_label( " " ), Gtk::PACK_SHRINK );
|
||||
}
|
||||
return hbox ;
|
||||
}
|
||||
|
||||
void VBox_VisualDisk::Set_Selected( const Partition & partition )
|
||||
void VBox_VisualDisk::draw_partitions( const std::vector<visual_partition> & visual_partitions )
|
||||
{
|
||||
//clean previously selected one
|
||||
temp = selected_partition ;
|
||||
selected_partition = -1;
|
||||
if ( temp >= 0 ) //prevent segfault at firsttime selection
|
||||
drawingarea_on_expose( NULL, visual_partitions[ temp ] ) ;
|
||||
|
||||
if ( partition.type == GParted::TYPE_EXTENDED )
|
||||
return; //extended can not be selected in visualdisk (yet )
|
||||
|
||||
//now set new selected one
|
||||
for ( unsigned int t = 0 ; t < visual_partitions .size() ; t++ )
|
||||
{
|
||||
if ( visual_partitions[ t ] ->sector_start == partition .sector_start && visual_partitions[ t ] ->drawingarea != NULL )
|
||||
//partition...
|
||||
gc ->set_foreground( visual_partitions[ t ] .color );
|
||||
drawingarea .get_window() ->draw_rectangle( gc,
|
||||
true,
|
||||
visual_partitions[ t ] .x_start,
|
||||
visual_partitions[ t ] .y_start,
|
||||
visual_partitions[ t ] .length,
|
||||
visual_partitions[ t ] .height );
|
||||
|
||||
//used..
|
||||
if ( visual_partitions[ t ] .used_length > 0 )
|
||||
{
|
||||
selected_partition = t;
|
||||
drawingarea_on_expose( NULL, visual_partitions[ t ] ) ;
|
||||
return;
|
||||
}
|
||||
}
|
||||
gc ->set_foreground( color_used );
|
||||
drawingarea .get_window() ->draw_rectangle( gc,
|
||||
true,
|
||||
visual_partitions[ t ] .x_used_start,
|
||||
visual_partitions[ t ] .y_used_unused_start,
|
||||
visual_partitions[ t ] .used_length,
|
||||
visual_partitions[ t ] .used_unused_height );
|
||||
}
|
||||
|
||||
void VBox_VisualDisk::drawingarea_on_realize( Visual_Partition* vp )
|
||||
//unused
|
||||
if ( visual_partitions[ t ] .unused_length > 0 )
|
||||
{
|
||||
vp ->gc = Gdk::GC::create( vp ->drawingarea ->get_window( ) );
|
||||
|
||||
vp ->drawingarea ->get_window( ) ->set_background( vp ->color_fs );
|
||||
//eventmasks necessary for tooltips
|
||||
vp ->drawingarea ->add_events( Gdk::ENTER_NOTIFY_MASK );
|
||||
vp ->drawingarea ->add_events( Gdk::LEAVE_NOTIFY_MASK );
|
||||
gc ->set_foreground( color_unused );
|
||||
drawingarea .get_window() ->draw_rectangle( gc,
|
||||
true,
|
||||
visual_partitions[ t ] .x_unused_start,
|
||||
visual_partitions[ t ] .y_used_unused_start,
|
||||
visual_partitions[ t ] .unused_length,
|
||||
visual_partitions[ t ] .used_unused_height );
|
||||
}
|
||||
|
||||
bool VBox_VisualDisk::drawingarea_on_expose( GdkEventExpose * ev, Visual_Partition* vp )
|
||||
//text
|
||||
if ( visual_partitions[ t ] .x_text > 0 )
|
||||
{
|
||||
vp ->drawingarea ->get_window( ) ->clear( ) ;
|
||||
|
||||
if ( vp ->used != -1 ) //if not unknown or unallocated
|
||||
{
|
||||
vp ->gc ->set_foreground( color_used );
|
||||
vp ->drawingarea ->get_window( ) ->draw_rectangle( vp ->gc, true, BORDER, BORDER, vp ->used, vp ->height );
|
||||
|
||||
vp ->gc ->set_foreground( color_unused );
|
||||
vp ->drawingarea ->get_window( ) ->draw_rectangle( vp ->gc, true, BORDER + vp ->used, BORDER, vp ->length - vp ->used - BORDER *2 , vp ->height );
|
||||
gc ->set_foreground( color_text );
|
||||
drawingarea .get_window() ->draw_layout( gc,
|
||||
visual_partitions[ t ] .x_text,
|
||||
visual_partitions[ t ] .y_text,
|
||||
visual_partitions[ t ] .pango_layout ) ;
|
||||
}
|
||||
|
||||
vp ->gc ->set_foreground( color_text );
|
||||
vp ->drawingarea ->get_window( ) ->draw_layout( vp ->gc, BORDER +2, vp ->text_y, vp ->pango_layout ) ;
|
||||
|
||||
//if partition is selected one..
|
||||
if ( vp ->index == selected_partition )
|
||||
//selection rectangle...
|
||||
if ( visual_partitions[ t ] .selected )
|
||||
{
|
||||
vp ->gc ->set_foreground( color_used );
|
||||
vp ->drawingarea ->get_window( ) ->draw_rectangle( vp ->gc, false, 4, 4, vp ->length -8, vp ->height +8 );
|
||||
gc ->set_foreground( color_used );
|
||||
//selection start and ends at 4px from the borders, hence the >8 restriction
|
||||
if ( visual_partitions[ t ] .length > 8 )
|
||||
drawingarea .get_window() ->draw_rectangle( gc,
|
||||
false,
|
||||
visual_partitions[ t ] .x_start +4,
|
||||
visual_partitions[ t ] .y_start +4,
|
||||
visual_partitions[ t ] .length -9,
|
||||
visual_partitions[ t ] .height -9 );
|
||||
else
|
||||
drawingarea .get_window() ->draw_rectangle( gc,
|
||||
true,
|
||||
visual_partitions[ t ] .x_start,
|
||||
visual_partitions[ t ] .y_start +9,
|
||||
visual_partitions[ t ] .length,
|
||||
visual_partitions[ t ] .height -19 );
|
||||
}
|
||||
|
||||
if ( visual_partitions[ t ] .logicals .size() > 0 )
|
||||
draw_partitions( visual_partitions[ t ] .logicals ) ;
|
||||
}
|
||||
}
|
||||
|
||||
bool VBox_VisualDisk::set_selected( std::vector<visual_partition> & visual_partitions, int x, int y )
|
||||
{
|
||||
bool found = false ;
|
||||
|
||||
for ( unsigned int t = 0 ; t < visual_partitions .size() ; t++ )
|
||||
{
|
||||
if ( visual_partitions[ t ] .x_start <= x && x < visual_partitions[ t ] .x_start + visual_partitions[ t ] .length &&
|
||||
visual_partitions[ t ] .y_start <= y && y < visual_partitions[ t ] .y_start + visual_partitions[ t ] .height )
|
||||
{
|
||||
visual_partitions[ t ] .selected = true ;
|
||||
selected_vp = visual_partitions[ t ] ;
|
||||
found = true ;
|
||||
}
|
||||
else
|
||||
visual_partitions[ t ] .selected = false ;
|
||||
|
||||
if ( visual_partitions[ t ] .logicals .size() > 0 )
|
||||
visual_partitions[ t ] .selected &= ! set_selected( visual_partitions[ t ] .logicals, x, y ) ;
|
||||
|
||||
}
|
||||
|
||||
return found ;
|
||||
}
|
||||
|
||||
void VBox_VisualDisk::set_selected( std::vector<visual_partition> & visual_partitions, const Partition & partition )
|
||||
{
|
||||
for ( unsigned int t = 0 ; t < visual_partitions .size() ; t++ )
|
||||
{
|
||||
if ( visual_partitions[ t ] .partition == partition )
|
||||
{
|
||||
visual_partitions[ t ] .selected = true ;
|
||||
selected_vp = visual_partitions[ t ] ;
|
||||
}
|
||||
else
|
||||
visual_partitions[ t ] .selected = false ;
|
||||
|
||||
if ( visual_partitions[ t ] .logicals .size() > 0 )
|
||||
set_selected( visual_partitions[ t ] .logicals, partition ) ;
|
||||
}
|
||||
}
|
||||
|
||||
void VBox_VisualDisk::drawingarea_on_realize()
|
||||
{
|
||||
gc = Gdk::GC::create( drawingarea .get_window() );
|
||||
|
||||
//connect here to prevent premature signalling (only relevant at startup)
|
||||
drawingarea .signal_size_allocate() .connect( sigc::mem_fun( *this, &VBox_VisualDisk::on_resize ) ) ;
|
||||
}
|
||||
|
||||
bool VBox_VisualDisk::drawingarea_on_expose( GdkEventExpose * event )
|
||||
{
|
||||
draw_partitions( visual_partitions ) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool VBox_VisualDisk::on_drawingarea_button_press( GdkEventButton *event, const Partition & partition )
|
||||
bool VBox_VisualDisk::on_drawingarea_button_press( GdkEventButton * event )
|
||||
{
|
||||
signal_mouse_click .emit( event, partition );
|
||||
if ( set_selected( visual_partitions, static_cast<int>( event ->x ), static_cast<int>( event ->y ) ) )
|
||||
signal_mouse_click .emit( event, selected_vp .partition );
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
void VBox_VisualDisk::on_resize( Gtk::Allocation & allocation )
|
||||
{
|
||||
MIN_SIZE = 20 ;
|
||||
|
||||
int calced, TOTAL ;
|
||||
do
|
||||
{
|
||||
TOTAL = allocation .get_width() - TOT_SEP ;
|
||||
calced = allocation .get_width() ; //for first time :)
|
||||
do
|
||||
{
|
||||
TOTAL -= ( calced - allocation .get_width() ) ;
|
||||
calced = calc_length( visual_partitions, TOTAL ) ;
|
||||
}
|
||||
while ( calced > allocation .get_width() && TOTAL > 0 ) ;
|
||||
|
||||
MIN_SIZE-- ;
|
||||
}
|
||||
while ( TOTAL <= 0 && MIN_SIZE > 0 ) ;
|
||||
|
||||
calc_position_and_height( visual_partitions, 0, 0 ) ;
|
||||
calc_used_unused( visual_partitions ) ;
|
||||
calc_text( visual_partitions ) ;
|
||||
}
|
||||
|
||||
void VBox_VisualDisk::free_colors( std::vector<visual_partition> & visual_partitions )
|
||||
{
|
||||
for ( unsigned int t = 0 ; t < visual_partitions .size() ; t++ )
|
||||
{
|
||||
this ->get_colormap( ) ->free_color( visual_partitions[ t ] .color ) ;
|
||||
|
||||
if ( visual_partitions[ t ] .logicals .size() > 0 )
|
||||
free_colors( visual_partitions[ t ] .logicals ) ;
|
||||
}
|
||||
}
|
||||
|
||||
VBox_VisualDisk::~VBox_VisualDisk()
|
||||
{
|
||||
for ( unsigned int t = 0 ; t < visual_partitions .size( ) ; t++ )
|
||||
{
|
||||
this ->get_colormap( ) ->free_colors( visual_partitions[ t ] ->color_fs, 1 ) ;
|
||||
delete visual_partitions[ t ] ;
|
||||
}
|
||||
|
||||
visual_partitions .clear( ) ;
|
||||
clear() ;
|
||||
|
||||
//free the allocated colors
|
||||
this ->get_colormap( ) ->free_colors( color_used, 1 ) ;
|
||||
|
|
|
@ -28,7 +28,6 @@ Win_GParted::Win_GParted( )
|
|||
selected_partition .Reset( ) ;
|
||||
new_count = 1;
|
||||
current_device = 0 ;
|
||||
vbox_visual_disk = NULL;
|
||||
pulse = false ;
|
||||
|
||||
//==== GUI =========================
|
||||
|
@ -50,8 +49,9 @@ Win_GParted::Win_GParted( )
|
|||
init_toolbar( ) ;
|
||||
vbox_main.pack_start( hbox_toolbar, Gtk::PACK_SHRINK );
|
||||
|
||||
//hbox_visual... ( contains the visual represenation of the disks )
|
||||
vbox_main.pack_start( hbox_visual, Gtk::PACK_SHRINK );
|
||||
//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_main .pack_start( vbox_visual_disk, Gtk::PACK_SHRINK ) ;
|
||||
|
||||
//hpaned_main (NOTE: added to vpaned_main)
|
||||
init_hpaned_main( ) ;
|
||||
|
@ -472,18 +472,22 @@ void Win_GParted::Refresh_Visual( )
|
|||
treerow[ treeview_operations_columns .operation_description ] = operations[ t ] .str_operation ;
|
||||
switch ( operations[ t ] .operationtype )
|
||||
{
|
||||
case GParted::DELETE : treerow[ treeview_operations_columns.operation_icon ] =render_icon(Gtk::Stock::DELETE, Gtk::ICON_SIZE_MENU);
|
||||
case GParted::DELETE :
|
||||
treerow[ treeview_operations_columns.operation_icon ] =render_icon(Gtk::Stock::DELETE, Gtk::ICON_SIZE_MENU);
|
||||
break;
|
||||
case GParted::CREATE : treerow[ treeview_operations_columns.operation_icon ] =render_icon(Gtk::Stock::NEW, Gtk::ICON_SIZE_MENU);
|
||||
case GParted::CREATE :
|
||||
treerow[ treeview_operations_columns.operation_icon ] =render_icon(Gtk::Stock::NEW, Gtk::ICON_SIZE_MENU);
|
||||
break;
|
||||
case GParted::RESIZE_MOVE: treerow[ treeview_operations_columns.operation_icon ] =render_icon(Gtk::Stock::GOTO_LAST, Gtk::ICON_SIZE_MENU);
|
||||
case GParted::RESIZE_MOVE:
|
||||
treerow[ treeview_operations_columns.operation_icon ] =render_icon(Gtk::Stock::GOTO_LAST, Gtk::ICON_SIZE_MENU);
|
||||
break;
|
||||
case GParted::CONVERT : treerow[ treeview_operations_columns.operation_icon ] =render_icon(Gtk::Stock::CONVERT, Gtk::ICON_SIZE_MENU);
|
||||
case GParted::CONVERT :
|
||||
treerow[ treeview_operations_columns.operation_icon ] =render_icon(Gtk::Stock::CONVERT, Gtk::ICON_SIZE_MENU);
|
||||
break;
|
||||
case GParted::COPY : treerow[ treeview_operations_columns.operation_icon ] =render_icon(Gtk::Stock::COPY, Gtk::ICON_SIZE_MENU);
|
||||
case GParted::COPY :
|
||||
treerow[ treeview_operations_columns.operation_icon ] =render_icon(Gtk::Stock::COPY, Gtk::ICON_SIZE_MENU);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//set new statusbartext
|
||||
|
@ -525,16 +529,7 @@ void Win_GParted::Refresh_Visual( )
|
|||
}
|
||||
|
||||
//vbox visual
|
||||
if ( vbox_visual_disk != NULL )
|
||||
{
|
||||
hbox_visual .remove( *vbox_visual_disk );
|
||||
delete ( vbox_visual_disk );
|
||||
}
|
||||
|
||||
vbox_visual_disk = new VBox_VisualDisk ( partitions, devices[ current_device ] .length ) ;
|
||||
vbox_visual_disk ->signal_mouse_click.connect( sigc::mem_fun( this, &Win_GParted::mouse_click ) ) ;
|
||||
hbox_visual .pack_start( *vbox_visual_disk, Gtk::PACK_EXPAND_PADDING ) ;
|
||||
hbox_visual .show_all_children( ) ;
|
||||
vbox_visual_disk .load_partitions( partitions, devices[ current_device ] .length ) ;
|
||||
|
||||
//treeview details
|
||||
treeview_detail .Load_Partitions( partitions ) ;
|
||||
|
@ -704,7 +699,6 @@ void Win_GParted::menu_gparted_refresh_devices( )
|
|||
thread = Glib::Thread::create( SigC::slot_class( *this, &Win_GParted::find_devices_thread ), true );
|
||||
|
||||
Show_Pulsebar() ;
|
||||
|
||||
//check if current_device is still available (think about hotpluggable shit like usbdevices)
|
||||
if ( current_device >= devices .size() )
|
||||
current_device = 0 ;
|
||||
|
@ -748,20 +742,16 @@ void Win_GParted::menu_gparted_refresh_devices( )
|
|||
{
|
||||
optionmenu_devices .hide() ;
|
||||
|
||||
menubar_main .items()[ 1 ] .set_sensitive( false ) ;
|
||||
menubar_main .items()[ 2 ] .set_sensitive( false ) ;
|
||||
menubar_main .items()[ 3 ] .set_sensitive( false ) ;
|
||||
menubar_main .items()[ 4 ] .set_sensitive( false ) ;
|
||||
toolbar_main .set_sensitive( false ) ;
|
||||
optionmenu_devices .set_sensitive( false ) ;
|
||||
|
||||
Fill_Label_Device_Info( true ) ;
|
||||
|
||||
if ( vbox_visual_disk != NULL )
|
||||
{
|
||||
hbox_visual .remove( *vbox_visual_disk );
|
||||
delete( vbox_visual_disk ) ;
|
||||
vbox_visual_disk = NULL ;
|
||||
}
|
||||
|
||||
vbox_visual_disk .clear() ;
|
||||
treeview_detail .Clear() ;
|
||||
|
||||
//hmzz, this is really paranoid, but i think it's the right thing to do ;)
|
||||
|
@ -886,7 +876,8 @@ void Win_GParted::mouse_click( GdkEventButton *event, const Partition & partitio
|
|||
Set_Valid_Operations( ) ;
|
||||
|
||||
treeview_detail .Set_Selected( partition );
|
||||
vbox_visual_disk ->Set_Selected( partition );
|
||||
|
||||
vbox_visual_disk .set_selected( partition ) ;
|
||||
|
||||
if ( event ->type == GDK_2BUTTON_PRESS && ! pulse )
|
||||
activate_info( ) ;
|
||||
|
|
Loading…
Reference in New Issue