From: johanengelen Date: Sat, 24 Jan 2009 01:15:07 +0000 (+0000) Subject: sort combo enumerations X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=ed781c9fef4b808e68c478d37ab877785aed446b;p=inkscape.git sort combo enumerations --- diff --git a/src/ui/widget/combo-enums.h b/src/ui/widget/combo-enums.h index c418ea28b..917fa8d92 100644 --- a/src/ui/widget/combo-enums.h +++ b/src/ui/widget/combo-enums.h @@ -25,6 +25,15 @@ namespace Widget { template class ComboBoxEnum : public Gtk::ComboBox, public AttrWidget { +private: + int on_sort_compare( const Gtk::TreeModel::iterator & a, const Gtk::TreeModel::iterator & b) + { + Glib::ustring an=(*a)[_columns.label]; + Glib::ustring bn=(*b)[_columns.label]; + g_message("%s - %s", an.c_str(), bn.c_str()); + return an.compare(bn); + } + public: ComboBoxEnum(E default_value, const Util::EnumDataConverter& c, const SPAttributeEnum a = SP_ATTR_INVALID) : AttrWidget(a, (unsigned int)default_value), setProgrammatically(false), _converter(c) @@ -44,6 +53,10 @@ public: row[_columns.label] = _( _converter.get_label(data->id).c_str() ); } set_active_by_id(default_value); + + // Sort the list + _model->set_default_sort_func(sigc::mem_fun(*this, &ComboBoxEnum::on_sort_compare)); + _model->set_sort_column(_columns.label, Gtk::SORT_ASCENDING); } ComboBoxEnum(const Util::EnumDataConverter& c, const SPAttributeEnum a = SP_ATTR_INVALID) @@ -64,6 +77,10 @@ public: row[_columns.label] = _( _converter.get_label(data->id).c_str() ); } set_active(0); + + // Sort the list + _model->set_default_sort_func(sigc::mem_fun(*this, &ComboBoxEnum::on_sort_compare)); + _model->set_sort_column(_columns.label, Gtk::SORT_ASCENDING); } virtual Glib::ustring get_as_attribute() const