Code

Swedish translation update by Elias.
[inkscape.git] / src / libnrtype / font-lister.h
index fb0810254e4617cd08bc5c25ebd297971620257a..13611caf7189bf438ca3006c66e34fe01370e2bb 100644 (file)
@@ -35,7 +35,7 @@ namespace Inkscape
                         };
 
 
-                        ~FontLister ();
+                        virtual ~FontLister ();
 
                         /** GtkTreeModelColumnRecord for the font list Gtk::ListStore
                          */
@@ -45,7 +45,7 @@ namespace Inkscape
                             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 
@@ -59,8 +59,22 @@ namespace Inkscape
                                 }
                         };
 
+                        /* 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
                          *
@@ -79,7 +93,7 @@ namespace Inkscape
                         }
 
                         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;