| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- #include <string>
- #include <gtkmm/grid.h>
- #include <gtkmm/entry.h>
- #include <gtkmm/label.h>
- #include <gtkmm/button.h>
- #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 = "<b>Edit \"";
- description_text += target->get_name();
- description_text += "\" light.</b>";
- 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;
- }
- }
|