prevent crasher when visual_disks is empty. load devices at startup on

* src/FrameVisualDisk.cc: prevent crasher when visual_disks is empty.
* include/Win_GParted.h,
  src/Win_GParted.cc: load devices at startup on signal_show instead
  of dispatching it from the c'tor.
  Also did some cleanups in the behaviour of opening and closing of
  the operationslist.
This commit is contained in:
Bart Hakvoort 2006-02-22 22:05:15 +00:00
parent a538361d3d
commit 283b40b892
4 changed files with 121 additions and 104 deletions

View File

@ -1,3 +1,12 @@
2006-02-22 Bart Hakvoort <hakvoort@cvs.gnome.org>
* src/FrameVisualDisk.cc: prevent crasher when visual_disks is empty.
* include/Win_GParted.h,
src/Win_GParted.cc: load devices at startup on signal_show instead
of dispatching it from the c'tor.
Also did some cleanups in the behaviour of opening and closing of
the operationslist.
2006-02-20 Bart Hakvoort <hakvoort@cvs.gnome.org> 2006-02-20 Bart Hakvoort <hakvoort@cvs.gnome.org>
* include/GParted_Core.h, * include/GParted_Core.h,

View File

@ -106,11 +106,13 @@ private:
void allow_undo( bool b ) { void allow_undo( bool b ) {
toolbar_main .get_nth_item( 8 ) ->set_sensitive( b ); toolbar_main .get_nth_item( 8 ) ->set_sensitive( b );
( (Gtk::CheckMenuItem *) & menubar_main .items( ) [ 1 ] .get_submenu( ) ->items( ) [ 0 ] ) ->set_sensitive( b ) ; } static_cast<Gtk::CheckMenuItem *>( & menubar_main .items()[ 1 ] .get_submenu() ->items()[ 0 ] )
->set_sensitive( b ) ; }
void allow_apply( bool b ) { void allow_apply( bool b ) {
toolbar_main .get_nth_item( 9 ) ->set_sensitive( b ); toolbar_main .get_nth_item( 9 ) ->set_sensitive( b );
( (Gtk::CheckMenuItem *) & menubar_main .items( ) [ 1 ] .get_submenu( ) ->items( ) [ 1 ] ) ->set_sensitive( b ) ; } static_cast<Gtk::CheckMenuItem *>( & menubar_main .items()[ 1 ] .get_submenu() ->items()[ 1 ] )
->set_sensitive( b ) ; }
//threads.. //threads..
void thread_refresh_devices() ; void thread_refresh_devices() ;
@ -123,6 +125,7 @@ private:
void clear_operationslist() ; void clear_operationslist() ;
void combo_devices_changed(); void combo_devices_changed();
void radio_devices_changed( unsigned int item ) ; void radio_devices_changed( unsigned int item ) ;
void on_signal_show() ;
void menu_gparted_refresh_devices(); void menu_gparted_refresh_devices();
void menu_gparted_filesystems(); void menu_gparted_filesystems();
@ -222,6 +225,7 @@ private:
unsigned short primary_count ;//primary_count checks for max. of 4 pimary partitions unsigned short primary_count ;//primary_count checks for max. of 4 pimary partitions
unsigned short new_count;//new_count keeps track of the new created partitions unsigned short new_count;//new_count keeps track of the new created partitions
FS fs ; FS fs ;
bool OPERATIONSLIST_OPEN ;
GParted_Core gparted_core ; GParted_Core gparted_core ;
GParted::Device *temp_device ; GParted::Device *temp_device ;
@ -229,8 +233,6 @@ private:
//stuff for progress overview and pulsebar //stuff for progress overview and pulsebar
Glib::Thread *thread ; Glib::Thread *thread ;
Glib::Dispatcher dispatcher;
sigc::connection conn ;
bool pulse ; bool pulse ;
}; };

View File

@ -374,7 +374,7 @@ void FrameVisualDisk::on_resize( Gtk::Allocation & allocation )
while ( TOTAL <= 0 && MIN_SIZE > 0 ) ; while ( TOTAL <= 0 && MIN_SIZE > 0 ) ;
//due to rounding a few px may be lost (max. 2), lets add these to the last partition. //due to rounding a few px may be lost (max. 2), lets add these to the last partition.
if ( allocation .get_width() > calced ) if ( allocation .get_width() > calced && visual_partitions .size() )
visual_partitions .back() .length += ( allocation .get_width() - calced ) ; visual_partitions .back() .length += ( allocation .get_width() - calced ) ;
calc_position_and_height( visual_partitions, 0, 0 ) ; calc_position_and_height( visual_partitions, 0, 0 ) ;

View File

@ -29,9 +29,6 @@
#include <gtkmm/radiobuttongroup.h> #include <gtkmm/radiobuttongroup.h>
#include <gtkmm/main.h> #include <gtkmm/main.h>
#include <cerrno>
#include <sys/swap.h>
namespace GParted namespace GParted
{ {
@ -42,6 +39,7 @@ Win_GParted::Win_GParted( const std::vector<Glib::ustring> & user_devices )
new_count = 1; new_count = 1;
current_device = 0 ; current_device = 0 ;
pulse = false ; pulse = false ;
OPERATIONSLIST_OPEN = true ;
gparted_core .set_user_devices( user_devices ) ; gparted_core .set_user_devices( user_devices ) ;
//==== GUI ========================= //==== GUI =========================
@ -60,6 +58,8 @@ Win_GParted::Win_GParted( const std::vector<Glib::ustring> & user_devices )
//Pack the main box //Pack the main box
this ->add( vbox_main ); this ->add( vbox_main );
this ->signal_show() .connect( sigc::mem_fun(*this, &Win_GParted::on_signal_show) );
//menubar.... //menubar....
init_menubar() ; init_menubar() ;
vbox_main .pack_start( menubar_main, Gtk::PACK_SHRINK ); vbox_main .pack_start( menubar_main, Gtk::PACK_SHRINK );
@ -95,12 +95,8 @@ Win_GParted::Win_GParted( const std::vector<Glib::ustring> & user_devices )
this ->show_all_children(); this ->show_all_children();
//make sure harddisk information and operationlist are closed.. //make sure harddisk information is closed..
hpaned_main .get_child1() ->hide() ; hpaned_main .get_child1() ->hide() ;
close_operationslist( ) ;
conn = dispatcher .connect( sigc::mem_fun( *this, &Win_GParted::menu_gparted_refresh_devices ) );
dispatcher() ;
} }
void Win_GParted::init_menubar() void Win_GParted::init_menubar()
@ -489,7 +485,6 @@ void Win_GParted::show_pulsebar( const Glib::ustring & status_message )
} }
thread ->join() ; thread ->join() ;
conn .disconnect() ;
pulsebar .hide(); pulsebar .hide();
statusbar .pop() ; statusbar .pop() ;
@ -755,39 +750,42 @@ void Win_GParted::set_valid_operations()
void Win_GParted::open_operationslist() void Win_GParted::open_operationslist()
{ {
if ( ! OPERATIONSLIST_OPEN )
{
OPERATIONSLIST_OPEN = true ;
hbox_operations .show() ; hbox_operations .show() ;
int x,y; this ->get_size( x, y );
y -= 300;
for ( int t = vpaned_main .get_position( ) ; t > y ; t-=5 ) for ( int t = vpaned_main .get_height() ; t > ( vpaned_main .get_height() - 100 ) ; t -= 5 )
{ {
vpaned_main .set_position( t ); vpaned_main .set_position( t );
while ( Gtk::Main::events_pending() ) while ( Gtk::Main::events_pending() )
Gtk::Main::iteration() ; Gtk::Main::iteration() ;
} }
( (Gtk::CheckMenuItem *) & menubar_main .items( ) [ 2 ] .get_submenu( ) ->items( ) [ 1 ] ) ->set_active( true ) ; static_cast<Gtk::CheckMenuItem *>( & menubar_main .items()[ 2 ] .get_submenu() ->items()[ 1 ] )
->set_active( true ) ;
}
} }
void Win_GParted::close_operationslist() void Win_GParted::close_operationslist()
{ {
//FIXME: when started like 'gparted bla' it wil crash in this function if ( OPERATIONSLIST_OPEN )
//most likely this has something to do with the removal of the legend which rendered {
//the '210' incorrect. This static numbering sucks anyway, so i should find a way to open and OPERATIONSLIST_OPEN = false ;
//close the operationslist without these static numbers. See also open_operationslist()
int x,y; this ->get_size( x, y ); for ( int t = vpaned_main .get_position() ; t < vpaned_main .get_height() ; t += 5 )
y -= 210 ; //height of whole app - menubar - visualdisk - statusbar ....
for ( int t = vpaned_main .get_position() ; t < y ; t+=5 )
{ {
vpaned_main .set_position( t ) ; vpaned_main .set_position( t ) ;
while ( Gtk::Main::events_pending() ) while ( Gtk::Main::events_pending() )
Gtk::Main::iteration(); Gtk::Main::iteration();
} }
hbox_operations .hide() ; hbox_operations .hide() ;
static_cast<Gtk::CheckMenuItem *>(
& menubar_main .items()[ 2 ] .get_submenu() -> static_cast<Gtk::CheckMenuItem *>( & menubar_main .items()[ 2 ] .get_submenu() ->items()[ 1 ] )
items()[ 1 ] ) ->set_active( false ) ; ->set_active( false ) ;
}
} }
void Win_GParted::clear_operationslist() void Win_GParted::clear_operationslist()
@ -825,6 +823,14 @@ void Win_GParted::radio_devices_changed( unsigned int item )
} }
} }
void Win_GParted::on_signal_show()
{
vpaned_main .set_position( vpaned_main .get_height() ) ;
close_operationslist() ;
menu_gparted_refresh_devices() ;
}
void Win_GParted::thread_refresh_devices() void Win_GParted::thread_refresh_devices()
{ {
gparted_core .get_devices( devices ) ; gparted_core .get_devices( devices ) ;