/***********************************************************************************

    Copyright (C) 2007-2026 Ahmet Öztürk (aoz_2@yahoo.com)

    This file is part of Lifeograph.

    Lifeograph is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Lifeograph is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Lifeograph.  If not, see <http://www.gnu.org/licenses/>.

***********************************************************************************/


#ifndef LIFEOGRAPH_DIALOG_SCRIPT_PROMPT_HEADER
#define LIFEOGRAPH_DIALOG_SCRIPT_PROMPT_HEADER


#include <pybind11/embed.h>
#include <gtkmm.h>

#include "../helpers_gtk.hpp"

namespace py = pybind11;

namespace LoG
{

using namespace HELPERS;

class __attribute__((visibility("hidden"))) DialogScriptPrompt : public Gtk::Window
{
    public:
        enum class FieldType
        {
            CHECK, OPTION, TEXT, DATE, FILE, FOLDER, TAG, FILTER, HIDDEN
        };

        using DropDownPyObj = DropDownAdvanced< py::object >;

        struct __attribute__((visibility("hidden"))) Option
        {
            String label;
            py::object id;
        };

        using VecOptions = std::vector< Option >;

        struct InputCtrlInfo
        {
            FieldType     type;
            String        name;
            Gtk::Widget*  W_ctrl;
        };

        using VecControls = std::vector< InputCtrlInfo >;

        using MapPyObjects = std::map< String, py::object >;

        static void                 show( const String&, const String&, const String&,
                                          const py::list& );

        void                        populate_controls( const py::list& );
        void                        add_control( FieldType, const String&, VecOptions&& );

                                    DialogScriptPrompt( BaseObjectType*,
                                                        const Glib::RefPtr< Gtk::Builder >& );

    protected:
        bool                        on_key_press_event( guint, guint, Gdk::ModifierType );

        void                        handle_apply();

        static DialogScriptPrompt*  ptr;
        Gtk::Label*                 m_L_script_name;
        Gtk::Label*                 m_L_info;
        Gtk::Grid*                  m_G_controls;

        int                         m_row_last { 0 };

        VecControls                 m_fields;
        MapPyObjects                m_hidden_options;

        String                      m_script_name;
        String                      m_callback_name;
};

} // end of namespace LoG

#endif

