summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Jeanmougin <marc@jeanmougin.fr>2018-06-14 18:16:30 +0000
committerMarc Jeanmougin <marc@jeanmougin.fr>2018-06-14 18:16:30 +0000
commit3a70f80a739cb2dc9e9ed5b00c2ea10454e94c05 (patch)
treee7d7a510dd21581b047d40235327295737c1b0bc /src
parentMerge branch 'fontmarkup' of gitlab.com:darktrojan/inkscape (diff)
parentIn font list, don't change selection if current font is already selected; oth... (diff)
downloadinkscape-3a70f80a739cb2dc9e9ed5b00c2ea10454e94c05.tar.gz
inkscape-3a70f80a739cb2dc9e9ed5b00c2ea10454e94c05.zip
Merge branch 'fontselection' of gitlab.com:darktrojan/inkscape
Diffstat (limited to 'src')
-rw-r--r--src/libnrtype/font-lister.cpp10
-rw-r--r--src/libnrtype/font-lister.h2
-rw-r--r--src/ui/dialog/text-edit.cpp6
-rw-r--r--src/ui/widget/font-selector.cpp11
4 files changed, 24 insertions, 5 deletions
diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp
index 0c0c1c29c..8c50f47d4 100644
--- a/src/libnrtype/font-lister.cpp
+++ b/src/libnrtype/font-lister.cpp
@@ -919,6 +919,16 @@ Gtk::TreePath FontLister::get_path_for_font(Glib::ustring family)
return font_list_store->get_path(get_row_for_font(family));
}
+bool FontLister::is_path_for_font(Gtk::TreePath path, Glib::ustring family)
+{
+ Gtk::TreeModel::iterator iter = font_list_store->get_iter(path);
+ if (iter) {
+ return familyNamesAreEqual(family, (*iter)[FontList.family]);
+ }
+
+ return false;
+}
+
Gtk::TreeModel::Row FontLister::get_row_for_style(Glib::ustring style)
{
diff --git a/src/libnrtype/font-lister.h b/src/libnrtype/font-lister.h
index c505b3b18..358340c76 100644
--- a/src/libnrtype/font-lister.h
+++ b/src/libnrtype/font-lister.h
@@ -261,6 +261,8 @@ public:
Gtk::TreePath get_path_for_font(Glib::ustring family);
+ bool is_path_for_font(Gtk::TreePath path, Glib::ustring family);
+
Gtk::TreeModel::Row get_row_for_style() { return get_row_for_style (current_style); }
Gtk::TreeModel::Row get_row_for_style(Glib::ustring style);
diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp
index fca65a1ba..5cb0993c6 100644
--- a/src/ui/dialog/text-edit.cpp
+++ b/src/ui/dialog/text-edit.cpp
@@ -74,12 +74,12 @@ TextEdit::TextEdit()
selectChangedConn(),
subselChangedConn(),
selectModifiedConn(),
+ blocked(false),
/*
TRANSLATORS: Test string used in text and font dialog (when no
* text has been entered) to get a preview of the font. Choose
* some representative characters that users of your locale will be
* interested in.*/
- blocked(false),
samplephrase(_("AaBbCcIiPpQq12369$\342\202\254\302\242?.;/()"))
{
@@ -458,6 +458,10 @@ void TextEdit::onApply()
apply_button.set_sensitive ( false );
sp_repr_css_attr_unref (css);
+
+ Inkscape::FontLister* font_lister = Inkscape::FontLister::get_instance();
+ font_lister->update_font_list(SP_ACTIVE_DESKTOP->getDocument());
+
blocked = false;
}
diff --git a/src/ui/widget/font-selector.cpp b/src/ui/widget/font-selector.cpp
index 59b7311c2..132e9bfdf 100644
--- a/src/ui/widget/font-selector.cpp
+++ b/src/ui/widget/font-selector.cpp
@@ -106,8 +106,6 @@ FontSelector::FontSelector (bool with_size, bool with_variations)
// Initialize font family lists. (May already be done.) Should be done on document change.
font_lister->update_font_list(SP_ACTIVE_DESKTOP->getDocument());
-
- font_lister->connectUpdate(sigc::mem_fun(*this, &FontSelector::update_font));
}
void
@@ -167,8 +165,13 @@ FontSelector::update_font ()
path.push_back(0);
}
- family_treeview.set_cursor (path);
- family_treeview.scroll_to_row (path);
+ Gtk::TreePath currentPath;
+ Gtk::TreeViewColumn *currentColumn;
+ family_treeview.get_cursor(currentPath, currentColumn);
+ if (currentPath.empty() || !font_lister->is_path_for_font(currentPath, family)) {
+ family_treeview.set_cursor (path);
+ family_treeview.scroll_to_row (path);
+ }
// Get font-lister style list for selected family
Gtk::TreeModel::Row row = *(family_treeview.get_model()->get_iter (path));