21#include <gtkmm/liststore.h>
25#define COLUMN_STRING 0
33 _activeUnitInitialized(false),
40 _store = Gtk::ListStore::create(columns);
41 Gtk::TreeModel::Row row;
43 for (
auto & m_iter : m) {
45 Glib::ustring unit = m_iter.first;
56 gint count =
_store->children().size();
57 if ((count > 0) && (
_active > count)) {
106 for (
auto& row:
_store->children() ) {
107 Glib::ustring storedUnit = row[columns.
col_value];
108 if (!unit->
abbr.compare (storedUnit)) {
121 for (
auto &row :
_store->children()) {
122 Glib::ustring storedUnit = row[columns.
col_label];
123 if (!
label.compare(storedUnit)) {
143 std::cerr <<
"UnitTracker::addAjustment: Adjustment already added!" << std::endl;
151 Gtk::TreeModel::Row row;
152 row = *(
_store->append());
164 Gtk::TreeModel::Row row;
165 row = *(
_store->prepend());
184 Glib::ustring
const &tooltip)
189 combo->set_name(
"unit-tracker");
190 combo->set_data(Glib::Quark(
"unit-tracker"),
this);
202 if (
data && where_the_object_was) {
215 g_warning(
"Received a finalization callback for unknown object %p", where_the_object_was);
231 Glib::ustring oldAbbr(
"NotFound" );
232 Glib::ustring newAbbr(
"NotFound" );
233 for (
auto& row:
_store->children() ) {
237 if (
index == active) {
240 if (newAbbr !=
"NotFound" && oldAbbr !=
"NotFound")
break;
244 if (oldAbbr !=
"NotFound") {
246 if (newAbbr !=
"NotFound") {
255 std::cerr <<
"UnitTracker::_setActive: Did not find new unit: " << active << std::endl;
259 std::cerr <<
"UnitTracker::_setActive: Did not find old unit: " << oldActive
260 <<
" new: " << active << std::endl;
266 if(combo) combo->set_active(active);
277 auto const oldVal = gtk_adjustment_get_value(adj);
283 val = newUnit->
factor * 100;
295 gtk_adjustment_set_value(adj, val);
static double convert(double from_dist, Unit const *from, Unit const *to)
Convert distances.
UnitMap units(UnitType type) const
Provides an iterable list of items in the given unit table.
Unit const * getUnit(Glib::ustring const &name) const
Retrieve a given unit based on its string identifier.
std::vector< ItemIterator > _active
@ UNIT_TYPE_DIMENSIONLESS
struct _GtkAdjustment GtkAdjustment