@ -33,7 +33,7 @@ void Window::generate_keybindings() {
}
Window : : Window ( ) : box ( Gtk : : ORIENTATION_VERTICAL ) , notebook ( directories ) , compiling ( false ) {
INFO ( " Create Window " ) ;
DEBUG ( " start " ) ;
set_title ( " juCi++ " ) ;
set_default_size ( 600 , 400 ) ;
set_events ( Gdk : : POINTER_MOTION_MASK | Gdk : : FOCUS_CHANGE_MASK | Gdk : : SCROLL_MASK ) ;
@ -104,9 +104,9 @@ Window::Window() : box(Gtk::ORIENTATION_VERTICAL), notebook(directories), compil
directories . select ( notebook . get_current_view ( ) - > file_path ) ;
if ( auto source_view = dynamic_cast < Source : : ClangView * > ( notebook . get_current_view ( ) ) ) {
if ( source_view - > start_ reparse_needed) {
if ( source_view - > reparse_needed ) {
source_view - > start_reparse ( ) ;
source_view - > start_ reparse_needed= false ;
source_view - > reparse_needed = false ;
}
}
@ -132,11 +132,10 @@ Window::Window() : box(Gtk::ORIENTATION_VERTICAL), notebook(directories), compil
about . set_comments ( " This is an open source IDE with high-end features to make your programming experience juicy " ) ;
about . set_license_type ( Gtk : : License : : LICENSE_MIT_X11 ) ;
about . set_transient_for ( * this ) ;
INFO ( " Window create d" ) ;
DEBUG ( " en d" ) ;
} // Window constructor
void Window : : create_menu ( ) {
INFO ( " Adding actions to menu " ) ;
menu . action_group - > add ( Gtk : : Action : : create ( " FileQuit " , " Quit juCi++ " ) , Gtk : : AccelKey ( menu . key_map [ " quit " ] ) , [ this ] ( ) {
hide ( ) ;
} ) ;
@ -189,7 +188,6 @@ void Window::create_menu() {
search_and_replace_entry ( ) ;
} ) ;
menu . action_group - > add ( Gtk : : Action : : create ( " EditUndo " , " Undo " ) , Gtk : : AccelKey ( menu . key_map [ " edit_undo " ] ) , [ this ] ( ) {
INFO ( " On undo " ) ;
if ( notebook . get_current_page ( ) ! = - 1 ) {
auto undo_manager = notebook . get_current_view ( ) - > get_source_buffer ( ) - > get_undo_manager ( ) ;
if ( undo_manager - > can_undo ( ) ) {
@ -197,10 +195,8 @@ void Window::create_menu() {
notebook . get_current_view ( ) - > scroll_to ( notebook . get_current_view ( ) - > get_buffer ( ) - > get_insert ( ) ) ;
}
}
INFO ( " Done undo " ) ;
} ) ;
menu . action_group - > add ( Gtk : : Action : : create ( " EditRedo " , " Redo " ) , Gtk : : AccelKey ( menu . key_map [ " edit_redo " ] ) , [ this ] ( ) {
INFO ( " On Redo " ) ;
if ( notebook . get_current_page ( ) ! = - 1 ) {
auto undo_manager = notebook . get_current_view ( ) - > get_source_buffer ( ) - > get_undo_manager ( ) ;
if ( undo_manager - > can_redo ( ) ) {
@ -208,7 +204,6 @@ void Window::create_menu() {
notebook . get_current_view ( ) - > scroll_to ( notebook . get_current_view ( ) - > get_buffer ( ) - > get_insert ( ) ) ;
}
}
INFO ( " Done Redo " ) ;
} ) ;
menu . action_group - > add ( Gtk : : Action : : create ( " SourceGotoLine " , " Go to Line " ) , Gtk : : AccelKey ( menu . key_map [ " source_goto_line " ] ) , [ this ] ( ) {
@ -218,7 +213,8 @@ void Window::create_menu() {
if ( notebook . get_current_page ( ) ! = - 1 ) {
while ( gtk_events_pending ( ) )
gtk_main_iteration ( ) ;
notebook . get_current_view ( ) - > scroll_to ( notebook . get_current_view ( ) - > get_buffer ( ) - > get_insert ( ) , 0.0 , 1.0 , 0.5 ) ;
if ( notebook . get_current_page ( ) ! = - 1 )
notebook . get_current_view ( ) - > scroll_to ( notebook . get_current_view ( ) - > get_buffer ( ) - > get_insert ( ) , 0.0 , 1.0 , 0.5 ) ;
}
} ) ;
menu . action_group - > add ( Gtk : : Action : : create ( " SourceGotoDeclaration " , " Go to Declaration " ) , Gtk : : AccelKey ( menu . key_map [ " source_goto_declaration " ] ) , [ this ] ( ) {
@ -230,7 +226,8 @@ void Window::create_menu() {
notebook . get_current_view ( ) - > get_buffer ( ) - > place_cursor ( notebook . get_current_view ( ) - > get_buffer ( ) - > get_iter_at_line_index ( location . second . line - 1 , location . second . index - 1 ) ) ;
while ( gtk_events_pending ( ) )
gtk_main_iteration ( ) ;
notebook . get_current_view ( ) - > scroll_to ( notebook . get_current_view ( ) - > get_buffer ( ) - > get_insert ( ) , 0.0 , 1.0 , 0.5 ) ;
if ( notebook . get_current_page ( ) ! = - 1 )
notebook . get_current_view ( ) - > scroll_to ( notebook . get_current_view ( ) - > get_buffer ( ) - > get_insert ( ) , 0.0 , 1.0 , 0.5 ) ;
}
}
}
@ -325,6 +322,10 @@ void Window::create_menu() {
} ) ;
menu . action_group - > add ( Gtk : : Action : : create ( " WindowCloseTab " , " Close Tab " ) , Gtk : : AccelKey ( menu . key_map [ " close_tab " ] ) , [ this ] ( ) {
notebook . close_current_page ( ) ;
if ( notebook . get_current_page ( ) ! = - 1 )
Singleton : : status ( ) - > set_text ( notebook . get_current_view ( ) - > status ) ;
else
Singleton : : status ( ) - > set_text ( " " ) ;
} ) ;
menu . action_group - > add ( Gtk : : Action : : create ( " HelpAbout " , " About " ) , [ this ] ( ) {
about . show ( ) ;
@ -332,7 +333,6 @@ void Window::create_menu() {
} ) ;
add_accel_group ( menu . ui_manager - > get_accel_group ( ) ) ;
menu . build ( ) ;
INFO ( " Menu build " )
}
bool Window : : on_key_press_event ( GdkEventKey * event ) {
@ -526,7 +526,6 @@ void Window::open_file_dialog() {
void Window : : save_file_dialog ( ) {
if ( notebook . get_current_page ( ) = = - 1 )
return ;
INFO ( " Save file dialog " ) ;
Gtk : : FileChooserDialog dialog ( * this , " Please choose a file " , Gtk : : FILE_CHOOSER_ACTION_SAVE ) ;
gtk_file_chooser_set_filename ( ( GtkFileChooser * ) dialog . gobj ( ) , notebook . get_current_view ( ) - > file_path . string ( ) . c_str ( ) ) ;
dialog . set_position ( Gtk : : WindowPosition : : WIN_POS_CENTER_ALWAYS ) ;
@ -652,7 +651,8 @@ void Window::goto_line_entry() {
buffer - > place_cursor ( buffer - > get_iter_at_line ( line ) ) ;
while ( gtk_events_pending ( ) )
gtk_main_iteration ( ) ;
notebook . get_current_view ( ) - > scroll_to ( buffer - > get_insert ( ) , 0.0 , 1.0 , 0.5 ) ;
if ( notebook . get_current_page ( ) ! = - 1 )
notebook . get_current_view ( ) - > scroll_to ( buffer - > get_insert ( ) , 0.0 , 1.0 , 0.5 ) ;
}
}
catch ( const std : : exception & e ) { }
@ -688,10 +688,11 @@ void Window::rename_token_entry() {
entry_box . entries . emplace_back ( * token_name , [ this , token_name , token ] ( const std : : string & content ) {
if ( notebook . get_current_page ( ) ! = - 1 & & content ! = * token_name ) {
for ( int c = 0 ; c < notebook . size ( ) ; c + + ) {
if ( notebook . get_view ( c ) - > rename_similar_tokens ) {
auto number = notebook . get_view ( c ) - > rename_similar_tokens ( * token , content ) ;
auto view = notebook . get_view ( c ) ;
if ( view - > rename_similar_tokens ) {
auto number = view - > rename_similar_tokens ( * token , content ) ;
if ( number > 0 ) {
Singleton : : terminal ( ) - > print ( " Replaced " + boost : : lexical_cast < std : : string > ( number ) + " occurrences in file " + notebook . get_ view( c ) - > file_path . string ( ) + " \n " ) ;
Singleton : : terminal ( ) - > print ( " Replaced " + boost : : lexical_cast < std : : string > ( number ) + " occurrences in file " + view - > file_path . string ( ) + " \n " ) ;
notebook . save ( c ) ;
}
}