index b43395912141a34297eb2b3307a6b4e9749b62eb..13611caf7189bf438ca3006c66e34fe01370e2bb 100644 (file)
class FontLister
{
public:
- ~FontLister ();
+
+ enum Exceptions
+ {
+ FAMILY_NOT_FOUND
+ };
+
+
+ virtual ~FontLister ();
/** GtkTreeModelColumnRecord for the font list Gtk::ListStore
*/
public:
/** Column containing the family name
*/
- Gtk::TreeModelColumn<std::string> font;
+ Gtk::TreeModelColumn<Glib::ustring> font;
/** Column containing an std::vector<std::string> with style names
* for the corresponding family
}
};
+ /* Case-insensitive < compare for standard strings */
+ class StringLessThan
+ {
+ public:
+ bool operator () (std::string str1, std::string str2) const
+ {
+ std::string s1=str1; // Can't transform the originals!
+ std::string s2=str2;
+ std::transform(s1.begin(), s1.end(), s1.begin(), (int(*)(int)) toupper);
+ std::transform(s2.begin(), s2.end(), s2.begin(), (int(*)(int)) toupper);
+ return s1<s2;
+ }
+ };
+
FontListClass FontList;
- typedef std::map<std::string, Gtk::TreePath> IterMapType;
+ typedef std::map<Glib::ustring, Gtk::TreePath, StringLessThan> IterMapType;
/** Returns the ListStore with the font names
*
}
Gtk::TreePath
- get_row_for_font (std::string family)
+ get_row_for_font (Glib::ustring family)
{
IterMapType::iterator iter = font_list_store_iter_map.find (family);
+ if (iter == font_list_store_iter_map.end ()) throw FAMILY_NOT_FOUND;
return (*iter).second;
}