enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[ardour.git] / gtk2_ardour / luawindow.cc
index dfdba52db3f8c3d26aaa863a18f86e20b85dd74a..e8ab438a15d490704fdcaec1d00319cd089e2354 100644 (file)
@@ -34,6 +34,7 @@
 #include "pbd/md5.h"
 
 #include "gtkmm2ext/gtk_ui.h"
+#include "gtkmm2ext/pane.h"
 #include "gtkmm2ext/utils.h"
 #include "gtkmm2ext/window_title.h"
 
@@ -50,7 +51,7 @@
 #include "utils.h"
 #include "utils_videotl.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace ARDOUR;
 using namespace ARDOUR_UI_UTILS;
@@ -94,7 +95,7 @@ LuaWindow::LuaWindow ()
        , _menu_snippet (0)
        , _menu_actions (0)
        , _btn_run (_("Run"))
-       , _btn_clear (_("Clear Outtput"))
+       , _btn_clear (_("Clear Output"))
        , _btn_open (_("Import"))
        , _btn_save (_("Save"))
        , _btn_delete (_("Delete"))
@@ -155,9 +156,9 @@ LuaWindow::LuaWindow ()
        vbox->pack_start (*scrollin, true, true, 0);
        vbox->pack_start (*hbox, false, false, 2);
 
-       Gtk::VPaned *vpane = manage (new Gtk::VPaned ());
-       vpane->pack1 (*vbox, true, false);
-       vpane->pack2 (scrollout, false, true);
+       Gtkmm2ext::VPane *vpane = manage (new Gtkmm2ext::VPane ());
+       vpane->add (*vbox);
+       vpane->add (scrollout);
 
        vpane->show_all ();
        add (*vpane);
@@ -567,8 +568,16 @@ LuaWindow::rebuild_menu ()
                items_scratch.push_back(elem);
        }
 
+       items_scratch.push_back(SeparatorElem());
+
        for (ScriptBufferList::const_iterator i = script_buffers.begin (); i != script_buffers.end (); ++i) {
-               Menu_Helpers::MenuElem elem = Gtk::Menu_Helpers::MenuElem((*i)->name,
+               std::string name;
+               if ((*i)->flags & Buffer_ReadOnly) {
+                       name = "[R] " + (*i)->name;
+               } else {
+                       name = (*i)->name;
+               }
+               Menu_Helpers::MenuElem elem = Gtk::Menu_Helpers::MenuElem(name,
                                sigc::bind(sigc::mem_fun(*this, &LuaWindow::script_selection_changed), (*i), false));
 
                if ((*i)->flags & Buffer_Scratch) {
@@ -597,7 +606,7 @@ LuaWindow::script_selection_changed (ScriptBufferPtr n, bool force)
 
        Glib::RefPtr<Gtk::TextBuffer> tb (entry.get_buffer());
 
-       if ((n->flags & Buffer_Valid)) {
+       if (_current_buffer->flags & Buffer_Valid) {
                _current_buffer->script = tb->get_text();
        }
 
@@ -663,6 +672,7 @@ LuaWindow::ScriptBuffer::ScriptBuffer (const std::string& n)
        , flags (Buffer_Scratch | Buffer_Valid)
 {
        script =
+               "---- this header is (only) required to save the script\n"
                "-- ardour { [\"type\"] = \"Snippet\", name = \"\" }\n"
                "-- function factory () return function () -- -- end end\n";
 }
@@ -700,11 +710,12 @@ LuaWindow::ScriptBuffer::~ScriptBuffer ()
 bool
 LuaWindow::ScriptBuffer::load ()
 {
+       assert (!(flags & Buffer_Valid));
        if (!(flags & Buffer_HasFile)) return false;
-       if (flags & Buffer_Valid) return true;
        try {
                script = Glib::file_get_contents (path);
                flags |= Buffer_Valid;
+               flags &= BufferFlags(~Buffer_Dirty);
        } catch (Glib::FileError e) {
                return false;
        }