diff libgui/src/m-editor/file-editor.cc @ 18767:095fdef3d67c gui-release

use editors run selection action for the context menu * file-editor-tab.cc (constructor): initialize flag for octave file; (update_lexer): set flag for octave file; (set_file_name, handle_copy_available, change_editor_state): editor_state_changed signal uses flag for octave file; * file-editor-tab.h: flag for octave file, also used in editor_state_changed * file-editor.cc (create_context_menu): add action for running selection; (handle_editor_state_changed): gets flag whether file is an octave script, enable run action and run selection action depending on selection and file type; (add_file_editor_tab): connect editor_state_changed to handle_editor_state_changedwith new third parameter; * file-editor.h: handle_editor_state_changed has a new third parameter * octave-qscintilla.cc (contextMenuEvent): run selection is added by the edtior
author Torsten <ttl@justmail.de>
date Fri, 16 May 2014 20:01:27 +0200
parents 64bd9afac22c
children b2c4d6d461f0
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor.cc	Thu May 15 08:37:02 2014 -0700
+++ b/libgui/src/m-editor/file-editor.cc	Fri May 16 20:01:27 2014 +0200
@@ -965,6 +965,8 @@
   menu->addAction (_paste_action);
   menu->addSeparator ();
   menu->addAction (_selectall_action);
+  menu->addSeparator ();
+  menu->addAction (_run_selection_action);
 }
 
 void
@@ -994,7 +996,8 @@
 
 void
 file_editor::handle_editor_state_changed (bool copy_available,
-                                          const QString& file_name)
+                                          const QString& file_name,
+                                          bool is_octave_file)
 {
   // In case there is some scenario where traffic could be coming from
   // all the file editor tabs, just process info from the current active tab.
@@ -1002,7 +1005,8 @@
     {
       _copy_action->setEnabled (copy_available);
       _cut_action->setEnabled (copy_available);
-      _run_selection_action->setEnabled (copy_available);
+      _run_selection_action->setEnabled (copy_available && is_octave_file);
+      _run_action->setEnabled (is_octave_file);
 
       if (!file_name.isEmpty ())
         {
@@ -1410,8 +1414,8 @@
            this, SLOT (handle_file_name_changed (const QString&,
                                                  const QString&)));
 
-  connect (f, SIGNAL (editor_state_changed (bool, const QString&)),
-           this, SLOT (handle_editor_state_changed (bool, const QString&)));
+  connect (f, SIGNAL (editor_state_changed (bool, const QString&, bool)),
+           this, SLOT (handle_editor_state_changed (bool, const QString&, bool)));
 
   connect (f, SIGNAL (tab_remove_request ()),
            this, SLOT (handle_tab_remove_request ()));