From 5b7b8889dc2b3dbdbbbe8876649989370e431c8d Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sun, 8 Sep 2019 01:12:15 +0200 Subject: Dis allow to emit once instead 3 time on font change --- src/libnrtype/font-lister.cpp | 25 +++++++++++++------------ src/libnrtype/font-lister.h | 6 +++--- 2 files changed, 16 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp index 701c5c3d6..4aedd1641 100644 --- a/src/libnrtype/font-lister.cpp +++ b/src/libnrtype/font-lister.cpp @@ -572,7 +572,7 @@ std::pair FontLister::selection_update() } std::pair ui = ui_from_fontspec(fontspec); - set_font_family(ui.first); + (ui.first); set_font_style(ui.second); #ifdef DEBUG_FONT @@ -601,8 +601,8 @@ void FontLister::set_fontspec(Glib::ustring new_fontspec, bool /*check*/) << " style:" << new_style << std::endl; #endif - set_font_family(new_family, false); - set_font_style(new_style); + set_font_family(new_family, false, false); + set_font_style(new_style, false); emit_update(); } @@ -678,7 +678,7 @@ std::pair FontLister::new_font_family(Glib::ustrin return std::make_pair(new_family, best_style); } -std::pair FontLister::set_font_family(Glib::ustring new_family, bool check_style) +std::pair FontLister::set_font_family(Glib::ustring new_family, bool check_style, bool emit) { #ifdef DEBUG_FONT @@ -697,14 +697,14 @@ std::pair FontLister::set_font_family(Glib::ustrin std::cout << "FontLister::set_font_family: end" << std::endl; std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" << std::endl; #endif - - emit_update(); - + if (emit) { + emit_update(); + } return ui; } -std::pair FontLister::set_font_family(int row, bool check_style) +std::pair FontLister::set_font_family(int row, bool check_style, bool emit) { #ifdef DEBUG_FONT @@ -721,7 +721,7 @@ std::pair FontLister::set_font_family(int row, boo new_family = (*iter)[FontList.family]; } - std::pair ui = set_font_family(new_family, check_style); + std::pair ui = set_font_family(new_family, check_style, emit); #ifdef DEBUG_FONT std::cout << "FontLister::set_font_family( row ): end" << std::endl; @@ -731,7 +731,7 @@ std::pair FontLister::set_font_family(int row, boo } -void FontLister::set_font_style(Glib::ustring new_style) +void FontLister::set_font_style(Glib::ustring new_style, bool emit) { // TODO: Validate input using Pango. If Pango doesn't recognize a style it will @@ -749,8 +749,9 @@ void FontLister::set_font_style(Glib::ustring new_style) std::cout << "FontLister::set_font_style: end" << std::endl; std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" << std::endl; #endif - - emit_update(); + if (emit) { + emit_update(); + } } diff --git a/src/libnrtype/font-lister.h b/src/libnrtype/font-lister.h index 16c34d94c..1a0a47b15 100644 --- a/src/libnrtype/font-lister.h +++ b/src/libnrtype/font-lister.h @@ -217,7 +217,7 @@ public: * Calls new_font_family(). * (For use in text-toolbar where update is immediate.) */ - std::pair set_font_family(Glib::ustring family, bool check_style = true); + std::pair set_font_family(Glib::ustring family, bool check_style = true, bool emit = true); /** * Sets font-family from row in list store. @@ -227,7 +227,7 @@ public: * font-family list correctly. * Calls set_font_family(). */ - std::pair set_font_family(int row, bool check_style = true); + std::pair set_font_family(int row, bool check_style = true, bool emit = true); Glib::ustring get_font_family() { @@ -242,7 +242,7 @@ public: /** * Sets style. Does not validate style for family. */ - void set_font_style(Glib::ustring style); + void set_font_style(Glib::ustring style, bool emit = true); Glib::ustring get_font_style() { -- cgit v1.2.3