From 1bbcf787b1eda125320bb6a5163140987ba067f2 Mon Sep 17 00:00:00 2001 From: Bart Hakvoort Date: Sun, 27 Nov 2005 19:48:00 +0000 Subject: [PATCH] Added a menu 'Edit' which contains 'Undo' and 'Apply'. (#322550) * include/Win_GParted.h, src/Win_GParted.cc: Added a menu 'Edit' which contains 'Undo' and 'Apply'. (#322550) --- ChangeLog | 5 +++++ include/Win_GParted.h | 50 +++++++++++++++++++++++++++++++++---------- src/Win_GParted.cc | 16 +++++++++----- 3 files changed, 55 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index b971269a..bc4783fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-11-27 Bart Hakvoort + * include/Win_GParted.h, + src/Win_GParted.cc: Added a menu 'Edit' which contains 'Undo' and + 'Apply'. (#322550) + 2005-11-27 Bart Hakvoort * configure.in: raised dependencies to >=gtkmm-2.6 and >=parted-1.6.25 diff --git a/include/Win_GParted.h b/include/Win_GParted.h index f1f77b71..eb57e124 100644 --- a/include/Win_GParted.h +++ b/include/Win_GParted.h @@ -77,18 +77,46 @@ private: void Set_Valid_Convert_Filesystems( ) ; //determines to which filesystems a partition can be converted //convenience functions - void allow_new( bool b ) { menu_partition .items( )[ 0 ] .set_sensitive( b ); toolbar_main .get_nth_item( 0 ) ->set_sensitive( b ); } - void allow_delete( bool b ) { menu_partition .items( )[ 1 ] .set_sensitive( b ); toolbar_main .get_nth_item( 1 ) ->set_sensitive( b ); } - void allow_resize( bool b ) { menu_partition .items( )[ 3 ] .set_sensitive( b ); toolbar_main .get_nth_item( 3 ) ->set_sensitive( b ); } - void allow_copy( bool b ) { menu_partition .items( )[ 5 ] .set_sensitive( b ); toolbar_main .get_nth_item( 5 ) ->set_sensitive( b ); } - void allow_paste( bool b ) { menu_partition .items( )[ 6 ] .set_sensitive( b ); toolbar_main .get_nth_item( 6 ) ->set_sensitive( b ); } - void allow_convert( bool b ) { menu_partition .items( )[ 8 ] .set_sensitive( b ); } - void allow_unmount( bool b ) { menu_partition .items( )[ 10 ] .set_sensitive( b ); } - void allow_info( bool b ) { menu_partition .items( )[ 12 ] .set_sensitive( b ); } - void allow_undo( bool b ) { toolbar_main .get_nth_item( 8 ) ->set_sensitive( b ); } - void allow_apply( bool b ) { toolbar_main .get_nth_item( 9 ) ->set_sensitive( b ); } + void allow_new( bool b ) { + menu_partition .items( )[ 0 ] .set_sensitive( b ); + toolbar_main .get_nth_item( 0 ) ->set_sensitive( b ); } - void find_devices_thread( ) { gparted_core .get_devices( devices ) ; pulse = false ; } + void allow_delete( bool b ) { + menu_partition .items( )[ 1 ] .set_sensitive( b ); + toolbar_main .get_nth_item( 1 ) ->set_sensitive( b ); } + + void allow_resize( bool b ) { + menu_partition .items( )[ 3 ] .set_sensitive( b ); + toolbar_main .get_nth_item( 3 ) ->set_sensitive( b ); } + + void allow_copy( bool b ) { + menu_partition .items( )[ 5 ] .set_sensitive( b ); + toolbar_main .get_nth_item( 5 ) ->set_sensitive( b ); } + + void allow_paste( bool b ) { + menu_partition .items( )[ 6 ] .set_sensitive( b ); + toolbar_main .get_nth_item( 6 ) ->set_sensitive( b ); } + + void allow_convert( bool b ) { + menu_partition .items( )[ 8 ] .set_sensitive( b ); } + + void allow_unmount( bool b ) { + menu_partition .items( )[ 10 ] .set_sensitive( b ); } + + void allow_info( bool b ) { + menu_partition .items( )[ 12 ] .set_sensitive( b ); } + + void allow_undo( bool b ) { + toolbar_main .get_nth_item( 8 ) ->set_sensitive( b ); + ( (Gtk::CheckMenuItem *) & menubar_main .items( ) [ 1 ] .get_submenu( ) ->items( ) [ 0 ] ) ->set_sensitive( b ) ; } + + void allow_apply( bool b ) { + toolbar_main .get_nth_item( 9 ) ->set_sensitive( b ); + ( (Gtk::CheckMenuItem *) & menubar_main .items( ) [ 1 ] .get_submenu( ) ->items( ) [ 1 ] ) ->set_sensitive( b ) ; } + + void find_devices_thread( ) { + gparted_core .get_devices( devices ) ; + pulse = false ; } //signal handlers void open_operationslist( ) ; diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc index a179ffd1..f0a01541 100644 --- a/src/Win_GParted.cc +++ b/src/Win_GParted.cc @@ -96,6 +96,12 @@ void Win_GParted::init_menubar( ) menu ->items( ) .push_back( Gtk::Menu_Helpers::StockMenuElem( Gtk::Stock::QUIT, sigc::mem_fun(*this, &Win_GParted::menu_gparted_quit) ) ); menubar_main .items( ) .push_back( Gtk::Menu_Helpers::MenuElem( _("_GParted"), *menu ) ); + //edit + menu = manage( new Gtk::Menu( ) ) ; + menu ->items( ) .push_back( Gtk::Menu_Helpers::StockMenuElem( Gtk::Stock::UNDO, Gtk::AccelKey("z"), sigc::mem_fun(*this, &Win_GParted::activate_undo) ) ); + menu ->items( ) .push_back( Gtk::Menu_Helpers::StockMenuElem( Gtk::Stock::APPLY, sigc::mem_fun(*this, &Win_GParted::activate_apply) ) ); + menubar_main .items( ) .push_back( Gtk::Menu_Helpers::MenuElem( _("_Edit"), *menu ) ); + //view menu = manage( new Gtk::Menu( ) ) ; menu ->items( ) .push_back( Gtk::Menu_Helpers::CheckMenuElem( _("Harddisk Information"), sigc::mem_fun(*this, &Win_GParted::menu_view_harddisk_info) ) ); @@ -653,8 +659,8 @@ void Win_GParted::open_operationslist( ) while ( Gtk::Main::events_pending( ) ) Gtk::Main::iteration( ); } - - ( (Gtk::CheckMenuItem *) & menubar_main .items( ) [ 1 ] .get_submenu( ) ->items( ) [ 1 ] ) ->set_active( true ) ; + + ( (Gtk::CheckMenuItem *) & menubar_main .items( ) [ 2 ] .get_submenu( ) ->items( ) [ 1 ] ) ->set_active( true ) ; } void Win_GParted::close_operationslist( ) @@ -669,7 +675,7 @@ void Win_GParted::close_operationslist( ) } hbox_operations .hide( ) ; - ( (Gtk::CheckMenuItem *) & menubar_main .items( ) [ 1 ] .get_submenu( ) ->items() [ 1 ] ) ->set_active( false ) ; + ( (Gtk::CheckMenuItem *) & menubar_main .items( ) [ 2 ] .get_submenu( ) ->items() [ 1 ] ) ->set_active( false ) ; } void Win_GParted::clear_operationslist( ) @@ -796,7 +802,7 @@ void Win_GParted::menu_gparted_quit( ) void Win_GParted::menu_view_harddisk_info( ) { - if ( ( (Gtk::CheckMenuItem *) & menubar_main .items( ) [ 1 ] .get_submenu( ) ->items( ) [ 0 ] ) ->get_active( ) ) + if ( ( (Gtk::CheckMenuItem *) & menubar_main .items( ) [ 2 ] .get_submenu( ) ->items( ) [ 0 ] ) ->get_active( ) ) { //open harddisk information hpaned_main .get_child1( ) ->show( ) ; for ( int t = hpaned_main .get_position( ) ; t < 250 ; t +=15 ) @@ -820,7 +826,7 @@ void Win_GParted::menu_view_harddisk_info( ) void Win_GParted::menu_view_operations( ) { - if ( ( (Gtk::CheckMenuItem *) & menubar_main .items( ) [ 1 ] .get_submenu( ) ->items( ) [ 1 ] ) ->get_active( ) ) + if ( ( (Gtk::CheckMenuItem *) & menubar_main .items( ) [ 2 ] .get_submenu( ) ->items( ) [ 1 ] ) ->get_active( ) ) open_operationslist( ) ; else close_operationslist( ) ;