X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fluadialog.cc;h=04040c820162bc9499e17edcf06fdd6de9d01c2d;hb=8eb3b9d34b862822fbc670458a247bc74c975289;hp=22fcee6cdaa865272939a151b9158de703eb494e;hpb=35aa4f692a60394fe2756be44661a411e80c7f69;p=ardour.git diff --git a/gtk2_ardour/luadialog.cc b/gtk2_ardour/luadialog.cc index 22fcee6cda..04040c8201 100644 --- a/gtk2_ardour/luadialog.cc +++ b/gtk2_ardour/luadialog.cc @@ -21,11 +21,12 @@ #include "ardour/dB.h" #include "ardour/rc_configuration.h" -#include "gtkmm2ext/slider_controller.h" #include "gtkmm2ext/utils.h" +#include "widgets/ardour_dropdown.h" +#include "widgets/slider_controller.h" + #include "ardour_dialog.h" -#include "ardour_dropdown.h" #include "luadialog.h" #include "utils.h" @@ -177,7 +178,7 @@ public: : LuaDialogWidget (key, title) , _db_adjustment (ARDOUR::gain_to_slider_position_with_max (1.0, ARDOUR::Config->get_max_gain ()), 0, 1, 0.01, 0.1) { - _db_slider = Gtk::manage (new Gtkmm2ext::HSliderController (&_db_adjustment, boost::shared_ptr (), 220, 18)); + _db_slider = Gtk::manage (new ArdourWidgets::HSliderController (&_db_adjustment, boost::shared_ptr (), 220, 18)); _fader_centering_box.pack_start (*_db_slider, true, false); @@ -238,7 +239,7 @@ protected: } Gtk::Adjustment _db_adjustment; - Gtkmm2ext::HSliderController* _db_slider; + ArdourWidgets::HSliderController* _db_slider; Gtk::Entry _db_display; Gtk::HBox _box; Gtk::VBox _fader_centering_box; @@ -431,11 +432,52 @@ protected: _rv = rv; } - ArdourDropdown _dd; + ArdourWidgets::ArdourDropdown _dd; std::vector _refs; luabridge::LuaRef* _rv; }; +class LuaFileChooser : public LuaDialogWidget +{ +public: + LuaFileChooser (std::string const& key, std::string const& title, Gtk::FileChooserAction a, const std::string& path) + : LuaDialogWidget (key, title) + , _fc (a) + { + if (!path.empty ()) { + switch (a) { + case Gtk::FILE_CHOOSER_ACTION_OPEN: + case Gtk::FILE_CHOOSER_ACTION_SAVE: + if (Glib::file_test (path, Glib::FILE_TEST_IS_REGULAR|Glib::FILE_TEST_EXISTS)) { + _fc.set_filename (path); + } + break; + case Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER: + if (Glib::file_test (path, Glib::FILE_TEST_IS_DIR|Glib::FILE_TEST_EXISTS)) { + _fc.set_filename (path); + } + break; + case Gtk::FILE_CHOOSER_ACTION_CREATE_FOLDER: + break; + } + } + } + + Gtk::Widget* widget () + { + return &_fc; + } + + void assign (luabridge::LuaRef* rv) const + { + (*rv)[_key] = std::string (_fc.get_filename ()); + } + +protected: + Gtk::FileChooserButton _fc; +}; + + /******************************************************************************* * Lua Parameter Dialog @@ -546,6 +588,18 @@ Dialog::Dialog (std::string const& title, luabridge::LuaRef lr) dflt = i.value ()["default"].cast (); } _widgets.push_back (new LuaDialogDropDown (key, title, i.value ()["values"], dflt)); + } else if (type == "file") { + std::string path; + if (i.value ()["path"].isString ()) { + path = i.value ()["path"].cast (); + } + _widgets.push_back (new LuaFileChooser (key, title, Gtk::FILE_CHOOSER_ACTION_OPEN, path)); + } else if (type == "folder") { + std::string path; + if (i.value ()["path"].isString ()) { + path = i.value ()["path"].cast (); + } + _widgets.push_back (new LuaFileChooser (key, title, Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER, path)); } } @@ -589,7 +643,7 @@ Dialog::run (lua_State *L) case Gtk::RESPONSE_ACCEPT: break; default: - lua_pushnil (L); + lua_pushnil (L); return 1; }