fixed a few issues with selecting/activating partitions. improved support
* include/DrawingAreaVisualDisk.h, src/DrawingAreaVisualDisk.cc: fixed a few issues with selecting/activating partitions. * include/Utils.h, src/Utils.cc, src/Dialog_Disklabel.cc, src/Dialog_Partition_Info.cc (mk_label): improved support for aligment. * src/Win_GParted.cc: fixed a small alignmentissue in the devices submenu.
This commit is contained in:
parent
ad9f2126e7
commit
c3c5f189ed
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
2006-03-20 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||||
|
|
||||||
|
* include/DrawingAreaVisualDisk.h,
|
||||||
|
src/DrawingAreaVisualDisk.cc: fixed a few issues with
|
||||||
|
selecting/activating partitions.
|
||||||
|
* include/Utils.h,
|
||||||
|
src/Utils.cc,
|
||||||
|
src/Dialog_Disklabel.cc,
|
||||||
|
src/Dialog_Partition_Info.cc (mk_label): improved support for
|
||||||
|
aligment.
|
||||||
|
* src/Win_GParted.cc: fixed a small alignmentissue in the devices
|
||||||
|
submenu.
|
||||||
|
|
||||||
2006-03-19 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
2006-03-19 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||||
|
|
||||||
* include/GParted_Core.h,
|
* include/GParted_Core.h,
|
||||||
|
|
|
@ -57,8 +57,8 @@ private:
|
||||||
void draw_partition( const visual_partition & vp ) ;
|
void draw_partition( const visual_partition & vp ) ;
|
||||||
void draw_partitions( const std::vector<visual_partition> & visual_partitions ) ;
|
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( const std::vector<visual_partition> & visual_partitions, int x, int y ) ;
|
||||||
void set_selected( std::vector<visual_partition> & visual_partitions, const Partition & partition ) ;
|
void set_selected( const std::vector<visual_partition> & visual_partitions, const Partition & partition ) ;
|
||||||
|
|
||||||
int spreadout_leftover_px( std::vector<visual_partition> & visual_partitions, int pixels ) ;
|
int spreadout_leftover_px( std::vector<visual_partition> & visual_partitions, int pixels ) ;
|
||||||
void free_colors( std::vector<visual_partition> & visual_partitions ) ;
|
void free_colors( std::vector<visual_partition> & visual_partitions ) ;
|
||||||
|
@ -82,8 +82,6 @@ private:
|
||||||
int y_used_unused_start, used_unused_height ;
|
int y_used_unused_start, used_unused_height ;
|
||||||
int x_text, y_text ;
|
int x_text, y_text ;
|
||||||
|
|
||||||
bool selected ;
|
|
||||||
|
|
||||||
Gdk::Color color ;
|
Gdk::Color color ;
|
||||||
Glib::RefPtr<Pango::Layout> pango_layout;
|
Glib::RefPtr<Pango::Layout> pango_layout;
|
||||||
|
|
||||||
|
@ -102,8 +100,6 @@ private:
|
||||||
y_used_unused_start = used_unused_height =
|
y_used_unused_start = used_unused_height =
|
||||||
x_text = y_text = 0 ;
|
x_text = y_text = 0 ;
|
||||||
|
|
||||||
selected = false ;
|
|
||||||
|
|
||||||
pango_layout .clear() ;
|
pango_layout .clear() ;
|
||||||
logicals .clear() ;
|
logicals .clear() ;
|
||||||
}
|
}
|
||||||
|
@ -116,7 +112,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<visual_partition> visual_partitions ;
|
std::vector<visual_partition> visual_partitions ;
|
||||||
visual_partition selected_vp ;
|
const visual_partition * selected_vp ;
|
||||||
int TOT_SEP, MIN_SIZE ;
|
int TOT_SEP, MIN_SIZE ;
|
||||||
|
|
||||||
Glib::RefPtr<Gdk::GC> gc;
|
Glib::RefPtr<Gdk::GC> gc;
|
||||||
|
|
|
@ -114,7 +114,7 @@ public:
|
||||||
static Sector Round( double double_value ) ;
|
static Sector Round( double double_value ) ;
|
||||||
static Gtk::Label * mk_label( const Glib::ustring & text,
|
static Gtk::Label * mk_label( const Glib::ustring & text,
|
||||||
bool use_markup = true,
|
bool use_markup = true,
|
||||||
bool align_left = true,
|
Gtk::AlignmentEnum alignment = Gtk::ALIGN_LEFT,
|
||||||
bool wrap = false,
|
bool wrap = false,
|
||||||
const Glib::ustring & text_color = "black" ) ;
|
const Glib::ustring & text_color = "black" ) ;
|
||||||
static Glib::ustring num_to_str( Sector number, bool use_C_locale = false ) ;
|
static Glib::ustring num_to_str( Sector number, bool use_C_locale = false ) ;
|
||||||
|
|
|
@ -51,7 +51,7 @@ Dialog_Disklabel::Dialog_Disklabel( const Glib::ustring & device_path, const std
|
||||||
str_temp += "\n\n" ;
|
str_temp += "\n\n" ;
|
||||||
str_temp += _("By default GParted creates an msdos disklabel.") ;
|
str_temp += _("By default GParted creates an msdos disklabel.") ;
|
||||||
str_temp += "\n" ;
|
str_temp += "\n" ;
|
||||||
vbox ->pack_start( * Utils::mk_label( str_temp, true, true, true ), Gtk::PACK_SHRINK );
|
vbox ->pack_start( * Utils::mk_label( str_temp, true, Gtk::ALIGN_LEFT, true ), Gtk::PACK_SHRINK );
|
||||||
|
|
||||||
//advanced
|
//advanced
|
||||||
str_temp = "<b>" ;
|
str_temp = "<b>" ;
|
||||||
|
|
|
@ -49,7 +49,7 @@ Dialog_Partition_Info::Dialog_Partition_Info( const Partition & partition )
|
||||||
Gtk::PACK_SHRINK ) ;
|
Gtk::PACK_SHRINK ) ;
|
||||||
|
|
||||||
frame ->set_label_widget( *hbox ) ;
|
frame ->set_label_widget( *hbox ) ;
|
||||||
frame ->add( * Utils::mk_label( "<i>" + partition.error + "</i>", true, true, true ) ) ;
|
frame ->add( * Utils::mk_label( "<i>" + partition.error + "</i>", true, Gtk::ALIGN_LEFT, true ) ) ;
|
||||||
|
|
||||||
this ->get_vbox() ->pack_start( *frame, Gtk::PACK_SHRINK ) ;
|
this ->get_vbox() ->pack_start( *frame, Gtk::PACK_SHRINK ) ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,7 @@ void DrawingAreaVisualDisk::load_partitions( const std::vector<Partition> & part
|
||||||
|
|
||||||
void DrawingAreaVisualDisk::set_selected( const Partition & partition )
|
void DrawingAreaVisualDisk::set_selected( const Partition & partition )
|
||||||
{
|
{
|
||||||
|
selected_vp = NULL ;
|
||||||
set_selected( visual_partitions, partition ) ;
|
set_selected( visual_partitions, partition ) ;
|
||||||
|
|
||||||
queue_draw() ;
|
queue_draw() ;
|
||||||
|
@ -63,6 +64,7 @@ void DrawingAreaVisualDisk::clear()
|
||||||
{
|
{
|
||||||
free_colors( visual_partitions ) ;
|
free_colors( visual_partitions ) ;
|
||||||
visual_partitions .clear() ;
|
visual_partitions .clear() ;
|
||||||
|
selected_vp = NULL ;
|
||||||
|
|
||||||
queue_resize() ;
|
queue_resize() ;
|
||||||
}
|
}
|
||||||
|
@ -247,18 +249,6 @@ void DrawingAreaVisualDisk::draw_partition( const visual_partition & vp )
|
||||||
vp .y_text,
|
vp .y_text,
|
||||||
vp .pango_layout ) ;
|
vp .pango_layout ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//selection
|
|
||||||
if ( vp .selected )
|
|
||||||
{
|
|
||||||
gc ->set_foreground( color_used ) ;
|
|
||||||
get_window() ->draw_rectangle( gc,
|
|
||||||
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_partition> & visual_partitions )
|
void DrawingAreaVisualDisk::draw_partitions( const std::vector<visual_partition> & visual_partitions )
|
||||||
|
@ -272,45 +262,34 @@ void DrawingAreaVisualDisk::draw_partitions( const std::vector<visual_partition>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DrawingAreaVisualDisk::set_selected( std::vector<visual_partition> & visual_partitions, int x, int y )
|
void DrawingAreaVisualDisk::set_selected( const std::vector<visual_partition> & visual_partitions, int x, int y )
|
||||||
{
|
{
|
||||||
bool found = false ;
|
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, x, y ) ;
|
||||||
|
|
||||||
for ( unsigned int t = 0 ; t < visual_partitions .size() ; t++ )
|
if ( ! selected_vp &&
|
||||||
{
|
visual_partitions[ t ] .x_start <= x &&
|
||||||
if ( visual_partitions[ t ] .x_start <= x &&
|
|
||||||
x < visual_partitions[ t ] .x_start + visual_partitions[ t ] .length &&
|
x < visual_partitions[ t ] .x_start + visual_partitions[ t ] .length &&
|
||||||
visual_partitions[ t ] .y_start <= y &&
|
visual_partitions[ t ] .y_start <= y &&
|
||||||
y < visual_partitions[ t ] .y_start + visual_partitions[ t ] .height )
|
y < visual_partitions[ t ] .y_start + visual_partitions[ t ] .height )
|
||||||
{
|
{
|
||||||
visual_partitions[ t ] .selected = true ;
|
selected_vp = & visual_partitions[ t ] ;
|
||||||
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 DrawingAreaVisualDisk::set_selected( const std::vector<visual_partition> & visual_partitions,
|
||||||
}
|
const Partition & partition )
|
||||||
|
|
||||||
void DrawingAreaVisualDisk::set_selected( std::vector<visual_partition> & visual_partitions, const Partition & partition )
|
|
||||||
{
|
{
|
||||||
for ( unsigned int t = 0 ; t < visual_partitions .size() ; t++ )
|
for ( unsigned int t = 0 ; t < visual_partitions .size() && ! selected_vp ; 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 )
|
if ( visual_partitions[ t ] .logicals .size() > 0 )
|
||||||
set_selected( visual_partitions[ t ] .logicals, partition ) ;
|
set_selected( visual_partitions[ t ] .logicals, partition ) ;
|
||||||
|
|
||||||
|
if ( ! selected_vp && visual_partitions[ t ] .partition == partition )
|
||||||
|
selected_vp = & visual_partitions[ t ] ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,6 +310,18 @@ bool DrawingAreaVisualDisk::on_expose_event( GdkEventExpose * event )
|
||||||
|
|
||||||
draw_partitions( visual_partitions ) ;
|
draw_partitions( visual_partitions ) ;
|
||||||
|
|
||||||
|
//selection
|
||||||
|
if ( selected_vp )
|
||||||
|
{
|
||||||
|
gc ->set_foreground( color_used ) ;
|
||||||
|
get_window() ->draw_rectangle( gc,
|
||||||
|
false,
|
||||||
|
selected_vp ->x_start + BORDER/2 ,
|
||||||
|
selected_vp ->y_start + BORDER/2 ,
|
||||||
|
selected_vp ->length - BORDER,
|
||||||
|
selected_vp ->height - BORDER ) ;
|
||||||
|
}
|
||||||
|
|
||||||
return ret_val ;
|
return ret_val ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,16 +329,19 @@ bool DrawingAreaVisualDisk::on_button_press_event( GdkEventButton * event )
|
||||||
{
|
{
|
||||||
bool ret_val = Gtk::DrawingArea::on_button_press_event( event ) ;
|
bool ret_val = Gtk::DrawingArea::on_button_press_event( event ) ;
|
||||||
|
|
||||||
|
selected_vp = NULL ;
|
||||||
set_selected( visual_partitions, static_cast<int>( event ->x ), static_cast<int>( event ->y ) ) ;
|
set_selected( visual_partitions, static_cast<int>( event ->x ), static_cast<int>( event ->y ) ) ;
|
||||||
queue_draw() ;
|
queue_draw() ;
|
||||||
|
|
||||||
signal_partition_selected .emit( selected_vp .partition, false ) ;
|
if ( selected_vp )
|
||||||
|
{
|
||||||
|
signal_partition_selected .emit( selected_vp ->partition, false ) ;
|
||||||
|
|
||||||
if ( event ->type == GDK_2BUTTON_PRESS ) //FIXME: only emit the signal if a partition was selected
|
if ( event ->type == GDK_2BUTTON_PRESS )
|
||||||
//right now it's possible to 'activate' a seperator.
|
|
||||||
signal_partition_activated .emit() ;
|
signal_partition_activated .emit() ;
|
||||||
else if ( event ->button == 3 )
|
else if ( event ->button == 3 )
|
||||||
signal_popup_menu .emit( event ->button, event ->time ) ;
|
signal_popup_menu .emit( event ->button, event ->time ) ;
|
||||||
|
}
|
||||||
|
|
||||||
return ret_val ;
|
return ret_val ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,13 +30,11 @@ Sector Utils::Round( double double_value )
|
||||||
|
|
||||||
Gtk::Label * Utils::mk_label( const Glib::ustring & text,
|
Gtk::Label * Utils::mk_label( const Glib::ustring & text,
|
||||||
bool use_markup,
|
bool use_markup,
|
||||||
bool align_left,
|
Gtk::AlignmentEnum alignment,
|
||||||
bool wrap,
|
bool wrap,
|
||||||
const Glib::ustring & text_color )
|
const Glib::ustring & text_color )
|
||||||
{
|
{
|
||||||
Gtk::Label * label = manage( new Gtk::Label( text,
|
Gtk::Label * label = manage( new Gtk::Label( text, alignment, Gtk::ALIGN_TOP ) ) ;
|
||||||
align_left ? Gtk::ALIGN_LEFT : Gtk::ALIGN_CENTER,
|
|
||||||
Gtk::ALIGN_TOP ) ) ;
|
|
||||||
|
|
||||||
label ->set_use_markup( use_markup ) ;
|
label ->set_use_markup( use_markup ) ;
|
||||||
label ->set_line_wrap( wrap ) ;
|
label ->set_line_wrap( wrap ) ;
|
||||||
|
|
|
@ -444,20 +444,26 @@ void Win_GParted::refresh_combo_devices()
|
||||||
treerow[ treeview_devices_columns .size ] = "(" + Utils::format_size( devices[ i ] .length ) + ")" ;
|
treerow[ treeview_devices_columns .size ] = "(" + Utils::format_size( devices[ i ] .length ) + ")" ;
|
||||||
|
|
||||||
//devices submenu....
|
//devices submenu....
|
||||||
menu ->items() .push_back( Gtk::Menu_Helpers::RadioMenuElem(
|
hbox = manage( new Gtk::HBox() ) ;
|
||||||
radio_group,
|
hbox ->pack_start( * Utils::mk_label( devices[ i ] .get_path() ), Gtk::PACK_SHRINK ) ;
|
||||||
devices[ i ] .get_path() + "\t(" + Utils::format_size( devices[ i ] .length ) + ")",
|
hbox ->pack_start( * Utils::mk_label( " (" + Utils::format_size( devices[ i ] .length ) + ")",
|
||||||
sigc::bind<unsigned int>( sigc::mem_fun(*this, &Win_GParted::radio_devices_changed), i ) ) ) ;
|
true,
|
||||||
|
Gtk::ALIGN_RIGHT ),
|
||||||
|
Gtk::PACK_EXPAND_WIDGET ) ;
|
||||||
|
|
||||||
//FIXME: the (size) needs the be rightaligned while the path should remain left-aligned
|
menu ->items() .push_back( * manage( new Gtk::RadioMenuItem( radio_group ) ) ) ;
|
||||||
//i guess this takes 2 labels to achieve..
|
menu ->items() .back() .add( *hbox ) ;
|
||||||
|
menu ->items() .back() .signal_activate() .connect(
|
||||||
|
sigc::bind<unsigned int>( sigc::mem_fun(*this, &Win_GParted::radio_devices_changed), i ) ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
menubar_main .items()[ 0 ] .get_submenu() ->items()[ 1 ] .remove_submenu() ;
|
menubar_main .items()[ 0 ] .get_submenu() ->items()[ 1 ] .remove_submenu() ;
|
||||||
|
|
||||||
if ( menu ->items() .size() )
|
if ( menu ->items() .size() )
|
||||||
|
{
|
||||||
|
menu ->show_all() ;
|
||||||
menubar_main .items()[ 0 ] .get_submenu() ->items()[ 1 ] .set_submenu( *menu ) ;
|
menubar_main .items()[ 0 ] .get_submenu() ->items()[ 1 ] .set_submenu( *menu ) ;
|
||||||
|
}
|
||||||
|
|
||||||
combo_devices .set_active( current_device ) ;
|
combo_devices .set_active( current_device ) ;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue