From 0fcaca9f3c3adb22510bfa55765fa80a7ba56259 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Tue, 24 Nov 2020 20:47:17 +0100 Subject: [PATCH 1/2] Fix combo box delay when font sample enabled Basicaly first time load without sample --- src/libnrtype/font-lister.cpp | 10 +++++++++- src/ui/widget/combo-box-entry-tool-item.cpp | 4 ---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp index 7413c65767..14e1a2ddf0 100644 --- a/src/libnrtype/font-lister.cpp +++ b/src/libnrtype/font-lister.cpp @@ -1206,8 +1206,9 @@ void font_lister_cell_data_func2(GtkCellLayout * /*cell_layout*/, } Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + static bool first = true; int show_sample = prefs->getInt("/tools/text/show_sample_in_list", 1); - if (show_sample) { + if (show_sample && !first) { Glib::ustring sample = prefs->getString("/tools/text/font_sample"); gchar* sample_escaped = g_markup_escape_text(sample.data(), -1); @@ -1220,6 +1221,13 @@ void font_lister_cell_data_func2(GtkCellLayout * /*cell_layout*/, g_free(sample_escaped); } + GtkTreeIter *itercopy = gtk_tree_iter_copy(iter); + bool next = gtk_tree_model_iter_next (model, itercopy); + if (show_sample && !next) { + first = false; + } + gtk_tree_iter_free(itercopy); + g_object_set(G_OBJECT(cell), "markup", markup.c_str(), NULL); g_free(family); g_free(family_escaped); diff --git a/src/ui/widget/combo-box-entry-tool-item.cpp b/src/ui/widget/combo-box-entry-tool-item.cpp index c4f546ac96..601854ab83 100644 --- a/src/ui/widget/combo-box-entry-tool-item.cpp +++ b/src/ui/widget/combo-box-entry-tool-item.cpp @@ -106,10 +106,6 @@ ComboBoxEntryToolItem::ComboBoxEntryToolItem(Glib::ustring name, nullptr, nullptr ); } - // FIXME: once gtk3 migration is done this can be removed - // https://bugzilla.gnome.org/show_bug.cgi?id=734915 - gtk_widget_show_all (comboBoxEntry); - // Optionally add formatting... if( _cell_data_func != nullptr ) { GtkCellRenderer *cell = gtk_cell_renderer_text_new(); -- GitLab From 475f643abba7e3e269f3da80cb057a3dd2cfb350 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Tue, 24 Nov 2020 21:22:53 +0000 Subject: [PATCH 2/2] Add @speleo3 improvements, thanks! --- src/libnrtype/font-lister.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp index 14e1a2ddf0..04c95a9a9c 100644 --- a/src/libnrtype/font-lister.cpp +++ b/src/libnrtype/font-lister.cpp @@ -1220,13 +1220,10 @@ void font_lister_cell_data_func2(GtkCellLayout * /*cell_layout*/, markup += ""; g_free(sample_escaped); } - - GtkTreeIter *itercopy = gtk_tree_iter_copy(iter); - bool next = gtk_tree_model_iter_next (model, itercopy); - if (show_sample && !next) { + auto iter_copy = *iter; + if (show_sample && first && !gtk_tree_model_iter_next (model, &iter_copy)) { first = false; } - gtk_tree_iter_free(itercopy); g_object_set(G_OBJECT(cell), "markup", markup.c_str(), NULL); g_free(family); -- GitLab