#include "gtkmm2ext/utils.h"
#include "gtkmm2ext/window_title.h"
+#include "widgets/pane.h"
+#include "widgets/tooltips.h"
+
#include "ardour/filesystem_paths.h"
#include "ardour/luabindings.h"
#include "LuaBridge/LuaBridge.h"
#include "luainstance.h"
#include "luawindow.h"
#include "public_editor.h"
-#include "tooltips.h"
#include "utils.h"
#include "utils_videotl.h"
-#include "i18n.h"
+#include "pbd/i18n.h"
using namespace ARDOUR;
-using namespace ARDOUR_UI_UTILS;
using namespace PBD;
using namespace Gtk;
using namespace Glib;
, _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"))
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);
+ ArdourWidgets::VPane *vpane = manage (new ArdourWidgets::VPane ());
+ vpane->add (*vbox);
+ vpane->add (scrollout);
+ vpane->set_divider (0, 0.75);
vpane->show_all ();
add (*vpane);
set_size_request (640, 480); // XXX
- ARDOUR_UI_UTILS::set_tooltip (script_select, _("Select Editor Buffer"));
+ ArdourWidgets::set_tooltip (script_select, _("Select Editor Buffer"));
setup_buffers ();
LuaScripting::instance().scripts_changed.connect (*this, invalidator (*this), boost::bind (&LuaWindow::refresh_scriptlist, this), gui_context());
{
if (!_visible) return 0;
_visible = false;
- return just_hide_it (ev, static_cast<Gtk::Window *>(this));
+ return ARDOUR_UI_UTILS::just_hide_it (ev, static_cast<Gtk::Window *>(this));
}
void LuaWindow::reinit_lua ()
delete lua;
lua = new LuaState();
lua->Print.connect (sigc::mem_fun (*this, &LuaWindow::append_text));
+ lua->sandbox (false);
lua_State* L = lua->getState();
LuaInstance::register_classes (L);
}
} catch (luabridge::LuaException const& e) {
append_text (string_compose (_("LuaException: %1"), e.what()));
+ } catch (Glib::Exception const& e) {
+ append_text (string_compose (_("Glib Exception: %1"), e.what()));
+ } catch (std::exception const& e) {
+ append_text (string_compose (_("C++ Exception: %1"), e.what()));
+ } catch (...) {
+ append_text (string_compose (_("C++ Exception: %1"), "..."));
}
} else {
// script with factory method
lua->do_command ("factory = nil;");
} catch (luabridge::LuaException const& e) {
append_text (string_compose (_("LuaException: %1"), e.what()));
+ } catch (Glib::Exception const& e) {
+ append_text (string_compose (_("Glib Exception: %1"), e.what()));
+ } catch (std::exception const& e) {
+ append_text (string_compose (_("C++ Exception: %1"), e.what()));
+ } catch (...) {
+ append_text (string_compose (_("C++ Exception: %1"), "..."));
}
}
}
Glib::RefPtr<Gtk::TextBuffer> tb (outtext.get_buffer());
tb->insert (tb->end(), s + "\n");
scroll_to_bottom ();
+ Gtkmm2ext::UI::instance()->flush_pending (0.05);
}
void
tb->set_text ("");
}
+void
+LuaWindow::edit_script (const std::string& name, const std::string& script)
+{
+ ScriptBuffer* sb = new LuaWindow::ScriptBuffer (name);
+ sb->script = script;
+ script_buffers.push_back (ScriptBufferPtr (sb));
+ script_selection_changed (script_buffers.back ());
+ refresh_scriptlist ();
+ show_window ();
+}
+
void
LuaWindow::new_script ()
{
// TODO convert a few URL (eg. pastebin) to raw.
#if 0
char *url = "http://pastebin.com/raw/3UMkZ6nV";
- char *rv = a3_curl_http_get (url, 0);
+ char *rv = ArdourCurl::http_get (url, 0);
if (rv) {
new_script ();
Glib::RefPtr<Gtk::TextBuffer> tb (entry.get_buffer());
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) {
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();
}
, 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";
}
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;
}