#include #include #include #include #include #include "editor.hpp" #include "light.hpp" #include "config.hpp" namespace cx_light { editor::editor(light *target) { this->target = target->copy(); this->set_row_spacing(DEFAULT_MARGIN); this->set_column_spacing(DEFAULT_MARGIN); std::string description_text = "Edit \""; description_text += target->get_name(); description_text += "\" light."; this->description = new Gtk::Label(description_text); this->description->set_use_markup(); this->description->set_hexpand(); this->description->set_halign(Gtk::Align::START); this->attach(*this->description, 0, 0, 4, 1); this->title_label = new Gtk::Label("Title"); this->title_label->set_halign(Gtk::Align::START); this->attach(*this->title_label, 0, 1, 1, 1); this->title = new Gtk::Entry(); this->attach(*this->title, 1, 1, 3, 1); this->address_label = new Gtk::Label("Address"); this->address_label->set_halign(Gtk::Align::START); this->attach(*this->address_label, 0, 2, 1, 1); this->address = new Gtk::Entry(); this->attach(*this->address, 1, 2, 3, 1); this->back = new Gtk::Button("Back"); this->attach(*this->back, 0, 3, 2, 1); this->save = new Gtk::Button("Save"); this->attach(*this->save, 2, 3, 2, 1); } editor::~editor() { this->remove(*this->save); this->remove(*this->back); this->remove(*this->title); this->remove(*this->address); this->remove(*this->description); this->remove(*this->title_label); this->remove(*this->address_label); delete this->target; delete this->save; delete this->back; delete this->title; delete this->address; delete this->description; delete this->title_label; delete this->address_label; } std::string editor::get_title() { std::string current = this->title->get_buffer()->get_text(); if (current.empty()) { return this->target->get_name(); } return current; } std::string editor::get_address() { std::string current = this->address->get_buffer()->get_text(); if (current.empty()) { return this->target->get_address(); } return current; } }