Code

patch from bug 169004
authorbuliabyak <buliabyak@users.sourceforge.net>
Mon, 11 Aug 2008 00:14:32 +0000 (00:14 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Mon, 11 Aug 2008 00:14:32 +0000 (00:14 +0000)
src/libnrtype/font-lister.h
src/widgets/toolbox.cpp

index b2d2a3ecf5a48023e188803ff8f01538232dd2e1..13611caf7189bf438ca3006c66e34fe01370e2bb 100644 (file)
@@ -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<Glib::ustring, Gtk::TreePath> IterMapType; 
+                        typedef std::map<Glib::ustring, Gtk::TreePath, StringLessThan> IterMapType; 
 
                         /** Returns the ListStore with the font names
                          *
index a27e3906cdd841dcb3cd990f886fcd4bbbf9c45c..a7591608fb7f8b44c397ccb02d6912b579bb7655 100644 (file)
@@ -5175,12 +5175,15 @@ sp_text_toolbox_family_changed (GtkTreeSelection    *selection,
     gtk_widget_grab_focus (GTK_WIDGET(desktop->canvas));
 }
 
+/* This is where execution comes when the contents of the font family box have been completed
+   by the press of the return key */
 void
 sp_text_toolbox_family_entry_activate (GtkEntry     *entry,
                                        GObject      *tbl)
 {
-    const char *family = gtk_entry_get_text (entry);
+    const char *family = gtk_entry_get_text (entry);   // Fetch the requested font family
 
+// Try to match that to a known font. If not, then leave current font alone and remain focused on text box
     try {
         Gtk::TreePath path = Inkscape::FontLister::get_instance()->get_row_for_font (family);
         GtkTreeSelection *selection = GTK_TREE_SELECTION (g_object_get_data (G_OBJECT(tbl), "family-tree-selection"));