diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2011-07-23 06:45:54 +0000 |
|---|---|---|
| committer | tavmjong-free <tavmjong@free.fr> | 2011-07-23 06:45:54 +0000 |
| commit | 4812c9be2179558c274be11608a667d14268e6af (patch) | |
| tree | 8801dcd1c51e065c3d5006efa91e06c4fec5c90d /src | |
| parent | patch by Giacomo Mirabassi for Bug 813366, support for image tag (diff) | |
| download | inkscape-4812c9be2179558c274be11608a667d14268e6af.tar.gz inkscape-4812c9be2179558c274be11608a667d14268e6af.zip | |
Don't flag a comma separted list of fonts in the font-family entry box
as missing on the system if each font in the list is present.
(bzr r10493)
Diffstat (limited to 'src')
| -rw-r--r-- | src/ink-comboboxentry-action.cpp | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/src/ink-comboboxentry-action.cpp b/src/ink-comboboxentry-action.cpp index 5147b04a8..b0fd299bb 100644 --- a/src/ink-comboboxentry-action.cpp +++ b/src/ink-comboboxentry-action.cpp @@ -3,7 +3,8 @@ * Features: * Setting GtkEntryBox width in characters. * Passing a function for formatting cells. - * Displaying a warning if text isn't in list. + * Displaying a warning if entry text isn't in list. + * Check comma separated values in text against list. (Useful for font-family fallbacks.) * Setting names for GtkComboBoxEntry and GtkEntry (actionName_combobox, actionName_entry) * to allow setting resources. * @@ -35,6 +36,7 @@ static GtkWidget* create_menu_item( GtkAction* action ); // Internal static gint get_active_row_from_text( Ink_ComboBoxEntry_Action* action, const gchar* target_text ); +static gint check_comma_separated_text( Ink_ComboBoxEntry_Action* action ); // Callbacks static void combo_box_changed_cb( GtkComboBoxEntry* widget, gpointer data ); @@ -463,7 +465,9 @@ gboolean ink_comboboxentry_action_set_active_text( Ink_ComboBoxEntry_Action* ink gtk_entry_set_text( ink_comboboxentry_action->entry, text ); // Show or hide warning - if( ink_comboboxentry_action->active == -1 && ink_comboboxentry_action->warning != NULL ) { + if( ink_comboboxentry_action->active == -1 && + ink_comboboxentry_action->warning != NULL && + check_comma_separated_text( ink_comboboxentry_action ) ) { { GtkStockItem item; gboolean isStock = gtk_stock_lookup( GTK_STOCK_DIALOG_WARNING, &item ); @@ -607,6 +611,46 @@ gint get_active_row_from_text( Ink_ComboBoxEntry_Action* action, const gchar* ta } +// Checks if all comma separated text fragments are in the list. +// This is useful for checking if all fonts in a font-family fallback +// list are available on the system. +// The return value is set to the number of missing text fragments. +// This routine could also create a Pango Markup string to show which +// fragments are invalid. +// It is envisioned that one can construct a Pango Markup String here +// so that individual text fragments can be flagged as not being in the +// list. +static gint check_comma_separated_text( Ink_ComboBoxEntry_Action* action ) { + + gint ret_val = 0; + + // Parse fallback_list using a comma as deliminator + gchar** tokens = g_strsplit( action->text, ",", 0 ); + + gint i = 0; + gboolean first = TRUE; + while( tokens[i] != NULL ) { + + // Remove any surrounding white space. + g_strstrip( tokens[i] ); + + if( get_active_row_from_text( action, tokens[i] ) == -1 ) { + ret_val += 1; + } + ++i; + } + g_strfreev( tokens ); + + // Pango Markup notes: + // GString* Pango_Markup = g_string_new(""); + // if not present: + // g_string_sprintfa( Pango_Markup, "<span strikethrough=\"true\" strikethrough_color=\"#880000\">%s</span>", tokens[i] ); + // PangoLayout * pl = gtk_entry_get_layout( entry ); + // pango_layout_set_markup( pl, Pango_Markup->str, -1 ); + // g_string_free( Pango_Markup, TRUE ); + + return ret_val; +} // Callbacks --------------------------------------------------- |
