diff libgui/src/m-editor/file-editor.cc @ 29439:fe06fafb4cac

fix en-/disabling some editor actions depending on file type (bug #60214) * file-editor-tab.cc (handle_request_add_breakpoint): just return if the file is not an octave file * file-editor.cc (check_actions): en-/disable the run action and debug actions depending on tabs and file type, emit signal of changed tabs also with flag if octave file or not; (handle_editor_state_changed): store if current file is an octave file, emit signal with possibly changed file type; * file-editor.h: signal editor_tabs_changed_signal with two args, new flag m_is_octave_file * main-window.cc (handle_exit_debugger): en/-disable step action depending on editor tabs and file type; (construct): slot editor_tabs_changed has two args now; (editor_tabs_changed): two args, store editor file type in flag and en-/disable step action accordingly * main-window.h: slot editor_tabs_changed with two args, new flag m_editor_is_octave_file
author Torsten Lilge <ttl-octave@mailbox.org>
date Sun, 14 Mar 2021 22:45:42 +0100
parents 34097a2f1f60
children 0e9319d40977
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor.cc	Sat Mar 13 10:56:43 2021 +0100
+++ b/libgui/src/m-editor/file-editor.cc	Sun Mar 14 22:45:42 2021 +0100
@@ -206,6 +206,7 @@
 
   void file_editor::check_actions (void)
   {
+    // Do not include shared actions not only related to the editor
     bool have_tabs = m_tab_widget->count () > 0;
 
     m_edit_cmd_menu->setEnabled (have_tabs);
@@ -231,7 +232,13 @@
     m_find_next_action->setEnabled (have_tabs);
     m_find_previous_action->setEnabled (have_tabs);
     m_print_action->setEnabled (have_tabs);
-    m_run_action->setEnabled (have_tabs);
+
+    m_run_action->setEnabled (have_tabs && m_is_octave_file);
+
+    m_toggle_breakpoint_action->setEnabled (have_tabs && m_is_octave_file);
+    m_next_breakpoint_action->setEnabled (have_tabs && m_is_octave_file);
+    m_previous_breakpoint_action->setEnabled (have_tabs && m_is_octave_file);
+    m_remove_all_breakpoints_action->setEnabled (have_tabs && m_is_octave_file);
 
     m_edit_function_action->setEnabled (have_tabs);
     m_save_action->setEnabled (have_tabs);
@@ -241,7 +248,7 @@
     m_close_others_action->setEnabled (have_tabs && m_tab_widget->count () > 1);
     m_sort_tabs_action->setEnabled (have_tabs && m_tab_widget->count () > 1);
 
-    emit editor_tabs_changed_signal (have_tabs);
+    emit editor_tabs_changed_signal (have_tabs, m_is_octave_file);
   }
 
   // empty_script determines whether we have to create an empty script
@@ -985,8 +992,12 @@
         if (m_copy_action)
           m_copy_action->setEnabled (copy_available);
         m_cut_action->setEnabled (copy_available);
+
         m_run_selection_action->setEnabled (copy_available);
         m_run_action->setEnabled (is_octave_file);
+        m_is_octave_file = is_octave_file;
+
+        emit editor_tabs_changed_signal (true, m_is_octave_file);
       }
 
     m_copy_action_enabled = m_copy_action->isEnabled ();