From 18b21ab5b2f41a6934999c741f5177f24220406a Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Thu, 26 Nov 2020 20:22:11 +0100 Subject: [PATCH] Another attemp --- src/libnrtype/font-lister.cpp | 7 +++++-- src/ui/toolbar/text-toolbar.cpp | 1 + src/ui/widget/combo-box-entry-tool-item.cpp | 14 ++++++++------ src/ui/widget/combo-box-entry-tool-item.h | 1 + 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp index 7413c65767..9695f7aa8f 100644 --- a/src/libnrtype/font-lister.cpp +++ b/src/libnrtype/font-lister.cpp @@ -1206,8 +1206,10 @@ void font_lister_cell_data_func2(GtkCellLayout * /*cell_layout*/, } Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + static int passes = 0; + gint total = gtk_tree_model_iter_n_children (model, nullptr); int show_sample = prefs->getInt("/tools/text/show_sample_in_list", 1); - if (show_sample) { + if (show_sample && passes > total + 3) { Glib::ustring sample = prefs->getString("/tools/text/font_sample"); gchar* sample_escaped = g_markup_escape_text(sample.data(), -1); @@ -1218,8 +1220,9 @@ void font_lister_cell_data_func2(GtkCellLayout * /*cell_layout*/, markup += sample_escaped; markup += ""; g_free(sample_escaped); + } else { + passes += 1; } - g_object_set(G_OBJECT(cell), "markup", markup.c_str(), NULL); g_free(family); g_free(family_escaped); diff --git a/src/ui/toolbar/text-toolbar.cpp b/src/ui/toolbar/text-toolbar.cpp index e0a3efcf3b..367674e93a 100644 --- a/src/ui/toolbar/text-toolbar.cpp +++ b/src/ui/toolbar/text-toolbar.cpp @@ -257,6 +257,7 @@ TextToolbar::TextToolbar(SPDesktop *desktop) //ink_comboboxentry_action_set_warning_callback( act, sp_text_fontfamily_select_all ); _font_family_item->signal_changed().connect( sigc::mem_fun(*this, &TextToolbar::fontfamily_value_changed) ); + _font_family_item->set_id_column(0); add(*_font_family_item); // Change style of drop-down from menu to list diff --git a/src/ui/widget/combo-box-entry-tool-item.cpp b/src/ui/widget/combo-box-entry-tool-item.cpp index c4f546ac96..3656470d68 100644 --- a/src/ui/widget/combo-box-entry-tool-item.cpp +++ b/src/ui/widget/combo-box-entry-tool-item.cpp @@ -78,7 +78,7 @@ ComboBoxEntryToolItem::ComboBoxEntryToolItem(Glib::ustring name, gchar *entry_name = g_strjoin( nullptr, action_name, "_entry", NULL ); g_free( action_name ); - GtkWidget* comboBoxEntry = gtk_combo_box_new_with_model_and_entry (_model); + GtkWidget* comboBoxEntry = gtk_combo_box_new_with_entry (); gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (comboBoxEntry), 0); // Name it so we can muck with it using an RC file @@ -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(); @@ -155,7 +151,7 @@ ComboBoxEntryToolItem::ComboBoxEntryToolItem(Glib::ustring name, } set_tooltip(_tooltip.c_str()); - + gtk_combo_box_set_model(_combobox,_model); show_all(); } @@ -168,6 +164,12 @@ ComboBoxEntryToolItem::get_active_text() return _text; } +void +ComboBoxEntryToolItem::set_id_column(gint id) +{ + gtk_combo_box_set_id_column (_combobox, id); +} + /* * For the font-family list we need to handle two cases: * Text is in list store: diff --git a/src/ui/widget/combo-box-entry-tool-item.h b/src/ui/widget/combo-box-entry-tool-item.h index c7969e2bfd..53ed44bae2 100644 --- a/src/ui/widget/combo-box-entry-tool-item.h +++ b/src/ui/widget/combo-box-entry-tool-item.h @@ -104,6 +104,7 @@ public: void set_warning( const gchar* warning_cb ); void set_warning_cb(gpointer warning ); void set_tooltip( const gchar* tooltip ); + void set_id_column( gint id ); // Accessor methods decltype(_model) get_model() const {return _model;} -- GitLab