diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2013-02-23 11:47:01 +0000 |
|---|---|---|
| committer | tavmjong-free <tavmjong@free.fr> | 2013-02-23 11:47:01 +0000 |
| commit | 59732b62d22fa2b395eb0cb0e5fb079ab71e66cb (patch) | |
| tree | d5b740cc6ccfb195672449f8367c7bc3b467fe58 /src/libnrtype | |
| parent | Null pointer check (should fix Bug #966441 ) (diff) | |
| download | inkscape-59732b62d22fa2b395eb0cb0e5fb079ab71e66cb.tar.gz inkscape-59732b62d22fa2b395eb0cb0e5fb079ab71e66cb.zip | |
Small step towards fixing font-family scrolling issue (bug 1122553).
(bzr r12142)
Diffstat (limited to 'src/libnrtype')
| -rw-r--r-- | src/libnrtype/font-lister.cpp | 67 | ||||
| -rw-r--r-- | src/libnrtype/font-lister.h | 18 |
2 files changed, 85 insertions, 0 deletions
diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp index 2c22ecff0..57a019e96 100644 --- a/src/libnrtype/font-lister.cpp +++ b/src/libnrtype/font-lister.cpp @@ -68,6 +68,7 @@ namespace Inkscape (*treeModelIter)[FontList.onSystem] = true; } } + current_family_row = 0; current_family = "sans-serif"; current_style = "Normal"; current_fontspec = "sans-serif"; // Empty style -> Normal @@ -107,6 +108,18 @@ namespace Inkscape font_list_store->freeze_notify(); + /* Find if current row is in document or system part of list */ + gboolean row_is_system = false; + if( current_family_row > -1 ) { + Gtk::TreePath path; + path.push_back( current_family_row ); + Gtk::TreeModel::iterator iter = font_list_store->get_iter( path ); + if( iter ) { + row_is_system = (*iter)[FontList.onSystem]; + // std::cout << " In: row: " << current_family_row << " " << (*iter)[FontList.family] << std::endl; + } + } + /* Clear all old document font-family entries */ Gtk::TreeModel::iterator iter = font_list_store->get_iter( "0" ); while( iter != font_list_store->children().end() ) { @@ -162,6 +175,32 @@ namespace Inkscape (*treeModelIter)[FontList.onSystem] = false; } + /* Now we do a song and dance to find the correct row as the row corresponding + * to the current_family may have changed. We can't simply search for the + * family name in the list since it can occur twice, once in the document + * font family part and once in the system font family part. Above we determined + * which part it is in. + */ + if( current_family_row > -1 ) { + int start = 0; + if( row_is_system ) start = fontfamilies.size(); + int length = font_list_store->children().size(); + for( int i = 0; i < length; ++i ) { + int row = i + start; + if( row >= length ) row -= length; + Gtk::TreePath path; + path.push_back( row ); + Gtk::TreeModel::iterator iter = font_list_store->get_iter( path ); + if( iter ) { + if( current_family.compare( (*iter)[FontList.family] ) == 0 ) { + current_family_row = row; + break; + } + } + } + } + // std::cout << " Out: row: " << current_family_row << " " << current_family << std::endl; + font_list_store->thaw_notify(); } @@ -456,6 +495,34 @@ namespace Inkscape return ui; } + + std::pair<Glib::ustring, Glib::ustring> + FontLister::set_font_family (int row, gboolean check_style) { + +#ifdef DEBUG_FONT + std::cout << "\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl; + std::cout << "FontLister::set_font_family( row ): " << row << std::endl; +#endif + + current_family_row = row; + Gtk::TreePath path; + path.push_back( row ); + Glib::ustring new_family = current_family; + Gtk::TreeModel::iterator iter = font_list_store->get_iter( path ); + if( iter ) { + current_family = (*iter)[FontList.family]; + } + + std::pair<Glib::ustring, Glib::ustring> ui = set_font_family( new_family, check_style ); + +#ifdef DEBUG_FONT + std::cout << "FontLister::set_font_family( row ): end" << std::endl; + std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" << std::endl; +#endif + return ui; + } + + // void // FontLister::new_font_style (Glib::ustring new_style) { // // Is this needed? What do we do? diff --git a/src/libnrtype/font-lister.h b/src/libnrtype/font-lister.h index 10a269771..aaa996247 100644 --- a/src/libnrtype/font-lister.h +++ b/src/libnrtype/font-lister.h @@ -187,17 +187,34 @@ namespace Inkscape * to find closest style to old current_style. * New font-family and style returned. * Updates current_family and current_style. + * Calls new_font_family(). * (For use in text-toolbar where update is immediate.) */ std::pair<Glib::ustring, Glib::ustring> set_font_family (Glib::ustring family, gboolean check_style = true); + /** Sets font-family from row in list store. + * The row can be used to determine if we are in the + * document or system part of the font-family list. + * This is needed to handle scrolling through the + * font-family list correctly. + * Calls set_font_family(). + */ + std::pair<Glib::ustring, Glib::ustring> + set_font_family (int row, gboolean check_style = true); + Glib::ustring get_font_family () { return current_family; } + int + get_font_family_row () + { + return current_family_row; + } + /* Not Used */ void new_font_style (Glib::ustring style); @@ -280,6 +297,7 @@ namespace Inkscape /** Info for currently selected font (what is shown in the UI). * May include font-family lists and fonts not on system. */ + int current_family_row; Glib::ustring current_family; Glib::ustring current_style; Glib::ustring current_fontspec; |
