diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2013-02-24 14:31:21 +0000 |
|---|---|---|
| committer | tavmjong-free <tavmjong@free.fr> | 2013-02-24 14:31:21 +0000 |
| commit | ae56bd6349992b95e44850a930440f81538545c5 (patch) | |
| tree | aa7dfe25b7e2c1901a33ff353b176ee22464e009 /src | |
| parent | Fix warnings with autoconf >= 2.68 (diff) | |
| download | inkscape-ae56bd6349992b95e44850a930440f81538545c5.tar.gz inkscape-ae56bd6349992b95e44850a930440f81538545c5.zip | |
Fix for font-family scrolling in text-tool tool-controls (bug 1122553).
(bzr r12149)
Diffstat (limited to 'src')
| -rw-r--r-- | src/ink-comboboxentry-action.cpp | 26 | ||||
| -rw-r--r-- | src/ink-comboboxentry-action.h | 2 | ||||
| -rw-r--r-- | src/libnrtype/font-lister.cpp | 13 | ||||
| -rw-r--r-- | src/widgets/text-toolbar.cpp | 29 |
4 files changed, 48 insertions, 22 deletions
diff --git a/src/ink-comboboxentry-action.cpp b/src/ink-comboboxentry-action.cpp index 8b8ecfa9e..320472347 100644 --- a/src/ink-comboboxentry-action.cpp +++ b/src/ink-comboboxentry-action.cpp @@ -377,7 +377,8 @@ GtkWidget* create_tool_item( GtkAction* action ) ink_comboboxentry_action->combobox = GTK_COMBO_BOX (comboBoxEntry); - gtk_combo_box_set_active( GTK_COMBO_BOX( comboBoxEntry ), ink_comboboxentry_action->active ); + //gtk_combo_box_set_active( GTK_COMBO_BOX( comboBoxEntry ), ink_comboboxentry_action->active ); + gtk_combo_box_set_active( GTK_COMBO_BOX( comboBoxEntry ), 0 ); g_signal_connect( G_OBJECT(comboBoxEntry), "changed", G_CALLBACK(combo_box_changed_cb), action ); @@ -482,13 +483,28 @@ gchar* ink_comboboxentry_action_get_active_text( Ink_ComboBoxEntry_Action* actio return text; } -gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* action, const gchar* text ) { +/* + * For the font-family list we need to handle two cases: + * Text is in list store: + * In this case we use row number as the font-family list can have duplicate + * entries, one in the document font part and one in the system font part. In + * order that scrolling through the list works properly we must distinguish + * between the two. + * Text is not in the list store (i.e. default font-family is not on system): + * In this case we have a row number of -1, and the text must be set by hand. + */ +gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* action, const gchar* text, int row ) { - g_free( action->text ); - action->text = g_strdup( text ); + if( strcmp( action->text, text ) != 0 ) { + g_free( action->text ); + action->text = g_strdup( text ); + } // Get active row or -1 if none - action->active = get_active_row_from_text( action, action->text ); + if( row < 0 ) { + row = get_active_row_from_text( action, action->text ); + } + action->active = row; // Set active row, check that combobox has been created. if( action->combobox ) { diff --git a/src/ink-comboboxentry-action.h b/src/ink-comboboxentry-action.h index 6368dcb6c..a66f0790e 100644 --- a/src/ink-comboboxentry-action.h +++ b/src/ink-comboboxentry-action.h @@ -91,7 +91,7 @@ GtkTreeModel *ink_comboboxentry_action_get_model( Ink_ComboBoxEntry_Action* GtkComboBox *ink_comboboxentry_action_get_comboboxentry( Ink_ComboBoxEntry_Action* action ); gchar* ink_comboboxentry_action_get_active_text( Ink_ComboBoxEntry_Action* action ); -gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* action, const gchar* text ); +gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* action, const gchar* text, int row=-1 ); void ink_comboboxentry_action_set_entry_width( Ink_ComboBoxEntry_Action* action, gint entry_width ); void ink_comboboxentry_action_set_extra_width( Ink_ComboBoxEntry_Action* action, gint extra_width ); diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp index 57a019e96..5e67c5991 100644 --- a/src/libnrtype/font-lister.cpp +++ b/src/libnrtype/font-lister.cpp @@ -10,7 +10,6 @@ #include <glibmm.h> #include <gtkmm/treemodel.h> #include <gtkmm/liststore.h> - #include "font-lister.h" #include "FontFactory.h" @@ -364,10 +363,11 @@ namespace Inkscape set_font_family( ui.first ); #ifdef DEBUG_FONT - std::cout << " canonized: :" << current_fontspec << ":" << std::endl; - std::cout << " system: :" << current_fontspec_system << ":" << std::endl; - std::cout << " family: :" << current_family << ":" << std::endl; - std::cout << " style: :" << current_style << ":" << std::endl; + std::cout << " family_row: :" << current_family_row << ":" << std::endl; + std::cout << " canonized: :" << current_fontspec << ":" << std::endl; + std::cout << " system: :" << current_fontspec_system << ":" << std::endl; + std::cout << " family: :" << current_family << ":" << std::endl; + std::cout << " style: :" << current_style << ":" << std::endl; std::cout << "FontLister::selection_update: exit" << std::endl; std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" << std::endl; #endif @@ -485,6 +485,7 @@ namespace Inkscape current_fontspec_system = system_fontspec( current_fontspec ); #ifdef DEBUG_FONT + std::cout << " family_row: :" << current_family_row << ":" << std::endl; std::cout << " canonized: :" << current_fontspec << ":" << std::endl; std::cout << " system: :" << current_fontspec_system << ":" << std::endl; std::cout << " family: :" << current_family << ":" << std::endl; @@ -510,7 +511,7 @@ namespace Inkscape Glib::ustring new_family = current_family; Gtk::TreeModel::iterator iter = font_list_store->get_iter( path ); if( iter ) { - current_family = (*iter)[FontList.family]; + new_family = (*iter)[FontList.family]; } std::pair<Glib::ustring, Glib::ustring> ui = set_font_family( new_family, check_style ); diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 105ec96f8..cc6d02ea8 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -144,31 +144,36 @@ static void sp_text_fontfamily_value_changed( Ink_ComboBoxEntry_Action *act, GOb // quit if run by the _changed callbacks if (g_object_get_data(G_OBJECT(tbl), "freeze")) { +#ifdef DEBUG_TEXT + std::cout << "sp_text_fontfamily_value_changed: frozen... return" << std::endl; + std::cout << "MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\n" << std::endl; +#endif return; } g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) ); Glib::ustring new_family = ink_comboboxentry_action_get_active_text( act ); -#ifdef DEBUG_TEXT - std::cout << " Old family: " << fontlister->get_font_family() << std::endl; - std::cout << " New family: " << new_family << std::endl; -#endif // TODO: Think about how to handle handle multiple selections. While // the font-family may be the same for all, the styles might be different. + // See: TextEdit::onApply() for example of looping over selected items. Inkscape::FontLister* fontlister = Inkscape::FontLister::get_instance(); +#ifdef DEBUG_TEXT + std::cout << " Old family: " << fontlister->get_font_family() << std::endl; + std::cout << " New family: " << new_family << std::endl; + std::cout << " Old active: " << fontlister->get_font_family_row() << std::endl; + std::cout << " New active: " << act->active << std::endl; +#endif if( new_family.compare( fontlister->get_font_family() ) != 0 ) { - //std::cout << "sp_text_fontfamily_value_changed: from: " << fontlister->get_font_family() - // << " to: " << new_family << std::endl; - std::pair<Glib::ustring,Glib::ustring> ui = fontlister->set_font_family( new_family ); + std::pair<Glib::ustring,Glib::ustring> ui = fontlister->set_font_family( act->active ); // active text set in sp_text_toolbox_selection_changed() SPCSSAttr *css = sp_repr_css_attr_new (); fontlister->set_css( css ); SPDesktop *desktop = SP_ACTIVE_DESKTOP; - sp_desktop_set_style (desktop, css, true, true); + sp_desktop_set_style (desktop, css, true, true); // Results in selection change called twice. sp_repr_css_attr_unref (css); DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, @@ -870,7 +875,7 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ // Update font list, but only if widget already created. if( fontFamilyAction->combobox != NULL ) { - ink_comboboxentry_action_set_active_text( fontFamilyAction, fontlister->get_font_family().c_str() ); + ink_comboboxentry_action_set_active_text( fontFamilyAction, fontlister->get_font_family().c_str(), fontlister->get_font_family_row() ); ink_comboboxentry_action_set_active_text( fontStyleAction, fontlister->get_font_style().c_str() ); } @@ -952,7 +957,12 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ Ink_ComboBoxEntry_Action* fontSizeAction = INK_COMBOBOXENTRY_ACTION( g_object_get_data( tbl, "TextFontSizeAction" ) ); + + // Freeze to ignore callbacks. + //g_object_freeze_notify( G_OBJECT( fontSizeAction->combobox ) ); sp_text_set_sizes(GTK_LIST_STORE(ink_comboboxentry_action_get_model(fontSizeAction)), unit); + //g_object_thaw_notify( G_OBJECT( fontSizeAction->combobox ) ); + ink_comboboxentry_action_set_active_text( fontSizeAction, os.str().c_str() ); Glib::ustring tooltip = Glib::ustring::format(_("Font size"), " (", sp_style_get_css_unit_string(unit), ")"); @@ -1294,7 +1304,6 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje /* Font styles */ { Inkscape::FontLister* fontlister = Inkscape::FontLister::get_instance(); - fontlister->update_font_list( sp_desktop_document( SP_ACTIVE_DESKTOP )); Glib::RefPtr<Gtk::ListStore> store = fontlister->get_style_list(); GtkListStore* model_style = store->gobj(); |
